summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man')
-rw-r--r--src/lib/libcrypto/man/ACCESS_DESCRIPTION_new.3151
-rw-r--r--src/lib/libcrypto/man/AES_encrypt.3173
-rw-r--r--src/lib/libcrypto/man/ASIdentifiers_new.3138
-rw-r--r--src/lib/libcrypto/man/ASN1_BIT_STRING_set.3139
-rw-r--r--src/lib/libcrypto/man/ASN1_INTEGER_get.3428
-rw-r--r--src/lib/libcrypto/man/ASN1_NULL_new.366
-rw-r--r--src/lib/libcrypto/man/ASN1_OBJECT_new.3228
-rw-r--r--src/lib/libcrypto/man/ASN1_PRINTABLE_type.392
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_TABLE_get.394
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_length.3461
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_new.3303
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_print_ex.3241
-rw-r--r--src/lib/libcrypto/man/ASN1_TIME_set.3752
-rw-r--r--src/lib/libcrypto/man/ASN1_TYPE_get.3443
-rw-r--r--src/lib/libcrypto/man/ASN1_UNIVERSALSTRING_to_string.364
-rw-r--r--src/lib/libcrypto/man/ASN1_generate_nconf.3394
-rw-r--r--src/lib/libcrypto/man/ASN1_get_object.3200
-rw-r--r--src/lib/libcrypto/man/ASN1_item_d2i.3492
-rw-r--r--src/lib/libcrypto/man/ASN1_item_digest.371
-rw-r--r--src/lib/libcrypto/man/ASN1_item_new.3126
-rw-r--r--src/lib/libcrypto/man/ASN1_item_pack.384
-rw-r--r--src/lib/libcrypto/man/ASN1_item_sign.3120
-rw-r--r--src/lib/libcrypto/man/ASN1_item_verify.377
-rw-r--r--src/lib/libcrypto/man/ASN1_mbstring_copy.3369
-rw-r--r--src/lib/libcrypto/man/ASN1_parse_dump.3216
-rw-r--r--src/lib/libcrypto/man/ASN1_put_object.3226
-rw-r--r--src/lib/libcrypto/man/ASRange_new.3410
-rw-r--r--src/lib/libcrypto/man/AUTHORITY_KEYID_new.373
-rw-r--r--src/lib/libcrypto/man/BASIC_CONSTRAINTS_new.389
-rw-r--r--src/lib/libcrypto/man/BF_set_key.3269
-rw-r--r--src/lib/libcrypto/man/BIO_accept.3387
-rw-r--r--src/lib/libcrypto/man/BIO_ctrl.3637
-rw-r--r--src/lib/libcrypto/man/BIO_dump.3128
-rw-r--r--src/lib/libcrypto/man/BIO_dup_chain.3141
-rw-r--r--src/lib/libcrypto/man/BIO_f_base64.3148
-rw-r--r--src/lib/libcrypto/man/BIO_f_buffer.3262
-rw-r--r--src/lib/libcrypto/man/BIO_f_cipher.3209
-rw-r--r--src/lib/libcrypto/man/BIO_f_md.3366
-rw-r--r--src/lib/libcrypto/man/BIO_f_null.399
-rw-r--r--src/lib/libcrypto/man/BIO_find_type.3271
-rw-r--r--src/lib/libcrypto/man/BIO_get_data.3406
-rw-r--r--src/lib/libcrypto/man/BIO_get_ex_new_index.3198
-rw-r--r--src/lib/libcrypto/man/BIO_meth_new.3367
-rw-r--r--src/lib/libcrypto/man/BIO_new.3279
-rw-r--r--src/lib/libcrypto/man/BIO_new_CMS.3141
-rw-r--r--src/lib/libcrypto/man/BIO_printf.346
-rw-r--r--src/lib/libcrypto/man/BIO_push.3335
-rw-r--r--src/lib/libcrypto/man/BIO_read.3281
-rw-r--r--src/lib/libcrypto/man/BIO_s_accept.3414
-rw-r--r--src/lib/libcrypto/man/BIO_s_bio.3416
-rw-r--r--src/lib/libcrypto/man/BIO_s_connect.3503
-rw-r--r--src/lib/libcrypto/man/BIO_s_datagram.3573
-rw-r--r--src/lib/libcrypto/man/BIO_s_fd.3290
-rw-r--r--src/lib/libcrypto/man/BIO_s_file.3377
-rw-r--r--src/lib/libcrypto/man/BIO_s_mem.3306
-rw-r--r--src/lib/libcrypto/man/BIO_s_null.3101
-rw-r--r--src/lib/libcrypto/man/BIO_s_socket.3125
-rw-r--r--src/lib/libcrypto/man/BIO_set_callback.3396
-rw-r--r--src/lib/libcrypto/man/BIO_should_retry.3301
-rw-r--r--src/lib/libcrypto/man/BN_CTX_new.3123
-rw-r--r--src/lib/libcrypto/man/BN_CTX_start.3137
-rw-r--r--src/lib/libcrypto/man/BN_add.3646
-rw-r--r--src/lib/libcrypto/man/BN_add_word.3182
-rw-r--r--src/lib/libcrypto/man/BN_bn2bin.3388
-rw-r--r--src/lib/libcrypto/man/BN_cmp.3169
-rw-r--r--src/lib/libcrypto/man/BN_copy.3165
-rw-r--r--src/lib/libcrypto/man/BN_generate_prime.3375
-rw-r--r--src/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3153
-rw-r--r--src/lib/libcrypto/man/BN_kronecker.357
-rw-r--r--src/lib/libcrypto/man/BN_mod_inverse.3126
-rw-r--r--src/lib/libcrypto/man/BN_mod_mul_montgomery.3271
-rw-r--r--src/lib/libcrypto/man/BN_mod_sqrt.3111
-rw-r--r--src/lib/libcrypto/man/BN_new.3165
-rw-r--r--src/lib/libcrypto/man/BN_num_bytes.3175
-rw-r--r--src/lib/libcrypto/man/BN_rand.3146
-rw-r--r--src/lib/libcrypto/man/BN_set_bit.3216
-rw-r--r--src/lib/libcrypto/man/BN_set_flags.3160
-rw-r--r--src/lib/libcrypto/man/BN_set_negative.363
-rw-r--r--src/lib/libcrypto/man/BN_swap.3148
-rw-r--r--src/lib/libcrypto/man/BN_zero.3174
-rw-r--r--src/lib/libcrypto/man/BUF_MEM_new.3153
-rw-r--r--src/lib/libcrypto/man/CMAC_Init.3273
-rw-r--r--src/lib/libcrypto/man/CMS_ContentInfo_new.3135
-rw-r--r--src/lib/libcrypto/man/CMS_add0_cert.3222
-rw-r--r--src/lib/libcrypto/man/CMS_add1_recipient_cert.3200
-rw-r--r--src/lib/libcrypto/man/CMS_add1_signer.3249
-rw-r--r--src/lib/libcrypto/man/CMS_compress.3170
-rw-r--r--src/lib/libcrypto/man/CMS_decrypt.3226
-rw-r--r--src/lib/libcrypto/man/CMS_encrypt.3191
-rw-r--r--src/lib/libcrypto/man/CMS_final.3101
-rw-r--r--src/lib/libcrypto/man/CMS_get0_RecipientInfos.3328
-rw-r--r--src/lib/libcrypto/man/CMS_get0_SignerInfos.3214
-rw-r--r--src/lib/libcrypto/man/CMS_get0_type.3226
-rw-r--r--src/lib/libcrypto/man/CMS_get1_ReceiptRequest.3198
-rw-r--r--src/lib/libcrypto/man/CMS_sign.3246
-rw-r--r--src/lib/libcrypto/man/CMS_sign_receipt.3119
-rw-r--r--src/lib/libcrypto/man/CMS_signed_add1_attr.3360
-rw-r--r--src/lib/libcrypto/man/CMS_uncompress.3115
-rw-r--r--src/lib/libcrypto/man/CMS_verify.3230
-rw-r--r--src/lib/libcrypto/man/CMS_verify_receipt.3110
-rw-r--r--src/lib/libcrypto/man/CONF_modules_free.3100
-rw-r--r--src/lib/libcrypto/man/CONF_modules_load_file.3282
-rw-r--r--src/lib/libcrypto/man/CRYPTO_lock.3121
-rw-r--r--src/lib/libcrypto/man/CRYPTO_memcmp.395
-rw-r--r--src/lib/libcrypto/man/CRYPTO_set_ex_data.3564
-rw-r--r--src/lib/libcrypto/man/CRYPTO_set_mem_functions.396
-rw-r--r--src/lib/libcrypto/man/ChaCha.3253
-rw-r--r--src/lib/libcrypto/man/DES_set_key.3787
-rw-r--r--src/lib/libcrypto/man/DH_generate_key.3122
-rw-r--r--src/lib/libcrypto/man/DH_generate_parameters.3241
-rw-r--r--src/lib/libcrypto/man/DH_get0_pqg.3342
-rw-r--r--src/lib/libcrypto/man/DH_get_ex_new_index.399
-rw-r--r--src/lib/libcrypto/man/DH_new.3133
-rw-r--r--src/lib/libcrypto/man/DH_set_method.3195
-rw-r--r--src/lib/libcrypto/man/DH_size.397
-rw-r--r--src/lib/libcrypto/man/DIST_POINT_new.3154
-rw-r--r--src/lib/libcrypto/man/DSA_SIG_new.3141
-rw-r--r--src/lib/libcrypto/man/DSA_do_sign.3119
-rw-r--r--src/lib/libcrypto/man/DSA_dup_DH.388
-rw-r--r--src/lib/libcrypto/man/DSA_generate_key.384
-rw-r--r--src/lib/libcrypto/man/DSA_generate_parameters_ex.3174
-rw-r--r--src/lib/libcrypto/man/DSA_get0_pqg.3320
-rw-r--r--src/lib/libcrypto/man/DSA_get_ex_new_index.398
-rw-r--r--src/lib/libcrypto/man/DSA_meth_new.3230
-rw-r--r--src/lib/libcrypto/man/DSA_new.3141
-rw-r--r--src/lib/libcrypto/man/DSA_set_method.3178
-rw-r--r--src/lib/libcrypto/man/DSA_sign.3173
-rw-r--r--src/lib/libcrypto/man/DSA_size.3122
-rw-r--r--src/lib/libcrypto/man/ECDH_compute_key.388
-rw-r--r--src/lib/libcrypto/man/ECDSA_SIG_new.3452
-rw-r--r--src/lib/libcrypto/man/EC_GROUP_copy.3492
-rw-r--r--src/lib/libcrypto/man/EC_GROUP_new.3353
-rw-r--r--src/lib/libcrypto/man/EC_KEY_METHOD_new.3320
-rw-r--r--src/lib/libcrypto/man/EC_KEY_new.3532
-rw-r--r--src/lib/libcrypto/man/EC_POINT_add.3216
-rw-r--r--src/lib/libcrypto/man/EC_POINT_new.3455
-rw-r--r--src/lib/libcrypto/man/ENGINE_new.3174
-rw-r--r--src/lib/libcrypto/man/ERR.3152
-rw-r--r--src/lib/libcrypto/man/ERR_GET_LIB.3126
-rw-r--r--src/lib/libcrypto/man/ERR_asprintf_error_data.355
-rw-r--r--src/lib/libcrypto/man/ERR_clear_error.370
-rw-r--r--src/lib/libcrypto/man/ERR_error_string.3176
-rw-r--r--src/lib/libcrypto/man/ERR_get_error.3191
-rw-r--r--src/lib/libcrypto/man/ERR_load_crypto_strings.3150
-rw-r--r--src/lib/libcrypto/man/ERR_load_strings.3116
-rw-r--r--src/lib/libcrypto/man/ERR_print_errors.3122
-rw-r--r--src/lib/libcrypto/man/ERR_put_error.3125
-rw-r--r--src/lib/libcrypto/man/ERR_remove_state.3108
-rw-r--r--src/lib/libcrypto/man/ERR_set_mark.386
-rw-r--r--src/lib/libcrypto/man/ESS_SIGNING_CERT_new.3117
-rw-r--r--src/lib/libcrypto/man/EVP_AEAD_CTX_init.3411
-rw-r--r--src/lib/libcrypto/man/EVP_BytesToKey.3145
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3261
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3146
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3209
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_set_flags.3233
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_do_all.3211
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_meth_new.3388
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_nid.3306
-rw-r--r--src/lib/libcrypto/man/EVP_DigestInit.3606
-rw-r--r--src/lib/libcrypto/man/EVP_DigestSignInit.3243
-rw-r--r--src/lib/libcrypto/man/EVP_DigestVerifyInit.3223
-rw-r--r--src/lib/libcrypto/man/EVP_EncodeInit.3334
-rw-r--r--src/lib/libcrypto/man/EVP_EncryptInit.3813
-rw-r--r--src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3279
-rw-r--r--src/lib/libcrypto/man/EVP_MD_nid.3315
-rw-r--r--src/lib/libcrypto/man/EVP_OpenInit.3157
-rw-r--r--src/lib/libcrypto/man/EVP_PKCS82PKEY.360
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_ctrl.3582
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_get_operation.3137
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_new.3183
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_set_hkdf_md.3258
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_set_tls1_prf_md.3171
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3242
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_cmp.3179
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_decrypt.3175
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_derive.3254
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_encrypt.3183
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.3128
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_keygen.3369
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_new.3347
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_new_CMAC_key.3159
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_print_private.3129
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3498
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_sign.3190
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_size.3224
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_verify.3167
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_verify_recover.3188
-rw-r--r--src/lib/libcrypto/man/EVP_SealInit.3191
-rw-r--r--src/lib/libcrypto/man/EVP_SignInit.3211
-rw-r--r--src/lib/libcrypto/man/EVP_VerifyInit.3205
-rw-r--r--src/lib/libcrypto/man/EVP_aes_128_cbc.3304
-rw-r--r--src/lib/libcrypto/man/EVP_aes_128_ccm.3573
-rw-r--r--src/lib/libcrypto/man/EVP_aes_128_gcm.3254
-rw-r--r--src/lib/libcrypto/man/EVP_camellia_128_cbc.3151
-rw-r--r--src/lib/libcrypto/man/EVP_chacha20.3292
-rw-r--r--src/lib/libcrypto/man/EVP_des_cbc.3230
-rw-r--r--src/lib/libcrypto/man/EVP_rc2_cbc.3201
-rw-r--r--src/lib/libcrypto/man/EVP_rc4.3109
-rw-r--r--src/lib/libcrypto/man/EVP_sha1.3120
-rw-r--r--src/lib/libcrypto/man/EVP_sha3_224.391
-rw-r--r--src/lib/libcrypto/man/EVP_sm3.382
-rw-r--r--src/lib/libcrypto/man/EVP_sm4_cbc.382
-rw-r--r--src/lib/libcrypto/man/EXTENDED_KEY_USAGE_new.384
-rw-r--r--src/lib/libcrypto/man/GENERAL_NAME_new.3165
-rw-r--r--src/lib/libcrypto/man/HMAC.3324
-rw-r--r--src/lib/libcrypto/man/IPAddressRange_new.3525
-rw-r--r--src/lib/libcrypto/man/MD5.3201
-rw-r--r--src/lib/libcrypto/man/Makefile436
-rw-r--r--src/lib/libcrypto/man/NAME_CONSTRAINTS_new.3100
-rw-r--r--src/lib/libcrypto/man/OBJ_NAME_add.3307
-rw-r--r--src/lib/libcrypto/man/OBJ_create.3249
-rw-r--r--src/lib/libcrypto/man/OBJ_find_sigid_algs.389
-rw-r--r--src/lib/libcrypto/man/OBJ_nid2obj.3521
-rw-r--r--src/lib/libcrypto/man/OCSP_CRLID_new.3113
-rw-r--r--src/lib/libcrypto/man/OCSP_REQUEST_new.3329
-rw-r--r--src/lib/libcrypto/man/OCSP_SERVICELOC_new.3109
-rw-r--r--src/lib/libcrypto/man/OCSP_cert_to_id.3239
-rw-r--r--src/lib/libcrypto/man/OCSP_request_add1_nonce.3163
-rw-r--r--src/lib/libcrypto/man/OCSP_resp_find_status.3494
-rw-r--r--src/lib/libcrypto/man/OCSP_response_status.3308
-rw-r--r--src/lib/libcrypto/man/OCSP_sendreq_new.3323
-rw-r--r--src/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3281
-rw-r--r--src/lib/libcrypto/man/OPENSSL_cleanse.342
-rw-r--r--src/lib/libcrypto/man/OPENSSL_config.3152
-rw-r--r--src/lib/libcrypto/man/OPENSSL_init_crypto.3115
-rw-r--r--src/lib/libcrypto/man/OPENSSL_load_builtin_modules.3101
-rw-r--r--src/lib/libcrypto/man/OPENSSL_malloc.3101
-rw-r--r--src/lib/libcrypto/man/OPENSSL_sk_new.3553
-rw-r--r--src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3152
-rw-r--r--src/lib/libcrypto/man/PEM_ASN1_read.3172
-rw-r--r--src/lib/libcrypto/man/PEM_X509_INFO_read.3189
-rw-r--r--src/lib/libcrypto/man/PEM_bytes_read_bio.3184
-rw-r--r--src/lib/libcrypto/man/PEM_read.3416
-rw-r--r--src/lib/libcrypto/man/PEM_read_bio_PrivateKey.31335
-rw-r--r--src/lib/libcrypto/man/PEM_write_bio_CMS_stream.395
-rw-r--r--src/lib/libcrypto/man/PEM_write_bio_PKCS7_stream.390
-rw-r--r--src/lib/libcrypto/man/PKCS12_SAFEBAG_new.3104
-rw-r--r--src/lib/libcrypto/man/PKCS12_create.3188
-rw-r--r--src/lib/libcrypto/man/PKCS12_new.399
-rw-r--r--src/lib/libcrypto/man/PKCS12_newpass.3155
-rw-r--r--src/lib/libcrypto/man/PKCS12_parse.3145
-rw-r--r--src/lib/libcrypto/man/PKCS5_PBKDF2_HMAC.3163
-rw-r--r--src/lib/libcrypto/man/PKCS7_add_attribute.3365
-rw-r--r--src/lib/libcrypto/man/PKCS7_dataFinal.3158
-rw-r--r--src/lib/libcrypto/man/PKCS7_dataInit.3226
-rw-r--r--src/lib/libcrypto/man/PKCS7_decrypt.3118
-rw-r--r--src/lib/libcrypto/man/PKCS7_encrypt.3169
-rw-r--r--src/lib/libcrypto/man/PKCS7_final.3202
-rw-r--r--src/lib/libcrypto/man/PKCS7_get_signer_info.362
-rw-r--r--src/lib/libcrypto/man/PKCS7_new.3269
-rw-r--r--src/lib/libcrypto/man/PKCS7_set_content.3120
-rw-r--r--src/lib/libcrypto/man/PKCS7_set_type.3119
-rw-r--r--src/lib/libcrypto/man/PKCS7_sign.3251
-rw-r--r--src/lib/libcrypto/man/PKCS7_sign_add_signer.3187
-rw-r--r--src/lib/libcrypto/man/PKCS7_verify.3252
-rw-r--r--src/lib/libcrypto/man/PKCS8_PRIV_KEY_INFO_new.365
-rw-r--r--src/lib/libcrypto/man/PKCS8_pkey_set0.3159
-rw-r--r--src/lib/libcrypto/man/PKEY_USAGE_PERIOD_new.374
-rw-r--r--src/lib/libcrypto/man/POLICYINFO_new.3218
-rw-r--r--src/lib/libcrypto/man/RAND_add.373
-rw-r--r--src/lib/libcrypto/man/RAND_bytes.3108
-rw-r--r--src/lib/libcrypto/man/RAND_load_file.3119
-rw-r--r--src/lib/libcrypto/man/RAND_set_rand_method.355
-rw-r--r--src/lib/libcrypto/man/RC2_encrypt.3195
-rw-r--r--src/lib/libcrypto/man/RC4.3126
-rw-r--r--src/lib/libcrypto/man/RIPEMD160.3154
-rw-r--r--src/lib/libcrypto/man/RSA_PSS_PARAMS_new.360
-rw-r--r--src/lib/libcrypto/man/RSA_blinding_on.397
-rw-r--r--src/lib/libcrypto/man/RSA_check_key.3130
-rw-r--r--src/lib/libcrypto/man/RSA_generate_key.3164
-rw-r--r--src/lib/libcrypto/man/RSA_get0_key.3460
-rw-r--r--src/lib/libcrypto/man/RSA_get_ex_new_index.3382
-rw-r--r--src/lib/libcrypto/man/RSA_meth_new.3606
-rw-r--r--src/lib/libcrypto/man/RSA_new.3248
-rw-r--r--src/lib/libcrypto/man/RSA_padding_add_PKCS1_type_1.3236
-rw-r--r--src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3402
-rw-r--r--src/lib/libcrypto/man/RSA_print.3144
-rw-r--r--src/lib/libcrypto/man/RSA_private_encrypt.3150
-rw-r--r--src/lib/libcrypto/man/RSA_public_encrypt.3247
-rw-r--r--src/lib/libcrypto/man/RSA_security_bits.3137
-rw-r--r--src/lib/libcrypto/man/RSA_set_method.3252
-rw-r--r--src/lib/libcrypto/man/RSA_sign.3147
-rw-r--r--src/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3131
-rw-r--r--src/lib/libcrypto/man/RSA_size.397
-rw-r--r--src/lib/libcrypto/man/SHA1.3285
-rw-r--r--src/lib/libcrypto/man/SMIME_crlf_copy.396
-rw-r--r--src/lib/libcrypto/man/SMIME_read_ASN1.3124
-rw-r--r--src/lib/libcrypto/man/SMIME_read_CMS.3132
-rw-r--r--src/lib/libcrypto/man/SMIME_read_PKCS7.3150
-rw-r--r--src/lib/libcrypto/man/SMIME_text.357
-rw-r--r--src/lib/libcrypto/man/SMIME_write_ASN1.3163
-rw-r--r--src/lib/libcrypto/man/SMIME_write_CMS.3133
-rw-r--r--src/lib/libcrypto/man/SMIME_write_PKCS7.3184
-rw-r--r--src/lib/libcrypto/man/STACK_OF.3207
-rw-r--r--src/lib/libcrypto/man/TS_REQ_new.3182
-rw-r--r--src/lib/libcrypto/man/UI_create_method.3284
-rw-r--r--src/lib/libcrypto/man/UI_get_string_type.3281
-rw-r--r--src/lib/libcrypto/man/UI_new.3529
-rw-r--r--src/lib/libcrypto/man/X25519.3211
-rw-r--r--src/lib/libcrypto/man/X509V3_EXT_get_nid.394
-rw-r--r--src/lib/libcrypto/man/X509V3_EXT_print.3195
-rw-r--r--src/lib/libcrypto/man/X509V3_extensions_print.3100
-rw-r--r--src/lib/libcrypto/man/X509V3_get_d2i.3507
-rw-r--r--src/lib/libcrypto/man/X509V3_parse_list.3101
-rw-r--r--src/lib/libcrypto/man/X509_ALGOR_dup.3297
-rw-r--r--src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3136
-rw-r--r--src/lib/libcrypto/man/X509_ATTRIBUTE_new.3180
-rw-r--r--src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3267
-rw-r--r--src/lib/libcrypto/man/X509_CINF_new.3117
-rw-r--r--src/lib/libcrypto/man/X509_CRL_get0_by_serial.3179
-rw-r--r--src/lib/libcrypto/man/X509_CRL_new.3143
-rw-r--r--src/lib/libcrypto/man/X509_CRL_print.3113
-rw-r--r--src/lib/libcrypto/man/X509_EXTENSION_set_object.3348
-rw-r--r--src/lib/libcrypto/man/X509_INFO_new.372
-rw-r--r--src/lib/libcrypto/man/X509_LOOKUP_hash_dir.3188
-rw-r--r--src/lib/libcrypto/man/X509_LOOKUP_new.3460
-rw-r--r--src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3391
-rw-r--r--src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3283
-rw-r--r--src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3265
-rw-r--r--src/lib/libcrypto/man/X509_NAME_hash.397
-rw-r--r--src/lib/libcrypto/man/X509_NAME_new.3103
-rw-r--r--src/lib/libcrypto/man/X509_NAME_print_ex.3260
-rw-r--r--src/lib/libcrypto/man/X509_OBJECT_get0_X509.3252
-rw-r--r--src/lib/libcrypto/man/X509_PKEY_new.392
-rw-r--r--src/lib/libcrypto/man/X509_PUBKEY_new.3401
-rw-r--r--src/lib/libcrypto/man/X509_PURPOSE_set.3295
-rw-r--r--src/lib/libcrypto/man/X509_REQ_add1_attr.3172
-rw-r--r--src/lib/libcrypto/man/X509_REQ_add_extensions.3113
-rw-r--r--src/lib/libcrypto/man/X509_REQ_new.3145
-rw-r--r--src/lib/libcrypto/man/X509_REQ_print_ex.3173
-rw-r--r--src/lib/libcrypto/man/X509_REVOKED_new.3213
-rw-r--r--src/lib/libcrypto/man/X509_SIG_get0.390
-rw-r--r--src/lib/libcrypto/man/X509_SIG_new.368
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_get_error.3591
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3153
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_new.3365
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3326
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_set_verify.3256
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3309
-rw-r--r--src/lib/libcrypto/man/X509_STORE_get_by_subject.3246
-rw-r--r--src/lib/libcrypto/man/X509_STORE_load_locations.3188
-rw-r--r--src/lib/libcrypto/man/X509_STORE_new.3145
-rw-r--r--src/lib/libcrypto/man/X509_STORE_set1_param.3268
-rw-r--r--src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3121
-rw-r--r--src/lib/libcrypto/man/X509_VERIFY_PARAM_new.3306
-rw-r--r--src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3736
-rw-r--r--src/lib/libcrypto/man/X509_add1_trust_object.399
-rw-r--r--src/lib/libcrypto/man/X509_check_ca.3117
-rw-r--r--src/lib/libcrypto/man/X509_check_host.3246
-rw-r--r--src/lib/libcrypto/man/X509_check_issued.3109
-rw-r--r--src/lib/libcrypto/man/X509_check_private_key.373
-rw-r--r--src/lib/libcrypto/man/X509_check_purpose.3431
-rw-r--r--src/lib/libcrypto/man/X509_cmp.3235
-rw-r--r--src/lib/libcrypto/man/X509_cmp_time.3200
-rw-r--r--src/lib/libcrypto/man/X509_digest.3155
-rw-r--r--src/lib/libcrypto/man/X509_find_by_subject.369
-rw-r--r--src/lib/libcrypto/man/X509_get0_notBefore.3264
-rw-r--r--src/lib/libcrypto/man/X509_get0_signature.3280
-rw-r--r--src/lib/libcrypto/man/X509_get1_email.3123
-rw-r--r--src/lib/libcrypto/man/X509_get_extension_flags.3234
-rw-r--r--src/lib/libcrypto/man/X509_get_pubkey.3296
-rw-r--r--src/lib/libcrypto/man/X509_get_pubkey_parameters.399
-rw-r--r--src/lib/libcrypto/man/X509_get_serialNumber.3129
-rw-r--r--src/lib/libcrypto/man/X509_get_subject_name.3189
-rw-r--r--src/lib/libcrypto/man/X509_get_version.3162
-rw-r--r--src/lib/libcrypto/man/X509_keyid_set1.3171
-rw-r--r--src/lib/libcrypto/man/X509_load_cert_file.3133
-rw-r--r--src/lib/libcrypto/man/X509_new.3279
-rw-r--r--src/lib/libcrypto/man/X509_ocspid_print.358
-rw-r--r--src/lib/libcrypto/man/X509_print_ex.3279
-rw-r--r--src/lib/libcrypto/man/X509_sign.3209
-rw-r--r--src/lib/libcrypto/man/X509_signature_dump.385
-rw-r--r--src/lib/libcrypto/man/X509_verify_cert.393
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_add_inherit.3475
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_get_range.3132
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_inherits.3104
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_subset.3176
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_validate_path.3203
-rw-r--r--src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3327
-rw-r--r--src/lib/libcrypto/man/X509v3_get_ext_by_NID.3408
-rw-r--r--src/lib/libcrypto/man/a2d_ASN1_OBJECT.384
-rw-r--r--src/lib/libcrypto/man/a2i_ipadd.3136
-rw-r--r--src/lib/libcrypto/man/bn_dump.3415
-rw-r--r--src/lib/libcrypto/man/crypto.3419
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_NULL.392
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_OBJECT.3164
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3461
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_SEQUENCE_ANY.398
-rw-r--r--src/lib/libcrypto/man/d2i_AUTHORITY_KEYID.375
-rw-r--r--src/lib/libcrypto/man/d2i_BASIC_CONSTRAINTS.3106
-rw-r--r--src/lib/libcrypto/man/d2i_CMS_ContentInfo.3128
-rw-r--r--src/lib/libcrypto/man/d2i_DHparams.399
-rw-r--r--src/lib/libcrypto/man/d2i_DIST_POINT.3201
-rw-r--r--src/lib/libcrypto/man/d2i_DSAPublicKey.3412
-rw-r--r--src/lib/libcrypto/man/d2i_ECPKParameters.3467
-rw-r--r--src/lib/libcrypto/man/d2i_ESS_SIGNING_CERT.3118
-rw-r--r--src/lib/libcrypto/man/d2i_GENERAL_NAME.3160
-rw-r--r--src/lib/libcrypto/man/d2i_OCSP_REQUEST.3181
-rw-r--r--src/lib/libcrypto/man/d2i_OCSP_RESPONSE.3248
-rw-r--r--src/lib/libcrypto/man/d2i_PKCS12.3202
-rw-r--r--src/lib/libcrypto/man/d2i_PKCS7.3341
-rw-r--r--src/lib/libcrypto/man/d2i_PKCS8PrivateKey_bio.3172
-rw-r--r--src/lib/libcrypto/man/d2i_PKCS8_PRIV_KEY_INFO.3127
-rw-r--r--src/lib/libcrypto/man/d2i_PKEY_USAGE_PERIOD.374
-rw-r--r--src/lib/libcrypto/man/d2i_POLICYINFO.3165
-rw-r--r--src/lib/libcrypto/man/d2i_PrivateKey.3312
-rw-r--r--src/lib/libcrypto/man/d2i_RSAPublicKey.3389
-rw-r--r--src/lib/libcrypto/man/d2i_TS_REQ.3333
-rw-r--r--src/lib/libcrypto/man/d2i_X509.3362
-rw-r--r--src/lib/libcrypto/man/d2i_X509_ALGOR.389
-rw-r--r--src/lib/libcrypto/man/d2i_X509_ATTRIBUTE.376
-rw-r--r--src/lib/libcrypto/man/d2i_X509_CRL.3148
-rw-r--r--src/lib/libcrypto/man/d2i_X509_EXTENSION.3104
-rw-r--r--src/lib/libcrypto/man/d2i_X509_NAME.3213
-rw-r--r--src/lib/libcrypto/man/d2i_X509_REQ.3151
-rw-r--r--src/lib/libcrypto/man/d2i_X509_SIG.3159
-rw-r--r--src/lib/libcrypto/man/des_read_pw.3197
-rw-r--r--src/lib/libcrypto/man/evp.3249
-rw-r--r--src/lib/libcrypto/man/i2a_ASN1_STRING.3255
-rw-r--r--src/lib/libcrypto/man/i2d_CMS_bio_stream.395
-rw-r--r--src/lib/libcrypto/man/i2d_PKCS7_bio_stream.394
-rw-r--r--src/lib/libcrypto/man/lh_new.3554
-rw-r--r--src/lib/libcrypto/man/openssl.cnf.5361
-rw-r--r--src/lib/libcrypto/man/s2i_ASN1_INTEGER.3215
-rw-r--r--src/lib/libcrypto/man/v2i_ASN1_BIT_STRING.3125
-rw-r--r--src/lib/libcrypto/man/x509_verify.3221
-rw-r--r--src/lib/libcrypto/man/x509v3.cnf.5738
428 files changed, 0 insertions, 96142 deletions
diff --git a/src/lib/libcrypto/man/ACCESS_DESCRIPTION_new.3 b/src/lib/libcrypto/man/ACCESS_DESCRIPTION_new.3
deleted file mode 100644
index 15156ffca3..0000000000
--- a/src/lib/libcrypto/man/ACCESS_DESCRIPTION_new.3
+++ /dev/null
@@ -1,151 +0,0 @@
1.\" $OpenBSD: ACCESS_DESCRIPTION_new.3,v 1.6 2022/03/31 17:27:16 naddy Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 31 2022 $
18.Dt ACCESS_DESCRIPTION_NEW 3
19.Os
20.Sh NAME
21.Nm ACCESS_DESCRIPTION_new ,
22.Nm ACCESS_DESCRIPTION_free ,
23.Nm AUTHORITY_INFO_ACCESS_new ,
24.Nm AUTHORITY_INFO_ACCESS_free
25.Nd X.509 information access extensions
26.Sh SYNOPSIS
27.In openssl/x509v3.h
28.Ft ACCESS_DESCRIPTION *
29.Fn ACCESS_DESCRIPTION_new void
30.Ft void
31.Fn ACCESS_DESCRIPTION_free "ACCESS_DESCRIPTION *ad"
32.Ft AUTHORITY_INFO_ACCESS
33.Fn AUTHORITY_INFO_ACCESS_new void
34.Ft void
35.Fn AUTHORITY_INFO_ACCESS_free "AUTHORITY_INFO_ACCESS *aia"
36.Sh DESCRIPTION
37Using the information access extensions, certificates and certificate
38revocation lists can point to auxiliary information and services
39available online, for example online validation services or CA
40policy data.
41.Pp
42.Fn ACCESS_DESCRIPTION_new
43allocates and initializes an empty
44.Vt ACCESS_DESCRIPTION
45object, representing an ASN.1
46.Vt AccessDescription
47structure defined in RFC 5280 section 4.2.2.1.
48It can hold a pointer to a
49.Vt GENERAL_NAME
50object documented in
51.Xr GENERAL_NAME_new 3
52and an access method identifier.
53.Fn ACCESS_DESCRIPTION_free
54frees
55.Fa ad .
56.Pp
57The access method identifier is somewhat misnamed; it identifies
58the type and format of the information provided.
59How to access that information is often obvious from the
60.Vt GENERAL_NAME
61which may for example include a uniform resource identifier.
62.Pp
63Four standard access method identifiers are defined in RFC 5280:
64.Bl -bullet
65.It
66.Qq id-ad-caIssuers
67can occur in the authority information access extension of certificates
68and certificate revocation lists and provides access to certificates
69issued to the CA that issued the certificate, or provides access
70to certificates used for signing the CRL, in order to help constructing
71a certification path.
72.It
73.Qq id-ad-ocsp
74can occur in the authority information access extension of certificates
75and provides access to revocation information via the Online
76Certificate Status Protocol (OCSP) defined in RFC 6960.
77.It
78.Qq id-ad-caRepository
79can occur in the subject information access extension of CA
80certificates and provides access to an online repository of
81certificates issued by the CA.
82.It
83.Qq id-ad-timeStamping
84can occur in the subject information access extension of end entity
85certificates and indicates that the subject offers timestamping
86services using the Time Stamp Protocol defined in RFC 3161.
87.El
88.Pp
89.Fn AUTHORITY_INFO_ACCESS_new
90allocates and initializes an empty
91.Vt AUTHORITY_INFO_ACCESS
92object, which is a
93.Vt STACK_OF(ACCESS_DESCRIPTION)
94and represents an ASN.1
95.Vt AuthorityInfoAccessSyntax
96structure defined in RFC 5280 section 4.2.2.1.
97It can be used for the authority information access extension of
98certificates and certificate revocation lists and for the subject
99information access extension of certificates.
100.Fn AUTHORITY_INFO_ACCESS_free
101frees
102.Fa aia .
103.Sh RETURN VALUES
104.Fn ACCESS_DESCRIPTION_new
105and
106.Fn AUTHORITY_INFO_ACCESS_new
107return the new
108.Vt ACCESS_DESCRIPTION
109or
110.Vt AUTHORITY_INFO_ACCESS
111object, respectively, or
112.Dv NULL
113if an error occurs.
114.Sh SEE ALSO
115.Xr d2i_ACCESS_DESCRIPTION 3 ,
116.Xr DIST_POINT_new 3 ,
117.Xr GENERAL_NAME_new 3 ,
118.Xr OCSP_REQUEST_new 3 ,
119.Xr TS_REQ_new 3 ,
120.Xr X509_CRL_new 3 ,
121.Xr X509_EXTENSION_new 3 ,
122.Xr X509_new 3
123.Sh STANDARDS
124These extensions are only defined in the following RFC and not
125specified in the underlying X.509 standard.
126.Pp
127RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
128Certificate Revocation List (CRL) Profile:
129.Bl -dash -compact
130.It
131section 4.2.2.1: Certificate Extensions: Authority Information Access
132.It
133section 4.2.2.2: Certificate Extensions: Subject Information Access
134.It
135section 5.2.7: CRL Extensions: Authority Information Access
136.El
137.Pp
138Regarding OCSP and TSP, see:
139.Pp
140RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
141Status Protocol
142.Pp
143RFC 3161: Internet X.509 Public Key Infrastructure Time-Stamp Protocol
144.Sh HISTORY
145.Fn ACCESS_DESCRIPTION_new ,
146.Fn ACCESS_DESCRIPTION_free ,
147.Fn AUTHORITY_INFO_ACCESS_new ,
148and
149.Fn AUTHORITY_INFO_ACCESS_free
150first appeared in OpenSSL 0.9.5 and have been available since
151.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/AES_encrypt.3 b/src/lib/libcrypto/man/AES_encrypt.3
deleted file mode 100644
index f022848a61..0000000000
--- a/src/lib/libcrypto/man/AES_encrypt.3
+++ /dev/null
@@ -1,173 +0,0 @@
1.\" $OpenBSD: AES_encrypt.3,v 1.1 2019/08/28 10:37:42 schwarze Exp $
2.\"
3.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: August 28 2019 $
18.Dt AES_ENCRYPT 3
19.Os
20.Sh NAME
21.Nm AES_set_encrypt_key ,
22.Nm AES_set_decrypt_key ,
23.Nm AES_encrypt ,
24.Nm AES_decrypt ,
25.Nm AES_cbc_encrypt
26.Nd low-level interface to the AES symmetric cipher
27.Sh SYNOPSIS
28.In openssl/aes.h
29.Ft int
30.Fo AES_set_encrypt_key
31.Fa "const unsigned char *userKey"
32.Fa "const int bits"
33.Fa "AES_KEY *key"
34.Fc
35.Ft int
36.Fo AES_set_decrypt_key
37.Fa "const unsigned char *userKey"
38.Fa "const int bits"
39.Fa "AES_KEY *key"
40.Fc
41.Ft void
42.Fo AES_encrypt
43.Fa "const unsigned char *in"
44.Fa "unsigned char *out"
45.Fa "const AES_KEY *key"
46.Fc
47.Ft void
48.Fo AES_decrypt
49.Fa "const unsigned char *in"
50.Fa "unsigned char *out"
51.Fa "const AES_KEY *key"
52.Fc
53.Ft void
54.Fo AES_cbc_encrypt
55.Fa "const unsigned char *in"
56.Fa "unsigned char *out"
57.Fa "size_t length"
58.Fa "const AES_KEY *key"
59.Fa "unsigned char *ivec"
60.Fa "const int enc"
61.Fc
62.Sh DESCRIPTION
63These function provide a low-level interface to the AES symmetric
64cipher algorithm, also called Rijndael.
65For reasons of flexibility, it is recommended that application
66programs use the high-level interface described in
67.Xr EVP_EncryptInit 3
68and
69.Xr EVP_aes_128_cbc 3
70instead whenever possible.
71.Pp
72.Vt AES_KEY
73is a structure that can hold up to 60
74.Vt int
75values and a number of rounds.
76.Pp
77.Fn AES_set_encrypt_key
78expands the
79.Fa userKey ,
80which is
81.Fa bits
82long, into the
83.Fa key
84structure to prepare for encryption.
85The number of bits and bytes read from
86.Fa userKey ,
87the number of
88.Vt int
89values stored into
90.Fa key ,
91and the number of rounds are as follows:
92.Pp
93.Bl -column bits bytes ints rounds -offset indent -compact
94.It bits Ta bytes Ta ints Ta rounds
95.It 128 Ta 16 Ta 44 Ta 10
96.It 192 Ta 24 Ta 52 Ta 12
97.It 256 Ta 32 Ta 60 Ta 14
98.El
99.Pp
100.Fn AES_set_decrypt_key
101does the same, but in preparation for decryption.
102.Pp
103.Fn AES_encrypt
104reads a single 16 byte block from
105.Pf * Fa in ,
106encrypts it with the
107.Fa key ,
108and writes the 16 resulting bytes to
109.Pf * Fa out .
110The 16 byte buffers starting at
111.Fa in
112and
113.Fa out
114can overlap, and
115.Fa in
116and
117.Fa out
118can even point to the same memory location.
119.Pp
120.Fn AES_decrypt
121decrypts a single block and is otherwise identical to
122.Fn AES_encrypt .
123.Pp
124If
125.Fa enc
126is non-zero,
127.Fn AES_cbc_encrypt
128encrypts
129.Fa len
130bytes at
131.Fa in
132to
133.Fa out
134using the 128 bit
135.Fa key
136and the 128 bit
137initialization vector
138.Fa ivec
139in CBC mode.
140If
141.Fa enc
142is 0,
143.Fn AES_cbc_encrypt
144performs the corresponding decryption.
145.Sh RETURN VALUES
146.Fn AES_set_encrypt_key
147and
148.Fn AES_set_decrypt_key
149return 0 for success, -1 if
150.Fa userKey
151or
152.Fa key
153is
154.Dv NULL ,
155or -2 if the number of
156.Fa bits
157is unsupported.
158.Sh SEE ALSO
159.Xr crypto 3 ,
160.Xr EVP_aes_128_cbc 3 ,
161.Xr EVP_EncryptInit 3
162.Sh STANDARDS
163ISO/IEC 18033-3:2010
164Information technology \(em Security techniques \(em
165Encryption algorithms \(em Part 3: Block ciphers
166.Sh HISTORY
167These functions first appeared in OpenSSL 0.9.7
168and have been available since
169.Ox 3.2 .
170.Sh AUTHORS
171.An Vincent Rijmen
172.An Antoon Bosselaers
173.An Paulo Barreto
diff --git a/src/lib/libcrypto/man/ASIdentifiers_new.3 b/src/lib/libcrypto/man/ASIdentifiers_new.3
deleted file mode 100644
index d8473b81a0..0000000000
--- a/src/lib/libcrypto/man/ASIdentifiers_new.3
+++ /dev/null
@@ -1,138 +0,0 @@
1.\" $OpenBSD: ASIdentifiers_new.3,v 1.11 2023/09/30 18:16:44 tb Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 30 2023 $
18.Dt ASIDENTIFIERS_NEW 3
19.Os
20.Sh NAME
21.Nm ASIdentifiers_new ,
22.Nm ASIdentifiers_free ,
23.Nm d2i_ASIdentifiers ,
24.Nm i2d_ASIdentifiers
25.Nd RFC 3779 autonomous system identifier delegation extensions
26.Sh SYNOPSIS
27.In openssl/x509v3.h
28.Ft ASIdentifiers *
29.Fo ASIdentifiers_new
30.Fa "void"
31.Fc
32.Ft void
33.Fo ASIdentifiers_free
34.Fa "ASIdentifiers *asid"
35.Fc
36.Ft ASIdentifiers *
37.Fo d2i_ASIdentifiers
38.Fa "ASIdentifiers **asid"
39.Fa "const unsigned char **in"
40.Fa "long len"
41.Fc
42.Ft int
43.Fo i2d_ASIdentifiers
44.Fa "ASIdentifiers *asid"
45.Fa "unsigned char **out"
46.Fc
47.Sh DESCRIPTION
48RFC 3779 defines two X.509v3 certificate extensions that allow the
49delegation of
50IP addresses and autonomous system (AS) identifiers
51from the issuer to the subject of the certificate.
52An
53.Vt ASIdentifiers
54object contains collections of individual AS numbers and
55ranges of AS numbers to be delegated.
56.Pp
57.Fn ASIdentifiers_new
58allocates and initializes a new, empty
59.Vt ASIdentifiers
60object that can be populated with
61.Xr X509v3_asid_add_id_or_range 3 .
62See
63.Xr ASRange_new 3
64for implementation details.
65.Pp
66.Fn ASIdentifiers_free
67frees
68.Fa asid
69including any data contained in it.
70If
71.Fa asid
72is
73.Dv NULL ,
74no action occurs.
75.Pp
76.Fn d2i_ASIdentifiers
77and
78.Fn i2d_ASIdentifiers
79decode and encode ASN.1
80.Vt ASIdentifiers
81objects as defined in RFC 3779, section 3.2.3.1.
82For details about the semantics, examples, caveats, and bugs, see
83.Xr ASN1_item_d2i 3 .
84In order for the encoding produced by
85.Fn i2d_ASIdentifiers
86to conform to RFC 3779,
87.Fa asid
88must be in
89.Dq canonical form ,
90see
91.Xr X509v3_asid_canonize 3 .
92.Sh RETURN VALUES
93.Fn ASIdentifiers_new
94returns a new
95.Vt ASIdentifiers
96object or
97.Dv NULL
98if an error occurs.
99.Pp
100.Fn d2i_ASIdentifiers
101returns an
102.Vt ASIdentifiers
103object or
104.Dv NULL
105if a decoding or memory allocation error occurs.
106.Pp
107.Fn i2d_ASIdentifiers
108returns the number of bytes successfully encoded
109or a value <= 0 if an error occurs.
110.Sh SEE ALSO
111.Xr ASRange_new 3 ,
112.Xr crypto 3 ,
113.Xr IPAddressRange_new 3 ,
114.Xr X509_new 3 ,
115.Xr X509v3_addr_add_inherit 3 ,
116.Xr X509v3_addr_get_range 3 ,
117.Xr X509v3_addr_inherits 3 ,
118.Xr X509v3_addr_subset 3 ,
119.Xr X509v3_addr_validate_path 3 ,
120.Xr X509v3_asid_add_id_or_range 3
121.Sh STANDARDS
122RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers:
123.Bl -dash -compact
124.It
125section 3: Autonomous System Identifier Delegation Extension
126.El
127.Pp
128RFC 7020: The Internet Numbers Registry System
129.Pp
130RFC 7249: Internet Numbers Registries
131.Sh HISTORY
132These functions first appeared in OpenSSL 0.9.8e
133and have been available since
134.Ox 7.1 .
135.Sh BUGS
136There are no corresponding functions for the RFC 3779
137IP address delegation extension represented by
138.Vt IPAddrBlocks .
diff --git a/src/lib/libcrypto/man/ASN1_BIT_STRING_set.3 b/src/lib/libcrypto/man/ASN1_BIT_STRING_set.3
deleted file mode 100644
index a916ca3ab2..0000000000
--- a/src/lib/libcrypto/man/ASN1_BIT_STRING_set.3
+++ /dev/null
@@ -1,139 +0,0 @@
1.\" $OpenBSD: ASN1_BIT_STRING_set.3,v 1.5 2024/12/24 09:48:56 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 24 2024 $
18.Dt ASN1_BIT_STRING_SET 3
19.Os
20.Sh NAME
21.Nm ASN1_BIT_STRING_set ,
22.Nm ASN1_BIT_STRING_set_bit ,
23.Nm ASN1_BIT_STRING_get_bit
24.Nd ASN.1 BIT STRING accessors
25.Sh SYNOPSIS
26.In openssl/asn1.h
27.Ft int
28.Fo ASN1_BIT_STRING_set
29.Fa "ASN1_BIT_STRING *bitstr"
30.Fa "unsigned char *data"
31.Fa "int len"
32.Fc
33.Ft int
34.Fo ASN1_BIT_STRING_set_bit
35.Fa "ASN1_BIT_STRING *bitstr"
36.Fa "int bitnumber"
37.Fa "int set"
38.Fc
39.Ft int
40.Fo ASN1_BIT_STRING_get_bit
41.Fa "ASN1_BIT_STRING *bitstr"
42.Fa "int bitnumber"
43.Fc
44.Sh DESCRIPTION
45.Fn ASN1_BIT_STRING_set
46sets the length attribute of
47.Fa bitstr
48to
49.Fa len
50and copies that number of bytes from
51.Fa data
52into
53.Fa bitstr ,
54overwriting any previous data, by merely calling
55.Xr ASN1_STRING_set 3 .
56This function does no validation whatsoever.
57In particular, it neither checks that
58.Fa bitstr
59is actually of the type
60.Dv V_ASN1_BIT_STRING
61nor, even if it is, that the
62.Fa data
63and
64.Fa len
65arguments make sense for this particular bit string.
66.Pp
67If the
68.Fa set
69argument is non-zero,
70.Fn ASN1_BIT_STRING_set_bit
71sets the bit with the given
72.Fa bitnumber
73in the
74.Fa bitstr ;
75otherwise, it clears that bit.
76A
77.Fa bitnumber
78of 0 addresses the most significant bit in the first data byte of
79.Fa bitstr ,
807 the least significant bit in the same byte,
818 the most significant bit in the second data byte, and so on.
82.Pp
83If setting a bit is requested beyond the last existing data byte,
84additional bytes are added to the
85.Fa bitstr
86as needed.
87After clearing a bit, any trailing NUL bytes are removed from the
88.Fa bitstr .
89.Pp
90.Fn ASN1_BIT_STRING_get_bit
91checks that the bit with the given
92.Fa bitnumber
93is set in
94.Fa bitstr .
95.Sh RETURN VALUES
96.Fn ASN1_BIT_STRING_set
97returns 1 on success or 0 if memory allocation fails or if
98.Fa data
99is
100.Dv NULL
101and
102.Fa len
103is \-1 in the same call.
104.Pp
105.Fn ASN1_BIT_STRING_set_bit
106returns 1 on success or 0 if
107.Fa bitstr
108is
109.Dv NULL
110or if memory allocation fails.
111.Pp
112.Fn ASN1_BIT_STRING_get_bit
113returns 1 if the bit with the given
114.Fa bitnumber
115is set in the
116.Fa bitstr
117or 0 if
118.Fa bitstr
119is
120.Dv NULL ,
121if
122.Fa bitnumber
123points beyond the last data byte in
124.Fa bitstr ,
125or if the requested bit is not set.
126.Sh SEE ALSO
127.Xr ASN1_BIT_STRING_new 3 ,
128.Xr ASN1_STRING_set 3 ,
129.Xr d2i_ASN1_BIT_STRING 3 ,
130.Xr v2i_ASN1_BIT_STRING 3
131.Sh HISTORY
132.Fn ASN1_BIT_STRING_set
133first appeared in SSLeay 0.6.5.
134.Fn ASN1_BIT_STRING_set_bit
135and
136.Fn ASN1_BIT_STRING_get_bit
137first appeared in SSLeay 0.9.0.
138These functions have been available since
139.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/ASN1_INTEGER_get.3 b/src/lib/libcrypto/man/ASN1_INTEGER_get.3
deleted file mode 100644
index 84f566eda9..0000000000
--- a/src/lib/libcrypto/man/ASN1_INTEGER_get.3
+++ /dev/null
@@ -1,428 +0,0 @@
1.\" $OpenBSD: ASN1_INTEGER_get.3,v 1.7 2023/05/22 19:38:04 tb Exp $
2.\" selective merge up to:
3.\" OpenSSL man3/ASN1_INTEGER_get_int64 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2018, 2021, 2022 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: May 22 2023 $
70.Dt ASN1_INTEGER_GET 3
71.Os
72.Sh NAME
73.Nm ASN1_INTEGER_get_uint64 ,
74.Nm ASN1_INTEGER_get_int64 ,
75.Nm ASN1_INTEGER_get ,
76.Nm ASN1_INTEGER_set_uint64 ,
77.Nm ASN1_INTEGER_set_int64 ,
78.Nm ASN1_INTEGER_set ,
79.Nm ASN1_INTEGER_cmp ,
80.Nm ASN1_INTEGER_dup ,
81.Nm BN_to_ASN1_INTEGER ,
82.Nm ASN1_INTEGER_to_BN ,
83.Nm ASN1_ENUMERATED_get_int64 ,
84.Nm ASN1_ENUMERATED_get ,
85.Nm ASN1_ENUMERATED_set_int64 ,
86.Nm ASN1_ENUMERATED_set ,
87.Nm BN_to_ASN1_ENUMERATED ,
88.Nm ASN1_ENUMERATED_to_BN
89.Nd ASN.1 INTEGER and ENUMERATED utilities
90.Sh SYNOPSIS
91.In openssl/asn1.h
92.Ft int
93.Fo ASN1_INTEGER_get_uint64
94.Fa "uint64_t *out_val"
95.Fa "const ASN1_INTEGER *a"
96.Fc
97.Ft int
98.Fo ASN1_INTEGER_get_int64
99.Fa "int64_t *out_val"
100.Fa "const ASN1_INTEGER *a"
101.Fc
102.Ft long
103.Fo ASN1_INTEGER_get
104.Fa "const ASN1_INTEGER *a"
105.Fc
106.Ft int
107.Fo ASN1_INTEGER_set_uint64
108.Fa "ASN1_INTEGER *a"
109.Fa "uint64_t v"
110.Fc
111.Ft int
112.Fo ASN1_INTEGER_set_int64
113.Fa "ASN1_INTEGER *a"
114.Fa "int64_t v"
115.Fc
116.Ft int
117.Fo ASN1_INTEGER_set
118.Fa "ASN1_INTEGER *a"
119.Fa "long v"
120.Fc
121.Ft int
122.Fo ASN1_INTEGER_cmp
123.Fa "const ASN1_INTEGER *a1"
124.Fa "const ASN1_INTEGER *a2"
125.Fc
126.Ft ASN1_INTEGER *
127.Fo ASN1_INTEGER_dup
128.Fa "const ASN1_INTEGER *a"
129.Fc
130.Ft ASN1_INTEGER *
131.Fo BN_to_ASN1_INTEGER
132.Fa "const BIGNUM *bn"
133.Fa "ASN1_INTEGER *ai"
134.Fc
135.Ft BIGNUM *
136.Fo ASN1_INTEGER_to_BN
137.Fa "const ASN1_INTEGER *ai"
138.Fa "BIGNUM *bn"
139.Fc
140.Ft int
141.Fo ASN1_ENUMERATED_get_int64
142.Fa "int64_t *out_val"
143.Fa "const ASN1_ENUMERATED *a"
144.Fc
145.Ft long
146.Fo ASN1_ENUMERATED_get
147.Fa "const ASN1_ENUMERATED *a"
148.Fc
149.Ft int
150.Fo ASN1_ENUMERATED_set_int64
151.Fa "ASN1_ENUMERATED *a"
152.Fa "int64_t v"
153.Fc
154.Ft int
155.Fo ASN1_ENUMERATED_set
156.Fa "ASN1_ENUMERATED *a"
157.Fa "long v"
158.Fc
159.Ft ASN1_ENUMERATED *
160.Fo BN_to_ASN1_ENUMERATED
161.Fa "const BIGNUM *bn"
162.Fa "ASN1_ENUMERATED *ai"
163.Fc
164.Ft BIGNUM *
165.Fo ASN1_ENUMERATED_to_BN
166.Fa "const ASN1_ENUMERATED *ai"
167.Fa "BIGNUM *bn"
168.Fc
169.Sh DESCRIPTION
170These functions convert to and from
171.Vt ASN1_INTEGER
172and
173.Vt ASN1_ENUMERATED
174objects.
175.Pp
176.Fn ASN1_INTEGER_get_uint64
177and
178.Fn ASN1_INTEGER_get_int64
179store the value of
180.Fa a
181in
182.Pf * Fa out_val
183if successful.
184.Pp
185The deprecated function
186.Fn ASN1_INTEGER_get
187converts
188.Fa a
189to the
190.Vt long
191type.
192.Pp
193.Fn ASN1_INTEGER_set_uint64 ,
194.Fn ASN1_INTEGER_set_int64 ,
195and
196.Fn ASN1_INTEGER_set
197set the type of
198.Fa a
199to
200.Dv V_ASN1_INTEGER
201or
202.Dv V_ASN1_NEG_INTEGER
203depending on the sign of
204.Fa v
205and set the value of
206.Fa a
207to
208.Fa v .
209.Pp
210.Fn ASN1_INTEGER_cmp
211compares the signed integer numbers represented by
212.Fa a1
213and
214.Fa a2 .
215.Pp
216.Fn ASN1_INTEGER_dup
217does exactly the same as
218.Xr ASN1_STRING_dup 3
219without providing any type safety,
220except that it fails if the
221.Xr ASN1_STRING_length 3
222of
223.Fa a
224is 0.
225.Pp
226.Fn BN_to_ASN1_INTEGER
227converts
228.Fa bn
229to an
230.Vt ASN1_INTEGER .
231If
232.Fa ai
233is
234.Dv NULL ,
235a new
236.Vt ASN1_INTEGER
237object is returned.
238Otherwise, the existing object
239.Fa ai
240is used instead.
241.Pp
242.Fn ASN1_INTEGER_to_BN
243converts
244.Fa ai
245into a
246.Vt BIGNUM .
247If
248.Fa bn
249is
250.Dv NULL ,
251a new
252.Vt BIGNUM
253object is returned.
254Otherwise, the existing object
255.Fa bn
256is used instead.
257.Pp
258.Fn ASN1_ENUMERATED_get_int64 ,
259.Fn ASN1_ENUMERATED_get ,
260.Fn ASN1_ENUMERATED_set_int64 ,
261.Fn ASN1_ENUMERATED_set ,
262.Fn BN_to_ASN1_ENUMERATED ,
263and
264.Fn ASN1_ENUMERATED_to_BN
265behave like their
266.Vt ASN1_INTEGER
267counterparts except that they operate on an
268.Vt ASN1_ENUMERATED
269object.
270.Sh RETURN VALUES
271.Fn ASN1_INTEGER_get_uint64
272returns 1 in case of success or 0 if
273.Fa a
274is not of the type
275.Dv V_ASN1_INTEGER
276or greater than
277.Dv UINT64_MAX .
278.Pp
279.Fn ASN1_INTEGER_get_int64
280returns 1 in case of success or 0 if
281.Fa a
282is not of the type
283.Dv V_ASN1_INTEGER
284or
285.Dv V_ASN1_NEG_INTEGER ,
286less than
287.Dv INT64_MIN ,
288or greater than
289.Dv INT64_MAX .
290.Pp
291.Fn ASN1_INTEGER_get
292and
293.Fn ASN1_ENUMERATED_get
294return the converted value, 0 if
295.Fa a
296is
297.Dv NULL ,
298or \-1 on error, which is ambiguous because \-1 is a legitimate
299value for an
300.Vt ASN1_INTEGER .
301.Pp
302.Fn ASN1_INTEGER_set_uint64 ,
303.Fn ASN1_INTEGER_set_int64 ,
304.Fn ASN1_INTEGER_set ,
305.Fn ASN1_ENUMERATED_set_int64 ,
306and
307.Fn ASN1_ENUMERATED_set
308return 1 for success or 0 for failure.
309They only fail if a memory allocation error occurs.
310.Pp
311.Fn ASN1_INTEGER_cmp
312returns a value greater than, equal to, or less than 0
313if the signed integer number represented by
314.Fa a1
315is greater than, equal to, or less than
316the signed integer number represented by
317.Fa a2 ,
318respectively.
319.Pp
320.Fn ASN1_INTEGER_dup
321returns a pointer to a newly allocated
322.Vt ASN1_STRING
323structure or
324.Dv NULL
325if
326.Fa a
327is a
328.Dv NULL
329pointer, if the length of
330.Fa a
331is 0, or if memory allocation fails.
332.Pp
333.Fn BN_to_ASN1_INTEGER
334and
335.Fn BN_to_ASN1_ENUMERATED
336return an
337.Vt ASN1_INTEGER
338or
339.Vt ASN1_ENUMERATED
340object, respectively, or
341.Dv NULL
342if an error occurs.
343They only fail due to memory allocation errors.
344.Pp
345.Fn ASN1_INTEGER_to_BN
346and
347.Fn ASN1_ENUMERATED_to_BN
348return a
349.Vt BIGNUM
350object of
351.Dv NULL
352if an error occurs.
353They can fail if the passed type is incorrect (due to a programming error)
354or due to memory allocation failures.
355.Sh SEE ALSO
356.Xr ASN1_INTEGER_new 3 ,
357.Xr ASN1_STRING_length 3
358.Sh HISTORY
359.Fn ASN1_INTEGER_set
360first appeared in SSLeay 0.5.1.
361.Fn ASN1_INTEGER_get ,
362.Fn BN_to_ASN1_INTEGER ,
363and
364.Fn ASN1_INTEGER_to_BN
365first appeared in SSLeay 0.6.0.
366.Fn ASN1_INTEGER_cmp
367and
368.Fn ASN1_INTEGER_dup
369first appeared in SSLeay 0.6.5.
370These functions have been available since
371.Ox 2.3 .
372.Pp
373.Fn ASN1_ENUMERATED_get ,
374.Fn ASN1_ENUMERATED_set ,
375.Fn BN_to_ASN1_ENUMERATED ,
376and
377.Fn ASN1_ENUMERATED_to_BN
378first appeared in OpenSSL 0.9.2b and have been available since
379.Ox 2.6 .
380.Pp
381.Fn ASN1_INTEGER_get_uint64 ,
382.Fn ASN1_INTEGER_get_int64 ,
383.Fn ASN1_INTEGER_set_uint64 ,
384.Fn ASN1_INTEGER_set_int64 ,
385.Fn ASN1_ENUMERATED_get_int64 ,
386and
387.Fn ASN1_ENUMERATED_set_int64
388first appeared in OpenSSL 1.1.0 and have been available since
389.Ox 7.2 .
390.Sh CAVEATS
391In general an
392.Vt ASN1_INTEGER
393or
394.Vt ASN1_ENUMERATED
395type can contain an integer of almost arbitrary size
396and so cannot always be represented by a C
397.Vt long
398type.
399The ambiguous return values of
400.Fn ASN1_INTEGER_get
401and
402.Fn ASN1_ENUMERATED_get
403imply that these functions should be avoided if possible.
404.Sh BUGS
405.Fn ASN1_INTEGER_cmp ,
406.Fn ASN1_INTEGER_dup ,
407and
408.Fn ASN1_INTEGER_to_BN
409do not check whether their arguments are really of the type
410.Dv V_ASN1_INTEGER
411or
412.Dv V_ASN1_NEG_INTEGER .
413They may report success even if their arguments are of a wrong type.
414Consequently, even in case of success, the return value of
415.Fn ASN1_INTEGER_dup
416is not guaranteed to be of the type
417.Dv V_ASN1_INTEGER
418or
419.Dv V_ASN1_NEG_INTEGER
420either.
421.Pp
422Similarly,
423.Fn ASN1_ENUMERATED_to_BN
424does not check whether its argument is really of the type
425.Dv V_ASN1_ENUMERATED
426or
427.Dv V_ASN1_NEG_ENUMERATED
428and may report success even if the argument is of a wrong type.
diff --git a/src/lib/libcrypto/man/ASN1_NULL_new.3 b/src/lib/libcrypto/man/ASN1_NULL_new.3
deleted file mode 100644
index b4d2428ed1..0000000000
--- a/src/lib/libcrypto/man/ASN1_NULL_new.3
+++ /dev/null
@@ -1,66 +0,0 @@
1.\" $OpenBSD: ASN1_NULL_new.3,v 1.3 2021/12/09 18:42:35 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 9 2021 $
18.Dt ASN1_NULL_NEW 3
19.Os
20.Sh NAME
21.Nm ASN1_NULL_new ,
22.Nm ASN1_NULL_free
23.Nd ASN.1 NULL value
24.Sh SYNOPSIS
25.In openssl/asn1.h
26.Ft ASN1_NULL *
27.Fn ASN1_NULL_new void
28.Ft void
29.Fn ASN1_NULL_free "ASN1_NULL *val_in"
30.Sh DESCRIPTION
31.Fn ASN1_NULL_new
32returns a specific invalid pointer that represents the ASN.1 NULL value,
33which is the only possible value of the ASN.1 NULL type.
34That pointer is different from a
35.Dv NULL
36pointer.
37Dereferencing it almost certainly results in a segmentation fault.
38This function does not allocate memory and cannot fail.
39.Pp
40.Fn ASN1_NULL_free
41has no effect whatsoever.
42In particular, it ignores the
43.Fa val_in
44argument and does not free any memory.
45In normal use, application programs only pass the invalid pointer
46obtained from
47.Fn ASN1_NULL_new
48to this function.
49But even if a valid pointer is passed, that pointer does not become invalid.
50.Pp
51The ASN.1 NULL type is also represented by the
52.Dv V_ASN1_NULL
53type identifier constant.
54.Sh SEE ALSO
55.Xr ASN1_item_new 3 ,
56.Xr d2i_ASN1_NULL 3
57.Sh STANDARDS
58ITU-T Recommendation X.208, also known as ISO/IEC 8824-1:
59Specification of Abstract Syntax Notation One (ASN.1),
60section 19: Notation for the null type
61.Sh HISTORY
62.Fn ASN1_NULL_new
63and
64.Fn ASN1_NULL_free
65first appeared in OpenSSL 0.9.5 and have been available since
66.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/ASN1_OBJECT_new.3 b/src/lib/libcrypto/man/ASN1_OBJECT_new.3
deleted file mode 100644
index 3e2eac02ee..0000000000
--- a/src/lib/libcrypto/man/ASN1_OBJECT_new.3
+++ /dev/null
@@ -1,228 +0,0 @@
1.\" $OpenBSD: ASN1_OBJECT_new.3,v 1.16 2023/09/05 15:01:39 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d4 Mar 19 12:28:58 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2017, 2021, 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson.
22.\" Copyright (c) 2002, 2006 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: September 5 2023 $
69.Dt ASN1_OBJECT_NEW 3
70.Os
71.Sh NAME
72.Nm ASN1_OBJECT_new ,
73.Nm ASN1_OBJECT_create ,
74.Nm ASN1_OBJECT_free
75.Nd ASN.1 object identifiers
76.Sh SYNOPSIS
77.In openssl/asn1.h
78.Ft ASN1_OBJECT *
79.Fo ASN1_OBJECT_new
80.Fa void
81.Fc
82.Ft ASN1_OBJECT *
83.Fo ASN1_OBJECT_create
84.Fa "int nid"
85.Fa "unsigned char *content"
86.Fa "int len"
87.Fa "const char *short_name"
88.Fa "const char *long_name"
89.Fc
90.Ft void
91.Fo ASN1_OBJECT_free
92.Fa "ASN1_OBJECT *a"
93.Fc
94.Sh DESCRIPTION
95.Fn ASN1_OBJECT_new
96allocates and initializes an empty
97.Vt ASN1_OBJECT
98object, representing an ASN.1 OBJECT IDENTIFIER.
99It can hold a short name, a long name, a numeric identifier (NID),
100and a sequence of integers identifying a node in the International
101Object Identifier tree as specified in ITU-T recommendation X.660.
102The new object is marked as dynamically allocated.
103.Pp
104The ASN.1 object identifier type is also represented by the
105.Dv V_ASN1_OBJECT
106type identifier constant.
107.Pp
108.Fn ASN1_OBJECT_create
109allocates a new
110.Vt ASN1_OBJECT
111with the given
112.Fa nid ,
113copies the
114.Fa len
115DER
116.Fa content
117octets, the
118.Fa short_name ,
119and the
120.Fa long_name
121into it, and marks the new object and all data contained in it
122as dynamically allocated.
123.Pp
124Application programs normally use utility functions like
125.Xr OBJ_nid2obj 3
126rather than using
127.Fn ASN1_OBJECT_new
128or
129.Fn ASN1_OBJECT_create
130directly.
131.Pp
132.Fn ASN1_OBJECT_free
133has the following effects:
134.Pp
135All data contained in
136.Fa a
137that is marked as dynamically allocated is freed,
138and the respective fields of
139.Fa a
140become empty.
141Contained data not marked as dynamically allocated remains intact.
142.Pp
143If the object
144.Fa a
145itself is marked as dynamically allocated, it is freed.
146Otherwise, the pointer
147.Fa a
148remains valid.
149.Pp
150If
151.Fa a
152is a
153.Dv NULL
154pointer or if neither the object itself nor any of its content
155is marked as dynamically allocated, no action occurs.
156.Sh RETURN VALUES
157.Fn ASN1_OBJECT_new
158and
159.Fn ASN1_OBJECT_create
160return a pointer to the new object or
161.Dv NULL
162if memory allocation fails,
163.Sh ERRORS
164After failure of
165.Fn ASN1_OBJECT_new
166or
167.Fn ASN1_OBJECT_create ,
168the following diagnostic can be retrieved with
169.Xr ERR_get_error 3 ,
170.Xr ERR_GET_REASON 3 ,
171and
172.Xr ERR_reason_error_string 3 :
173.Bl -tag -width Ds
174.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
175Memory allocation failed.
176.El
177.Pp
178After some cases of failure of
179.Fn ASN1_OBJECT_create ,
180the following diagnostic can be retrieved in addition to the above:
181.Bl -tag -width Ds
182.It Dv ERR_R_ASN1_LIB Qq "ASN1 lib"
183Memory allocation failed.
184.El
185.Sh SEE ALSO
186.Xr a2d_ASN1_OBJECT 3 ,
187.Xr ASN1_TYPE_get 3 ,
188.Xr d2i_ASN1_OBJECT 3 ,
189.Xr OBJ_create 3 ,
190.Xr OBJ_nid2obj 3
191.Sh STANDARDS
192ITU-T Recommendation X.208, also known as ISO/IEC 8824-1:
193Specification of Abstract Syntax Notation One (ASN.1),
194section 28: Notation for the object identifier type
195.Pp
196ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
197Information technology - ASN.1 encoding rules:
198Specification of Basic Encoding Rules (BER), Canonical Encoding
199Rules (CER) and Distinguished Encoding Rules (DER),
200section 8.19: Encoding of an object identifier value
201.Sh HISTORY
202.Fn ASN1_OBJECT_new
203and
204.Fn ASN1_OBJECT_free
205first appeared in SSLeay 0.5.1 and
206.Fn ASN1_OBJECT_create
207in SSLeay 0.8.0.
208These functions have been available since
209.Ox 2.4 .
210.Sh BUGS
211The function
212.Fn ASN1_OBJECT_new
213is not useful for any practical purpose because the library does not
214provide any function capable of adding data to an existing object.
215Consequently, if the application program creates an object with
216.Fn ASN1_OBJECT_new ,
217that object will always remain empty.
218.Pp
219Similarly, if an
220.Fa nid
221of
222.Dv NID_undef
223is passed to
224.Fn ASN1_OBJECT_create ,
225or if
226.Dv NULL
227is passed for any of its pointer arguments, the returned object
228will permanently remain incomplete.
diff --git a/src/lib/libcrypto/man/ASN1_PRINTABLE_type.3 b/src/lib/libcrypto/man/ASN1_PRINTABLE_type.3
deleted file mode 100644
index 391dd32e66..0000000000
--- a/src/lib/libcrypto/man/ASN1_PRINTABLE_type.3
+++ /dev/null
@@ -1,92 +0,0 @@
1.\" $OpenBSD: ASN1_PRINTABLE_type.3,v 1.1 2021/11/15 13:39:40 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 15 2021 $
18.Dt ASN1_PRINTABLE_TYPE 3
19.Os
20.Sh NAME
21.Nm ASN1_PRINTABLE_type
22.Nd classify a single-byte character string
23.Sh SYNOPSIS
24.In openssl/asn1.h
25.Ft int
26.Fo ASN1_PRINTABLE_type
27.Fa "const unsigned char *string"
28.Fa "int len"
29.Fc
30.Sh DESCRIPTION
31.Fn ASN1_PRINTABLE_type
32assumes that the given
33.Fa string
34consists of single-byte characters and classifies it
35according to which kinds characters occur.
36If
37.Fa len
38is greater than 0, at most
39.Fa len
40characters are inspected.
41Otherwise, the
42.Fa string
43needs to be NUL-terminated.
44.Sh RETURN VALUES
45If the given
46.Fa string
47contains a character outside the
48.Xr ascii 7
49range,
50.Fn ASN1_PRINTABLE_type
51returns
52.Dv V_ASN1_T61STRING .
53.Pp
54Otherwise, if it contains a character that is neither a letter
55nor a digit nor the space character
56.Po
57.Ql "\ " ,
58ASCII 0x20
59.Pc
60nor the apostrophe quote
61.Po
62.Ql \(aq ,
63ASCII 0x27
64.Pc
65nor contained in the set
66.Qq ()+,\-./:=?\& ,
67it returns
68.Dv V_ASN1_IA5STRING .
69.Pp
70Otherwise, including if
71.Fa string
72is a
73.Dv NULL
74pointer or points to an empty string, it returns
75.Dv V_ASN1_PRINTABLESTRING .
76.Sh SEE ALSO
77.Xr ASN1_mbstring_copy 3 ,
78.Xr ASN1_STRING_new 3 ,
79.Xr ASN1_STRING_to_UTF8 3 ,
80.Xr isascii 3 ,
81.Xr ascii 7
82.Sh HISTORY
83.Fn ASN1_PRINTABLE_type
84first appeared in SSLeay 0.4.5d, has been part of the public API
85since SSLeay 0.5.1, and has been available since
86.Ox 2.4 .
87.Sh CAVEATS
88The ASN.1 notion of what constitutes a
89.Vt PrintableString
90is more restrictive than what the C library function
91.Xr isprint 3
92considers printable.
diff --git a/src/lib/libcrypto/man/ASN1_STRING_TABLE_get.3 b/src/lib/libcrypto/man/ASN1_STRING_TABLE_get.3
deleted file mode 100644
index 2bf8831c12..0000000000
--- a/src/lib/libcrypto/man/ASN1_STRING_TABLE_get.3
+++ /dev/null
@@ -1,94 +0,0 @@
1.\" $OpenBSD: ASN1_STRING_TABLE_get.3,v 1.4 2023/12/21 21:23:37 tb Exp $
2.\" checked up to:
3.\" OpenSSL ASN1_STRING_TABLE_add.pod 7b608d08 Jul 27 01:18:50 2017 +0800
4.\"
5.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org>
6.\"
7.\" Permission to use, copy, modify, and distribute this software for any
8.\" purpose with or without fee is hereby granted, provided that the above
9.\" copyright notice and this permission notice appear in all copies.
10.\"
11.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\"
19.Dd $Mdocdate: December 21 2023 $
20.Dt ASN1_STRING_TABLE_GET 3
21.Os
22.Sh NAME
23.\" .Nm ASN1_STRING_TABLE_add0 and
24.\" .Nm ASN1_STRING_TABLE_cleanup are intentionally undocumented
25.\" because they will be removed in the next major bump
26.\" .Dv STABLE_FLAGS_MALLOC is intentionally undocumented because it is unused
27.Nm ASN1_STRING_TABLE_get
28.Nd retrieve an entry from the global ASN.1 string table
29.Sh SYNOPSIS
30.In openssl/asn1.h
31.Ft ASN1_STRING_TABLE *
32.Fo ASN1_STRING_TABLE_get
33.Fa "int nid"
34.Fc
35.Sh DESCRIPTION
36The ASN.1 string table is a unique global object.
37Each entry is of the type
38.Vt ASN1_STRING_TABLE
39and contains information about one NID object.
40The entries are predefined according to RFC 5280 appendix A.1.
41.Pp
42The upper bounds for the number of characters in various kinds of
43.Vt ASN1_STRING
44objects are:
45.Pp
46.Bl -column -compact NID_organizationalUnitNa maxsi ub_organization_unit_na
47.It object type Ta maxsize Ta symbolic constant
48.It Dv NID_commonName Ta 64 Ta Dv ub_common_name
49.It Dv NID_countryName Ta 2 Ta \(em
50.It Dv NID_givenName Ta 32768 Ta Dv ub_name
51.It Dv NID_initials Ta 32768 Ta Dv ub_name
52.It Dv NID_localityName Ta 128 Ta Dv ub_locality_name
53.It Dv NID_name Ta 32768 Ta Dv ub_name
54.It Dv NID_organizationName Ta 64 Ta Dv ub_organization_name
55.It Dv NID_organizationalUnitName Ta 64 Ta Dv ub_organization_unit_name
56.It Dv NID_pkcs9_emailAddress Ta 128 Ta Dv ub_email_address
57.It Dv NID_serialNumber Ta 64 Ta Dv ub_serial_number
58.It Dv NID_stateOrProvinceName Ta 128 Ta Dv ub_state_name
59.It Dv NID_surname Ta 32768 Ta Dv ub_name
60.El
61.Pp
62The function
63.Fn ASN1_STRING_TABLE_get
64retrieves the entry for
65.Fa nid .
66If the
67.Dv STABLE_NO_MASK
68flag is set,
69.Xr ASN1_STRING_set_by_NID 3
70skips applying the global mask that can be set with
71.Xr ASN1_STRING_set_default_mask 3 .
72.Sh RETURN VALUES
73.Fn ASN1_STRING_TABLE_get
74returns a valid
75.Vt ASN1_STRING_TABLE
76structure or
77.Dv NULL
78if nothing is found.
79.Sh SEE ALSO
80.Xr ASN1_OBJECT_new 3 ,
81.Xr ASN1_STRING_set_by_NID 3 ,
82.Xr OBJ_create 3 ,
83.Xr OBJ_nid2obj 3
84.Sh HISTORY
85.Fn ASN1_STRING_TABLE_get
86first appeared in OpenSSL 0.9.5 and has been available since
87.Ox 2.7 .
88.Sh BUGS
89Most aspects of the semantics considerably differ from OpenSSL.
90.Pp
91.Dv ub_email_address ,
92which should really be called
93.Dv ub_emailaddress_length ,
94was changed in RFC 5280 from 128 to 255 to match PKCS#9 (RFC 2985).
diff --git a/src/lib/libcrypto/man/ASN1_STRING_length.3 b/src/lib/libcrypto/man/ASN1_STRING_length.3
deleted file mode 100644
index 0c397607a9..0000000000
--- a/src/lib/libcrypto/man/ASN1_STRING_length.3
+++ /dev/null
@@ -1,461 +0,0 @@
1.\" $OpenBSD: ASN1_STRING_length.3,v 1.30 2024/12/27 15:30:17 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018, 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson.
22.\" Copyright (c) 2002, 2006, 2013, 2015, 2016, 2017 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: December 27 2024 $
70.Dt ASN1_STRING_LENGTH 3
71.Os
72.Sh NAME
73.Nm ASN1_STRING_cmp ,
74.Nm ASN1_OCTET_STRING_cmp ,
75.Nm ASN1_STRING_data ,
76.Nm ASN1_STRING_dup ,
77.Nm ASN1_OCTET_STRING_dup ,
78.Nm ASN1_STRING_get0_data ,
79.Nm ASN1_STRING_length ,
80.Nm ASN1_STRING_length_set ,
81.Nm ASN1_STRING_set0 ,
82.Nm ASN1_STRING_set ,
83.Nm ASN1_OCTET_STRING_set ,
84.Nm ASN1_STRING_copy ,
85.Nm ASN1_STRING_to_UTF8 ,
86.Nm ASN1_STRING_type
87.\" deprecated aliases, intentionally undocumented:
88.\" M_ASN1_STRING_data, M_ASN1_STRING_length
89.Nd ASN1_STRING utility functions
90.Sh SYNOPSIS
91.In openssl/asn1.h
92.Ft int
93.Fo ASN1_STRING_cmp
94.Fa "const ASN1_STRING *a"
95.Fa "const ASN1_STRING *b"
96.Fc
97.Ft int
98.Fo ASN1_OCTET_STRING_cmp
99.Fa "const ASN1_OCTET_STRING *a"
100.Fa "const ASN1_OCTET_STRING *b"
101.Fc
102.Ft unsigned char *
103.Fo ASN1_STRING_data
104.Fa "ASN1_STRING *x"
105.Fc
106.Ft ASN1_STRING *
107.Fo ASN1_STRING_dup
108.Fa "const ASN1_STRING *a"
109.Fc
110.Ft ASN1_OCTET_STRING *
111.Fo ASN1_OCTET_STRING_dup
112.Fa "const ASN1_OCTET_STRING *a"
113.Fc
114.Ft const unsigned char *
115.Fo ASN1_STRING_get0_data
116.Fa "const ASN1_STRING *x"
117.Fc
118.Ft int
119.Fo ASN1_STRING_length
120.Fa "const ASN1_STRING *x"
121.Fc
122.Ft void
123.Fo ASN1_STRING_length_set
124.Fa "ASN1_STRING *x"
125.Fa "int len"
126.Fc
127.Ft void
128.Fo ASN1_STRING_set0
129.Fa "ASN1_STRING *str"
130.Fa "void *data"
131.Fa "int len"
132.Fc
133.Ft int
134.Fo ASN1_STRING_set
135.Fa "ASN1_STRING *str"
136.Fa "const void *data"
137.Fa "int len"
138.Fc
139.Ft int
140.Fo ASN1_OCTET_STRING_set
141.Fa "ASN1_OCTET_STRING *str"
142.Fa "const unsigned char *data"
143.Fa "int len"
144.Fc
145.Ft int
146.Fo ASN1_STRING_copy
147.Fa "ASN1_STRING *dst"
148.Fa "const ASN1_STRING *src"
149.Fc
150.Ft int
151.Fo ASN1_STRING_to_UTF8
152.Fa "unsigned char **out"
153.Fa "const ASN1_STRING *in"
154.Fc
155.Ft int
156.Fo ASN1_STRING_type
157.Fa "const ASN1_STRING *x"
158.Fc
159.Sh DESCRIPTION
160These functions manipulate
161.Vt ASN1_STRING
162structures.
163.Pp
164.Fn ASN1_STRING_cmp
165compares the type, the length, and the content of
166.Fa a
167and
168.Fa b .
169.Pp
170.Fn ASN1_OCTET_STRING_cmp
171does exactly the same as
172.Fn ASN1_STRING_cmp
173without providing any type safety.
174.Pp
175.Fn ASN1_STRING_data
176is similar to
177.Fn ASN1_STRING_get0_data
178except that the returned value is not constant.
179This function is deprecated.
180Applications should use
181.Fn ASN1_STRING_get0_data
182instead.
183.Pp
184.Fn ASN1_STRING_dup
185allocates a new
186.Vt ASN1_STRING
187object and copies the type, length, data, and flags from
188.Fa a
189into it.
190.Pp
191.Fn ASN1_OCTET_STRING_dup
192does exactly the same as
193.Fn ASN1_STRING_dup
194without providing any type safety.
195.Pp
196.Fn ASN1_STRING_get0_data
197returns an internal pointer to the data of
198.Fa x .
199It should not be freed or modified in any way.
200.Pp
201.Fn ASN1_STRING_length
202returns the length attribute of
203.Fa x ,
204measured in bytes.
205.Pp
206.Fn ASN1_STRING_length_set
207sets the length attribute of
208.Fa x
209to
210.Fa len .
211It may put
212.Fa x
213into an inconsistent internal state.
214.Pp
215.Fn ASN1_STRING_set0
216frees any data stored in
217.Fa str ,
218sets the length attribute to
219.Fa len
220bytes, and sets the data attribute to
221.Fa data ,
222transferring ownership, without doing any validation.
223.Pp
224.Fn ASN1_STRING_set
225sets the length attribute of
226.Fa str
227to
228.Fa len
229and copies that number of bytes from
230.Fa data
231into
232.Fa str ,
233overwriting any previous data.
234If
235.Fa len
236is \-1, then
237.Fn strlen data
238is used instead of
239.Fa len .
240If
241.Fa data
242is
243.Dv NULL ,
244the content of
245.Fa str
246remains uninitialized; that is not considered an error unless
247.Fa len
248is negative.
249.Pp
250.Fn ASN1_OCTET_STRING_set
251does exactly the same as
252.Fn ASN1_STRING_set
253without providing any type safety.
254.Pp
255.Fn ASN1_STRING_copy
256copies the length and data of
257.Fa src
258into
259.Fa dst
260using
261.Fn ASN1_STRING_set
262and changes the type and flags of
263.Fa dst
264to match the type and flags of
265.Fa src .
266.Pp
267.Fn ASN1_STRING_to_UTF8
268converts the string
269.Fa in
270to UTF-8 format.
271The converted data is copied into a newly allocated buffer
272.Pf * Fa out .
273The buffer
274.Pf * Fa out
275should be freed using
276.Xr free 3 .
277.Pp
278.Fn ASN1_STRING_type
279returns the type of
280.Fa x .
281If the bit
282.Dv V_ASN1_NEG
283is set in the return value,
284.Fa x
285is an ASN.1 INTEGER or ENUMERATED object with a negative value.
286.Pp
287Almost all ASN.1 types are represented as
288.Vt ASN1_STRING
289structures.
290Other types such as
291.Vt ASN1_OCTET_STRING
292are simply typedefed to
293.Vt ASN1_STRING
294and the functions call the
295.Vt ASN1_STRING
296equivalents.
297.Vt ASN1_STRING
298is also used for some CHOICE types which consist entirely of primitive
299string types such as
300.Vt DirectoryString
301and
302.Vt Time .
303.Pp
304These functions should
305.Em not
306be used to examine or modify
307.Vt ASN1_INTEGER
308or
309.Vt ASN1_ENUMERATED
310types: the relevant INTEGER or ENUMERATED utility functions should
311be used instead.
312.Pp
313In general it cannot be assumed that the data returned by
314.Fn ASN1_STRING_get0_data
315and
316.Fn ASN1_STRING_data
317is NUL terminated, and it may contain embedded NUL characters.
318The format of the data depends on the string type:
319for example for an
320.Vt IA5String
321the data contains ASCII characters, for a
322.Vt BMPString
323two bytes per character in big endian format, and for a
324.Vt UTF8String
325UTF-8 characters.
326.Pp
327Similar care should be taken to ensure the data is in the correct format
328when calling
329.Fn ASN1_STRING_set
330or
331.Fn ASN1_STRING_set0 .
332.Sh RETURN VALUES
333.Fn ASN1_STRING_cmp
334and
335.Fn ASN1_OCTET_STRING_cmp
336return 0 if the type, the length, and the content of
337.Fa a
338and
339.Fa b
340agree, or a non-zero value otherwise.
341In contrast to
342.Xr strcmp 3 ,
343the sign of the return value does not indicate lexicographical ordering.
344.Pp
345.Fn ASN1_STRING_data
346and
347.Fn ASN1_STRING_get0_data
348return an internal pointer to the data of
349.Fa x .
350.Pp
351.Fn ASN1_STRING_dup
352and
353.Fn ASN1_OCTET_STRING_dup
354return a pointer to a newly allocated
355.Vt ASN1_STRING
356structure or
357.Dv NULL
358if an error occurred.
359.Pp
360.Fn ASN1_STRING_length
361returns a number of bytes.
362.Pp
363.Fn ASN1_STRING_set ,
364.Fn ASN1_OCTET_STRING_set ,
365and
366.Fn ASN1_STRING_copy
367return 1 on success or 0 on failure.
368They fail if memory allocation fails.
369.Fn ASN1_STRING_set
370and
371.Fn ASN1_OCTET_STRING_set
372also fail if
373.Fa data
374is
375.Dv NULL
376and
377.Fa len
378is \-1 in the same call.
379.Fn ASN1_STRING_copy
380also fails if
381.Fa src
382is
383.Dv NULL .
384.Pp
385.Fn ASN1_STRING_to_UTF8
386returns the number of bytes in the output buffer
387.Pf * Fa out ,
388or a negative number if an error occurred.
389.Pp
390.Fn ASN1_STRING_type
391returns an integer constant, for example
392.Dv V_ASN1_OCTET_STRING
393or
394.Dv V_ASN1_NEG_INTEGER .
395.Pp
396In some cases of failure of
397.Fn ASN1_STRING_dup ,
398.Fn ASN1_STRING_set ,
399and
400.Fn ASN1_STRING_to_UTF8 ,
401the reason can be determined with
402.Xr ERR_get_error 3 .
403.Sh SEE ALSO
404.Xr a2i_ASN1_STRING 3 ,
405.Xr a2i_ipadd 3 ,
406.Xr ASN1_BIT_STRING_set 3 ,
407.Xr ASN1_mbstring_copy 3 ,
408.Xr ASN1_PRINTABLE_type 3 ,
409.Xr ASN1_STRING_new 3 ,
410.Xr ASN1_UNIVERSALSTRING_to_string 3 ,
411.Xr s2i_ASN1_INTEGER 3
412.Sh HISTORY
413.Fn ASN1_STRING_cmp ,
414.Fn ASN1_STRING_dup ,
415.Fn ASN1_STRING_set ,
416and
417.Fn ASN1_OCTET_STRING_set
418first appeared in SSLeay 0.6.5.
419.Fn ASN1_OCTET_STRING_cmp ,
420.Fn ASN1_STRING_data ,
421.Fn ASN1_OCTET_STRING_dup ,
422and
423.Fn ASN1_STRING_type
424first appeared in SSLeay 0.8.0.
425.Fn ASN1_STRING_length
426first appeared in SSLeay 0.9.0.
427All these functions have been available since
428.Ox 2.4 .
429.Pp
430.Fn ASN1_STRING_length_set
431first appeared in OpenSSL 0.9.5 and has been available since
432.Ox 2.7 .
433.Pp
434.Fn ASN1_STRING_to_UTF8
435first appeared in OpenSSL 0.9.6 and has been available since
436.Ox 2.9 .
437.Pp
438.Fn ASN1_STRING_set0
439first appeared in OpenSSL 0.9.8h and has been available since
440.Ox 4.5 .
441.Pp
442.Fn ASN1_STRING_copy
443first appeared in OpenSSL 1.0.0 and has been available since
444.Ox 4.9 .
445.Pp
446.Fn ASN1_STRING_get0_data
447first appeared in OpenSSL 1.1.0 and has been available since
448.Ox 6.3 .
449.Sh BUGS
450.Fn ASN1_OCTET_STRING_cmp ,
451.Fn ASN1_OCTET_STRING_dup ,
452and
453.Fn ASN1_OCTET_STRING_set
454do not check whether their arguments are really of the type
455.Dv V_ASN1_OCTET_STRING .
456They may report success even if their arguments are of a wrong type.
457Consequently, even in case of success, the return value of
458.Fn ASN1_OCTET_STRING_dup
459is not guaranteed to be of the type
460.Dv V_ASN1_OCTET_STRING
461either.
diff --git a/src/lib/libcrypto/man/ASN1_STRING_new.3 b/src/lib/libcrypto/man/ASN1_STRING_new.3
deleted file mode 100644
index 212bacd413..0000000000
--- a/src/lib/libcrypto/man/ASN1_STRING_new.3
+++ /dev/null
@@ -1,303 +0,0 @@
1.\" $OpenBSD: ASN1_STRING_new.3,v 1.27 2024/12/27 15:30:17 schwarze Exp $
2.\" OpenSSL 99d63d46 Tue Mar 24 07:52:24 2015 -0400
3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: December 27 2024 $
19.Dt ASN1_STRING_NEW 3
20.Os
21.Sh NAME
22.Nm ASN1_STRING_new ,
23.Nm ASN1_STRING_type_new ,
24.Nm ASN1_STRING_free ,
25.Nm ASN1_OCTET_STRING_new ,
26.Nm ASN1_OCTET_STRING_free ,
27.Nm ASN1_BIT_STRING_new ,
28.Nm ASN1_BIT_STRING_free ,
29.Nm ASN1_INTEGER_new ,
30.Nm ASN1_INTEGER_free ,
31.Nm ASN1_ENUMERATED_new ,
32.Nm ASN1_ENUMERATED_free ,
33.Nm ASN1_UTF8STRING_new ,
34.Nm ASN1_UTF8STRING_free ,
35.Nm ASN1_IA5STRING_new ,
36.Nm ASN1_IA5STRING_free ,
37.Nm ASN1_UNIVERSALSTRING_new ,
38.Nm ASN1_UNIVERSALSTRING_free ,
39.Nm ASN1_BMPSTRING_new ,
40.Nm ASN1_BMPSTRING_free ,
41.Nm ASN1_GENERALSTRING_new ,
42.Nm ASN1_GENERALSTRING_free ,
43.Nm ASN1_T61STRING_new ,
44.Nm ASN1_T61STRING_free ,
45.Nm ASN1_VISIBLESTRING_new ,
46.Nm ASN1_VISIBLESTRING_free ,
47.Nm ASN1_PRINTABLESTRING_new ,
48.Nm ASN1_PRINTABLESTRING_free ,
49.Nm ASN1_PRINTABLE_new ,
50.Nm ASN1_PRINTABLE_free ,
51.Nm DIRECTORYSTRING_new ,
52.Nm DIRECTORYSTRING_free ,
53.Nm DISPLAYTEXT_new ,
54.Nm DISPLAYTEXT_free ,
55.Nm ASN1_GENERALIZEDTIME_new ,
56.Nm ASN1_GENERALIZEDTIME_free ,
57.Nm ASN1_UTCTIME_new ,
58.Nm ASN1_UTCTIME_free ,
59.Nm ASN1_TIME_new ,
60.Nm ASN1_TIME_free
61.\" deprecated aliases, intentionally undocumented: M_ASN1_IA5STRING_new,
62.\" M_ASN1_ENUMERATED_free, M_ASN1_INTEGER_free, M_ASN1_OCTET_STRING_free
63.Nd allocate and free ASN1_STRING objects
64.Sh SYNOPSIS
65.In openssl/asn1.h
66.Ft ASN1_STRING *
67.Fn ASN1_STRING_new void
68.Ft ASN1_STRING *
69.Fn ASN1_STRING_type_new "int type"
70.Ft void
71.Fn ASN1_STRING_free "ASN1_STRING *a"
72.Ft ASN1_OCTET_STRING *
73.Fn ASN1_OCTET_STRING_new void
74.Ft void
75.Fn ASN1_OCTET_STRING_free "ASN1_OCTET_STRING *a"
76.Ft ASN1_BIT_STRING *
77.Fn ASN1_BIT_STRING_new void
78.Ft void
79.Fn ASN1_BIT_STRING_free "ASN1_BIT_STRING *a"
80.Ft ASN1_INTEGER *
81.Fn ASN1_INTEGER_new void
82.Ft void
83.Fn ASN1_INTEGER_free "ASN1_INTEGER *a"
84.Ft ASN1_ENUMERATED *
85.Fn ASN1_ENUMERATED_new void
86.Ft void
87.Fn ASN1_ENUMERATED_free "ASN1_ENUMERATED *a"
88.Ft ASN1_UTF8STRING *
89.Fn ASN1_UTF8STRING_new void
90.Ft void
91.Fn ASN1_UTF8STRING_free "ASN1_UTF8STRING *a"
92.Ft ASN1_IA5STRING *
93.Fn ASN1_IA5STRING_new void
94.Ft void
95.Fn ASN1_IA5STRING_free "ASN1_IA5STRING *a"
96.Ft ASN1_UNIVERSALSTRING *
97.Fn ASN1_UNIVERSALSTRING_new void
98.Ft void
99.Fn ASN1_UNIVERSALSTRING_free "ASN1_UNIVERSALSTRING *a"
100.Ft ASN1_BMPSTRING *
101.Fn ASN1_BMPSTRING_new void
102.Ft void
103.Fn ASN1_BMPSTRING_free "ASN1_BMPSTRING *a"
104.Ft ASN1_GENERALSTRING *
105.Fn ASN1_GENERALSTRING_new void
106.Ft void
107.Fn ASN1_GENERALSTRING_free "ASN1_GENERALSTRING *a"
108.Ft ASN1_T61STRING *
109.Fn ASN1_T61STRING_new void
110.Ft void
111.Fn ASN1_T61STRING_free "ASN1_T61STRING *a"
112.Ft ASN1_VISIBLESTRING *
113.Fn ASN1_VISIBLESTRING_new void
114.Ft void
115.Fn ASN1_VISIBLESTRING_free "ASN1_VISIBLESTRING *a"
116.Ft ASN1_PRINTABLESTRING *
117.Fn ASN1_PRINTABLESTRING_new void
118.Ft void
119.Fn ASN1_PRINTABLESTRING_free "ASN1_PRINTABLESTRING *a"
120.Ft ASN1_STRING *
121.Fn ASN1_PRINTABLE_new void
122.Ft void
123.Fn ASN1_PRINTABLE_free "ASN1_STRING *a"
124.Ft ASN1_STRING *
125.Fn DIRECTORYSTRING_new void
126.Ft void
127.Fn DIRECTORYSTRING_free "ASN1_STRING *a"
128.Ft ASN1_STRING *
129.Fn DISPLAYTEXT_new void
130.Ft void
131.Fn DISPLAYTEXT_free "ASN1_STRING *a"
132.Ft ASN1_GENERALIZEDTIME *
133.Fn ASN1_GENERALIZEDTIME_new void
134.Ft void
135.Fn ASN1_GENERALIZEDTIME_free "ASN1_GENERALIZEDTIME *a"
136.Ft ASN1_UTCTIME *
137.Fn ASN1_UTCTIME_new void
138.Ft void
139.Fn ASN1_UTCTIME_free "ASN1_UTCTIME *a"
140.Ft ASN1_TIME *
141.Fn ASN1_TIME_new void
142.Ft void
143.Fn ASN1_TIME_free "ASN1_TIME *a"
144.Sh DESCRIPTION
145The
146.Vt ASN1_STRING
147object can represent a variety of ASN.1 built-in types.
148It can store a type and a value.
149.Pp
150All the
151.Fn *_new
152functions
153allocate and initialize an empty
154.Vt ASN1_STRING
155object.
156The following table shows the type assigned to the new object,
157and which ASN.1 type it represents.
158.Bl -column "ASN1_GENERALIZEDTIME_new()" "V_ASN1_GENERALIZEDTIME"
159.It Em constructor function Ta Em OpenSSL type Ta Em ASN.1 type
160.It Ta
161.It Fn ASN1_STRING_new Ta Dv V_ASN1_OCTET_STRING
162.It Fn ASN1_STRING_type_new Ta Fa type No argument
163.It Ta
164.It Fn ASN1_OCTET_STRING_new Ta Dv V_ASN1_OCTET_STRING Ta OCTET STRING
165.It Fn ASN1_BIT_STRING_new Ta Dv V_ASN1_BIT_STRING Ta BIT STRING
166.It Fn ASN1_INTEGER_new Ta Dv V_ASN1_INTEGER Ta INTEGER
167.It Fn ASN1_ENUMERATED_new Ta Dv V_ASN1_ENUMERATED Ta ENUMERATED
168.It Ta
169.It Fn ASN1_UTF8STRING_new Ta Dv V_ASN1_UTF8STRING Ta UTF8String
170.It Fn ASN1_IA5STRING_new Ta Dv V_ASN1_IA5STRING Ta IA5String
171.It Ta
172.It Fn ASN1_UNIVERSALSTRING_new Ta Dv V_ASN1_UNIVERSALSTRING Ta UniversalString
173.It Fn ASN1_BMPSTRING_new Ta Dv V_ASN1_BMPSTRING Ta BMPString
174.It Fn ASN1_GENERALSTRING_new Ta Dv V_ASN1_GENERALSTRING Ta GeneralString
175.It Fn ASN1_T61STRING_new Ta Dv V_ASN1_T61STRING Ta T61String
176.It Fn ASN1_VISIBLESTRING_new Ta Dv V_ASN1_VISIBLESTRING Ta VisibleString
177.It Fn ASN1_PRINTABLESTRING_new Ta Dv V_ASN1_PRINTABLESTRING Ta PrintableString
178.It Ta
179.It Fn ASN1_PRINTABLE_new Ta Dv V_ASN1_UNDEF
180.It Fn DIRECTORYSTRING_new Ta Dv V_ASN1_UNDEF
181.It Fn DISPLAYTEXT_new Ta Dv V_ASN1_UNDEF
182.It Ta
183.It Fn ASN1_GENERALIZEDTIME_new Ta Dv V_ASN1_GENERALIZEDTIME Ta GeneralizedTime
184.It Fn ASN1_UTCTIME_new Ta Dv V_ASN1_UTCTIME Ta UTCTime
185.It Fn ASN1_TIME_new Ta Dv V_ASN1_UNDEF Ta TIME
186.El
187.Pp
188All the
189.Fn *_free
190functions free
191.Fa a
192including any data contained in it.
193If
194.Fa a
195is a
196.Dv NULL
197pointer, no action occurs.
198.Sh RETURN VALUES
199All the
200.Fn *_new
201functions return the new
202.Vt ASN1_STRING
203object if successful; otherwise
204.Dv NULL
205is returned and an error code can be retrieved with
206.Xr ERR_get_error 3 .
207.Sh SEE ALSO
208.Xr a2i_ipadd 3 ,
209.Xr ASN1_BIT_STRING_set 3 ,
210.Xr ASN1_INTEGER_get 3 ,
211.Xr ASN1_item_pack 3 ,
212.Xr ASN1_mbstring_copy 3 ,
213.Xr ASN1_PRINTABLE_type 3 ,
214.Xr ASN1_STRING_length 3 ,
215.Xr ASN1_STRING_print_ex 3 ,
216.Xr ASN1_TIME_set 3 ,
217.Xr ASN1_TYPE_get 3 ,
218.Xr ASN1_UNIVERSALSTRING_to_string 3 ,
219.Xr d2i_ASN1_OBJECT 3 ,
220.Xr d2i_ASN1_OCTET_STRING 3 ,
221.Xr i2a_ASN1_STRING 3 ,
222.Xr s2i_ASN1_INTEGER 3 ,
223.Xr X509_cmp_time 3 ,
224.Xr X509_EXTENSION_get_object 3 ,
225.Xr X509_get_ext_by_OBJ 3 ,
226.Xr X509_NAME_ENTRY_get_object 3
227.Sh HISTORY
228.Fn ASN1_OCTET_STRING_new ,
229.Fn ASN1_OCTET_STRING_free ,
230.Fn ASN1_BIT_STRING_new ,
231.Fn ASN1_BIT_STRING_free ,
232.Fn ASN1_INTEGER_new ,
233.Fn ASN1_INTEGER_free ,
234.Fn ASN1_IA5STRING_new ,
235.Fn ASN1_IA5STRING_free ,
236.Fn ASN1_T61STRING_new ,
237.Fn ASN1_T61STRING_free ,
238.Fn ASN1_PRINTABLESTRING_new ,
239.Fn ASN1_PRINTABLESTRING_free ,
240.Fn ASN1_PRINTABLE_new ,
241.Fn ASN1_PRINTABLE_free ,
242.Fn ASN1_UTCTIME_new ,
243and
244.Fn ASN1_UTCTIME_free
245first appeared in SSLeay 0.5.1.
246.Fn ASN1_STRING_new ,
247.Fn ASN1_STRING_type_new ,
248and
249.Fn ASN1_STRING_free
250first appeared in SSLeay 0.6.5.
251.Fn ASN1_UNIVERSALSTRING_new ,
252.Fn ASN1_UNIVERSALSTRING_free ,
253.Fn ASN1_GENERALSTRING_new ,
254and
255.Fn ASN1_GENERALSTRING_free
256first appeared in SSLeay 0.8.0.
257.Fn ASN1_BMPSTRING_new ,
258.Fn ASN1_BMPSTRING_free ,
259.Fn ASN1_GENERALIZEDTIME_new ,
260and
261.Fn ASN1_GENERALIZEDTIME_free
262first appeared in SSLeay 0.9.0.
263All these functions have been available since
264.Ox 2.4 .
265.Pp
266.Fn ASN1_ENUMERATED_new ,
267.Fn ASN1_ENUMERATED_free ,
268.Fn ASN1_TIME_new ,
269and
270.Fn ASN1_TIME_free
271first appeared in OpenSSL 0.9.2b.
272.Fn ASN1_UTF8STRING_new ,
273.Fn ASN1_UTF8STRING_free ,
274.Fn ASN1_VISIBLESTRING_new ,
275.Fn ASN1_VISIBLESTRING_free ,
276.Fn DIRECTORYSTRING_new ,
277.Fn DIRECTORYSTRING_free ,
278.Fn DISPLAYTEXT_new ,
279and
280.Fn DISPLAYTEXT_free
281first appeared in OpenSSL 0.9.3.
282These functions have been available since
283.Ox 2.6 .
284.Sh BUGS
285.Vt ASN1_OCTET_STRING ,
286.Vt ASN1_BIT_STRING ,
287.Vt ASN1_INTEGER ,
288.Vt ASN1_ENUMERATED ,
289.Vt ASN1_UTF8STRING ,
290.Vt ASN1_IA5STRING ,
291.Vt ASN1_UNIVERSALSTRING ,
292.Vt ASN1_BMPSTRING ,
293.Vt ASN1_GENERALSTRING ,
294.Vt ASN1_T61STRING ,
295.Vt ASN1_VISIBLESTRING ,
296.Vt ASN1_PRINTABLESTRING ,
297.Vt ASN1_GENERALIZEDTIME ,
298.Vt ASN1_UTCTIME ,
299and
300.Vt ASN1_TIME
301are merely typedef aliases of
302.Vt ASN1_STRING
303and provide no type safety whatsoever.
diff --git a/src/lib/libcrypto/man/ASN1_STRING_print_ex.3 b/src/lib/libcrypto/man/ASN1_STRING_print_ex.3
deleted file mode 100644
index eb43b2fe5c..0000000000
--- a/src/lib/libcrypto/man/ASN1_STRING_print_ex.3
+++ /dev/null
@@ -1,241 +0,0 @@
1.\" $OpenBSD: ASN1_STRING_print_ex.3,v 1.18 2021/12/14 19:36:18 schwarze Exp $
2.\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\"
5.\" This file was written by Dr. Stephen Henson.
6.\" Copyright (c) 2002, 2004, 2007, 2013, 2016, 2017 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: December 14 2021 $
54.Dt ASN1_STRING_PRINT_EX 3
55.Os
56.Sh NAME
57.Nm ASN1_STRING_print_ex ,
58.Nm ASN1_STRING_print_ex_fp ,
59.Nm ASN1_STRING_print ,
60.Nm ASN1_tag2str
61.\" M_ASN1_OCTET_STRING_print is a deprecated alias, intentionally undocumented
62.Nd ASN1_STRING output routines
63.Sh SYNOPSIS
64.In openssl/asn1.h
65.Ft int
66.Fo ASN1_STRING_print_ex
67.Fa "BIO *out"
68.Fa "const ASN1_STRING *str"
69.Fa "unsigned long flags"
70.Fc
71.Ft int
72.Fo ASN1_STRING_print_ex_fp
73.Fa "FILE *fp"
74.Fa "const ASN1_STRING *str"
75.Fa "unsigned long flags"
76.Fc
77.Ft int
78.Fo ASN1_STRING_print
79.Fa "BIO *out"
80.Fa "const ASN1_STRING *str"
81.Fc
82.Ft const char *
83.Fo ASN1_tag2str
84.Fa "int tag"
85.Fc
86.Sh DESCRIPTION
87These functions output an
88.Vt ASN1_STRING
89structure.
90.Vt ASN1_STRING
91is used to
92represent all the ASN.1 string types.
93.Pp
94.Fn ASN1_STRING_print_ex
95outputs
96.Fa str
97to
98.Fa out ,
99the format being determined by the options
100.Fa flags .
101.Fn ASN1_STRING_print_ex_fp
102is identical except it outputs to
103.Fa fp
104instead.
105.Pp
106.Fn ASN1_STRING_print
107prints
108.Fa str
109to
110.Fa out
111but using a different format to
112.Fn ASN1_STRING_print_ex .
113It replaces unprintable characters (other than CR, LF) with
114.Sq \&. .
115.Pp
116.Fn ASN1_tag2str
117returns a human-readable name of the specified ASN.1
118.Fa tag .
119.Pp
120.Fn ASN1_STRING_print
121is a deprecated function which should be avoided; use
122.Fn ASN1_STRING_print_ex
123instead.
124.Pp
125Although there are a large number of options,
126.Dv ASN1_STRFLGS_RFC2253
127is often suitable, or on UTF-8 terminals
128.Dv ASN1_STRFLGS_RFC2253
129and
130.Pf ~ Dv ASN1_STRFLGS_ESC_MSB .
131.Pp
132The complete set of supported options for
133.Fa flags
134is listed below.
135.Pp
136Various characters can be escaped.
137If
138.Dv ASN1_STRFLGS_ESC_2253
139is set, the characters determined by RFC 2253 are escaped.
140If
141.Dv ASN1_STRFLGS_ESC_CTRL
142is set, control characters are escaped.
143If
144.Dv ASN1_STRFLGS_ESC_MSB
145is set, characters with the MSB set are escaped: this option should
146.Em not
147be used if the terminal correctly interprets UTF-8 sequences.
148.Pp
149Escaping takes several forms.
150If the character being escaped is a 16-bit character then the form "\eUXXXX"
151is used using exactly four characters for the hex representation.
152If it is 32 bits then "\eWXXXXXXXX" is used using eight characters
153of its hex representation.
154These forms will only be used if UTF-8 conversion is not set (see below).
155.Pp
156Printable characters are normally escaped using the backslash
157.Pq Sq \e
158character.
159If
160.Dv ASN1_STRFLGS_ESC_QUOTE
161is set, then the whole string is instead surrounded by double quote
162characters: this is arguably more readable than the backslash notation.
163Other characters use the "\eXX" using exactly two characters of the hex
164representation.
165.Pp
166If
167.Dv ASN1_STRFLGS_UTF8_CONVERT
168is set, then characters are converted to UTF-8 format first.
169If the terminal supports the display of UTF-8 sequences then this
170option will correctly display multi-byte characters.
171.Pp
172If
173.Dv ASN1_STRFLGS_IGNORE_TYPE
174is set, then the string type is not interpreted at all:
175everything is assumed to be one byte per character.
176This is primarily for debugging purposes and can result
177in confusing output in multi-character strings.
178.Pp
179If
180.Dv ASN1_STRFLGS_SHOW_TYPE
181is set, then the string type itself is printed before its value
182(for example "BMPSTRING"), using
183.Fn ASN1_tag2str .
184.Pp
185Instead of being interpreted the contents of a string can be "dumped":
186this just outputs the value of the string using the form #XXXX
187using hex format for each octet.
188.Pp
189If
190.Dv ASN1_STRFLGS_DUMP_ALL
191is set, then any type is dumped.
192.Pp
193Normally non-character string types (such as OCTET STRING)
194are assumed to be one byte per character; if
195.Dv ASN1_STRFLGS_DUMP_UNKNOWN
196is set, then they will be dumped instead.
197.Pp
198When a type is dumped normally just the content octets are printed; if
199.Dv ASN1_STRFLGS_DUMP_DER
200is set, then the complete encoding is dumped
201instead (including tag and length octets).
202.Pp
203.Dv ASN1_STRFLGS_RFC2253
204includes all the flags required by RFC 2253.
205It is equivalent to
206.Dv ASN1_STRFLGS_ESC_2253 |
207.Dv ASN1_STRFLGS_ESC_CTRL |
208.Dv ASN1_STRFLGS_ESC_MSB |
209.Dv ASN1_STRFLGS_UTF8_CONVERT |
210.Dv ASN1_STRFLGS_DUMP_UNKNOWN |
211.Dv ASN1_STRFLGS_DUMP_DER .
212.Sh RETURN VALUES
213.Fn ASN1_STRING_print_ex
214and
215.Fn ASN1_STRING_print_ex_fp
216return the number of characters written or \-1 if an error occurred.
217.Pp
218.Fn ASN1_STRING_print
219returns 1 on success or 0 on error.
220.Pp
221.Fn ASN1_tag2str
222returns a static string.
223.Sh SEE ALSO
224.Xr ASN1_parse_dump 3 ,
225.Xr ASN1_STRING_new 3 ,
226.Xr X509_NAME_print_ex 3 ,
227.Xr X509_signature_dump 3
228.Sh HISTORY
229.Fn ASN1_STRING_print
230first appeared in SSLeay 0.6.5 and has been available since
231.Ox 2.4 .
232.Pp
233.Fn ASN1_tag2str
234first appeared in OpenSSL 0.9.5 and has been available since
235.Ox 2.7 .
236.Pp
237.Fn ASN1_STRING_print_ex
238and
239.Fn ASN1_STRING_print_ex_fp
240first appeared in OpenSSL 0.9.6 and have been available since
241.Ox 2.9 .
diff --git a/src/lib/libcrypto/man/ASN1_TIME_set.3 b/src/lib/libcrypto/man/ASN1_TIME_set.3
deleted file mode 100644
index 233cb13f2c..0000000000
--- a/src/lib/libcrypto/man/ASN1_TIME_set.3
+++ /dev/null
@@ -1,752 +0,0 @@
1.\" $OpenBSD: ASN1_TIME_set.3,v 1.23 2024/03/05 18:30:40 tb Exp $
2.\" full merge up to: OpenSSL 3d0f1cb9 Jul 11 03:01:24 2017 +0800
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
9.\" Copyright (c) 2022 Bob Beck <beck@openbsd.org>
10.\"
11.\" Permission to use, copy, modify, and distribute this software for any
12.\" purpose with or without fee is hereby granted, provided that the above
13.\" copyright notice and this permission notice appear in all copies.
14.\"
15.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
16.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
18.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22.\"
23.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
24.\" and Todd Short <tshort@akamai.com>.
25.\" Copyright (c) 2015, 2017 The OpenSSL Project. All rights reserved.
26.\"
27.\" Redistribution and use in source and binary forms, with or without
28.\" modification, are permitted provided that the following conditions
29.\" are met:
30.\"
31.\" 1. Redistributions of source code must retain the above copyright
32.\" notice, this list of conditions and the following disclaimer.
33.\"
34.\" 2. Redistributions in binary form must reproduce the above copyright
35.\" notice, this list of conditions and the following disclaimer in
36.\" the documentation and/or other materials provided with the
37.\" distribution.
38.\"
39.\" 3. All advertising materials mentioning features or use of this
40.\" software must display the following acknowledgment:
41.\" "This product includes software developed by the OpenSSL Project
42.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
43.\"
44.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
45.\" endorse or promote products derived from this software without
46.\" prior written permission. For written permission, please contact
47.\" openssl-core@openssl.org.
48.\"
49.\" 5. Products derived from this software may not be called "OpenSSL"
50.\" nor may "OpenSSL" appear in their names without prior written
51.\" permission of the OpenSSL Project.
52.\"
53.\" 6. Redistributions of any form whatsoever must retain the following
54.\" acknowledgment:
55.\" "This product includes software developed by the OpenSSL Project
56.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
57.\"
58.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
59.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
62.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
67.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\"
71.Dd $Mdocdate: March 5 2024 $
72.Dt ASN1_TIME_SET 3
73.Os
74.Sh NAME
75.Nm ASN1_TIME_set ,
76.Nm ASN1_UTCTIME_set ,
77.Nm ASN1_GENERALIZEDTIME_set ,
78.Nm ASN1_TIME_adj ,
79.Nm ASN1_UTCTIME_adj ,
80.Nm ASN1_GENERALIZEDTIME_adj ,
81.Nm ASN1_TIME_set_string ,
82.Nm ASN1_TIME_set_string_X509 ,
83.Nm ASN1_UTCTIME_set_string ,
84.Nm ASN1_GENERALIZEDTIME_set_string ,
85.Nm ASN1_TIME_normalize ,
86.Nm ASN1_TIME_check ,
87.Nm ASN1_UTCTIME_check ,
88.Nm ASN1_GENERALIZEDTIME_check ,
89.Nm ASN1_TIME_print ,
90.Nm ASN1_UTCTIME_print ,
91.Nm ASN1_GENERALIZEDTIME_print ,
92.Nm ASN1_TIME_to_tm ,
93.Nm ASN1_TIME_diff ,
94.Nm ASN1_TIME_cmp_time_t ,
95.Nm ASN1_UTCTIME_cmp_time_t ,
96.Nm ASN1_TIME_compare ,
97.Nm ASN1_TIME_to_generalizedtime ,
98.Nm OPENSSL_gmtime ,
99.Nm OPENSSL_timegm ,
100.Nm OPENSSL_posix_to_tm ,
101.Nm OPENSSL_tm_to_posix
102.Nd ASN.1 Time functions
103.Sh SYNOPSIS
104.In openssl/asn1.h
105.Ft ASN1_TIME *
106.Fo ASN1_TIME_set
107.Fa "ASN1_TIME *s"
108.Fa "time_t t"
109.Fc
110.Ft ASN1_UTCTIME *
111.Fo ASN1_UTCTIME_set
112.Fa "ASN1_UTCTIME *s"
113.Fa "time_t t"
114.Fc
115.Ft ASN1_GENERALIZEDTIME *
116.Fo ASN1_GENERALIZEDTIME_set
117.Fa "ASN1_GENERALIZEDTIME *s"
118.Fa "time_t t"
119.Fc
120.Ft ASN1_TIME *
121.Fo ASN1_TIME_adj
122.Fa "ASN1_TIME *s"
123.Fa "time_t t"
124.Fa "int offset_day"
125.Fa "long offset_sec"
126.Fc
127.Ft ASN1_UTCTIME *
128.Fo ASN1_UTCTIME_adj
129.Fa "ASN1_UTCTIME *s"
130.Fa "time_t t"
131.Fa "int offset_day"
132.Fa "long offset_sec"
133.Fc
134.Ft ASN1_GENERALIZEDTIME *
135.Fo ASN1_GENERALIZEDTIME_adj
136.Fa "ASN1_GENERALIZEDTIME *s"
137.Fa "time_t t"
138.Fa "int offset_day"
139.Fa "long offset_sec"
140.Fc
141.Ft int
142.Fo ASN1_TIME_set_string
143.Fa "ASN1_TIME *s"
144.Fa "const char *str"
145.Fc
146.Ft int
147.Fo ASN1_TIME_set_string_X509
148.Fa "ASN1_TIME *s"
149.Fa "const char *str"
150.Fc
151.Ft int
152.Fo ASN1_UTCTIME_set_string
153.Fa "ASN1_UTCTIME *s"
154.Fa "const char *str"
155.Fc
156.Ft int
157.Fo ASN1_GENERALIZEDTIME_set_string
158.Fa "ASN1_GENERALIZEDTIME *s"
159.Fa "const char *str"
160.Fc
161.Ft int
162.Fo ASN1_TIME_normalize
163.Fa "ASN1_TIME *s"
164.Fc
165.Ft int
166.Fo ASN1_TIME_check
167.Fa "const ASN1_TIME *t"
168.Fc
169.Ft int
170.Fo ASN1_UTCTIME_check
171.Fa "const ASN1_UTCTIME *t"
172.Fc
173.Ft int
174.Fo ASN1_GENERALIZEDTIME_check
175.Fa "const ASN1_GENERALIZEDTIME *t"
176.Fc
177.Ft int
178.Fo ASN1_TIME_print
179.Fa "BIO *b"
180.Fa "const ASN1_TIME *s"
181.Fc
182.Ft int
183.Fo ASN1_UTCTIME_print
184.Fa "BIO *b"
185.Fa "const ASN1_UTCTIME *s"
186.Fc
187.Ft int
188.Fo ASN1_GENERALIZEDTIME_print
189.Fa "BIO *b"
190.Fa "const ASN1_GENERALIZEDTIME *s"
191.Fc
192.Ft int
193.Fo ASN1_TIME_to_tm
194.Fa "const ASN1_TIME *s"
195.Fa "struct tm *tm"
196.Fc
197.Ft int
198.Fo ASN1_TIME_diff
199.Fa "int *pday"
200.Fa "int *psec"
201.Fa "const ASN1_TIME *from"
202.Fa "const ASN1_TIME *to"
203.Fc
204.Ft int
205.Fo ASN1_TIME_cmp_time_t
206.Fa "const ASN1_TIME *s"
207.Fa "time_t t"
208.Fc
209.Ft int
210.Fo ASN1_UTCTIME_cmp_time_t
211.Fa "const ASN1_UTCTIME *s"
212.Fa "time_t t"
213.Fc
214.Ft int
215.Fo ASN1_TIME_compare
216.Fa "const ASN1_TIME *s"
217.Fa "const ASN1_TIME *t"
218.Fc
219.Ft ASN1_GENERALIZEDTIME *
220.Fo ASN1_TIME_to_generalizedtime
221.Fa "const ASN1_TIME *t"
222.Fa "ASN1_GENERALIZEDTIME **out"
223.Fc
224.In openssl/crypto.h
225.Ft struct tm *
226.Fo OPENSSL_gmtime
227.Fa "const time_t *time"
228.Fa "struct tm *out_tm"
229.Fc
230.In openssl/posix_time.h
231.Ft int
232.Fo OPENSSL_timegm
233.Fa "const struct tm *tm"
234.Fa "time_t *out_time"
235.Fc
236.Ft int
237.Fo OPENSSL_posix_to_tm
238.Fa "int64_t time"
239.Fa "struct tm *out_tm"
240.Fc
241.Ft int
242.Fo OPENSSL_tm_to_posix
243.Fa "struct tm *t_tm"
244.Fa "int64_t *out"
245.Fc
246.Sh DESCRIPTION
247An
248.Vt ASN1_TIME
249object is a shallow wrapper around a string containing an ASN.1
250.Vt Time
251value in the restricted format valid in X.509 certificates.
252An
253.Vt ASN1_TIME
254object is either an
255.Vt ASN1_UTCTIME
256object containing a string of the format
257.Ar YYMMDDHHMMSS Ns Cm Z
258which is valid for the years 1950 to 2049, or an
259.Vt ASN1_GENERALIZEDTIME
260object containing a string of the format
261.Ar YYYYMMDDHHMMSS Ns Cm Z
262which is valid for the years 0000 to 1949 and 2050 to 9999.
263In both cases, the mandatory suffix
264.Sq Cm Z
265represents the GMT time zone.
266LibreSSL by design does not support the full syntax of ASN.1 times.
267In particular, it neither supports fractional seconds
268nor any other time zone.
269.Pp
270The functions
271.Fn ASN1_TIME_set ,
272.Fn ASN1_UTCTIME_set ,
273and
274.Fn ASN1_GENERALIZEDTIME_set
275set the time object
276.Fa s
277to the time represented by the
278.Vt time_t
279value
280.Fa t .
281If
282.Fa s
283is
284.Dv NULL ,
285a new time object is allocated and returned.
286.Pp
287The functions
288.Fn ASN1_TIME_adj ,
289.Fn ASN1_UTCTIME_adj ,
290and
291.Fn ASN1_GENERALIZEDTIME_adj
292set the time object
293.Fa s
294to the time represented by the time
295.Fa offset_day
296and
297.Fa offset_sec
298after the
299.Vt time_t
300value
301.Fa t .
302The values of
303.Fa offset_day
304or
305.Fa offset_sec
306can be negative to set a time before
307.Fa t .
308The
309.Fa offset_sec
310value can also exceed the number of seconds in a day.
311If
312.Fa s
313is
314.Dv NULL ,
315a new time object is allocated and returned.
316.Pp
317.Fn ASN1_TIME_adj
318may change the type from
319.Vt ASN1_GENERALIZEDTIME
320to
321.Vt ASN1_UTCTIME
322or vice versa depending on the resulting year.
323The functions
324.Fn ASN1_UTCTIME_adj
325and
326.Fn ASN1_GENERALIZEDTIME_adj
327do not modify the type of the return object.
328.Pp
329The functions
330.Fn ASN1_TIME_set_string ,
331.Fn ASN1_TIME_set_string_X509 ,
332.Fn ASN1_UTCTIME_set_string ,
333and
334.Fn ASN1_GENERALIZEDTIME_set_string
335set the time object
336.Fa s
337to the time string
338.Fa str ,
339which must be in appropriate ASN.1 time format:
340YYMMDDHHMMSSZ for
341.Vt ASN1_UTCTIME ,
342YYYYMMDDHHMMSSZ for
343.Vt ASN1_GENERALIZEDTIME ,
344or either of the two for
345.Vt ASN1_TIME .
346The string
347.Fa str
348is copied into
349.Fa s .
350If
351.Fa s
352is
353.Dv NULL ,
354these functions only perform a format check on
355.Fa str .
356.Pp
357In LibreSSL,
358.Fn ASN1_TIME_set_string
359and
360.Fn ASN1_TIME_set_string_X509
361behave identically and always set the time object
362to a valid value to use in an X.509 certificate.
363.Fn ASN1_GENERALIZEDTIME_set_string
364may encode a time string that is not valid in an X.509 certificate.
365.Pp
366The function
367.Fn ASN1_TIME_normalize
368converts an
369.Vt ASN1_GENERALIZEDTIME
370into a time value that can be used in a certificate
371by changing it to an
372.Vt ASN1_UTCTIME
373if possible.
374It has no effect on an
375.Vt ASN1_UTCTIME .
376.Pp
377The functions
378.Fn ASN1_TIME_check ,
379.Fn ASN1_UTCTIME_check ,
380and
381.Fn ASN1_GENERALIZEDTIME_check
382check the syntax of the time string contained in the object
383.Fa s .
384.Pp
385The functions
386.Fn ASN1_TIME_print ,
387.Fn ASN1_UTCTIME_print ,
388and
389.Fn ASN1_GENERALIZEDTIME_print
390print out the time
391.Fa s
392to
393.Vt BIO
394.Fa b
395in human readable format.
396It will be of the format MMM DD HH:MM:SS YYYY [GMT], for example "Feb 3
39700:55:52 2015 GMT".
398It does not include a newline.
399If the time string has an invalid format,
400it prints out "Bad time value" and returns an error.
401.Pp
402The function
403.Fn ASN1_TIME_to_tm
404converts the time
405.Fa s
406to the standard
407.Vt tm
408structure.
409If
410.Fa s
411is
412.Dv NULL ,
413then the current time is converted.
414The output time is always in the GMT time zone.
415The
416.Fa tm_sec , tm_min , tm_hour , tm_mday , tm_mon ,
417and
418.Fa tm_year
419fields of the
420.Vt tm
421structure are set to the proper values,
422whereas all other fields are set to 0.
423If
424.Fa tm
425is
426.Dv NULL ,
427this function performs a format check on
428.Fa s
429only.
430.Pp
431The function
432.Fn ASN1_TIME_diff
433sets
434.Pf * Fa pday
435and
436.Pf * Fa psec
437to the time difference between
438.Fa from
439and
440.Fa to .
441If
442.Fa to
443represents a time later than
444.Fa from ,
445then one or both (depending on the time difference) of
446.Pf * Fa pday
447and
448.Pf * Fa psec
449will be positive.
450If
451.Fa to
452represents a time earlier than
453.Fa from ,
454then one or both of
455.Pf * Fa pday
456and
457.Pf * Fa psec
458will be negative.
459If
460.Fa to
461and
462.Fa from
463represent the same time, then
464.Pf * Fa pday
465and
466.Pf * Fa psec
467will both be zero.
468If both
469.Pf * Fa pday
470and
471.Pf * Fa psec
472are nonzero, they will always have the same sign.
473The value of
474.Pf * Fa psec
475will always be less than the number of seconds in a day.
476If
477.Fa from
478or
479.Fa to
480is
481.Dv NULL ,
482the current time is used.
483.Pp
484The functions
485.Fn ASN1_TIME_cmp_time_t ,
486.Fn ASN1_UTCTIME_cmp_time_t ,
487and
488.Fn ASN1_TIME_compare
489compare the two times represented by
490.Fa s
491and
492.Fa t .
493.Pp
494The function
495.Fn ASN1_TIME_to_generalizedtime
496converts the
497.Vt ASN1_TIME
498.Fa t
499to an
500.Vt ASN1_GENERALIZEDTIME ,
501regardless of year.
502If either
503.Fa out
504or
505.Pf * Fa out
506is
507.Dv NULL ,
508then a new object is allocated and must be freed after use.
509.Pp
510The
511.Vt ASN1_TIME ,
512.Vt ASN1_UTCTIME ,
513and
514.Vt ASN1_GENERALIZEDTIME
515objects are represented as
516.Vt ASN1_STRING
517objects internally and can be freed using
518.Xr ASN1_STRING_free 3 .
519.Pp
520It is recommended that
521.Vt ASN1_TIME
522functions be used instead of
523.Vt ASN1_UTCTIME
524or
525.Vt ASN1_GENERALIZEDTIME
526functions because the
527.Vt ASN1_UTCTIME
528and
529.Vt ASN1_GENERALIZEDTIME
530functions act only on that specific time format, while the
531.Vt ASN1_TIME
532functions operate on either format.
533.Pp
534.Fn OPENSSL_gmtime
535converts a time_t value in
536.Fa time
537to a struct tm in
538.Fa out_tm
539and also returns the struct passed in on success.
540.Pp
541.Fn OPENSSL_timegm
542converts a time structure in UTC time in
543.Fa tm
544to a time_t value in
545.Fa out_time .
546.Pp
547.Fn OPENSSL_posix_to_tm
548converts an
549.Vt int64_t
550POSIX time value in
551.Fa time ,
552which must be in the range of year 0 to 9999,
553to a broken out time value in
554.Fa tm .
555.Pp
556.Fn OPENSSL_tm_to_posix
557converts a time value between the years 0 and 9999 in
558.Fa tm
559to a POSIX time value in
560.Fa out .
561.Sh RETURN VALUES
562.Fn ASN1_TIME_set ,
563.Fn ASN1_UTCTIME_set ,
564.Fn ASN1_GENERALIZEDTIME_set ,
565.Fn ASN1_TIME_adj ,
566.Fn ASN1_UTCTIME_adj ,
567.Fn ASN1_GENERALIZEDTIME_adj ,
568and
569.Fn ASN1_TIME_to_generalizedtime
570return a pointer to a time object or
571.Dv NULL
572if an error occurred.
573.Pp
574.Fn ASN1_TIME_set_string ,
575.Fn ASN1_TIME_set_string_X509 ,
576.Fn ASN1_UTCTIME_set_string ,
577and
578.Fn ASN1_GENERALIZEDTIME_set_string
579return 1 if the time value is successfully set or 0 otherwise.
580.Pp
581.Fn ASN1_TIME_normalize
582returns 1 on success or 0 on error.
583.Pp
584.Fn ASN1_TIME_check ,
585.Fn ASN1_UTCTIME_check ,
586and
587.Fn ASN1_GENERALIZEDTIME_check
588return 1 if the time string contained in the object is syntactically
589correct or 0 otherwise.
590.Pp
591.Fn ASN1_TIME_print ,
592.Fn ASN1_UTCTIME_print ,
593and
594.Fn ASN1_GENERALIZEDTIME_print
595return 1 if the time is successfully printed or 0 if an error
596occurred (I/O error or invalid time format).
597.Pp
598.Fn ASN1_TIME_to_tm
599returns 1 if the time is successfully parsed
600or 0 if an error occurred, usually due to an invalid time format.
601.Pp
602.Fn ASN1_TIME_diff
603returns 1 for success or 0 for failure.
604It can for example fail if a time string passed in has invalid syntax.
605.Pp
606.Fn ASN1_TIME_cmp_time_t ,
607.Fn ASN1_UTCTIME_cmp_time_t ,
608and
609.Fn ASN1_TIME_compare
610return \-1 if
611.Fa s
612is earlier than
613.Fa t ,
6140 if both are equal, 1 if
615.Fa s
616is later than
617.Fa t ,
618or \-2 on error.
619.Pp
620.Fn OPENSSL_timegm
621returns 1 for success or 0 for failure.
622It can fail if the time is not representable in a time_t,
623or falls outside the range allowed in RFC 5280 times.
624.Pp
625.Fn OPENSSL_gmtime
626returns
627.Fa out_tm
628on success or NULL for failure.
629It can fail if the time is not representable in a struct tm,
630or falls outside the range allowed in RFC 5280 times.
631.Pp
632.Fn OPENSSL_posix_to_tm
633and
634.Fn OPENSSL_tm_to_posix
635return 1 for success or 0 on failure.
636It is a failure if the year is less than 0 or more than 9999.
637.Sh EXAMPLES
638Set a time object to one hour after the current time and print it
639out:
640.Bd -literal -offset indent
641#include <time.h>
642#include <openssl/asn1.h>
643
644ASN1_TIME *asn1_time;
645time_t t;
646BIO *b;
647
648t = time(NULL);
649asn1_time = ASN1_TIME_adj(NULL, t, 0, 60 * 60);
650b = BIO_new_fp(stdout, BIO_NOCLOSE);
651if (asn1_time != NULL) {
652 ASN1_TIME_print(b, asn1_time);
653 BIO_printf(b, "\en");
654} else {
655 BIO_printf(b, "Time out of range or un-representable\en");
656}
657ASN1_STRING_free(asn1_time);
658BIO_free(b);
659.Ed
660.Sh SEE ALSO
661.Xr ASN1_TIME_new 3 ,
662.Xr X509_cmp_time 3
663.Sh STANDARDS
664The usage of the ASN.1
665.Vt Time ,
666.Vt UTCTime ,
667and
668.Vt GeneralizedTime
669data types in X.509 certificates is specified in
670RFC 5280, Internet X.509 Public Key Infrastructure Certificate and
671Certificate Revocation List (CRL) Profile,
672section 4.1.2.5 (TBS Certificate Validity).
673.Sh HISTORY
674.Fn ASN1_UTCTIME_check
675and
676.Fn ASN1_UTCTIME_print
677first appeared in SSLeay 0.5.1.
678.Fn ASN1_UTCTIME_set
679first appeared in SSLeay 0.6.0.
680.Fn ASN1_UTCTIME_set_string
681first appeared in SSLeay 0.9.0.
682All these functions have been available since
683.Ox 2.4 .
684.Pp
685.Fn ASN1_TIME_set ,
686.Fn ASN1_GENERALIZEDTIME_set ,
687.Fn ASN1_GENERALIZEDTIME_set_string ,
688.Fn ASN1_GENERALIZEDTIME_check ,
689.Fn ASN1_TIME_print ,
690and
691.Fn ASN1_GENERALIZEDTIME_print
692first appeared in OpenSSL 0.9.2b and have been available since
693.Ox 2.6 .
694.Pp
695.Fn ASN1_UTCTIME_cmp_time_t
696first appeared in OpenSSL 0.9.6 and has been available since
697.Ox 2.9 .
698.Pp
699.Fn ASN1_TIME_check
700and
701.Fn ASN1_TIME_to_generalizedtime
702first appeared in OpenSSL 0.9.7 and have been available since
703.Ox 3.2 .
704.Pp
705.Fn ASN1_TIME_adj ,
706.Fn ASN1_UTCTIME_adj ,
707.Fn ASN1_GENERALIZEDTIME_adj ,
708and
709.Fn ASN1_TIME_set_string
710first appeared in OpenSSL 1.0.0 and have been available since
711.Ox 4.9 .
712.Pp
713.Fn ASN1_TIME_diff
714first appeared in OpenSSL 1.0.2 and have been available since
715.Ox 7.1 .
716.Pp
717.Fn ASN1_TIME_set_string_X509 ,
718.Fn ASN1_TIME_normalize ,
719.Fn ASN1_TIME_to_tm ,
720.Fn ASN1_TIME_cmp_time_t ,
721and
722.Fn ASN1_TIME_compare
723first appeared in OpenSSL 1.1.1 and have been available since
724.Ox 7.2 .
725.Pp
726.Fn OPENSSL_gmtime
727first appeared in OpenSSL 0.9.7.
728.Fn OPENSSL_timegm ,
729.Fn OPENSSL_posix_to_tm ,
730and
731.Fn OPENSSL_tm_to_posix
732first appeared in BoringSSL;
733all these functions have been available since
734.Ox 7.5 .
735.Sh CAVEATS
736Some applications add offset times directly to a
737.Vt time_t
738value and pass the results to
739.Fn ASN1_TIME_set
740(or equivalent).
741This can cause problems as the
742.Vt time_t
743value can overflow on some systems resulting in unexpected results.
744New applications should use
745.Fn ASN1_TIME_adj
746instead and pass the offset value in the
747.Fa offset_sec
748and
749.Fa offset_day
750parameters instead of directly manipulating a
751.Vt time_t
752value.
diff --git a/src/lib/libcrypto/man/ASN1_TYPE_get.3 b/src/lib/libcrypto/man/ASN1_TYPE_get.3
deleted file mode 100644
index 16af168d91..0000000000
--- a/src/lib/libcrypto/man/ASN1_TYPE_get.3
+++ /dev/null
@@ -1,443 +0,0 @@
1.\" $OpenBSD: ASN1_TYPE_get.3,v 1.19 2023/10/09 16:06:01 tb Exp $
2.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2015, 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: October 9 2023 $
69.Dt ASN1_TYPE_GET 3
70.Os
71.Sh NAME
72.Nm ASN1_TYPE_new ,
73.Nm ASN1_TYPE_free ,
74.Nm ASN1_TYPE_get ,
75.Nm ASN1_TYPE_set ,
76.Nm ASN1_TYPE_set1 ,
77.Nm ASN1_TYPE_set_octetstring ,
78.Nm ASN1_TYPE_get_octetstring ,
79.Nm ASN1_TYPE_set_int_octetstring ,
80.Nm ASN1_TYPE_get_int_octetstring ,
81.Nm ASN1_TYPE_cmp
82.Nd ASN.1 objects of arbitrary type
83.Sh SYNOPSIS
84.In openssl/asn1.h
85.Ft ASN1_TYPE *
86.Fn ASN1_TYPE_new void
87.Ft void
88.Fn ASN1_TYPE_free "ASN1_TYPE *a"
89.Ft int
90.Fo ASN1_TYPE_get
91.Fa "const ASN1_TYPE *a"
92.Fc
93.Ft void
94.Fo ASN1_TYPE_set
95.Fa "ASN1_TYPE *a"
96.Fa "int type"
97.Fa "void *value"
98.Fc
99.Ft int
100.Fo ASN1_TYPE_set1
101.Fa "ASN1_TYPE *a"
102.Fa "int type"
103.Fa "const void *value"
104.Fc
105.Ft int
106.Fo ASN1_TYPE_set_octetstring
107.Fa "ASN1_TYPE *a"
108.Fa "const unsigned char *data"
109.Fa "int len"
110.Fc
111.Ft int
112.Fo ASN1_TYPE_get_octetstring
113.Fa "const ASN1_TYPE *a"
114.Fa "unsigned char *buffer"
115.Fa "int buflen"
116.Fc
117.Ft int
118.Fo ASN1_TYPE_set_int_octetstring
119.Fa "ASN1_TYPE *a"
120.Fa "long num"
121.Fa "const unsigned char *data"
122.Fa "int len"
123.Fc
124.Ft int
125.Fo ASN1_TYPE_get_int_octetstring
126.Fa "const ASN1_TYPE *a",
127.Fa "long *num"
128.Fa "unsigned char *buffer",
129.Fa "int buflen"
130.Fc
131.Ft int
132.Fo ASN1_TYPE_cmp
133.Fa "const ASN1_TYPE *a"
134.Fa "const ASN1_TYPE *b"
135.Fc
136.Sh DESCRIPTION
137The
138.Vt ASN1_TYPE
139data type and the
140.Dv V_ASN1_ANY
141type identifier constant represent the ASN.1 ANY type.
142An
143.Vt ASN1_TYPE
144object can store an ASN.1 value of arbitrary type,
145including constructed types such as a SEQUENCE.
146It also remembers internally which type it currently holds.
147.Pp
148.Fn ASN1_TYPE_new
149allocates and initializes an empty
150.Vt ASN1_TYPE
151object of type
152.Dv V_ASN1_UNDEF .
153.Pp
154.Fn ASN1_TYPE_free
155frees
156.Fa a
157including the value stored in it, if any.
158If
159.Fa a
160is a
161.Dv NULL
162pointer, no action occurs.
163.Pp
164.Fn ASN1_TYPE_get
165returns the type currently held by
166.Fa a ,
167represented by one of the
168.Dv V_ASN1_*
169constants defined in
170.In openssl/asn1.h .
171.Pp
172.Fn ASN1_TYPE_set
173frees the value contained in
174.Fa a ,
175if any, and sets the
176.Fa value
177and
178.Fa type
179now held in
180.Fa a .
181This function uses the pointer
182.Fa value
183internally so it must
184.Sy not
185be freed up after the call.
186.Pp
187.Fn ASN1_TYPE_set1
188sets the type held by
189.Fa a
190to
191.Fa type
192and its value to a copy of
193.Fa value .
194If copying succeeds, the previous value that was contained in
195.Fa a
196is freed.
197If copying fails,
198.Fa a
199remains unchanged.
200.Pp
201The type and meaning of the
202.Fa value
203argument of
204.Fn ASN1_TYPE_set
205and
206.Fn ASN1_TYPE_set1
207is determined by the
208.Fa type
209argument.
210If
211.Fa type
212is
213.Dv V_ASN1_NULL ,
214.Fa value
215is ignored.
216If
217.Fa type
218is
219.Dv V_ASN1_BOOLEAN ,
220then the boolean is set to TRUE if
221.Fa value
222is not
223.Dv NULL .
224If
225.Fa type
226is
227.Dv V_ASN1_OBJECT ,
228then
229.Fa value
230is an
231.Vt ASN1_OBJECT
232structure.
233Otherwise
234.Fa type
235is an
236.Vt ASN1_STRING
237structure.
238If
239.Fa type
240corresponds to a primitive type or a string type, then the contents
241of the
242.Vt ASN1_STRING
243contains the content octets of the type.
244If
245.Fa type
246corresponds to a constructed type or a tagged type
247.Pq Dv V_ASN1_SEQUENCE , V_ASN1_SET , No or Dv V_ASN1_OTHER ,
248then the
249.Vt ASN1_STRING
250contains the entire ASN.1 encoding verbatim, including tag and
251length octets.
252.Pp
253.Fn ASN1_TYPE_set_octetstring
254allocates a new
255.Vt ASN1_OCTET_STRING
256object, copies
257.Fa len
258bytes of
259.Fa data
260into it using
261.Xr ASN1_STRING_set 3 ,
262and replaces the value of
263.Fa a
264with it by calling
265.Fn ASN1_TYPE_set
266with a type of
267.Dv V_ASN1_OCTET_STRING .
268.Pp
269.Fn ASN1_TYPE_get_octetstring
270copies the contents of the
271.Vt ASN1_OCTET_STRING
272object contained in
273.Fa a ,
274but not more than
275.Fa buflen
276bytes, into the
277.Fa buffer
278provided by the caller.
279.Pp
280.Fn ASN1_TYPE_set_int_octetstring
281frees the value contained in
282.Fa a ,
283if any, sets its type to
284.Dv V_ASN1_SEQUENCE ,
285and sets its value to a two-element ASN.1 sequence consisting of
286an ASN.1 INTEGER object with the value
287.Fa num
288and an ASN.1 OCTET STRING object
289containing a copy of the
290.Fa len
291bytes pointed to by
292.Fa data .
293.Pp
294.Fn ASN1_TYPE_get_int_octetstring
295copies the integer value from the first element of the ASN.1 sequence
296.Fa a
297to
298.Pf * Fa num
299unless
300.Fa num
301is a
302.Dv NULL
303pointer and copies the octet string value from the second element,
304but not more than
305.Fa buflen
306bytes, into the
307.Fa buffer
308provided by the caller unless
309.Fa buffer
310is a
311.Dv NULL
312pointer.
313.Pp
314.Fn ASN1_TYPE_cmp
315checks that
316.Fa a
317and
318.Fa b
319hold the same type, the same value, and are encoded in the same way.
320.Pp
321If the types agree and the values have the same meaning but are
322encoded differently, they are considered different.
323For example, a boolean value is represented
324using a single content octet.
325Under BER, any non-zero octet represents the TRUE value, but
326.Fn ASN1_TYPE_cmp
327will only report a match if the content octet is the same.
328.Pp
329If either or both of the arguments passed to
330.Fn ASN1_TYPE_cmp
331is
332.Dv NULL ,
333the result is a mismatch.
334Technically, if both arguments are
335.Dv NULL ,
336the two types could be absent OPTIONAL fields and so should match,
337however passing
338.Dv NULL
339values could also indicate a programming error (for example an
340unparsable type which returns
341.Dv NULL )
342for types which do
343.Sy not
344match.
345So applications should handle the case of two absent values separately.
346.Sh RETURN VALUES
347.Fn ASN1_TYPE_new
348returns the new
349.Vt ASN1_TYPE
350object or
351.Dv NULL
352if an error occurs.
353.Pp
354.Fn ASN1_TYPE_get
355returns the type currently held by
356.Fa a
357or 0 if an error occurs.
358The latter can happen if
359.Fa a
360does not contain a value even though its type is not
361.Dv V_ASN1_NULL .
362For example, it will always happen for empty objects
363newly constructed with
364.Fn ASN1_TYPE_new .
365.Pp
366.Fn ASN1_TYPE_set1 ,
367.Fn ASN1_TYPE_set_octetstring ,
368and
369.Fn ASN1_TYPE_set_int_octetstring
370return 1 on success or 0 on failure.
371.Pp
372.Fn ASN1_TYPE_get_octetstring
373returns the number of data bytes contained in the
374.Vt ASN1_OCTET_STRING
375object contained in
376.Fa a
377or \-1 if
378.Fa a
379is not of the type
380.Dv V_ASN1_OCTET_STRING
381or does not contain any object.
382If the return value is greater than the
383.Fa buflen
384argument, the content was truncated when copied to the
385.Fa buffer .
386.Pp
387.Fn ASN1_TYPE_get_int_octetstring
388returns the number of data bytes contained in the
389.Vt ASN1_OCTET_STRING
390object that is the second element of the ASN.1 sequence
391.Fa a
392or \-1 if
393.Fa a
394is not of the type
395.Dv V_ASN1_SEQUENCE
396or if decoding fails.
397If the return value is greater than the
398.Fa buflen
399argument, the content was truncated when copied to the
400.Fa buffer .
401.Pp
402.Fn ASN1_TYPE_cmp
403returns 0 for a match or non-zero for a mismatch.
404.Sh SEE ALSO
405.Xr ASN1_generate_nconf 3 ,
406.Xr ASN1_get_object 3 ,
407.Xr ASN1_item_free 3 ,
408.Xr ASN1_OBJECT_new 3 ,
409.Xr ASN1_parse_dump 3 ,
410.Xr ASN1_put_object 3 ,
411.Xr ASN1_STRING_dup 3 ,
412.Xr ASN1_STRING_new 3 ,
413.Xr crypto 3 ,
414.Xr d2i_ASN1_NULL 3 ,
415.Xr d2i_ASN1_SEQUENCE_ANY 3 ,
416.Xr d2i_ASN1_TYPE 3 ,
417.Xr OBJ_dup 3
418.Sh HISTORY
419.Fn ASN1_TYPE_new
420and
421.Fn ASN1_TYPE_free
422first appeared in SSLeay 0.5.1,
423.Fn ASN1_TYPE_get
424and
425.Fn ASN1_TYPE_set
426in SSLeay 0.8.0, and
427.Fn ASN1_TYPE_set_octetstring ,
428.Fn ASN1_TYPE_get_octetstring ,
429.Fn ASN1_TYPE_set_int_octetstring ,
430and
431.Fn ASN1_TYPE_get_int_octetstring
432in SSLeay 0.9.0.
433These functions have been available since
434.Ox 2.4 .
435.Pp
436.Fn ASN1_TYPE_set1
437first appeared in OpenSSL 0.9.8h and has been available since
438.Ox 4.5 .
439.Pp
440.Fn ASN1_TYPE_cmp
441first appeared in OpenSSL 0.9.8zd, 1.0.0p, and 1.0.1k
442and has been available since
443.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/ASN1_UNIVERSALSTRING_to_string.3 b/src/lib/libcrypto/man/ASN1_UNIVERSALSTRING_to_string.3
deleted file mode 100644
index 2af675295b..0000000000
--- a/src/lib/libcrypto/man/ASN1_UNIVERSALSTRING_to_string.3
+++ /dev/null
@@ -1,64 +0,0 @@
1.\" $OpenBSD: ASN1_UNIVERSALSTRING_to_string.3,v 1.1 2021/11/15 13:39:40 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 15 2021 $
18.Dt ASN1_UNIVERSALSTRING_TO_STRING 3
19.Os
20.Sh NAME
21.Nm ASN1_UNIVERSALSTRING_to_string
22.Nd recode UTF-32 to ISO Latin-1
23.Sh SYNOPSIS
24.In openssl/asn1.h
25.Ft int
26.Fo ASN1_UNIVERSALSTRING_to_string
27.Fa "ASN1_UNIVERSALSTRING *string"
28.Fc
29.Sh DESCRIPTION
30.Fn ASN1_UNIVERSALSTRING_to_string
31assumes that the given
32.Fa string
33is encoded in UTF-32, recodes it in place to ISO Latin-1,
34and changes the type according to
35.Xr ASN1_PRINTABLE_type 3 .
36.Pp
37.Fn ASN1_UNIVERSALSTRING_to_string
38fails and leaves the
39.Fa string
40unchanged if its
41.Xr ASN1_STRING_type 3
42is not
43.Dv V_ASN1_UNIVERSALSTRING ,
44if its
45.Xr ASN1_STRING_length 3
46is not a multiple of four bytes,
47or if any of its characters cannot be represented in ISO Latin-1.
48.Pp
49In case of success, the
50.Xr ASN1_STRING_length 3
51of the
52.Fa string
53is reduced by a factor of four.
54.Sh RETURN VALUES
55.Fn ASN1_UNIVERSALSTRING_to_string
56returns 1 on success or 0 on failure.
57.Sh SEE ALSO
58.Xr ASN1_mbstring_copy 3 ,
59.Xr ASN1_STRING_new 3 ,
60.Xr ASN1_STRING_to_UTF8 3
61.Sh HISTORY
62.Fn ASN1_UNIVERSALSTRING_to_string
63first appeared in SSLeay 0.8.0 and has been available since
64.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/ASN1_generate_nconf.3 b/src/lib/libcrypto/man/ASN1_generate_nconf.3
deleted file mode 100644
index b15d4295a9..0000000000
--- a/src/lib/libcrypto/man/ASN1_generate_nconf.3
+++ /dev/null
@@ -1,394 +0,0 @@
1.\" $OpenBSD: ASN1_generate_nconf.3,v 1.13 2019/06/10 14:58:48 schwarze Exp $
2.\" OpenSSL 05ea606a Fri May 20 20:52:46 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson.
5.\" Copyright (c) 2002, 2003, 2006-2009, 2013-2015 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: June 10 2019 $
53.Dt ASN1_GENERATE_NCONF 3
54.Os
55.Sh NAME
56.Nm ASN1_generate_nconf ,
57.Nm ASN1_generate_v3
58.Nd ASN.1 generation functions
59.Sh SYNOPSIS
60.In openssl/asn1.h
61.Ft ASN1_TYPE *
62.Fo ASN1_generate_nconf
63.Fa "const char *str"
64.Fa "CONF *nconf"
65.Fc
66.Ft ASN1_TYPE *
67.Fo ASN1_generate_v3
68.Fa "const char *str"
69.Fa "X509V3_CTX *cnf"
70.Fc
71.Sh DESCRIPTION
72These functions generate the ASN.1 encoding of a string in an
73.Vt ASN1_TYPE
74structure.
75.Pp
76.Fa str
77contains the string to encode
78.Fa nconf
79or
80.Fa cnf
81contains the optional configuration information
82where additional strings will be read from.
83.Fa nconf
84will typically come from a config file whereas
85.Fa cnf
86is obtained from an
87.Vt X509V3_CTX
88structure which will typically be used
89by X509 v3 certificate extension functions.
90.Fa cnf
91or
92.Fa nconf
93can be set to
94.Dv NULL
95if no additional configuration will be used.
96.Sh GENERATION STRING FORMAT
97The actual data encoded is determined by the string
98.Fa str
99and the configuration information.
100The general format of the string is:
101.Pp
102.D1 Oo Ar modifier , Oc Ns Ar type Ns Op : Ns Ar value
103.Pp
104That is zero or more comma separated modifiers followed by a type
105followed by an optional colon and a value.
106The formats of
107.Ar type ,
108.Ar value
109and
110.Ar modifier
111are explained below.
112.Ss Supported types
113The supported types are listed below.
114Unless otherwise specified, only the
115.Cm ASCII
116format is permissible.
117.Bl -tag -width Ds
118.It Cm BOOLEAN , BOOL
119This encodes a boolean type.
120The
121.Ar value
122string is mandatory and should be
123.Cm TRUE
124or
125.Cm FALSE .
126Additionally
127.Cm true ,
128.Cm Y ,
129.Cm y ,
130.Cm YES ,
131.Cm yes ,
132.Cm false ,
133.Cm N ,
134.Cm n ,
135.Cm NO
136and
137.Cm no
138are acceptable.
139.It Cm NULL
140Encode the NULL type.
141The
142.Ar value
143string must not be present.
144.It Cm INTEGER , INT
145Encodes an ASN.1 INTEGER type.
146The
147.Ar value
148string represents the value of the integer.
149It can be prefaced by a minus sign
150and is normally interpreted as a decimal value unless the prefix
151.Cm 0x
152is included.
153.It Cm ENUMERATED , ENUM
154Encodes the ASN.1 ENUMERATED type.
155It is otherwise identical to
156.Cm INTEGER .
157.It Cm OBJECT , OID
158Encodes an ASN.1 OBJECT IDENTIFIER.
159The
160.Ar value
161string can be a short name, a long name, or numerical format.
162.It Cm UTCTIME , UTC
163Encodes an ASN.1 UTCTime structure.
164The value should be in the format
165.Ar YYMMDDHHMMSSZ .
166.It Cm GENERALIZEDTIME , GENTIME
167Encodes an ASN.1 GeneralizedTime structure.
168The value should be in the format
169.Ar YYYYMMDDHHMMSSZ .
170.It Cm OCTETSTRING , OCT
171Encodes an ASN.1 OCTET STRING.
172.Ar value
173represents the contents of this structure.
174The format strings
175.Cm ASCII
176and
177.Cm HEX
178can be used to specify the format of
179.Ar value .
180.It Cm BITSTRING , BITSTR
181Encodes an ASN.1 BIT STRING.
182.Ar value
183represents the contents of this structure.
184The format strings
185.Cm ASCII ,
186.Cm HEX ,
187and
188.Cm BITLIST
189can be used to specify the format of
190.Ar value .
191.Pp
192If the format is anything other than
193.Cm BITLIST ,
194the number of unused bits is set to zero.
195.It Xo
196.Cm BMPSTRING , BMP ,
197.Cm GeneralString ,
198.Cm IA5STRING , IA5 ,
199.Cm NUMERICSTRING , NUMERIC ,
200.Cm PRINTABLESTRING , PRINTABLE ,
201.Cm T61STRING , T61 ,
202.Cm TELETEXSTRING ,
203.Cm UNIVERSALSTRING , UNIV ,
204.Cm UTF8String , UTF8 ,
205.Cm VISIBLESTRING , VISIBLE
206.Xc
207These encode the corresponding string types.
208.Ar value
209represents the contents of this structure.
210The format can be
211.Cm ASCII
212or
213.Cm UTF8 .
214.It Cm SEQUENCE , SEQ , SET
215Formats the result as an ASN.1 SEQUENCE or SET type.
216.Ar value
217should be a section name which will contain the contents.
218The field names in the section are ignored
219and the values are in the generated string format.
220If
221.Ar value
222is absent, then an empty SEQUENCE will be encoded.
223.El
224.Ss Modifiers
225Modifiers affect the following structure.
226They can be used to add EXPLICIT or IMPLICIT tagging, add wrappers,
227or to change the string format of the final type and value.
228The supported formats are:
229.Bl -tag -width Ds
230.It Cm EXPLICIT , EXP
231Add an explicit tag to the following structure.
232This string should be followed by a colon
233and the tag value to use as a decimal value.
234.Pp
235By following the number with
236.Cm U ,
237.Cm A ,
238.Cm P
239or
240.Cm C ,
241UNIVERSAL, APPLICATION, PRIVATE or CONTEXT SPECIFIC tagging can be used.
242The default is CONTEXT SPECIFIC.
243.It Cm IMPLICIT , IMP
244This is the same as
245.Cm EXPLICIT
246except IMPLICIT tagging is used instead.
247.It Cm OCTWRAP , SEQWRAP , SETWRAP , BITWRAP
248The following structure is surrounded by
249an OCTET STRING, a SEQUENCE, a SET, or a BIT STRING, respectively.
250For a BIT STRING the number of unused bits is set to zero.
251.It Cm FORMAT
252This specifies the format of the ultimate value.
253It should be followed by a colon and one of the strings
254.Cm ASCII ,
255.Cm UTF8 ,
256.Cm HEX ,
257or
258.Cm BITLIST .
259.Pp
260If no format specifier is included, then
261.Cm ASCII
262is used.
263If
264.Cm UTF8
265is specified, then the
266.Ar value
267string must be a valid UTF-8 string.
268For
269.Cm HEX ,
270the output must be a set of hex digits.
271.Cm BITLIST
272(which is only valid for a BIT STRING) is a comma separated list
273of the indices of the set bits, all other bits are zero.
274.El
275.Sh RETURN VALUES
276.Fn ASN1_generate_nconf
277and
278.Fn ASN1_generate_v3
279return the encoded data as an
280.Vt ASN1_TYPE
281structure or
282.Dv NULL
283if an error occurred.
284.Pp
285The error codes can be obtained by
286.Xr ERR_get_error 3 .
287.Sh EXAMPLES
288A simple
289.Vt IA5String :
290.Pp
291.Dl IA5STRING:Hello World
292.Pp
293An
294.Vt IA5String
295explicitly tagged:
296.Pp
297.Dl EXPLICIT:0,IA5STRING:Hello World
298.Pp
299An
300.Vt IA5String
301explicitly tagged using APPLICATION tagging:
302.Pp
303.Dl EXPLICIT:0A,IA5STRING:Hello World
304.Pp
305A BITSTRING with bits 1 and 5 set and all others zero:
306.Pp
307.Dl FORMAT:BITLIST,BITSTRING:1,5
308.Pp
309A more complex example using a config file to produce a
310SEQUENCE consisting of a BOOL an OID and a
311.Vt UTF8String :
312.Bd -literal -offset indent
313asn1 = SEQUENCE:seq_section
314
315[seq_section]
316
317field1 = BOOLEAN:TRUE
318field2 = OID:commonName
319field3 = UTF8:Third field
320.Ed
321.Pp
322This example produces an
323.Vt RSAPrivateKey
324structure.
325This is the key contained in the file
326.Pa client.pem
327in all OpenSSL distributions.
328Note that the field names such as
329.Qq coeff
330are ignored and are present just for clarity.
331.Bd -literal -offset 2n
332asn1=SEQUENCE:private_key
333[private_key]
334version=INTEGER:0
335
336n=INTEGER:0xBB6FE79432CC6EA2D8F970675A5A87BFBE1AFF0BE63E879F2AFFB93644\e
337D4D2C6D000430DEC66ABF47829E74B8C5108623A1C0EE8BE217B3AD8D36D5EB4FCA1D9
338
339e=INTEGER:0x010001
340
341d=INTEGER:0x6F05EAD2F27FFAEC84BEC360C4B928FD5F3A9865D0FCAAD291E2A52F4A\e
342F810DC6373278C006A0ABBA27DC8C63BF97F7E666E27C5284D7D3B1FFFE16B7A87B51D
343
344p=INTEGER:0xF3929B9435608F8A22C208D86795271D54EBDFB09DDEF539AB083DA912\e
345D4BD57
346
347q=INTEGER:0xC50016F89DFF2561347ED1186A46E150E28BF2D0F539A1594BBD7FE467\e
34846EC4F
349
350exp1=INTEGER:0x9E7D4326C924AFC1DEA40B45650134966D6F9DFA3A7F9D698CD4ABEA\e
3519C0A39B9
352
353exp2=INTEGER:0xBA84003BB95355AFB7C50DF140C60513D0BA51D637272E355E397779\e
354E7B2458F
355
356coeff=INTEGER:0x30B9E4F2AFA5AC679F920FC83F1F2DF1BAF1779CF989447FABC2F5\e
357628657053A
358.Ed
359.Pp
360This example is the corresponding public key in an ASN.1
361.Vt SubjectPublicKeyInfo
362structure:
363.Bd -literal -offset 2n
364# Start with a SEQUENCE
365asn1=SEQUENCE:pubkeyinfo
366
367# pubkeyinfo contains an algorithm identifier and the public key
368# wrapped in a BIT STRING
369[pubkeyinfo]
370algorithm=SEQUENCE:rsa_alg
371pubkey=BITWRAP,SEQUENCE:rsapubkey
372
373# algorithm ID for RSA is just an OID and a NULL
374[rsa_alg]
375algorithm=OID:rsaEncryption
376parameter=NULL
377
378# Actual public key: modulus and exponent
379[rsapubkey]
380n=INTEGER:0xBB6FE79432CC6EA2D8F970675A5A87BFBE1AFF0BE63E879F2AFFB93644\e
381D4D2C6D000430DEC66ABF47829E74B8C5108623A1C0EE8BE217B3AD8D36D5EB4FCA1D9
382
383e=INTEGER:0x010001
384.Ed
385.Sh SEE ALSO
386.Xr ASN1_TYPE_get 3 ,
387.Xr d2i_ASN1_TYPE 3 ,
388.Xr x509v3.cnf 5
389.Sh HISTORY
390.Fn ASN1_generate_nconf
391and
392.Fn ASN1_generate_v3
393first appeared in OpenSSL 0.9.8 and have been available since
394.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/ASN1_get_object.3 b/src/lib/libcrypto/man/ASN1_get_object.3
deleted file mode 100644
index 781b12ad5a..0000000000
--- a/src/lib/libcrypto/man/ASN1_get_object.3
+++ /dev/null
@@ -1,200 +0,0 @@
1.\" $OpenBSD: ASN1_get_object.3,v 1.2 2021/07/11 19:03:45 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 11 2021 $
18.Dt ASN1_GET_OBJECT 3
19.Os
20.Sh NAME
21.Nm ASN1_get_object
22.Nd parse identifier and length octets
23.Sh SYNOPSIS
24.In openssl/asn1.h
25.Ft int
26.Fo ASN1_get_object
27.Fa "const unsigned char **ber_in"
28.Fa "long *plength"
29.Fa "int *ptag"
30.Fa "int *pclass"
31.Fa "long omax"
32.Fc
33.Sh DESCRIPTION
34.Fn ASN1_get_object
35parses the identifier and length octets of a BER-encoded value.
36On function entry,
37.Pf * Fa ber_in
38is expected to point to the first identifier octet.
39If the identifier and length octets turn out to be valid,
40the function advances
41.Pf * Fa ber_in
42to the first content octet before returning.
43.Pp
44If the identifier octets are valid,
45.Fn ASN1_get_object
46stores the tag number in
47.Pf * Fa ptag
48and the class of the tag in
49.Pf * Fa pclass .
50The class is either
51.Dv V_ASN1_UNIVERSAL
52or
53.Dv V_ASN1_APPLICATION
54or
55.Dv V_ASN1_CONTEXT_SPECIFIC
56or
57.Dv V_ASN1_PRIVATE .
58.Pp
59If the length octets are valid, too,
60.Fn ASN1_get_object
61stores the number encoded in the length octets in
62.Pf * Fa plength .
63If the length octet indicates the indefinite form,
64.Pf * Fa plength
65is set to 0.
66.Pp
67.Fn ASN1_get_object
68inspects at most
69.Fa omax
70bytes.
71If parsing of the length octets remains incomplete after inspecting
72that number of bytes, parsing fails with
73.Dv ASN1_R_HEADER_TOO_LONG .
74.Sh RETURN VALUES
75Bits set in the return value of
76.Fn ASN1_get_object
77have the following meanings:
78.Bl -tag -width Ds
79.It 0x80
80An error occurred.
81One of the
82.Sx ERRORS
83described below has been set.
84.It 0x20 = Dv V_ASN1_CONSTRUCTED
85The encoding is constructed rather than primitive,
86and the identifier and length octets are valid.
87.It 0x01
88The length octet indicates the indefinite form.
89This bit can only occur if
90.Dv V_ASN1_CONSTRUCTED
91is also set.
92.El
93.Pp
94Consequently, the following combinations can occur:
95.Bl -tag -width Ds
96.It 0x00
97A valid primitive encoding.
98.It 0x20
99A valid constructed encoding, definite form.
100.It 0x21
101A valid constructed encoding, indefinite form.
102.It 0x80
103Either a primitive encoding with a valid tag and definite length,
104but the content octets won't fit into
105.Fa omax ,
106or parsing failed.
107Use
108.Xr ERR_GET_REASON 3
109to distinguish the two cases.
110.It 0xa0
111A constructed encoding with a valid tag and definite length,
112but the content octets won't fit into
113.Fa omax .
114.El
115.Pp
116The bit combinations 0x01, 0x81, and 0xa1 cannot occur as return values.
117.Sh ERRORS
118If the bit 0x80 is set in the return value,
119diagnostics can be retrieved with
120.Xr ERR_get_error 3 ,
121.Xr ERR_GET_REASON 3 ,
122and
123.Xr ERR_reason_error_string 3 :
124.Bl -tag -width Ds
125.It Dv ASN1_R_HEADER_TOO_LONG Qq "header too long"
126Inspecting
127.Fa omax
128bytes was insufficient to finish parsing,
129the tag number encoded in the identifier octets exceeds
130.Dv INT_MAX ,
131the number encoded in the length octets exceeds
132.Dv LONG_MAX ,
133or using the indefinite form for the length octets is attempted
134even though the encoding is primitive.
135.Pp
136In this case, the return value is exactly 0x80; no other bits are set.
137.Pp
138If the problem occurred while parsing the identifier octets,
139.Pf * Fa ptag
140and
141.Pf * Fa pclass
142remain unchanged.
143If the problem occurred while parsing the length octets,
144.Pf * Fa ptag
145and
146.Pf * Fa pclass
147are set according to the identifier octets.
148In both cases,
149.Pf * Fa ber_in
150and
151.Pf * Fa plength
152remain unchanged.
153.Pp
154The wording of the error message is confusing.
155On the one hand, the header might be just fine,
156and the root cause of the problem could be that the chosen
157.Fa omax
158argument was too small.
159On the other hand, outright BER syntax errors are also reported as
160.Dv ASN1_R_HEADER_TOO_LONG .
161.It Dv ASN1_R_TOO_LONG Qq "too long"
162The identifier and length octets are valid,
163but the content octets won't fit into
164.Fa omax .
165The following have been set as appropriate and can safely be inspected:
166.Pf * pclass ,
167.Pf * ptag ,
168.Pf * plength ,
169and the bits
170.Dv V_ASN1_CONSTRUCTED
171and 0x01 in the return value.
172The parse pointer
173.Pf * ber_in
174has been advanced to the first content octet.
175.Pp
176Again, the error message may occasionally sound confusing.
177The length of the content may be reasonable, and the root cause of
178the problem could be that the chosen
179.Fa omax
180argument was too small.
181.El
182.Sh SEE ALSO
183.Xr ASN1_item_d2i 3 ,
184.Xr ASN1_item_new 3 ,
185.Xr ASN1_parse_dump 3
186.Sh STANDARDS
187ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
188Information technology - ASN.1 encoding rules:
189Specification of Basic Encoding Rules (BER), Canonical Encoding
190Rules (CER) and Distinguished Encoding Rules (DER):
191.Bl -dash -offset 2n -width 1n -compact
192.It
193Section 8.1.2: Identifier octets
194.It
195Section 8.1.3: Length octets
196.El
197.Sh HISTORY
198.Fn ASN1_get_object
199first appeared in SSLeay 0.5.1 and has been available since
200.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/ASN1_item_d2i.3 b/src/lib/libcrypto/man/ASN1_item_d2i.3
deleted file mode 100644
index bc99f4a6da..0000000000
--- a/src/lib/libcrypto/man/ASN1_item_d2i.3
+++ /dev/null
@@ -1,492 +0,0 @@
1.\" $OpenBSD: ASN1_item_d2i.3,v 1.18 2023/05/01 07:37:45 tb Exp $
2.\" selective merge up to:
3.\" OpenSSL doc/man3/d2i_X509.pod 256989ce Jun 19 15:00:32 2020 +0200
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2002, 2003, 2015 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: May 1 2023 $
70.Dt ASN1_ITEM_D2I 3
71.Os
72.Sh NAME
73.Nm ASN1_item_d2i ,
74.Nm ASN1_item_d2i_bio ,
75.Nm ASN1_item_d2i_fp ,
76.Nm d2i_ASN1_TYPE ,
77.Nm ASN1_item_i2d ,
78.Nm ASN1_item_i2d_bio ,
79.Nm ASN1_item_i2d_fp ,
80.Nm i2d_ASN1_TYPE ,
81.Nm ASN1_item_dup ,
82.Nm ASN1_item_print
83.Nd decode and encode ASN.1 objects
84.Sh SYNOPSIS
85.In openssl/asn1.h
86.Ft ASN1_VALUE *
87.Fo ASN1_item_d2i
88.Fa "ASN1_VALUE **val_out"
89.Fa "const unsigned char **der_in"
90.Fa "long length"
91.Fa "const ASN1_ITEM *it"
92.Fc
93.Ft void *
94.Fo ASN1_item_d2i_bio
95.Fa "const ASN1_ITEM *it"
96.Fa "BIO *in_bio"
97.Fa "void *val_out"
98.Fc
99.Ft void *
100.Fo ASN1_item_d2i_fp
101.Fa "const ASN1_ITEM *it"
102.Fa "FILE *in_fp"
103.Fa "void *val_out"
104.Fc
105.Ft ASN1_TYPE *
106.Fo d2i_ASN1_TYPE
107.Fa "ASN1_TYPE **val_out"
108.Fa "const unsigned char **der_in"
109.Fa "long length"
110.Fc
111.Ft int
112.Fo ASN1_item_i2d
113.Fa "ASN1_VALUE *val_in"
114.Fa "unsigned char **der_out"
115.Fa "const ASN1_ITEM *it"
116.Fc
117.Ft int
118.Fo ASN1_item_i2d_bio
119.Fa "const ASN1_ITEM *it"
120.Fa "BIO *out_bio"
121.Fa "void *val_in"
122.Fc
123.Ft int
124.Fo ASN1_item_i2d_fp
125.Fa "const ASN1_ITEM *it"
126.Fa "FILE *out_fp"
127.Fa "void *val_in"
128.Fc
129.Ft int
130.Fo i2d_ASN1_TYPE
131.Fa "ASN1_TYPE *val_in"
132.Fa "unsigned char **der_out"
133.Fc
134.Ft void *
135.Fo ASN1_item_dup
136.Fa "const ASN1_ITEM *it"
137.Fa "void *val_in"
138.Fc
139.Ft int
140.Fo ASN1_item_print
141.Fa "BIO *out_bio"
142.Fa "ASN1_VALUE *val_in"
143.Fa "int indent"
144.Fa "const ASN1_ITEM *it"
145.Fa "const ASN1_PCTX *pctx"
146.Fc
147.Sh DESCRIPTION
148These functions convert ASN.1 values from their BER encoding to
149internal C structures
150.Pq Dq d2i
151and vice versa
152.Pq Dq i2d .
153Unlike the C structures which contain pointers to sub-objects, BER
154is a serialized encoding, suitable for transfer over the network
155and for storage in a file.
156.Pp
157.Fn ASN1_item_d2i
158interprets
159.Pf * Fa der_in
160as a DER- or BER-encoded byte array and decodes one value of type
161.Fa it
162represented by up to
163.Fa length
164bytes.
165If successful,
166.Pf * Fa der_in
167is advanced to the byte following the parsed data.
168.Pp
169If decoding succeeds and
170.Fa val_out
171or
172.Pf * Fa val_out
173is
174.Dv NULL ,
175a new object is allocated.
176.Pp
177If decoding succeeds and
178.Pf * Fa val_out
179is not
180.Dv NULL ,
181it is assumed to point to a valid populated object and an attempt
182is made to reuse it.
183It must not be an empty structure such as one returned by
184.Xr ASN1_item_new 3
185or by one of the various type-specific
186.Fn *_new
187functions.
188This
189.Dq reuse
190capability is present for backward compatibility, but its use is
191strongly discouraged; see the
192.Sx BUGS
193section below.
194.Pp
195.Fn ASN1_item_d2i_bio
196and
197.Fn ASN1_item_d2i_fp
198are similar to
199.Fn ASN1_item_d2i
200except that they read from a
201.Vt BIO
202or
203.Vt FILE ,
204respectively.
205.Pp
206.Fn d2i_ASN1_TYPE
207is similar to
208.Fn ASN1_item_d2i
209except that it does not require a desired type to be specified by
210the user, but instead returns an
211.Vt ASN1_TYPE
212wrapper object containing both the type and the value found in the input.
213.Pp
214.Fn ASN1_item_i2d
215encodes the object pointed to by
216.Fa val_in
217into DER format.
218.Pp
219If
220.Pf * Fa der_out
221is not
222.Dv NULL ,
223it writes the DER-encoded data to the buffer at
224.Pf * Fa der_out
225and increments it to point after the data just written.
226In this case, it is the responsibility of the user to make sure
227that the buffer pointed to by
228.Pf * Fa der_out
229is long enough, such that no buffer overflow can occur.
230.Pp
231If
232.Pf * Fa der_out
233is
234.Dv NULL ,
235memory is allocated for a buffer, and
236.Pf * Fa der_out
237is not incremented, but points to the start of the data just written.
238.Pp
239If
240.Fa der_out
241is
242.Dv NULL ,
243the encoded bytes are not written anywhere but discarded.
244For
245.Fa val_in
246objects of variable encoding size, this is sometimes used to first
247find the number of bytes that will be written.
248Then, a sufficient amount of memory is allocated before calling
249.Fn ASN1_item_i2d
250again.
251This explicit double-call technique is often not needed because the
252auto-allocation technique described in the previous paragraph can
253be used.
254.Pp
255.Fn ASN1_item_i2d_bio
256and
257.Fn ASN1_item_i2d_fp
258are similar to
259.Fn ASN1_item_i2d
260except that they write to a
261.Vt BIO
262or
263.Vt FILE ,
264respectively.
265.Pp
266.Fn i2d_ASN1_TYPE
267is similar to
268.Fn ASN1_item_i2d
269except that the type and the value are not provided separately,
270but in the form of a single
271.Vt ASN1_TYPE
272object.
273.Pp
274.Fn ASN1_item_dup
275creates a deep copy of
276.Fa val_in
277by calling
278.Fn ASN1_item_i2d
279and
280.Fn ASN1_item_d2i .
281.Sh RETURN VALUES
282If successful,
283.Fn ASN1_item_d2i ,
284.Fn ASN1_item_d2i_bio ,
285.Fn ASN1_item_d2i_fp ,
286and
287.Fn d2i_ASN1_TYPE
288return a pointer to the decoded ASN.1 value.
289In addition, if
290.Fa val_out
291is not
292.Dv NULL ,
293the pointer is also written to
294.Pf * Fa val_out .
295If an error occurs,
296.Dv NULL
297is returned.
298.Pp
299.Fn ASN1_item_i2d
300and
301.Fn i2d_ASN1_TYPE
302return the number of bytes written
303or a negative value if an error occurs.
304.Pp
305.Fn ASN1_item_i2d_bio
306and
307.Fn ASN1_item_i2d_fp
308return 1 for success or 0 for failure.
309.Pp
310.Fn ASN1_item_dup
311returns the new
312.Vt ASN1_VALUE
313object or
314.Dv NULL
315if an error occurs.
316.Sh EXAMPLES
317Many type-specific wrapper functions exist.
318Using those wrappers is recommended in application code
319because it restores part of the type safety that the low-level
320interfaces using
321.Vt ASN1_VALUE
322lack.
323.Pp
324For example, to allocate a buffer and write the DER encoding of an
325.Vt X509
326object into it:
327.Bd -literal -offset indent
328X509 *x;
329unsigned char *buf;
330int len;
331
332buf = NULL;
333len = i2d_X509(x, &buf);
334if (len < 0)
335 /* error */
336.Ed
337.Pp
338Attempt to decode a buffer:
339.Bd -literal -offset indent
340X509 *x;
341unsigned char *buf;
342const unsigned char *p;
343int len;
344
345/* Set up buf and len to point to the input buffer. */
346p = buf;
347x = d2i_X509(NULL, &p, len);
348if (x == NULL)
349 /* error */
350.Ed
351.Pp
352Equivalent technique:
353.Bd -literal -offset indent
354X509 *x;
355unsigned char *buf;
356const unsigned char *p;
357int len;
358
359/* Set up buf and len to point to the input buffer. */
360p = buf;
361x = NULL;
362
363if (d2i_X509(&x, &p, len) == NULL)
364 /* error */
365.Ed
366.Sh SEE ALSO
367.Xr ASN1_get_object 3 ,
368.Xr ASN1_item_digest 3 ,
369.Xr ASN1_item_new 3 ,
370.Xr ASN1_item_pack 3 ,
371.Xr ASN1_item_sign 3 ,
372.Xr ASN1_item_verify 3 ,
373.Xr ASN1_TYPE_new 3
374.Sh HISTORY
375.Fn d2i_ASN1_TYPE
376and
377.Fn i2d_ASN1_TYPE
378first appeared in SSLeay 0.5.1 and have been available since
379.Ox 2.4 .
380.Pp
381.Fn ASN1_item_d2i ,
382.Fn ASN1_item_d2i_bio ,
383.Fn ASN1_item_d2i_fp ,
384.Fn ASN1_item_i2d ,
385.Fn ASN1_item_i2d_bio ,
386.Fn ASN1_item_i2d_fp ,
387and
388.Fn ASN1_item_dup
389first appeared in OpenSSL 0.9.7 and have been available since
390.Ox 3.2 .
391.Pp
392.Fn ASN1_item_print
393first appeared in OpenSSL 1.0.0 and has been available since
394.Ox 4.9 .
395.Sh CAVEATS
396If the type described by
397.Fa it
398fails to match the true type of
399.Fa val_in
400or
401.Pf * Fa val_out ,
402buffer overflows and segmentation faults are likely to occur.
403For more details about why the type
404.Vt ASN1_VALUE
405constitutes dangerous user interface design, see
406.Xr ASN1_item_new 3 .
407.Pp
408The encoded data is in binary form and may contain embedded NUL bytes.
409Functions such as
410.Xr strlen 3
411will not return the correct length of the encoded data.
412.Pp
413While the way that
414.Pf * Fa der_in
415and
416.Pf * Fa der_out
417are incremented after the operation supports the typical usage
418patterns of reading or writing one object after another, this
419behaviour can trap the unwary.
420.Pp
421Using a temporary pointer into the buffer is mandatory.
422A common mistake is to attempt to use a buffer directly as follows:
423.Bd -literal -offset indent
424X509 *x;
425unsigned char *buf;
426int len;
427
428len = i2d_X509(x, NULL);
429buf = malloc(len);
430i2d_X509(x, &buf);
431/* do something with buf[] */
432free(buf);
433.Ed
434.Pp
435This code will result in
436.Va buf
437apparently containing garbage because it was incremented during
438.Fn i2d_X509
439to point after the data just written.
440Also
441.Va buf
442will no longer contain the pointer allocated by
443.Xr malloc 3
444and the subsequent call to
445.Xr free 3
446is likely to crash.
447.Pp
448Another trap to avoid is misuse of the
449.Fa val_out
450argument:
451.Bd -literal -offset indent
452X509 *x;
453
454if (d2i_X509(&x, &p, len) == NULL)
455 /* error */
456.Ed
457.Pp
458This will probably crash somewhere in
459.Fn d2i_X509
460because
461.Va x
462is uninitialized and an attempt will be made to interpret its invalid
463content as an
464.Vt X509
465object, typically causing a segmentation violation.
466If
467.Va x
468is set to
469.Dv NULL
470first, then this will not happen.
471.Sh BUGS
472If the
473.Dq reuse
474capability is used, a valid object is passed in via
475.Pf * Fa val_out ,
476and an error occurs, then the object is not freed and may be left
477in an invalid or inconsistent state.
478.Pp
479In some versions of OpenSSL, the
480.Dq reuse
481behaviour is broken such that some parts of the reused object may
482persist if they are not present in the new one.
483.Pp
484In many versions of OpenSSL,
485.Fn ASN1_item_i2d
486will not return an error if mandatory fields are not initialized
487due to a programming error.
488In that case, the encoded structure may contain invalid data and
489some fields may be missing entirely, such that trying to parse it
490with
491.Fn ASN1_item_d2i
492may fail.
diff --git a/src/lib/libcrypto/man/ASN1_item_digest.3 b/src/lib/libcrypto/man/ASN1_item_digest.3
deleted file mode 100644
index 56a97555e9..0000000000
--- a/src/lib/libcrypto/man/ASN1_item_digest.3
+++ /dev/null
@@ -1,71 +0,0 @@
1.\" $OpenBSD: ASN1_item_digest.3,v 1.2 2022/09/11 04:39:46 jsg Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 11 2022 $
18.Dt ASN1_ITEM_DIGEST 3
19.Os
20.Sh NAME
21.Nm ASN1_item_digest
22.Nd DER-encode and hash an ASN.1 value
23.Sh SYNOPSIS
24.In openssl/x509.h
25.Ft int
26.Fo ASN1_item_digest
27.Fa "const ASN1_ITEM *it"
28.Fa "const EVP_MD *type"
29.Fa "void *val_in"
30.Fa "unsigned char *md"
31.Fa "unsigned int *s"
32.Fc
33.Sh DESCRIPTION
34.Fn ASN1_item_digest
35assumes that
36.Fa val_in
37is an
38.Vt ASN1_VALUE
39of the type specified by
40.Fa it ,
41encodes it into DER format by calling
42.Xr ASN1_item_i2d 3 ,
43hashes the resulting byte array using the digest
44.Fa type
45by calling
46.Xr EVP_Digest 3 ,
47places the digest value into
48.Pf * Fa md ,
49and, unless
50.Fa s
51is
52.Dv NULL ,
53places the length in bytes of the digest into
54.Pf * Fa s .
55Providing a buffer
56.Pf * Fa md
57large enough to contain the digest is the responsibility of the caller;
58providing a buffer of
59.Dv EVP_MAX_MD_SIZE
60bytes is recommended.
61.Sh RETURN VALUES
62.Fn ASN1_item_digest
63returns 1 for success or 0 if encoding or hashing fails.
64.Sh SEE ALSO
65.Xr ASN1_item_i2d 3 ,
66.Xr ASN1_item_sign 3 ,
67.Xr EVP_Digest 3
68.Sh HISTORY
69.Fn ASN1_item_digest
70first appeared in OpenSSL 0.9.7 and has been available since
71.Ox 3.1 .
diff --git a/src/lib/libcrypto/man/ASN1_item_new.3 b/src/lib/libcrypto/man/ASN1_item_new.3
deleted file mode 100644
index 7015ed6319..0000000000
--- a/src/lib/libcrypto/man/ASN1_item_new.3
+++ /dev/null
@@ -1,126 +0,0 @@
1.\" $OpenBSD: ASN1_item_new.3,v 1.11 2022/01/12 17:54:51 tb Exp $
2.\"
3.\" Copyright (c) 2016, 2018 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: January 12 2022 $
18.Dt ASN1_ITEM_NEW 3
19.Os
20.Sh NAME
21.Nm ASN1_item_new ,
22.Nm ASN1_item_free
23.Nd generic ASN.1 value constructor and destructor
24.Sh SYNOPSIS
25.In openssl/asn1.h
26.Ft ASN1_VALUE *
27.Fo ASN1_item_new
28.Fa "const ASN1_ITEM *it"
29.Fc
30.Ft void
31.Fo ASN1_item_free
32.Fa "ASN1_VALUE *val_in"
33.Fa "const ASN1_ITEM *it"
34.Fc
35.Sh DESCRIPTION
36.Fn ASN1_item_new
37allocates and initializes an empty ASN.1 value
38of the type described by the global static object
39.Fa it .
40.Pp
41If the item type described by
42.Fa it
43is reference counted,
44.Fn ASN1_item_free
45decrements the reference count of
46.Fa val_in .
47Otherwise, or if the reference count reaches 0,
48.Fn ASN1_item_free
49frees
50.Fa val_in ,
51assuming that it is of the type described by
52.Fa it .
53If the true type of
54.Fa val_in
55fails to match the specified
56.Fa it ,
57buffer overflows and segmentation faults are likely to occur.
58It is not possible to recover the type of an
59.Vt ASN1_VALUE
60object by inspecting it; the type always needs to be remembered
61separately.
62.Pp
63.Vt ASN1_VALUE
64is an incomplete type, and pointers to it always require casting
65to the correct complete type before they can be dereferenced.
66For all practical purposes, a pointer to
67.Vt ASN1_VALUE
68is equivalent to a
69.Vt void
70pointer.
71.Pp
72Depending on
73.Fa it ,
74there are more than 150 different types that
75.Fn ASN1_item_new
76may return.
77Most of them are pointers to structures or pointers to arrays of
78structures, but there are a few exceptions, for example:
79If
80.Fa it
81is
82.Dv ASN1_NULL_it ,
83.Fn ASN1_item_new
84returns a specific invalid pointer representing the unique
85.Vt ASN1_NULL
86object.
87If
88.Fa it
89is
90.Dv LONG_it ,
91.Fn ASN1_item_new
92does not return a pointer at all, but a
93.Vt long
94value cast to
95.Vt ASN1_VALUE * .
96.Sh RETURN VALUES
97The
98.Fn ASN1_item_new
99function returns the new
100.Vt ASN1_VALUE
101object if successful; otherwise
102.Dv NULL
103is returned and an error code can be retrieved with
104.Xr ERR_get_error 3 .
105.Sh SEE ALSO
106.Xr ASN1_get_object 3 ,
107.Xr ASN1_item_d2i 3 ,
108.Xr ASN1_item_digest 3 ,
109.Xr ASN1_item_pack 3 ,
110.Xr ASN1_item_sign 3 ,
111.Xr ASN1_item_verify 3 ,
112.Xr ASN1_NULL_new 3 ,
113.Xr ASN1_TYPE_new 3 ,
114.Xr d2i_ASN1_NULL 3 ,
115.Xr OBJ_nid2obj 3
116.Sh HISTORY
117.Fn ASN1_item_new
118and
119.Fn ASN1_item_free
120first appeared in OpenSSL 0.9.7 and have been available since
121.Ox 3.2 .
122.Sh BUGS
123The
124.Vt ASN1_VALUE
125type compromises type safety and invites programming mistakes that
126will typically have severe consequences.
diff --git a/src/lib/libcrypto/man/ASN1_item_pack.3 b/src/lib/libcrypto/man/ASN1_item_pack.3
deleted file mode 100644
index 4c87530622..0000000000
--- a/src/lib/libcrypto/man/ASN1_item_pack.3
+++ /dev/null
@@ -1,84 +0,0 @@
1.\" $OpenBSD: ASN1_item_pack.3,v 1.1 2021/11/15 11:51:09 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 15 2021 $
18.Dt ASN1_ITEM_PACK 3
19.Os
20.Sh NAME
21.Nm ASN1_item_pack ,
22.Nm ASN1_item_unpack
23.Nd pack an ASN.1 object into an ASN1_STRING
24.Sh SYNOPSIS
25.In openssl/asn1.h
26.Ft ASN1_STRING *
27.Fo ASN1_item_pack
28.Fa "void *val_in"
29.Fa "const ASN1_ITEM *it"
30.Fa "ASN1_STRING **string_out"
31.Fc
32.Ft void *
33.Fo ASN1_item_unpack
34.Fa "const ASN1_STRING *string_in"
35.Fa "const ASN1_ITEM *it"
36.Fc
37.Sh DESCRIPTION
38.Fn ASN1_item_pack
39encodes the object pointed to by
40.Fa val_in
41into DER format using
42.Xr ASN1_item_i2d 3
43and stores the encoded form in
44.Pf ** Fa string_out .
45If
46.Fa string_out
47or
48.Pf * Fa string_out
49is a
50.Dv NULL
51pointer, a new
52.Vt ASN1_STRING
53object is allocated and returned.
54.Pp
55.Fn ASN1_item_unpack
56interprets the data in
57.Fa string_in
58as a DER- or BER-encoded byte array and decodes one value of the type
59.Fa it
60into a newly allocated object using
61.Xr ASN1_item_d2i 3 .
62.Sh RETURN VALUES
63.Fn ASN1_item_pack
64returns the modified or new object or
65.Dv NULL
66if memory allocation or encoding fails.
67.Pp
68.Fn ASN1_item_unpack
69returns the new object or
70.Dv NULL
71if memory allocation or decoding fails.
72.Sh SEE ALSO
73.Xr ASN1_item_d2i 3 ,
74.Xr ASN1_item_new 3 ,
75.Xr ASN1_STRING_new 3
76.Sh HISTORY
77.Fn ASN1_item_pack
78and
79.Fn ASN1_item_unpack
80first appeared in OpenSSL 0.9.7 and have been available since
81.Ox 3.2 .
82.Sh BUGS
83See the BUGS section in
84.Xr ASN1_item_i2d 3 .
diff --git a/src/lib/libcrypto/man/ASN1_item_sign.3 b/src/lib/libcrypto/man/ASN1_item_sign.3
deleted file mode 100644
index 8c09fe77ff..0000000000
--- a/src/lib/libcrypto/man/ASN1_item_sign.3
+++ /dev/null
@@ -1,120 +0,0 @@
1.\" $OpenBSD: ASN1_item_sign.3,v 1.3 2024/12/06 12:51:13 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 6 2024 $
18.Dt ASN1_ITEM_SIGN 3
19.Os
20.Sh NAME
21.Nm ASN1_item_sign ,
22.Nm ASN1_item_sign_ctx
23.Nd DER-encode and sign an ASN.1 value
24.Sh SYNOPSIS
25.In openssl/x509.h
26.Ft int
27.Fo ASN1_item_sign
28.Fa "const ASN1_ITEM *it"
29.Fa "X509_ALGOR *algor1"
30.Fa "X509_ALGOR *algor2"
31.Fa "ASN1_BIT_STRING *sig_out"
32.Fa "void *val_in"
33.Fa "EVP_PKEY *pkey"
34.Fa "const EVP_MD *type"
35.Fc
36.Ft int
37.Fo ASN1_item_sign_ctx
38.Fa "const ASN1_ITEM *it"
39.Fa "X509_ALGOR *algor1"
40.Fa "X509_ALGOR *algor2"
41.Fa "ASN1_BIT_STRING *sig_out"
42.Fa "void *val_in"
43.Fa "EVP_MD_CTX *ctx"
44.Fc
45.Sh DESCRIPTION
46.Fn ASN1_item_sign
47assumes that
48.Fa val_in
49is an
50.Vt ASN1_VALUE
51of the type specified by
52.Fa it ,
53encodes it into DER format by calling
54.Xr ASN1_item_i2d 3 ,
55and signs the resulting byte array in a way similar to
56.Xr EVP_DigestSign 3 ,
57using a signing context created with
58.Xr EVP_DigestSignInit 3
59for the given digest
60.Fa type
61and private key
62.Fa pkey .
63The created signature is placed into the
64.Fa sig_out
65object provided by the caller,
66freeing and replacing any data already contained in that object.
67.Pp
68.Fn ASN1_item_sign_ctx
69is similar except that the provided
70.Ft ctx
71is used rather than creating a new one.
72No matter whether
73.Fn ASN1_item_sign_ctx
74succeeds or fails,
75.Xr EVP_MD_CTX_cleanup 3
76is called on
77.Fa ctx
78before returning.
79.Pp
80For both functions, unless
81.Fa algor1
82is
83.Dv NULL ,
84its algorithm OID and parameter type are set according to the digest
85.Fa type
86used, and its parameter value is cleared.
87In RSA-PSS mode, the parameter value is also copied into
88.Fa algor1 .
89Unless
90.Fa algor2
91is
92.Dv NULL ,
93the same data is copied into it.
94.Sh RETURN VALUES
95These functions return the length of the signature in bytes
96or 0 if memory allocation, encoding, or signing fails.
97.Pp
98.Fn ASN1_item_sign_ctx
99also fails and returns 0 if
100.Fa ctx
101is not fully initialized.
102.Sh SEE ALSO
103.Xr ASN1_BIT_STRING_new 3 ,
104.Xr ASN1_item_digest 3 ,
105.Xr ASN1_item_i2d 3 ,
106.Xr ASN1_item_verify 3 ,
107.Xr EVP_Digest 3 ,
108.Xr EVP_DigestSign 3 ,
109.Xr EVP_MD_CTX_new 3 ,
110.Xr EVP_PKEY_new 3 ,
111.Xr OBJ_find_sigid_by_algs 3 ,
112.Xr X509_ALGOR_new 3
113.Sh HISTORY
114.Fn ASN1_item_sign
115first appeared in OpenSSL 0.9.7 and has been available since
116.Ox 3.1 .
117.Pp
118.Fn ASN1_item_sign_ctx
119first appeared in OpenSSL 1.0.1 and has been available since
120.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/ASN1_item_verify.3 b/src/lib/libcrypto/man/ASN1_item_verify.3
deleted file mode 100644
index d2810879e3..0000000000
--- a/src/lib/libcrypto/man/ASN1_item_verify.3
+++ /dev/null
@@ -1,77 +0,0 @@
1.\" $OpenBSD: ASN1_item_verify.3,v 1.3 2021/12/18 17:47:44 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 18 2021 $
18.Dt ASN1_ITEM_VERIFY 3
19.Os
20.Sh NAME
21.Nm ASN1_item_verify
22.Nd signature verification for ASN.1 values
23.Sh SYNOPSIS
24.In openssl/x509.h
25.Ft int
26.Fo ASN1_item_verify
27.Fa "const ASN1_ITEM *it"
28.Fa "X509_ALGOR *algor1"
29.Fa "ASN1_BIT_STRING *sig_in"
30.Fa "void *val_in"
31.Fa "EVP_PKEY *pkey"
32.Fc
33.Sh DESCRIPTION
34.Fn ASN1_item_verify
35assumes that
36.Fa val_in
37is an
38.Ft ASN1_VALUE
39of the type specified by
40.Fa it ,
41encodes it into DER format by calling
42.Xr ASN1_item_i2d 3 ,
43and verifies in a way similar to
44.Xr EVP_DigestVerify 3
45that
46.Fa sig_in
47contains a valid signature of the resulting byte array,
48a signature that was created with the signature algorithm
49.Fa algor1
50and the private key corresponding to the public key
51.Fa pkey .
52.Sh RETURN VALUES
53.Fn ASN1_item_verify
54returns 1 if signature verification succeeds, 0 if signature verification
55fails, or \-1 if
56.Fa pkey
57is
58.Dv NULL ,
59if
60.Fa sig_in
61contains invalid flags, or if
62.Fa algor1
63requests an invalid or unsupported digest algorithm
64or does not work with the given
65.Fa pkey .
66.Sh SEE ALSO
67.Xr ASN1_BIT_STRING_new 3 ,
68.Xr ASN1_item_i2d 3 ,
69.Xr ASN1_item_sign 3 ,
70.Xr EVP_DigestVerify 3 ,
71.Xr EVP_PKEY_new 3 ,
72.Xr OBJ_find_sigid_algs 3 ,
73.Xr X509_ALGOR_new 3
74.Sh HISTORY
75.Fn ASN1_item_verify
76first appeared in OpenSSL 0.9.7 and has been available since
77.Ox 3.1 .
diff --git a/src/lib/libcrypto/man/ASN1_mbstring_copy.3 b/src/lib/libcrypto/man/ASN1_mbstring_copy.3
deleted file mode 100644
index e0b48aaa62..0000000000
--- a/src/lib/libcrypto/man/ASN1_mbstring_copy.3
+++ /dev/null
@@ -1,369 +0,0 @@
1.\" $OpenBSD: ASN1_mbstring_copy.3,v 1.6 2022/02/21 00:22:03 jsg Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: February 21 2022 $
18.Dt ASN1_MBSTRING_COPY 3
19.Os
20.Sh NAME
21.Nm ASN1_mbstring_copy ,
22.Nm ASN1_mbstring_ncopy ,
23.Nm ASN1_STRING_set_by_NID ,
24.Nm ASN1_STRING_set_default_mask ,
25.Nm ASN1_STRING_set_default_mask_asc ,
26.Nm ASN1_STRING_get_default_mask ,
27.Nm ASN1_tag2bit
28.Nd copy a multibyte string into an ASN.1 string object
29.Sh SYNOPSIS
30.In openssl/asn1.h
31.Ft int
32.Fo ASN1_mbstring_copy
33.Fa "ASN1_STRING **out"
34.Fa "const unsigned char *in"
35.Fa "int inbytes"
36.Fa "int inform"
37.Fa "unsigned long mask"
38.Fc
39.Ft int
40.Fo ASN1_mbstring_ncopy
41.Fa "ASN1_STRING **out"
42.Fa "const unsigned char *in"
43.Fa "int inbytes"
44.Fa "int inform"
45.Fa "unsigned long mask"
46.Fa "long minchars"
47.Fa "long maxchars"
48.Fc
49.Ft ASN1_STRING *
50.Fo ASN1_STRING_set_by_NID
51.Fa "ASN1_STRING **out"
52.Fa "const unsigned char *in"
53.Fa "int inbytes"
54.Fa "int inform"
55.Fa "int nid"
56.Fc
57.Ft void
58.Fo ASN1_STRING_set_default_mask
59.Fa "unsigned long mask"
60.Fc
61.Ft int
62.Fo ASN1_STRING_set_default_mask_asc
63.Fa "const char *maskname"
64.Fc
65.Ft unsigned long
66.Fn ASN1_STRING_get_default_mask void
67.Ft unsigned long
68.Fn ASN1_tag2bit "int tag"
69.Sh DESCRIPTION
70.Fn ASN1_mbstring_copy
71interprets
72.Fa inbytes
73bytes starting at
74.Fa in
75as a multibyte string and copies it to
76.Pf * Fa out ,
77optionally changing the encoding.
78If the
79.Fa inbytes
80argument is negative, the
81.Xr strlen 3
82of
83.Fa in
84is used instead.
85.Pp
86The
87.Fa inform
88argument specifies the character encoding of
89.Fa in :
90.Bl -column MBSTRING_UNIV encoding
91.It Ar inform Ta encoding
92.It Dv MBSTRING_ASC Ta ISO-Latin-1
93.It Dv MBSTRING_BMP Ta UTF-16
94.It Dv MBSTRING_UNIV Ta UTF-32
95.It Dv MBSTRING_UTF8 Ta UTF-8
96.El
97.Pp
98The bit
99.Fa mask
100specifies a set of ASN.1 string types
101that the user is willing to accept:
102.Bl -column B_ASN1_UNIVERSALSTRING ASN1_UNIVERSALSTRING default
103.It bit in Fa mask Ta acceptable output type Ta default
104.It Dv B_ASN1_PRINTABLESTRING Ta Vt ASN1_PRINTABLESTRING Ta yes
105.It Dv B_ASN1_IA5STRING Ta Vt ASN1_IA5STRING Ta no
106.It Dv B_ASN1_T61STRING Ta Vt ASN1_T61STRING Ta yes
107.It Dv B_ASN1_BMPSTRING Ta Vt ASN1_BMPSTRING Ta yes
108.It Dv B_ASN1_UNIVERSALSTRING Ta Vt ASN1_UNIVERSALSTRING Ta no
109.It any other bit Ta Vt ASN1_UTF8STRING Ta yes
110.El
111.Pp
112The first type from the above table that is included in the
113.Fa mask
114argument and that can represent
115.Fa in
116is used as the output type.
117The
118.Dq default
119column indicates whether the type is considered acceptable if the
120.Fa mask
121argument has the special value 0.
122.Pp
123The following bit mask constants
124each include several of the bits listed above:
125.Bl -column B_ASN1_DIRECTORYSTRING_ MMM MMM MMM MMM MMM MMMM
126.It mask constant Ta PRI Ta IA5 Ta T61 Ta BMP Ta UNI Ta UTF8
127.It Dv B_ASN1_DIRECTORYSTRING Ta yes Ta no Ta yes Ta yes Ta yes Ta yes
128.It Dv DIRSTRING_TYPE Ta yes Ta no Ta yes Ta yes Ta no Ta yes
129.It Dv PKCS9STRING_TYPE Ta yes Ta yes Ta yes Ta yes Ta no Ta yes
130.El
131.Pp
132If
133.Fa out
134is
135.Dv NULL ,
136.Fa inform ,
137.Fa inbytes ,
138and
139.Fa in
140are validated and the output type is determined and returned,
141but nothing is copied.
142.Pp
143Otherwise, if
144.Pf * Fa out
145is
146.Dv NULL ,
147a new output object of the output type is allocated
148and a pointer to it is stored in
149.Pf * Fa out .
150.Pp
151Otherwise,
152.Pf ** Fa out
153is used as the output object.
154Any data already stored in it is freed
155and its type is changed to the output type.
156.Pp
157Finally,
158.Fa in
159is copied to the output object, changing the character encoding if
160.Fa inform
161does not match the encoding used by the output type.
162.Pp
163.Fn ASN1_mbstring_ncopy
164is similar except that the number of characters in
165.Fa in
166is restricted to the range from
167.Fa minchars
168to
169.Fa maxchars ,
170inclusive.
171If
172.Fa maxchars
173is 0, no upper limit is enforced on the number of characters.
174.Pp
175.Fn ASN1_STRING_set_by_NID
176is similar with the following differences:
177.Bl -bullet -width 1n
178.It
179If
180.Fa out
181is
182.Dv NULL ,
183a new output object is allocated and returned
184instead of skipping the copying.
185.It
186If
187.Fa nid
188has a global string table entry that can be retrieved with
189.Xr ASN1_STRING_TABLE_get 3 ,
190.Fa mask ,
191.Fa minchars ,
192and
193.Fa maxchars
194are taken from that string table entry.
195For some values of
196.Fa nid ,
197an additional global mask is AND'ed into the mask before using it.
198The default value of the global mask is
199.Dv B_ASN1_UTF8STRING .
200.It
201If
202.Fa nid
203has no global string table entry,
204.Dv B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING |
205.Dv B_ASN1_BMPSTRING | B_ASN1_UTF8STRING
206is used instead of the mask taken from the table,
207and the global mask is also AND'ed into it.
208.It
209Even though success and failure happen in the same situations,
210the return value is different.
211.Xr ASN1_STRING_type 3
212can be used to determine the type of the return value.
213.El
214.Pp
215.Fn ASN1_STRING_set_default_mask
216sets the global mask used by
217.Fn ASN1_STRING_set_by_NID
218to the
219.Fa mask
220argument.
221.Pp
222.Fn ASN1_STRING_set_default_mask_asc
223sets the global mask as follows:
224.Bl -column utf8only
225.It Ar maskname Ta Ar mask
226.It Qo default Qc Ta anything
227.It Qo nombstr Qc Ta anything except Dv B_ASN1_BMPSTRING | B_ASN1_UTF8STRING
228.It Qo pkix Qc Ta anything except Dv B_ASN1_T61STRING
229.It Qo utf8only Qc Ta Dv B_ASN1_UTF8STRING
230.El
231.Pp
232If the
233.Fa maskname
234argument starts with the substring
235.Qq MASK:\& ,
236the rest of it is interpreted as an
237.Vt unsigned long
238value using
239.Xr strtoul 3 .
240.Pp
241.Fn ASN1_tag2bit
242translates ASN.1 data types to type bits as follows:
243.Bl -column V_ASN1_OBJECT_DESCRIPTOR B_ASN1_UNIVERSALSTRING
244.It Fa tag Ta return value
245.It Dv V_ASN1_BIT_STRING Ta Dv B_ASN1_BIT_STRING
246.It Dv V_ASN1_BMPSTRING Ta Dv B_ASN1_BMPSTRING
247.It Dv V_ASN1_BOOLEAN Ta 0
248.It Dv V_ASN1_ENUMERATED Ta Dv B_ASN1_UNKNOWN
249.It Dv V_ASN1_EOC Ta 0
250.It Dv V_ASN1_EXTERNAL Ta Dv B_ASN1_UNKNOWN
251.It Dv V_ASN1_GENERALIZEDTIME Ta Dv B_ASN1_GENERALIZEDTIME
252.It Dv V_ASN1_GENERALSTRING Ta Dv B_ASN1_GENERALSTRING
253.It Dv V_ASN1_GRAPHICSTRING Ta Dv B_ASN1_GRAPHICSTRING
254.It Dv V_ASN1_IA5STRING Ta Dv B_ASN1_IA5STRING
255.It Dv V_ASN1_INTEGER Ta 0
256.It Dv V_ASN1_ISO64STRING Ta Dv B_ASN1_ISO64STRING
257.It Dv V_ASN1_NULL Ta 0
258.It Dv V_ASN1_NUMERICSTRING Ta Dv B_ASN1_NUMERICSTRING
259.It Dv V_ASN1_OBJECT Ta 0
260.It Dv V_ASN1_OBJECT_DESCRIPTOR Ta Dv B_ASN1_UNKNOWN
261.It Dv V_ASN1_OCTET_STRING Ta Dv B_ASN1_OCTET_STRING
262.It Dv V_ASN1_PRINTABLESTRING Ta Dv B_ASN1_PRINTABLESTRING
263.It Dv V_ASN1_REAL Ta Dv B_ASN1_UNKNOWN
264.It Dv V_ASN1_SEQUENCE Ta Dv B_ASN1_SEQUENCE
265.It Dv V_ASN1_SET Ta 0
266.It Dv V_ASN1_T61STRING Ta Dv B_ASN1_T61STRING
267.It Dv V_ASN1_TELETEXSTRING Ta Dv B_ASN1_TELETEXSTRING
268.It Dv V_ASN1_UNDEF Ta 0
269.It Dv V_ASN1_UNIVERSALSTRING Ta Dv B_ASN1_UNIVERSALSTRING
270.It Dv V_ASN1_UTCTIME Ta Dv B_ASN1_UTCTIME
271.It Dv V_ASN1_UTF8STRING Ta Dv B_ASN1_UTF8STRING
272.It Dv V_ASN1_VIDEOTEXSTRING Ta Dv B_ASN1_VIDEOTEXSTRING
273.It Dv V_ASN1_VISIBLESTRING Ta Dv B_ASN1_VISIBLESTRING
274.It 11, 13, 14, 15, 29 Ta Dv B_ASN1_UNKNOWN
275.It Dv other Po < 0, > 30 Pc Ta Dv 0
276.El
277.Pp
278In typical usage, the calling code calculates the bitwise AND
279of the return value and a mask describing data types
280that the calling code is willing to use.
281If the result of the AND operation is non-zero, the data type is
282adequate; otherwise, the calling code may need to raise an error.
283.Sh RETURN VALUES
284.Fn ASN1_mbstring_copy
285and
286.Fn ASN1_mbstring_ncopy
287return the
288.Dv V_ASN1_*
289constant representing the output type or \-1 if
290.Fa inform
291is invalid, if
292.Fa inbytes
293or
294.Fa in
295is invalid for the
296.Fa inform
297encoding, if
298.Fa in
299contains an UTF-16 surrogate,
300which is unsupported even for input using the UTF-16 encoding,
301or if memory allocation fails.
302.Pp
303.Fn ASN1_mbstring_ncopy
304also returns \-1 if
305.Fa in
306contains fewer than
307.Fa minchars
308or more than
309.Fa maxchars
310characters.
311.Pp
312.Fn ASN1_STRING_set_by_NID
313returns the new or changed ASN.1 string object or
314.Dv NULL
315on failure.
316.Pp
317.Fn ASN1_STRING_set_default_mask_asc
318returns 1 if successful or 0 if
319.Qq MASK:\&
320is not followed by a number, if the number is followed by a non-numeric
321character, or if the
322.Fa maskname
323is invalid.
324.Pp
325.Fn ASN1_STRING_get_default_mask
326returns the global mask.
327.Pp
328.Fn ASN1_tag2bit
329returns a
330.Dv B_ASN1_*
331constant or 0.
332.Sh SEE ALSO
333.Xr ASN1_PRINTABLE_type 3 ,
334.Xr ASN1_STRING_new 3 ,
335.Xr ASN1_STRING_set 3 ,
336.Xr ASN1_STRING_TABLE_get 3 ,
337.Xr ASN1_UNIVERSALSTRING_to_string 3
338.Sh HISTORY
339.Fn ASN1_mbstring_copy ,
340.Fn ASN1_mbstring_ncopy ,
341.Fn ASN1_STRING_set_by_NID ,
342.Fn ASN1_STRING_set_default_mask ,
343.Fn ASN1_STRING_set_default_mask_asc ,
344and
345.Fn ASN1_STRING_get_default_mask
346first appeared in OpenSSL 0.9.5 and have been available since
347.Ox 2.7 .
348.Pp
349.Fn ASN1_tag2bit
350first appeared in OpenSSL 0.9.7 and has been available since
351.Ox 3.2 .
352.Sh BUGS
353If integer overflow occurs in
354.Fn ASN1_STRING_set_default_mask_asc
355while parsing a number following
356.Qq MASK:\& ,
357the function succeeds, essentially behaving in the same way as for
358.Qq default .
359.Pp
360Passing
361.Qq default
362to
363.Fn ASN1_STRING_set_default_mask_asc
364does
365.Em not
366restore the default mask.
367Instead, passing
368.Qq utf8only
369does that.
diff --git a/src/lib/libcrypto/man/ASN1_parse_dump.3 b/src/lib/libcrypto/man/ASN1_parse_dump.3
deleted file mode 100644
index 50761f38aa..0000000000
--- a/src/lib/libcrypto/man/ASN1_parse_dump.3
+++ /dev/null
@@ -1,216 +0,0 @@
1.\" $OpenBSD: ASN1_parse_dump.3,v 1.3 2021/12/09 18:52:09 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 9 2021 $
18.Dt ASN1_PARSE_DUMP 3
19.Os
20.Sh NAME
21.Nm ASN1_parse_dump ,
22.Nm ASN1_parse
23.Nd parse BER and print information about it
24.Sh SYNOPSIS
25.In openssl/asn1.h
26.Ft int
27.Fo ASN1_parse_dump
28.Fa "BIO *bio"
29.Fa "const unsigned char *ber_in"
30.Fa "long length"
31.Fa "int indent"
32.Fa "int dump"
33.Fc
34.Ft int
35.Fo ASN1_parse
36.Fa "BIO *bio"
37.Fa "const unsigned char *ber_in"
38.Fa "long length"
39.Fa "int indent"
40.Fc
41.Sh DESCRIPTION
42.Fn ASN1_parse_dump
43parses BER-encoded values and prints information about them to
44.Fa bio .
45On function entry,
46.Pf * Fa ber_in
47is expected to point to the first identifier octet of an encoded value.
48At most
49.Fa length
50bytes are inspected.
51.Pp
52For each value successfully parsed, the following information is printed:
53.Bl -enum
54.It
55The index of its first identifier octet relative to
56.Fa ber_in
57as a decimal number followed by a colon.
58For the first value parsed and printed, this is
59.Qq 0:\& .
60.It
61The nesting depth as a decimal integer.
62For the first value parsed and printed, this is
63.Qq d=0 .
64.It
65The header length in bytes, including the identifier octets and the
66length octets, as a decimal integer.
67For example, for a boolean value, this is
68.Qq hl=2
69because the encoding of a boolean value contains
70one identifier octet (0x01) and one length octet (also 0x01,
71because one content octet follows after the header).
72.It
73If the value is encoded using the definite form for the length octets,
74the number encoded in the length octets as a decimal integer.
75This is the number of content octets that follow.
76For example, for a boolean value, this is
77.Qq l=1 .
78If the value is encoded using a length octet indicating the indefinite form,
79.Qq l=inf
80is printed instead.
81.It
82If the value is primitive,
83.Qq prim:\&
84is printed;
85if it is constructed,
86.Qq cons:\& .
87.It
88The next field depends on the class of the tag:
89.Bl -tag -width Ds
90.It Dv V_ASN1_PRIVATE
91.Qq priv
92followed by the decimal tag number in square brackets
93.It Dv V_ASN1_CONTEXT_SPECIFIC
94.Qq cont
95followed by the decimal tag number in square brackets
96.It Dv V_ASN1_APPLICATION
97.Qq appl
98followed by the decimal tag number in square brackets
99.It V_ASN1_UNIVERSAL
100If the tag number is 30 or less, the return value from
101.Xr ASN1_tag2str 3
102is printed; otherwise,
103.Qq <ASN1
104followed by the decimal tag number and a closing angle bracket.
105.El
106.El
107.Pp
108For constructed values, the contained values are recursively printed.
109.Pp
110Primitive values are processed as follows:
111.Bl -tag -width Ds
112.It Dv V_ASN1_BOOLEAN
113Its integer value is printed as a decimal number.
114.It Dv V_ASN1_INTEGER
115Decoded with
116.Xr d2i_ASN1_INTEGER 3 ,
117printed as a hexadecimal number with an even number of digits.
118.It Dv V_ASN1_ENUMERATED
119Decoded with
120.Xr d2i_ASN1_ENUMERATED 3 ,
121printed as a hexadecimal number with an even number of digits.
122.It Dv V_ASN1_OBJECT
123Decoded with
124.Xr d2i_ASN1_OBJECT 3 ,
125printed with
126.Xr i2a_ASN1_OBJECT 3 .
127.It Dv V_ASN1_OCTET_STRING
128Decoded with
129.Xr d2i_ASN1_OCTET_STRING 3 .
130If the data consists only of printable ASCII characters, line feeds,
131carriage returns and horizontal tabs, it is printed as an ASCII string.
132.Pp
133Otherwise, the
134.Fa dump
135argument decides the format.
136If it is zero, a raw hex dump is emitted, consisting of two hexadecimal
137digits for every data byte.
138If
139.Fa dump
140is non-zero,
141.Xr BIO_dump_indent 3
142is used.
143Unless
144.Fa dump
145is \-1, the data is truncated after
146.Fa dump
147bytes.
148.It Dv V_ASN1_PRINTABLESTRING
149Printed as an ASCII string.
150The same applies to
151.Dv V_ASN1_IA5STRING ,
152.Dv V_ASN1_T61STRING ,
153.Dv V_ASN1_NUMERICSTRING ,
154.Dv V_ASN1_VISIBLESTRING ,
155.Dv V_ASN1_UTF8STRING ,
156.Dv V_ASN1_UTCTIME ,
157and
158.Dv V_ASN1_GENERALIZEDTIME .
159.It Other tags
160If the
161.Fa dump
162argument is 0, their data is silently ignored.
163If
164.Fa dump
165is non-zero,
166.Xr BIO_dump_indent 3
167is used.
168Unless
169.Fa dump
170is \-1, the data is truncated after
171.Fa dump
172bytes.
173.El
174.Pp
175.Fn ASN1_parse
176is identical to
177.Fn ASN1_parse_dump
178with 0 passed as the
179.Fa dump
180argument.
181.Sh RETURN VALUES
182These functions return 1 for success or 0 for failure.
183.Pp
184In particular, they print an error message to
185.Fa bio ,
186abort parsing and printing, and return 0
187when parsing or decoding fails, when a recursive call fails,
188when encountering a value extending beyond
189.Fa length ,
190or when encountering a nesting level in excess of 128.
191They also abort parsing and printing and return 0
192when any printing operation fails.
193.Sh SEE ALSO
194.Xr ASN1_get_object 3 ,
195.Xr ASN1_item_d2i 3 ,
196.Xr ASN1_item_new 3 ,
197.Xr ASN1_STRING_print 3 ,
198.Xr ASN1_TYPE_new 3
199.Sh STANDARDS
200ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
201Information technology - ASN.1 encoding rules:
202Specification of Basic Encoding Rules (BER), Canonical Encoding
203Rules (CER) and Distinguished Encoding Rules (DER),
204section 8.1: General rules for encoding
205.Sh HISTORY
206.Fn ASN1_parse
207first appeared in SSLeay 0.5.1 and has been available since
208.Ox 2.4 .
209.Pp
210.Fn ASN1_parse_dump
211first appeared in OpenSSL 0.9.6 and has been available since
212.Ox 2.9 .
213.Sh BUGS
214The content of values tagged as
215.Dv V_ASN1_BMPSTRING
216is silently ignored and none of it is printed.
diff --git a/src/lib/libcrypto/man/ASN1_put_object.3 b/src/lib/libcrypto/man/ASN1_put_object.3
deleted file mode 100644
index 97a352724c..0000000000
--- a/src/lib/libcrypto/man/ASN1_put_object.3
+++ /dev/null
@@ -1,226 +0,0 @@
1.\" $OpenBSD: ASN1_put_object.3,v 1.5 2022/01/12 17:54:51 tb Exp $
2.\"
3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: January 12 2022 $
18.Dt ASN1_PUT_OBJECT 3
19.Os
20.Sh NAME
21.Nm ASN1_put_object ,
22.Nm ASN1_put_eoc ,
23.Nm ASN1_object_size
24.Nd start and end the BER encoding of an arbitrary ASN.1 data element
25.Sh SYNOPSIS
26.In openssl/asn1.h
27.Ft void
28.Fo ASN1_put_object
29.Fa "unsigned char **ber_out"
30.Fa "int constructed"
31.Fa "int content_length"
32.Fa "int tag"
33.Fa "int class"
34.Fc
35.Ft int
36.Fo ASN1_put_eoc
37.Fa "unsigned char **ber_out"
38.Fc
39.Ft int
40.Fo ASN1_object_size
41.Fa "int constructed"
42.Fa "int content_length"
43.Fa "int tag"
44.Fc
45.Sh DESCRIPTION
46.Fn ASN1_put_object
47begins writing the BER encoding of an arbitrary ASN.1 data element
48to the buffer
49.Pf * ber_out
50by writing the identifier and the length bytes.
51Making sure that there is sufficient space in the buffer
52is the responsibility of the caller.
53This function does not write any content bytes
54nor any end-of-content bytes.
55.Pp
56The tag
57.Fa class
58can be
59.Dv V_ASN1_UNIVERSAL ,
60.Dv V_ASN1_APPLICATION ,
61.Dv V_ASN1_CONTEXT_SPECIFIC ,
62or
63.Dv V_ASN1_PRIVATE
64and is written to the two most significant bits of the first byte written.
65.Pp
66The
67.Fa constructed
68argument can have the following values:
69.Bl -tag -width 1n -offset 2n -compact
70.It 0
71Start a primitive value by setting the third most significant bit
72of the first byte written to 0.
73Always use the definite form.
74.It 1
75Start a constructed value by setting the third most significant bit
76of the first byte written to 1, and use the definite form.
77.It 2
78Start a constructed value and use the indefinite form,
79.El
80.Pp
81If the
82.Fa tag
83is less than
84.Dv V_ASN1_PRIMITIVE_TAG Pq = 0x1f ,
85it is written to the five least significant bits
86of the only identifier byte written.
87Otherwise, these five bits are all set to 1, and the
88.Fa tag
89is encoded in one or more following identifier bytes as needed.
90.Pp
91After completing the identifier byte(s),
92when using the definite form, the given
93.Fa content_length
94is encoded in one or more bytes as needed,
95using the long form if and only if the
96.Fa content_length
97is greater than 127.
98When using the indefinite form,
99the special byte 0x80 is written instead and the
100.Fa content_length
101argument is ignored.
102.Pp
103At the end,
104.Pf * Fa ber_out
105is set to the byte following the last byte written.
106The calling code can then start writing content bytes.
107.Pp
108If the indefinite form was selected,
109the calling code is also responsible for calling
110.Fn ASN1_put_eoc
111which writes an end-of-content marker to
112.Pf * Fa ber_out ,
113consisting of two NUL bytes, and advances
114.Pf * Fa ber_out
115by two bytes.
116.Pp
117.Fn ASN1_object_size
118calculates the total length in bytes of the BER encoding
119of an ASN.1 data element with the given
120.Fa tag
121and the number of content bytes given by
122.Fa content_length .
123The
124.Fa constructed
125argument has the same meaning as for
126.Fn ASN1_put_object .
127The return value includes the identifier, length, and content bytes.
128If
129.Fa constructed
130is 2, it also includes the end-of-content bytes.
131For the definite form, only the short form is supported if the
132.Fa content_length
133is less than 128.
134.Sh RETURN VALUES
135.Fn ASN1_put_eoc
136returns the number of bytes written, which is always 2.
137.Pp
138.Fn ASN1_object_size
139returns the total number of bytes in the encoding of the data element.
140.Sh SEE ALSO
141.Xr ASN1_item_i2d 3 ,
142.Xr ASN1_TYPE_get 3 ,
143.Xr i2d_ASN1_NULL 3 ,
144.Xr i2d_ASN1_OBJECT 3 ,
145.Xr i2d_ASN1_OCTET_STRING 3 ,
146.Xr i2d_ASN1_SEQUENCE_ANY 3
147.Sh STANDARDS
148ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
149Information technology - ASN.1 encoding rules:
150Specification of Basic Encoding Rules (BER), Canonical Encoding
151Rules (CER) and Distinguished Encoding Rules (DER),
152section 8.1: General rules for encoding
153.Sh HISTORY
154.Fn ASN1_put_object
155and
156.Fn ASN1_object_size
157first appeared in SSLeay 0.5.1 and have been available since
158.Ox 2.4 .
159.Pp
160.Fn ASN1_put_eoc
161first appeared in OpenSSL 0.9.8 and has been available since
162.Ox 4.5 .
163.Sh CAVEATS
164None of these functions do any sanity checking.
165When called in inconsistent ways, invalid content may result in
166.Pf * Fa ber_out ,
167for example
168.Bl -dash -compact
169.It
170a
171.Fa tag
172number less than
173.Dv V_ASN1_PRIMITIVE_TAG
174with a
175.Fa class
176other than
177.Dv V_ASN1_UNIVERSAL
178.It
179a
180.Fa tag
181number equal to
182.Dv V_ASN1_EOC Pq 0x00
183or
184.Dv V_ASN1_PRIMITIVE_TAG Pq 0x1f
185.It
186a
187.Vt BOOLEAN ,
188.Vt INTEGER ,
189.Vt NULL
190etc. with the
191.Fa constructed
192bit set
193.It
194a
195.Vt SEQUENCE
196or
197.Vt SET
198etc. without the
199.Fa constructed
200bit set
201.It
202a
203.Fa content_length
204that makes no sense for the given
205.Fa tag
206.It
207a
208.Fa content_length
209that disagrees with the following data
210.It
211a
212.Vt BOOLEAN ,
213.Vt INTEGER ,
214.Vt NULL
215etc. in indefinite form
216.It
217an end-of-content marker even though no indefinite form was started
218.It
219\&...
220.El
221.Pp
222If the calling code wants to find out how many bytes were written,
223it needs to save a copy of the pointer
224.Pf * Fa ber_out
225before calling
226.Fn ASN1_put_object .
diff --git a/src/lib/libcrypto/man/ASRange_new.3 b/src/lib/libcrypto/man/ASRange_new.3
deleted file mode 100644
index dc58c98e58..0000000000
--- a/src/lib/libcrypto/man/ASRange_new.3
+++ /dev/null
@@ -1,410 +0,0 @@
1.\" $OpenBSD: ASRange_new.3,v 1.8 2023/10/11 12:06:11 tb Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 11 2023 $
18.Dt ASRANGE_NEW 3
19.Os
20.Sh NAME
21.Nm ASRange_new ,
22.Nm ASRange_free ,
23.Nm d2i_ASRange ,
24.Nm i2d_ASRange ,
25.Nm ASIdOrRange_new ,
26.Nm ASIdOrRange_free ,
27.Nm d2i_ASIdOrRange ,
28.Nm i2d_ASIdOrRange ,
29.Nm ASIdentifierChoice_new ,
30.Nm ASIdentifierChoice_free ,
31.Nm d2i_ASIdentifierChoice ,
32.Nm i2d_ASIdentifierChoice
33.Nd RFC 3779 autonomous system identifiers and ranges
34.Sh SYNOPSIS
35.In openssl/x509v3.h
36.Ft "ASRange *"
37.Fn ASRange_new void
38.Ft void
39.Fn ASRange_free "ASRange *asrange"
40.Ft ASRange *
41.Fo d2i_ASRange
42.Fa "ASRange **asrange"
43.Fa "const unsigned char **der_in"
44.Fa "long length"
45.Fc
46.Ft int
47.Fo i2d_ASRange
48.Fa "ASRange *asrange"
49.Fa "unsigned char **der_out"
50.Fc
51.Ft "ASIdOrRange *"
52.Fn ASIdOrRange_new void
53.Ft void
54.Fn ASIdOrRange_free "ASIdOrRange *aor"
55.Ft ASIdOrRange *
56.Fo d2i_ASIdOrRange
57.Fa "ASIdOrRange **aor"
58.Fa "const unsigned char **der_in"
59.Fa "long length"
60.Fc
61.Ft int
62.Fo i2d_ASIdOrRange
63.Fa "ASIdOrRange *aor"
64.Fa "unsigned char **der_out"
65.Fc
66.Ft "ASIdentifierChoice *"
67.Fn ASIdentifierChoice_new void
68.Ft void
69.Fn ASIdentifierChoice_free "ASIdentifierChoice *aic"
70.Ft ASIdentifierChoice *
71.Fo d2i_ASIdentifierChoice
72.Fa "ASIdentifierChoice **aic"
73.Fa "const unsigned char **der_in"
74.Fa "long length"
75.Fc
76.Ft int
77.Fo i2d_ASIdentifierChoice
78.Fa "ASIdentifierChoice *aic"
79.Fa "unsigned char **der_out"
80.Fc
81.Sh DESCRIPTION
82.Vt ASRange ,
83.Vt ASIdOrRange ,
84and
85.Vt ASIdentifierChoice
86are building blocks of the
87.Vt ASIdentifiers
88type representing the RFC 3779
89autonomous system identifier delegation extension.
90.Pp
91All
92.Vt ASN1_INTEGER Ns s
93in this manual must be representable as unsigned 32-bit integers.
94The API performs no corresponding checks.
95An
96.Vt ASN1_INTEGER
97can be set using
98.Xr ASN1_INTEGER_set_uint64 3 .
99.Pp
100The
101.Vt ASRange
102type defined in RFC 3779 section 3.2.3.8 is implemented as
103.Bd -literal -offset indent
104typedef struct ASRange_st {
105 ASN1_INTEGER *min;
106 ASN1_INTEGER *max;
107} ASRange;
108.Ed
109.Pp
110It represents the closed range [min,max] of AS identifiers between
111.Fa min
112and
113.Fa max ,
114where
115.Fa min
116should be strictly smaller than
117.Fa max .
118.Pp
119.Fn ASRange_new
120allocates a new
121.Vt ASRange
122object with allocated, empty
123.Fa min
124and
125.Fa max ,
126thus representing the invalid range [0,0].
127.Pp
128.Fn ASRange_free
129frees
130.Fa asrange
131including any data contained in it.
132If
133.Fa asrange
134is
135.Dv NULL ,
136no action occurs.
137.Pp
138The
139.Vt ASIdOrRange
140type defined in RFC 3779 section 3.2.3.5 is implemented as
141.Bd -literal -offset indent
142typedef struct ASIdOrRange_st {
143 int type;
144 union {
145 ASN1_INTEGER *id;
146 ASRange *range;
147 } u;
148} ASIdOrRange;
149.Ed
150.Pp
151representing an individual AS identifier or a range.
152When populating an
153.Vt ASIdOrRange
154object by hand, its
155.Fa type
156should be set to
157.Dv ASIdOrRange_id
158or
159.Dv ASIdOrRange_range
160to indicate which member of the union
161.Fa u
162is valid.
163.Pp
164.Fn ASIdOrRange_new
165returns a new
166.Vt ASIdOrRange
167object with invalid type and
168.Dv NULL
169members of the union
170.Fa u .
171.Pp
172.Fn ASIdOrRange_free
173frees
174.Fa aor
175including any data contained in it,
176provided
177.Fa type
178is set correctly.
179If
180.Fa asrange
181is
182.Dv NULL ,
183no action occurs.
184.Pp
185In order to express a list of AS identifiers and ranges,
186RFC 3779 section 3.2.3.4
187uses an ASN.1 SEQUENCE,
188which is implemented via a
189.Xr STACK_OF 3
190construction over
191.Vt ASIdOrRange :
192.Bd -literal -offset indent
193typedef STACK_OF(ASIdOrRange) ASIdOrRanges;
194.Ed
195.Pp
196Since an
197.Vt ASIdOrRanges
198object should be sorted in a specific way (see
199.Xr X509v3_asid_canonize 3 Ns ),
200a comparison function is needed for a correct instantiation
201with
202.Xr sk_new 3 .
203The
204.Fn ASIdOrRange_cmp
205function is not directly exposed and not easily accessible
206from outside the library,
207and it is non-trivial to implement.
208It is therefore discouraged to use
209.Vt ASIdOrRanges
210objects that are not part of an
211.Vt ASIdentifiers
212object.
213.Pp
214The
215.Dq inherit
216marker from RFC 3779 section 3.2.3.3 is implemented as
217.Vt ASN1_NULL .
218It has no dedicated type or API and can be instantiated with
219.Xr ASN1_NULL_new 3 .
220.Pp
221The
222.Vt ASIdentifierChoice
223type defined in RFC 3779 section 3.2.3.2 is implemented as
224.Bd -literal -offset indent
225typedef struct ASIdentifierChoice_st {
226 int type;
227 union {
228 ASN1_NULL *inherit;
229 ASIdOrRanges *asIdsOrRanges;
230 } u;
231} ASIdentifierChoice;
232.Ed
233.Pp
234where the
235.Fa type
236member should be set to
237.Dv ASIdentifierChoice_inherit
238or
239.Dv ASIdentifierChoice_asIdsOrRanges
240to indicate whether a given
241.Vt ASIdentifierChoice
242object represents an inherited list or an explicit list.
243.Pp
244.Fn ASIdentifierChoice_new
245returns a new
246.Vt ASIdentifierChoice
247object with invalid type and
248.Dv NULL
249members of the union
250.Fa u .
251.Pp
252.Fn ASIdentifierChoice_free
253frees
254.Fa aic
255including any data contained in it,
256provided
257.Fa type
258is set correctly.
259.Pp
260The
261.Vt ASIdentifiers
262type defined in RFC 3779 section 3.2.3.1 is implemented as
263.Bd -literal -offset indent
264typedef struct ASIdentifiers_st {
265 ASIdentifierChoice *asnum;
266 ASIdentifierChoice *rdi;
267} ASIdentifiers;
268.Ed
269.Pp
270It should be instantiated with
271.Xr ASIdentifiers_new 3
272and populated with
273.Xr X509v3_asid_add_id_or_range 3 .
274.Pp
275.Fn d2i_ASRange ,
276.Fn i2d_ASRange ,
277.Fn d2i_ASIdOrRange ,
278.Fn i2d_ASIdOrRange ,
279.Fn d2i_ASIdentifierChoice ,
280and
281.Fn i2d_ASIdentifierChoice
282decode and encode ASN.1
283.Vt ASRange ,
284.Vt ASIdOrRange ,
285and
286.Vt ASIdentifierChoice
287objects.
288For details about the semantics, examples, caveats, and bugs, see
289.Xr ASN1_item_d2i 3 .
290In order for the encoding produced by
291.Fn i2d_ASRange
292to be correct,
293.Fa min
294must be strictly less than
295.Fa max .
296Similarly for
297.Fn i2d_ASIdOrRange
298and an
299.Fa ASIdOrRange
300object of
301.Fa type
302.Dv ASIdOrRange_range .
303.Sh RETURN VALUES
304.Fn ASRange_new
305returns a new
306.Vt ASRange
307object with allocated, empty members, or
308.Dv NULL
309if an error occurs.
310.Pp
311.Fn ASIdOrRange_new
312returns a new, empty
313.Vt ASIdOrRange
314object or
315.Dv NULL
316if an error occurs.
317.Pp
318.Fn ASIdentifierChoice_new
319returns a new, empty
320.Vt ASIdentifierChoice
321object or
322.Dv NULL
323if an error occurs.
324.Pp
325The decoding functions
326.Fn d2i_ASRange ,
327.Fn d2i_ASIdOrRange ,
328and
329.Fn d2i_ASIdentifierChoice
330return an
331.Vt ASRange ,
332an
333.Vt ASIdOrRange ,
334or an
335.Vt ASIdentifierChoice ,
336object, respectively,
337or
338.Dv NULL
339if an error occurs.
340.Pp
341The encoding functions
342.Fn i2d_ASRange ,
343.Fn i2d_ASIdOrRange ,
344and
345.Fn i2d_ASIdentifierChoice
346return the number of bytes successfully encoded
347or a value <= 0 if an error occurs.
348.Sh SEE ALSO
349.Xr ASIdentifiers_new 3 ,
350.Xr ASN1_INTEGER_set_uint64 3 ,
351.Xr crypto 3 ,
352.Xr IPAddressRange_new 3 ,
353.Xr s2i_ASN1_INTEGER 3 ,
354.Xr STACK_OF 3 ,
355.Xr X509_new 3 ,
356.Xr X509v3_asid_add_id_or_range 3
357.Sh STANDARDS
358RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers:
359.Bl -dash -compact
360.It
361section 3.2.3: Syntax
362.It
363section 3.2.3.1: Type ASIdentifiers
364.It
365section 3.2.3.2: Elements asnum, rdi, and Type ASIdentifierChoice
366.It
367section 3.2.3.3: Element inherit
368.It
369section 3.2.3.4: Element asIdsOrRanges
370.It
371section 3.2.3.5: Type ASIdOrRange
372.It
373section 3.2.3.6: Element id
374.It
375section 3.2.3.7: Element range
376.It
377section 3.2.3.8: Type ASRange
378.It
379section 3.2.3.9: Elements min and max
380.El
381.Sh HISTORY
382These functions first appeared in OpenSSL 0.9.8e
383and have been available since
384.Ox 7.1 .
385.Sh BUGS
386An
387.Fn ASIdOrRanges_new
388function that installs the correct comparison function
389on the stack of
390.Vt ASIdOrRange
391should have been part of the API to make it usable.
392.Pp
393.Fn ASIdentifierChoice_new
394is of very limited use because
395.Fn ASIdOrRanges_new
396is missing.
397.Pp
398There is no way of ensuring that an
399.Vt ASIdOrRanges
400object is in canonical form unless it is part of an
401.Vt ASIdentifiers
402object.
403It is therefore difficult to guarantee that the output of
404.Fn i2d_ASIdentifierChoice
405is conformant.
406.Pp
407RFC 3779 3.2.3.4 has
408.Dq Fa asIdsOrRanges
409while its type in this implementation is
410.Vt ASIdOrRanges .
diff --git a/src/lib/libcrypto/man/AUTHORITY_KEYID_new.3 b/src/lib/libcrypto/man/AUTHORITY_KEYID_new.3
deleted file mode 100644
index bff451ff36..0000000000
--- a/src/lib/libcrypto/man/AUTHORITY_KEYID_new.3
+++ /dev/null
@@ -1,73 +0,0 @@
1.\" $OpenBSD: AUTHORITY_KEYID_new.3,v 1.4 2019/06/06 01:06:58 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 6 2019 $
18.Dt AUTHORITY_KEYID_NEW 3
19.Os
20.Sh NAME
21.Nm AUTHORITY_KEYID_new ,
22.Nm AUTHORITY_KEYID_free
23.Nd X.509 authority key identifier extension
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft AUTHORITY_KEYID *
27.Fn AUTHORITY_KEYID_new void
28.Ft void
29.Fn AUTHORITY_KEYID_free "AUTHORITY_KEYID *id"
30.Sh DESCRIPTION
31Using the authority key identifier extension, an X.509 certificate
32or certificate revocation list can specify which key pair was used
33for signing it.
34.Pp
35.Fn AUTHORITY_KEYID_new
36allocates and initializes an empty
37.Vt AUTHORITY_KEYID
38object, representing an ASN.1
39.Vt AuthorityKeyIdentifier
40structure defined in RFC 5280 section 4.2.1.1.
41It can hold an issuer name, a serial number, and a key identifier.
42.Pp
43.Fn AUTHORITY_KEYID_free
44frees
45.Fa id .
46.Sh RETURN VALUES
47.Fn AUTHORITY_KEYID_new
48returns the new
49.Vt AUTHORITY_KEYID
50object or
51.Dv NULL
52if an error occurs.
53.Sh SEE ALSO
54.Xr d2i_AUTHORITY_KEYID 3 ,
55.Xr GENERAL_NAMES_new 3 ,
56.Xr X509_CRL_new 3 ,
57.Xr X509_EXTENSION_new 3 ,
58.Xr X509_new 3
59.Sh STANDARDS
60RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
61Certificate Revocation List (CRL) Profile:
62.Bl -dash -compact
63.It
64section 4.2.1.1: Certificate Extensions: Authority Key Identifier
65.It
66section 5.2.1: CRL Extensions: Authority Key Identifier
67.El
68.Sh HISTORY
69.Fn AUTHORITY_KEYID_new
70and
71.Fn AUTHORITY_KEYID_free
72first appeared in OpenSSL 0.9.2b and have been available since
73.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/BASIC_CONSTRAINTS_new.3 b/src/lib/libcrypto/man/BASIC_CONSTRAINTS_new.3
deleted file mode 100644
index e60b0d223c..0000000000
--- a/src/lib/libcrypto/man/BASIC_CONSTRAINTS_new.3
+++ /dev/null
@@ -1,89 +0,0 @@
1.\" $OpenBSD: BASIC_CONSTRAINTS_new.3,v 1.6 2021/10/27 11:24:47 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 27 2021 $
18.Dt BASIC_CONSTRAINTS_NEW 3
19.Os
20.Sh NAME
21.Nm BASIC_CONSTRAINTS_new ,
22.Nm BASIC_CONSTRAINTS_free
23.Nd X.509 extension to mark CA certificates
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft BASIC_CONSTRAINTS *
27.Fn BASIC_CONSTRAINTS_new void
28.Ft void
29.Fn BASIC_CONSTRAINTS_free "BASIC_CONSTRAINTS *bc"
30.Sh DESCRIPTION
31.Fn BASIC_CONSTRAINTS_new
32allocates and initializes an empty
33.Vt BASIC_CONSTRAINTS
34object, representing an ASN.1
35.Vt BasicConstraints
36structure defined in RFC 5280 section 4.2.1.9.
37.Pp
38This object contains two fields.
39The field
40.Fa "int ca"
41is non-zero if the certificate is a CA certificate.
42The field
43.Fa "ASN1_INTEGER *pathlen"
44specifies the maximum number of non-self-issued intermediate
45certificates that may follow this certificate in a valid
46certification path.
47.Pp
48If an X.509 version 3 certificate does not contain this extension
49or if the
50.Fa ca
51field of the
52.Vt BASIC_CONSTRAINTS
53object is 0, or if the certificate contains a key usage extension
54having the
55.Dv KU_KEY_CERT_SIGN
56bit unset, then it is not a CA certificate but an end entity
57certificate.
58.Pp
59.Fn BASIC_CONSTRAINTS_free
60frees
61.Fa bc .
62.Sh RETURN VALUES
63.Fn BASIC_CONSTRAINTS_new
64returns the new
65.Vt BASIC_CONSTRAINTS
66object or
67.Dv NULL
68if an error occurs.
69.Sh SEE ALSO
70.Xr d2i_BASIC_CONSTRAINTS 3 ,
71.Xr X509_check_purpose 3 ,
72.Xr X509_EXTENSION_new 3 ,
73.Xr X509_get_extension_flags 3 ,
74.Xr X509_new 3
75.Sh STANDARDS
76RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
77Certificate Revocation List (CRL) Profile:
78.Bl -dash -compact
79.It
80section 4.2.1.9: Basic Constraints
81.It
82section 6.1: Basic Path Validation
83.El
84.Sh HISTORY
85.Fn BASIC_CONSTRAINTS_new
86and
87.Fn BASIC_CONSTRAINTS_free
88first appeared in OpenSSL 0.9.2b and have been available since
89.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/BF_set_key.3 b/src/lib/libcrypto/man/BF_set_key.3
deleted file mode 100644
index 5f4c7a689b..0000000000
--- a/src/lib/libcrypto/man/BF_set_key.3
+++ /dev/null
@@ -1,269 +0,0 @@
1.\" $OpenBSD: BF_set_key.3,v 1.12 2023/08/05 18:27:55 jmc Exp $
2.\" OpenSSL 99d63d46 Jul 19 09:27:53 2016 -0400
3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org>.
5.\" Copyright (c) 2000, 2002, 2005, 2014, 2016 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: August 5 2023 $
53.Dt BF_SET_KEY 3
54.Os
55.Sh NAME
56.Nm BF_set_key ,
57.Nm BF_encrypt ,
58.Nm BF_decrypt ,
59.Nm BF_ecb_encrypt ,
60.Nm BF_cbc_encrypt ,
61.Nm BF_cfb64_encrypt ,
62.Nm BF_ofb64_encrypt
63.Nd Blowfish encryption
64.Sh SYNOPSIS
65.In openssl/blowfish.h
66.Ft void
67.Fo BF_set_key
68.Fa "BF_KEY *key"
69.Fa "int len"
70.Fa "const unsigned char *data"
71.Fc
72.Ft void
73.Fo BF_encrypt
74.Fa "BF_LONG *data"
75.Fa "const BF_KEY *key"
76.Fc
77.Ft void
78.Fo BF_decrypt
79.Fa "BF_LONG *data"
80.Fa "const BF_KEY *key"
81.Fc
82.Ft void
83.Fo BF_ecb_encrypt
84.Fa "const unsigned char *in"
85.Fa "unsigned char *out"
86.Fa "BF_KEY *key"
87.Fa "int enc"
88.Fc
89.Ft void
90.Fo BF_cbc_encrypt
91.Fa "const unsigned char *in"
92.Fa "unsigned char *out"
93.Fa "long length"
94.Fa "BF_KEY *schedule"
95.Fa "unsigned char *ivec"
96.Fa "int enc"
97.Fc
98.Ft void
99.Fo BF_cfb64_encrypt
100.Fa "const unsigned char *in"
101.Fa "unsigned char *out"
102.Fa "long length"
103.Fa "BF_KEY *schedule"
104.Fa "unsigned char *ivec"
105.Fa "int *num"
106.Fa "int enc"
107.Fc
108.Ft void
109.Fo BF_ofb64_encrypt
110.Fa "const unsigned char *in"
111.Fa "unsigned char *out"
112.Fa "long length"
113.Fa "BF_KEY *schedule"
114.Fa "unsigned char *ivec"
115.Fa "int *num"
116.Fc
117.Sh DESCRIPTION
118This library implements the Blowfish cipher,
119which was invented and defined by
120.An Counterpane .
121Note that applications should use higher level functions such as
122.Xr EVP_EncryptInit 3
123instead of calling the Blowfish functions directly.
124.Pp
125Blowfish is a block cipher that operates on 64-bit (8 byte) blocks of data.
126It uses a variable size key, but typically, 128-bit (16 byte) keys
127are considered good for strong encryption.
128Blowfish can be used in the same modes as DES
129and is currently one of the faster block ciphers.
130It is quite a bit faster than DES, and much faster than IDEA or RC2.
131.Pp
132Blowfish consists of a key setup phase
133and the actual encryption or decryption phase.
134.Pp
135.Fn BF_set_key
136sets up the
137.Vt BF_KEY
138.Fa key
139using the
140.Fa len
141bytes long key at
142.Fa data .
143.Pp
144.Fn BF_ecb_encrypt
145is the basic Blowfish encryption and decryption function.
146It encrypts or decrypts the first 64 bits of
147.Fa in
148using the key
149.Fa key ,
150putting the result in
151.Fa out .
152.Fa enc
153decides if encryption
154.Pq Dv BF_ENCRYPT
155or decryption
156.Pq Dv BF_DECRYPT
157shall be performed.
158The vector pointed at by
159.Fa in
160and
161.Fa out
162must be 64 bits in length, no less.
163If they are larger, everything after the first 64 bits is ignored.
164.Pp
165The mode functions
166.Fn BF_cbc_encrypt ,
167.Fn BF_cfb64_encrypt ,
168and
169.Fn BF_ofb64_encrypt
170all operate on variable length data.
171They all take an initialization vector
172.Fa ivec
173which needs to be passed along into the next call of the same function
174for the same message.
175.Fa ivec
176may be initialized with anything, but the recipient needs to know what
177it was initialized with, or it won't be able to decrypt.
178Some programs and protocols simplify this, like SSH, where
179.Fa ivec
180is simply initialized to zero.
181.Fn BF_cbc_encrypt
182operates on data that is a multiple of 8 bytes long, while
183.Fn BF_cfb64_encrypt
184and
185.Fn BF_ofb64_encrypt
186are used to encrypt a variable number of bytes (the amount
187does not have to be an exact multiple of 8).
188The purpose of the latter two is to simulate stream ciphers and,
189therefore, they need the parameter
190.Fa num ,
191which is a pointer to an integer where the current offset in
192.Fa ivec
193is stored between calls.
194This integer must be initialized to zero when
195.Fa ivec
196is initialized.
197.Pp
198.Fn BF_cbc_encrypt
199is the Cipher Block Chaining function for Blowfish.
200It encrypts or decrypts the 64-bit chunks of
201.Fa in
202using the key
203.Fa schedule ,
204putting the result in
205.Fa out .
206.Fa enc
207decides if encryption
208.Pq Dv BF_ENCRYPT
209or decryption
210.Pq Dv BF_DECRYPT
211shall be performed.
212.Fa ivec
213must point at an 8-byte long initialization vector.
214.Pp
215.Fn BF_cfb64_encrypt
216is the CFB mode for Blowfish with 64-bit feedback.
217It encrypts or decrypts the bytes in
218.Fa in
219using the key
220.Fa schedule ,
221putting the result in
222.Fa out .
223.Fa enc
224decides if encryption
225.Pq Dv BF_ENCRYPT
226or decryption
227.Pq Dv BF_DECRYPT
228shall be performed.
229.Fa ivec
230must point at an
2318-byte long initialization vector.
232.Fa num
233must point at an integer which must be initially zero.
234.Pp
235.Fn BF_ofb64_encrypt
236is the OFB mode for Blowfish with 64-bit feedback.
237It uses the same parameters as
238.Fn BF_cfb64_encrypt ,
239which must be initialized the same way.
240.Pp
241.Fn BF_encrypt
242and
243.Fn BF_decrypt
244are the lowest level functions for Blowfish encryption.
245They encrypt/decrypt the first 64 bits of the vector pointed by
246.Fa data ,
247using the key
248.Fa key .
249These functions should not be used unless implementing `modes' of Blowfish.
250The alternative is to use
251.Fn BF_ecb_encrypt .
252Be aware that these functions take each 32-bit chunk in host-byte order,
253which is little-endian on little-endian platforms
254and big-endian on big-endian ones.
255.Sh SEE ALSO
256.Xr EVP_EncryptInit 3
257.Sh HISTORY
258.Fn BF_set_key ,
259.Fn BF_encrypt ,
260.Fn BF_ecb_encrypt ,
261.Fn BF_cbc_encrypt ,
262.Fn BF_cfb64_encrypt ,
263and
264.Fn BF_ofb64_encrypt
265first appeared in SSLeay 0.6.6.
266.Fn BF_decrypt
267first appeared in SSLeay 0.9.0.
268All these functions have been available since
269.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BIO_accept.3 b/src/lib/libcrypto/man/BIO_accept.3
deleted file mode 100644
index e2547ac0dd..0000000000
--- a/src/lib/libcrypto/man/BIO_accept.3
+++ /dev/null
@@ -1,387 +0,0 @@
1.\" $OpenBSD: BIO_accept.3,v 1.2 2023/04/30 13:38:48 schwarze Exp $
2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: April 30 2023 $
18.Dt BIO_ACCEPT 3
19.Os
20.Sh NAME
21.\" mentioned in OpenSSL documentation and still used internally in LibreSSL
22.Nm BIO_get_host_ip ,
23.Nm BIO_get_port ,
24.Nm BIO_get_accept_socket ,
25.Nm BIO_accept ,
26.Nm BIO_sock_error ,
27.Nm BIO_sock_non_fatal_error ,
28.Nm BIO_sock_should_retry ,
29.\" used internally in LibreSSL and OpenSSL and not deprecated in OpenSSL
30.Nm BIO_socket_nbio ,
31.\" mentioned in OpenSSL documentation and not deprecated in OpenSSL
32.Nm BIO_set_tcp_ndelay
33.\" deprecated in OpenSSL and unused anywhere, hence intentionally undocumented
34.\" .Nm BIO_gethostbyname
35.\" .Nm BIO_GHBN_CTRL_CACHE_SIZE
36.\" .Nm BIO_GHBN_CTRL_FLUSH
37.\" .Nm BIO_GHBN_CTRL_GET_ENTRY
38.\" .Nm BIO_GHBN_CTRL_HITS
39.\" .Nm BIO_GHBN_CTRL_MISSES
40.\" .Nm BIO_socket_ioctl
41.\" does almost nothing and used very rarely, hence intentionally undocumented
42.\" .Nm BIO_sock_init
43.\" .Nm BIO_sock_cleanup
44.Nd wrappers for socket operations
45.Sh SYNOPSIS
46.In openssl/bio.h
47.Ft int
48.Fo BIO_get_host_ip
49.Fa "const char *hostname"
50.Fa "unsigned char *in_addr_buffer"
51.Fc
52.Ft int
53.Fo BIO_get_port
54.Fa "const char *servname"
55.Fa "unsigned short *port"
56.Fc
57.Ft int
58.Fo BIO_get_accept_socket
59.Fa "char *host_port"
60.Fa "int bind_mode"
61.Fc
62.Ft int
63.Fo BIO_accept
64.Fa "int socket"
65.Fa "char **addr"
66.Fc
67.Ft int
68.Fn BIO_sock_error "int socket"
69.Ft int
70.Fn BIO_sock_non_fatal_error "int errnum"
71.Ft int
72.Fn BIO_sock_should_retry "int retval"
73.Ft int
74.Fn BIO_socket_nbio "int socket" "int mode"
75.Ft int
76.Fn BIO_set_tcp_ndelay "int socket" "int on"
77.Sh DESCRIPTION
78.Fn BIO_get_host_ip
79looks up one IPv4 address for the given
80.Fa hostname
81using
82.Xr getaddrinfo 3
83and writes the first returned IPv4 address into
84.Pf * Fa in_addr_buffer .
85The caller is responsible for providing a buffer that is at least
86.Fn sizeof in_addr_t
87bytes long.
88After a successful call, the caller needs to cast
89.Fa in_addr_buffer
90to
91.Pq Vt in_addr_t * .
92.Pp
93.Fn BIO_get_port
94looks up
95.Fa servname
96in the
97.Xr services 5
98database using
99.Xr getaddrinfo 3
100and stores the associated port number at the location specified by the
101.Fa port
102argument.
103.Pp
104.Fn BIO_get_accept_socket
105creates an IPv4 TCP socket and
106.Xr listen 2 Ns s
107for incoming connections.
108The string
109.Fa host_port
110is parsed.
111If it contains a colon, the substring before the colon is interpreted
112as a local hostname of the interface to
113.Xr bind 2
114to.
115If the hostname is empty, consists of a single asterisk
116.Pq Qq *:... ,
117or if there is no colon,
118.Dv INADDR_ANY
119is used instead of a local hostname.
120The rest of the string
121.Fa host_port ,
122or the whole string if it contains no colon,
123is treated as a service name.
124The hostname and the service name are converted to a local IP address
125and port number using
126.Xr getaddrinfo 3 .
127If
128.Fa bind_mode
129is the constant
130.Dv BIO_BIND_REUSEADDR ,
131allowing local address reuse is attempted using
132.Xr setsockopt 2
133with an argument of
134.Dv SO_REUSEADDR
135before calling
136.Xr bind 2 .
137.Pp
138.Fn BIO_accept
139calls
140.Xr accept 2
141to receive one connection on the
142.Fa socket .
143When it receives a connection, it
144.Xr free 3 Ns s
145.Pf * Fa addr ,
146and if it is an IPv4 connection, it allocates a new string,
147writes the peer IP address in dotted decimal form, a colon,
148and the decimal port number into the string, and stores a pointer
149to the string in
150.Pf * Fa addr .
151For other address families or if
152.Xr getnameinfo 3
153or memory allocation fails,
154.Pf * Fa addr
155is set to
156.Dv NULL
157but
158.Fn BIO_accept
159succeeds anyway.
160.Pp
161.Fn BIO_sock_error
162retrieves, clears, and returns the error status code of the
163.Fa socket
164by calling
165.Xr getsockopt 2
166with arguments
167.Dv SOL_SOCKET
168and
169.Dv SO_ERROR .
170.Pp
171.Fn BIO_sock_non_fatal_error
172determines whether the error status code
173.Fa errnum
174represents a recoverable error.
175.Pp
176.Fn BIO_sock_should_retry
177determines whether a recoverable error occurred by inspecting both
178.Xr errno 2
179and
180.Fa retval ,
181which is supposed to usually be
182the return value of a previously called function like
183.Fn BIO_accept ,
184.Xr BIO_read 3 ,
185or
186.Xr BIO_write 3 .
187.Pp
188If
189.Fa mode
190is non-zero,
191.Fn BIO_socket_nbio
192switches the
193.Fa socket
194to non-blocking mode using
195.Xr fcntl 2 .
196If
197.Fa mode
198is 0, it switches to blocking mode.
199.Pp
200.Fn BIO_set_tcp_ndelay
201sets the
202.Dv TCP_NODELAY
203option on the
204.Fa socket
205if
206.Fa on
207is 1 or clears it if
208.Fa on
209is 0; see
210.Xr tcp 4
211for details.
212.Sh RETURN VALUES
213.Fn BIO_get_host_ip ,
214.Fn BIO_get_port ,
215and
216.Fn BIO_socket_nbio
217return 1 on success or 0 on failure.
218.Pp
219.Fn BIO_get_accept_socket
220returns the file descriptor of the newly created listening socket or \-1 if
221.Fa host_port
222is
223.Dv NULL ,
224no service is specified, or
225.Xr getaddrinfo 3 ,
226.Xr socket 2 ,
227.Xr bind 2 ,
228.Xr listen 2 ,
229or memory allocation fails.
230.Pp
231.Fn BIO_accept
232returns the file descriptor of the received connection,
233\-1 on fatal errors, that is, when
234.Fa addr
235is
236.Dv NULL
237or
238.Xr accept 2
239fails fatally, or \-2 when
240.Xr accept 2
241fails in a non-fatal way and might succeed when retried later.
242.Pp
243.Fn BIO_sock_error
244returns an error status code like
245.Dv EAGAIN ,
246.Dv ECONNABORTED ,
247.Dv ECONNREFUSED ,
248.Dv ECONNRESET ,
249.Dv ELOOP ,
250.Dv EMSGSIZE ,
251.Dv ENOBUFS ,
252.Dv ENOTCONN ,
253.Dv EPIPE ,
254.Dv ETIMEDOUT ,
255or others, 0 if the
256.Fa socket
257is not in an error state, or 1 if
258.Xr getsockopt 2
259fails.
260.Pp
261.Fn BIO_sock_non_fatal_error
262returns 1 if
263.Fa errnum
264is
265.Dv EAGAIN ,
266.Dv EALREADY ,
267.Dv EINPROGRESS ,
268.Dv EINTR ,
269or
270.Dv ENOTCONN
271and 0 otherwise, even if
272.Fa errnum
273is 0.
274.Pp
275.Fn BIO_sock_should_retry
276returns 1 if
277.Fn BIO_sock_non_fatal_error errno
278is 1 and
279.Fa retval
280is either 0 or \-1, or 0 otherwise.
281.Pp
282.Fn BIO_set_tcp_ndelay
283returns 0 on success or \-1 on failure.
284.Sh ERRORS
285If
286.Fn BIO_get_host_ip ,
287.Fn BIO_get_port ,
288or
289.Fn BIO_get_accept_socket
290fail or
291.Fn BIO_accept
292fails fatally, the following diagnostics can be retrieved with
293.Xr ERR_get_error 3 ,
294.Xr ERR_GET_REASON 3 ,
295and
296.Xr ERR_reason_error_string 3 :
297.Bl -tag -width Ds
298.It Dv BIO_R_ACCEPT_ERROR Qq "accept error"
299.Xr accept 2
300failed fatally in
301.Fn BIO_accept .
302.It Dv BIO_R_BAD_HOSTNAME_LOOKUP Qq "bad hostname lookup"
303.Xr getaddrinfo 3
304failed or
305.Fa hostname
306was
307.Dv NULL
308in
309.Fn BIO_get_host_ip ,
310or
311.Xr getaddrinfo 3
312failed in
313.Fn BIO_get_accept_socket .
314.It Dv BIO_R_INVALID_ARGUMENT Qq "invalid argument"
315.Xr getaddrinfo 3
316failed in
317.Fn BIO_get_port .
318.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
319Memory allocation failed in
320.Fn BIO_get_accept_socket ,
321or
322.Fn BIO_accept
323.Em succeeded
324but was unable to allocate memory for
325.Pf * Fa addr .
326For
327.Fn BIO_accept ,
328the returned file descriptor is valid,
329and communication with the peer can be attempted using it.
330.It Dv BIO_R_NO_PORT_SPECIFIED Qq "no port specified"
331The
332.Fa servname
333argument was
334.Dv NULL
335in
336.Fn BIO_get_port ,
337or
338.Fa host_port
339was
340.Dv NULL
341or ended after the first colon in
342.Fn BIO_get_accept_socket .
343.It Dv BIO_R_NULL_PARAMETER Qq "null parameter"
344The
345.Fa addr
346argument was
347.Dv NULL
348in
349.Fn BIO_accept .
350.It Dv BIO_R_UNABLE_TO_BIND_SOCKET Qq "unable to bind socket"
351.Xr bind 2
352failed in
353.Fn BIO_get_accept_socket .
354.It Dv BIO_R_UNABLE_TO_CREATE_SOCKET Qq "unable to create socket"
355.Xr socket 2
356failed in
357.Fn BIO_get_accept_socket .
358.It Dv BIO_R_UNABLE_TO_LISTEN_SOCKET Qq "unable to listen socket"
359.Xr listen 2
360failed in
361.Fn BIO_get_accept_socket .
362.El
363.Sh SEE ALSO
364.Xr bind 2 ,
365.Xr connect 2 ,
366.Xr errno 2 ,
367.Xr fcntl 2 ,
368.Xr getsockopt 2 ,
369.Xr listen 2 ,
370.Xr sigaction 2 ,
371.Xr socket 2 ,
372.Xr BIO_new 3 ,
373.Xr BIO_read 3 ,
374.Xr getaddrinfo 3 ,
375.Xr ip 4 ,
376.Xr tcp 4
377.Sh HISTORY
378.Fn BIO_sock_should_retry
379first appeared in SSLeay 0.6.5 and the other functions except
380.Fn BIO_socket_nbio
381in SSLeay 0.8.0.
382They have all been available since
383.Ox 2.4 .
384.Pp
385.Fn BIO_socket_nbio
386first appeared in SSLeay 0.9.1 and has been available since
387.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/BIO_ctrl.3 b/src/lib/libcrypto/man/BIO_ctrl.3
deleted file mode 100644
index 2c537956e1..0000000000
--- a/src/lib/libcrypto/man/BIO_ctrl.3
+++ /dev/null
@@ -1,637 +0,0 @@
1.\" $OpenBSD: BIO_ctrl.3,v 1.25 2023/11/16 20:19:23 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535eaf Tue Sep 22 13:14:20 2020 +0100
3.\" selective merge up to: OpenSSL 0c5bc96f Tue Mar 15 13:57:22 2022 +0000
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000, 2016 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: November 16 2023 $
70.Dt BIO_CTRL 3
71.Os
72.Sh NAME
73.Nm BIO_ctrl ,
74.Nm BIO_callback_ctrl ,
75.Nm BIO_ptr_ctrl ,
76.Nm BIO_int_ctrl ,
77.Nm BIO_reset ,
78.Nm BIO_seek ,
79.Nm BIO_tell ,
80.Nm BIO_flush ,
81.Nm BIO_eof ,
82.Nm BIO_set_close ,
83.Nm BIO_get_close ,
84.Nm BIO_pending ,
85.Nm BIO_wpending ,
86.Nm BIO_ctrl_pending ,
87.Nm BIO_ctrl_wpending ,
88.Nm BIO_get_info_callback ,
89.Nm BIO_set_info_callback ,
90.Nm BIO_info_cb ,
91.Nm bio_info_cb
92.Nd BIO control operations
93.Sh SYNOPSIS
94.In openssl/bio.h
95.Ft long
96.Fo BIO_ctrl
97.Fa "BIO *b"
98.Fa "int cmd"
99.Fa "long larg"
100.Fa "void *parg"
101.Fc
102.Ft long
103.Fo BIO_callback_ctrl
104.Fa "BIO *b"
105.Fa "int cmd"
106.Fa "BIO_info_cb *cb"
107.Fc
108.Ft char *
109.Fo BIO_ptr_ctrl
110.Fa "BIO *b"
111.Fa "int cmd"
112.Fa "long larg"
113.Fc
114.Ft long
115.Fo BIO_int_ctrl
116.Fa "BIO *b"
117.Fa "int cmd"
118.Fa "long larg"
119.Fa "int iarg"
120.Fc
121.Ft int
122.Fo BIO_reset
123.Fa "BIO *b"
124.Fc
125.Ft int
126.Fo BIO_seek
127.Fa "BIO *b"
128.Fa "int ofs"
129.Fc
130.Ft int
131.Fo BIO_tell
132.Fa "BIO *b"
133.Fc
134.Ft int
135.Fo BIO_flush
136.Fa "BIO *b"
137.Fc
138.Ft int
139.Fo BIO_eof
140.Fa "BIO *b"
141.Fc
142.Ft int
143.Fo BIO_set_close
144.Fa "BIO *b"
145.Fa "long flag"
146.Fc
147.Ft int
148.Fo BIO_get_close
149.Fa "BIO *b"
150.Fc
151.Ft int
152.Fo BIO_pending
153.Fa "BIO *b"
154.Fc
155.Ft int
156.Fo BIO_wpending
157.Fa "BIO *b"
158.Fc
159.Ft size_t
160.Fo BIO_ctrl_pending
161.Fa "BIO *b"
162.Fc
163.Ft size_t
164.Fo BIO_ctrl_wpending
165.Fa "BIO *b"
166.Fc
167.Ft int
168.Fo BIO_get_info_callback
169.Fa "BIO *b"
170.Fa "BIO_info_cb **cbp"
171.Fc
172.Ft int
173.Fo BIO_set_info_callback
174.Fa "BIO *b"
175.Fa "BIO_info_cb *cb"
176.Fc
177.Ft typedef int
178.Fo BIO_info_cb
179.Fa "BIO *b"
180.Fa "int state"
181.Fa "int res"
182.Fc
183.Ft typedef int
184.Fo bio_info_cb
185.Fa "BIO *b"
186.Fa "int state"
187.Fa "int res"
188.Fc
189.Sh DESCRIPTION
190.Fn BIO_ctrl ,
191.Fn BIO_callback_ctrl ,
192.Fn BIO_ptr_ctrl ,
193and
194.Fn BIO_int_ctrl
195are BIO "control" operations taking arguments of various types.
196These functions are not normally called directly -
197various macros are used instead.
198The standard macros are described below.
199Macros specific to a particular type of BIO
200are described in the specific BIO's manual page
201as well as any special features of the standard calls.
202.Pp
203Depending on the
204.Fa cmd
205and on the type of
206.Fa b ,
207.Fn BIO_ctrl
208may have a read-only effect on
209.Fa b
210or change data in
211.Fa b
212or in its sub-structures.
213It may also have a side effect of changing the memory pointed to by
214.Fa parg .
215.Pp
216.Fn BIO_callback_ctrl
217does not call
218.Fn BIO_ctrl
219but instead requires that the BIO type of
220.Fa b
221provides a dedicated
222.Fa callback_ctrl
223function pointer, which is built into the library for some standard BIO
224types and can be provided with
225.Xr BIO_meth_set_callback_ctrl 3
226for application-defined BIO types.
227The only
228.Fa cmd
229supported by
230.Fn BIO_callback_ctrl
231is
232.Dv BIO_CTRL_SET_CALLBACK .
233.Pp
234.Fn BIO_ptr_ctrl
235calls
236.Fn BIO_ctrl
237with
238.Fa parg
239pointing to the location of a temporary pointer variable initialized to
240.Dv NULL .
241.Pp
242.Fn BIO_int_ctrl
243calls
244.Fn BIO_ctrl
245with
246.Fa parg
247pointing to the location of a temporary
248.Vt int
249variable initialized to
250.Fa iarg .
251If
252.Fn BIO_ctrl
253changes the value stored at
254.Pf * Fa parg ,
255the new value is ignored.
256.Pp
257.Fn BIO_reset
258typically resets a BIO to some initial state.
259In the case of file related BIOs, for example,
260it rewinds the file pointer to the start of the file.
261.Pp
262.Fn BIO_seek
263resets a file related BIO's (that is file descriptor and
264FILE BIOs) file position pointer to
265.Fa ofs
266bytes from start of file.
267.Pp
268.Fn BIO_tell
269returns the current file position of a file related BIO.
270.Pp
271.Fn BIO_flush
272normally writes out any internally buffered data.
273In some cases it is used to signal EOF and that no more data will be written.
274.Pp
275.Fn BIO_eof
276returns 1 if the BIO has read EOF.
277The precise meaning of "EOF" varies according to the BIO type.
278.Pp
279.Fn BIO_set_close
280sets the BIO
281.Fa b
282close flag to
283.Fa flag .
284.Fa flag
285can take the value
286.Dv BIO_CLOSE
287or
288.Dv BIO_NOCLOSE .
289Typically
290.Dv BIO_CLOSE
291is used in a source/sink BIO to indicate that the underlying I/O stream
292should be closed when the BIO is freed.
293.Pp
294.Fn BIO_get_close
295returns the BIO's close flag.
296.Pp
297.Fn BIO_pending ,
298.Fn BIO_ctrl_pending ,
299.Fn BIO_wpending ,
300and
301.Fn BIO_ctrl_wpending
302return the number of pending characters in the BIO's read and write buffers.
303Not all BIOs support these calls.
304.Fn BIO_ctrl_pending
305and
306.Fn BIO_ctrl_wpending
307return a
308.Vt size_t
309type and are functions.
310.Pp
311.Fn BIO_set_info_callback
312installs the function pointer
313.Fa cb
314as an info callback in
315.Fa b
316by calling
317.Fn BIO_callback_ctrl
318with a command of
319.Dv BIO_CTRL_SET_CALLBACK .
320Among the BIO types built into the library, only
321.Xr BIO_s_connect 3
322and
323.Xr BIO_f_ssl 3
324support this functionality.
325Some filter BIO types forward this control call
326to the next BIO in the chain instead of processing it themselves.
327.Pp
328.Fn BIO_get_info_callback
329places the function pointer to the info callback into
330.Pf * Fa cbp
331if any was installed using
332.Fn BIO_set_info_callback
333or
334.Fn BIO_callback_ctrl .
335If the type of
336.Fa b
337supports setting an info callback but none was installed, it stores a
338.Dv NULL
339pointer in
340.Pf * Fa cbp .
341.Pp
342The function type name
343.Vt bio_info_cb
344is a deprecated synonym for
345.Vt BIO_info_cb
346provided for backward compatibility with some existing application software.
347.Pp
348The following
349.Fa cmd
350constants correspond to macros:
351.Bl -column BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT BIO_set_ssl_renegotiate_timeout(3)
352.It Fa cmd No constant Ta corresponding macro
353.It Dv BIO_C_DESTROY_BIO_PAIR Ta Xr BIO_destroy_bio_pair 3
354.It Dv BIO_C_DO_STATE_MACHINE Ta Xr BIO_do_handshake 3
355.It Dv BIO_C_FILE_SEEK Ta Fn BIO_seek
356.It Dv BIO_C_FILE_TELL Ta Fn BIO_tell
357.It Dv BIO_C_GET_ACCEPT Ta Xr BIO_get_accept_port 3
358.It Dv BIO_C_GET_BIND_MODE Ta Xr BIO_get_bind_mode 3
359.It Dv BIO_C_GET_BUF_MEM_PTR Ta Xr BIO_get_mem_ptr 3
360.It Dv BIO_C_GET_BUFF_NUM_LINES Ta Xr BIO_get_buffer_num_lines 3
361.It Dv BIO_C_GET_CIPHER_CTX Ta Xr BIO_get_cipher_ctx 3
362.It Dv BIO_C_GET_CIPHER_STATUS Ta Xr BIO_get_cipher_status 3
363.It Dv BIO_C_GET_FD Ta Xr BIO_get_fd 3
364.It Dv BIO_C_GET_FILE_PTR Ta Xr BIO_get_fp 3
365.It Dv BIO_C_GET_MD Ta Xr BIO_get_md 3
366.It Dv BIO_C_GET_MD_CTX Ta Xr BIO_get_md_ctx 3
367.It Dv BIO_C_GET_READ_REQUEST Ta Xr BIO_get_read_request 3
368.It Dv BIO_C_GET_SSL Ta Xr BIO_get_ssl 3
369.It Dv BIO_C_GET_SSL_NUM_RENEGOTIATES Ta Xr BIO_get_num_renegotiates 3
370.It Dv BIO_C_GET_WRITE_BUF_SIZE Ta Xr BIO_get_write_buf_size 3
371.It Dv BIO_C_GET_WRITE_GUARANTEE Ta Xr BIO_get_write_guarantee 3
372.It Dv BIO_C_MAKE_BIO_PAIR Ta Xr BIO_make_bio_pair 3
373.It Dv BIO_C_RESET_READ_REQUEST Ta Xr BIO_ctrl_reset_read_request 3
374.It Dv BIO_C_SET_BIND_MODE Ta Xr BIO_set_bind_mode 3
375.It Dv BIO_C_SET_BUF_MEM Ta Xr BIO_set_mem_buf 3
376.It Dv BIO_C_SET_BUF_MEM_EOF_RETURN Ta Xr BIO_set_mem_eof_return 3
377.It Dv BIO_C_SET_BUFF_READ_DATA Ta Xr BIO_set_buffer_read_data 3
378.It Dv BIO_C_SET_FD Ta Xr BIO_set_fd 3
379.It Dv BIO_C_SET_FILE_PTR Ta Xr BIO_set_fp 3
380.It Dv BIO_C_SET_MD Ta Xr BIO_set_md 3
381.It Dv BIO_C_SET_MD_CTX Ta Xr BIO_set_md_ctx 3
382.It Dv BIO_C_SET_NBIO Ta Xr BIO_set_nbio 3
383.It Dv BIO_C_SET_SSL Ta Xr BIO_set_ssl 3
384.It Dv BIO_C_SET_SSL_RENEGOTIATE_BYTES Ta Xr BIO_set_ssl_renegotiate_bytes 3
385.It Dv BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT Ta Xr BIO_set_ssl_renegotiate_timeout 3
386.It Dv BIO_C_SET_WRITE_BUF_SIZE Ta Xr BIO_set_write_buf_size 3
387.It Dv BIO_C_SHUTDOWN_WR Ta Xr BIO_shutdown_wr 3
388.It Dv BIO_C_SSL_MODE Ta Xr BIO_set_ssl_mode 3
389.It Dv BIO_CTRL_DGRAM_CONNECT Ta Xr BIO_ctrl_dgram_connect 3
390.It Dv BIO_CTRL_DGRAM_GET_PEER Ta Xr BIO_dgram_get_peer 3
391.It Dv BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP Ta Xr BIO_dgram_recv_timedout 3
392.It Dv BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP Ta Xr BIO_dgram_send_timedout 3
393.It Dv BIO_CTRL_DGRAM_SET_CONNECTED Ta Xr BIO_ctrl_set_connected 3
394.It Dv BIO_CTRL_DGRAM_SET_PEER Ta Xr BIO_dgram_set_peer 3
395.It Dv BIO_CTRL_DUP Ta Xr BIO_dup_state 3
396.It Dv BIO_CTRL_EOF Ta Fn BIO_eof
397.It Dv BIO_CTRL_FLUSH Ta Fn BIO_flush
398.It Dv BIO_CTRL_GET_CALLBACK Ta Fn BIO_get_info_callback
399.It Dv BIO_CTRL_GET_CLOSE Ta Fn BIO_get_close
400.It Dv BIO_CTRL_INFO Ta Xr BIO_get_mem_data 3
401.It Dv BIO_CTRL_PENDING Ta Fn BIO_pending
402.It Dv BIO_CTRL_RESET Ta Fn BIO_reset
403.It Dv BIO_CTRL_SET_CALLBACK Ta Fn BIO_set_info_callback
404.It Dv BIO_CTRL_SET_CLOSE Ta Fn BIO_set_close
405.It Dv BIO_CTRL_WPENDING Ta Fn BIO_wpending
406.El
407.Pp
408A few
409.Fa cmd
410constants serve more than one macro each
411and are documented in the following manual pages:
412.Bl -column BIO_C_SET_BUFF_SIZE BIO_s_connect(3) -offset 3n
413.It Fa cmd No constant Ta manual page
414.It Dv BIO_C_GET_CONNECT Ta Xr BIO_s_connect 3
415.It Dv BIO_C_SET_ACCEPT Ta Xr BIO_s_accept 3
416.It Dv BIO_C_SET_BUFF_SIZE Ta Xr BIO_f_buffer 3
417.It Dv BIO_C_SET_CONNECT Ta Xr BIO_s_connect 3
418.It Dv BIO_C_SET_FILENAME Ta Xr BIO_s_file 3
419.El
420.Pp
421Some
422.Fa cmd
423constants are not associated with any macros.
424They are documented in the following manual pages:
425.Bl -column BIO_CTRL_DGRAM_SET_RECV_TIMEOUT BIO_dgram_recv_timedout(3)\
426 -offset 3n
427.It Fa cmd No constant Ta manual page
428.\" The following constants are intentionally undocumented because
429.\" BIO_f_asn1 has been removed from the public API.
430.\" .It Dv BIO_C_GET_EX_ARG Ta Xr BIO_f_asn1 3
431.\" .It Dv BIO_C_SET_EX_ARG Ta Xr BIO_f_asn1 3
432.It Dv BIO_CTRL_DGRAM_GET_FALLBACK_MTU Ta Xr BIO_dgram_set_peer 3
433.It Dv BIO_CTRL_DGRAM_GET_MTU Ta Xr BIO_dgram_set_peer 3
434.It Dv BIO_CTRL_DGRAM_GET_RECV_TIMEOUT Ta Xr BIO_dgram_recv_timedout 3
435.It Dv BIO_CTRL_DGRAM_GET_SEND_TIMEOUT Ta Xr BIO_dgram_send_timedout 3
436.It Dv BIO_CTRL_DGRAM_SET_MTU Ta Xr BIO_dgram_set_peer 3
437.It Dv BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT Ta Xr BIO_dgram_recv_timedout 3
438.It Dv BIO_CTRL_DGRAM_SET_RECV_TIMEOUT Ta Xr BIO_dgram_recv_timedout 3
439.It Dv BIO_CTRL_DGRAM_SET_SEND_TIMEOUT Ta Xr BIO_dgram_send_timedout 3
440.It Dv BIO_CTRL_DGRAM_MTU_EXCEEDED Ta Xr BIO_s_datagram 3
441.It Dv BIO_CTRL_POP Ta Xr BIO_pop 3
442.It Dv BIO_CTRL_PUSH Ta Xr BIO_push 3
443.El
444.Sh RETURN VALUES
445The meaning of the return values of
446.Fn BIO_ctrl ,
447.Fn BIO_callback_ctrl ,
448and
449.Fn BIO_int_ctrl
450depends on both the type of
451.Fa b
452and on the
453.Fa cmd .
454If
455.Fa b
456is a
457.Dv NULL
458pointer, no action occurs and 0 is returned.
459The return value \-2 usually indicates a fatal error.
460In particular, it is returned if the
461.Fa cmd
462is unsupported by the type of
463.Fa b .
464.Pp
465.Fn BIO_callback_ctrl
466and
467.Fn BIO_set_info_callback
468return 1 on success, 0 if
469.Fa b
470is
471.Dv NULL
472or to indicate failure of a valid
473.Fa cmd ,
474or \-2 if the
475.Fa cmd
476is not supported by
477.Fa b .
478.Pp
479.Fn BIO_ptr_ctrl
480returns
481.Dv NULL
482if the
483.Fn BIO_ctrl
484call returns a negative value or does not change
485.Pf * Fa parg ,
486or the pointer it puts into
487.Pf * Fa parg
488otherwise.
489.Pp
490.Fn BIO_int_ctrl
491returns the return value of
492.Fn BIO_ctrl .
493.Pp
494.Fn BIO_reset
495normally returns 1 for success and 0 or -1 for failure.
496File BIOs are an exception, returning 0 for success and -1 for failure.
497.Pp
498.Fn BIO_seek
499and
500.Fn BIO_tell
501both return the current file position on success
502and -1 for failure, except file BIOs which for
503.Fn BIO_seek
504always return 0 for success and -1 for failure.
505.Pp
506.Fn BIO_flush
507returns 1 for success and 0 or -1 for failure.
508.Pp
509.Fn BIO_eof
510returns 1 if EOF has been reached or 0 otherwise.
511.Pp
512.Fn BIO_set_close
513always returns 1.
514.Pp
515.Fn BIO_get_close
516returns the close flag value
517.Dv BIO_CLOSE
518or
519.Dv BIO_NOCLOSE .
520.Pp
521.Fn BIO_pending ,
522.Fn BIO_ctrl_pending ,
523.Fn BIO_wpending ,
524and
525.Fn BIO_ctrl_wpending
526return the amount of pending data.
527.Pp
528.Fn BIO_get_info_callback
529returns 1 on success, including when the type of
530.Fa b
531supports an info callback but none is installed,
5320 if
533.Fa b
534is
535.Dv NULL
536or \-2 if the type of
537.Fa b
538does not support an info callback.
539.Pp
540If a callback was installed in
541.Fa b
542using
543.Xr BIO_set_callback_ex 3
544or
545.Xr BIO_set_callback 3 ,
546it can modify the return values of all these functions.
547.Sh NOTES
548Because it can write data,
549.Fn BIO_flush
550may return 0 or -1 indicating that the call should be retried later
551in a similar manner to
552.Xr BIO_write 3 .
553The
554.Xr BIO_should_retry 3
555call should be used and appropriate action taken if the call fails.
556.Pp
557The return values of
558.Fn BIO_pending
559and
560.Fn BIO_wpending
561may not reliably determine the amount of pending data in all cases.
562For example in the case of a file BIO some data may be available in the
563.Vt FILE
564structure's internal buffers but it is not possible
565to determine this in a portable way.
566For other types of BIO they may not be supported.
567.Pp
568If they do not internally handle a particular
569.Fn BIO_ctrl
570operation, filter BIOs usually pass the operation
571to the next BIO in the chain.
572This often means there is no need to locate the required BIO for
573a particular operation: it can be called on a chain and it will
574be automatically passed to the relevant BIO.
575However, this can cause unexpected results.
576For example no current filter BIOs implement
577.Fn BIO_seek ,
578but this may still succeed if the chain ends
579in a FILE or file descriptor BIO.
580.Pp
581Source/sink BIOs return a 0 if they do not recognize the
582.Fn BIO_ctrl
583operation.
584.Sh SEE ALSO
585.Xr BIO_meth_new 3 ,
586.Xr BIO_new 3
587.Sh HISTORY
588.Fn BIO_ctrl ,
589.Fn BIO_reset ,
590.Fn BIO_flush ,
591.Fn BIO_eof ,
592.Fn BIO_set_close ,
593.Fn BIO_get_close ,
594and
595.Fn BIO_pending
596first appeared in SSLeay 0.6.0.
597.Fn BIO_wpending
598first appeared in SSLeay 0.8.1.
599.Fn BIO_ptr_ctrl ,
600.Fn BIO_int_ctrl ,
601.Fn BIO_get_info_callback
602and
603.Fn BIO_set_info_callback
604first appeared in SSLeay 0.9.0.
605All these functions have been available since
606.Ox 2.4 .
607.Pp
608.Fn BIO_seek
609and
610.Fn BIO_tell
611first appeared in SSLeay 0.9.1.
612.Fn BIO_ctrl_pending
613and
614.Fn BIO_ctrl_wpending
615first appeared in OpenSSL 0.9.4.
616These functions have been available since
617.Ox 2.6 .
618.Pp
619.Fn BIO_callback_ctrl
620first appeared in OpenSSL 0.9.5 and has been available since
621.Ox 2.7 .
622.Pp
623.Fn bio_info_cb
624first appeared with a more complicated prototype in OpenSSL 0.9.6
625and has been available since
626.Ox 2.9 .
627.Pp
628.Fn BIO_info_cb
629first appeared in OpenSSL 1.1.0h and has been available since
630.Ox 6.3 .
631.Sh BUGS
632Some of the return values are ambiguous and care should be taken.
633In particular a return value of 0 can be returned if an operation
634is not supported, if an error occurred, if EOF has not been reached
635and in the case of
636.Fn BIO_seek
637on a file BIO for a successful operation.
diff --git a/src/lib/libcrypto/man/BIO_dump.3 b/src/lib/libcrypto/man/BIO_dump.3
deleted file mode 100644
index 8817f0c4ca..0000000000
--- a/src/lib/libcrypto/man/BIO_dump.3
+++ /dev/null
@@ -1,128 +0,0 @@
1.\" $OpenBSD: BIO_dump.3,v 1.4 2022/12/20 15:34:03 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 20 2022 $
18.Dt BIO_DUMP 3
19.Os
20.Sh NAME
21.Nm BIO_dump ,
22.Nm BIO_dump_indent ,
23.Nm BIO_dump_fp ,
24.Nm BIO_dump_indent_fp
25.\" intentionally undocumented because nothing uses these two functions:
26.\" .Nm BIO_dump_cb
27.\" .Nm BIO_dump_indent_cb
28.Nd hexadecimal printout of arbitrary byte arrays
29.Sh SYNOPSIS
30.In openssl/bio.h
31.Ft int
32.Fo BIO_dump
33.Fa "BIO *b"
34.Fa "const char *s"
35.Fa "int len"
36.Fc
37.Ft int
38.Fo BIO_dump_indent
39.Fa "BIO *b"
40.Fa "const char *s"
41.Fa "int len"
42.Fa "int indent"
43.Fc
44.Ft int
45.Fo BIO_dump_fp
46.Fa "FILE *fp"
47.Fa "const char *s"
48.Fa "int len"
49.Fc
50.Ft int
51.Fo BIO_dump_indent_fp
52.Fa "FILE *fp"
53.Fa "const char *s"
54.Fa "int len"
55.Fa "int indent"
56.Fc
57.Sh DESCRIPTION
58.Fn BIO_dump
59prints
60.Fa len
61bytes starting at
62.Fa s
63to
64.Fa bio
65in hexadecimal format.
66.Pp
67The first column of output contains the index, in the byte array starting at
68.Fa s ,
69of the first byte shown on the respective output line, expressed as a
70four-digit hexadecimal number starting at 0000, followed by a dash.
71After the dash, sixteen bytes of data are printed as two-digit
72hexadecimal numbers, respecting the order in which they appear in
73the array
74.Fa s .
75Another dash is printed after the eighth column.
76.Pp
77To the right of the hexadecimal representation of the bytes,
78the same bytes are printed again, this time as ASCII characters.
79Non-printable ASCII characters are replaced with dots.
80.Pp
81Trailing space characters and NUL bytes are omitted from the main table.
82If there are any, an additional line is printed, consisting of the
83.Fa len
84argument as a four-digit hexadecimal number, a dash, and the fixed string
85.Qq <SPACES/NULS> .
86.Pp
87.Fn BIO_dump_indent
88is similar except that
89.Fa indent
90space characters are prepended to each output line.
91If
92.Fa indent
93is 7 or more, the number of data columns is reduced such that the
94total width of the output does not exceed 79 characters per line.
95.Pp
96.Fn BIO_dump_fp
97and
98.Fn BIO_dump_indent_fp
99are similar except that
100.Xr fwrite 3
101is used instead of
102.Xr BIO_write 3 .
103.Sh RETURN VALUES
104On success these functions return the total number of bytes written by
105.Xr BIO_write 3
106or
107.Xr fwrite 3 .
108If a failure occurs at any point when writing, these
109functions will stop after having potentially written out partial results,
110and return -1.
111.Sh SEE ALSO
112.Xr hexdump 1 ,
113.Xr BIO_new 3 ,
114.Xr BIO_write 3
115.Sh HISTORY
116.Fn BIO_dump
117first appeared in SSLeay 0.6.5 and has been available since
118.Ox 2.4 .
119.Pp
120.Fn BIO_dump_indent
121first appeared in OpenSSL 0.9.6 and has been available since
122.Ox 2.9 .
123.Pp
124.Fn BIO_dump_fp
125and
126.Fn BIO_dump_indent_fp
127first appeared in OpenSSL 0.9.8 and have been available since
128.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/BIO_dup_chain.3 b/src/lib/libcrypto/man/BIO_dup_chain.3
deleted file mode 100644
index 5c5e8c6533..0000000000
--- a/src/lib/libcrypto/man/BIO_dup_chain.3
+++ /dev/null
@@ -1,141 +0,0 @@
1.\" $OpenBSD: BIO_dup_chain.3,v 1.2 2023/04/09 06:27:52 jsg Exp $
2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: April 9 2023 $
18.Dt BIO_DUP_CHAIN 3
19.Os
20.Sh NAME
21.Nm BIO_dup_chain ,
22.Nm BIO_dup_state
23.Nd copy a BIO chain
24.Sh SYNOPSIS
25.In openssl/bio.h
26.Ft BIO *
27.Fn BIO_dup_chain "BIO *b"
28.Ft long
29.Fn BIO_dup_state "BIO *b" "BIO *new_bio"
30.Sh DESCRIPTION
31.Fn BIO_dup_chain
32copies the chain starting at
33.Fa b
34by iteratively copying
35.Fa b
36and all the BIOs following it
37and joining the copies in the same order as in the original chain.
38The copying operation is neither a deep copy nor a shallow copy.
39.Pp
40Some parts of the state of each BIO are copied,
41in particular with respect to the values returned by
42.Xr BIO_get_init 3 ,
43.Xr BIO_test_flags 3 ,
44and
45.Xr BIO_get_shutdown 3 .
46.\" XXX new_bio->num = bio->num;
47Other parts of the state of the BIOs are not copied
48but instead initialized to 0,
49in particular with respect to the values returned by
50.Xr BIO_number_read 3 ,
51.Xr BIO_number_written 3 ,
52and
53.Xr BIO_get_retry_reason 3 .
54The custom data pointer that can be used by custom BIO types
55and that can be retrieved with
56.Xr BIO_get_data 3
57is set to
58.Dv NULL
59in the copied BIO objects rather than copied.
60The reference count of each BIO in the copied chain is set to 1.
61.Pp
62For each BIO in the chain, copying the data that was set with
63.Xr BIO_set_ex_data 3
64is attempted, which may involve calling application-defined
65callback functions.
66.Pp
67The following pointers are copied
68rather than creating deep copies of the objects pointed to:
69.Bl -bullet
70.It
71The
72.Fa type
73pointer used for creating each BIO with
74.Xr BIO_new 3 ,
75implying that functions like
76.Xr BIO_method_name 3
77return pointers to the same strings for the BIOs in the copied chain,
78and that these strings are not copied.
79.It
80All function pointers, in particular those installed with
81.Xr BIO_set_callback_ex 3
82and
83.Xr BIO_get_callback_ex 3 .
84.It
85The pointer installed with
86.Xr BIO_set_callback_arg 3 ,
87which implies that for BIOs using
88.Xr BIO_debug_callback 3 ,
89those in the copied chain use the same BIOs for debugging output
90as the corresponding ones in the original chain,
91and none of the debugging output BIOs are copied.
92.El
93.Pp
94.Fn BIO_dup_state
95is a macro that calls
96.Xr BIO_ctrl 3
97with a
98.Fa cmd
99argument of
100.Dv BIO_CTRL_DUP .
101It is automatically called for each BIO during
102.Fn BIO_dup_chain
103after the copied BIO is initialized and data copied into it,
104but before the data set with
105.Xr BIO_set_ex_data 3
106is copied into the new BIO and before it is linked into the new chain.
107.Pp
108This control operation may modify the operation of
109.Fn BIO_dup_chain
110for particular types of BIOs contained in the chain,
111for example initializing or copying additional data.
112For BIO types provided by the library, such additional effects
113are documented in the respective manual pages, in particular in
114.Xr BIO_f_buffer 3 ,
115.Xr BIO_f_cipher 3 ,
116.Xr BIO_f_md 3 ,
117.Xr BIO_f_ssl 3 ,
118.Xr BIO_s_bio 3 ,
119and
120.Xr BIO_s_connect 3 .
121.Sh RETURN VALUES
122.Fn BIO_dup_chain
123returns a pointer to the newly allocated copy of the BIO
124.Fa b
125on success or
126.Dv NULL
127on failure .
128.Pp
129.Fn BIO_dup_state
130returns 1 on success or a value less than or equal to zero on failure.
131.Sh SEE ALSO
132.Xr BIO_get_data 3 ,
133.Xr BIO_new 3 ,
134.Xr BIO_next 3 ,
135.Xr BIO_push 3
136.Sh HISTORY
137.Fn BIO_dup_chain
138and
139.Fn BIO_dup_state
140first appeared in SSLeay 0.8.0 and have been available since
141.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BIO_f_base64.3 b/src/lib/libcrypto/man/BIO_f_base64.3
deleted file mode 100644
index e4589de035..0000000000
--- a/src/lib/libcrypto/man/BIO_f_base64.3
+++ /dev/null
@@ -1,148 +0,0 @@
1.\" $OpenBSD: BIO_f_base64.3,v 1.15 2023/09/11 04:00:40 jsg Exp $
2.\" OpenSSL fc1d88f0 Wed Jul 2 22:42:40 2014 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000, 2003, 2005, 2014 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: September 11 2023 $
53.Dt BIO_F_BASE64 3
54.Os
55.Sh NAME
56.Nm BIO_f_base64
57.\" .Nm EVP_ENCODE_LENGTH and
58.\" .Nm EVP_DECODE_LENGTH are intentionally undocumented
59.\" because they are internal implementation details of BIO_f_base64(3)
60.\" and practically unused outside evp/bio_b64.c.
61.Nd base64 BIO filter
62.Sh SYNOPSIS
63.In openssl/bio.h
64.In openssl/evp.h
65.Ft const BIO_METHOD *
66.Fo BIO_f_base64
67.Fa void
68.Fc
69.Sh DESCRIPTION
70.Fn BIO_f_base64
71returns the base64 BIO method.
72This is a filter BIO that base64 encodes any data written through it
73and decodes any data read through it.
74.Pp
75Base64 BIOs do not support
76.Xr BIO_gets 3
77or
78.Xr BIO_puts 3 .
79.Pp
80.Xr BIO_flush 3
81on a base64 BIO that is being written through
82is used to signal that no more data is to be encoded:
83this is used to flush the final block through the BIO.
84.Pp
85To encode the data all on one line and to expect the data to be all
86on one line, initialize the base64 BIO as follows:
87.Bd -literal -offset indent
88BIO *b64 = BIO_new(BIO_f_base64());
89BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
90.Ed
91.Sh RETURN VALUES
92.Fn BIO_f_base64
93returns the base64 BIO method.
94.Pp
95When called on a base64 BIO object,
96.Xr BIO_method_type 3
97returns the constant
98.Dv BIO_TYPE_BASE64
99and
100.Xr BIO_method_name 3
101returns a pointer to the static string
102.Qq base64 encoding .
103.Sh EXAMPLES
104Base64 encode the string "hello, world\en"
105and write the result to standard output:
106.Bd -literal -offset indent
107BIO *bio, *b64;
108char message[] = "hello, world\en";
109
110b64 = BIO_new(BIO_f_base64());
111bio = BIO_new_fp(stdout, BIO_NOCLOSE);
112BIO_push(b64, bio);
113BIO_write(b64, message, strlen(message));
114BIO_flush(b64);
115
116BIO_free_all(b64);
117.Ed
118.Pp
119Read Base64-encoded data from standard input
120and write the decoded data to standard output:
121.Bd -literal -offset indent
122BIO *bio, *b64, *bio_out;
123char inbuf[512];
124int inlen;
125
126b64 = BIO_new(BIO_f_base64());
127bio = BIO_new_fp(stdin, BIO_NOCLOSE);
128bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
129BIO_push(b64, bio);
130while((inlen = BIO_read(b64, inbuf, 512)) > 0)
131 BIO_write(bio_out, inbuf, inlen);
132
133BIO_flush(bio_out);
134BIO_free_all(b64);
135.Ed
136.Sh SEE ALSO
137.Xr BIO_new 3 ,
138.Xr EVP_EncodeInit 3
139.Sh HISTORY
140.Fn BIO_f_base64
141first appeared in SSLeay 0.6.5 and has been available since
142.Ox 2.4 .
143.Sh BUGS
144The ambiguity of EOF in base64-encoded data can cause additional
145data following the base64-encoded block to be misinterpreted.
146.Pp
147There should be some way of specifying a test that the BIO can perform
148to reliably determine EOF (for example a MIME boundary).
diff --git a/src/lib/libcrypto/man/BIO_f_buffer.3 b/src/lib/libcrypto/man/BIO_f_buffer.3
deleted file mode 100644
index a3012c5c5d..0000000000
--- a/src/lib/libcrypto/man/BIO_f_buffer.3
+++ /dev/null
@@ -1,262 +0,0 @@
1.\" $OpenBSD: BIO_f_buffer.3,v 1.17 2023/04/29 12:22:08 schwarze Exp $
2.\" full merge up to OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2000, 2010, 2015, 2016 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: April 29 2023 $
70.Dt BIO_F_BUFFER 3
71.Os
72.Sh NAME
73.Nm BIO_f_buffer ,
74.Nm BIO_get_buffer_num_lines ,
75.Nm BIO_set_read_buffer_size ,
76.Nm BIO_set_write_buffer_size ,
77.Nm BIO_set_buffer_size ,
78.Nm BIO_set_buffer_read_data
79.\" .Nm BIO_buffer_get_num_lines and
80.\" .Nm BIO_CTRL_GET are intentionally undocumented.
81.\" Contrary to what bio.h says, they do not *not* get some "IO type",
82.\" whatever that is supposed to be, but are NOOPs, and nothing uses them.
83.Nd buffering BIO
84.Sh SYNOPSIS
85.In openssl/bio.h
86.Ft const BIO_METHOD *
87.Fo BIO_f_buffer
88.Fa void
89.Fc
90.Ft long
91.Fo BIO_get_buffer_num_lines
92.Fa "BIO *b"
93.Fc
94.Ft long
95.Fo BIO_set_read_buffer_size
96.Fa "BIO *b"
97.Fa "long size"
98.Fc
99.Ft long
100.Fo BIO_set_write_buffer_size
101.Fa "BIO *b"
102.Fa "long size"
103.Fc
104.Ft long
105.Fo BIO_set_buffer_size
106.Fa "BIO *b"
107.Fa "long size"
108.Fc
109.Ft long
110.Fo BIO_set_buffer_read_data
111.Fa "BIO *b"
112.Fa "void *buf"
113.Fa "long num"
114.Fc
115.Sh DESCRIPTION
116.Fn BIO_f_buffer
117returns the buffering BIO method.
118.Pp
119Data written to a buffering BIO is buffered and periodically written
120to the next BIO in the chain.
121Data read from a buffering BIO comes from an internal buffer
122which is filled from the next BIO in the chain.
123Both
124.Xr BIO_gets 3
125and
126.Xr BIO_puts 3
127are supported.
128.Pp
129Calling
130.Xr BIO_reset 3
131on a buffering BIO clears any buffered data.
132.Pp
133.Fn BIO_get_buffer_num_lines
134returns the number of lines currently buffered.
135.Pp
136.Fn BIO_set_read_buffer_size ,
137.Fn BIO_set_write_buffer_size ,
138and
139.Fn BIO_set_buffer_size
140set the read, write or both read and write buffer sizes to
141.Fa size .
142The initial buffer size is
143.Dv DEFAULT_BUFFER_SIZE ,
144currently 4096.
145Any attempt to reduce the buffer size below
146.Dv DEFAULT_BUFFER_SIZE
147is ignored.
148Any buffered data is cleared when the buffer is resized.
149.Pp
150.Fn BIO_set_buffer_read_data
151clears the read buffer and fills it with
152.Fa num
153bytes of
154.Fa buf .
155If
156.Fa num
157is larger than the current buffer size, the buffer is expanded.
158.Pp
159Buffering BIOs implement
160.Xr BIO_gets 3
161by using
162.Xr BIO_read 3
163operations on the next BIO in the chain.
164By prepending a buffering BIO to a chain
165it is therefore possible to provide the functionality of
166.Xr BIO_gets 3
167if the following BIOs do not support it (for example SSL BIOs).
168.Pp
169Data is only written to the next BIO in the chain
170when the write buffer fills or when
171.Xr BIO_flush 3
172is called.
173It is therefore important to call
174.Xr BIO_flush 3
175whenever any pending data should be written
176such as when removing a buffering BIO using
177.Xr BIO_pop 3 .
178.Xr BIO_flush 3
179may need to be retried if the ultimate source/sink BIO is non-blocking.
180.Pp
181When a chain containing a buffering BIO is copied with
182.Xr BIO_dup_chain 3 ,
183.Fn BIO_set_read_buffer_size
184and
185.Fn BIO_set_write_buffer_size
186are called internally to automatically copy both buffer sizes from the
187original BIO object to the new one.
188.Pp
189.Xr BIO_ctrl 3
190.Fa cmd
191arguments correspond to macros as follows:
192.Bl -column BIO_C_GET_BUFF_NUM_LINES BIO_get_buffer_num_lines() -offset 3n
193.It Fa cmd No constant Ta corresponding macro
194.It Dv BIO_C_GET_BUFF_NUM_LINES Ta Fn BIO_get_buffer_num_lines
195.It Dv BIO_C_SET_BUFF_READ_DATA Ta Fn BIO_set_buffer_read_data
196.It Dv BIO_C_SET_BUFF_SIZE Ta Fn BIO_set_buffer_size
197.It Dv BIO_CTRL_FLUSH Ta Xr BIO_flush 3
198.It Dv BIO_CTRL_PENDING Ta Xr BIO_pending 3
199.It Dv BIO_CTRL_RESET Ta Xr BIO_reset 3
200.It Dv BIO_CTRL_WPENDING Ta Xr BIO_wpending 3
201.El
202.Pp
203The
204.Fa cmd
205constant
206.Dv BIO_C_SET_BUFF_SIZE
207is special.
208It is also used for
209.Xr BIO_int_ctrl 3
210with the following
211.Fa iarg
212arguments:
213.Bl -column BIO_C_SET_BUFF_SIZE iarg BIO_set_write_buffer_size() -offset 3n
214.It Fa cmd No constant Ta Fa iarg Ta corresponding macro
215.It Dv BIO_C_SET_BUFF_SIZE Ta 0 Ta Fn BIO_set_read_buffer_size
216.It Ta 1 Ta Fn BIO_set_write_buffer_size
217.El
218.Sh RETURN VALUES
219.Fn BIO_f_buffer
220returns the buffering BIO method.
221.Pp
222When called on a buffering BIO object,
223.Xr BIO_method_type 3
224returns the constant
225.Dv BIO_TYPE_BUFFER
226and
227.Xr BIO_method_name 3
228returns a pointer to the static string
229.Qq buffer .
230.Pp
231.Fn BIO_get_buffer_num_lines
232returns the number of lines buffered (may be 0).
233.Pp
234.Fn BIO_set_read_buffer_size ,
235.Fn BIO_set_write_buffer_size ,
236and
237.Fn BIO_set_buffer_size
238return 1 if the buffer was successfully resized or 0 for failure.
239.Pp
240.Fn BIO_set_buffer_read_data
241returns 1 if the data was set correctly or 0 if there was an error.
242.Sh SEE ALSO
243.Xr BIO_ctrl 3 ,
244.Xr BIO_flush 3 ,
245.Xr BIO_new 3 ,
246.Xr BIO_pop 3 ,
247.Xr BIO_reset 3
248.Sh HISTORY
249.Fn BIO_f_buffer
250first appeared in SSLeay 0.6.0.
251.Fn BIO_get_buffer_num_lines
252and
253.Fn BIO_set_buffer_size
254first appeared in SSLeay 0.6.5.
255.Fn BIO_set_read_buffer_size
256and
257.Fn BIO_set_write_buffer_size
258first appeared in SSLeay 0.8.0.
259.Fn BIO_set_buffer_read_data
260first appeared in SSLeay 0.9.0.
261All these functions have been available since
262.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BIO_f_cipher.3 b/src/lib/libcrypto/man/BIO_f_cipher.3
deleted file mode 100644
index c5d00c6981..0000000000
--- a/src/lib/libcrypto/man/BIO_f_cipher.3
+++ /dev/null
@@ -1,209 +0,0 @@
1.\" $OpenBSD: BIO_f_cipher.3,v 1.16 2023/04/29 12:01:53 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000, 2003, 2015, 2016 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: April 29 2023 $
53.Dt BIO_F_CIPHER 3
54.Os
55.Sh NAME
56.Nm BIO_f_cipher ,
57.Nm BIO_set_cipher ,
58.Nm BIO_get_cipher_status ,
59.Nm BIO_get_cipher_ctx
60.\" .Nm BIO_CTRL_SET is intentionally undocumented because it has no effect.
61.Nd cipher BIO filter
62.Sh SYNOPSIS
63.In openssl/bio.h
64.In openssl/evp.h
65.Ft const BIO_METHOD *
66.Fo BIO_f_cipher
67.Fa void
68.Fc
69.Ft int
70.Fo BIO_set_cipher
71.Fa "BIO *b"
72.Fa "const EVP_CIPHER *cipher"
73.Fa "unsigned char *key"
74.Fa "unsigned char *iv"
75.Fa "int enc"
76.Fc
77.Ft long
78.Fo BIO_get_cipher_status
79.Fa "BIO *b"
80.Fc
81.Ft long
82.Fo BIO_get_cipher_ctx
83.Fa "BIO *b"
84.Fa "EVP_CIPHER_CTX **pctx"
85.Fc
86.Sh DESCRIPTION
87.Fn BIO_f_cipher
88returns the cipher BIO method.
89This is a filter BIO that encrypts any data written through it,
90and decrypts any data read from it.
91It is a BIO wrapper for the cipher routines
92.Xr EVP_CipherInit 3 ,
93.Xr EVP_CipherUpdate 3 ,
94and
95.Xr EVP_CipherFinal 3 .
96.Pp
97Cipher BIOs do not support
98.Xr BIO_gets 3
99or
100.Xr BIO_puts 3 .
101.Pp
102.Xr BIO_flush 3
103on an encryption BIO that is being written through
104is used to signal that no more data is to be encrypted:
105this is used to flush and possibly pad the final block through the BIO.
106.Pp
107.Fn BIO_set_cipher
108sets the cipher of BIO
109.Fa b
110to
111.Fa cipher
112using key
113.Fa key
114and IV
115.Fa iv .
116.Fa enc
117should be set to 1 for encryption and zero for decryption.
118.Pp
119When reading from an encryption BIO, the final block is automatically
120decrypted and checked when EOF is detected.
121.Fn BIO_get_cipher_status
122is a
123.Xr BIO_ctrl 3
124macro which can be called to determine
125whether the decryption operation was successful.
126.Pp
127.Fn BIO_get_cipher_ctx
128is a
129.Xr BIO_ctrl 3
130macro which retrieves the internal BIO cipher context.
131The retrieved context can be used in conjunction
132with the standard cipher routines to set it up.
133This is useful when
134.Fn BIO_set_cipher
135is not flexible enough for the applications needs.
136.Pp
137When a chain containing a cipher BIO is copied with
138.Xr BIO_dup_chain 3 ,
139the cipher context is automatically copied from the existing BIO object
140to the new one and the init flag that can be retrieved with
141.Xr BIO_get_init 3
142is set to 1.
143.Pp
144When encrypting,
145.Xr BIO_flush 3
146must be called to flush the final block through the BIO.
147If it is not, then the final block will fail a subsequent decrypt.
148.Pp
149When decrypting, an error on the final block is signalled
150by a zero return value from the read operation.
151A successful decrypt followed by EOF
152will also return zero for the final read.
153.Fn BIO_get_cipher_status
154should be called to determine if the decrypt was successful.
155.Pp
156As always, if
157.Xr BIO_gets 3
158or
159.Xr BIO_puts 3
160support is needed, then it can be achieved
161by preceding the cipher BIO with a buffering BIO.
162.Pp
163.Xr BIO_ctrl 3
164.Fa cmd
165arguments correspond to macros as follows:
166.Bl -column BIO_C_GET_CIPHER_STATUS BIO_get_cipher_status() -offset 3n
167.It Fa cmd No constant Ta corresponding macro
168.It Dv BIO_C_GET_CIPHER_CTX Ta Fn BIO_get_cipher_ctx
169.It Dv BIO_C_GET_CIPHER_STATUS Ta Fn BIO_get_cipher_status
170.It Dv BIO_CTRL_FLUSH Ta Xr BIO_flush 3
171.It Dv BIO_CTRL_PENDING Ta Xr BIO_pending 3
172.It Dv BIO_CTRL_RESET Ta Xr BIO_reset 3
173.It Dv BIO_CTRL_WPENDING Ta Xr BIO_wpending 3
174.El
175.Sh RETURN VALUES
176.Fn BIO_f_cipher
177returns the cipher BIO method.
178.Pp
179When called on a cipher BIO object,
180.Xr BIO_method_type 3
181returns the constant
182.Dv BIO_TYPE_CIPHER
183and
184.Xr BIO_method_name 3
185returns a pointer to the static string
186.Qq cipher .
187.Pp
188.Fn BIO_set_cipher
189returns 1 on success and 0 on error.
190.Pp
191.Fn BIO_get_cipher_status
192returns 1 for a successful decrypt and 0 for failure.
193.Pp
194.Fn BIO_get_cipher_ctx
195currently always returns 1.
196.Sh SEE ALSO
197.Xr BIO_new 3 ,
198.Xr EVP_EncryptInit 3
199.Sh HISTORY
200.Fn BIO_f_cipher ,
201.Fn BIO_set_cipher ,
202and
203.Fn BIO_get_cipher_status
204first appeared in SSLeay 0.6.5 and have been available since
205.Ox 2.4 .
206.Pp
207.Fn BIO_get_cipher_ctx
208first appeared in SSLeay 0.9.1 and has been available since
209.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/BIO_f_md.3 b/src/lib/libcrypto/man/BIO_f_md.3
deleted file mode 100644
index 279aabc980..0000000000
--- a/src/lib/libcrypto/man/BIO_f_md.3
+++ /dev/null
@@ -1,366 +0,0 @@
1.\" $OpenBSD: BIO_f_md.3,v 1.15 2023/04/28 16:20:01 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2022, 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2000, 2006, 2009, 2016 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: April 28 2023 $
70.Dt BIO_F_MD 3
71.Os
72.Sh NAME
73.Nm BIO_f_md ,
74.Nm BIO_set_md ,
75.Nm BIO_get_md ,
76.Nm BIO_get_md_ctx ,
77.Nm BIO_set_md_ctx
78.Nd message digest BIO filter
79.Sh SYNOPSIS
80.In openssl/bio.h
81.In openssl/evp.h
82.Ft const BIO_METHOD *
83.Fo BIO_f_md
84.Fa void
85.Fc
86.Ft long
87.Fo BIO_set_md
88.Fa "BIO *b"
89.Fa "EVP_MD *md"
90.Fc
91.Ft long
92.Fo BIO_get_md
93.Fa "BIO *b"
94.Fa "EVP_MD **mdp"
95.Fc
96.Ft long
97.Fo BIO_get_md_ctx
98.Fa "BIO *b"
99.Fa "EVP_MD_CTX **mdcp"
100.Fc
101.Ft long
102.Fo BIO_set_md_ctx
103.Fa "BIO *b"
104.Fa "EVP_MD_CTX *mdc"
105.Fc
106.Sh DESCRIPTION
107.Fn BIO_f_md
108returns the message digest BIO method.
109This is a filter BIO that digests any data passed through it.
110It is a BIO wrapper for the digest routines
111.Xr EVP_DigestInit 3 ,
112.Xr EVP_DigestUpdate 3 ,
113and
114.Xr EVP_DigestFinal 3 .
115.Pp
116.Fn BIO_set_md
117sets the message digest of
118.Fa b
119to
120.Fa md
121and initializes it using
122.Xr EVP_DigestInit_ex 3 .
123Calling this function is required before any data is passed through
124.Fa b .
125.Pp
126.Fn BIO_get_md
127places a pointer to the digest method of
128.Fa b
129into
130.Pf * Fa mdp .
131.Pp
132Any data written or read through a digest BIO using
133.Xr BIO_read 3
134and
135.Xr BIO_write 3
136is digested.
137.Pp
138.Xr BIO_gets 3 ,
139if its
140.Sy size
141parameter is large enough,
142finishes the digest calculation and returns the digest value.
143.Xr BIO_puts 3
144is
145not supported.
146If an application needs to call
147.Xr BIO_gets 3
148or
149.Xr BIO_puts 3
150through a chain containing digest BIOs,
151this can be done by prepending a buffering BIO.
152.Pp
153After the digest has been retrieved from a digest BIO, call
154.Xr BIO_reset 3
155to reinitialize it and any BIOs following it in its chain
156before passing any more data through it.
157If no subsequent BIOs require reinitialization,
158.Fn BIO_set_md
159can be used instead of
160.Xr BIO_reset 3 .
161.Pp
162.Fn BIO_get_md_ctx
163places a pointer to the digest context of
164.Fa b
165into
166.Pf * Fa mdcp
167and marks the BIO as initialized without actually initializing it.
168Unless
169.Fn BIO_set_md
170was already called on
171.Fa b ,
172the caller becomes responsible for initializing the digest context with
173.Xr EVP_DigestInit_ex 3 .
174.Pp
175The context returned by
176.Fn BIO_get_md_ctx
177can be used in calls to
178.Xr EVP_DigestFinal 3
179and also in the signature routines
180.Xr EVP_SignFinal 3
181and
182.Xr EVP_VerifyFinal 3 .
183.Pp
184The context returned by
185.Fn BIO_get_md_ctx
186is an internal context structure.
187Changes made to this context will affect the digest BIO itself, and
188the context pointer will become invalid when the digest BIO is freed.
189.Pp
190.Fn BIO_set_md_ctx
191replaces the digest context of
192.Fa b
193with
194.Fa mdc .
195Calling this function is usually not necessary
196because creating a digest BIO with
197.Xr BIO_new 3
198automatically creates a digest context and stores it internally.
199Before calling
200.Fn BIO_set_md_ctx ,
201the caller has to retrieve the old context using
202.Fn BIO_get_md_ctx ,
203and the caller also becomes responsible for calling
204.Xr EVP_MD_CTX_free 3
205on the old context.
206Unless
207.Fa mdc
208is already initialized, the caller needs to initialize it after calling
209.Fn BIO_set_md_ctx
210using either
211.Fn BIO_set_md
212or
213.Xr EVP_DigestInit 3 .
214.Pp
215When a chain containing a message digest BIO is copied with
216.Xr BIO_dup_chain 3 ,
217.Xr EVP_MD_CTX_copy_ex 3
218is called internally to automatically copy the message digest context
219from the existing BIO object to the new one,
220and the init flag that can be retrieved with
221.Xr BIO_get_init 3
222is set to 1.
223.Pp
224.Xr BIO_ctrl 3
225.Fa cmd
226arguments correspond to macros as follows:
227.Bl -column BIO_C_GET_MD_CTX "corresponding macro" -offset 3n
228.It Fa cmd No constant Ta corresponding macro
229.It Dv BIO_C_GET_MD Ta Fn BIO_get_md
230.It Dv BIO_C_GET_MD_CTX Ta Fn BIO_get_md_ctx
231.It Dv BIO_C_SET_MD Ta Fn BIO_set_md
232.It Dv BIO_C_SET_MD_CTX Ta Fn BIO_set_md_ctx
233.It Dv BIO_CTRL_RESET Ta Xr BIO_reset 3
234.El
235.Sh RETURN VALUES
236.Fn BIO_f_md
237returns the digest BIO method.
238.Pp
239When called on a message digest BIO object,
240.Xr BIO_method_type 3
241returns the constant
242.Dv BIO_TYPE_MD
243and
244.Xr BIO_method_name 3
245returns a pointer to the static string
246.Qq message digest .
247.Pp
248.Fn BIO_set_md
249returns 1 on success or 0 if
250.Xr EVP_DigestInit_ex 3
251fails.
252.Pp
253.Fn BIO_get_md
254and
255.Fn BIO_set_md_ctx
256return 1 on success or 0 if
257.Fa b
258is not initialized.
259.Pp
260.Fn BIO_get_md_ctx
261returns 1 on success or 0 on failure,
262but the current implementation cannot actually fail.
263.Sh EXAMPLES
264The following example creates a BIO chain containing a SHA-1 and MD5
265digest BIO and passes the string "Hello World" through it.
266Error checking has been omitted for clarity.
267.Bd -literal -offset 2n
268BIO *bio, *mdtmp;
269const char message[] = "Hello World";
270bio = BIO_new(BIO_s_null());
271mdtmp = BIO_new(BIO_f_md());
272BIO_set_md(mdtmp, EVP_sha1());
273/*
274 * For BIO_push() we want to append the sink BIO
275 * and keep a note of the start of the chain.
276 */
277bio = BIO_push(mdtmp, bio);
278mdtmp = BIO_new(BIO_f_md());
279BIO_set_md(mdtmp, EVP_md5());
280bio = BIO_push(mdtmp, bio);
281/* Note: mdtmp can now be discarded */
282BIO_write(bio, message, strlen(message));
283.Ed
284.Pp
285The next example digests data by reading through a chain instead:
286.Bd -literal -offset 2n
287BIO *bio, *mdtmp;
288char buf[1024];
289int rdlen;
290
291bio = BIO_new_file(file, "rb");
292mdtmp = BIO_new(BIO_f_md());
293BIO_set_md(mdtmp, EVP_sha1());
294bio = BIO_push(mdtmp, bio);
295mdtmp = BIO_new(BIO_f_md());
296BIO_set_md(mdtmp, EVP_md5());
297bio = BIO_push(mdtmp, bio);
298do {
299 rdlen = BIO_read(bio, buf, sizeof(buf));
300 /* Might want to do something with the data here */
301} while (rdlen > 0);
302.Ed
303.Pp
304This next example retrieves the message digests from a BIO chain
305and outputs them.
306This could be used with the examples above.
307.Bd -literal -offset 2n
308BIO *mdtmp;
309unsigned char mdbuf[EVP_MAX_MD_SIZE];
310int mdlen;
311int i;
312
313mdtmp = bio; /* Assume bio has previously been set up */
314do {
315 EVP_MD *md;
316 mdtmp = BIO_find_type(mdtmp, BIO_TYPE_MD);
317 if (!mdtmp)
318 break;
319 BIO_get_md(mdtmp, &md);
320 printf("%s digest", OBJ_nid2sn(EVP_MD_type(md)));
321 mdlen = BIO_gets(mdtmp, mdbuf, EVP_MAX_MD_SIZE);
322 for(i = 0; i < mdlen; i++)
323 printf(":%02X", mdbuf[i]);
324 printf("\en");
325 mdtmp = BIO_next(mdtmp);
326} while(mdtmp);
327BIO_free_all(bio);
328.Ed
329.Sh SEE ALSO
330.Xr BIO_new 3 ,
331.Xr EVP_DigestInit 3
332.Sh HISTORY
333.Fn BIO_f_md ,
334.Fn BIO_set_md ,
335and
336.Fn BIO_get_md
337first appeared in SSLeay 0.6.0.
338.Fn BIO_get_md_ctx
339first appeared in SSLeay 0.8.1.
340These functions have been available since
341.Ox 2.4 .
342.Pp
343.Fn BIO_set_md_ctx
344first appeared in OpenSSL 0.9.7e and has been available since
345.Ox 3.8 .
346.Pp
347Before OpenSSL 1.0.0, the call to
348.Fn BIO_get_md_ctx
349would only work if the
350.Vt BIO
351had been initialized, for example by calling
352.Fn BIO_set_md .
353.Sh BUGS
354The lack of support for
355.Xr BIO_puts 3
356and the non-standard behaviour of
357.Xr BIO_gets 3
358could be regarded as anomalous.
359It could be argued that
360.Xr BIO_gets 3
361and
362.Xr BIO_puts 3
363should be passed to the next BIO in the chain and digest the data
364passed through and that digests should be retrieved using a separate
365.Xr BIO_ctrl 3
366call.
diff --git a/src/lib/libcrypto/man/BIO_f_null.3 b/src/lib/libcrypto/man/BIO_f_null.3
deleted file mode 100644
index 687d991b52..0000000000
--- a/src/lib/libcrypto/man/BIO_f_null.3
+++ /dev/null
@@ -1,99 +0,0 @@
1.\" $OpenBSD: BIO_f_null.3,v 1.12 2023/04/11 16:58:43 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: April 11 2023 $
52.Dt BIO_F_NULL 3
53.Os
54.Sh NAME
55.Nm BIO_f_null
56.\" .Nm BIO_f_nbio_test is intentionally undocumented
57.\" because it exposes absurd functionality that is unused
58.\" except in openssl(1) s_client/s_server -nbio_test.
59.Nd null filter
60.Sh SYNOPSIS
61.In openssl/bio.h
62.Ft const BIO_METHOD *
63.Fo BIO_f_null
64.Fa void
65.Fc
66.Sh DESCRIPTION
67.Fn BIO_f_null
68returns the null filter BIO method.
69This is a filter BIO that does nothing.
70As may be apparent, a null filter BIO is not particularly useful.
71.Pp
72All requests to a null filter BIO are passed through to the next BIO
73in the chain: this means that a BIO chain containing a null filter BIO
74behaves just as though the BIO was not there.
75.Pp
76A chain containing a null filter BIO cannot be copied with
77.Xr BIO_dup_chain 3 ,
78and any attempt to do so fails and returns
79.Dv NULL .
80.Sh RETURN VALUES
81.Fn BIO_f_null
82returns the null filter BIO method.
83.Pp
84When called on a null filter BIO object,
85.Xr BIO_method_type 3
86returns the constant
87.Dv BIO_TYPE_NULL_FILTER
88and
89.Xr BIO_method_name 3
90returns a pointer to the static string
91.Qq NULL filter ,
92not to be confused with a NUL string nor with a
93.Dv NULL pointer .
94.Sh SEE ALSO
95.Xr BIO_new 3
96.Sh HISTORY
97.Fn BIO_f_null
98first appeared in SSLeay 0.8.0 and has been available since
99.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BIO_find_type.3 b/src/lib/libcrypto/man/BIO_find_type.3
deleted file mode 100644
index 4a9eee7832..0000000000
--- a/src/lib/libcrypto/man/BIO_find_type.3
+++ /dev/null
@@ -1,271 +0,0 @@
1.\" $OpenBSD: BIO_find_type.3,v 1.12 2023/07/26 20:01:04 tb Exp $
2.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2021, 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2000, 2013, 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: July 26 2023 $
69.Dt BIO_FIND_TYPE 3
70.Os
71.Sh NAME
72.Nm BIO_find_type ,
73.Nm BIO_next ,
74.Nm BIO_method_type ,
75.Nm BIO_method_name
76.Nd BIO chain traversal
77.Sh SYNOPSIS
78.In openssl/bio.h
79.Ft BIO *
80.Fo BIO_find_type
81.Fa "BIO *bio"
82.Fa "int type"
83.Fc
84.Ft BIO *
85.Fo BIO_next
86.Fa "BIO *bio"
87.Fc
88.Ft int
89.Fo BIO_method_type
90.Fa "const BIO *bio"
91.Fc
92.Ft const char *
93.Fo BIO_method_name
94.Fa "const BIO *bio"
95.Fc
96.Fd #define BIO_TYPE_NONE 0
97.Fd #define BIO_TYPE_START 128
98.Sh DESCRIPTION
99.Fn BIO_find_type
100searches for a BIO matching the given
101.Fa type
102in the chain starting at
103.Fa bio .
104If the least significant byte of the
105.Fa type
106argument is non-zero, only exact matches of the
107.Fa type
108are accepted.
109Otherwise, a match only requires that any of the bits set in the
110.Fa type
111argument is also set in the candidate BIO.
112.Pp
113Types with a least significant byte in the range from 0 to
114.Dv BIO_TYPE_START ,
115inclusive, are reserved for BIO types built into the library.
116Types with a least significant byte greater than
117.Dv BIO_TYPE_START
118are available for user-defined BIO types; see
119.Xr BIO_get_new_index 3
120for details.
121.Pp
122.Fn BIO_next
123returns the next BIO in the chain after
124.Fa bio .
125This function can be used to traverse all BIOs in a chain
126or in conjunction with
127.Fn BIO_find_type
128to find all BIOs of a certain type.
129.Pp
130.Fn BIO_method_type
131returns the type of the given
132.Fa bio .
133.Pp
134.Fn BIO_method_name
135returns an ASCII string representing the type of the
136.Fa bio .
137.Pp
138The following are the built-in source/sink BIO types
139that operate on file descriptors.
140They all have both of the bits
141.Dv BIO_TYPE_SOURCE_SINK
142and
143.Dv BIO_TYPE_DESCRIPTOR
144but not the bit
145.Dv BIO_TYPE_FILTER
146set in their type constant.
147.Bl -column BIO_TYPE_NULL_FILTER "datagram socket" BIO_s_datagram(3)
148.It Fa type No constant Ta Em name No string Ta Vt BIO_METHOD
149.It Dv BIO_TYPE_ACCEPT Ta socket accept Ta Xr BIO_s_accept 3
150.It Dv BIO_TYPE_CONNECT Ta socket connect Ta Xr BIO_s_connect 3
151.It Dv BIO_TYPE_DGRAM Ta datagram socket Ta Xr BIO_s_datagram 3
152.It Dv BIO_TYPE_FD Ta file descriptor Ta Xr BIO_s_fd 3
153.It Dv BIO_TYPE_SOCKET Ta socket Ta Xr BIO_s_socket 3
154.El
155.Pp
156The following are the built-in source/sink BIO types
157that do not directly operate on file descriptors.
158They all have the bit
159.Dv BIO_TYPE_SOURCE_SINK
160but not the bits
161.Dv BIO_TYPE_DESCRIPTOR
162and
163.Dv BIO_TYPE_FILTER
164set in their type constant.
165.Bl -column BIO_TYPE_NULL_FILTER "datagram socket" BIO_s_datagram(3)
166.It Fa type No constant Ta Em name No string Ta Vt BIO_METHOD
167.It Dv BIO_TYPE_BIO Ta BIO pair Ta Xr BIO_s_bio 3
168.It Dv BIO_TYPE_FILE Ta FILE pointer Ta Xr BIO_s_file 3
169.It Dv BIO_TYPE_MEM Ta memory buffer Ta Xr BIO_s_mem 3
170.It Dv BIO_TYPE_NULL Ta NULL Ta Xr BIO_s_null 3
171.El
172.Pp
173The following are the built-in filter BIO types.
174They all have the bit
175.Dv BIO_TYPE_FILTER
176but not the bits
177.Dv BIO_TYPE_SOURCE_SINK
178and
179.Dv BIO_TYPE_DESCRIPTOR
180set in their type constant.
181.Bl -column BIO_TYPE_NULL_FILTER "datagram socket" BIO_s_datagram(3)
182.It Fa type No constant Ta Em name No string Ta Vt BIO_METHOD
183.\" BIO_TYPE_ASN1 is intentionally undocumented because BIO_f_asn1 was
184.\" removed from the public API.
185.\" .It Dv BIO_TYPE_ASN1 Ta asn1 Ta Xr BIO_f_asn1 3
186.It Dv BIO_TYPE_BASE64 Ta base64 encoding Ta Xr BIO_f_base64 3
187.It Dv BIO_TYPE_BUFFER Ta buffer Ta Xr BIO_f_buffer 3
188.It Dv BIO_TYPE_CIPHER Ta cipher Ta Xr BIO_f_cipher 3
189.It Dv BIO_TYPE_MD Ta message digest Ta Xr BIO_f_md 3
190.It Dv BIO_TYPE_NULL_FILTER Ta NULL filter Ta Xr BIO_f_null 3
191.It Dv BIO_TYPE_SSL Ta ssl Ta Xr BIO_f_ssl 3
192.El
193.Pp
194The constants
195.Dv BIO_TYPE_BER ,
196.Dv BIO_TYPE_PROXY_CLIENT ,
197and
198.Dv BIO_TYPE_PROXY_SERVER
199do not correspond to any BIO types implemented by the library and are
200not intended to be used for application-defined types, either.
201The constants
202.Dv BIO_TYPE_COMP ,
203.Dv BIO_TYPE_LINEBUFFER ,
204and
205.Dv BIO_TYPE_NBIO_TEST
206corresponds to a deprecated BIO types that are intentionally undocumented.
207.Pp
208If a variable in an application program is intended
209to store a BIO type but temporarily does not refer to any BIO
210or refers to a BIO of an unknown type, setting the variable to
211.Dv BIO_TYPE_NONE
212is recommended.
213.Sh RETURN VALUES
214.Fn BIO_find_type
215returns the next matching BIO or
216.Dv NULL
217if
218.Fa bio
219is a
220.Dv NULL
221pointer or if no matching BIO is found.
222.Pp
223.Fn BIO_next
224returns the next BIO or
225.Dv NULL
226if
227.Fa bio
228is a
229.Dv NULL
230pointer or points to the last BIO in a chain.
231.Pp
232.Fn BIO_method_type
233returns one of the
234.Dv BIO_TYPE_*
235constants.
236.Pp
237.Fn BIO_method_name
238returns an internal pointer to a string.
239.Sh EXAMPLES
240Traverse a chain looking for digest BIOs:
241.Bd -literal -offset 2n
242BIO *btmp;
243
244btmp = in_bio; /* in_bio is the chain to search through */
245while (btmp != NULL) {
246 btmp = BIO_find_type(btmp, BIO_TYPE_MD);
247 if (btmp == NULL)
248 break; /* Not found */
249
250 /* btmp is a digest BIO, do something with it ... */
251 ...
252
253 btmp = BIO_next(btmp);
254}
255.Ed
256.Sh SEE ALSO
257.Xr BIO_meth_new 3 ,
258.Xr BIO_new 3
259.Sh HISTORY
260.Fn BIO_method_type
261and
262.Fn BIO_method_name
263first appeared in SSLeay 0.6.0.
264.Fn BIO_find_type
265first appeared in SSLeay 0.6.6.
266These functions have been available since
267.Ox 2.4 .
268.Pp
269.Fn BIO_next
270first appeared in OpenSSL 0.9.6 and has been available since
271.Ox 2.9 .
diff --git a/src/lib/libcrypto/man/BIO_get_data.3 b/src/lib/libcrypto/man/BIO_get_data.3
deleted file mode 100644
index 63750ac37b..0000000000
--- a/src/lib/libcrypto/man/BIO_get_data.3
+++ /dev/null
@@ -1,406 +0,0 @@
1.\" $OpenBSD: BIO_get_data.3,v 1.8 2023/11/16 20:27:43 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018, 2022 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Matt Caswell <matt@openssl.org>.
22.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: November 16 2023 $
69.Dt BIO_GET_DATA 3
70.Os
71.Sh NAME
72.Nm BIO_set_data ,
73.Nm BIO_get_data ,
74.Nm BIO_set_flags ,
75.Nm BIO_clear_flags ,
76.Nm BIO_test_flags ,
77.Nm BIO_get_flags ,
78.Nm BIO_set_retry_read ,
79.Nm BIO_set_retry_write ,
80.Nm BIO_set_retry_special ,
81.Nm BIO_clear_retry_flags ,
82.Nm BIO_get_retry_flags ,
83.Nm BIO_copy_next_retry ,
84.Nm BIO_set_init ,
85.Nm BIO_get_init ,
86.Nm BIO_set_shutdown ,
87.Nm BIO_get_shutdown
88.Nd manage BIO state information
89.Sh SYNOPSIS
90.In openssl/bio.h
91.Ft void
92.Fo BIO_set_data
93.Fa "BIO *a"
94.Fa "void *ptr"
95.Fc
96.Ft void *
97.Fo BIO_get_data
98.Fa "BIO *a"
99.Fc
100.Ft void
101.Fo BIO_set_flags
102.Fa "BIO *a"
103.Fa "int flags"
104.Fc
105.Ft void
106.Fo BIO_clear_flags
107.Fa "BIO *a"
108.Fa "int flags"
109.Fc
110.Ft int
111.Fo BIO_test_flags
112.Fa "const BIO *a"
113.Fa "int flags"
114.Fc
115.Ft int
116.Fo BIO_get_flags
117.Fa "const BIO *a"
118.Fc
119.Ft void
120.Fo BIO_set_retry_read
121.Fa "BIO *a"
122.Fc
123.Ft void
124.Fo BIO_set_retry_write
125.Fa "BIO *a"
126.Fc
127.Ft void
128.Fo BIO_set_retry_special
129.Fa "BIO *a"
130.Fc
131.Ft void
132.Fo BIO_clear_retry_flags
133.Fa "BIO *a"
134.Fc
135.Ft int
136.Fo BIO_get_retry_flags
137.Fa "BIO *a"
138.Fc
139.Ft void
140.Fo BIO_copy_next_retry
141.Fa "BIO *a"
142.Fc
143.Ft void
144.Fo BIO_set_init
145.Fa "BIO *a"
146.Fa "int init"
147.Fc
148.Ft int
149.Fo BIO_get_init
150.Fa "BIO *a"
151.Fc
152.Ft void
153.Fo BIO_set_shutdown
154.Fa "BIO *a"
155.Fa "int shutdown"
156.Fc
157.Ft int
158.Fo BIO_get_shutdown
159.Fa "BIO *a"
160.Fc
161.Sh DESCRIPTION
162These functions are mainly useful when implementing a custom BIO.
163.Pp
164The
165.Fn BIO_set_data
166function associates the custom data pointed to by
167.Fa ptr
168with the
169.Fa "BIO a" .
170This data can subsequently be retrieved via a call to
171.Fn BIO_get_data .
172This can be used by custom BIOs for storing implementation specific
173information.
174.Pp
175.Fn BIO_set_flags
176sets all the bits contained in the
177.Fa flags
178argument in the flags stored in
179.Fa a .
180The value of a flag neither changes when it is already set in
181.Fa a
182nor when it is unset in the
183.Fa flags
184argument.
185.Pp
186.Fn BIO_clear_flags
187clears all the bits contained in the
188.Fa flags
189argument from the flags stored in
190.Fa a .
191The value of a flag neither changes when it is already unset in
192.Fa a
193nor when it is unset in the
194.Fa flags
195argument.
196.Pp
197.Fn BIO_test_flags
198checks whether any of the bits contained in the
199.Fa flags
200argument are set in the flags stored in
201.Fa a .
202Application programs usually call macros like those documented in
203.Xr BIO_should_retry 3
204rather than calling
205.Fn BIO_test_flags
206directly.
207Flag bits correspond to accessor macros as follows:
208.Pp
209.Bl -tag -width BIO_FLAGS_SHOULD_RETRY -compact
210.It Dv BIO_FLAGS_READ
211.Xr BIO_should_read 3
212.It Dv BIO_FLAGS_WRITE
213.Xr BIO_should_write 3
214.It Dv BIO_FLAGS_IO_SPECIAL
215.Xr BIO_should_io_special 3
216.It Dv BIO_FLAGS_RWS
217.Xr BIO_retry_type 3
218.It Dv BIO_FLAGS_SHOULD_RETRY
219.Xr BIO_should_retry 3
220.It Dv BIO_FLAGS_BASE64_NO_NL
221see
222.Xr BIO_f_base64 3
223.It Dv BIO_FLAGS_MEM_RDONLY
224see
225.Xr BIO_s_mem 3
226.El
227.Pp
228In particular,
229.Dv BIO_FLAGS_RWS
230is the bitwise OR of
231.Dv BIO_FLAGS_READ ,
232.Dv BIO_FLAGS_WRITE ,
233and
234.Dv BIO_FLAGS_IO_SPECIAL .
235.Pp
236.Fn BIO_set_retry_read ,
237.Fn BIO_set_retry_write ,
238and
239.Fn BIO_set_retry_special
240set the
241.Dv BIO_FLAGS_READ ,
242.Dv BIO_FLAGS_WRITE ,
243and
244.Dv BIO_FLAGS_IO_SPECIAL
245flag bit in
246.Fa a ,
247respectively.
248They all set the
249.Dv BIO_FLAGS_SHOULD_RETRY
250flag bit, too.
251.Pp
252.Fn BIO_clear_retry_flags
253clears the flag bits
254.Dv BIO_FLAGS_READ ,
255.Dv BIO_FLAGS_WRITE ,
256.Dv BIO_FLAGS_IO_SPECIAL ,
257and
258.Dv BIO_FLAGS_SHOULD_RETRY
259in
260.Fa a .
261.Pp
262.Fn BIO_copy_next_retry
263copies retry-related state data from the BIO that follows
264.Fa a
265in its chain to
266.Fa a ,
267that is, the data accessible with
268.Fn BIO_get_retry_flags
269and
270.Xr BIO_get_retry_reason 3 .
271Flags which are already set in
272.Fa a
273are not cleared.
274Before calling
275.Fn BIO_copy_next_retry ,
276making sure that
277.Fa a
278is not the last BIO in its chain is the responsibility of the caller,
279for example by checking that
280.Xr BIO_next 3
281does not return
282.Dv NULL .
283.Pp
284The
285.Fn BIO_set_init
286function sets the
287.Fa init
288flag in
289.Fa a
290to the specified value.
291A non-zero value indicates that initialisation is complete,
292whilst zero indicates that it is not.
293Often initialisation will complete
294during initial construction of the BIO.
295For some BIOs however, initialisation may not be complete until
296additional steps have been taken, for example through calling custom
297ctrls.
298.Pp
299The
300.Fn BIO_set_shutdown
301and
302.Fn BIO_get_shutdown
303functions are low-level interfaces to forcefully set and get the
304.Fa shutdown
305flag of
306.Fa a ,
307circumventing type-dependent sanity checks,
308exclusively intended for implementing a new BIO type.
309The
310.Fa shutdown
311argument must be either
312.Dv BIO_CLOSE
313or
314.Dv BIO_NOCLOSE .
315When merely using a
316.Vt BIO
317object, call
318.Xr BIO_set_close 3
319and
320.Xr BIO_get_close 3
321instead.
322.Pp
323.Fn BIO_get_flags ,
324.Fn BIO_set_retry_read ,
325.Fn BIO_set_retry_write ,
326.Fn BIO_set_retry_special ,
327.Fn BIO_clear_retry_flags ,
328and
329.Fn BIO_get_retry_flags
330are implemented as macros.
331.Sh RETURN VALUES
332.Fn BIO_get_data
333returns a pointer to the implementation specific custom data associated
334with
335.Fa a ,
336or
337.Dv NULL
338if none is set.
339.Pp
340.Fn BIO_test_flags
341returns the bitwise AND of the
342.Fa flags
343argument and the flags stored in
344.Fa a .
345Consequently, it returns a non-zero value
346if and only if at least one of the requested
347.Fa flags
348is set.
349.Pp
350.Fn BIO_get_flags
351returns all the flags currently stored in
352.Fa a .
353.Pp
354.Fn BIO_get_retry_flags
355returns the bitwise AND of
356.Pq Dv BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY
357and the flags stored in
358.Fa a .
359.Pp
360.Fn BIO_get_init
361returns the value of the init flag of
362.Fa a .
363.Pp
364.Fn BIO_get_shutdown
365returns the value previously set with
366.Fn BIO_set_shutdown
367or with
368.Xr BIO_set_close 3 .
369.Sh SEE ALSO
370.Xr BIO_meth_new 3 ,
371.Xr BIO_new 3 ,
372.Xr BIO_set_close 3 ,
373.Xr BIO_should_retry 3
374.Sh HISTORY
375.Fn BIO_set_flags ,
376.Fn BIO_clear_flags ,
377.Fn BIO_set_retry_read ,
378.Fn BIO_set_retry_write ,
379.Fn BIO_set_retry_special ,
380.Fn BIO_clear_retry_flags ,
381and
382.Fn BIO_get_retry_flags
383first appeared in SSLeay 0.8.0,
384.Fn BIO_copy_next_retry
385in SSLeay 0.8.1, and
386.Fn BIO_get_flags
387in SSLeay 0.9.0.
388These functions have been available since
389.Ox 2.4 .
390.Pp
391.Fn BIO_test_flags
392first appeared in OpenSSL 0.9.8e and has been available since
393.Ox 4.5 .
394.Pp
395.Fn BIO_set_data ,
396.Fn BIO_get_data ,
397.Fn BIO_set_init ,
398.Fn BIO_set_shutdown ,
399and
400.Fn BIO_get_shutdown
401first appeared in OpenSSL 1.1.0 and have been available since
402.Ox 6.3 .
403.Pp
404.Fn BIO_get_init
405first appeared in OpenSSL 1.1.0 and has been available since
406.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/BIO_get_ex_new_index.3 b/src/lib/libcrypto/man/BIO_get_ex_new_index.3
deleted file mode 100644
index 54d00775e7..0000000000
--- a/src/lib/libcrypto/man/BIO_get_ex_new_index.3
+++ /dev/null
@@ -1,198 +0,0 @@
1.\" $OpenBSD: BIO_get_ex_new_index.3,v 1.17 2023/11/19 10:26:36 tb Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\"
4.\" This file was written by Rich Salz <rsalz@akamai.com>.
5.\" Copyright (c) 2015, 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 19 2023 $
52.Dt BIO_GET_EX_NEW_INDEX 3
53.Os
54.Sh NAME
55.Nm BIO_get_ex_new_index ,
56.Nm BIO_set_ex_data ,
57.Nm BIO_get_ex_data ,
58.Nm BIO_set_app_data ,
59.Nm BIO_get_app_data ,
60.Nm UI_get_ex_new_index ,
61.Nm UI_set_ex_data ,
62.Nm UI_get_ex_data ,
63.Nm X509_get_ex_new_index ,
64.Nm X509_set_ex_data ,
65.Nm X509_get_ex_data ,
66.Nm EC_KEY_get_ex_new_index ,
67.Nm EC_KEY_get_ex_data ,
68.Nm EC_KEY_set_ex_data
69.Nd application-specific data
70.Sh SYNOPSIS
71.In openssl/bio.h
72.In openssl/ui.h
73.In openssl/x509.h
74.In openssl/ec.h
75.Ft int
76.Fo TYPE_get_ex_new_index
77.Fa "long argl"
78.Fa "void *argp"
79.Fa "CRYPTO_EX_new *new_func"
80.Fa "CRYPTO_EX_dup *dup_func"
81.Fa "CRYPTO_EX_free *free_func"
82.Fc
83.Ft int
84.Fo TYPE_set_ex_data
85.Fa "TYPE *d"
86.Fa "int idx"
87.Fa "void *arg"
88.Fc
89.Ft void *
90.Fo TYPE_get_ex_data
91.Fa "TYPE *d"
92.Fa "int idx"
93.Fc
94.Ft int
95.Fo TYPE_set_app_data
96.Fa "TYPE *d"
97.Fa "void *arg"
98.Fc
99.Ft void *
100.Fo TYPE_get_app_data
101.Fa "TYPE *d"
102.Fc
103.Sh DESCRIPTION
104In the description here,
105.Vt TYPE
106is used a placeholder for any of the OpenSSL datatypes listed in
107.Xr CRYPTO_get_ex_new_index 3 .
108.Pp
109These functions handle application-specific data in OpenSSL data
110structures.
111Their usage is identical to that of
112.Xr RSA_get_ex_new_index 3 ,
113.Xr RSA_set_ex_data 3 ,
114and
115.Xr RSA_get_ex_data 3 .
116.Pp
117.Fn TYPE_get_ex_new_index
118is a macro that calls
119.Xr CRYPTO_get_ex_new_index 3
120with the correct index value.
121.Pp
122.Fn TYPE_set_ex_data
123is a function that calls
124.Xr CRYPTO_set_ex_data 3
125with an offset into the opaque ex_data part of the
126.Vt TYPE
127object.
128.Pp
129.Fn TYPE_get_ex_data
130is a function that calls
131.Xr CRYPTO_get_ex_data 3
132with an offset into the opaque ex_data part of the
133.Vt TYPE
134object.
135.Pp
136.Fn TYPE_set_app_data
137and
138.Fn TYPE_get_app_data
139are deprecated wrapper macros that call
140.Fn TYPE_set_ex_data
141and
142.Fn TYPE_get_ex_data
143with
144.Fa idx
145set to 0.
146.Sh RETURN VALUES
147.Fn TYPE_get_new_ex_index
148returns a new index on success or \-1 on error.
149.Pp
150.Fn TYPE_set_ex_data
151and
152.Fn TYPE_set_app_data
153return 1 on success or 0 on error.
154.Pp
155.Fn TYPE_get_ex_data
156and
157.Fn TYPE_get_app_data
158return the application data or
159.Dv NULL
160if an error occurred.
161.Sh SEE ALSO
162.Xr BIO_new 3 ,
163.Xr CRYPTO_get_ex_new_index 3 ,
164.Xr RSA_get_ex_new_index 3 ,
165.Xr X509_new 3
166.Sh HISTORY
167.Fn BIO_set_app_data
168and
169.Fn BIO_get_app_data
170first appeared in SSLeay 0.8.1.
171.Fn BIO_get_ex_new_index ,
172.Fn BIO_set_ex_data ,
173and
174.Fn BIO_get_ex_data
175first appeared in SSLeay 0.9.0.
176These functions have been available since
177.Ox 2.4 .
178.Pp
179.Fn X509_get_ex_new_index ,
180.Fn X509_set_ex_data ,
181and
182.Fn X509_get_ex_data
183first appeared in OpenSSL 0.9.5 and have been available since
184.Ox 2.7 .
185.Pp
186.Fn UI_get_ex_new_index ,
187.Fn UI_set_ex_data ,
188and
189.Fn UI_get_ex_data
190first appeared in OpenSSL 0.9.7 and have been available since
191.Ox 3.2 .
192.Pp
193.Fn EC_KEY_get_ex_new_index ,
194.Fn EC_KEY_set_ex_data ,
195and
196.Fn EC_KEY_get_ex_data
197first appeared in OpenSSL 1.1.0 and have been available since
198.Ox 6.5 .
diff --git a/src/lib/libcrypto/man/BIO_meth_new.3 b/src/lib/libcrypto/man/BIO_meth_new.3
deleted file mode 100644
index 2159560596..0000000000
--- a/src/lib/libcrypto/man/BIO_meth_new.3
+++ /dev/null
@@ -1,367 +0,0 @@
1.\" $OpenBSD: BIO_meth_new.3,v 1.5 2018/07/09 09:52:18 tb Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Matt Caswell <matt@openssl.org>
23.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: July 9 2018 $
70.Dt BIO_METH_NEW 3
71.Os
72.Sh NAME
73.Nm BIO_get_new_index ,
74.Nm BIO_meth_new ,
75.Nm BIO_meth_free ,
76.Nm BIO_meth_get_write ,
77.Nm BIO_meth_set_write ,
78.Nm BIO_meth_get_read ,
79.Nm BIO_meth_set_read ,
80.Nm BIO_meth_get_puts ,
81.Nm BIO_meth_set_puts ,
82.Nm BIO_meth_get_gets ,
83.Nm BIO_meth_set_gets ,
84.Nm BIO_meth_get_ctrl ,
85.Nm BIO_meth_set_ctrl ,
86.Nm BIO_meth_get_create ,
87.Nm BIO_meth_set_create ,
88.Nm BIO_meth_get_destroy ,
89.Nm BIO_meth_set_destroy ,
90.Nm BIO_meth_get_callback_ctrl ,
91.Nm BIO_meth_set_callback_ctrl
92.Nd manipulate BIO_METHOD structures
93.Sh SYNOPSIS
94.In openssl/bio.h
95.Ft int
96.Fn BIO_get_new_index void
97.Ft BIO_METHOD *
98.Fo BIO_meth_new
99.Fa "int type"
100.Fa "const char *name"
101.Fc
102.Ft void
103.Fo BIO_meth_free
104.Fa "BIO_METHOD *biom"
105.Fc
106.Ft int
107.Fn "(*BIO_meth_get_write(const BIO_METHOD *biom))" "BIO *" "const char *" int
108.Ft int
109.Fo BIO_meth_set_write
110.Fa "BIO_METHOD *biom"
111.Fa "int (*write)(BIO *, const char *, int)"
112.Fc
113.Ft int
114.Fn "(*BIO_meth_get_read(const BIO_METHOD *biom))" "BIO *" "char *" int
115.Ft int
116.Fo BIO_meth_set_read
117.Fa "BIO_METHOD *biom"
118.Fa "int (*read)(BIO *, char *, int)"
119.Fc
120.Ft int
121.Fn "(*BIO_meth_get_puts(const BIO_METHOD *biom))" "BIO *" "const char *"
122.Ft int
123.Fo BIO_meth_set_puts
124.Fa "BIO_METHOD *biom"
125.Fa "int (*puts)(BIO *, const char *)"
126.Fc
127.Ft int
128.Fn "(*BIO_meth_get_gets(const BIO_METHOD *biom))" "BIO *" "char *" int
129.Ft int
130.Fo BIO_meth_set_gets
131.Fa "BIO_METHOD *biom"
132.Fa "int (*gets)(BIO *, char *, int)"
133.Fc
134.Ft long
135.Fn "(*BIO_meth_get_ctrl(const BIO_METHOD *biom))" "BIO *" int long "void *"
136.Ft int
137.Fo BIO_meth_set_ctrl
138.Fa "BIO_METHOD *biom"
139.Fa "long (*ctrl)(BIO *, int, long, void *)"
140.Fc
141.Ft int
142.Fn "(*BIO_meth_get_create(const BIO_METHOD *biom))" "BIO *"
143.Ft int
144.Fo BIO_meth_set_create
145.Fa "BIO_METHOD *biom"
146.Fa "int (*create)(BIO *)"
147.Fc
148.Ft int
149.Fn "(*BIO_meth_get_destroy(const BIO_METHOD *biom))" "BIO *"
150.Ft int
151.Fo BIO_meth_set_destroy
152.Fa "BIO_METHOD *biom"
153.Fa "int (*destroy)(BIO *)"
154.Fc
155.Ft long
156.Fo "(*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))"
157.Fa "BIO *"
158.Fa int
159.Fa "BIO_info_cb *"
160.Fc
161.Ft int
162.Fo BIO_meth_set_callback_ctrl
163.Fa "BIO_METHOD *biom"
164.Fa "long (*callback_ctrl)(BIO *, int, BIO_info_cb *)"
165.Fc
166.Sh DESCRIPTION
167The
168.Vt BIO_METHOD
169structure stores function pointers implementing a
170.Vt BIO
171type.
172See
173.Xr BIO_new 3
174for more information about
175.Vt BIO
176objects.
177.Pp
178.Fn BIO_meth_new
179creates a new
180.Vt BIO_METHOD
181structure.
182It requires a unique integer
183.Fa type ;
184use
185.Fn BIO_get_new_index
186to get the value for
187.Fa type .
188Currently, the user can only create up to 127 different BIO types, and
189.Fa type
190is limited to the range 129\(en255.
191The
192.Fa name
193pointer is stored in the structure and will not be freed by
194.Fn BIO_meth_free .
195.Pp
196The standard BIO types are listed in
197.In openssl/bio.h .
198Some examples include
199.Dv BIO_TYPE_BUFFER
200and
201.Dv BIO_TYPE_CIPHER .
202The
203.Fa type
204of filter BIOs should have the
205.Dv BIO_TYPE_FILTER
206bit set.
207Source/sink BIOs should have the
208.Dv BIO_TYPE_SOURCE_SINK
209bit set.
210File descriptor based BIOs (e.g. socket, fd, connect, accept etc.\&)
211should additionally have the
212.Dv BIO_TYPE_DESCRIPTOR
213bit set.
214See
215.Xr BIO_find_type 3
216for more information.
217.Pp
218.Fn BIO_meth_free
219is an alias for
220.Xr free 3 .
221.Pp
222.Fn BIO_meth_get_write ,
223.Fn BIO_meth_set_write ,
224.Fn BIO_meth_get_read ,
225and
226.Fn BIO_meth_set_read
227get and set the functions
228.Fa write
229and
230.Fa read
231used for writing and reading arbitrary length data to and from the
232.Vt BIO .
233These functions are called from
234.Xr BIO_write 3
235and
236.Xr BIO_read 3 ,
237respectively.
238The parameters and return values of
239.Fa write
240and
241.Fa read
242have the same meaning as for
243.Xr BIO_write 3
244and
245.Xr BIO_read 3 .
246.Pp
247.Fn BIO_meth_get_puts
248and
249.Fn BIO_meth_set_puts
250get and set the function
251.Fa puts
252used for writing a NUL-terminated string to the
253.Vt BIO .
254This function is called from
255.Xr BIO_puts 3 .
256The parameters and the return value of
257.Fa puts
258have the same meaning as for
259.Xr BIO_puts 3 .
260.Pp
261.Fn BIO_meth_get_gets
262and
263.Fn BIO_meth_set_gets
264get and set the function
265.Fa gets
266used for reading a line of data from the
267.Vt BIO .
268This function is called from
269.Xr BIO_gets 3 .
270The parameters and the return value of
271.Fa gets
272have the same meaning as for
273.Xr BIO_gets 3 .
274.Pp
275.Fn BIO_meth_get_ctrl
276and
277.Fn BIO_meth_set_ctrl
278get and set the function
279.Fa ctrl
280used for processing control messages in the
281.Vt BIO .
282This function is called from
283.Xr BIO_ctrl 3 .
284The parameters and return value of
285.Fa ctrl
286have the same meaning as for
287.Xr BIO_ctrl 3 .
288.Pp
289.Fn BIO_meth_get_create
290and
291.Fn BIO_meth_set_create
292get and set a function
293.Fa create
294used while initializing a new instance of the
295.Vt BIO .
296This function is called from
297.Xr BIO_new 3 .
298The
299.Xr BIO_new 3
300function allocates the memory for the new
301.Vt BIO ,
302and a pointer to this newly allocated structure is passed
303as the parameter to
304.Fa create .
305.Pp
306.Fn BIO_meth_get_destroy
307and
308.Fn BIO_meth_set_destroy
309get and set a function
310.Fa destroy
311used while destroying an instance of a
312.Vt BIO .
313This function is called from
314.Xr BIO_free 3 .
315A pointer to the
316.Vt BIO
317to be destroyed is passed as the parameter.
318The
319.Fa destroy
320function is intended to perform clean-up specific to the
321.Vt BIO
322.Fa type .
323The memory for the
324.Vt BIO
325itself must not be freed by this function.
326.Pp
327.Fn BIO_meth_get_callback_ctrl
328and
329.Fn BIO_meth_set_callback_ctrl
330get and set the function
331.Fa callback_ctrl
332used for processing callback control messages in the
333.Vt BIO .
334This function is called from
335.Xr BIO_callback_ctrl 3 .
336The parameters and return value of
337.Fa callback_ctrl
338have the same meaning as for
339.Xr BIO_callback_ctrl 3 .
340.Sh RETURN VALUES
341.Fn BIO_get_new_index
342returns the new BIO type value or \-1 if an error occurs.
343.Pp
344.Fn BIO_meth_new
345returns the new
346.Vt BIO_METHOD
347structure or
348.Dv NULL
349if an error occurs.
350.Pp
351The
352.Fn BIO_meth_set_*
353functions return 1 on success or 0 on error.
354Currently, they cannot fail.
355.Pp
356The
357.Fn BIO_meth_get_*
358functions return function pointers.
359.Sh SEE ALSO
360.Xr BIO_ctrl 3 ,
361.Xr BIO_find_type 3 ,
362.Xr BIO_new 3 ,
363.Xr BIO_read 3
364.Sh HISTORY
365These functions first appeared in OpenSSL 1.1.0
366and have been available since
367.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/BIO_new.3 b/src/lib/libcrypto/man/BIO_new.3
deleted file mode 100644
index f97a314826..0000000000
--- a/src/lib/libcrypto/man/BIO_new.3
+++ /dev/null
@@ -1,279 +0,0 @@
1.\" $OpenBSD: BIO_new.3,v 1.28 2023/07/26 20:01:04 tb Exp $
2.\" full merge up to:
3.\" OpenSSL man3/BIO_new.pod fb46be03 Feb 26 11:51:31 2016 +0000
4.\" OpenSSL man7/bio.pod 631c37be Dec 12 16:56:50 2017 +0100
5.\" partial merge up to:
6.\" OpenSSL man3/BIO_new.pod e9b77246 Jan 20 19:58:49 2017 +0100
7.\"
8.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
9.\" Copyright (c) 2000, 2015, 2016 The OpenSSL Project. All rights reserved.
10.\"
11.\" Redistribution and use in source and binary forms, with or without
12.\" modification, are permitted provided that the following conditions
13.\" are met:
14.\"
15.\" 1. Redistributions of source code must retain the above copyright
16.\" notice, this list of conditions and the following disclaimer.
17.\"
18.\" 2. Redistributions in binary form must reproduce the above copyright
19.\" notice, this list of conditions and the following disclaimer in
20.\" the documentation and/or other materials provided with the
21.\" distribution.
22.\"
23.\" 3. All advertising materials mentioning features or use of this
24.\" software must display the following acknowledgment:
25.\" "This product includes software developed by the OpenSSL Project
26.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
27.\"
28.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
29.\" endorse or promote products derived from this software without
30.\" prior written permission. For written permission, please contact
31.\" openssl-core@openssl.org.
32.\"
33.\" 5. Products derived from this software may not be called "OpenSSL"
34.\" nor may "OpenSSL" appear in their names without prior written
35.\" permission of the OpenSSL Project.
36.\"
37.\" 6. Redistributions of any form whatsoever must retain the following
38.\" acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
41.\"
42.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
43.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
46.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\"
55.Dd $Mdocdate: July 26 2023 $
56.Dt BIO_NEW 3
57.Os
58.Sh NAME
59.Nm BIO_new ,
60.Nm BIO_up_ref ,
61.Nm BIO_set ,
62.Nm BIO_free ,
63.Nm BIO_vfree ,
64.Nm BIO_free_all
65.Nd construct and destruct I/O abstraction objects
66.Sh SYNOPSIS
67.In openssl/bio.h
68.Ft BIO *
69.Fo BIO_new
70.Fa "const BIO_METHOD *type"
71.Fc
72.Ft int
73.Fo BIO_up_ref
74.Fa "BIO *a"
75.Fc
76.Ft int
77.Fo BIO_set
78.Fa "BIO *a"
79.Fa "const BIO_METHOD *type"
80.Fc
81.Ft int
82.Fo BIO_free
83.Fa "BIO *a"
84.Fc
85.Ft void
86.Fo BIO_vfree
87.Fa "BIO *a"
88.Fc
89.Ft void
90.Fo BIO_free_all
91.Fa "BIO *a"
92.Fc
93.Sh DESCRIPTION
94A
95.Vt BIO
96is an I/O abstraction object, hiding many of the underlying I/O
97details from an application.
98If an application uses BIOs for its I/O, it can transparently handle
99SSL connections, unencrypted network connections, and file I/O.
100.Pp
101The
102.Fn BIO_new
103function constructs a new
104.Vt BIO
105using the method
106.Fa type
107and sets its reference count to 1.
108There are two groups of BIO types, source/sink BIOs and filter BIOs.
109.Pp
110Source/sink BIOs provide input or consume output.
111Examples include socket BIOs and file BIOs.
112.Pp
113Filter BIOs take data from one BIO and pass it through to another,
114or to the application, forming a chain of BIOs.
115The data may be left unmodified (for example by a message digest BIO)
116or translated (for example by an encryption BIO).
117The effect of a filter BIO may change according to the I/O operation
118it is performing: for example an encryption BIO encrypts data
119if it is written to and decrypts data if it is read from.
120.Pp
121Some BIOs (such as memory BIOs) can be used immediately after calling
122.Fn BIO_new .
123Others (such as file BIOs) need some additional initialization, and
124utility functions exists to construct and initialize such BIOs.
125.Pp
126Normally the
127.Fa type
128argument is supplied by a function which returns a pointer to a
129.Vt BIO_METHOD .
130There is a naming convention for such functions:
131the methods for source/sink BIOs are called
132.Fn BIO_s_*
133and those for filter BIOs
134.Fn BIO_f_* .
135.Pp
136.Fn BIO_up_ref
137increments the reference count of
138.Fa a
139by 1.
140.Pp
141.Fn BIO_set
142is a deprecated function to initialize an unused
143.Vt BIO
144structure located in static memory or on the stack,
145to set its method to
146.Fa type ,
147and to set its reference count to 1.
148It must not be called on
149.Vt BIO
150objects created with
151.Fn BIO_new ,
152nor on objects that were already used.
153.Pp
154.Fn BIO_free
155and
156.Fn BIO_vfree
157decrement the reference count of
158.Fa a
159by 1, and if the reference count reaches 0, they destruct the single
160.Vt BIO
161.Fa a ,
162which may also have some effect on the
163underlying I/O structure, for example it may close the file being
164referred to under certain circumstances.
165If
166.Fa a
167is a
168.Dv NULL
169pointer, no action occurs.
170If
171.Fn BIO_free
172is called on a BIO chain, it destructs at most one BIO,
173resulting in a memory leak.
174.Pp
175.Fn BIO_free_all
176calls
177.Fn BIO_free
178on
179.Fa a
180and on all following
181.Vt BIO
182objects in the chain.
183As soon as the reference count of a
184.Vt BIO
185is still non-zero after calling
186.Fn BIO_free
187on it, the function
188.Fn BIO_free_all
189returns right away and refrains from freeing the remaining
190.Vt BIO
191objects in the chain.
192It does not halt if an error occurs
193destructing an individual BIO in the chain.
194If
195.Fa a
196is a
197.Dv NULL
198pointer, no action occurs.
199Calling
200.Fn BIO_free_all
201on a single BIO has the same effect as
202.Fn BIO_vfree .
203.Pp
204Common I/O functions are documented in
205.Xr BIO_read 3 .
206Forming chains is explained in
207.Xr BIO_push 3 ;
208inspecting them is explained in
209.Xr BIO_find_type 3 .
210For more details about the different kinds of BIOs, see the individual
211.Vt BIO_METHOD
212manual pages.
213.Sh RETURN VALUES
214.Fn BIO_new
215returns a newly constructed
216.Vt BIO
217object or
218.Dv NULL
219on failure.
220.Pp
221.Fn BIO_up_ref ,
222.Fn BIO_set ,
223and
224.Fn BIO_free
225return 1 for success or 0 for failure.
226.Sh EXAMPLES
227Create a memory BIO:
228.Pp
229.Dl BIO *mem = BIO_new(BIO_s_mem());
230.Sh SEE ALSO
231.Xr BIO_accept 3 ,
232.Xr BIO_ctrl 3 ,
233.Xr BIO_dump 3 ,
234.Xr BIO_dup_chain 3 ,
235.Xr BIO_f_base64 3 ,
236.Xr BIO_f_buffer 3 ,
237.Xr BIO_f_cipher 3 ,
238.Xr BIO_f_md 3 ,
239.Xr BIO_f_null 3 ,
240.Xr BIO_f_ssl 3 ,
241.Xr BIO_find_type 3 ,
242.Xr BIO_get_ex_new_index 3 ,
243.Xr BIO_meth_new 3 ,
244.Xr BIO_new_CMS 3 ,
245.Xr BIO_printf 3 ,
246.Xr BIO_push 3 ,
247.Xr BIO_read 3 ,
248.Xr BIO_s_accept 3 ,
249.Xr BIO_s_bio 3 ,
250.Xr BIO_s_connect 3 ,
251.Xr BIO_s_datagram 3 ,
252.Xr BIO_s_fd 3 ,
253.Xr BIO_s_file 3 ,
254.Xr BIO_s_mem 3 ,
255.Xr BIO_s_null 3 ,
256.Xr BIO_s_socket 3 ,
257.Xr BIO_set_callback 3 ,
258.Xr BIO_set_data 3 ,
259.Xr BIO_should_retry 3 ,
260.Xr BUF_MEM_new 3 ,
261.Xr crypto 3
262.Sh HISTORY
263.Fn BIO_new ,
264.Fn BIO_set ,
265and
266.Fn BIO_free
267first appeared in SSLeay 0.6.0.
268.Fn BIO_free_all
269first appeared in SSLeay 0.6.6.
270All these functions have been available since
271.Ox 2.4 .
272.Pp
273.Fn BIO_vfree
274first appeared in OpenSSL 0.9.6 and has been available since
275.Ox 2.9 .
276.Pp
277.Fn BIO_up_ref
278first appeared in OpenSSL 1.1.0 and has been available since
279.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/BIO_new_CMS.3 b/src/lib/libcrypto/man/BIO_new_CMS.3
deleted file mode 100644
index ab93e1c00c..0000000000
--- a/src/lib/libcrypto/man/BIO_new_CMS.3
+++ /dev/null
@@ -1,141 +0,0 @@
1.\" $OpenBSD: BIO_new_CMS.3,v 1.9 2023/05/01 07:28:11 tb Exp $
2.\" full merge up to: OpenSSL df75c2bfc Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: May 1 2023 $
52.Dt BIO_NEW_CMS 3
53.Os
54.Sh NAME
55.Nm BIO_new_CMS
56.Nd CMS streaming filter BIO
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft BIO *
60.Fo BIO_new_CMS
61.Fa "BIO *out"
62.Fa "CMS_ContentInfo *cms"
63.Fc
64.Sh DESCRIPTION
65.Fn BIO_new_CMS
66returns a streaming filter
67.Vt BIO
68chain based on
69.Fa cms .
70The output of the filter is written to
71.Fa out .
72Any data written to the chain is automatically translated
73to a BER format CMS structure of the appropriate type.
74.Pp
75The chain returned by this function behaves like a standard filter
76.Vt BIO .
77It supports non blocking I/O.
78Content is processed and streamed on the fly and not all held in memory
79at once: so it is possible to encode very large structures.
80After all content has been written through the chain,
81.Xr BIO_flush 3
82must be called to finalise the structure.
83.Pp
84The
85.Dv CMS_STREAM
86flag must be included in the corresponding
87.Fa flags
88parameter of the
89.Fa cms
90creation function.
91.Pp
92If an application wishes to write additional data to
93.Fa out ,
94BIOs should be removed from the chain using
95.Xr BIO_pop 3
96and freed with
97.Xr BIO_free 3
98until
99.Fa out
100is reached.
101If no additional data needs to be written,
102.Xr BIO_free_all 3
103can be called to free up the whole chain.
104.Pp
105Any content written through the filter is used verbatim:
106no canonical translation is performed.
107.Pp
108It is possible to chain multiple BIOs to, for example,
109create a triple wrapped signed, enveloped, signed structure.
110In this case it is the application's responsibility
111to set the inner content type of any outer
112.Vt CMS_ContentInfo
113structures.
114.Pp
115Large numbers of small writes through the chain should be avoided as this
116will produce an output consisting of lots of OCTET STRING structures.
117Prepending a
118.Xr BIO_f_buffer 3
119buffering BIO will prevent this.
120.Sh RETURN VALUES
121.Fn BIO_new_CMS
122returns a
123.Vt BIO
124chain when successful or
125.Dv NULL
126if an error occurred.
127The error can be obtained from
128.Xr ERR_get_error 3 .
129.Sh SEE ALSO
130.Xr BIO_new 3 ,
131.Xr CMS_ContentInfo_new 3 ,
132.Xr CMS_encrypt 3 ,
133.Xr CMS_sign 3
134.Sh HISTORY
135.Fn BIO_new_CMS
136first appeared in OpenSSL 1.0.0
137and has been available since
138.Ox 6.7 .
139.Sh BUGS
140There is currently no corresponding inverse BIO
141which can decode a CMS structure on the fly.
diff --git a/src/lib/libcrypto/man/BIO_printf.3 b/src/lib/libcrypto/man/BIO_printf.3
deleted file mode 100644
index 32dec0a828..0000000000
--- a/src/lib/libcrypto/man/BIO_printf.3
+++ /dev/null
@@ -1,46 +0,0 @@
1.\" $OpenBSD: BIO_printf.3,v 1.4 2024/03/02 09:18:28 tb Exp $
2.\" OpenSSL 2ca2e917 Mon Mar 20 16:25:22 2017 -0400
3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: March 2 2024 $
19.Dt BIO_PRINTF 3
20.Os
21.Sh NAME
22.Nm BIO_printf
23.Nd formatted output to a BIO
24.Sh SYNOPSIS
25.In openssl/bio.h
26.Ft int
27.Fo BIO_printf
28.Fa "BIO *bio"
29.Fa "const char *format"
30.Fa ...
31.Fc
32.Sh DESCRIPTION
33.Fn BIO_printf
34is a wrapper around
35.Xr vfprintf 3 ,
36sending the output to the specified
37.Fa bio .
38.Sh RETURN VALUES
39These functions return the number of bytes written,
40or -1 if an error occurs.
41.Sh SEE ALSO
42.Xr BIO_new 3
43.Sh HISTORY
44.Fn BIO_printf
45first appeared in SSLeay 0.6.5 and has been available since
46.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BIO_push.3 b/src/lib/libcrypto/man/BIO_push.3
deleted file mode 100644
index 46c736e2c2..0000000000
--- a/src/lib/libcrypto/man/BIO_push.3
+++ /dev/null
@@ -1,335 +0,0 @@
1.\" $OpenBSD: BIO_push.3,v 1.14 2022/12/16 16:02:17 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL doc/man3/BIO_push.pod 791bfd91 Nov 19 20:38:27 2021 +0100
4.\" OpenSSL doc/man7/bio.pod 1cb7eff4 Sep 10 13:56:40 2019 +0100
5.\"
6.\" This file is a derived work.
7.\" The changes are covered by the following Copyright and license:
8.\"
9.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
10.\"
11.\" Permission to use, copy, modify, and distribute this software for any
12.\" purpose with or without fee is hereby granted, provided that the above
13.\" copyright notice and this permission notice appear in all copies.
14.\"
15.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22.\"
23.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
24.\" Copyright (c) 2000, 2014 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: December 16 2022 $
71.Dt BIO_PUSH 3
72.Os
73.Sh NAME
74.Nm BIO_push ,
75.Nm BIO_pop ,
76.Nm BIO_set_next
77.Nd manipulate BIO chains
78.Sh SYNOPSIS
79.In openssl/bio.h
80.Ft BIO *
81.Fo BIO_push
82.Fa "BIO *b"
83.Fa "BIO *new_tail"
84.Fc
85.Ft BIO *
86.Fo BIO_pop
87.Fa "BIO *b"
88.Fc
89.Ft void
90.Fo BIO_set_next
91.Fa "BIO *b"
92.Fa "BIO *new_tail"
93.Fc
94.Sh DESCRIPTION
95BIOs can be joined together to form chains.
96A chain normally consists of one or more filter BIOs
97and one source/sink BIO at the end.
98Data read from or written to the first BIO traverses the chain
99to the end.
100.Pp
101Every BIO is a member of exactly one chain.
102It is either at the beginning of its chain
103or there is exactly one preceding BIO.
104It is either at the end of its chain
105or there is exactly one following BIO.
106If there is neither a preceding nor a following BIO,
107it can be regarded as a chain with one member.
108Every chain has exactly one beginning and exactly one end.
109.Pp
110.Fn BIO_push
111appends the chain starting at
112.Fa new_tail
113to the end of the chain that contains
114.Fa b .
115Unless
116.Fa b
117is
118.Dv NULL ,
119it then calls
120.Xr BIO_ctrl 3
121on
122.Fa b
123with an argument of
124.Dv BIO_CTRL_PUSH .
125If
126.Fa b
127or
128.Fa new_tail
129is
130.Dv NULL ,
131nothing is appended.
132.Pp
133In LibreSSL, if
134.Fa new_tail
135is not at the beginning of its chain,
136the head of that chain up to but not including
137.Fa new_tail
138is cut off and becomes a separate chain.
139For portability, it is best to make sure that
140.Fa new_tail
141is at the beginning of its chain before calling
142.Fn BIO_push .
143.Pp
144.Fn BIO_pop
145removes the BIO
146.Fa b
147from its chain.
148Despite the word
149.Dq pop
150in the function name,
151.Fa b
152can be at the beginning, in the middle, or at the end of its chain.
153Before removal,
154.Xr BIO_ctrl 3
155is called on
156.Fa b
157with an argument of
158.Dv BIO_CTRL_POP .
159The removed BIO
160.Fa b
161becomes the only member of its own chain and can thus be freed
162or attached to a different chain.
163If
164.Fa b
165is
166.Dv NULL ,
167no action occurs.
168.Pp
169.Fn BIO_set_next
170appends the chain starting with
171.Fa new_tail
172to the chain ending with
173.Fa b .
174.Pp
175In LibreSSL, if
176.Fa new_tail
177is not at the beginning of its chain,
178the head of that chain up to but not including
179.Fa new_tail
180is cut off and becomes a separate chain,
181and if
182.Fa b
183is not at the end of its chain,
184the tail of that chain starting after
185.Fa b
186is cut off and becomes a separate chain.
187.Pp
188For portability, it is best to make sure that
189.Fa b
190is at the end of its chain and that
191.Fa new_tail
192is at the beginning of its chain before calling
193.Fn BIO_set_next
194and to avoid calling
195.Fn BIO_pop
196on
197.Fa new_tail
198afterwards.
199.Pp
200In LibreSSL, the only built-in BIO type for which
201.Xr BIO_ctrl 3
202calls with an argument of
203.Dv BIO_CTRL_PUSH
204or
205.Dv BIO_CTRL_POP
206have any effect is
207.Xr BIO_f_ssl 3 .
208.Sh RETURN VALUES
209.Fn BIO_push
210returns
211.Fa b
212if it is not
213.Dv NULL
214or
215.Fa new_tail
216if it is.
217.Pp
218.Fn BIO_pop
219returns the BIO that followed
220.Fa b
221in its chain, or
222.Dv NULL
223if
224.Fa b
225is
226.Dv NULL
227or was at the end of its chain.
228.Sh EXAMPLES
229For these examples suppose
230.Sy md1
231and
232.Sy md2
233are digest BIOs,
234.Sy b64
235is a Base64 BIO and
236.Sy f
237is a file BIO (see
238.Xr BIO_f_md 3 ,
239.Xr BIO_f_base64 3 ,
240and
241.Xr BIO_s_file 3 ,
242respectively).
243.Pp
244If the call
245.Pp
246.Dl BIO_push(b64, f);
247.Pp
248is made then the new chain will be
249.Sy b64-f .
250After making the calls
251.Bd -literal -offset indent
252BIO_push(md2, b64);
253BIO_push(md1, md2);
254.Ed
255.Pp
256the new chain is
257.Sy md1-md2-b64-f .
258Data written to
259.Sy md1
260will be digested
261by
262.Sy md1
263and
264.Sy md2 ,
265Base64-encoded and written to
266.Sy f .
267.Pp
268It should be noted that reading causes data to pass
269in the reverse direction.
270That is, data is read from
271.Sy f ,
272Base64-decoded and digested by
273.Sy md1
274and
275.Sy md2 .
276If this call is made:
277.Pp
278.Dl BIO_pop(md2);
279.Pp
280The call will return
281.Sy b64
282and the new chain will be
283.Sy md1-b64-f ;
284data can be written to
285.Sy md1
286as before.
287.Sh SEE ALSO
288.Xr BIO_find_type 3 ,
289.Xr BIO_new 3 ,
290.Xr BIO_read 3
291.Sh HISTORY
292.Fn BIO_push
293first appeared in SSLeay 0.6.0.
294.Fn BIO_pop
295first appeared in SSLeay 0.6.4.
296Both functions have been available since
297.Ox 2.4 .
298.Pp
299.Fn BIO_set_next
300first appeared in OpenSSL 1.1.0
301and has been available since
302.Ox 7.1 .
303.Sh CAVEATS
304Creating a cyclic chain results in undefined behavior.
305For example, infinite recursion or infinite loops may ensue.
306.Pp
307If it is unknown whether
308.Fa b
309and
310.Fa new_tail
311are already members of the same chain and whether joining them would
312create a cycle, the calling code can use the following safe idiom:
313.Bd -literal -offset indent
314BIO *btest;
315
316for (btest = new_tail; btest != NULL; btest = BIO_next(btest))
317 if (btest == b)
318 /* Bail out because this would create a cycle. */
319BIO_push(b, new_tail); /* This is now safe. */
320.Ed
321.Pp
322The same idiom can be used with
323.Fn BIO_set_next
324instead of
325.Fn BIO_push .
326.Pp
327Often, the safe idiom is not needed because it is already known that
328.Fa b
329and
330.Fa new_tail
331are not members of the same chain, for example when
332.Fa b
333or
334.Fa new_tail
335was created right before.
diff --git a/src/lib/libcrypto/man/BIO_read.3 b/src/lib/libcrypto/man/BIO_read.3
deleted file mode 100644
index 5fea9f728a..0000000000
--- a/src/lib/libcrypto/man/BIO_read.3
+++ /dev/null
@@ -1,281 +0,0 @@
1.\" $OpenBSD: BIO_read.3,v 1.11 2022/12/18 17:40:55 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2021, 2022 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2000, 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 18 2022 $
69.Dt BIO_READ 3
70.Os
71.Sh NAME
72.Nm BIO_read ,
73.Nm BIO_number_read ,
74.Nm BIO_gets ,
75.Nm BIO_write ,
76.Nm BIO_puts ,
77.Nm BIO_indent ,
78.Nm BIO_number_written
79.Nd BIO I/O functions
80.Sh SYNOPSIS
81.In openssl/bio.h
82.Ft int
83.Fo BIO_read
84.Fa "BIO *b"
85.Fa "void *buf"
86.Fa "int len"
87.Fc
88.Ft unsigned long
89.Fo BIO_number_read
90.Fa "BIO *b"
91.Fc
92.Ft int
93.Fo BIO_gets
94.Fa "BIO *b"
95.Fa "char *buf"
96.Fa "int size"
97.Fc
98.Ft int
99.Fo BIO_write
100.Fa "BIO *b"
101.Fa "const void *buf"
102.Fa "int len"
103.Fc
104.Ft int
105.Fo BIO_puts
106.Fa "BIO *b"
107.Fa "const char *string"
108.Fc
109.Ft int
110.Fo BIO_indent
111.Fa "BIO *b"
112.Fa "int indent"
113.Fa "int max"
114.Fc
115.Ft unsigned long
116.Fo BIO_number_written
117.Fa "BIO *b"
118.Fc
119.Sh DESCRIPTION
120.Fn BIO_read
121attempts to read
122.Fa len
123bytes from
124.Fa b
125and places the data in
126.Fa buf .
127.Pp
128.Fn BIO_number_read
129returns the grand total of bytes read from
130.Fa b
131using
132.Fn BIO_read
133so far.
134Bytes read with
135.Fn BIO_gets
136do
137.Sy not
138count.
139.Xr BIO_new 3
140and
141.Xr BIO_set 3
142initialize the counter to 0.
143When reading very large amounts of data,
144the counter will eventually wrap around from
145.Dv ULONG_MAX
146to 0.
147.Pp
148.Fn BIO_gets
149performs the BIOs "gets" operation and places the data in
150.Fa buf .
151Usually this operation will attempt to read a line of data
152from the BIO of maximum length
153.Fa size No \- 1 .
154There are exceptions to this however, for example
155.Fn BIO_gets
156on a digest BIO will calculate and return the digest
157and other BIOs may not support
158.Fn BIO_gets
159at all.
160The returned string is always NUL-terminated.
161.Pp
162.Fn BIO_write
163attempts to write
164.Fa len
165bytes from
166.Fa buf
167to
168.Fa b .
169.Pp
170.Fn BIO_puts
171attempts to write the NUL-terminated
172.Fa string
173to
174.Fa b .
175.Pp
176.Fn BIO_indent
177attempts to write
178.Fa indent
179space characters to
180.Fa b ,
181but not more than
182.Fa max
183characters.
184.Pp
185.Fn BIO_number_written
186returns the grand total of bytes written to
187.Fa b
188using
189.Fn BIO_write ,
190.Fn BIO_puts ,
191and
192.Fn BIO_indent
193so far.
194.Xr BIO_new 3
195and
196.Xr BIO_set 3
197initialize the counter to 0.
198When writing very large amounts of data,
199the counter will eventually wrap around from
200.Dv ULONG_MAX
201to 0.
202.Pp
203One technique sometimes used with blocking sockets
204is to use a system call (such as
205.Xr select 2 ,
206.Xr poll 2
207or equivalent) to determine when data is available and then call
208.Xr read 2
209to read the data.
210The equivalent with BIOs (that is call
211.Xr select 2
212on the underlying I/O structure and then call
213.Fn BIO_read
214to read the data) should
215.Em not
216be used because a single call to
217.Fn BIO_read
218can cause several reads (and writes in the case of SSL BIOs)
219on the underlying I/O structure and may block as a result.
220Instead
221.Xr select 2
222(or equivalent) should be combined with non-blocking I/O
223so successive reads will request a retry instead of blocking.
224.Pp
225See
226.Xr BIO_should_retry 3
227for details of how to determine the cause of a retry and other I/O issues.
228.Pp
229If the
230.Fn BIO_gets
231function is not supported by a BIO then it is possible to
232work around this by adding a buffering BIO
233.Xr BIO_f_buffer 3
234to the chain.
235.Sh RETURN VALUES
236.Fn BIO_indent
237returns 1 if successful, even if nothing was written,
238or 0 if writing fails.
239.Pp
240.Fn BIO_number_read
241and
242.Fn BIO_number_written
243return a number of bytes or 0 if
244.Fa b
245is a
246.Dv NULL
247pointer.
248.Pp
249The other functions return either the amount of data successfully
250read or written (if the return value is positive) or that no data
251was successfully read or written if the result is 0 or \-1.
252If the return value is \-2, then the operation is not implemented
253in the specific BIO type.
254The trailing NUL is not included in the length returned by
255.Fn BIO_gets .
256.Pp
257A 0 or \-1 return is not necessarily an indication of an error.
258In particular when the source/sink is non-blocking or of a certain type
259it may merely be an indication that no data is currently available and that
260the application should retry the operation later.
261.Sh SEE ALSO
262.Xr BIO_meth_new 3 ,
263.Xr BIO_new 3 ,
264.Xr BIO_should_retry 3
265.Sh HISTORY
266.Fn BIO_read ,
267.Fn BIO_gets ,
268.Fn BIO_write ,
269and
270.Fn BIO_puts
271first appeared in SSLeay 0.6.0.
272.Fn BIO_number_read
273and
274.Fn BIO_number_written
275first appeared in SSLeay 0.6.5.
276These functions have been available since
277.Ox 2.4 .
278.Pp
279.Fn BIO_indent
280first appeared in OpenSSL 0.9.7 and has been available since
281.Ox 3.4 .
diff --git a/src/lib/libcrypto/man/BIO_s_accept.3 b/src/lib/libcrypto/man/BIO_s_accept.3
deleted file mode 100644
index 8e88fe1c52..0000000000
--- a/src/lib/libcrypto/man/BIO_s_accept.3
+++ /dev/null
@@ -1,414 +0,0 @@
1.\" $OpenBSD: BIO_s_accept.3,v 1.16 2023/04/29 13:06:10 schwarze Exp $
2.\" full merge up to: OpenSSL c03726ca Thu Aug 27 12:28:08 2015 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2000, 2014, 2015 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: April 29 2023 $
69.Dt BIO_S_ACCEPT 3
70.Os
71.Sh NAME
72.Nm BIO_s_accept ,
73.Nm BIO_set_accept_port ,
74.Nm BIO_get_accept_port ,
75.Nm BIO_new_accept ,
76.Nm BIO_set_nbio_accept ,
77.Nm BIO_set_accept_bios ,
78.Nm BIO_set_bind_mode ,
79.Nm BIO_get_bind_mode ,
80.Nm BIO_do_accept
81.Nd accept BIO
82.Sh SYNOPSIS
83.In openssl/bio.h
84.Ft const BIO_METHOD *
85.Fo BIO_s_accept
86.Fa void
87.Fc
88.Ft long
89.Fo BIO_set_accept_port
90.Fa "BIO *b"
91.Fa "char *name"
92.Fc
93.Ft char *
94.Fo BIO_get_accept_port
95.Fa "BIO *b"
96.Fc
97.Ft BIO *
98.Fo BIO_new_accept
99.Fa "const char *host_port"
100.Fc
101.Ft long
102.Fo BIO_set_nbio_accept
103.Fa "BIO *b"
104.Fa "int n"
105.Fc
106.Ft long
107.Fo BIO_set_accept_bios
108.Fa "BIO *b"
109.Fa "char *bio"
110.Fc
111.Ft long
112.Fo BIO_set_bind_mode
113.Fa "BIO *b"
114.Fa "long mode"
115.Fc
116.Ft long
117.Fo BIO_get_bind_mode
118.Fa "BIO *b"
119.Fa "long dummy"
120.Fc
121.Fd #define BIO_BIND_NORMAL 0
122.Fd #define BIO_BIND_REUSEADDR_IF_UNUSED 1
123.Fd #define BIO_BIND_REUSEADDR 2
124.Ft long
125.Fo BIO_do_accept
126.Fa "BIO *b"
127.Fc
128.Sh DESCRIPTION
129.Fn BIO_s_accept
130returns the accept BIO method.
131This is a wrapper round the platform's TCP/IP socket
132.Xr accept 2
133routines.
134.Pp
135Using accept BIOs, TCP/IP connections can be accepted
136and data transferred using only BIO routines.
137In this way any platform specific operations
138are hidden by the BIO abstraction.
139.Pp
140Read and write operations on an accept BIO
141will perform I/O on the underlying connection.
142If no connection is established and the port (see below) is set up
143properly then the BIO waits for an incoming connection.
144.Pp
145Accept BIOs support
146.Xr BIO_puts 3
147but not
148.Xr BIO_gets 3 .
149.Pp
150If the close flag is set on an accept BIO, then any active
151connection on that chain is shut down and the socket closed when
152the BIO is freed.
153.Pp
154Calling
155.Xr BIO_reset 3
156on an accept BIO will close any active connection and reset the BIO
157into a state where it awaits another incoming connection.
158.Pp
159.Xr BIO_get_fd 3
160and
161.Xr BIO_set_fd 3
162can be called to retrieve or set the accept socket.
163See
164.Xr BIO_s_fd 3 .
165.Pp
166.Fn BIO_set_accept_port
167uses the string
168.Fa name
169to set the accept port.
170The port is represented as a string of the form
171.Ar host : Ns Ar port ,
172where
173.Ar host
174is the interface to use and
175.Ar port
176is the port.
177The host can be
178.Qq * ,
179which is interpreted as meaning any interface;
180.Ar port
181has the same syntax as the port specified in
182.Xr BIO_set_conn_port 3
183for connect BIOs.
184It can be a numerical port string or a string to look up using
185.Xr getservbyname 3
186and a string table.
187.Pp
188.Fn BIO_new_accept
189combines
190.Xr BIO_new 3
191and
192.Fn BIO_set_accept_port
193into a single call.
194It creates a new accept BIO with port
195.Fa host_port .
196.Pp
197.Fn BIO_set_nbio_accept
198sets the accept socket to blocking mode (the default) if
199.Fa n
200is 0 or non-blocking mode if
201.Fa n
202is 1.
203.Pp
204.Fn BIO_set_accept_bios
205can be used to set a chain of BIOs which will be duplicated
206and prepended to the chain when an incoming connection is received.
207This is useful if, for example, a buffering or SSL BIO
208is required for each connection.
209The chain of BIOs must not be freed after this call -
210they will be automatically freed when the accept BIO is freed.
211.Pp
212.Fn BIO_set_bind_mode
213and
214.Fn BIO_get_bind_mode
215set and retrieve the current bind mode.
216If
217.Dv BIO_BIND_NORMAL Pq the default
218is set, then another socket cannot be bound to the same port.
219If
220.Dv BIO_BIND_REUSEADDR
221is set, then other sockets can bind to the same port.
222If
223.Dv BIO_BIND_REUSEADDR_IF_UNUSED
224is set, then an attempt is first made to use
225.Dv BIO_BIN_NORMAL ;
226if this fails and the port is not in use,
227then a second attempt is made using
228.Dv BIO_BIND_REUSEADDR .
229.Pp
230.Fn BIO_do_accept
231serves two purposes.
232When it is first called, after the accept BIO has been set up,
233it will attempt to create the accept socket and bind an address to it.
234Second and subsequent calls to
235.Fn BIO_do_accept
236will await an incoming connection, or request a retry in non-blocking mode.
237.Sh NOTES
238When an accept BIO is at the end of a chain, it will await an
239incoming connection before processing I/O calls.
240When an accept BIO is not at the end of a chain,
241it passes I/O calls to the next BIO in the chain.
242.Pp
243When a connection is established, a new socket BIO is created
244for the connection and appended to the chain.
245That is the chain is now accept->socket.
246This effectively means that attempting I/O on an initial accept
247socket will await an incoming connection then perform I/O on it.
248.Pp
249If any additional BIOs have been set using
250.Fn BIO_set_accept_bios ,
251then they are placed between the socket and the accept BIO;
252that is, the chain will be accept->otherbios->socket.
253.Pp
254If a server wishes to process multiple connections (as is normally
255the case), then the accept BIO must be made available for further
256incoming connections.
257This can be done by waiting for a connection and then calling:
258.Pp
259.Dl connection = BIO_pop(accept);
260.Pp
261After this call,
262.Sy connection
263will contain a BIO for the recently established connection and
264.Sy accept
265will now be a single BIO again which can be used
266to await further incoming connections.
267If no further connections will be accepted, the
268.Sy accept
269can be freed using
270.Xr BIO_free 3 .
271.Pp
272If only a single connection will be processed,
273it is possible to perform I/O using the accept BIO itself.
274This is often undesirable however because the accept BIO
275will still accept additional incoming connections.
276This can be resolved by using
277.Xr BIO_pop 3
278(see above) and freeing up the accept BIO after the initial connection.
279.Pp
280If the underlying accept socket is non-blocking and
281.Fn BIO_do_accept
282is called to await an incoming connection, it is possible for
283.Xr BIO_should_io_special 3
284with the reason
285.Dv BIO_RR_ACCEPT .
286If this happens, then it is an indication that an accept attempt
287would block: the application should take appropriate action
288to wait until the underlying socket has accepted a connection
289and retry the call.
290.Pp
291.Xr BIO_ctrl 3
292.Fa cmd
293and
294.Fa larg
295arguments correspond to macros as follows:
296.Bl -column BIO_C_DO_STATE_MACHINE larg BIO_get_accept_port(3) -offset 3n
297.It Fa cmd No constant Ta Fa larg Ta corresponding macro
298.It Dv BIO_C_DO_STATE_MACHINE Ta 0 Ta Fn BIO_do_accept
299.It Dv BIO_C_GET_ACCEPT Ta 0 Ta Fn BIO_get_accept_port
300.It Dv BIO_C_GET_BIND_MODE Ta 0 Ta Fn BIO_get_bind_mode
301.It Dv BIO_C_GET_FD Ta 0 Ta Xr BIO_get_fd 3
302.It Dv BIO_C_SET_ACCEPT Ta 0 Ta Fn BIO_set_accept_port
303.It Ta 1 Ta Fn BIO_set_nbio_accept
304.It Ta 2 Ta Fn BIO_set_accept_bios
305.It Dv BIO_C_SET_FD Ta Fa fd Ta Xr BIO_set_fd 3
306.It Dv BIO_C_SET_NBIO Ta Fa n Ta Xr BIO_set_nbio 3
307.It Dv BIO_C_SET_BIND_MODE Ta Fa mode Ta Fn BIO_set_bind_mode
308.It Dv BIO_CTRL_GET_CLOSE Ta 0 Ta Xr BIO_get_close 3
309.It Dv BIO_CTRL_RESET Ta 0 Ta Xr BIO_reset 3
310.It Dv BIO_CTRL_SET_CLOSE Ta Fa flag Ta Xr BIO_set_close 3
311.El
312.Sh RETURN VALUES
313When called on an accept BIO object,
314.Xr BIO_method_type 3
315returns the constant
316.Dv BIO_TYPE_ACCEPT
317and
318.Xr BIO_method_name 3
319returns a pointer to the static string
320.Qq socket accept .
321.Pp
322.Fn BIO_do_accept ,
323.Fn BIO_set_accept_port ,
324.Fn BIO_set_nbio_accept ,
325.Fn BIO_set_accept_bios ,
326and
327.Fn BIO_set_bind_mode
328return 1 for success or 0 or -1 for failure.
329.Pp
330.Fn BIO_get_accept_port
331returns the port as a string or
332.Dv NULL
333on error.
334.Pp
335.Fn BIO_get_bind_mode
336returns the set of BIO_BIND flags or -1 on failure.
337.Pp
338.Fn BIO_new_accept
339returns a
340.Vt BIO
341or
342.Dv NULL
343on error.
344.Sh EXAMPLES
345This example accepts two connections on port 4444,
346sends messages down each and finally closes both down.
347.Bd -literal -offset 2n
348BIO *abio, *cbio, *cbio2;
349ERR_load_crypto_strings();
350abio = BIO_new_accept("4444");
351
352/* First call to BIO_accept() sets up accept BIO */
353if (BIO_do_accept(abio) <= 0) {
354 fprintf(stderr, "Error setting up accept\en");
355 ERR_print_errors_fp(stderr);
356 exit(0);
357}
358
359/* Wait for incoming connection */
360if (BIO_do_accept(abio) <= 0) {
361 fprintf(stderr, "Error accepting connection\en");
362 ERR_print_errors_fp(stderr);
363 exit(0);
364}
365fprintf(stderr, "Connection 1 established\en");
366
367/* Retrieve BIO for connection */
368cbio = BIO_pop(abio);
369
370BIO_puts(cbio, "Connection 1: Sending out Data on initial connection\en");
371fprintf(stderr, "Sent out data on connection 1\en");
372
373/* Wait for another connection */
374if (BIO_do_accept(abio) <= 0) {
375 fprintf(stderr, "Error accepting connection\en");
376 ERR_print_errors_fp(stderr);
377 exit(0);
378}
379fprintf(stderr, "Connection 2 established\en");
380
381/* Close accept BIO to refuse further connections */
382cbio2 = BIO_pop(abio);
383BIO_free(abio);
384
385BIO_puts(cbio2, "Connection 2: Sending out Data on second\en");
386fprintf(stderr, "Sent out data on connection 2\en");
387BIO_puts(cbio, "Connection 1: Second connection established\en");
388
389/* Close the two established connections */
390BIO_free(cbio);
391BIO_free(cbio2);
392.Ed
393.Sh SEE ALSO
394.Xr BIO_new 3
395.Sh HISTORY
396.Fn BIO_s_accept ,
397.Fn BIO_set_accept_port ,
398.Fn BIO_new_accept ,
399.Fn BIO_set_accept_bios ,
400and
401.Fn BIO_do_accept
402first appeared in SSLeay 0.8.0.
403.Fn BIO_set_nbio_accept
404and
405.Fn BIO_get_accept_port
406first appeared in SSLeay 0.9.0.
407All these functions have been available since
408.Ox 2.4 .
409.Pp
410.Fn BIO_set_bind_mode
411and
412.Fn BIO_get_bind_mode
413first appeared in SSLeay 0.9.1 and have been available since
414.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/BIO_s_bio.3 b/src/lib/libcrypto/man/BIO_s_bio.3
deleted file mode 100644
index efda019df3..0000000000
--- a/src/lib/libcrypto/man/BIO_s_bio.3
+++ /dev/null
@@ -1,416 +0,0 @@
1.\" $OpenBSD: BIO_s_bio.3,v 1.20 2024/05/19 07:12:50 jsg Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by
5.\" Lutz Jaenicke <Lutz.Jaenicke@aet.TU-Cottbus.DE>,
6.\" Dr. Stephen Henson <steve@openssl.org>,
7.\" Bodo Moeller <bodo@openssl.org>,
8.\" and Richard Levitte <levitte@openssl.org>.
9.\" Copyright (c) 2000, 2002, 2015, 2016 The OpenSSL Project.
10.\" All rights reserved.
11.\"
12.\" Redistribution and use in source and binary forms, with or without
13.\" modification, are permitted provided that the following conditions
14.\" are met:
15.\"
16.\" 1. Redistributions of source code must retain the above copyright
17.\" notice, this list of conditions and the following disclaimer.
18.\"
19.\" 2. Redistributions in binary form must reproduce the above copyright
20.\" notice, this list of conditions and the following disclaimer in
21.\" the documentation and/or other materials provided with the
22.\" distribution.
23.\"
24.\" 3. All advertising materials mentioning features or use of this
25.\" software must display the following acknowledgment:
26.\" "This product includes software developed by the OpenSSL Project
27.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
28.\"
29.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
30.\" endorse or promote products derived from this software without
31.\" prior written permission. For written permission, please contact
32.\" openssl-core@openssl.org.
33.\"
34.\" 5. Products derived from this software may not be called "OpenSSL"
35.\" nor may "OpenSSL" appear in their names without prior written
36.\" permission of the OpenSSL Project.
37.\"
38.\" 6. Redistributions of any form whatsoever must retain the following
39.\" acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
42.\"
43.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
44.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
47.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54.\" OF THE POSSIBILITY OF SUCH DAMAGE.
55.\"
56.Dd $Mdocdate: May 19 2024 $
57.Dt BIO_S_BIO 3
58.Os
59.Sh NAME
60.Nm BIO_s_bio ,
61.Nm BIO_make_bio_pair ,
62.Nm BIO_destroy_bio_pair ,
63.Nm BIO_shutdown_wr ,
64.Nm BIO_set_write_buf_size ,
65.Nm BIO_get_write_buf_size ,
66.Nm BIO_new_bio_pair ,
67.Nm BIO_get_write_guarantee ,
68.Nm BIO_ctrl_get_write_guarantee ,
69.Nm BIO_get_read_request ,
70.Nm BIO_ctrl_get_read_request ,
71.Nm BIO_ctrl_reset_read_request
72.Nd BIO pair BIO
73.Sh SYNOPSIS
74.In openssl/bio.h
75.Ft const BIO_METHOD *
76.Fo BIO_s_bio
77.Fa void
78.Fc
79.Ft int
80.Fo BIO_make_bio_pair
81.Fa "BIO *b1"
82.Fa "BIO *b2"
83.Fc
84.Ft int
85.Fo BIO_destroy_bio_pair
86.Fa "BIO *b"
87.Fc
88.Ft int
89.Fo BIO_shutdown_wr
90.Fa "BIO *b"
91.Fc
92.Ft int
93.Fo BIO_set_write_buf_size
94.Fa "BIO *b"
95.Fa "long size"
96.Fc
97.Ft size_t
98.Fo BIO_get_write_buf_size
99.Fa "BIO *b"
100.Fa "long size"
101.Fc
102.Ft int
103.Fo BIO_new_bio_pair
104.Fa "BIO **bio1"
105.Fa "size_t writebuf1"
106.Fa "BIO **bio2"
107.Fa "size_t writebuf2"
108.Fc
109.Ft int
110.Fo BIO_get_write_guarantee
111.Fa "BIO *b"
112.Fc
113.Ft size_t
114.Fo BIO_ctrl_get_write_guarantee
115.Fa "BIO *b"
116.Fc
117.Ft int
118.Fo BIO_get_read_request
119.Fa "BIO *b"
120.Fc
121.Ft size_t
122.Fo BIO_ctrl_get_read_request
123.Fa "BIO *b"
124.Fc
125.Ft int
126.Fo BIO_ctrl_reset_read_request
127.Fa "BIO *b"
128.Fc
129.Sh DESCRIPTION
130.Fn BIO_s_bio
131returns the method for a BIO pair.
132A BIO pair is a pair of source/sink BIOs where data written to either
133half of the pair is buffered and can be read from the other half.
134Both halves must usually be handled by the same application thread
135since no locking is done on the internal data structures.
136.Pp
137Since BIO chains typically end in a source/sink BIO,
138it is possible to make this one half of a BIO pair and
139have all the data processed by the chain under application control.
140.Pp
141One typical use of BIO pairs is
142to place TLS/SSL I/O under application control.
143This can be used when the application wishes to use a non-standard
144transport for TLS/SSL or the normal socket routines are inappropriate.
145.Pp
146Calls to
147.Xr BIO_read 3
148will read data from the buffer or request a retry if no data is available.
149.Pp
150Calls to
151.Xr BIO_write 3
152will place data in the buffer or request a retry if the buffer is full.
153.Pp
154The standard calls
155.Xr BIO_ctrl_pending 3
156and
157.Xr BIO_ctrl_wpending 3
158can be used to determine the amount of pending data
159in the read or write buffer.
160.Pp
161.Xr BIO_reset 3
162clears any data in the write buffer.
163.Pp
164.Fn BIO_make_bio_pair
165joins two separate BIOs into a connected pair.
166.Pp
167.Fn BIO_destroy_pair
168destroys the association between two connected BIOs.
169Freeing up any half of the pair will automatically destroy the association.
170.Pp
171.Fn BIO_shutdown_wr
172is used to close down a BIO
173.Fa b .
174After this call no further writes on BIO
175.Fa b
176are allowed; they will return an error.
177Reads on the other half of the pair will return any pending data
178or EOF when all pending data has been read.
179.Pp
180.Fn BIO_set_write_buf_size
181sets the write buffer size of BIO
182.Fa b
183to
184.Fa size .
185If the size is not initialized, a default value is used.
186This is currently 17K, sufficient for a maximum size TLS record.
187When a chain containing a BIO pair is copied with
188.Xr BIO_dup_chain 3 ,
189the write buffer size is automatically copied
190from the original BIO object to the new one.
191.Pp
192.Fn BIO_get_write_buf_size
193returns the size of the write buffer.
194.Pp
195.Fn BIO_new_bio_pair
196combines the calls to
197.Xr BIO_new 3 ,
198.Fn BIO_make_bio_pair
199and
200.Fn BIO_set_write_buf_size
201to create a connected pair of BIOs
202.Fa bio1
203and
204.Fa bio2
205with write buffer sizes
206.Fa writebuf1
207and
208.Fa writebuf2 .
209If either size is zero, then the default size is used.
210.Fn BIO_new_bio_pair
211does not check whether
212.Fa bio1
213or
214.Fa bio2
215point to some other BIO; the values are overwritten and
216.Xr BIO_free 3
217is not called.
218.Pp
219.Fn BIO_get_write_guarantee
220and
221.Fn BIO_ctrl_get_write_guarantee
222return the maximum length of data
223that can be currently written to the BIO.
224Writes larger than this value will return a value from
225.Xr BIO_write 3
226less than the amount requested or if the buffer is full request a retry.
227.Fn BIO_ctrl_get_write_guarantee
228is a function whereas
229.Fn BIO_get_write_guarantee
230is a macro.
231.Pp
232.Fn BIO_get_read_request
233and
234.Fn BIO_ctrl_get_read_request
235return the amount of data requested, or the buffer size if it is less,
236if the last read attempt at the other half of the BIO pair failed
237due to an empty buffer.
238This can be used to determine how much data should be
239written to the BIO so the next read will succeed:
240this is most useful in TLS/SSL applications where the amount of
241data read is usually meaningful rather than just a buffer size.
242After a successful read this call will return zero.
243It also will return zero once new data has been written
244satisfying the read request or part of it.
245Note that
246.Fn BIO_get_read_request
247never returns an amount larger than that returned by
248.Fn BIO_get_write_guarantee .
249.Pp
250.Fn BIO_ctrl_reset_read_request
251can also be used to reset the value returned by
252.Fn BIO_get_read_request
253to zero.
254.Pp
255Both halves of a BIO pair should be freed.
256Even if one half is implicitly freed due to a
257.Xr BIO_free_all 3
258or
259.Xr SSL_free 3
260call, the other half still needs to be freed.
261.Pp
262When used in bidirectional applications (such as TLS/SSL),
263care should be taken to flush any data in the write buffer.
264This can be done by calling
265.Xr BIO_pending 3
266on the other half of the pair and, if any data is pending,
267reading it and sending it to the underlying transport.
268This must be done before any normal processing (such as calling
269.Xr select 2 )
270due to a request and
271.Xr BIO_should_read 3
272being true.
273.Pp
274To see why this is important,
275consider a case where a request is sent using
276.Xr BIO_write 3
277and a response read with
278.Xr BIO_read 3 ,
279this can occur during a TLS/SSL handshake for example.
280.Xr BIO_write 3
281will succeed and place data in the write buffer.
282.Xr BIO_read 3
283will initially fail and
284.Xr BIO_should_read 3
285will be true.
286If the application then waits for data to become available
287on the underlying transport before flushing the write buffer,
288it will never succeed because the request was never sent.
289.Pp
290.Xr BIO_eof 3
291is true if no data is in the peer BIO and the peer BIO has been shutdown.
292.Pp
293.Xr BIO_ctrl 3
294.Fa cmd
295arguments correspond to macros as follows:
296.Bl -column BIO_C_GET_WRITE_GUARANTEE BIO_ctrl_reset_read_request() -offset 3n
297.It Fa cmd No constant Ta corresponding macro
298.It Dv BIO_C_DESTROY_BIO_PAIR Ta Fn BIO_destroy_bio_pair
299.It Dv BIO_C_GET_READ_REQUEST Ta Fn BIO_get_read_request
300.It Dv BIO_C_GET_WRITE_BUF_SIZE Ta Fn BIO_get_write_buf_size
301.It Dv BIO_C_GET_WRITE_GUARANTEE Ta Fn BIO_get_write_guarantee
302.It Dv BIO_C_MAKE_BIO_PAIR Ta Fn BIO_make_bio_pair
303.It Dv BIO_C_RESET_READ_REQUEST Ta Fn BIO_ctrl_reset_read_request
304.It Dv BIO_C_SET_WRITE_BUF_SIZE Ta Fn BIO_set_write_buf_size
305.It Dv BIO_C_SHUTDOWN_WR Ta Fn BIO_shutdown_wr
306.It Dv BIO_CTRL_EOF Ta Xr BIO_eof 3
307.It Dv BIO_CTRL_GET_CLOSE Ta Xr BIO_get_close 3
308.It Dv BIO_CTRL_PENDING Ta Xr BIO_pending 3
309.It Dv BIO_CTRL_RESET Ta Xr BIO_reset 3
310.It Dv BIO_CTRL_SET_CLOSE Ta Xr BIO_set_close 3
311.It Dv BIO_CTRL_WPENDING Ta Xr BIO_wpending 3
312.El
313.Sh RETURN VALUES
314.Fn BIO_new_bio_pair
315returns 1 on success, with the new BIOs available in
316.Fa bio1
317and
318.Fa bio2 ,
319or 0 on failure, with NULL pointers stored into the locations for
320.Fa bio1
321and
322.Fa bio2 .
323Check the error stack for more information.
324.Pp
325When called on a BIO pair BIO object,
326.Xr BIO_method_type 3
327returns the constant
328.Dv BIO_TYPE_BIO
329and
330.Xr BIO_method_name 3
331returns a pointer to the static string
332.Qq BIO pair .
333.\" XXX More return values need to be added here.
334.Sh EXAMPLES
335The BIO pair can be used to have full control
336over the network access of an application.
337The application can call
338.Xr select 2
339on the socket as required without having to go through the SSL interface.
340.Bd -literal -offset 2n
341BIO *internal_bio, *network_bio;
342\&...
343BIO_new_bio_pair(&internal_bio, 0, &network_bio, 0);
344SSL_set_bio(ssl, internal_bio, internal_bio);
345SSL_operations(); /* e.g. SSL_read() and SSL_write() */
346\&...
347
348application | TLS-engine
349 | |
350 +----------> SSL_operations()
351 | /\e ||
352 | || \e/
353 | BIO-pair (internal_bio)
354 | BIO-pair (network_bio)
355 | || /\e
356 | \e/ ||
357 +-----------< BIO_operations()
358 | |
359 socket |
360
361\&...
362SSL_free(ssl); /* implicitly frees internal_bio */
363BIO_free(network_bio);
364\&...
365.Ed
366.Pp
367As the BIO pair will only buffer the data and never directly access
368the connection, it behaves non-blocking and will return as soon as
369the write buffer is full or the read buffer is drained.
370Then the application has to flush the write buffer
371and/or fill the read buffer.
372.Pp
373Use
374.Xr BIO_ctrl_pending 3
375to find out whether data is buffered in the BIO
376and must be transferred to the network.
377Use
378.Fn BIO_ctrl_get_read_request
379to find out how many bytes must be written into the buffer before the
380SSL operations can successfully be continued.
381.Sh SEE ALSO
382.Xr BIO_new 3 ,
383.Xr BIO_read 3 ,
384.Xr BIO_should_retry 3 ,
385.Xr ssl 3 ,
386.Xr SSL_set_bio 3
387.Sh HISTORY
388.Fn BIO_s_bio ,
389.Fn BIO_make_bio_pair ,
390.Fn BIO_destroy_bio_pair ,
391.Fn BIO_set_write_buf_size ,
392.Fn BIO_get_write_buf_size ,
393.Fn BIO_new_bio_pair ,
394.Fn BIO_get_write_guarantee ,
395.Fn BIO_ctrl_get_write_guarantee ,
396.Fn BIO_get_read_request ,
397and
398.Fn BIO_ctrl_reset_read_request
399first appeared in OpenSSL 0.9.4 and have been available since
400.Ox 2.6 .
401.Pp
402.Fn BIO_ctrl_reset_read_request
403first appeared in OpenSSL 0.9.5 and has been available since
404.Ox 2.7 .
405.Pp
406.Fn BIO_shutdown_wr
407first appeared in OpenSSL 0.9.6 and has been available since
408.Ox 2.9 .
409.Sh CAVEATS
410As the data is buffered, SSL operations may return with an
411.Dv ERROR_SSL_WANT_READ
412condition, but there is still data in the write buffer.
413An application must not rely on the error value of the SSL operation
414but must assure that the write buffer is always flushed first.
415Otherwise a deadlock may occur as the peer might be waiting
416for the data before being able to continue.
diff --git a/src/lib/libcrypto/man/BIO_s_connect.3 b/src/lib/libcrypto/man/BIO_s_connect.3
deleted file mode 100644
index bce68a26b9..0000000000
--- a/src/lib/libcrypto/man/BIO_s_connect.3
+++ /dev/null
@@ -1,503 +0,0 @@
1.\" $OpenBSD: BIO_s_connect.3,v 1.19 2023/04/30 13:53:54 schwarze Exp $
2.\" full merge up to: OpenSSL 0e474b8b Nov 1 15:45:49 2015 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: April 30 2023 $
69.Dt BIO_S_CONNECT 3
70.Os
71.Sh NAME
72.Nm BIO_s_connect ,
73.Nm BIO_new_connect ,
74.Nm BIO_set_conn_hostname ,
75.Nm BIO_set_conn_port ,
76.Nm BIO_set_conn_ip ,
77.Nm BIO_set_conn_int_port ,
78.Nm BIO_get_conn_hostname ,
79.Nm BIO_get_conn_port ,
80.Nm BIO_get_conn_ip ,
81.Nm BIO_get_conn_int_port ,
82.Nm BIO_set_nbio ,
83.Nm BIO_do_connect
84.Nd connect BIO
85.Sh SYNOPSIS
86.In openssl/bio.h
87.Ft const BIO_METHOD *
88.Fo BIO_s_connect
89.Fa void
90.Fc
91.Ft BIO *
92.Fo BIO_new_connect
93.Fa "const char *name"
94.Fc
95.Ft long
96.Fo BIO_set_conn_hostname
97.Fa "BIO *b"
98.Fa "char *name"
99.Fc
100.Ft long
101.Fo BIO_set_conn_port
102.Fa "BIO *b"
103.Fa "char *port"
104.Fc
105.Ft long
106.Fo BIO_set_conn_ip
107.Fa "BIO *b"
108.Fa "char *ip"
109.Fc
110.Ft long
111.Fo BIO_set_conn_int_port
112.Fa "BIO *b"
113.Fa "char *port"
114.Fc
115.Ft char *
116.Fo BIO_get_conn_hostname
117.Fa "BIO *b"
118.Fc
119.Ft char *
120.Fo BIO_get_conn_port
121.Fa "BIO *b"
122.Fc
123.Ft char *
124.Fo BIO_get_conn_ip
125.Fa "BIO *b"
126.Fc
127.Ft long
128.Fo BIO_get_conn_int_port
129.Fa "BIO *b"
130.Fc
131.Ft long
132.Fo BIO_set_nbio
133.Fa "BIO *b"
134.Fa "long n"
135.Fc
136.Ft long
137.Fo BIO_do_connect
138.Fa "BIO *b"
139.Fc
140.Sh DESCRIPTION
141.Fn BIO_s_connect
142returns the connect BIO method.
143This is a wrapper around the platform's TCP/IP socket connection routines.
144.Pp
145Using connect BIOs, TCP/IP connections can be made and data
146transferred using only BIO routines.
147In this way any platform specific operations
148are hidden by the BIO abstraction.
149.Pp
150Read and write operations on a connect BIO will perform I/O
151on the underlying connection.
152If no connection is established and the port and hostname (see below)
153is set up properly, then a connection is established first.
154.Pp
155Connect BIOs support
156.Xr BIO_puts 3
157but not
158.Xr BIO_gets 3 .
159.Pp
160If the close flag is set on a connect BIO, then any active connection
161is shutdown and the socket closed when the BIO is freed.
162.Pp
163Calling
164.Xr BIO_reset 3
165on a connect BIO will close any active connection and reset the BIO
166into a state where it can connect to the same host again.
167.Pp
168.Xr BIO_get_fd 3
169places the underlying socket in
170.Fa c
171if it is not
172.Dv NULL
173and also returns the socket.
174If
175.Fa c
176is not
177.Dv NULL ,
178it should be of type
179.Vt "int *" .
180.Pp
181.Xr BIO_set_info_callback 3
182and
183.Xr BIO_callback_ctrl 3
184with a
185.Fa cmd
186of
187.Dv BIO_CTRL_SET_CALLBACK
188save the pointer to the
189.Fa cb
190function internally in
191.Fa b
192and
193.Xr BIO_get_info_callback 3
194retrieves this function pointer.
195If such an info callback is installed, it is invoked whenever
196a state change or error occurs in the connect BIO state machine.
197The arguments of the callback include the new
198.Fa state
199in case of a state change or the old
200.Fa state
201in case of an error and the value
202.Fa res
203that the state machine would return to whatever operation invoked it
204if no info callback had been installed.
205If an info callback is installed, the state machine
206returns the return value of the info callback instead.
207Consequently, the info callback is supposed to usually return
208.Fa res .
209The precise effect of the return value depends on which operation
210the state machine was invoked from.
211Usually, \-1 is used to indicate failure and return values less than
212or equal to zero abort the operation in question, whereas positive
213values indicate success and allow the operation to proceed.
214.Pp
215The
216.Fa state
217constants passed to the callback are named according to
218which operation needs to be performed next.
219They are listed here in the order the states are passed through:
220.Pp
221.Bl -tag -width BIO_CONN_S_BLOCKED_CONNECT -offset 3n -compact
222.It Dv BIO_CONN_S_BEFORE
223The BIO is idle and no connection has been initiated yet.
224.It Dv BIO_CONN_S_GET_IP
225The hostname to connect to needs to be converted to an IP address.
226.It Dv BIO_CONN_S_GET_PORT
227The service name to connect to needs to be converted to a TCP port number.
228.It Dv BIO_CONN_S_CREATE_SOCKET
229The TCP socket needs to be created with the
230.Xr socket 2
231system call.
232.It Dv BIO_CONN_S_NBIO
233Socket options may need to be set using
234.Xr fcntl 2
235and
236.Xr setsockopt 2 .
237.It Dv BIO_CONN_S_CONNECT
238The connection needs to be initiated with the
239.Xr connect 2
240system call.
241.It Dv BIO_CONN_S_BLOCKED_CONNECT
242The
243.Xr connect 2
244system call would have blocked and needs to be tried again.
245.It Dv BIO_CONN_S_OK
246The connection has been established and can now be used to transfer data.
247.El
248.Pp
249.Fn BIO_set_conn_hostname
250uses the string
251.Fa name
252to set the hostname.
253The hostname can be an IP address.
254The hostname can also include the port in the form
255.Ar hostname : Ns Ar port .
256It is also acceptable to use the forms
257.Ar hostname Ns / Ns Pa any/other/path
258or
259.Ar hostname : Ns Ar port Ns / Ns Pa any/other/path .
260.Pp
261.Fn BIO_set_conn_port
262sets the port to
263.Fa port .
264.Fa port
265is looked up as a service using
266.Xr getaddrinfo 3 .
267.Pp
268.Fn BIO_set_conn_ip
269sets the IP address to
270.Fa ip
271using binary form i.e. four bytes specifying the IP address
272in big-endian form.
273.Pp
274.Fn BIO_set_conn_int_port
275sets the port using
276.Fa port .
277.Fa port
278should
279be of type
280.Vt "int *" .
281.Pp
282.Fn BIO_get_conn_hostname
283returns the hostname of the connect BIO or
284.Dv NULL
285if the BIO is initialized but no hostname is set.
286This return value is an internal pointer which should not be modified.
287.Pp
288.Fn BIO_get_conn_port
289returns the port as a string.
290This return value is an internal pointer which should not be modified.
291.Pp
292.Fn BIO_get_conn_ip
293returns the IP address in binary form.
294.Pp
295.Fn BIO_get_conn_int_port
296returns the port as an
297.Vt int .
298.Pp
299.Fn BIO_set_nbio
300sets the non-blocking I/O flag to
301.Fa n .
302If
303.Fa n
304is zero then blocking I/O is set.
305If
306.Fa n
307is 1 then non-blocking I/O is set.
308Blocking I/O is the default.
309The call to
310.Fn BIO_set_nbio
311should be made before the connection is established
312because non-blocking I/O is set during the connect process.
313.Pp
314.Fn BIO_new_connect
315combines
316.Xr BIO_new 3
317and
318.Fn BIO_set_conn_hostname
319into a single call.
320It creates a new connect BIO with
321.Fa name .
322.Pp
323.Fn BIO_do_connect
324attempts to connect the supplied BIO.
325It returns 1 if the connection was established successfully.
326A zero or negative value is returned if the connection
327could not be established.
328The call
329.Xr BIO_should_retry 3
330should be used for non-blocking connect BIOs
331to determine if the call should be retried.
332.Pp
333If blocking I/O is set then a non-positive return value from any
334I/O call is caused by an error condition, although a zero return
335will normally mean that the connection was closed.
336.Pp
337If the port name is supplied as part of the host name then this will
338override any value set with
339.Fn BIO_set_conn_port .
340This may be undesirable if the application does not wish to allow
341connection to arbitrary ports.
342This can be avoided by checking for the presence of the
343.Sq \&:
344character in the passed hostname and either indicating an error
345or truncating the string at that point.
346.Pp
347The values returned by
348.Fn BIO_get_conn_hostname ,
349.Fn BIO_get_conn_port ,
350.Fn BIO_get_conn_ip ,
351and
352.Fn BIO_get_conn_int_port
353are updated when a connection attempt is made.
354Before any connection attempt the values returned
355are those set by the application itself.
356.Pp
357Applications do not have to call
358.Fn BIO_do_connect
359but may wish to do so to separate the connection process
360from other I/O processing.
361.Pp
362If non-blocking I/O is set,
363then retries will be requested as appropriate.
364.Pp
365In addition to
366.Xr BIO_should_read 3
367and
368.Xr BIO_should_write 3
369it is also possible for
370.Xr BIO_should_io_special 3
371to be true during the initial connection process with the reason
372.Dv BIO_RR_CONNECT .
373If this is returned, it is an indication
374that a connection attempt would block.
375The application should then take appropriate action to wait
376until the underlying socket has connected and retry the call.
377.Pp
378When a chain containing a connect BIO is copied with
379.Xr BIO_dup_chain 3 ,
380.Fn BIO_set_conn_hostname ,
381.Fn BIO_set_conn_port ,
382.Fn BIO_set_nbio ,
383and
384.Xr BIO_set_info_callback 3
385are called internally to automatically copy the hostname, port,
386non-blocking I/O flag, and info callback from the original BIO object
387to the new one.
388.Pp
389.Xr BIO_ctrl 3
390.Fa cmd
391and
392.Fa larg
393arguments correspond to macros as follows:
394.Bl -column BIO_C_DO_STATE_MACHINE larg BIO_get_conn_hostname(3) -offset 3n
395.It Fa cmd No constant Ta Fa larg Ta corresponding macro
396.It Dv BIO_C_DO_STATE_MACHINE Ta 0 Ta Fn BIO_do_connect
397.It Dv BIO_C_GET_CONNECT Ta 0 Ta Fn BIO_get_conn_hostname
398.It Ta 1 Ta Fn BIO_get_conn_port
399.It Ta 2 Ta Fn BIO_get_conn_ip
400.It Ta 3 Ta Fn BIO_get_conn_int_port
401.It Dv BIO_C_GET_FD Ta 0 Ta Xr BIO_get_fd 3
402.It Dv BIO_C_SET_CONNECT Ta 0 Ta Fn BIO_set_conn_hostname
403.It Ta 1 Ta Fn BIO_set_conn_port
404.It Ta 2 Ta Fn BIO_set_conn_ip
405.It Ta 3 Ta Fn BIO_set_conn_int_port
406.It Dv BIO_C_SET_NBIO Ta Fa n Ta Fn BIO_set_nbio
407.It Dv BIO_CTRL_GET_CLOSE Ta 0 Ta Xr BIO_get_close 3
408.It Dv BIO_CTRL_RESET Ta 0 Ta Xr BIO_reset 3
409.It Dv BIO_CTRL_SET_CLOSE Ta Fa flag Ta Xr BIO_set_close 3
410.El
411.Sh RETURN VALUES
412.Fn BIO_s_connect
413returns the connect BIO method.
414.Pp
415When called on a connect BIO object,
416.Xr BIO_method_type 3
417returns the constant
418.Dv BIO_TYPE_CONNECT
419and
420.Xr BIO_method_name 3
421returns a pointer to the static string
422.Qq socket connect .
423.Pp
424.Xr BIO_get_fd 3
425returns the socket or -1 if the BIO has not been initialized.
426.Pp
427.Fn BIO_set_conn_hostname ,
428.Fn BIO_set_conn_port ,
429.Fn BIO_set_conn_ip ,
430and
431.Fn BIO_set_conn_int_port
432always return 1.
433.Pp
434.Fn BIO_get_conn_hostname
435returns the connected hostname or
436.Dv NULL
437if none is set.
438.Pp
439.Fn BIO_get_conn_port
440returns a string representing the connected port or
441.Dv NULL
442if not set.
443.Pp
444.Fn BIO_get_conn_ip
445returns a pointer to the connected IP address in binary form
446or all zeros if not set.
447.Pp
448.Fn BIO_get_conn_int_port
449returns the connected port or 0 if none was set.
450.Pp
451.Fn BIO_set_nbio
452always returns 1.
453.Pp
454.Fn BIO_do_connect
455returns 1 if the connection was successfully
456established and 0 or -1 if the connection failed.
457.Sh EXAMPLES
458This example connects to a webserver on the local host and attempts
459to retrieve a page and copy the result to standard output.
460.Bd -literal -offset 2n
461BIO *cbio, *out;
462int len;
463char tmpbuf[1024];
464
465ERR_load_crypto_strings();
466cbio = BIO_new_connect("localhost:http");
467out = BIO_new_fp(stdout, BIO_NOCLOSE);
468if (BIO_do_connect(cbio) <= 0) {
469 fprintf(stderr, "Error connecting to server\en");
470 ERR_print_errors_fp(stderr);
471 /* whatever ... */
472}
473BIO_puts(cbio, "GET / HTTP/1.0\en\en");
474for(;;) {
475 len = BIO_read(cbio, tmpbuf, 1024);
476 if (len <= 0)
477 break;
478 BIO_write(out, tmpbuf, len);
479}
480BIO_free(cbio);
481BIO_free(out);
482.Ed
483.Sh SEE ALSO
484.Xr BIO_new 3
485.Sh HISTORY
486.Fn BIO_s_connect ,
487.Fn BIO_new_connect ,
488.Fn BIO_set_nbio ,
489and
490.Fn BIO_do_connect
491first appeared in SSLeay 0.8.0.
492.Fn BIO_set_conn_hostname ,
493.Fn BIO_set_conn_port ,
494.Fn BIO_set_conn_ip ,
495.Fn BIO_set_conn_int_port ,
496.Fn BIO_get_conn_hostname ,
497.Fn BIO_get_conn_port ,
498.Fn BIO_get_conn_ip ,
499and
500.Fn BIO_get_conn_int_port
501first appeared in SSLeay 0.9.0.
502All these functions have been available since
503.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BIO_s_datagram.3 b/src/lib/libcrypto/man/BIO_s_datagram.3
deleted file mode 100644
index 104823e7a7..0000000000
--- a/src/lib/libcrypto/man/BIO_s_datagram.3
+++ /dev/null
@@ -1,573 +0,0 @@
1.\" $OpenBSD: BIO_s_datagram.3,v 1.3 2023/04/28 16:49:00 schwarze Exp $
2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: April 28 2023 $
18.Dt BIO_S_DATAGRAM 3
19.Os
20.Sh NAME
21.Nm BIO_s_datagram ,
22.Nm BIO_new_dgram ,
23.Nm BIO_dgram_set_peer ,
24.Nm BIO_ctrl_dgram_connect ,
25.Nm BIO_dgram_get_peer ,
26.Nm BIO_ctrl_set_connected ,
27.Nm BIO_dgram_recv_timedout ,
28.Nm BIO_dgram_send_timedout ,
29.Nm BIO_dgram_non_fatal_error
30.\" .Nm BIO_CTRL_DGRAM_QUERY_MTU and
31.\" .Nm BIO_CTRL_DGRAM_MTU_DISCOVER are intentionally undocumented.
32.\" They are almost unused, and OpenBSD does not appear to support them.
33.Nd datagram socket BIO
34.Sh SYNOPSIS
35.In openssl/bio.h
36.Ft const BIO_METHOD *
37.Fn BIO_s_datagram void
38.Ft BIO *
39.Fo BIO_new_dgram
40.Fa "int fd"
41.Fa "int close_flag"
42.Fc
43.Ft int
44.Fo BIO_dgram_set_peer
45.Fa "BIO *b"
46.Fa "struct sockaddr *sa"
47.Fc
48.Ft int
49.Fo BIO_ctrl_dgram_connect
50.Fa "BIO *b"
51.Fa "struct sockaddr *sa"
52.Fc
53.Ft int
54.Fo BIO_dgram_get_peer
55.Fa "BIO *b"
56.Fa "struct sockaddr *sa"
57.Fc
58.Ft int
59.Fo BIO_ctrl_set_connected
60.Fa "BIO *b"
61.Fa "long argl"
62.Fa "struct sockaddr *sa"
63.Fc
64.Ft int
65.Fn BIO_dgram_recv_timedout "BIO *b"
66.Ft int
67.Fn BIO_dgram_send_timedout "BIO *b"
68.Ft int
69.Fn BIO_dgram_non_fatal_error "int errnum"
70.Sh DESCRIPTION
71.Fn BIO_s_datagram
72returns the datagram socket BIO method.
73The usual application is to transmit data using the IPv4 or IPv6
74.Xr udp 4
75protocol.
76.Pp
77When called on a datagram socket BIO object,
78.Xr BIO_method_type 3
79returns the constant
80.Dv BIO_TYPE_DGRAM
81and
82.Xr BIO_method_name 3
83returns a pointer to the static string
84.Qq datagram socket .
85.Ss Constructors and destructors
86.Xr BIO_new 3
87allocates a new datagram socket BIO object and initializes all its data
88to zero, including the datagram socket file descriptor, the peer address,
89the init flag that can be retrieved with
90.Xr BIO_get_init 3 ,
91the connected flag, the MTU, and all timeout and error information.
92The reference count and the close flag are set to 1.
93.Pp
94.Fn BIO_new_dgram
95allocates and initializes a new datagram socket BIO object with
96.Xr BIO_new 3 ,
97sets the datagram socket file descriptor and the close flag
98according to its arguments, and sets the init flag to 1.
99.Pp
100If the reference count reaches 0 in
101.Xr BIO_free 3
102and the close and init flags are set,
103.Xr shutdown 2
104and
105.Xr close 2
106are called on the datagram socket file descriptor before freeing the
107storage used by the BIO object.
108.Pp
109When a chain containing a datagram socket BIO is copied with
110.Xr BIO_dup_chain 3 ,
111the datagram socket file descriptor, the init flag, the close flag,
112the flags accessible with
113.Xr BIO_test_flags 3 ,
114and any data that was set with
115.Xr BIO_set_ex_data 3
116are automatically copied from the original BIO object to the new one,
117but the peer address, the connected flag, the MTU and all timeout and
118error information are not copied but instead initialized to zero.
119.Ss Initialization and configuration
120If the close flag is set in
121.Fa b ,
122.Xr BIO_set_fd 3
123clears all flags that are set in
124.Fa b
125and if the init flag was set, it calls
126.Xr shutdown 2
127and
128.Xr close 2
129on the previously assigned file descriptor.
130In any case,
131.Xr BIO_set_fd 3
132then sets the new file descriptor and the new close flag according to
133its arguments and sets the init flag to 1.
134.Pp
135If the init flag is set in
136.Fa b ,
137.Xr BIO_get_fd 3
138returns its datagram socket file descriptor, and unless the
139.Fa c
140argument is a
141.Dv NULL
142pointer, it also stores the file descriptor in
143.Pf * Fa c .
144If the init flag is not set,
145.Xr BIO_get_fd 3
146fails and returns \-1.
147.Pp
148.Xr BIO_set_close 3
149sets the close flag in
150.Fa b
151to the
152.Fa flag
153argument.
154.Xr BIO_get_close 3
155returns the value of the close flag from
156.Fa b .
157.Pp
158For datagram socket BIO objects,
159the shutdown flag is the same flag as the close flag.
160Consequently,
161.Xr BIO_set_shutdown 3
162has the same effect as
163.Xr BIO_set_close 3
164and
165.Xr BIO_get_shutdown 3
166has the same effect as
167.Xr BIO_get_close 3 .
168.Pp
169.Fn BIO_dgram_set_peer
170copies
171.Fa sa
172as the peer address into
173.Fa b .
174.Pp
175.Fn BIO_ctrl_dgram_connect
176does exactly the same as
177.Fn BIO_dgram_set_peer .
178Its name is even more misleading than the name of
179.Fn BIO_ctrl_set_connected .
180In addition to what is said there,
181.Fn BIO_ctrl_dgram_connect
182does not even set the connected flag in
183.Fa b .
184.Pp
185.Fn BIO_dgram_get_peer
186copies the peer address from
187.Fa b
188to
189.Pf * Fa sa .
190Before calling this function, the caller has to make sure
191that the peer address is indeed set in
192.Fa b
193and that sufficient memory is available starting at
194.Fa sa
195to copy a complete
196.Vt struct sockaddr ,
197.Vt struct sockaddr_in ,
198or
199.Vt struct sockaddr_in6
200to that place, depending on which address family
201.Fa b
202is currently used for.
203.Pp
204Unless
205.Fa sa
206is
207.Dv NULL ,
208.Fn BIO_ctrl_set_connected
209sets the connected flag in
210.Fa b
211and copies
212.Fa sa
213as the peer address into
214.Fa b .
215If
216.Fa sa
217is
218.Dv NULL ,
219.Fn BIO_ctrl_set_connected
220clears the connected flag and the peer address in
221.Fa b .
222Considering that communication using a datagram protocol is connectionless,
223the name of this function is misleading.
224It is neither establishing or terminating a connection nor changing
225anything with respect to the state of the datagram socket, but merely
226modifying some purely informational data in the wrapping BIO object.
227The additional
228.Fa argl
229argument is passed through to the callbacks documented in
230.Xr BIO_set_callback 3
231if any such callbacks are installed, but it is otherwise ignored.
232.Pp
233.Xr BIO_ctrl 3
234with a
235.Fa cmd
236of
237.Dv BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT
238interprets the
239.Fa parg
240argument as a pointer to a
241.Vt struct timeval
242and sets the read timeout to the specified absolute UTC time.
243.Pp
244.Xr BIO_ctrl 3
245with a
246.Fa cmd
247of
248.Dv BIO_CTRL_DGRAM_SET_RECV_TIMEOUT ,
249.Dv BIO_CTRL_DGRAM_GET_RECV_TIMEOUT ,
250.Dv BIO_CTRL_DGRAM_SET_SEND_TIMEOUT ,
251or
252.Dv BIO_CTRL_DGRAM_GET_SEND_TIMEOUT
253interprets the
254.Fa parg
255argument as a pointer to a
256.Vt struct timeval
257and calls
258.Xr setsockopt 2
259or
260.Xr getsockopt 2
261on the datagram socket file descriptor of
262.Fa b
263with an argument of
264.Dv SO_RCVTIMEO
265or
266.Dv SO_SNDTIMEO ,
267respectively.
268.Dv BIO_CTRL_DGRAM_SET_RECV_TIMEOUT
269and
270.Dv BIO_CTRL_DGRAM_SET_SEND_TIMEOUT
271return 1 on success,
272.Dv BIO_CTRL_DGRAM_GET_RECV_TIMEOUT
273and
274.Dv BIO_CTRL_DGRAM_GET_SEND_TIMEOUT
275the number of bytes written to
276.Pf * Fa parg .
277All four return \-1 on failure.
278Remember that
279.Xr BIO_read 3
280may actually use a shorter timeout when
281.Dv BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT
282is in effect.
283.Pp
284.Xr BIO_ctrl 3
285with a
286.Fa cmd
287of
288.Dv BIO_CTRL_DGRAM_GET_FALLBACK_MTU
289returns 1232 if the peer address is an IPv6 address that is not IPv4 mapped
290or 548 otherwise.
291Making sure that a peer address is set before issuing this command
292is the responsibility of the caller.
293.Pp
294.Xr BIO_ctrl 3
295with a
296.Fa cmd
297of
298.Dv BIO_CTRL_DGRAM_SET_MTU
299sets the MTU attribute of
300.Fa b
301to the value of the
302.Fa larg
303argument and also returns that argument.
304.Xr BIO_ctrl 3
305with a
306.Fa cmd
307of
308.Dv BIO_CTRL_DGRAM_GET_MTU
309returns the MTU attribute of
310.Fa b
311or 0 if it was not set.
312.Pp
313.Xr BIO_ctrl 3
314with a
315.Fa cmd
316of
317.Dv BIO_CTRL_DGRAM_MTU_EXCEEDED
318returns 1 if the most recent non-fatal failure of
319.Xr BIO_read 3
320or
321.Xr BIO_write 3
322was caused by
323.Er EMSGSIZE
324or 0 otherwise.
325This command also clears the
326.Xr errno 2
327value that was saved internally for this particular purpose, so that
328issuing the same command again will return 0 until the next
329.Er EMSGSIZE
330failure occurs.
331.Pp
332.Fn BIO_dgram_recv_timedout
333and
334.Fn BIO_dgram_send_timedout
335check whether the most recent non-fatal failure of
336.Xr BIO_read 3
337or
338.Xr BIO_write 3
339was caused by
340.Er EAGAIN .
341Despite having different names, both functions do exactly the same,
342and both inspect the most recent non-fatal I/O failure, no matter
343whether it occurred during a receive or send operation.
344Both functions also clear the
345.Xr errno 2
346value that was saved internally for this particular purpose,
347so that calling these functions again will return 0 until the next
348.Er EAGAIN
349failure occurs.
350.Pp
351Datagram socket BIOs do not support
352.Xr BIO_eof 3 ,
353.Xr BIO_get_mem_data 3 ,
354.Xr BIO_pending 3 ,
355.Xr BIO_reset 3 ,
356.Xr BIO_seek 3 ,
357.Xr BIO_tell 3 ,
358and
359.Xr BIO_wpending 3 ,
360and attempting any such operation results in failure
361and returns a value of 0.
362.Pp
363Control commands correspond to accessor functions as follows:
364.Pp
365.Bl -tag -width BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP -compact
366.It Dv BIO_C_GET_FD
367.Xr BIO_get_fd 3
368.It Dv BIO_C_SET_FD
369.Xr BIO_set_fd 3
370.It Dv BIO_CTRL_DGRAM_CONNECT
371.Fn BIO_ctrl_dgram_connect Pq deprecated
372.It Dv BIO_CTRL_DGRAM_GET_PEER
373.Fn BIO_dgram_get_peer
374.It BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP
375.Fn BIO_dgram_recv_timedout
376.It BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP
377.Fn BIO_dgram_send_timedout
378.It Dv BIO_CTRL_DGRAM_SET_CONNECTED
379.Fn BIO_ctrl_set_connected
380.It Dv BIO_CTRL_DGRAM_SET_PEER
381.Fn BIO_dgram_set_peer
382.It Dv BIO_CTRL_GET_CLOSE
383.Xr BIO_get_close 3
384.It Dv BIO_CTRL_SET_CLOSE
385.Xr BIO_set_close 3
386.El
387.Ss Input and output operations
388.Xr BIO_read 3
389attempts to read up to
390.Fa len
391bytes into
392.Fa buf
393from the datagram socket file descriptor using
394.Xr recvfrom 2 .
395If a read timeout is set,
396.Xr setsockopt 2
397is used with an argument of
398.Dv SO_RCVTIMEO
399to temporarily shorten the timeout on the datagram socket during the
400.Xr recvfrom 2
401call such that it returns before the read timeout expires.
402.Pp
403If
404.Xr recvfrom 2
405succeeds and the connected flag is not yet set,
406.Xr BIO_read 3
407also copies the peer address received from
408.Xr recvfrom 2
409into
410.Fa b .
411.Pp
412If
413.Xr recvfrom 2
414is attempted,
415.Xr BIO_read 3
416clears the flags
417.Dv BIO_FLAGS_WRITE
418and
419.Dv BIO_FLAGS_IO_SPECIAL
420in
421.Fa b
422and clears or sets the flags
423.Dv BIO_FLAGS_READ
424and
425.Dv BIO_FLAGS_SHOULD_RETRY
426as appropriate.
427.Pp
428If the connected flag is set in
429.Fa b ,
430.Xr BIO_write 3
431attempts to
432.Xr write 2
433.Fa len
434bytes from
435.Fa buf
436to the datagram socket file descriptor.
437If the connected flag is not set, it attempts to transmit
438.Fa len
439bytes from
440.Fa buf
441to the peer using
442.Xr sendto 2 .
443.Pp
444If
445.Xr write 2
446or
447.Xr sendto 2
448is attempted,
449.Xr BIO_write 3
450clears the flags
451.Dv BIO_FLAGS_READ
452and
453.Dv BIO_FLAGS_IO_SPECIAL
454in
455.Fa b
456and clears or sets the flags
457.Dv BIO_FLAGS_WRITE
458and
459.Dv BIO_FLAGS_SHOULD_RETRY
460as appropriate.
461.Pp
462The effect of
463.Xr BIO_puts 3
464is similar to the effect of
465.Xr BIO_write 3
466with a
467.Fa len
468argument of
469.Fn strlen string .
470.Pp
471Datagram socket BIOs do not support
472.Xr BIO_gets 3 .
473Calling this function fails and returns \-2.
474.Pp
475.Xr BIO_flush 3
476has no effect on a datagram socket BIO.
477It always succeeds and returns 1.
478.Sh RETURN VALUES
479.Fn BIO_s_datagram
480returns the datagram socket BIO method.
481.Pp
482.Fn BIO_new_dgram
483returns a newly allocated datagram socket BIO object or
484.Dv NULL
485on failure.
486.Pp
487.Fn BIO_dgram_set_peer ,
488.Fn BIO_ctrl_dgram_connect ,
489and
490.Fn BIO_ctrl_set_connected
491return 1 on success or a value less than or equal to zero on failure.
492They can only fail if
493.Fa b
494is not a datagram socket BIO object.
495.Pp
496.Fn BIO_dgram_get_peer
497returns the number of bytes copied to
498.Fa sa
499or a value less than or equal to zero on failure.
500It can only fail if
501.Fa b
502is not a datagram socket BIO object.
503.Pp
504.Fn BIO_dgram_recv_timedout
505and
506.Fn BIO_dgram_send_timedout
507return 1 if the most recent non-fatal I/O error was caused by
508.Er EAGAIN
509or 0 otherwise.
510.Pp
511.Fn BIO_dgram_non_fatal_error
512returns 1 if
513.Fa errnum
514is
515.Er EAGAIN ,
516.Er EALREADY ,
517.Er EINPROGRESS ,
518or
519.Er EINTR
520or 0 otherwise, even if
521.Fa errnum
522is 0.
523.Sh SEE ALSO
524.Xr close 2 ,
525.Xr getsockopt 2 ,
526.Xr recvfrom 2 ,
527.Xr sendto 2 ,
528.Xr shutdown 2 ,
529.Xr BIO_ctrl 3 ,
530.Xr BIO_get_init 3 ,
531.Xr BIO_new 3 ,
532.Xr BIO_read 3 ,
533.Xr BIO_s_connect 3 ,
534.Xr BIO_set_fd 3 ,
535.Xr BIO_should_retry 3 ,
536.Xr udp 4
537.Sh HISTORY
538.Fn BIO_s_datagram ,
539.Fn BIO_new_dgram ,
540.Fn BIO_dgram_set_peer ,
541.Fn BIO_ctrl_dgram_connect ,
542.Fn BIO_ctrl_set_connected ,
543.Fn BIO_dgram_recv_timedout ,
544.Fn BIO_dgram_send_timedout ,
545and
546.Fn BIO_dgram_non_fatal_error
547first appeared in OpenSSL 0.9.8 and have been available since
548.Ox 4.5 .
549.Pp
550.Fn BIO_dgram_get_peer
551first appeared in OpenSSL 0.9.8m and has been available since
552.Ox 4.9 .
553.Sh BUGS
554If
555.Xr getsockopt 2
556or
557.Xr setsockopt 2
558fails during
559.Xr BIO_read 3 ,
560the library prints an error message to standard error output
561but otherwise ignores the problem, thus possibly using unintended
562timeout values.
563.Pp
564.Xr BIO_read 3
565and
566.Xr BIO_write 3
567may clear the global variable
568.Xr errno 2
569before attempting the
570.Xr recvfrom 2
571or
572.Xr sendto 2
573system call but may not clear it if they fail before reaching this point.
diff --git a/src/lib/libcrypto/man/BIO_s_fd.3 b/src/lib/libcrypto/man/BIO_s_fd.3
deleted file mode 100644
index 852a06756a..0000000000
--- a/src/lib/libcrypto/man/BIO_s_fd.3
+++ /dev/null
@@ -1,290 +0,0 @@
1.\" $OpenBSD: BIO_s_fd.3,v 1.13 2023/11/16 20:19:23 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: November 16 2023 $
69.Dt BIO_S_FD 3
70.Os
71.Sh NAME
72.Nm BIO_s_fd ,
73.Nm BIO_set_fd ,
74.Nm BIO_get_fd ,
75.Nm BIO_new_fd ,
76.Nm BIO_fd_non_fatal_error ,
77.Nm BIO_fd_should_retry
78.Nd file descriptor BIO
79.Sh SYNOPSIS
80.In openssl/bio.h
81.Ft const BIO_METHOD *
82.Fo BIO_s_fd
83.Fa "void"
84.Fc
85.Ft long
86.Fo BIO_set_fd
87.Fa "BIO *b"
88.Fa "int fd"
89.Fa "long close_flag"
90.Fc
91.Ft long
92.Fo BIO_get_fd
93.Fa "BIO *b"
94.Fa "int *c"
95.Fc
96.Ft BIO *
97.Fo BIO_new_fd
98.Fa "int fd"
99.Fa "int close_flag"
100.Fc
101.Ft int
102.Fn BIO_fd_non_fatal_error "int errnum"
103.Ft int
104.Fn BIO_fd_should_retry "int retval"
105.Sh DESCRIPTION
106.Fn BIO_s_fd
107returns the file descriptor BIO method.
108This is a wrapper around the platform's file descriptor routines such as
109.Xr read 2
110and
111.Xr write 2 .
112.Pp
113.Xr BIO_read 3
114and
115.Xr BIO_write 3
116read or write the underlying descriptor.
117.Xr BIO_puts 3
118is supported but
119.Xr BIO_gets 3
120is not.
121.Pp
122If the close flag is set,
123.Xr close 2
124is called on the underlying file descriptor when the
125.Vt BIO
126is freed.
127.Pp
128.Xr BIO_reset 3
129attempts to set the file pointer to the start of the file using
130.Fn lseek fd 0 0 .
131.Pp
132.Xr BIO_seek 3
133sets the file pointer to position
134.Fa ofs
135from start of file using
136.Fn lseek fd ofs 0 .
137.Pp
138.Xr BIO_tell 3
139returns the current file position by calling
140.Fn lseek fd 0 1 .
141.Pp
142.Fn BIO_set_fd
143sets the file descriptor of
144.Vt BIO
145.Fa b
146to
147.Fa fd
148and the close flag to
149.Fa close_flag .
150.Pp
151.Fn BIO_get_fd
152places the file descriptor in
153.Fa c
154if it is not
155.Dv NULL
156and also returns the file descriptor.
157.Pp
158.Fn BIO_new_fd
159returns a file descriptor BIO using
160.Fa fd
161and
162.Fa close_flag .
163.Pp
164.Fn BIO_fd_non_fatal_error
165determines whether the error status code
166.Fa errnum
167represents a recoverable error.
168.Fn BIO_fd_should_retry
169determines whether a recoverable error occurred by inspecting both
170.Xr errno 2
171and
172.Fa retval ,
173which is supposed to usually be
174the return value of a previously called function like
175.Xr BIO_read 3
176or
177.Xr BIO_write 3 .
178These two functions are mostly used internally; in application code,
179it is usually easier and more robust to use
180.Xr BIO_should_retry 3 ,
181which works for any BIO type.
182.Pp
183The behaviour of
184.Xr BIO_read 3
185and
186.Xr BIO_write 3
187depends on the behavior of the platform's
188.Xr read 2
189and
190.Xr write 2
191calls on the descriptor.
192If the underlying file descriptor is in a non-blocking mode,
193then the BIO will behave in the manner described in the
194.Xr BIO_read 3
195and
196.Xr BIO_should_retry 3
197manual pages.
198.Pp
199File descriptor BIOs should not be used for socket I/O.
200Use socket BIOs instead.
201.Pp
202.Xr BIO_ctrl 3
203.Fa cmd
204arguments correspond to macros as follows:
205.Bl -column BIO_CTRL_GET_CLOSE BIO_get_close(3) -offset 3n
206.It Fa cmd No constant Ta corresponding macro
207.It Dv BIO_C_FILE_SEEK Ta Xr BIO_seek 3
208.It Dv BIO_C_FILE_TELL Ta Xr BIO_tell 3
209.It Dv BIO_C_GET_FD Ta Fn BIO_get_fd
210.It Dv BIO_C_SET_FD Ta Fn BIO_set_fd
211.It Dv BIO_CTRL_GET_CLOSE Ta Xr BIO_get_close 3
212.It Dv BIO_CTRL_RESET Ta Xr BIO_reset 3
213.It Dv BIO_CTRL_SET_CLOSE Ta Xr BIO_set_close 3
214.El
215.Sh RETURN VALUES
216.Fn BIO_s_fd
217returns the file descriptor BIO method.
218.Pp
219When called on a file descriptor BIO object,
220.Xr BIO_method_type 3
221returns the constant
222.Dv BIO_TYPE_FD
223and
224.Xr BIO_method_name 3
225returns a pointer to the static string
226.Qq file descriptor .
227.Pp
228.Fn BIO_set_fd
229always returns 1.
230.Pp
231.Fn BIO_get_fd
232returns the file descriptor or -1 if the
233.Vt BIO
234has not been initialized.
235.Pp
236.Fn BIO_new_fd
237returns the newly allocated
238.Vt BIO
239or
240.Dv NULL
241if an error occurred.
242.Pp
243.Fn BIO_fd_non_fatal_error
244returns 1 if
245.Fa errnum
246is
247.Dv EAGAIN ,
248.Dv EALREADY ,
249.Dv EINPROGRESS ,
250.Dv EINTR ,
251or
252.Dv ENOTCONN
253and 0 otherwise, even if
254.Fa errnum
255is 0.
256.Pp
257.Fn BIO_fd_should_retry
258returns 1 if
259.Fn BIO_fd_non_fatal_error errno
260is 1 and
261.Fa retval
262is either 0 or \-1, or 0 otherwise.
263.Sh EXAMPLES
264This is a file descriptor BIO version of "Hello World":
265.Bd -literal -offset indent
266BIO *out;
267out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE);
268BIO_printf(out, "Hello World\en");
269BIO_free(out);
270.Ed
271.Sh SEE ALSO
272.Xr BIO_new 3 ,
273.Xr BIO_read 3 ,
274.Xr BIO_s_socket 3 ,
275.Xr BIO_seek 3 ,
276.Xr BIO_should_retry 3
277.Sh HISTORY
278.Fn BIO_s_fd ,
279.Fn BIO_set_fd ,
280and
281.Fn BIO_get_fd
282first appeared in SSLeay 0.6.0,
283.Fn BIO_fd_should_retry
284in SSLeay 0.6.5, and
285.Fn BIO_new_fd
286and
287.Fn BIO_fd_non_fatal_error
288in SSLeay 0.8.0.
289All these functions have been available since
290.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BIO_s_file.3 b/src/lib/libcrypto/man/BIO_s_file.3
deleted file mode 100644
index 14950cad13..0000000000
--- a/src/lib/libcrypto/man/BIO_s_file.3
+++ /dev/null
@@ -1,377 +0,0 @@
1.\" $OpenBSD: BIO_s_file.3,v 1.17 2023/11/16 20:19:23 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000, 2010 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: November 16 2023 $
70.Dt BIO_S_FILE 3
71.Os
72.Sh NAME
73.Nm BIO_s_file ,
74.Nm BIO_new_file ,
75.Nm BIO_new_fp ,
76.Nm BIO_set_fp ,
77.Nm BIO_get_fp ,
78.Nm BIO_read_filename ,
79.Nm BIO_write_filename ,
80.Nm BIO_append_filename ,
81.Nm BIO_rw_filename
82.\" Nm BIO_CTRL_SET_FILENAME is unused and intentionally undocumented.
83.Nd FILE BIO
84.Sh SYNOPSIS
85.In openssl/bio.h
86.Ft const BIO_METHOD *
87.Fo BIO_s_file
88.Fa void
89.Fc
90.Ft BIO *
91.Fo BIO_new_file
92.Fa "const char *filename"
93.Fa "const char *mode"
94.Fc
95.Ft BIO *
96.Fo BIO_new_fp
97.Fa "FILE *stream"
98.Fa "int flags"
99.Fc
100.Ft long
101.Fo BIO_set_fp
102.Fa "BIO *b"
103.Fa "FILE *fp"
104.Fa "int flags"
105.Fc
106.Ft long
107.Fo BIO_get_fp
108.Fa "BIO *b"
109.Fa "FILE **fpp"
110.Fc
111.Ft long
112.Fo BIO_read_filename
113.Fa "BIO *b"
114.Fa "char *name"
115.Fc
116.Ft long
117.Fo BIO_write_filename
118.Fa "BIO *b"
119.Fa "char *name"
120.Fc
121.Ft long
122.Fo BIO_append_filename
123.Fa "BIO *b"
124.Fa "char *name"
125.Fc
126.Ft long
127.Fo BIO_rw_filename
128.Fa "BIO *b"
129.Fa "char *name"
130.Fc
131.Sh DESCRIPTION
132.Fn BIO_s_file
133returns the BIO file method.
134As its name implies, it is a wrapper around the stdio
135.Vt FILE
136structure and it is a source/sink BIO.
137.Pp
138Calls to
139.Xr BIO_read 3
140and
141.Xr BIO_write 3
142read and write data to the underlying stream.
143.Xr BIO_gets 3
144and
145.Xr BIO_puts 3
146are supported on file BIOs.
147.Pp
148.Xr BIO_flush 3
149on a file BIO calls the
150.Xr fflush 3
151function on the wrapped stream.
152.Pp
153.Xr BIO_reset 3
154attempts to change the file pointer to the start of file using
155.Fn fseek stream 0 0 .
156.Pp
157.Xr BIO_seek 3
158sets the file pointer to position
159.Fa ofs
160from the start of the file using
161.Fn fseek stream ofs 0 .
162.Pp
163.Xr BIO_eof 3
164calls
165.Xr feof 3 .
166.Pp
167Setting the
168.Dv BIO_CLOSE
169flag calls
170.Xr fclose 3
171on the stream when the BIO is freed.
172.Pp
173.Fn BIO_new_file
174creates a new file BIO with mode
175.Fa mode .
176The meaning of
177.Fa mode
178is the same as for the stdio function
179.Xr fopen 3 .
180The
181.Dv BIO_CLOSE
182flag is set on the returned BIO.
183.Pp
184.Fn BIO_new_fp
185creates a file BIO wrapping
186.Fa stream .
187Flags can be:
188.Dv BIO_CLOSE , BIO_NOCLOSE Pq the close flag ,
189.Dv BIO_FP_TEXT
190(sets the underlying stream to text mode, default is binary:
191this only has any effect under Win32).
192.Pp
193.Fn BIO_set_fp
194sets the file pointer of a file BIO to
195.Fa fp .
196.Fa flags
197has the same meaning as in
198.Fn BIO_new_fp .
199.Pp
200.Fn BIO_get_fp
201retrieves the file pointer of a file BIO.
202.Pp
203.Xr BIO_seek 3
204sets the position pointer to
205.Fa offset
206bytes from the start of file.
207.Pp
208.Xr BIO_tell 3
209returns the value of the position pointer.
210.Pp
211.Fn BIO_read_filename ,
212.Fn BIO_write_filename ,
213.Fn BIO_append_filename ,
214and
215.Fn BIO_rw_filename
216set the file BIO
217.Fa b
218to use file
219.Fa name
220for reading, writing, append or read write respectively.
221.Pp
222When wrapping stdout, stdin, or stderr, the underlying stream
223should not normally be closed, so the
224.Dv BIO_NOCLOSE
225flag should be set.
226.Pp
227Because the file BIO calls the underlying stdio functions, any quirks
228in stdio behaviour will be mirrored by the corresponding BIO.
229.Pp
230On Windows,
231.Fn BIO_new_files
232reserves for the filename argument to be UTF-8 encoded.
233In other words, if you have to make it work in a multi-lingual
234environment, encode file names in UTF-8.
235.Pp
236The following
237.Xr BIO_ctrl 3
238.Fa cmd
239constants correspond to macros:
240.Bl -column BIO_C_GET_FILE_PTR "corresponding macro" -offset 3n
241.It Fa cmd No constant Ta corresponding macro
242.It Dv BIO_C_FILE_SEEK Ta Xr BIO_seek 3
243.It Dv BIO_C_FILE_TELL Ta Xr BIO_tell 3
244.It Dv BIO_C_GET_FILE_PTR Ta Fn BIO_get_fp
245.It Dv BIO_C_SET_FILE_PTR Ta Fn BIO_set_fp
246.It Dv BIO_C_SET_FILENAME Ta various, see below
247.It Dv BIO_CTRL_EOF Ta Xr BIO_eof 3
248.It Dv BIO_CTRL_FLUSH Ta Xr BIO_flush 3
249.It Dv BIO_CTRL_GET_CLOSE Ta Xr BIO_get_close 3
250.It Dv BIO_CTRL_RESET Ta Xr BIO_reset 3
251.It Dv BIO_CTRL_SET_CLOSE Ta Xr BIO_set_close 3
252.El
253.Pp
254The meaning of
255.Dv BIO_C_SET_FILENAME
256depends on the flags passed in the
257.Xr BIO_ctrl 3
258.Fa larg
259argument:
260.Bl -column "BIO_CLOSE | BIO_FP_READ | BIO_FP_WRITE" "BIO_append_filename()"\
261 -offset 3n
262.It Fa larg No argument Ta corresponding macro
263.It Dv BIO_CLOSE | BIO_FP_READ Ta Fn BIO_read_filename
264.It Dv BIO_CLOSE | BIO_FP_WRITE Ta Fn BIO_write_filename
265.It Dv BIO_CLOSE | BIO_FP_APPEND Ta Fn BIO_append_filename
266.It Dv BIO_CLOSE | BIO_FP_READ | BIO_FP_WRITE Ta Fn BIO_rw_filename
267.El
268.Sh RETURN VALUES
269.Fn BIO_s_file
270returns the file BIO method.
271.Pp
272.Fn BIO_new_file
273and
274.Fn BIO_new_fp
275return a file BIO or
276.Dv NULL
277if an error occurred.
278.Pp
279When called on a file BIO object,
280.Xr BIO_method_type 3
281returns the constant
282.Dv BIO_TYPE_FILE
283and
284.Xr BIO_method_name 3
285returns a pointer to the static string
286.Qq FILE pointer .
287.Pp
288.Fn BIO_set_fp
289and
290.Fn BIO_get_fp
291return 1 for success or 0 for failure (although the current
292implementation never returns 0).
293.Pp
294.Xr BIO_seek 3
295returns the same value as the underlying
296.Xr fseek 3
297function: 0 for success or -1 for failure.
298.Pp
299.Xr BIO_tell 3
300returns the current file position.
301.Pp
302.Fn BIO_read_filename ,
303.Fn BIO_write_filename ,
304.Fn BIO_append_filename ,
305and
306.Fn BIO_rw_filename
307return 1 for success or 0 for failure.
308.Sh EXAMPLES
309File BIO "hello world":
310.Bd -literal -offset indent
311BIO *bio_out;
312bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
313BIO_printf(bio_out, "Hello World\en");
314.Ed
315.Pp
316Alternative technique:
317.Bd -literal -offset indent
318BIO *bio_out;
319bio_out = BIO_new(BIO_s_file());
320if(bio_out == NULL) /* Error ... */
321if(!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error ... */
322BIO_printf(bio_out, "Hello World\en");
323.Ed
324.Pp
325Write to a file:
326.Bd -literal -offset indent
327BIO *out;
328out = BIO_new_file("filename.txt", "w");
329if(!out) /* Error occurred */
330BIO_printf(out, "Hello World\en");
331BIO_free(out);
332.Ed
333.Pp
334Alternative technique:
335.Bd -literal -offset indent
336BIO *out;
337out = BIO_new(BIO_s_file());
338if(out == NULL) /* Error ... */
339if(!BIO_write_filename(out, "filename.txt")) /* Error ... */
340BIO_printf(out, "Hello World\en");
341BIO_free(out);
342.Ed
343.Sh SEE ALSO
344.Xr BIO_new 3 ,
345.Xr BIO_read 3 ,
346.Xr BIO_seek 3
347.Sh HISTORY
348.Fn BIO_s_file ,
349.Fn BIO_set_fp ,
350.Fn BIO_get_fp ,
351.Fn BIO_read_filename ,
352.Fn BIO_write_filename ,
353and
354.Fn BIO_append_filename
355first appeared in SSLeay 0.6.0.
356.Fn BIO_new_file
357and
358.Fn BIO_new_fp
359first appeared in SSLeay 0.8.0.
360All these functions have been available since
361.Ox 2.4 .
362.Pp
363.Fn BIO_rw_filename
364first appeared in SSLeay 0.9.1 and has been available since
365.Ox 2.6 .
366.Sh BUGS
367.Xr BIO_reset 3
368and
369.Xr BIO_seek 3
370are implemented using
371.Xr fseek 3
372on the underlying stream.
373The return value for
374.Xr fseek 3
375is 0 for success or -1 if an error occurred.
376This differs from other types of BIO which will typically return
3771 for success and a non-positive value if an error occurred.
diff --git a/src/lib/libcrypto/man/BIO_s_mem.3 b/src/lib/libcrypto/man/BIO_s_mem.3
deleted file mode 100644
index d7bbf6af43..0000000000
--- a/src/lib/libcrypto/man/BIO_s_mem.3
+++ /dev/null
@@ -1,306 +0,0 @@
1.\" $OpenBSD: BIO_s_mem.3,v 1.19 2023/11/16 20:19:23 schwarze Exp $
2.\" full merge up to: OpenSSL 8711efb4 Mon Apr 20 11:33:12 2009 +0000
3.\" selective merge up to: OpenSSL 36359cec Mar 7 14:37:23 2018 +0100
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: November 16 2023 $
53.Dt BIO_S_MEM 3
54.Os
55.Sh NAME
56.Nm BIO_s_mem ,
57.Nm BIO_set_mem_eof_return ,
58.Nm BIO_get_mem_data ,
59.Nm BIO_set_mem_buf ,
60.Nm BIO_get_mem_ptr ,
61.Nm BIO_new_mem_buf
62.Nd memory BIO
63.Sh SYNOPSIS
64.In openssl/bio.h
65.Ft const BIO_METHOD *
66.Fo BIO_s_mem
67.Fa "void"
68.Fc
69.Ft long
70.Fo BIO_set_mem_eof_return
71.Fa "BIO *b"
72.Fa "int v"
73.Fc
74.Ft long
75.Fo BIO_get_mem_data
76.Fa "BIO *b"
77.Fa "char **pp"
78.Fc
79.Ft long
80.Fo BIO_set_mem_buf
81.Fa "BIO *b"
82.Fa "BUF_MEM *bm"
83.Fa "int c"
84.Fc
85.Ft long
86.Fo BIO_get_mem_ptr
87.Fa "BIO *b"
88.Fa "BUF_MEM **pp"
89.Fc
90.Ft BIO *
91.Fo BIO_new_mem_buf
92.Fa "const void *buf"
93.Fa "int len"
94.Fc
95.Sh DESCRIPTION
96.Fn BIO_s_mem
97returns the memory BIO method function.
98.Pp
99A memory BIO is a source/sink BIO which uses memory for its I/O.
100Data written to a memory BIO is stored in a
101.Vt BUF_MEM
102structure which is extended as appropriate to accommodate the stored data.
103.Pp
104Any data written to a memory BIO can be recalled by reading from it.
105Unless the memory BIO is read only,
106any data read from it is deleted from the BIO.
107To find out whether a memory BIO is read only,
108.Xr BIO_test_flags 3
109can be called with an argument of
110.Dv BIO_FLAGS_MEM_RDONLY .
111.Pp
112Memory BIOs support
113.Xr BIO_gets 3
114and
115.Xr BIO_puts 3 .
116.Pp
117If the
118.Dv BIO_CLOSE
119flag is set when a memory BIO is freed, the underlying
120.Dv BUF_MEM
121structure is also freed.
122.Pp
123Calling
124.Xr BIO_reset 3
125on a read/write memory BIO clears any data in it.
126On a read only BIO it restores the BIO to its original state
127and the read only data can be read again.
128.Pp
129.Xr BIO_eof 3
130is true if no data is in the BIO.
131.Pp
132.Xr BIO_ctrl_pending 3
133returns the number of bytes currently stored.
134.Pp
135.Fn BIO_set_mem_eof_return
136sets the behaviour of memory BIO
137.Fa b
138when it is empty.
139If
140.Fa v
141is zero, then an empty memory BIO will return EOF:
142it will return zero and
143.Fn BIO_should_retry
144will be false.
145If
146.Fa v
147is non-zero then it will return
148.Fa v
149when it is empty and it will set the read retry flag:
150.Fn BIO_read_retry
151is true.
152To avoid ambiguity with a normal positive return value
153.Fa v
154should be set to a negative value, typically -1.
155.Pp
156.Fn BIO_get_mem_data
157sets
158.Pf * Fa pp
159to a pointer to the start of the memory BIO's data
160and returns the total amount of data available.
161.Pp
162.Fn BIO_set_mem_buf
163sets the internal BUF_MEM structure to
164.Fa bm
165and sets the close flag to
166.Fa c .
167That is,
168.Fa c
169should be either
170.Dv BIO_CLOSE
171or
172.Dv BIO_NOCLOSE .
173.Pp
174.Fn BIO_get_mem_ptr
175places the underlying
176.Vt BUF_MEM
177structure in
178.Pf * Fa pp .
179.Pp
180.Fn BIO_new_mem_buf
181creates a memory BIO using
182.Fa len
183bytes of data at
184.Fa buf .
185If
186.Fa len
187is -1, then
188.Fa buf
189is assumed to be NUL terminated and its length is determined by
190.Xr strlen 3 .
191The BIO is set to a read only state and as a result cannot be written to.
192This is useful when some data needs to be made available
193from a static area of memory in the form of a BIO.
194The supplied data is read directly from the supplied buffer:
195it is
196.Em not
197copied first, so the supplied area of memory must be unchanged
198until the BIO is freed.
199.Pp
200Writes to memory BIOs will always succeed if memory is available:
201their size can grow indefinitely.
202.Pp
203.Xr BIO_ctrl 3
204.Fa cmd
205arguments correspond to macros as follows:
206.Bl -column BIO_C_SET_BUF_MEM_EOF_RETURN BIO_set_mem_eof_return() -offset 3n
207.It Fa cmd No constant Ta corresponding macro
208.It Dv BIO_C_GET_BUF_MEM_PTR Ta Fn BIO_get_mem_ptr
209.It Dv BIO_C_SET_BUF_MEM Ta Fn BIO_set_mem_buf
210.It Dv BIO_C_SET_BUF_MEM_EOF_RETURN Ta Fn BIO_set_mem_eof_return
211.It Dv BIO_CTRL_EOF Ta Xr BIO_eof 3
212.It Dv BIO_CTRL_GET_CLOSE Ta Xr BIO_get_close 3
213.It Dv BIO_CTRL_INFO Ta Fn BIO_get_mem_data
214.It Dv BIO_CTRL_PENDING Ta Xr BIO_pending 3
215.It Dv BIO_CTRL_RESET Ta Xr BIO_reset 3
216.It Dv BIO_CTRL_SET_CLOSE Ta Xr BIO_set_close 3
217.It Dv BIO_CTRL_WPENDING Ta Xr BIO_wpending 3
218.El
219.Sh RETURN VALUES
220.Fn BIO_s_mem
221returns a pointer to a static object.
222.Pp
223When called on a memory BIO object,
224.Xr BIO_method_type 3
225returns the constant
226.Dv BIO_TYPE_MEM
227and
228.Xr BIO_method_name 3
229returns a pointer to the static string
230.Qq memory buffer .
231.Pp
232.Fn BIO_set_mem_eof_return ,
233.Fn BIO_get_mem_data ,
234.Fn BIO_set_mem_buf ,
235and
236.Fn BIO_get_mem_ptr
237return 1 on success or a value less than or equal to 0 if an error occurred.
238.Pp
239.Fn BIO_new_mem_buf
240returns a newly allocated
241.Vt BIO
242object on success or
243.Dv NULL
244on error.
245.Sh EXAMPLES
246Create a memory BIO and write some data to it:
247.Bd -literal -offset indent
248BIO *mem = BIO_new(BIO_s_mem());
249BIO_puts(mem, "Hello World\en");
250.Ed
251.Pp
252Create a read only memory BIO:
253.Bd -literal -offset indent
254char data[] = "Hello World";
255BIO *mem;
256mem = BIO_new_mem_buf(data, -1);
257.Ed
258.Pp
259Extract the
260.Vt BUF_MEM
261structure from a memory BIO and then free up the BIO:
262.Bd -literal -offset indent
263BUF_MEM *bptr;
264BIO_get_mem_ptr(mem, &bptr);
265/* Make sure BIO_free() leaves BUF_MEM alone. */
266BIO_set_close(mem, BIO_NOCLOSE);
267BIO_free(mem);
268.Ed
269.Sh SEE ALSO
270.Xr BIO_new 3 ,
271.Xr BUF_MEM_new 3
272.Sh HISTORY
273.Fn BIO_s_mem
274first appeared in SSLeay 0.6.0.
275.Fn BIO_set_mem_buf
276and
277.Fn BIO_get_mem_ptr
278first appeared in SSLeay 0.6.5.
279These functions have been available since
280.Ox 2.4 .
281.Pp
282.Fn BIO_set_mem_eof_return
283and
284.Fn BIO_get_mem_data
285first appeared in SSLeay 0.9.1 and have been available since
286.Ox 2.6 .
287.Pp
288.Fn BIO_new_mem_buf
289first appeared in OpenSSL 0.9.5 and has been available since
290.Ox 2.7 .
291.Sh CAVEATS
292Do not manually switch a writable memory BIO to read-only mode: calling
293.Xr BIO_set_flags 3
294with an argument of
295.Dv BIO_FLAGS_MEM_RDONLY
296will ultimately result in a memory leak when the BIO object is
297finally handed to
298.Xr BIO_free 3 .
299It might also cause security issues because it prevents
300.Xr BIO_reset 3
301from clearing the data.
302.Sh BUGS
303There should be an option to set the maximum size of a memory BIO.
304.Pp
305There should be a way to "rewind" a read/write BIO without destroying
306its contents.
diff --git a/src/lib/libcrypto/man/BIO_s_null.3 b/src/lib/libcrypto/man/BIO_s_null.3
deleted file mode 100644
index 6e7cad6d37..0000000000
--- a/src/lib/libcrypto/man/BIO_s_null.3
+++ /dev/null
@@ -1,101 +0,0 @@
1.\" $OpenBSD: BIO_s_null.3,v 1.10 2023/04/11 16:58:43 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: April 11 2023 $
52.Dt BIO_S_NULL 3
53.Os
54.Sh NAME
55.Nm BIO_s_null
56.\" .Nm BIO_s_log is intentionally undocumented because it is unused
57.Nd null data sink
58.Sh SYNOPSIS
59.In openssl/bio.h
60.Ft const BIO_METHOD *
61.Fo BIO_s_null
62.Fa void
63.Fc
64.Sh DESCRIPTION
65.Fn BIO_s_null
66returns the null sink BIO method.
67Data written to the null sink is discarded, reads return EOF.
68.Pp
69A null sink BIO behaves in a similar manner to the
70.Xr null 4
71device.
72.Pp
73A null BIO can be placed on the end of a chain to discard any data
74passed through it.
75.Pp
76A null sink is useful if, for example, an application wishes
77to digest some data by writing through a digest bio
78but not send the digested data anywhere.
79Since a BIO chain must normally include a source/sink BIO,
80this can be achieved by adding a null sink BIO to the end of the chain.
81.Sh RETURN VALUES
82.Fn BIO_s_null
83returns the null sink BIO method.
84.Pp
85When called on a null sink BIO object,
86.Xr BIO_method_type 3
87returns the constant
88.Dv BIO_TYPE_NULL
89and
90.Xr BIO_method_name 3
91returns a pointer to the static string
92.Qq NULL ,
93not to be confused with a NUL string nor with a
94.Dv NULL
95pointer.
96.Sh SEE ALSO
97.Xr BIO_new 3
98.Sh HISTORY
99.Fn BIO_s_null
100first appeared in SSLeay 0.6.0 and has been available since
101.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BIO_s_socket.3 b/src/lib/libcrypto/man/BIO_s_socket.3
deleted file mode 100644
index 402622b3bd..0000000000
--- a/src/lib/libcrypto/man/BIO_s_socket.3
+++ /dev/null
@@ -1,125 +0,0 @@
1.\" $OpenBSD: BIO_s_socket.3,v 1.10 2023/04/11 16:58:43 schwarze Exp $
2.\" OpenSSL bbdc9c98 Oct 19 22:02:21 2000 +0000
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: April 11 2023 $
52.Dt BIO_S_SOCKET 3
53.Os
54.Sh NAME
55.Nm BIO_s_socket ,
56.Nm BIO_new_socket
57.Nd socket BIO
58.Sh SYNOPSIS
59.In openssl/bio.h
60.Ft const BIO_METHOD *
61.Fo BIO_s_socket
62.Fa void
63.Fc
64.Ft BIO *
65.Fo BIO_new_socket
66.Fa "int sock"
67.Fa "int close_flag"
68.Fc
69.Sh DESCRIPTION
70.Fn BIO_s_socket
71returns the socket BIO method.
72This is a wrapper around the platform's socket routines.
73.Pp
74.Xr BIO_read 3
75and
76.Xr BIO_write 3
77read or write the underlying socket.
78.Xr BIO_puts 3
79is supported but
80.Xr BIO_gets 3
81is not.
82.Pp
83If the close flag is set, then the socket is shut down and closed
84when the BIO is freed.
85.Pp
86.Fn BIO_new_socket
87returns a socket BIO using
88.Fa sock
89and
90.Fa close_flag .
91.Pp
92Socket BIOs also support any relevant functionality of file descriptor BIOs.
93.Pp
94The reason for having separate file descriptor and socket BIOs
95is that on some platforms, sockets are not file descriptors
96and use distinct I/O routines.
97Windows is one such platform.
98Any code mixing the two will not work on all platforms.
99.Sh RETURN VALUES
100.Fn BIO_s_socket
101returns the socket BIO method.
102.Pp
103.Fn BIO_new_socket
104returns the newly allocated BIO or
105.Dv NULL
106if an error occurred.
107.Pp
108When called on a socket BIO object,
109.Xr BIO_method_type 3
110returns the constant
111.Dv BIO_TYPE_SOCKET
112and
113.Xr BIO_method_name 3
114returns a pointer to the static string
115.Qq socket .
116.Sh SEE ALSO
117.Xr BIO_get_fd 3 ,
118.Xr BIO_new 3
119.Sh HISTORY
120.Fn BIO_s_socket
121first appeared in SSLeay 0.6.0.
122.Fn BIO_new_socket
123first appeared in SSLeay 0.8.0.
124Both functions have been available since
125.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BIO_set_callback.3 b/src/lib/libcrypto/man/BIO_set_callback.3
deleted file mode 100644
index 56a0102be6..0000000000
--- a/src/lib/libcrypto/man/BIO_set_callback.3
+++ /dev/null
@@ -1,396 +0,0 @@
1.\" $OpenBSD: BIO_set_callback.3,v 1.12 2023/04/30 13:57:29 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018, 2022 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2000, 2016, 2017 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: April 30 2023 $
69.Dt BIO_SET_CALLBACK 3
70.Os
71.Sh NAME
72.Nm BIO_callback_fn_ex ,
73.Nm BIO_set_callback_ex ,
74.Nm BIO_get_callback_ex ,
75.Nm BIO_callback_fn ,
76.Nm BIO_set_callback ,
77.Nm BIO_get_callback ,
78.Nm BIO_set_callback_arg ,
79.Nm BIO_get_callback_arg ,
80.Nm BIO_debug_callback
81.\" The following three macros are intentionally undocumented because
82.\" they are unused and would only cause obfuscation if they were used.
83.\" .Nm BIO_CB_return
84.\" .Nm BIO_cb_pre
85.\" .Nm BIO_cb_post
86.Nd BIO callback functions
87.Sh SYNOPSIS
88.In openssl/bio.h
89.Ft typedef long
90.Fo (*BIO_callback_fn_ex)
91.Fa "BIO *b"
92.Fa "int oper"
93.Fa "const char *argp"
94.Fa "size_t len"
95.Fa "int argi"
96.Fa "long argl"
97.Fa "int ret"
98.Fa "size_t *processed"
99.Fc
100.Ft void
101.Fo BIO_set_callback_ex
102.Fa "BIO *b"
103.Fa "BIO_callback_fn_ex cb_ex"
104.Fc
105.Ft BIO_callback_fn_ex
106.Fo BIO_get_callback_ex
107.Fa "const BIO *b"
108.Fc
109.Ft typedef long
110.Fo (*BIO_callback_fn)
111.Fa "BIO *b"
112.Fa "int oper"
113.Fa "const char *argp"
114.Fa "int argi"
115.Fa "long argl"
116.Fa "long ret"
117.Fc
118.Ft void
119.Fo BIO_set_callback
120.Fa "BIO *b"
121.Fa "BIO_callback_fn cb"
122.Fc
123.Ft BIO_callback_fn
124.Fo BIO_get_callback
125.Fa "BIO *b"
126.Fc
127.Ft void
128.Fo BIO_set_callback_arg
129.Fa "BIO *b"
130.Fa "char *pointer"
131.Fc
132.Ft char *
133.Fo BIO_get_callback_arg
134.Fa "const BIO *b"
135.Fc
136.Ft long
137.Fo BIO_debug_callback
138.Fa "BIO *bio"
139.Fa "int oper"
140.Fa "const char *argp"
141.Fa "int argi"
142.Fa "long argl"
143.Fa "long ret"
144.Fc
145.Sh DESCRIPTION
146.Fn BIO_set_callback_ex
147and
148.Fn BIO_get_callback_ex
149set and retrieve the BIO callback.
150The callback is called during most high-level BIO operations.
151It can be used for debugging purposes to trace operations on a BIO
152or to modify its operation.
153.Pp
154.Fn BIO_set_callback
155and
156.Fn BIO_get_callback
157are deprecated functions that set and retrieve the old-style BIO callback,
158which is only used if no new-style callback is set with
159.Fn BIO_set_callback_ex .
160.Pp
161.Fn BIO_set_callback_arg
162stores the
163.Fa pointer
164internally in
165.Fa b
166and
167.Fn BIO_get_callback_arg
168retrieves it from
169.Fa b .
170The name of these two functions is badly misleading: the
171.Fa pointer
172is never passed as an argument to any callback function.
173But of course, callback functions can call
174.Fn BIO_get_callback_arg
175and access the pointer, just like any other code can.
176.Pp
177.Fn BIO_debug_callback
178is a standard debugging callback which prints
179out information related to each BIO operation.
180If
181.Fn BIO_set_callback_arg
182was called with a
183.Pf non- Dv NULL
184argument, information is sent to the BIO pointed to by the
185.Fa pointer ;
186otherwise, standard error output is used.
187.Pp
188The arguments of the callback functions are as follows:
189.Bl -tag -width Ds
190.It Fa b
191The BIO the callback is attached to.
192.It Fa oper
193The operation being performed, which is one of
194.Dv BIO_CB_CTRL ,
195.Dv BIO_CB_FREE ,
196.Dv BIO_CB_GETS ,
197.Dv BIO_CB_PUTS ,
198.Dv BIO_CB_READ ,
199or
200.Dv BIO_CB_WRITE .
201For some operations, the callback is called twice,
202once before and once after the actual operation.
203The latter case has
204.Fa oper
205OR'ed with
206.Dv BIO_CB_RETURN .
207.It Fa argp , argi , argl
208The meaning of these three arguments depends on the value of
209.Fa oper ,
210that is on the operation being performed.
211.It Fa len
212The length of the data requested to be read or written.
213This is only useful if
214.Fa oper
215is
216.Dv BIO_CB_READ ,
217.Dv BIO_CB_WRITE ,
218or
219.Dv BIO_CB_GETS .
220.It Fa ret
221When
222.Fa oper
223does not include
224.Dv BIO_CB_RETURN ,
225i.e. when the callback is invoked before an operation,
226the value passed into the callback via
227.Fa ret
228is always 1.
229In this case, if the callback returns a negative value, the library
230aborts the requested operation and instead returns the negative
231return value from the callback to the application.
232If the callback returns a non-negative value, that return value is
233ignored by the library, and the operation is performed normally.
234.Pp
235When
236.Fa oper
237includes
238.Dv BIO_CB_RETURN ,
239i.e. when the callback is invoked after an operation,
240the value passed into the callback via
241.Fa ret
242is the return value that the operation would return to the application
243if no callback were present.
244When a callback is present, the operation only passes this value
245to the callback and instead of it returns the return value of the
246callback to the application.
247.It Fa processed
248The location pointed to is updated with the number of bytes
249actually read or written.
250Only used for
251.Dv BIO_CB_READ ,
252.Dv BIO_CB_WRITE ,
253.Dv BIO_CB_GETS ,
254and
255.Dv BIO_CB_PUTS .
256.El
257.Pp
258The callback should normally simply return
259.Fa ret
260when it has finished processing, unless it specifically wishes to
261abort the operation or to modify the value returned to the application.
262.Pp
263The callbacks are called as follows:
264.Bl -tag -width 1n
265.It \&In Fn BIO_free "BIO *b" :
266.Bd -literal
267before the free operation:
268cb_ex(b, BIO_CB_FREE, NULL, 0, 0, 0, 1, NULL)
269or cb(b, BIO_CB_FREE, NULL, 0, 0, 1)
270.Ed
271.It \&In Fn BIO_read "BIO *b" "void *out" "int outl" :
272.Bd -literal
273before the read operation:
274cb_ex(b, BIO_CB_READ, out, outl, 0, 0, 1, NULL)
275or cb(b, BIO_CB_READ, out, outl, 0, 1)
276
277after the read operation:
278cb_ex(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0, 0, ret, &bytes)
279or cb(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0, ret)
280.Ed
281.It \&In Fn BIO_write "BIO *b" "const void *in" "int inl" :
282.Bd -literal
283before the write operation:
284cb_ex(b, BIO_CB_WRITE, in, inl, 0, 0, 1, NULL)
285or cb(b, BIO_CB_WRITE, in, inl, 0, 1)
286
287after the write operation:
288cb_ex(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0, 0, ret, &bytes)
289or cb(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0, ret)
290.Ed
291.It \&In Fn BIO_gets "BIO *b" "char *out" "int outl" :
292.Bd -literal
293before the read operation:
294cb_ex(b, BIO_CB_GETS, out, outl, 0, 0, 1, NULL)
295or cb(b, BIO_CB_GETS, out, outl, 0, 1)
296
297after the read operation:
298cb_ex(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0, 0, ret, &bytes)
299or cb(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0, ret)
300.Ed
301.It \&In Fn BIO_puts "BIO *b" "const char *in" :
302.Bd -literal
303before the write operation:
304cb_ex(b, BIO_CB_PUTS, in, 0, 0, 0, 1, NULL)
305or cb(b, BIO_CB_PUTS, in, 0, 0, 1)
306
307after the write operation:
308cb_ex(b, BIO_CB_PUTS|BIO_CB_RETURN, in, 0, 0, 0, ret, &bytes)
309or cb(b, BIO_CB_PUTS|BIO_CB_RETURN, in, 0, 0, ret)
310.Ed
311.It \&In Fn BIO_ctrl "BIO *b" "int cmd" "long larg" "void *parg" :
312.Bd -literal
313before the control operation:
314cb_ex(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1, NULL)
315or cb(b, BIO_CB_CTRL, parg, cmd, larg, 1)
316
317after the control operation:
318cb_ex(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, 0, cmd, larg, ret, NULL)
319or cb(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, cmd, larg, ret)
320.Ed
321.It \&In Fn BIO_callback_ctrl "BIO *b" "int cmd" "BIO_info_cb *fp" :
322.Bd -literal
323before the control operation:
324cb_ex(b, BIO_CB_CTRL, fp, 0, cmd, 0, 1, NULL)
325or cb(b, BIO_CB_CTRL, fp, cmd, 0, 1)
326
327after the control operation:
328cb_ex(b, BIO_CB_CTRL|BIO_CB_RETURN, fp, 0, cmd, 0, ret, NULL)
329or cb(b, BIO_CB_CTRL|BIO_CB_RETURN, fp, cmd, 0, ret)
330.Ed
331.El
332.Sh RETURN VALUES
333.Fn BIO_get_callback_ex
334returns a pointer to the function
335.Fa cb_ex
336previously installed with
337.Fn BIO_set_callback_cb ,
338or
339.Dv NULL
340if no such callback was installed.
341.Pp
342.Fn BIO_get_callback
343returns a pointer to the function
344.Fa cb
345previously installed with
346.Fn BIO_set_callback ,
347or
348.Dv NULL
349if no such callback was installed.
350.Pp
351.Fn BIO_get_callback_arg
352returns the
353.Fa pointer
354previously set with
355.Fn BIO_set_callback_arg ,
356or
357.Dv NULL
358if no such pointer was set.
359.Pp
360.Fn BIO_debug_callback
361returns
362.Fa ret
363if the bit
364.Dv BIO_CB_RETURN
365is set in
366.Fa cmd ,
367or 1 otherwise.
368.Sh EXAMPLES
369The
370.Fn BIO_debug_callback
371function is a good example.
372Its source is in the file
373.Pa crypto/bio/bio_cb.c .
374.Sh SEE ALSO
375.Xr BIO_new 3
376.Sh HISTORY
377.Fn BIO_set_callback ,
378.Fn BIO_get_callback ,
379.Fn BIO_set_callback_arg ,
380and
381.Fn BIO_debug_callback
382first appeared in SSLeay 0.6.0.
383.Fn BIO_get_callback_arg
384first appeared in SSLeay 0.8.0.
385These functions have been available since
386.Ox 2.4 .
387.Pp
388.Fn BIO_callback_fn
389first appeared in OpenSSL 1.1.0.
390.Fn BIO_callback_fn_ex ,
391.Fn BIO_set_callback_ex ,
392and
393.Fn BIO_get_callback_ex
394first appeared in OpenSSL 1.1.1.
395These functions have been available since
396.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/BIO_should_retry.3 b/src/lib/libcrypto/man/BIO_should_retry.3
deleted file mode 100644
index 9b93743516..0000000000
--- a/src/lib/libcrypto/man/BIO_should_retry.3
+++ /dev/null
@@ -1,301 +0,0 @@
1.\" $OpenBSD: BIO_should_retry.3,v 1.11 2023/04/30 14:03:47 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL 57fd5170 May 13 11:24:11 2018 +0200
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000, 2010, 2016 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: April 30 2023 $
70.Dt BIO_SHOULD_RETRY 3
71.Os
72.Sh NAME
73.Nm BIO_should_read ,
74.Nm BIO_should_write ,
75.Nm BIO_should_io_special ,
76.Nm BIO_retry_type ,
77.Nm BIO_should_retry ,
78.Nm BIO_get_retry_BIO ,
79.Nm BIO_get_retry_reason ,
80.Nm BIO_set_retry_reason
81.Nd BIO retry functions
82.Sh SYNOPSIS
83.In openssl/bio.h
84.Ft int
85.Fo BIO_should_read
86.Fa "BIO *b"
87.Fc
88.Ft int
89.Fo BIO_should_write
90.Fa "BIO *b"
91.Fc
92.Ft int
93.Fo BIO_should_io_special
94.Fa "BIO *b"
95.Fc
96.Ft int
97.Fo BIO_retry_type
98.Fa "BIO *b"
99.Fc
100.Ft int
101.Fo BIO_should_retry
102.Fa "BIO *b"
103.Fc
104.Fd #define BIO_FLAGS_READ 0x01
105.Fd #define BIO_FLAGS_WRITE 0x02
106.Fd #define BIO_FLAGS_IO_SPECIAL 0x04
107.Fd #define BIO_FLAGS_RWS \e
108.Fd \& (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
109.Fd #define BIO_FLAGS_SHOULD_RETRY 0x08
110.Ft BIO *
111.Fo BIO_get_retry_BIO
112.Fa "BIO *bio"
113.Fa "int *reason"
114.Fc
115.Ft int
116.Fo BIO_get_retry_reason
117.Fa "BIO *bio"
118.Fc
119.Ft void
120.Fo BIO_set_retry_reason
121.Fa "BIO *bio"
122.Fa "int reason"
123.Fc
124.Sh DESCRIPTION
125These functions determine why a BIO is not able to read or write data.
126They will typically be called after a failed
127.Xr BIO_read 3
128or
129.Xr BIO_write 3
130call.
131.Pp
132.Fn BIO_should_retry
133returns 1 if the call that produced this condition should be retried
134at a later time, or 0 if an error occurred.
135.Pp
136.Fn BIO_should_read
137returns 1 if the cause of the retry condition is that a BIO needs
138to read data, or 0 otherwise.
139.Pp
140.Fn BIO_should_write
141returns 1 if the cause of the retry condition is that a BIO needs
142to write data, or 0 otherwise.
143.Pp
144.Fn BIO_should_io_special
145returns 1 if some special condition (i.e. a reason other than reading
146or writing) is the cause of the retry condition, or 0 otherwise.
147.Pp
148.Fn BIO_retry_type
149returns the bitwise OR of one or more of the flags
150.Dv BIO_FLAGS_READ ,
151.Dv BIO_FLAGS_WRITE ,
152and
153.Dv BIO_FLAGS_IO_SPECIAL
154representing the cause of the current retry condition,
155or 0 if there is no retry condition.
156Current BIO types only set one of the flags at a time.
157.Pp
158.Fn BIO_get_retry_BIO
159determines the precise reason for the special condition.
160It walks the BIO chain starting at
161.Fa bio
162and returns the BIO that caused this condition.
163If there is no special condition,
164.Fa bio
165itself is returned.
166If
167.Fa reason
168is not a
169.Dv NULL
170pointer,
171.Pf * Fa reason
172is set to one of the following reason codes:
173.Bl -tag -width 1n -offset 3n
174.It 0
175There is no special condition.
176.It Dv BIO_RR_ACCEPT
177.Xr accept 2
178would have blocked.
179This can occur for BIOs created from
180.Xr BIO_s_accept 3
181or
182.Xr BIO_f_ssl 3 .
183.It Dv BIO_RR_CONNECT
184.Xr connect 2
185would have blocked.
186This can occur for BIOs created from
187.Xr BIO_s_connect 3
188or
189.Xr BIO_f_ssl 3 .
190.It Dv BIO_RR_SSL_X509_LOOKUP
191An application callback set by
192.Xr SSL_CTX_set_client_cert_cb 3
193has asked to be called again.
194This can occur for BIOs created from
195.Xr BIO_f_ssl 3 .
196.El
197.Pp
198.Fn BIO_get_retry_reason
199returns one of the above reason codes for a special condition that occurred in
200.Fa bio .
201It does not walk the chain and returns 0 if no special condition occurred in
202.Fa bio
203itself.
204.Pp
205.Fn BIO_set_retry_reason
206sets the retry reason for a special condition for the given
207.Fa bio .
208It is intended to be called by functions implementing a BIO type
209rather than by functions merely using BIOs.
210.Pp
211.Fn BIO_should_retry ,
212.Fn BIO_should_read ,
213.Fn BIO_should_write ,
214.Fn BIO_should_io_special ,
215and
216.Fn BIO_retry_type
217are implemented as macros.
218.Pp
219If
220.Fn BIO_should_retry
221returns false, then the precise "error condition" depends on
222the BIO type that caused it and the return code of the BIO operation.
223For example if a call to
224.Xr BIO_read 3
225on a socket BIO returns 0 and
226.Fn BIO_should_retry
227is false, then the cause will be that the connection closed.
228A similar condition on a file BIO will mean that it has reached EOF.
229Some BIO types may place additional information on the error queue.
230For more details see the individual BIO type manual pages.
231.Pp
232If the underlying I/O structure is in a blocking mode,
233almost all current BIO types will not request a retry,
234because the underlying I/O calls will not.
235If the application knows that the BIO type will never
236signal a retry then it need not call
237.Fn BIO_should_retry
238after a failed BIO I/O call.
239This is typically done with file BIOs.
240.Pp
241SSL BIOs are the only current exception to this rule:
242they can request a retry even if the underlying I/O structure
243is blocking, if a handshake occurs during a call to
244.Xr BIO_read 3 .
245An application can retry the failed call immediately
246or avoid this situation by setting
247.Dv SSL_MODE_AUTO_RETRY
248on the underlying SSL structure.
249.Pp
250While an application may retry a failed non-blocking call immediately,
251this is likely to be very inefficient because the call will fail
252repeatedly until data can be processed or is available.
253An application will normally wait until the necessary condition
254is satisfied.
255How this is done depends on the underlying I/O structure.
256.Pp
257For example if the cause is ultimately a socket and
258.Fn BIO_should_read
259is true then a call to
260.Xr select 2
261may be made to wait until data is available
262and then retry the BIO operation.
263By combining the retry conditions of several non-blocking BIOs in a single
264.Xr select 2
265call it is possible to service several BIOs in a single thread,
266though the performance may be poor if SSL BIOs are present because
267long delays can occur during the initial handshake process.
268.Pp
269It is possible for a BIO to block indefinitely if the underlying I/O
270structure cannot process or return any data.
271This depends on the behaviour of the platforms I/O functions.
272This is often not desirable: one solution is to use non-blocking I/O
273and use a timeout on the
274.Xr select 2
275(or equivalent) call.
276.Sh SEE ALSO
277.Xr BIO_new 3 ,
278.Xr BIO_read 3
279.Sh HISTORY
280.Fn BIO_should_read ,
281.Fn BIO_should_write ,
282.Fn BIO_retry_type ,
283and
284.Fn BIO_should_retry
285first appeared in SSLeay 0.6.0.
286.Fn BIO_should_io_special ,
287.Fn BIO_get_retry_BIO ,
288and
289.Fn BIO_get_retry_reason
290first appeared in SSLeay 0.8.0.
291All these functions have been available since
292.Ox 2.4 .
293.Pp
294.Fn BIO_set_retry_reason
295first appeared in OpenSSL 1.1.0 and has been available since
296.Ox 7.1 .
297.Sh BUGS
298The OpenSSL ASN.1 functions cannot gracefully deal with non-blocking I/O:
299they cannot retry after a partial read or write.
300This is usually worked around by only passing the relevant data to ASN.1
301functions when the entire structure can be read or written.
diff --git a/src/lib/libcrypto/man/BN_CTX_new.3 b/src/lib/libcrypto/man/BN_CTX_new.3
deleted file mode 100644
index 336b918896..0000000000
--- a/src/lib/libcrypto/man/BN_CTX_new.3
+++ /dev/null
@@ -1,123 +0,0 @@
1.\" $OpenBSD: BN_CTX_new.3,v 1.10 2023/04/25 17:21:51 tb Exp $
2.\" OpenSSL aafbe1cc Jun 12 23:42:08 2013 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2013 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: April 25 2023 $
52.Dt BN_CTX_NEW 3
53.Os
54.Sh NAME
55.Nm BN_CTX_new ,
56.Nm BN_CTX_free
57.Nd allocate and free BN_CTX structures
58.Sh SYNOPSIS
59.In openssl/bn.h
60.Ft BN_CTX *
61.Fo BN_CTX_new
62.Fa void
63.Fc
64.Ft void
65.Fo BN_CTX_free
66.Fa "BN_CTX *c"
67.Fc
68.Sh DESCRIPTION
69A
70.Vt BN_CTX
71is a structure that holds
72.Vt BIGNUM
73temporary variables used by library functions.
74Since dynamic memory allocation to create
75.Vt BIGNUM Ns s
76is rather expensive when used in conjunction with repeated subroutine
77calls, the
78.Vt BN_CTX
79structure is used.
80.Pp
81.Fn BN_CTX_new
82allocates and initializes a
83.Vt BN_CTX
84structure.
85.Pp
86.Fn BN_CTX_free
87frees the components of the
88.Vt BN_CTX
89and, if it was created by
90.Fn BN_CTX_new ,
91also the structure itself.
92If
93.Xr BN_CTX_start 3
94has been used on the
95.Vt BN_CTX ,
96.Xr BN_CTX_end 3
97must be called before the
98.Vt BN_CTX
99may be freed by
100.Fn BN_CTX_free .
101If
102.Fa c
103is a
104.Dv NULL
105pointer, no action occurs.
106.Sh RETURN VALUES
107.Fn BN_CTX_new
108returns a pointer to the
109.Vt BN_CTX .
110If the allocation fails, it returns
111.Dv NULL
112and sets an error code that can be obtained by
113.Xr ERR_get_error 3 .
114.Sh SEE ALSO
115.Xr BN_add 3 ,
116.Xr BN_CTX_start 3 ,
117.Xr BN_new 3
118.Sh HISTORY
119.Fn BN_CTX_new
120and
121.Fn BN_CTX_free
122first appeared in SSLeay 0.5.1 and have been available since
123.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BN_CTX_start.3 b/src/lib/libcrypto/man/BN_CTX_start.3
deleted file mode 100644
index a2b62eff5c..0000000000
--- a/src/lib/libcrypto/man/BN_CTX_start.3
+++ /dev/null
@@ -1,137 +0,0 @@
1.\" $OpenBSD: BN_CTX_start.3,v 1.8 2019/08/20 10:59:09 schwarze Exp $
2.\" full merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: August 20 2019 $
52.Dt BN_CTX_START 3
53.Os
54.Sh NAME
55.Nm BN_CTX_start ,
56.Nm BN_CTX_get ,
57.Nm BN_CTX_end
58.Nd use temporary BIGNUM variables
59.Sh SYNOPSIS
60.In openssl/bn.h
61.Ft void
62.Fo BN_CTX_start
63.Fa "BN_CTX *ctx"
64.Fc
65.Ft BIGNUM *
66.Fo BN_CTX_get
67.Fa "BN_CTX *ctx"
68.Fc
69.Ft void
70.Fo BN_CTX_end
71.Fa "BN_CTX *ctx"
72.Fc
73.Sh DESCRIPTION
74These functions are used to obtain temporary
75.Vt BIGNUM
76variables from a
77.Vt BN_CTX
78(which can be created using
79.Xr BN_CTX_new 3 )
80in order to save the overhead of repeatedly creating and freeing
81.Vt BIGNUM Ns s
82in functions that are called from inside a loop.
83.Pp
84A function must call
85.Fn BN_CTX_start
86first.
87Then,
88.Fn BN_CTX_get
89may be called repeatedly to obtain temporary
90.Vt BIGNUM Ns s .
91All
92.Fn BN_CTX_get
93calls must be made before calling any other functions that use the
94.Fa ctx
95as an argument.
96.Pp
97Finally,
98.Fn BN_CTX_end
99must be called before returning from the function.
100When
101.Fn BN_CTX_end
102is called, the
103.Vt BIGNUM
104pointers obtained from
105.Fn BN_CTX_get
106become invalid.
107If
108.Fa ctx
109is
110.Dv NULL ,
111no action occurs.
112.Sh RETURN VALUES
113.Fn BN_CTX_get
114returns a pointer to the
115.Vt BIGNUM ,
116or
117.Dv NULL
118on error.
119Once
120.Fn BN_CTX_get
121has failed, the subsequent calls will return
122.Dv NULL
123as well, so it is sufficient to check the return value of the last
124.Fn BN_CTX_get
125call.
126In case of an error, an error code is set which can be obtained by
127.Xr ERR_get_error 3 .
128.Sh SEE ALSO
129.Xr BN_CTX_new 3 ,
130.Xr BN_new 3
131.Sh HISTORY
132.Fn BN_CTX_start ,
133.Fn BN_CTX_get ,
134and
135.Fn BN_CTX_end
136first appeared in OpenSSL 0.9.5 and have been available since
137.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/BN_add.3 b/src/lib/libcrypto/man/BN_add.3
deleted file mode 100644
index e7de441b7a..0000000000
--- a/src/lib/libcrypto/man/BN_add.3
+++ /dev/null
@@ -1,646 +0,0 @@
1.\" $OpenBSD: BN_add.3,v 1.20 2023/04/27 09:47:03 tb Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ulf Moeller <ulf@openssl.org>
22.\" and Bodo Moeller <bodo@openssl.org>.
23.\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: April 27 2023 $
70.Dt BN_ADD 3
71.Os
72.Sh NAME
73.Nm BN_add ,
74.Nm BN_uadd ,
75.Nm BN_sub ,
76.Nm BN_usub ,
77.Nm BN_mul ,
78.Nm BN_sqr ,
79.Nm BN_div ,
80.Nm BN_mod ,
81.Nm BN_nnmod ,
82.Nm BN_mod_add ,
83.Nm BN_mod_add_quick ,
84.Nm BN_mod_sub ,
85.Nm BN_mod_sub_quick ,
86.Nm BN_mod_mul ,
87.Nm BN_mod_sqr ,
88.Nm BN_mod_lshift ,
89.Nm BN_mod_lshift_quick ,
90.Nm BN_mod_lshift1 ,
91.Nm BN_mod_lshift1_quick ,
92.Nm BN_exp ,
93.Nm BN_mod_exp ,
94.\" The following are public, but intentionally undocumented for now:
95.\" .Nm BN_mod_exp_mont , r \(== a ^ p (mod m)
96.\" .Nm BN_mod_exp_mont_consttime ,
97.\" .Nm BN_mod_exp_mont_word ,
98.\" .Nm BN_mod_exp_simple ,
99.\" .Nm BN_mod_exp2_mont r \(== (a1 ^ p1) * (a2 ^ p2) (mod m)
100.\" Maybe they should be deleted from <openssl/bn.h>.
101.Nm BN_gcd
102.Nd arithmetic operations on BIGNUMs
103.Sh SYNOPSIS
104.In openssl/bn.h
105.Ft int
106.Fo BN_add
107.Fa "BIGNUM *r"
108.Fa "const BIGNUM *a"
109.Fa "const BIGNUM *b"
110.Fc
111.Ft int
112.Fo BN_uadd
113.Fa "BIGNUM *r"
114.Fa "const BIGNUM *a"
115.Fa "const BIGNUM *b"
116.Fc
117.Ft int
118.Fo BN_sub
119.Fa "BIGNUM *r"
120.Fa "const BIGNUM *a"
121.Fa "const BIGNUM *b"
122.Fc
123.Ft int
124.Fo BN_usub
125.Fa "BIGNUM *r"
126.Fa "const BIGNUM *a"
127.Fa "const BIGNUM *b"
128.Fc
129.Ft int
130.Fo BN_mul
131.Fa "BIGNUM *r"
132.Fa "const BIGNUM *a"
133.Fa "const BIGNUM *b"
134.Fa "BN_CTX *ctx"
135.Fc
136.Ft int
137.Fo BN_sqr
138.Fa "BIGNUM *r"
139.Fa "const BIGNUM *a"
140.Fa "BN_CTX *ctx"
141.Fc
142.Ft int
143.Fo BN_div
144.Fa "BIGNUM *dv"
145.Fa "BIGNUM *rem"
146.Fa "const BIGNUM *a"
147.Fa "const BIGNUM *d"
148.Fa "BN_CTX *ctx"
149.Fc
150.Ft int
151.Fo BN_mod
152.Fa "BIGNUM *rem"
153.Fa "const BIGNUM *a"
154.Fa "const BIGNUM *m"
155.Fa "BN_CTX *ctx"
156.Fc
157.Ft int
158.Fo BN_nnmod
159.Fa "BIGNUM *r"
160.Fa "const BIGNUM *a"
161.Fa "const BIGNUM *m"
162.Fa "BN_CTX *ctx"
163.Fc
164.Ft int
165.Fo BN_mod_add
166.Fa "BIGNUM *r"
167.Fa "const BIGNUM *a"
168.Fa "const BIGNUM *b"
169.Fa "const BIGNUM *m"
170.Fa "BN_CTX *ctx"
171.Fc
172.Ft int
173.Fo BN_mod_add_quick
174.Fa "BIGNUM *r"
175.Fa "const BIGNUM *a"
176.Fa "const BIGNUM *b"
177.Fa "const BIGNUM *m"
178.Fc
179.Ft int
180.Fo BN_mod_sub
181.Fa "BIGNUM *r"
182.Fa "const BIGNUM *a"
183.Fa "const BIGNUM *b"
184.Fa "const BIGNUM *m"
185.Fa "BN_CTX *ctx"
186.Fc
187.Ft int
188.Fo BN_mod_sub_quick
189.Fa "BIGNUM *r"
190.Fa "const BIGNUM *a"
191.Fa "const BIGNUM *b"
192.Fa "const BIGNUM *m"
193.Fc
194.Ft int
195.Fo BN_mod_mul
196.Fa "BIGNUM *r"
197.Fa "const BIGNUM *a"
198.Fa "const BIGNUM *b"
199.Fa "const BIGNUM *m"
200.Fa "BN_CTX *ctx"
201.Fc
202.Ft int
203.Fo BN_mod_sqr
204.Fa "BIGNUM *r"
205.Fa "const BIGNUM *a"
206.Fa "const BIGNUM *m"
207.Fa "BN_CTX *ctx"
208.Fc
209.Ft int
210.Fo BN_mod_lshift
211.Fa "BIGNUM *r"
212.Fa "const BIGNUM *a"
213.Fa "int n"
214.Fa "const BIGNUM *m"
215.Fa "BN_CTX *ctx"
216.Fc
217.Ft int
218.Fo BN_mod_lshift_quick
219.Fa "BIGNUM *r"
220.Fa "const BIGNUM *a"
221.Fa "int n"
222.Fa "const BIGNUM *m"
223.Fc
224.Ft int
225.Fo BN_mod_lshift1
226.Fa "BIGNUM *r"
227.Fa "const BIGNUM *a"
228.Fa "const BIGNUM *m"
229.Fa "BN_CTX *ctx"
230.Fc
231.Ft int
232.Fo BN_mod_lshift1_quick
233.Fa "BIGNUM *r"
234.Fa "const BIGNUM *a"
235.Fa "const BIGNUM *m"
236.Fc
237.Ft int
238.Fo BN_exp
239.Fa "BIGNUM *r"
240.Fa "const BIGNUM *a"
241.Fa "const BIGNUM *p"
242.Fa "BN_CTX *ctx"
243.Fc
244.Ft int
245.Fo BN_mod_exp
246.Fa "BIGNUM *r"
247.Fa "const BIGNUM *a"
248.Fa "const BIGNUM *p"
249.Fa "const BIGNUM *m"
250.Fa "BN_CTX *ctx"
251.Fc
252.Ft int
253.Fo BN_gcd
254.Fa "BIGNUM *r"
255.Fa "const BIGNUM *a"
256.Fa "const BIGNUM *b"
257.Fa "BN_CTX *ctx"
258.Fc
259.Sh DESCRIPTION
260.Fn BN_add
261adds
262.Fa a
263and
264.Fa b
265and places the result in
266.Fa r
267.Pq Li r=a+b .
268.Fa r
269may be the same
270.Vt BIGNUM
271as
272.Fa a
273or
274.Fa b .
275.Pp
276.Fn BN_uadd
277adds the absolute values of
278.Fa a
279and
280.Fa b
281and places the result in
282.Fa r
283.Pq Li r=|a|+|b|\& .
284.Fa r
285may be the same
286.Vt BIGNUM
287as
288.Fa a
289or
290.Fa b .
291.Pp
292.Fn BN_sub
293subtracts
294.Fa b
295from
296.Fa a
297and places the result in
298.Fa r
299.Pq Li r=a-b .
300.Fa r
301may be the same
302.Vt BIGNUM
303as
304.Fa a
305or
306.Fa b .
307.Pp
308.Fn BN_usub
309subtracts the absolute value of
310.Fa b
311from the absolute value of
312.Fa a
313and places the result in
314.Fa r
315.Pq Li r=|a|-|b|\& .
316It requires the absolute value of
317.Fa a
318to be greater than the absolute value of
319.Fa b ;
320otherwise it will fail.
321.Fa r
322may be the same
323.Vt BIGNUM
324as
325.Fa a
326or
327.Fa b .
328.Pp
329.Fn BN_mul
330multiplies
331.Fa a
332and
333.Fa b
334and places the result in
335.Fa r
336.Pq Li r=a*b .
337.Fa r
338may be the same
339.Vt BIGNUM
340as
341.Fa a
342or
343.Fa b .
344For multiplication by powers of 2, use
345.Xr BN_lshift 3 .
346.Pp
347.Fn BN_sqr
348takes the square of
349.Fa a
350and places the result in
351.Fa r
352.Pq Li r=a^2 .
353.Fa r
354and
355.Fa a
356may be the same
357.Vt BIGNUM .
358This function is faster than
359.Fn BN_mul r a a .
360.Pp
361.Fn BN_div
362divides
363.Fa a
364by
365.Fa d
366and places the result in
367.Fa dv
368and the remainder in
369.Fa rem
370.Pq Li dv=a/d , rem=a%d .
371If the flag
372.Dv BN_FLG_CONSTTIME
373is set on
374.Fa a
375or
376.Fa d ,
377it operates in constant time.
378Either of
379.Fa dv
380and
381.Fa rem
382may be
383.Dv NULL ,
384in which case the respective value is not returned.
385The result is rounded towards zero; thus if
386.Fa a
387is negative, the remainder will be zero or negative.
388For division by powers of 2, use
389.Fn BN_rshift 3 .
390.Pp
391.Fn BN_mod
392corresponds to
393.Fn BN_div
394with
395.Fa dv
396set to
397.Dv NULL .
398It is implemented as a macro.
399.Pp
400.Fn BN_nnmod
401reduces
402.Fa a
403modulo
404.Fa m
405and places the non-negative remainder in
406.Fa r .
407.Pp
408.Fn BN_mod_add
409adds
410.Fa a
411to
412.Fa b
413modulo
414.Fa m
415and places the non-negative result in
416.Fa r .
417.Pp
418.Fn BN_mod_add_quick
419is a variant of
420.Fn BN_mod_add
421that requires
422.Fa a
423and
424.Fa b
425to both be non-negative and smaller than
426.Fa m .
427If any of these constraints are violated,
428it silently produces wrong results.
429.Pp
430.Fn BN_mod_sub
431subtracts
432.Fa b
433from
434.Fa a
435modulo
436.Fa m
437and places the non-negative result in
438.Fa r .
439.Pp
440.Fn BN_mod_sub_quick
441is a variant of
442.Fn BN_mod_sub
443that requires
444.Fa a
445and
446.Fa b
447to both be non-negative and smaller than
448.Fa m .
449If any of these constraints are violated,
450it silently produces wrong results.
451.Pp
452.Fn BN_mod_mul
453multiplies
454.Fa a
455by
456.Fa b
457and finds the non-negative remainder respective to modulus
458.Fa m
459.Pq Li r=(a*b)%m .
460.Fa r
461may be the same
462.Vt BIGNUM
463as
464.Fa a
465or
466.Fa b .
467For a more efficient algorithm for repeated computations using the same
468modulus, see
469.Xr BN_mod_mul_montgomery 3 .
470.Pp
471.Fn BN_mod_sqr
472takes the square of
473.Fa a
474modulo
475.Fa m
476and places the result in
477.Fa r .
478.Pp
479.Fn BN_mod_lshift
480shifts
481.Fa a
482left by
483.Fa n
484bits, reduces the result modulo
485.Fa m ,
486and places the non-negative remainder in
487.Fa r
488.Pq Li r=a*2^n mod m .
489.Pp
490.Fn BN_mod_lshift1
491shifts
492.Fa a
493left by one bit, reduces the result modulo
494.Fa m ,
495and places the non-negative remainder in
496.Fa r
497.Pq Li r=a*2 mod m .
498.Pp
499.Fn BN_mod_lshift_quick
500and
501.Fn BN_mod_lshift1_quick
502are variants of
503.Fn BN_mod_lshift
504and
505.Fn BN_mod_lshift1 ,
506respectively, that require
507.Fa a
508to be non-negative and less than
509.Fa m .
510If either of these constraints is violated, they sometimes fail
511and sometimes silently produce wrong results.
512.Pp
513.Fn BN_exp
514raises
515.Fa a
516to the
517.Fa p Ns -th
518power and places the result in
519.Fa r
520.Pq Li r=a^p .
521This function is faster than repeated applications of
522.Fn BN_mul .
523.Pp
524.Fn BN_mod_exp
525computes
526.Fa a
527to the
528.Fa p Ns -th
529power modulo
530.Fa m
531.Pq Li r=(a^p)%m .
532If the flag
533.Dv BN_FLG_CONSTTIME
534is set on
535.Fa p ,
536it operates in constant time.
537This function uses less time and space than
538.Fn BN_exp .
539.Pp
540.Fn BN_gcd
541computes the greatest common divisor of
542.Fa a
543and
544.Fa b
545and places the result in
546.Fa r .
547.Fa r
548may be the same
549.Vt BIGNUM
550as
551.Fa a
552or
553.Fa b .
554.Pp
555For all functions,
556.Fa ctx
557is a previously allocated
558.Vt BN_CTX
559used for temporary variables; see
560.Xr BN_CTX_new 3 .
561.Pp
562Unless noted otherwise, the result
563.Vt BIGNUM
564must be different from the arguments.
565.Sh RETURN VALUES
566For all functions, 1 is returned for success, 0 on error.
567The return value should always be checked, for example:
568.Pp
569.Dl if (!BN_add(r,a,b)) goto err;
570.Pp
571The error codes can be obtained by
572.Xr ERR_get_error 3 .
573.Sh SEE ALSO
574.Xr BN_add_word 3 ,
575.Xr BN_CTX_new 3 ,
576.Xr BN_new 3 ,
577.Xr BN_set_bit 3 ,
578.Xr BN_set_flags 3 ,
579.Xr BN_set_negative 3
580.Sh HISTORY
581.Fn BN_add ,
582.Fn BN_sub ,
583.Fn BN_mul ,
584.Fn BN_sqr ,
585.Fn BN_div ,
586.Fn BN_mod ,
587.Fn BN_mod_mul ,
588.Fn BN_mod_exp ,
589and
590.Fn BN_gcd
591first appeared in SSLeay 0.5.1.
592.Fn BN_exp
593first appeared in SSLeay 0.9.0.
594All these functions have been available since
595.Ox 2.4 .
596.Pp
597.Fn BN_uadd ,
598.Fn BN_usub ,
599and the
600.Fa ctx
601argument to
602.Fn BN_mul
603first appeared in SSLeay 0.9.1 and have been available since
604.Ox 2.6 .
605.Pp
606.Fn BN_nnmod ,
607.Fn BN_mod_add ,
608.Fn BN_mod_add_quick ,
609.Fn BN_mod_sub ,
610.Fn BN_mod_sub_quick ,
611.Fn BN_mod_sqr ,
612.Fn BN_mod_lshift ,
613.Fn BN_mod_lshift_quick ,
614.Fn BN_mod_lshift1 ,
615and
616.Fn BN_mod_lshift1_quick
617first appeared in OpenSSL 0.9.7 and have been available since
618.Ox 3.2 .
619.Sh BUGS
620Even if the
621.Dv BN_FLG_CONSTTIME
622flag is set on
623.Fa a
624or
625.Fa b ,
626.Fn BN_gcd
627neither fails nor operates in constant time, potentially allowing
628timing side-channel attacks.
629.Pp
630Even if the
631.Dv BN_FLG_CONSTTIME
632flag is set on
633.Fa p ,
634if the modulus
635.Fa m
636is even,
637.Fn BN_mod_exp
638does not operate in constant time, potentially allowing
639timing side-channel attacks.
640.Pp
641If
642.Dv BN_FLG_CONSTTIME
643is set on
644.Fa p ,
645.Fn BN_exp
646fails instead of operating in constant time.
diff --git a/src/lib/libcrypto/man/BN_add_word.3 b/src/lib/libcrypto/man/BN_add_word.3
deleted file mode 100644
index 161029c302..0000000000
--- a/src/lib/libcrypto/man/BN_add_word.3
+++ /dev/null
@@ -1,182 +0,0 @@
1.\" $OpenBSD: BN_add_word.3,v 1.10 2022/11/22 19:02:07 schwarze Exp $
2.\" full merge up to: OpenSSL 9e183d22 Mar 11 08:56:44 2017 -0500
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2005 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 22 2022 $
52.Dt BN_ADD_WORD 3
53.Os
54.Sh NAME
55.Nm BN_add_word ,
56.Nm BN_sub_word ,
57.Nm BN_mul_word ,
58.Nm BN_div_word ,
59.Nm BN_mod_word
60.Nd arithmetic functions on BIGNUMs with integers
61.Sh SYNOPSIS
62.In openssl/bn.h
63.Ft int
64.Fo BN_add_word
65.Fa "BIGNUM *a"
66.Fa "BN_ULONG w"
67.Fc
68.Ft int
69.Fo BN_sub_word
70.Fa "BIGNUM *a"
71.Fa "BN_ULONG w"
72.Fc
73.Ft int
74.Fo BN_mul_word
75.Fa "BIGNUM *a"
76.Fa "BN_ULONG w"
77.Fc
78.Ft BN_ULONG
79.Fo BN_div_word
80.Fa "BIGNUM *a"
81.Fa "BN_ULONG w"
82.Fc
83.Ft BN_ULONG
84.Fo BN_mod_word
85.Fa "const BIGNUM *a"
86.Fa "BN_ULONG w"
87.Fc
88.Sh DESCRIPTION
89These functions perform arithmetic operations on BIGNUMs with unsigned
90integers.
91They are much more efficient than the normal BIGNUM arithmetic
92operations.
93.Pp
94.Vt BN_ULONG
95is a macro that expands to
96.Vt unsigned long Pq = Vt uint64_t
97on
98.Dv _LP64
99platforms and
100.Vt unsigned int Pq = Vt uint32_t
101elsewhere.
102.Pp
103.Fn BN_add_word
104adds
105.Fa w
106to
107.Fa a
108.Pq Li a+=w .
109.Pp
110.Fn BN_sub_word
111subtracts
112.Fa w
113from
114.Fa a
115.Pq Li a-=w .
116.Pp
117.Fn BN_mul_word
118multiplies
119.Fa a
120and
121.Fa w
122.Pq Li a*=w .
123.Pp
124.Fn BN_div_word
125divides
126.Fa a
127by
128.Fa w
129.Pq Li a/=w
130and returns the remainder.
131.Pp
132.Fn BN_mod_word
133returns the remainder of
134.Fa a
135divided by
136.Fa w
137.Pq Li a%w .
138.Pp
139For
140.Fn BN_div_word
141and
142.Fn BN_mod_word ,
143.Fa w
144must not be 0.
145.Sh RETURN VALUES
146.Fn BN_add_word ,
147.Fn BN_sub_word ,
148and
149.Fn BN_mul_word
150return 1 for success or 0 on error.
151The error codes can be obtained by
152.Xr ERR_get_error 3 .
153.Pp
154.Fn BN_mod_word
155and
156.Fn BN_div_word
157return
158.Fa a Ns % Ns Fa w
159on success and
160.Po Vt BN_ULONG Pc Ns -1
161if an error occurred.
162.Sh SEE ALSO
163.Xr BN_add 3 ,
164.Xr BN_new 3
165.Sh HISTORY
166.Fn BN_add_word ,
167.Fn BN_div_word ,
168and
169.Fn BN_mod_word
170first appeared in SSLeay 0.5.1.
171.Fn BN_sub_word
172and
173.Fn BN_mul_word
174first appeared in SSLeay 0.9.0.
175All these functions have been available since
176.Ox 2.4 .
177.Pp
178Before 0.9.8a, the return value for
179.Fn BN_div_word
180and
181.Fn BN_mod_word
182in case of an error was 0.
diff --git a/src/lib/libcrypto/man/BN_bn2bin.3 b/src/lib/libcrypto/man/BN_bn2bin.3
deleted file mode 100644
index 0fe9a90738..0000000000
--- a/src/lib/libcrypto/man/BN_bn2bin.3
+++ /dev/null
@@ -1,388 +0,0 @@
1.\" $OpenBSD: BN_bn2bin.3,v 1.16 2023/07/09 06:45:03 tb Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>
5.\" and Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2000, 2002, 2016 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: July 9 2023 $
53.Dt BN_BN2BIN 3
54.Os
55.Sh NAME
56.Nm BN_bn2bin ,
57.Nm BN_bn2binpad ,
58.Nm BN_bin2bn ,
59.Nm BN_bn2lebinpad ,
60.Nm BN_lebin2bn ,
61.Nm BN_bn2hex ,
62.Nm BN_bn2dec ,
63.Nm BN_hex2bn ,
64.Nm BN_dec2bn ,
65.Nm BN_asc2bn ,
66.Nm BN_print ,
67.Nm BN_print_fp ,
68.Nm BN_bn2mpi ,
69.Nm BN_mpi2bn
70.Nd format conversions
71.Sh SYNOPSIS
72.In openssl/bn.h
73.Ft int
74.Fo BN_bn2bin
75.Fa "const BIGNUM *a"
76.Fa "unsigned char *to"
77.Fc
78.Ft int
79.Fo BN_bn2binpad
80.Fa "const BIGNUM *a"
81.Fa "unsigned char *to"
82.Fa "int tolen"
83.Fc
84.Ft BIGNUM *
85.Fo BN_bin2bn
86.Fa "const unsigned char *s"
87.Fa "int len"
88.Fa "BIGNUM *ret"
89.Fc
90.Ft int
91.Fo BN_bn2lebinpad
92.Fa "const BIGNUM *a"
93.Fa "unsigned char *to"
94.Fa "int tolen"
95.Fc
96.Ft BIGNUM *
97.Fo BN_lebin2bn
98.Fa "const unsigned char *s"
99.Fa "int len"
100.Fa "BIGNUM *ret"
101.Fc
102.Ft char *
103.Fo BN_bn2hex
104.Fa "const BIGNUM *a"
105.Fc
106.Ft char *
107.Fo BN_bn2dec
108.Fa "const BIGNUM *a"
109.Fc
110.Ft int
111.Fo BN_hex2bn
112.Fa "BIGNUM **ap"
113.Fa "const char *str"
114.Fc
115.Ft int
116.Fo BN_dec2bn
117.Fa "BIGNUM **ap"
118.Fa "const char *str"
119.Fc
120.Ft int
121.Fo BN_asc2bn
122.Fa "BIGNUM **ap"
123.Fa "const char *str"
124.Fc
125.Ft int
126.Fo BN_print
127.Fa "BIO *fp"
128.Fa "const BIGNUM *a"
129.Fc
130.Ft int
131.Fo BN_print_fp
132.Fa "FILE *fp"
133.Fa "const BIGNUM *a"
134.Fc
135.Ft int
136.Fo BN_bn2mpi
137.Fa "const BIGNUM *a"
138.Fa "unsigned char *to"
139.Fc
140.Ft BIGNUM *
141.Fo BN_mpi2bn
142.Fa "unsigned char *s"
143.Fa "int len"
144.Fa "BIGNUM *ret"
145.Fc
146.Sh DESCRIPTION
147.Fn BN_bn2bin
148converts the absolute value of
149.Fa a
150into big-endian form and stores it at
151.Fa to .
152.Fa to
153must point to
154.Fn BN_num_bytes a
155bytes of memory.
156.Pp
157.Fn BN_bn2binpad
158also converts the absolute value of
159.Fa a
160into big-endian form and stores it at
161.Fa to .
162.Fa tolen
163indicates the length of the output buffer
164.Pf * Fa to .
165The result is padded with zeros if necessary.
166If
167.Fa tolen
168is less than
169.Fn BN_num_bytes a ,
170an error is returned.
171.Pp
172.Fn BN_bin2bn
173converts the positive integer in big-endian form of length
174.Fa len
175at
176.Fa s
177into a
178.Vt BIGNUM
179and places it in
180.Fa ret .
181If
182.Fa ret
183is
184.Dv NULL ,
185a new
186.Vt BIGNUM
187is created.
188.Pp
189.Fn BN_bn2lebinpad
190and
191.Fn BN_lebin2bn
192are identical to
193.Fn BN_bn2binpad
194and
195.Fn BN_bin2bn
196except the buffer
197.Pf * Fa to
198is in little-endian format.
199.Pp
200.Fn BN_bn2hex
201and
202.Fn BN_bn2dec
203return printable strings containing the hexadecimal and decimal encoding of
204.Fa a
205respectively.
206For negative numbers, the string is prefaced with a leading minus sign.
207The string must be freed later using
208.Xr free 3 .
209.Pp
210.Fn BN_hex2bn
211interprets
212.Fa str
213as a hexadecimal number.
214The string may start with a minus sign
215.Pq Sq - .
216Conversion stops at the first byte that is not a hexadecimal digit.
217The number is converted to a
218.Vt BIGNUM
219and stored in
220.Pf ** Fa ap .
221If
222.Pf * Fa ap
223is
224.Dv NULL ,
225a new
226.Vt BIGNUM
227is created.
228If
229.Fa ap
230is
231.Dv NULL ,
232it only computes the number's length in hexadecimal digits,
233also counting the leading minus sign if there is one.
234A "negative zero" is converted to zero.
235.Fn BN_dec2bn
236is the same using the decimal system.
237.Fn BN_asc2bn
238infers the number base from an optional prefix.
239If
240.Fa str
241starts with
242.Qq 0x
243or
244.Qq 0X ,
245it calls
246.Fn BN_hex2bn ,
247otherwise
248.Fn BN_dec2bn .
249If the number is negative, the minus sign can be given before or
250after the prefix.
251.Pp
252.Fn BN_print
253and
254.Fn BN_print_fp
255write the hexadecimal encoding of
256.Fa a ,
257with a leading minus sign for negative numbers, to the
258.Vt BIO
259or
260.Vt FILE
261.Fa fp .
262.Pp
263.Fn BN_bn2mpi
264and
265.Fn BN_mpi2bn
266convert
267.Vt BIGNUM Ns s
268from and to a format that consists of the number's length in bytes
269represented as a 4-byte big-endian number, and the number itself in
270big-endian format, where the most significant bit signals a negative
271number (the representation of numbers with the MSB set is prefixed with
272a NUL byte).
273.Pp
274.Fn BN_bn2mpi
275stores the representation of
276.Fa a
277at
278.Fa to ,
279where
280.Pf * Fa to
281must be large enough to hold the result.
282The size can be determined by calling
283.Fn BN_bn2mpi a NULL .
284.Pp
285.Fn BN_mpi2bn
286converts the
287.Fa len
288bytes long representation at
289.Fa s
290to a
291.Vt BIGNUM
292and stores it at
293.Fa ret ,
294or in a newly allocated
295.Vt BIGNUM
296if
297.Fa ret
298is
299.Dv NULL .
300.Sh RETURN VALUES
301.Fn BN_bn2bin
302returns the length of the big-endian number placed at
303.Fa to .
304.Pp
305.Fn BN_bn2binpad
306and
307.Fn BN_bn2lebinpad
308return the number of bytes written
309or \-1 if the supplied buffer is too small.
310.Pp
311.Fn BN_bin2bn
312and
313.Fn BN_lebin2bn
314return the
315.Vt BIGNUM ,
316or
317.Dv NULL
318on error.
319.Pp
320.Fn BN_bn2hex
321and
322.Fn BN_bn2dec
323return a NUL-terminated string, or
324.Dv NULL
325on error.
326.Fn BN_hex2bn
327and
328.Fn BN_dec2bn
329return the number's length in hexadecimal or decimal digits,
330also counting the leading minus sign if there is one,
331or 0 on error, in which case no new
332.Vt BIGNUM
333is created.
334.Fn BN_asc2bn
335returns 1 on success or 0 on error, in which case no new
336.Vt BIGNUM
337is created.
338.Pp
339.Fn BN_print_fp
340and
341.Fn BN_print
342return 1 on success, 0 on write errors.
343.Pp
344.Fn BN_bn2mpi
345returns the length of the representation.
346.Fn BN_mpi2bn
347returns the
348.Vt BIGNUM ,
349or
350.Dv NULL
351on error.
352.Pp
353The error codes can be obtained by
354.Xr ERR_get_error 3 .
355.Sh SEE ALSO
356.Xr ASN1_INTEGER_to_BN 3 ,
357.Xr BN_new 3 ,
358.Xr BN_num_bytes 3 ,
359.Xr BN_zero 3
360.Sh HISTORY
361.Fn BN_bn2bin ,
362.Fn BN_bin2bn ,
363and
364.Fn BN_print
365first appeared in SSLeay 0.5.1.
366.Fn BN_print_fp
367first appeared in SSLeay 0.6.0.
368.Fn BN_bn2hex ,
369.Fn BN_bn2dec ,
370.Fn BN_hex2bn ,
371.Fn BN_dec2bn ,
372.Fn BN_bn2mpi ,
373and
374.Fn BN_mpi2bn
375first appeared in SSLeay 0.9.0.
376All these functions have been available since
377.Ox 2.4 .
378.Pp
379.Fn BN_asc2bin
380first appeared in OpenSSL 1.0.0 and has been available since
381.Ox 4.9 .
382.Pp
383.Fn BN_bn2binpad ,
384.Fn BN_bn2lebinpad ,
385and
386.Fn BN_lebin2bn
387first appeared in OpenSSL 1.1.0 and have been available since
388.Ox 7.0 .
diff --git a/src/lib/libcrypto/man/BN_cmp.3 b/src/lib/libcrypto/man/BN_cmp.3
deleted file mode 100644
index ba973313f0..0000000000
--- a/src/lib/libcrypto/man/BN_cmp.3
+++ /dev/null
@@ -1,169 +0,0 @@
1.\" $OpenBSD: BN_cmp.3,v 1.10 2022/11/22 19:02:07 schwarze Exp $
2.\" full merge up to: OpenSSL 5b31b9df Aug 4 10:45:52 2021 +0300
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 22 2022 $
52.Dt BN_CMP 3
53.Os
54.Sh NAME
55.Nm BN_cmp ,
56.Nm BN_ucmp ,
57.Nm BN_is_zero ,
58.Nm BN_is_one ,
59.Nm BN_is_word ,
60.Nm BN_abs_is_word ,
61.Nm BN_is_odd
62.Nd BIGNUM comparison and test functions
63.Sh SYNOPSIS
64.In openssl/bn.h
65.Ft int
66.Fo BN_cmp
67.Fa "const BIGNUM *a"
68.Fa "const BIGNUM *b"
69.Fc
70.Ft int
71.Fo BN_ucmp
72.Fa "const BIGNUM *a"
73.Fa "const BIGNUM *b"
74.Fc
75.Ft int
76.Fo BN_is_zero
77.Fa "const BIGNUM *a"
78.Fc
79.Ft int
80.Fo BN_is_one
81.Fa "const BIGNUM *a"
82.Fc
83.Ft int
84.Fo BN_is_word
85.Fa "const BIGNUM *a"
86.Fa "const BN_ULONG w"
87.Fc
88.Ft int
89.Fo BN_abs_is_word
90.Fa "const BIGNUM *a"
91.Fa "const BN_ULONG w"
92.Fc
93.Ft int
94.Fo BN_is_odd
95.Fa "const BIGNUM *a"
96.Fc
97.Sh DESCRIPTION
98.Fn BN_cmp
99compares the numbers
100.Fa a
101and
102.Fa b .
103.Fn BN_ucmp
104compares their absolute values.
105.Pp
106.Fn BN_is_zero ,
107.Fn BN_is_one
108and
109.Fn BN_is_word
110test if
111.Fa a
112equals 0, 1, or
113.Fa w
114respectively.
115.Fn BN_abs_is_word
116tests if the absolute value of
117.Fa a
118equals
119.Fa w .
120.Fn BN_is_odd
121tests if a is odd.
122.Pp
123.Vt BN_ULONG
124is a macro that expands to
125.Vt unsigned long Pq = Vt uint64_t
126on
127.Dv _LP64
128platforms and
129.Vt unsigned int Pq = Vt uint32_t
130elsewhere.
131.Sh RETURN VALUES
132.Fn BN_cmp
133returns -1 if
134.Fa a Ns < Ns Fa b ,
1350 if
136.Fa a Ns == Ns Fa b ,
137and 1 if
138.Fa a Ns > Ns Fa b .
139.Fn BN_ucmp
140is the same using the absolute values of
141.Fa a
142and
143.Fa b .
144.Pp
145.Fn BN_is_zero ,
146.Fn BN_is_one ,
147.Fn BN_is_word ,
148.Fn BN_abs_is_word ,
149and
150.Fn BN_is_odd
151return 1 if the condition is true, 0 otherwise.
152.Sh SEE ALSO
153.Xr BN_new 3
154.Sh HISTORY
155.Fn BN_cmp ,
156.Fn BN_ucmp ,
157.Fn BN_is_zero ,
158.Fn BN_is_one ,
159and
160.Fn BN_is_word
161first appeared in SSLeay 0.5.1.
162.Fn BN_is_odd
163first appeared in SSLeay 0.8.0.
164These functions have been available since
165.Ox 2.4 .
166.Pp
167.Fn BN_abs_is_word
168first appeared in OpenSSL 0.9.7 and has been available since
169.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/BN_copy.3 b/src/lib/libcrypto/man/BN_copy.3
deleted file mode 100644
index 383255e382..0000000000
--- a/src/lib/libcrypto/man/BN_copy.3
+++ /dev/null
@@ -1,165 +0,0 @@
1.\" $OpenBSD: BN_copy.3,v 1.10 2021/12/06 19:45:27 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>
5.\" and Matt Caswell <matt@openssl.org>.
6.\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 6 2021 $
53.Dt BN_COPY 3
54.Os
55.Sh NAME
56.Nm BN_copy ,
57.Nm BN_dup ,
58.Nm BN_with_flags
59.Nd copy BIGNUMs
60.Sh SYNOPSIS
61.In openssl/bn.h
62.Ft BIGNUM *
63.Fo BN_copy
64.Fa "BIGNUM *to"
65.Fa "const BIGNUM *from"
66.Fc
67.Ft BIGNUM *
68.Fo BN_dup
69.Fa "const BIGNUM *from"
70.Fc
71.Ft void
72.Fo BN_with_flags
73.Fa "BIGNUM *dest"
74.Fa "const BIGNUM *b"
75.Fa "int flags"
76.Fc
77.Sh DESCRIPTION
78.Fn BN_copy
79copies
80.Fa from
81to
82.Fa to .
83.Pp
84.Fn BN_dup
85creates a new
86.Vt BIGNUM
87containing the value
88.Fa from .
89.Pp
90.Fn BN_with_flags
91creates a
92.Em temporary
93shallow copy of
94.Fa b
95in
96.Fa dest .
97It places significant restrictions on the copied data.
98Applications that do not adhere to these restrictions
99may encounter unexpected side effects or crashes.
100For that reason, use of this function is discouraged.
101.Pp
102Any flags provided in
103.Fa flags
104will be set in
105.Fa dest
106in addition to any flags already set in
107.Fa b .
108For example, this can be used to create a temporary copy of a
109.Vt BIGNUM
110with the
111.Dv BN_FLG_CONSTTIME
112flag set for constant time operations.
113.Pp
114The temporary copy in
115.Fa dest
116will share some internal state with
117.Fa b .
118For this reason, the following restrictions apply to the use of
119.Fa dest :
120.Bl -bullet
121.It
122.Fa dest
123should be a newly allocated
124.Vt BIGNUM
125obtained via a call to
126.Xr BN_new 3 .
127It should not have been used for other purposes or initialised in any way.
128.It
129.Fa dest
130must only be used in "read-only" operations, i.e. typically those
131functions where the relevant parameter is declared "const".
132.It
133.Fa dest
134must be used and freed before any further subsequent use of
135.Fa b .
136.El
137.Sh RETURN VALUES
138.Fn BN_copy
139returns
140.Fa to
141on success or
142.Dv NULL
143on error.
144.Fn BN_dup
145returns the new
146.Vt BIGNUM
147or
148.Dv NULL
149on error.
150The error codes can be obtained by
151.Xr ERR_get_error 3 .
152.Sh SEE ALSO
153.Xr BN_new 3 ,
154.Xr BN_set_flags 3
155.Sh HISTORY
156.Fn BN_copy
157and
158.Fn BN_dup
159first appeared in SSLeay 0.5.1 and have been available since
160.Ox 2.4 .
161.Pp
162.Fn BN_with_flags
163first appeared in OpenSSL 0.9.7h and 0.9.8a
164and has been available since
165.Ox 4.0 .
diff --git a/src/lib/libcrypto/man/BN_generate_prime.3 b/src/lib/libcrypto/man/BN_generate_prime.3
deleted file mode 100644
index d9144155c6..0000000000
--- a/src/lib/libcrypto/man/BN_generate_prime.3
+++ /dev/null
@@ -1,375 +0,0 @@
1.\" $OpenBSD: BN_generate_prime.3,v 1.25 2023/12/29 19:12:46 tb Exp $
2.\" full merge up to: OpenSSL f987a4dd Jun 27 10:12:08 2019 +0200
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ulf Moeller <ulf@openssl.org>
22.\" Bodo Moeller <bodo@openssl.org>, and Matt Caswell <matt@openssl.org>.
23.\" Copyright (c) 2000, 2003, 2013, 2014, 2018 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: December 29 2023 $
71.Dt BN_GENERATE_PRIME 3
72.Os
73.Sh NAME
74.Nm BN_is_prime_ex ,
75.Nm BN_is_prime_fasttest_ex ,
76.Nm BN_generate_prime_ex ,
77.Nm BN_GENCB_call ,
78.Nm BN_GENCB_new ,
79.Nm BN_GENCB_free ,
80.Nm BN_GENCB_set ,
81.Nm BN_GENCB_get_arg ,
82.Nm BN_GENCB_set_old
83.\" Nm BN_prime_checks_for_size is intentionally undocumented
84.\" because it should not be used outside of libcrypto.
85.Nd generate primes and test for primality
86.Sh SYNOPSIS
87.In openssl/bn.h
88.Ft int
89.Fo BN_is_prime_ex
90.Fa "const BIGNUM *a"
91.Fa "int nchecks"
92.Fa "BN_CTX *ctx"
93.Fa "BN_GENCB *cb"
94.Fc
95.Ft int
96.Fo BN_is_prime_fasttest_ex
97.Fa "const BIGNUM *a"
98.Fa "int nchecks"
99.Fa "BN_CTX *ctx"
100.Fa "int do_trial_division"
101.Fa "BN_GENCB *cb"
102.Fc
103.Ft int
104.Fo BN_generate_prime_ex
105.Fa "BIGNUM *ret"
106.Fa "int bits"
107.Fa "int safe"
108.Fa "const BIGNUM *modulus"
109.Fa "const BIGNUM *remainder"
110.Fa "BN_GENCB *cb"
111.Fc
112.Ft int
113.Fo BN_GENCB_call
114.Fa "BN_GENCB *cb"
115.Fa "int state_code"
116.Fa "int serial_number"
117.Fc
118.Ft BN_GENCB *
119.Fn BN_GENCB_new void
120.Ft void
121.Fo BN_GENCB_free
122.Fa "BN_GENCB *cb"
123.Fc
124.Ft void
125.Fo BN_GENCB_set
126.Fa "BN_GENCB *cb"
127.Fa "int (*cb_fp)(int, int, BN_GENCB *)"
128.Fa "void *cb_arg"
129.Fc
130.Ft void *
131.Fo BN_GENCB_get_arg
132.Fa "BN_GENCB *cb"
133.Fc
134.Pp
135Deprecated:
136.Pp
137.Ft void
138.Fo BN_GENCB_set_old
139.Fa "BN_GENCB *cb"
140.Fa "void (*cb_fp)(int, int, void *)"
141.Fa "void *cb_arg"
142.Fc
143.Sh DESCRIPTION
144.Fn BN_is_prime_ex
145and
146.Fn BN_is_prime_fasttest_ex
147test whether the number
148.Fa a
149is prime.
150In LibreSSL, both functions behave identically
151and use the Baillie-Pomerance-Selfridge-Wagstaff algorithm
152combined with
153.Fa checks
154Miller-Rabin rounds.
155The
156.Fa do_trial_division
157argument is ignored.
158.Pp
159It is unknown whether any composite number exists that the
160Baillie-PSW algorithm misclassifies as a prime.
161Some suspect that there may be infinitely many such numbers,
162but not a single one is currently known.
163It is known that no such number exists below 2\(ha64.
164.Pp
165In order to reduce the likelihood of a composite number
166passing the primality tests
167.Fn BN_is_prime_fasttest_ex
168and
169.Fn BN_is_prime_ex ,
170a number of rounds of the probabilistic Miller-Rabin test is performed.
171If
172.Fa checks
173is positive, it is used as the number of rounds;
174if it is zero or the special value
175.Dv BN_prime_checks ,
176a suitable number of rounds is calculated from the bit length of
177.Fa a .
178.Pp
179If
180.Dv NULL
181is passed for the
182.Fa ctx
183argument, these function allocate a
184.Vt BN_CTX
185object internally when they need one and free it before returning.
186Alternatively, to save the overhead of allocating and freeing
187that object for each call, the caller can pre-allocate a
188.Vt BN_CTX
189object and pass it in the
190.Fa ctx
191argument.
192.Pp
193.Fn BN_generate_prime_ex
194generates a pseudo-random prime number of at least bit length
195.Fa bits
196and places it in
197.Fa ret .
198Primality of
199.Fa ret
200is tested internally using
201.Fn BN_is_prime_ex .
202Consequently, for
203.Fa bits
204larger than 64, it is theoretically possible
205that this function might place a composite number into
206.Fa ret ;
207the probability of such an event is unknown but very small.
208.Pp
209The prime may have to fulfill additional requirements for use in
210Diffie-Hellman key exchange:
211.Bl -bullet
212.It
213If
214.Fa modulus
215is not
216.Dv NULL ,
217a prime is generated that fulfills the condition
218.Fa ret No % Fa modulus No = Fa remainder .
219If the
220.Fa remainder
221argument is
222.Dv NULL ,
2231 is used as the desired remainder.
224.It
225If the
226.Fa safe
227argument is non-zero, a safe prime is generated, that is,
228.Po Fa ret No \- 1 Pc Ns /2
229is also prime.
230.El
231.Pp
232If
233.Fa cb
234is not
235.Dv NULL ,
236it is used as follows:
237.Bl -bullet
238.It
239.Fn BN_GENCB_call cb 0 serial_number
240is called after generating a potential prime number.
241.It
242The
243.Fa state_code
244of 1 is reserved for callbacks during primality testing,
245but LibreSSL performs no such callbacks.
246.It
247When
248.Fa safe
249is non-zero and a safe prime has been found,
250.Fn BN_GENCB_call cb 2 serial_number
251is called.
252.It
253The callers of
254.Fn BN_generate_prime_ex
255may call
256.Fn BN_GENCB_call
257with other values as described in their respective manual pages; see
258.Sx SEE ALSO .
259.El
260.Pp
261In all cases, the
262.Fa serial_number
263is the number of candidates that have already been discarded
264for not being prime; that is,
265.Fa serial_number
266is 0 for the first candidate
267and then incremented whenever a new candidate is generated.
268.Pp
269.Fn BN_GENCB_call
270calls the callback function held in
271.Fa cb
272and passes the
273.Fa state_code
274and the
275.Fa serial_number
276as arguments.
277If
278.Fa cb
279is
280.Dv NULL
281or does not contain a callback function, no action occurs.
282.Pp
283.Fn BN_GENCB_new
284allocates a new
285.Vt BN_GENCB
286object.
287.Pp
288.Fn BN_GENCB_free
289frees
290.Fa cb .
291If
292.Fa cb
293is
294.Dv NULL ,
295no action occurs.
296.Pp
297.Fn BN_GENCB_set
298initialises
299.Fa cb
300to use the callback function pointer
301.Fa cb_fp
302and the additional callback argument
303.Fa cb_arg .
304.Pp
305The deprecated function
306.Fn BN_GENCB_set_old
307initialises
308.Fa cb
309to use the old-style callback function pointer
310.Fa cb_fp
311and the additional callback argument
312.Fa cb_arg .
313.Sh RETURN VALUES
314.Fn BN_is_prime_ex
315and
316.Fn BN_is_prime_fasttest_ex
317return 0 if the number is composite, 1 if it is prime with a very small
318error probability, or \-1 on error.
319.Pp
320.Fn BN_generate_prime_ex
321returns 1 on success or 0 on error.
322.Pp
323.Fn BN_GENCB_call
324returns 1 on success, including when
325.Fa cb
326is
327.Dv NULL
328or does not contain a callback function,
329or 0 on error.
330.Pp
331.Fn BN_GENCB_new
332returns a pointer to the newly allocated
333.Vt BN_GENCB
334object or
335.Dv NULL
336if memory allocation fails.
337.Pp
338The callback functions pointed to by the
339.Fa cb_fp
340arguments are supposed to return 1 on success or 0 on error.
341.Pp
342.Fn BN_GENCB_get_arg
343returns the
344.Fa cb_arg
345pointer that was previously stored in
346.Fa cb
347using
348.Fn BN_GENCB_set
349or
350.Fn BN_GENCB_set_old .
351.Pp
352In some cases, error codes can be obtained by
353.Xr ERR_get_error 3 .
354.Sh SEE ALSO
355.Xr BN_new 3 ,
356.Xr DH_generate_parameters 3 ,
357.Xr DSA_generate_parameters_ex 3 ,
358.Xr RSA_generate_key 3
359.Sh HISTORY
360.Fn BN_generate_prime_ex ,
361.Fn BN_is_prime_ex ,
362.Fn BN_is_prime_fasttest_ex ,
363.Fn BN_GENCB_call ,
364.Fn BN_GENCB_set_old ,
365and
366.Fn BN_GENCB_set
367first appeared in OpenSSL 0.9.8 and have been available since
368.Ox 4.5 .
369.Pp
370.Fn BN_GENCB_new ,
371.Fn BN_GENCB_free ,
372and
373.Fn BN_GENCB_get_arg
374first appeared in OpenSSL 1.1.0 and have been available since
375.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3 b/src/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3
deleted file mode 100644
index abaf80ef20..0000000000
--- a/src/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3
+++ /dev/null
@@ -1,153 +0,0 @@
1.\" $OpenBSD: BN_get_rfc3526_prime_8192.3,v 1.1 2023/07/20 16:26:40 tb Exp $
2.\" checked up to: OpenSSL DH_get_1024_160 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: July 20 2023 $
19.Dt BN_GET_RFC3526_PRIME_8192 3
20.Os
21.Sh NAME
22.Nm BN_get_rfc2409_prime_768 ,
23.Nm BN_get_rfc2409_prime_1024 ,
24.Nm BN_get_rfc3526_prime_1536 ,
25.Nm BN_get_rfc3526_prime_2048 ,
26.Nm BN_get_rfc3526_prime_3072 ,
27.Nm BN_get_rfc3526_prime_4096 ,
28.Nm BN_get_rfc3526_prime_6144 ,
29.Nm BN_get_rfc3526_prime_8192
30.Nd standard moduli for Diffie-Hellman key exchange
31.Sh SYNOPSIS
32.In openssl/bn.h
33.Ft BIGNUM *
34.Fn BN_get_rfc2409_prime_768 "BIGNUM *bn"
35.Ft BIGNUM *
36.Fn BN_get_rfc2409_prime_1024 "BIGNUM *bn"
37.Ft BIGNUM *
38.Fn BN_get_rfc3526_prime_1536 "BIGNUM *bn"
39.Ft BIGNUM *
40.Fn BN_get_rfc3526_prime_2048 "BIGNUM *bn"
41.Ft BIGNUM *
42.Fn BN_get_rfc3526_prime_3072 "BIGNUM *bn"
43.Ft BIGNUM *
44.Fn BN_get_rfc3526_prime_4096 "BIGNUM *bn"
45.Ft BIGNUM *
46.Fn BN_get_rfc3526_prime_6144 "BIGNUM *bn"
47.Ft BIGNUM *
48.Fn BN_get_rfc3526_prime_8192 "BIGNUM *bn"
49.Sh DESCRIPTION
50Each of these functions returns one specific constant Sophie Germain
51prime number
52.Fa p .
53.Pp
54If
55.Fa bn
56is
57.Dv NULL ,
58a new
59.Vt BIGNUM
60object is created and returned.
61Otherwise, the number is stored in
62.Pf * Fa bn
63and
64.Fa bn
65is returned.
66.Pp
67All these numbers are of the form
68.Pp
69.EQ
70p = 2 sup s - 2 sup left ( s - 64 right ) - 1 + 2 sup 64 *
71left { left [ 2 sup left ( s - 130 right ) pi right ] + offset right }
72delim $$
73.EN
74.Pp
75where
76.Ar s
77is the size of the binary representation of the number in bits
78and appears at the end of the function names.
79As long as the offset is sufficiently small, the above form assures
80that the top and bottom 64 bits of each number are all 1.
81.Pp
82The offsets are defined in the standards as follows:
83.Bl -column "8192 = 2 * 2^12" "4743158" -offset indent
84.It size Ar s Ta Ar offset
85.It Ta
86.It \ 768 = 3 * 2^8 Ta 149686
87.It 1024 = 2 * 2^9 Ta 129093
88.It 1536 = 3 * 2^9 Ta 741804
89.It 2048 = 2 * 2^10 Ta 124476
90.It 3072 = 3 * 2^10 Ta 1690314
91.It 4096 = 2 * 2^11 Ta 240904
92.It 6144 = 3 * 2^11 Ta 929484
93.It 8192 = 2 * 2^12 Ta 4743158
94.El
95.Pp
96For each of these prime numbers, the finite group of natural numbers
97smaller than
98.Fa p ,
99where the group operation is defined as multiplication modulo
100.Fa p ,
101is used for Diffie-Hellman key exchange.
102The first two of these groups are called the First Oakley Group and
103the Second Oakley Group.
104Obviously, all these groups are cyclic groups of order
105.Fa p ,
106respectively, and the numbers returned by these functions are not
107secrets.
108.Sh RETURN VALUES
109If memory allocation fails, these functions return
110.Dv NULL .
111That can happen even if
112.Fa bn
113is not
114.Dv NULL .
115.Sh SEE ALSO
116.Xr BN_mod_exp 3 ,
117.Xr BN_new 3 ,
118.Xr BN_set_flags 3 ,
119.Xr DH_new 3
120.Sh STANDARDS
121RFC 2409, "The Internet Key Exchange (IKE)", defines the Oakley Groups.
122.Pp
123RFC 2412, "The OAKLEY Key Determination Protocol", contains additional
124information about these numbers.
125.Pp
126RFC 3526, "More Modular Exponential (MODP) Diffie-Hellman groups
127for Internet Key Exchange (IKE)", defines the other six numbers.
128.Sh HISTORY
129.Fn BN_get_rfc2409_prime_768 ,
130.Fn BN_get_rfc2409_prime_1024 ,
131.Fn BN_get_rfc3526_prime_1536 ,
132.Fn BN_get_rfc3526_prime_2048 ,
133.Fn BN_get_rfc3526_prime_3072 ,
134.Fn BN_get_rfc3526_prime_4096 ,
135.Fn BN_get_rfc3526_prime_6144 ,
136and
137.Fn BN_get_rfc3526_prime_8192
138first appeared in OpenSSL 1.1.0 and have been available since
139.Ox 6.3 .
140The same functions without
141.Sy BN_
142prefix first appeared in OpenSSL 0.9.8a and
143.Ox 4.5 ;
144they were removed in
145.Ox 7.4 .
146.Sh CAVEATS
147As all the memory needed for storing the numbers is dynamically
148allocated, the
149.Dv BN_FLG_STATIC_DATA
150flag is not set on the returned
151.Vt BIGNUM
152objects.
153So be careful to not change the returned numbers.
diff --git a/src/lib/libcrypto/man/BN_kronecker.3 b/src/lib/libcrypto/man/BN_kronecker.3
deleted file mode 100644
index 90b7f43230..0000000000
--- a/src/lib/libcrypto/man/BN_kronecker.3
+++ /dev/null
@@ -1,57 +0,0 @@
1.\" $OpenBSD: BN_kronecker.3,v 1.2 2022/11/15 17:55:00 schwarze Exp $
2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 15 2022 $
18.Dt BN_KRONECKER 3
19.Os
20.Sh NAME
21.Nm BN_kronecker
22.Nd Kronecker symbol
23.Sh SYNOPSIS
24.In openssl/bn.h
25.Ft int
26.Fo BN_kronecker
27.Fa "const BIGNUM *a"
28.Fa "const BIGNUM *b"
29.Fa "BN_CTX *ctx"
30.Fc
31.Sh DESCRIPTION
32.Fn BN_kronecker
33computes the Kronecker symbol
34.Pq a | b ,
35which generalizes the Legendre and Jacobi symbols
36for arbitrary integer numbers
37.Fa b .
38.Sh RETURN VALUES
39.Fn BN_kronecker
40returns \-1, 0, or 1 in case of success or \-2 on error.
41.Sh SEE ALSO
42.Xr BN_CTX_new 3 ,
43.Xr BN_gcd 3 ,
44.Xr BN_mod_sqrt 3 ,
45.Xr BN_new 3
46.Rs
47.%A Henri Cohen
48.%B A Course in Computational Algebraic Number Theory
49.%I Springer
50.%C Berlin
51.%D 1993
52.%O Algorithm 1.4.10
53.Re
54.Sh HISTORY
55.Fn BN_kronecker
56first appeared in OpenSSL 0.9.7 and has been available since
57.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/BN_mod_inverse.3 b/src/lib/libcrypto/man/BN_mod_inverse.3
deleted file mode 100644
index d0a4b458f4..0000000000
--- a/src/lib/libcrypto/man/BN_mod_inverse.3
+++ /dev/null
@@ -1,126 +0,0 @@
1.\" $OpenBSD: BN_mod_inverse.3,v 1.13 2023/10/21 13:53:43 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: October 21 2023 $
52.Dt BN_MOD_INVERSE 3
53.Os
54.Sh NAME
55.Nm BN_mod_inverse
56.Nd compute inverse modulo m
57.Sh SYNOPSIS
58.In openssl/bn.h
59.Ft BIGNUM *
60.Fo BN_mod_inverse
61.Fa "BIGNUM *r"
62.Fa "const BIGNUM *a"
63.Fa "const BIGNUM *m"
64.Fa "BN_CTX *ctx"
65.Fc
66.Sh DESCRIPTION
67.Fn BN_mod_inverse
68computes the inverse of
69.Fa a
70modulo
71.Fa m
72and places the result in
73.Fa r ,
74so that
75.Fa r
76satisfies
77.Li a * r == 1 (mod m) .
78If
79.Fa r
80is
81.Dv NULL ,
82a new
83.Vt BIGNUM
84is allocated.
85.Pp
86If the flag
87.Dv BN_FLG_CONSTTIME
88is set on
89.Fa a
90or
91.Fa m ,
92it operates in constant time.
93.Pp
94.Fa ctx
95is a previously allocated
96.Vt BN_CTX
97used for temporary variables.
98.Fa r
99may be the same
100.Vt BIGNUM
101as
102.Fa a
103or
104.Fa m .
105.Sh RETURN VALUES
106.Fn BN_mod_inverse
107returns the
108.Vt BIGNUM
109containing the inverse, or
110.Dv NULL
111on error.
112The error codes can be obtained by
113.Xr ERR_get_error 3 .
114.Sh SEE ALSO
115.Xr BN_add 3 ,
116.Xr BN_new 3 ,
117.Xr BN_set_flags 3
118.Sh HISTORY
119.Fn BN_mod_inverse
120first appeared in SSLeay 0.5.1 and has been available since
121.Ox 2.4 .
122.Pp
123The
124.Fa r
125argument was added in SSLeay 0.9.1 and
126.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/BN_mod_mul_montgomery.3 b/src/lib/libcrypto/man/BN_mod_mul_montgomery.3
deleted file mode 100644
index ed004c2549..0000000000
--- a/src/lib/libcrypto/man/BN_mod_mul_montgomery.3
+++ /dev/null
@@ -1,271 +0,0 @@
1.\" $OpenBSD: BN_mod_mul_montgomery.3,v 1.16 2025/03/09 15:24:25 tb Exp $
2.\" full merge up to: OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Ulf Moeller <ulf@openssl.org>.
23.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: March 9 2025 $
70.Dt BN_MOD_MUL_MONTGOMERY 3
71.Os
72.Sh NAME
73.Nm BN_MONT_CTX_new ,
74.Nm BN_MONT_CTX_free ,
75.Nm BN_MONT_CTX_set ,
76.Nm BN_MONT_CTX_set_locked ,
77.Nm BN_MONT_CTX_copy ,
78.Nm BN_mod_mul_montgomery ,
79.Nm BN_from_montgomery ,
80.Nm BN_to_montgomery
81.Nd Montgomery multiplication
82.Sh SYNOPSIS
83.In openssl/bn.h
84.Ft BN_MONT_CTX *
85.Fo BN_MONT_CTX_new
86.Fa void
87.Fc
88.Ft void
89.Fo BN_MONT_CTX_free
90.Fa "BN_MONT_CTX *mont"
91.Fc
92.Ft int
93.Fo BN_MONT_CTX_set
94.Fa "BN_MONT_CTX *mont"
95.Fa "const BIGNUM *m"
96.Fa "BN_CTX *ctx"
97.Fc
98.Ft BN_MONT_CTX *
99.Fo BN_MONT_CTX_set_locked
100.Fa "BN_MONT_CTX **pmont"
101.Fa "int lock"
102.Fa "const BIGNUM *m"
103.Fa "BN_CTX *ctx"
104.Fc
105.Ft BN_MONT_CTX *
106.Fo BN_MONT_CTX_copy
107.Fa "BN_MONT_CTX *to"
108.Fa "const BN_MONT_CTX *from"
109.Fc
110.Ft int
111.Fo BN_mod_mul_montgomery
112.Fa "BIGNUM *r"
113.Fa "const BIGNUM *a"
114.Fa "const BIGNUM *b"
115.Fa "BN_MONT_CTX *mont"
116.Fa "BN_CTX *ctx"
117.Fc
118.Ft int
119.Fo BN_from_montgomery
120.Fa "BIGNUM *r"
121.Fa "const BIGNUM *a"
122.Fa "BN_MONT_CTX *mont"
123.Fa "BN_CTX *ctx"
124.Fc
125.Ft int
126.Fo BN_to_montgomery
127.Fa "BIGNUM *r"
128.Fa "const BIGNUM *a"
129.Fa "BN_MONT_CTX *mont"
130.Fa "BN_CTX *ctx"
131.Fc
132.Sh DESCRIPTION
133These functions implement Montgomery multiplication.
134They are used automatically when
135.Xr BN_mod_exp 3
136is called with suitable input, but they may be useful when several
137operations are to be performed using the same modulus.
138.Pp
139.Fn BN_MONT_CTX_new
140allocates and initializes a
141.Vt BN_MONT_CTX
142structure.
143.Pp
144.Fn BN_MONT_CTX_set
145sets up the
146.Fa mont
147structure from the modulus
148.Fa m
149by precomputing its inverse and a value R.
150.Pp
151.Fn BN_MONT_CTX_set_locked
152is a wrapper around
153.Fn BN_MONT_CTX_new
154and
155.Fn BN_MONT_CTX_set
156that is useful if more than one thread intends to use the same
157.Vt BN_MONT_CTX
158and none of these threads is exclusively responsible for creating
159and initializing the context.
160.Fn BN_MONT_CTX_set_locked
161first acquires the specified
162.Fa lock
163using
164.Xr CRYPTO_lock 3 .
165If
166.Pf * Fa pmont
167already differs from
168.Dv NULL ,
169no action occurs.
170Otherwise, a new
171.Vt BN_MONT_CTX
172is allocated with
173.Fn BN_MONT_CTX_new ,
174set up with
175.Fn BN_MONT_CTX_set ,
176and a pointer to it is stored in
177.Pf * Fa pmont .
178Finally, the
179.Fa lock
180is released.
181.Pp
182.Fn BN_MONT_CTX_copy
183copies the
184.Vt BN_MONT_CTX
185.Fa from
186to
187.Fa to .
188.Pp
189.Fn BN_MONT_CTX_free
190frees the components of the
191.Vt BN_MONT_CTX ,
192and, if it was created by
193.Fn BN_MONT_CTX_new ,
194also the structure itself.
195If
196.Fa mont
197is a
198.Dv NULL
199pointer, no action occurs.
200.Pp
201.Fn BN_mod_mul_montgomery
202computes
203.Pp
204.D1 Mont Ns Po Fa a , Fa b Pc := Fa a No * Fa b No * R^-1
205.Pp
206and places the result in
207.Fa r .
208.Pp
209.Fn BN_from_montgomery
210performs the Montgomery reduction
211.Pp
212.D1 Fa r No = Fa a No * R^-1
213.Pp
214.Fn BN_to_montgomery
215computes
216.Pp
217.D1 Mont Ns Po Fa a , No R^2 Pc = Fa a No * R
218.Pp
219Note that
220.Fa a
221must be non-negative and smaller than the modulus.
222.Pp
223For all functions,
224.Fa ctx
225is a previously allocated
226.Vt BN_CTX
227used for temporary variables.
228.Pp
229.Sy Warning :
230The inputs must be reduced modulo
231.Fa m ,
232otherwise the result will be outside the expected range.
233.Sh RETURN VALUES
234.Fn BN_MONT_CTX_new
235returns the newly allocated
236.Vt BN_MONT_CTX
237or
238.Dv NULL
239on error.
240.Pp
241.Fn BN_MONT_CTX_set_locked
242returns a pointer to the existing or newly created context or
243.Dv NULL
244on error.
245.Pp
246For the other functions, 1 is returned for success or 0 on error.
247The error codes can be obtained by
248.Xr ERR_get_error 3 .
249.Sh SEE ALSO
250.Xr BN_add 3 ,
251.Xr BN_CTX_new 3 ,
252.Xr BN_new 3 ,
253.Xr CRYPTO_lock 3
254.Sh HISTORY
255.Fn BN_MONT_CTX_new ,
256.Fn BN_MONT_CTX_free ,
257.Fn BN_MONT_CTX_set ,
258.Fn BN_mod_mul_montgomery ,
259.Fn BN_from_montgomery ,
260and
261.Fn BN_to_montgomery
262first appeared in SSLeay 0.6.1 and have been available since
263.Ox 2.4 .
264.Pp
265.Fn BN_MONT_CTX_copy
266first appeared in SSLeay 0.9.1 and has been available since
267.Ox 2.6 .
268.Pp
269.Fn BN_MONT_CTX_set_locked
270first appeared in OpenSSL 0.9.8 and has been available since
271.Ox 4.0 .
diff --git a/src/lib/libcrypto/man/BN_mod_sqrt.3 b/src/lib/libcrypto/man/BN_mod_sqrt.3
deleted file mode 100644
index 7247d907a0..0000000000
--- a/src/lib/libcrypto/man/BN_mod_sqrt.3
+++ /dev/null
@@ -1,111 +0,0 @@
1.\" $OpenBSD: BN_mod_sqrt.3,v 1.2 2022/12/06 22:22:42 tb Exp $
2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 6 2022 $
18.Dt BN_MOD_SQRT 3
19.Os
20.Sh NAME
21.Nm BN_mod_sqrt
22.Nd square root in a prime field
23.Sh SYNOPSIS
24.In openssl/bn.h
25.Ft BIGNUM *
26.Fo BN_mod_sqrt
27.Fa "BIGNUM *r"
28.Fa "const BIGNUM *a"
29.Fa "const BIGNUM *p"
30.Fa "BN_CTX *ctx"
31.Fc
32.Sh DESCRIPTION
33.Fn BN_mod_sqrt
34solves
35.Bd -unfilled -offset indent
36.EQ
37r sup 2 == a ( roman mod p )
38.EN
39.Ed
40.Pp
41for
42.Fa r
43in the prime field of characteristic
44.Fa p
45using the Tonelli-Shanks algorithm if needed
46and places one of the two solutions into
47.Fa r .
48The other solution is
49.Fa p
50\-
51.Fa r .
52.Pp
53The argument
54.Fa p
55is expected to be a prime number.
56.Sh RETURN VALUES
57In case of success,
58.Fn BN_mod_sqrt
59returns
60.Fa r ,
61or a newly allocated
62.Vt BIGNUM
63object if the
64.Fa r
65argument is
66.Dv NULL .
67.Pp
68In case of failure,
69.Dv NULL
70is returned.
71This for example happens if
72.Fa a
73is not a quadratic residue or if memory allocation fails.
74.Sh SEE ALSO
75.Xr BN_CTX_new 3 ,
76.Xr BN_kronecker 3 ,
77.Xr BN_mod_sqr 3 ,
78.Xr BN_new 3
79.Rs
80.%A Henri Cohen
81.%B A Course in Computational Algebraic Number Theory
82.%I Springer
83.%C Berlin
84.%D 1993
85.%O Algorithm 1.5.1
86.Re
87.Sh HISTORY
88.Fn BN_mod_sqrt
89first appeared in OpenSSL 0.9.7 and has been available since
90.Ox 3.2 .
91.Sh CAVEATS
92If
93.Fa p
94is not prime,
95.Fn BN_mod_sqrt
96may succeed or fail.
97If it succeeds, the square of the returned value is congruent to
98.Fa a
99modulo
100.Fa p .
101If it fails, the reason reported by
102.Xr ERR_get_error 3
103is often misleading.
104In particular, even if
105.Fa a
106is a perfect square,
107.Fn BN_mod_sqrt
108often reports
109.Dq not a square
110instead of
111.Dq p is not prime .
diff --git a/src/lib/libcrypto/man/BN_new.3 b/src/lib/libcrypto/man/BN_new.3
deleted file mode 100644
index 088048c622..0000000000
--- a/src/lib/libcrypto/man/BN_new.3
+++ /dev/null
@@ -1,165 +0,0 @@
1.\" $OpenBSD: BN_new.3,v 1.31 2023/07/26 20:08:59 tb Exp $
2.\" full merge up to: OpenSSL man3/BN_new 2457c19d Mar 6 08:43:36 2004 +0000
3.\" selective merge up to: man3/BN_new 681acb31 Sep 29 13:10:34 2017 +0200
4.\" full merge up to: OpenSSL man7/bn 05ea606a May 20 20:52:46 2016 -0400
5.\"
6.\" This file was written by Ulf Moeller <ulf@openssl.org>.
7.\" Copyright (c) 2000, 2004 The OpenSSL Project. All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: July 26 2023 $
54.Dt BN_NEW 3
55.Os
56.Sh NAME
57.Nm BN_new ,
58.Nm BN_clear ,
59.Nm BN_free ,
60.Nm BN_clear_free
61.Nd allocate and free BIGNUMs
62.Sh SYNOPSIS
63.In openssl/bn.h
64.Ft BIGNUM *
65.Fo BN_new
66.Fa void
67.Fc
68.Ft void
69.Fo BN_clear
70.Fa "BIGNUM *a"
71.Fc
72.Ft void
73.Fo BN_free
74.Fa "BIGNUM *a"
75.Fc
76.Ft void
77.Fo BN_clear_free
78.Fa "BIGNUM *a"
79.Fc
80.Sh DESCRIPTION
81The BN library performs arithmetic operations on integers of arbitrary
82size.
83It was written for use in public key cryptography, such as RSA and
84Diffie-Hellman.
85.Pp
86It uses dynamic memory allocation for storing its data structures.
87That means that there is no limit on the size of the numbers manipulated
88by these functions, but return values must always be checked in case a
89memory allocation error has occurred.
90.Pp
91The basic object in this library is a
92.Vt BIGNUM .
93It is used to hold a single large integer.
94This type should be considered opaque and fields should not be modified
95or accessed directly.
96.Pp
97.Fn BN_new
98allocates and initializes a
99.Vt BIGNUM
100structure, in particular setting the value to zero and the flags to
101.Dv BN_FLG_MALLOCED .
102The security-relevant flag
103.Dv BN_FLG_CONSTTIME
104is not set by default.
105.Pp
106.Fn BN_clear
107is used to destroy sensitive data such as keys when they are no longer
108needed.
109It erases the memory used by
110.Fa a
111and sets it to the value 0.
112.Pp
113.Fn BN_free
114frees the components of the
115.Vt BIGNUM
116and, if it was created by
117.Fn BN_new ,
118also the structure itself.
119.Fn BN_clear_free
120additionally overwrites the data before the memory is returned to the
121system.
122If
123.Fa a
124is a
125.Dv NULL
126pointer, no action occurs.
127.Sh RETURN VALUES
128.Fn BN_new
129returns a pointer to the
130.Vt BIGNUM .
131If the allocation fails, it returns
132.Dv NULL
133and sets an error code that can be obtained by
134.Xr ERR_get_error 3 .
135.Sh SEE ALSO
136.Xr BN_add 3 ,
137.Xr BN_add_word 3 ,
138.Xr BN_bn2bin 3 ,
139.Xr BN_cmp 3 ,
140.Xr BN_copy 3 ,
141.Xr BN_CTX_new 3 ,
142.Xr BN_CTX_start 3 ,
143.Xr BN_generate_prime 3 ,
144.Xr BN_get_rfc3526_prime_8192 3 ,
145.Xr BN_kronecker 3 ,
146.Xr BN_mod_inverse 3 ,
147.Xr BN_mod_mul_montgomery 3 ,
148.Xr BN_mod_sqrt 3 ,
149.Xr BN_num_bytes 3 ,
150.Xr BN_rand 3 ,
151.Xr BN_security_bits 3 ,
152.Xr BN_set_bit 3 ,
153.Xr BN_set_flags 3 ,
154.Xr BN_set_negative 3 ,
155.Xr BN_swap 3 ,
156.Xr BN_zero 3 ,
157.Xr crypto 3
158.Sh HISTORY
159.Fn BN_new ,
160.Fn BN_clear ,
161.Fn BN_free ,
162and
163.Fn BN_clear_free
164first appeared in SSLeay 0.5.1 and have been available since
165.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BN_num_bytes.3 b/src/lib/libcrypto/man/BN_num_bytes.3
deleted file mode 100644
index 785f43e2f0..0000000000
--- a/src/lib/libcrypto/man/BN_num_bytes.3
+++ /dev/null
@@ -1,175 +0,0 @@
1.\" $OpenBSD: BN_num_bytes.3,v 1.9 2022/11/22 18:55:04 schwarze Exp $
2.\" full merge up to: OpenSSL 9e183d22 Mar 11 08:56:44 2017 -0500
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ulf Moeller <ulf@openssl.org>
22.\" and Richard Levitte <levitte@openssl.org>.
23.\" Copyright (c) 2000, 2004 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: November 22 2022 $
70.Dt BN_NUM_BYTES 3
71.Os
72.Sh NAME
73.Nm BN_num_bits_word ,
74.Nm BN_num_bits ,
75.Nm BN_num_bytes
76.Nd get BIGNUM size
77.Sh SYNOPSIS
78.In openssl/bn.h
79.Ft int
80.Fo BN_num_bits_word
81.Fa "BN_ULONG w"
82.Fc
83.Ft int
84.Fo BN_num_bits
85.Fa "const BIGNUM *a"
86.Fc
87.Ft int
88.Fo BN_num_bytes
89.Fa "const BIGNUM *a"
90.Fc
91.Sh DESCRIPTION
92.Fn BN_num_bits_word
93returns the number of significant bits in
94.Fa w ,
95that is, the minimum number of digits needed to write
96.Fa w
97as a binary number.
98Except for an argument of 0, this is
99.Pp
100.D1 floor(log2( Ns Fa w ) ) No + 1 .
101.Pp
102.Vt BN_ULONG
103is a macro that expands to
104.Vt unsigned long Pq = Vt uint64_t
105on
106.Dv _LP64
107platforms and
108.Vt unsigned int Pq = Vt uint32_t
109elsewhere.
110.Pp
111.Fn BN_num_bits
112returns the number of significant bits in the value of the
113.Fa "BIGNUM *a" ,
114following the same principle as
115.Fn BN_num_bits_word .
116.Pp
117.Fn BN_num_bytes
118is a macro that returns the number of significant bytes in
119.Fa a ,
120i.e. the minimum number of bytes needed to store the value of
121.Fa a ,
122that is,
123.Fn BN_num_bits a
124divided by eight and rounded up to the next integer number.
125.Sh RETURN VALUES
126.Fn BN_num_bits_word
127returns the number of significant bits in
128.Fa w
129or 0 if
130.Fa w
131is 0.
132The maximum return value that can occur is
133.Dv BN_BITS2 ,
134which is 64 on
135.Dv _LP64
136platforms and 32 elsewhere.
137.Pp
138.Fn BN_num_bits
139returns the number of significant bits and
140.Fn BN_num_bytes
141the number of significant bytes in
142.Fa a ,
143or 0 if the value of
144.Fa a
145is 0.
146.Sh SEE ALSO
147.Xr BN_new 3 ,
148.Xr BN_security_bits 3 ,
149.Xr DH_size 3 ,
150.Xr DSA_size 3 ,
151.Xr RSA_size 3
152.Sh HISTORY
153.Fn BN_num_bytes
154and
155.Fn BN_num_bits
156first appeared in SSLeay 0.5.1.
157.Fn BN_num_bits_word
158first appeared in SSLeay 0.5.2.
159These functions have been available since
160.Ox 2.4 .
161.Sh CAVEATS
162Some have tried using
163.Fn BN_num_bits
164on individual numbers in RSA keys, DH keys and DSA keys, and found that
165they don't always come up with the number of bits they expected
166(something like 512, 1024, 2048, ...).
167This is because generating a number with some specific number of bits
168doesn't always set the highest bits, thereby making the number of
169.Em significant
170bits a little smaller.
171If you want to know the "key size" of such a key, use functions like
172.Xr RSA_size 3 ,
173.Xr DH_size 3 ,
174and
175.Xr DSA_size 3 .
diff --git a/src/lib/libcrypto/man/BN_rand.3 b/src/lib/libcrypto/man/BN_rand.3
deleted file mode 100644
index 3d4401a429..0000000000
--- a/src/lib/libcrypto/man/BN_rand.3
+++ /dev/null
@@ -1,146 +0,0 @@
1.\" $OpenBSD: BN_rand.3,v 1.18 2021/11/30 18:34:35 tb Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
4.\"
5.\" This file was written by Ulf Moeller <ulf@openssl.org>.
6.\" Copyright (c) 2000, 2001, 2002, 2013, 2015 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: November 30 2021 $
54.Dt BN_RAND 3
55.Os
56.Sh NAME
57.Nm BN_rand ,
58.Nm BN_rand_range ,
59.Nm BN_pseudo_rand ,
60.Nm BN_pseudo_rand_range
61.Nd generate pseudo-random number
62.Sh SYNOPSIS
63.In openssl/bn.h
64.Ft int
65.Fo BN_rand
66.Fa "BIGNUM *rnd"
67.Fa "int bits"
68.Fa "int top"
69.Fa "int bottom"
70.Fc
71.Ft int
72.Fo BN_rand_range
73.Fa "BIGNUM *rnd"
74.Fa "const BIGNUM *range"
75.Fc
76.Sh DESCRIPTION
77.Fn BN_rand
78generates a cryptographically strong pseudo-random number of
79.Fa bits
80in length and stores it in
81.Fa rnd .
82If
83.Fa top
84is
85.Dv BN_RAND_TOP_ANY ,
86the most significant bit of the random number can be zero.
87If
88.Fa top
89is
90.Dv BN_RAND_TOP_ONE ,
91the most significant bit is set to 1, and if
92.Fa top
93is
94.Dv BN_RAND_TOP_TWO ,
95the two most significant bits of the number will be set to 1, so
96that the product of two such random numbers will always have
97.Pf 2* Fa bits
98length.
99If
100.Fa bottom
101is
102.Dv BN_RAND_BOTTOM_ODD ,
103the number will be odd;
104if it is
105.Dv BN_RAND_BOTTOM_ANY ,
106it can be odd or even.
107The value of
108.Fa bits
109must be zero or greater.
110If
111.Fa bits
112is +1 then
113.Fa top
114cannot be
115.Dv BN_RAND_TOP_TWO .
116.Pp
117.Fn BN_rand_range
118generates a cryptographically strong pseudo-random number
119.Fa rnd
120in the range 0 <=
121.Fa rnd No < Fa range .
122.Pp
123.Fn BN_pseudo_rand
124is a deprecated alias for
125.Fn BN_rand ,
126and
127.Fn BN_pseudo_rand_range
128for
129.Fn BN_rand_range .
130.Sh RETURN VALUES
131The functions return 1 on success, 0 on error.
132The error codes can be obtained by
133.Xr ERR_get_error 3 .
134.Sh SEE ALSO
135.Xr BN_new 3
136.Sh HISTORY
137.Fn BN_rand
138first appeared in SSLeay 0.5.1 and has been available since
139.Ox 2.4 .
140.Pp
141The
142.Fa top
143== -1 case and the function
144.Fn BN_rand_range
145first appeared in OpenSSL 0.9.6a and have been available since
146.Ox 3.0 .
diff --git a/src/lib/libcrypto/man/BN_set_bit.3 b/src/lib/libcrypto/man/BN_set_bit.3
deleted file mode 100644
index 2c53066777..0000000000
--- a/src/lib/libcrypto/man/BN_set_bit.3
+++ /dev/null
@@ -1,216 +0,0 @@
1.\" $OpenBSD: BN_set_bit.3,v 1.8 2021/11/30 18:34:35 tb Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 30 2021 $
52.Dt BN_SET_BIT 3
53.Os
54.Sh NAME
55.Nm BN_set_bit ,
56.Nm BN_clear_bit ,
57.Nm BN_is_bit_set ,
58.Nm BN_mask_bits ,
59.Nm BN_lshift ,
60.Nm BN_lshift1 ,
61.Nm BN_rshift ,
62.Nm BN_rshift1
63.Nd bit operations on BIGNUMs
64.Sh SYNOPSIS
65.In openssl/bn.h
66.Ft int
67.Fo BN_set_bit
68.Fa "BIGNUM *a"
69.Fa "int n"
70.Fc
71.Ft int
72.Fo BN_clear_bit
73.Fa "BIGNUM *a"
74.Fa "int n"
75.Fc
76.Ft int
77.Fo BN_is_bit_set
78.Fa "const BIGNUM *a"
79.Fa "int n"
80.Fc
81.Ft int
82.Fo BN_mask_bits
83.Fa "BIGNUM *a"
84.Fa "int n"
85.Fc
86.Ft int
87.Fo BN_lshift
88.Fa "BIGNUM *r"
89.Fa "const BIGNUM *a"
90.Fa "int n"
91.Fc
92.Ft int
93.Fo BN_lshift1
94.Fa "BIGNUM *r"
95.Fa "const BIGNUM *a"
96.Fc
97.Ft int
98.Fo BN_rshift
99.Fa "BIGNUM *r"
100.Fa "const BIGNUM *a"
101.Fa "int n"
102.Fc
103.Ft int
104.Fo BN_rshift1
105.Fa "BIGNUM *r"
106.Fa "const BIGNUM *a"
107.Fc
108.Sh DESCRIPTION
109.Fn BN_set_bit
110sets bit
111.Fa n
112in
113.Fa a
114to 1
115.Pq Li a|=(1<<n) .
116The number is expanded if necessary.
117.Pp
118.Fn BN_clear_bit
119sets bit
120.Fa n
121in
122.Fa a
123to 0
124.Pq Li a&=~(1<<n) .
125An error occurs if
126.Fa a
127is shorter than
128.Fa n
129bits.
130.Pp
131.Fn BN_is_bit_set
132tests if bit
133.Fa n
134in
135.Fa a
136is set.
137.Pp
138.Fn BN_mask_bits
139truncates
140.Fa a
141to an
142.Fa n
143bit number
144.Pq Li a&=~((~0)>>n) .
145An error occurs if
146.Fa a
147already is shorter than
148.Fa n
149bits.
150.Pp
151.Fn BN_lshift
152shifts
153.Fa a
154left by
155.Fa n
156bits and places the result in
157.Fa r
158.Pq Li r=a*2^n .
159Note that
160.Fa n
161must be non-negative.
162.Fn BN_lshift1
163shifts
164.Fa a
165left by one and places the result in
166.Fa r
167.Pq Li r=2*a .
168.Pp
169.Fn BN_rshift
170shifts
171.Fa a
172right by
173.Fa n
174bits and places the result in
175.Fa r
176.Pq Li r=a/2^n .
177Note that
178.Fa n
179must be non-negative.
180.Fn BN_rshift1
181shifts
182.Fa a
183right by one and places the result in
184.Fa r
185.Pq Li r=a/2 .
186.Pp
187For the shift functions,
188.Fa r
189and
190.Fa a
191may be the same variable.
192.Sh RETURN VALUES
193.Fn BN_is_bit_set
194returns 1 if the bit is set, 0 otherwise.
195.Pp
196All other functions return 1 for success, 0 on error.
197The error codes can be obtained by
198.Xr ERR_get_error 3 .
199.Sh SEE ALSO
200.Xr BN_add 3 ,
201.Xr BN_new 3 ,
202.Xr BN_num_bytes 3 ,
203.Xr BN_set_negative 3 ,
204.Xr BN_zero 3
205.Sh HISTORY
206.Fn BN_set_bit ,
207.Fn BN_clear_bit ,
208.Fn BN_is_bit_set ,
209.Fn BN_mask_bits ,
210.Fn BN_lshift ,
211.Fn BN_lshift1 ,
212.Fn BN_rshift ,
213and
214.Fn BN_rshift1
215first appeared in SSLeay 0.5.1 and have been available since
216.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/BN_set_flags.3 b/src/lib/libcrypto/man/BN_set_flags.3
deleted file mode 100644
index 1285ae2b28..0000000000
--- a/src/lib/libcrypto/man/BN_set_flags.3
+++ /dev/null
@@ -1,160 +0,0 @@
1.\" $OpenBSD: BN_set_flags.3,v 1.6 2023/04/27 07:22:22 tb Exp $
2.\"
3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: April 27 2023 $
18.Dt BN_SET_FLAGS 3
19.Os
20.Sh NAME
21.Nm BN_set_flags ,
22.Nm BN_get_flags
23.Nd enable and inspect flags on BIGNUM objects
24.Sh SYNOPSIS
25.In openssl/bn.h
26.Ft void
27.Fo BN_set_flags
28.Fa "BIGNUM *b"
29.Fa "int flags"
30.Fc
31.Ft int
32.Fo BN_get_flags
33.Fa "const BIGNUM *b"
34.Fa "int flags"
35.Fc
36.Sh DESCRIPTION
37.Fn BN_set_flags
38enables the given
39.Fa flags
40on
41.Fa b .
42The
43.Fa flags
44argument can contain zero or more of the following constants OR'ed
45together:
46.Bl -tag -width Ds
47.It Dv BN_FLG_CONSTTIME
48If this flag is set on the divident
49.Fa a
50or the divisor
51.Fa d
52in
53.Xr BN_div 3 ,
54on the exponent
55.Fa p
56in
57.Xr BN_mod_exp 3 ,
58or on the divisor
59.Fa a
60or the modulus
61.Fa n
62in
63.Xr BN_mod_inverse 3 ,
64these functions select algorithms with an execution time independent
65of the respective numbers, to avoid exposing sensitive information
66to timing side-channel attacks.
67.Pp
68This flag is off by default for
69.Vt BIGNUM
70objects created with
71.Xr BN_new 3 .
72.It Dv BN_FLG_MALLOCED
73If this flag is set,
74.Xr BN_free 3
75and
76.Xr BN_clear_free 3
77will not only clear and free the components of
78.Fa b ,
79but also
80.Fa b
81itself.
82This flag is set internally by
83.Xr BN_new 3 .
84Setting it manually on an existing
85.Vt BIGNUM
86object is usually a bad idea and can cause calls to
87.Xr free 3
88with bogus arguments.
89.It Dv BN_FLG_STATIC_DATA
90If this flag is set,
91.Xr BN_clear_free 3
92will neither clear nor free the memory used for storing the number.
93Consequently, setting it manually on an existing
94.Vt BIGNUM
95object is usually a terrible idea that can cause both disclosure
96of secret data and memory leaks.
97This flag is automatically set on the constant
98.Vt BIGNUM
99object returned by
100.Xr BN_value_one 3 .
101.El
102.Pp
103.Fn BN_get_flags
104interprets
105.Fa flags
106as a bitmask and returns those of the given flags that are set in
107.Fa b ,
108OR'ed together, or 0 if none of the given
109.Fa flags
110is set.
111The
112.Fa flags
113argument has the same syntax as for
114.Fn BN_set_flags .
115.Sh RETURN VALUES
116.Fn BN_get_flags
117returns zero or more of the above constants, OR'ed together.
118.Sh SEE ALSO
119.Xr BN_mod_exp 3 ,
120.Xr BN_mod_inverse 3 ,
121.Xr BN_new 3 ,
122.Xr BN_with_flags 3
123.Sh HISTORY
124.Fn BN_set_flags
125and
126.Fn BN_get_flags
127first appeared in SSLeay 0.9.1 and have been available since
128.Ox 2.6 .
129.Sh CAVEATS
130No public interface exists to clear a flag once it is set.
131So think twice before using
132.Fn BN_set_flags .
133.Sh BUGS
134Even if the
135.Dv BN_FLG_CONSTTIME
136flag is set on
137.Fa a
138or
139.Fa b ,
140.Fn BN_gcd
141neither fails nor operates in constant time, potentially allowing
142timing side-channel attacks.
143.Pp
144Even if the
145.Dv BN_FLG_CONSTTIME
146flag is set on
147.Fa p ,
148if the modulus
149.Fa m
150is even,
151.Xr BN_mod_exp 3
152does not operate in constant time, potentially allowing
153timing side-channel attacks.
154.Pp
155If
156.Dv BN_FLG_CONSTTIME
157is set on
158.Fa p ,
159.Fn BN_exp
160fails instead of operating in constant time.
diff --git a/src/lib/libcrypto/man/BN_set_negative.3 b/src/lib/libcrypto/man/BN_set_negative.3
deleted file mode 100644
index 6cdff5c974..0000000000
--- a/src/lib/libcrypto/man/BN_set_negative.3
+++ /dev/null
@@ -1,63 +0,0 @@
1.\" $OpenBSD: BN_set_negative.3,v 1.6 2021/12/06 19:45:27 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 6 2021 $
18.Dt BN_SET_NEGATIVE 3
19.Os
20.Sh NAME
21.Nm BN_set_negative ,
22.Nm BN_is_negative
23.Nd change and inspect the sign of a BIGNUM
24.Sh SYNOPSIS
25.In openssl/bn.h
26.Ft void
27.Fo BN_set_negative
28.Fa "BIGNUM *b"
29.Fa "int n"
30.Fc
31.Ft int
32.Fo BN_is_negative
33.Fa "const BIGNUM *b"
34.Fc
35.Sh DESCRIPTION
36.Fn BN_set_negative
37sets
38.Fa b
39to negative if both
40.Fa b
41and
42.Fa n
43are non-zero, otherwise it sets it to positive.
44.Pp
45.Fn BN_is_negative
46tests the sign of
47.Fa b .
48.Sh RETURN VALUES
49.Fn BN_is_negative
50returns 1 if
51.Fa b
52is negative or 0 otherwise.
53.Sh SEE ALSO
54.Xr BN_add 3 ,
55.Xr BN_new 3 ,
56.Xr BN_set_bit 3 ,
57.Xr BN_zero 3
58.Sh HISTORY
59.Fn BN_set_negative
60and
61.Fn BN_is_negative
62first appeared in OpenSSL 0.9.8 and have been available since
63.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/BN_swap.3 b/src/lib/libcrypto/man/BN_swap.3
deleted file mode 100644
index 218ca1cf02..0000000000
--- a/src/lib/libcrypto/man/BN_swap.3
+++ /dev/null
@@ -1,148 +0,0 @@
1.\" $OpenBSD: BN_swap.3,v 1.6 2021/12/19 22:06:35 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Bodo Moeller <bodo@openssl.org>.
22.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 19 2021 $
69.Dt BN_SWAP 3
70.Os
71.Sh NAME
72.Nm BN_swap ,
73.Nm BN_consttime_swap
74.Nd exchange BIGNUMs
75.Sh SYNOPSIS
76.In openssl/bn.h
77.Ft void
78.Fo BN_swap
79.Fa "BIGNUM *a"
80.Fa "BIGNUM *b"
81.Fc
82.Ft void
83.Fo BN_consttime_swap
84.Fa "BN_ULONG condition"
85.Fa "BIGNUM *a"
86.Fa "BIGNUM *b"
87.Fa "int nwords"
88.Fc
89.Sh DESCRIPTION
90.Fn BN_swap
91and
92.Fn BN_consttime_swap
93exchange the values of
94.Fa a
95and
96.Fa b .
97.Pp
98.Fn BN_swap
99implements this by exchanging the pointers to the data buffers of
100.Fa a
101and
102.Fa b
103and also exchanging the values of the
104.Dv BN_FLG_STATIC_DATA
105bits.
106Consequently, the operation is fast and execution time does not depend
107on any properties of the two numbers.
108However, execution time obviously differs between swapping (by calling
109this function) and not swapping (by not calling this function).
110.Pp
111.Fn BN_consttime_swap
112only performs the exchange if the
113.Fa condition
114is non-zero; otherwise, it has no effect.
115It implements the exchange by exchanging the contents of the data
116buffers rather than the pointers to the data buffers.
117This is slower, but implemented in such a way that the execution time
118is not only independent of the properties of the two numbers, but also
119independent of the
120.Fa condition
121argument, i.e. the same for swapping or not swapping.
122Execution time does however grow in an approximately linear manner with the
123.Fa nwords
124argument.
125.Pp
126.Fn BN_consttime_swap
127calls
128.Xr abort 3
129if at least one of
130.Fa a
131or
132.Fa b
133has fewer than
134.Fa nwords
135data words allocated or more than
136.Fa nwords
137data words are currently in use in at least one of them.
138.Sh SEE ALSO
139.Xr BN_new 3 ,
140.Xr BN_set_flags 3
141.Sh HISTORY
142.Fn BN_swap
143first appeared in OpenSSL 0.9.7 and has been available since
144.Ox 3.2 .
145.Pp
146.Fn BN_consttime_swap
147first appeared in OpenSSL 1.0.1g and has been available since
148.Ox 5.6 .
diff --git a/src/lib/libcrypto/man/BN_zero.3 b/src/lib/libcrypto/man/BN_zero.3
deleted file mode 100644
index 0b677b246f..0000000000
--- a/src/lib/libcrypto/man/BN_zero.3
+++ /dev/null
@@ -1,174 +0,0 @@
1.\" $OpenBSD: BN_zero.3,v 1.13 2023/04/30 19:23:54 tb Exp $
2.\" full merge up to: OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" selective merge up to: OpenSSL b713c4ff Jan 22 14:41:09 2018 -0500
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2021, 2022 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Ulf Moeller <ulf@openssl.org>.
23.\" Copyright (c) 2000, 2001, 2018 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: April 30 2023 $
71.Dt BN_ZERO 3
72.Os
73.Sh NAME
74.Nm BN_zero ,
75.Nm BN_one ,
76.Nm BN_value_one ,
77.Nm BN_set_word ,
78.Nm BN_get_word
79.Nd BIGNUM assignment operations
80.Sh SYNOPSIS
81.In openssl/bn.h
82.Ft int
83.Fo BN_zero
84.Fa "BIGNUM *a"
85.Fc
86.Ft int
87.Fo BN_one
88.Fa "BIGNUM *a"
89.Fc
90.Ft const BIGNUM *
91.Fo BN_value_one
92.Fa void
93.Fc
94.Ft int
95.Fo BN_set_word
96.Fa "BIGNUM *a"
97.Fa "BN_ULONG w"
98.Fc
99.Ft BN_ULONG
100.Fo BN_get_word
101.Fa "const BIGNUM *a"
102.Fc
103.Sh DESCRIPTION
104.Vt BN_ULONG
105is a macro that expands to an unsigned integral type optimized
106for the most efficient implementation on the local platform.
107It is
108.Vt unsigned long Pq = Vt uint64_t
109on
110.Dv _LP64
111platforms and
112.Vt unsigned int Pq = Vt uint32_t
113elsewhere.
114.Pp
115.Fn BN_zero ,
116.Fn BN_one ,
117and
118.Fn BN_set_word
119set
120.Fa a
121to the values 0, 1 and
122.Fa w
123respectively.
124.Pp
125.Fn BN_value_one
126returns a
127.Vt BIGNUM
128constant of value 1.
129This constant is useful for comparisons and assignments.
130.Sh RETURN VALUES
131.Fn BN_get_word
132returns the value
133.Fa a ,
134or a number with all bits set if
135.Fa a
136cannot be represented as a
137.Vt BN_ULONG .
138.Pp
139.Fn BN_zero ,
140.Fn BN_one ,
141and
142.Fn BN_set_word
143return 1 on success, 0 otherwise.
144.Fn BN_value_one
145returns the constant.
146.Sh SEE ALSO
147.Xr BN_bn2bin 3 ,
148.Xr BN_new 3 ,
149.Xr BN_set_bit 3 ,
150.Xr BN_set_negative 3
151.Sh HISTORY
152.Fn BN_zero ,
153.Fn BN_one ,
154.Fn BN_value_one ,
155and
156.Fn BN_set_word
157first appeared in SSLeay 0.5.1.
158.Fn BN_get_word
159first appeared in SSLeay 0.6.0.
160These functions have been available since
161.Ox 2.4 .
162.Sh BUGS
163Someone might change the constant.
164.Pp
165If the value of a
166.Vt BIGNUM
167is equal to a
168.Vt BN_ULONG
169with all bits set, the return value of
170.Fn BN_get_word
171collides with return value used to indicate errors.
172.Pp
173.Vt BN_ULONG
174should probably be a typedef rather than a macro.
diff --git a/src/lib/libcrypto/man/BUF_MEM_new.3 b/src/lib/libcrypto/man/BUF_MEM_new.3
deleted file mode 100644
index 8c72091abe..0000000000
--- a/src/lib/libcrypto/man/BUF_MEM_new.3
+++ /dev/null
@@ -1,153 +0,0 @@
1.\" $OpenBSD: BUF_MEM_new.3,v 1.19 2024/07/24 08:57:58 tb Exp $
2.\" OpenSSL doc/crypto/buffer.pod 18edda0f Sep 20 03:28:54 2000 +0000
3.\" not merged: 74924dcb, 58e3457a, 21b0fa91, 7644a9ae
4.\" OpenSSL doc/crypto/BUF_MEM_new.pod 53934822 Jun 9 16:39:19 2016 -0400
5.\" not merged: c952780c, 91da5e77
6.\" OpenSSL doc/man3/BUF_MEM_new.pod 498180de Dec 12 15:35:09 2016 +0300
7.\"
8.\" This file was written by Ralf S. Engelschall <rse@openssl.org>.
9.\" Copyright (c) 1999, 2000, 2016 The OpenSSL Project. All rights reserved.
10.\"
11.\" Redistribution and use in source and binary forms, with or without
12.\" modification, are permitted provided that the following conditions
13.\" are met:
14.\"
15.\" 1. Redistributions of source code must retain the above copyright
16.\" notice, this list of conditions and the following disclaimer.
17.\"
18.\" 2. Redistributions in binary form must reproduce the above copyright
19.\" notice, this list of conditions and the following disclaimer in
20.\" the documentation and/or other materials provided with the
21.\" distribution.
22.\"
23.\" 3. All advertising materials mentioning features or use of this
24.\" software must display the following acknowledgment:
25.\" "This product includes software developed by the OpenSSL Project
26.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
27.\"
28.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
29.\" endorse or promote products derived from this software without
30.\" prior written permission. For written permission, please contact
31.\" openssl-core@openssl.org.
32.\"
33.\" 5. Products derived from this software may not be called "OpenSSL"
34.\" nor may "OpenSSL" appear in their names without prior written
35.\" permission of the OpenSSL Project.
36.\"
37.\" 6. Redistributions of any form whatsoever must retain the following
38.\" acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
41.\"
42.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
43.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
46.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\"
55.Dd $Mdocdate: July 24 2024 $
56.Dt BUF_MEM_NEW 3
57.Os
58.Sh NAME
59.Nm BUF_MEM_new ,
60.Nm BUF_MEM_free ,
61.Nm BUF_MEM_grow ,
62.Nm BUF_MEM_grow_clean
63.Nd simple character arrays structure
64.Sh SYNOPSIS
65.In openssl/buffer.h
66.Ft BUF_MEM *
67.Fo BUF_MEM_new
68.Fa void
69.Fc
70.Ft void
71.Fo BUF_MEM_free
72.Fa "BUF_MEM *a"
73.Fc
74.Ft int
75.Fo BUF_MEM_grow
76.Fa "BUF_MEM *str"
77.Fa "size_t len"
78.Fc
79.Ft int
80.Fo BUF_MEM_grow_clean
81.Fa "BUF_MEM *str"
82.Fa "size_t len"
83.Fc
84.Sh DESCRIPTION
85The buffer library handles simple character arrays.
86Buffers are used for various purposes in the library, most notably
87memory BIOs.
88.Pp
89The library uses the
90.Vt BUF_MEM
91structure defined in buffer.h:
92.Bd -literal
93typedef struct buf_mem_st {
94 size_t length; /* current number of bytes */
95 char *data;
96 size_t max; /* size of buffer */
97} BUF_MEM;
98.Ed
99.Pp
100.Fa length
101is the current size of the buffer in bytes;
102.Fa max
103is the amount of memory allocated to the buffer.
104There are three functions which handle these and one miscellaneous function.
105.Pp
106.Fn BUF_MEM_new
107allocates a new buffer of zero size.
108.Pp
109.Fn BUF_MEM_free
110frees up an already existing buffer.
111The data is zeroed before freeing up in case the buffer contains
112sensitive data.
113If
114.Fa a
115is a
116.Dv NULL
117pointer, no action occurs.
118.Pp
119.Fn BUF_MEM_grow
120changes the size of an already existing buffer to
121.Fa len .
122Any data already in the buffer is preserved if it increases in size.
123.Pp
124.Fn BUF_MEM_grow_clean
125is similar to
126.Fn BUF_MEM_grow ,
127but it sets any freed or additionally allocated memory to zero.
128.Sh RETURN VALUES
129.Fn BUF_MEM_new
130returns the buffer or
131.Dv NULL
132on error.
133.Pp
134.Fn BUF_MEM_grow
135and
136.Fn BUF_MEM_grow_clean
137return zero on error or the new size (i.e.\&
138.Fa len ) .
139.Sh SEE ALSO
140.Xr BIO_new 3 ,
141.Xr BIO_s_mem 3
142.Sh HISTORY
143.Fn BUF_MEM_new ,
144.Fn BUF_MEM_free ,
145and
146.Fn BUF_MEM_grow
147first appeared in SSLeay 0.6.0.
148All these functions have been available since
149.Ox 2.4 .
150.Pp
151.Fn BUF_MEM_grow_clean
152first appeared in OpenSSL 0.9.7 and has been available since
153.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/CMAC_Init.3 b/src/lib/libcrypto/man/CMAC_Init.3
deleted file mode 100644
index fd32ca085a..0000000000
--- a/src/lib/libcrypto/man/CMAC_Init.3
+++ /dev/null
@@ -1,273 +0,0 @@
1.\" $OpenBSD: CMAC_Init.3,v 1.9 2024/11/12 00:42:28 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 12 2024 $
18.Dt CMAC_INIT 3
19.Os
20.Sh NAME
21.Nm CMAC_CTX_new ,
22.Nm CMAC_Init ,
23.Nm CMAC_Update ,
24.Nm CMAC_Final ,
25.Nm CMAC_CTX_copy ,
26.Nm CMAC_CTX_get0_cipher_ctx ,
27.Nm CMAC_CTX_cleanup ,
28.Nm CMAC_CTX_free
29.Nd Cipher-based message authentication code
30.Sh SYNOPSIS
31.In openssl/cmac.h
32.Ft CMAC_CTX *
33.Fn CMAC_CTX_new void
34.Ft int
35.Fo CMAC_Init
36.Fa "CMAC_CTX *ctx"
37.Fa "const void *key"
38.Fa "size_t key_len"
39.Fa "const EVP_CIPHER *cipher"
40.Fa "ENGINE *engine"
41.Fc
42.Ft int
43.Fo CMAC_Update
44.Fa "CMAC_CTX *ctx"
45.Fa "const void *in_data"
46.Fa "size_t in_len"
47.Fc
48.Ft int
49.Fo CMAC_Final
50.Fa "CMAC_CTX *ctx"
51.Fa "unsigned char *out_mac"
52.Fa "size_t *out_len"
53.Fc
54.Ft int
55.Fo CMAC_CTX_copy
56.Fa "CMAC_CTX *out_ctx"
57.Fa "CMAC_CTX *in_ctx"
58.Fc
59.Ft EVP_CIPHER_CTX *
60.Fn CMAC_CTX_get0_cipher_ctx "CMAC_CTX *ctx"
61.Ft void
62.Fn CMAC_CTX_cleanup "CMAC_CTX *ctx"
63.Ft void
64.Fn CMAC_CTX_free "CMAC_CTX *ctx"
65.Sh DESCRIPTION
66CMAC is a message authentication code algorithm that can employ an
67arbitrary block cipher using a symmetric key.
68.Pp
69The present manual page describes low-level functions implementing CMAC.
70Instead of using these functions directly,
71application programs normally call
72.Xr EVP_PKEY_new_CMAC_key 3
73and then pass the resulting
74.Vt EVP_PKEY
75object to
76.Xr EVP_DigestSignInit 3 .
77.Pp
78The CMAC API is object-oriented.
79Calculating a message authentication code requires a
80.Vt CMAC_CTX
81object.
82Usually, the functions
83.Fn CMAC_CTX_new ,
84.Fn CMAC_Init ,
85.Fn CMAC_Update ,
86.Fn CMAC_Final ,
87and
88.Fn CMAC_CTX_free
89need to be called in this order.
90.Pp
91.Fn CMAC_CTX_new
92allocates a new
93.Vt CMAC_CTX
94object, initializes the embedded
95.Vt EVP_CIPHER_CTX
96object, and marks the object itself as uninitialized.
97.Pp
98.Fn CMAC_Init
99selects the given block
100.Fa cipher
101for use by
102.Fa ctx .
103Functions to obtain suitable
104.Vt EVP_CIPHER
105objects are listed in the CIPHER LISTING section of the
106.Xr EVP_EncryptInit 3
107manual page.
108Unless
109.Fa key
110is
111.Dv NULL ,
112.Fn CMAC_Init
113also initializes
114.Fa ctx
115for use with the given symmetric
116.Fa key
117that is
118.Fa key_len
119bytes long.
120In particular, it calculates and internally stores the two subkeys
121and initializes
122.Fa ctx
123for subsequently feeding in data with
124.Fn CMAC_Update .
125The
126.Fa engine
127argument is ignored; passing
128.Dv NULL
129is recommended.
130.Pp
131If
132.Fa ctx
133is already initialized,
134.Fn CMAC_Init
135can be called again with
136.Fa key
137and
138.Fa cipher
139both set to
140.Dv NULL
141and
142.Fa key_len
143set to 0.
144In that case, any data already processed is discarded and
145.Fa ctx
146is re-initialized to start reading data anew.
147.Pp
148.Fn CMAC_Update
149processes
150.Fa in_len
151bytes of input data pointed to by
152.Fa in_data .
153Depending on the number of input bytes already cached in
154.Fa ctx ,
155on
156.Fa in_len ,
157and on the block size, this may encrypt zero or more blocks.
158Unless
159.Fa in_len
160is zero, this function leaves at least one byte and at most one
161block of input cached but unprocessed inside the
162.Fa ctx
163object.
164.Fn CMAC_Update
165can be called multiple times
166to concatenate several chunks of input data of varying sizes.
167.Pp
168.Fn CMAC_Final
169stores the length of the message authentication code in bytes,
170which equals the cipher block size, into
171.Pf * Fa out_len .
172Unless
173.Fa out_mac
174is
175.Dv NULL ,
176it encrypts the last block, padding it if required, and copies the
177resulting message authentication code to
178.Fa out_mac .
179The caller is responsible for providing a buffer of sufficient size.
180.Pp
181.Fn CMAC_CTX_copy
182performs a deep copy of the already initialized
183.Fa in_ctx
184into
185.Fa out_ctx .
186.Pp
187.Fn CMAC_CTX_cleanup
188zeros out both subkeys and all temporary data in
189.Fa ctx
190and in the embedded
191.Vt EVP_CIPHER_CTX
192object, frees all allocated memory associated with it,
193except for
194.Fa ctx
195itself, and marks it as uninitialized,
196such that it can be reused for subsequent
197.Fn CMAC_Init .
198.Pp
199.Fn CMAC_CTX_free
200calls
201.Fn CMAC_CTX_cleanup ,
202then frees
203.Fa ctx
204itself.
205If
206.Fa ctx
207is
208.Dv NULL ,
209no action occurs.
210.Sh RETURN VALUES
211.Fn CMAC_CTX_new
212returns the new context object or
213.Dv NULL
214in case of failure.
215It succeeds unless memory is exhausted.
216.Pp
217.Fn CMAC_Init ,
218.Fn CMAC_Update ,
219.Fn CMAC_Final ,
220and
221.Fn CMAC_CTX_copy
222return 1 on success or 0 on failure.
223.Fn CMAC_Init
224fails if initializing the embedded
225.Vt EVP_CIPHER_CTX
226object fails.
227The others fail if
228.Fa in_ctx
229is uninitialized.
230.Fn CMAC_Update
231and
232.Fn CMAC_Final
233also fail if encrypting a block fails, and
234.Fn CMAC_CTX_copy
235if copying the embedded
236.Vt EVP_CIPHER_CTX
237object fails, which can for example happen when memory is exhausted.
238.Pp
239.Fn CMAC_CTX_get0_cipher_ctx
240returns an internal pointer to the
241.Vt EVP_CIPHER_CTX
242object that is embedded in
243.Fa ctx .
244.Sh ERRORS
245The CMAC code itself does not use the
246.In openssl/err.h
247framework, so in general, the reasons for failure cannot be found out with
248.Xr ERR_get_error 3 .
249However, since the
250.Xr EVP_EncryptInit 3
251functions are used internally, entries may still get pushed onto
252the error stack in some cases of failure.
253.Sh SEE ALSO
254.Xr EVP_aes_128_cbc 3 ,
255.Xr EVP_DigestSignInit 3 ,
256.Xr EVP_EncryptInit 3 ,
257.Xr EVP_PKEY_new_CMAC_key 3 ,
258.Xr HMAC 3
259.Sh STANDARDS
260.Rs
261.%A Morris Dworkin
262.%T "Recommendation for Block Cipher Modes of Operation:\
263 The CMAC Mode for Authentication"
264.%I National Institute of Standards and Technology
265.%R NIST Special Publication 800-38B
266.%U https://doi.org/10.6028/NIST.SP.800-38B
267.%C Gaithersburg, Maryland
268.%D May 2005, updated October 6, 2016
269.Re
270.Sh HISTORY
271These functions first appeared in OpenSSL 1.0.1
272and have been available since
273.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/CMS_ContentInfo_new.3 b/src/lib/libcrypto/man/CMS_ContentInfo_new.3
deleted file mode 100644
index d5117fa4ae..0000000000
--- a/src/lib/libcrypto/man/CMS_ContentInfo_new.3
+++ /dev/null
@@ -1,135 +0,0 @@
1.\" $OpenBSD: CMS_ContentInfo_new.3,v 1.4 2024/01/22 14:00:13 tb Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\"
4.\" Permission to use, copy, modify, and distribute this software for any
5.\" purpose with or without fee is hereby granted, provided that the above
6.\" copyright notice and this permission notice appear in all copies.
7.\"
8.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\"
16.Dd $Mdocdate: January 22 2024 $
17.Dt CMS_CONTENTINFO_NEW 3
18.Os
19.Sh NAME
20.Nm CMS_ContentInfo_new ,
21.Nm CMS_ContentInfo_free ,
22.Nm CMS_ContentInfo_print_ctx ,
23.Nm CMS_ReceiptRequest_new ,
24.Nm CMS_ReceiptRequest_free
25.Nd Cryptographic Message Syntax data structures
26.Sh SYNOPSIS
27.In openssl/cms.h
28.Ft CMS_ContentInfo *
29.Fn CMS_ContentInfo_new void
30.Ft void
31.Fn CMS_ContentInfo_free "CMS_ContentInfo *cms"
32.Ft int
33.Fo CMS_ContentInfo_print_ctx
34.Fa "BIO *out"
35.Fa "CMS_ContentInfo *cms"
36.Fa "int indent"
37.Fa "const ASN1_PCTX *pctx"
38.Fc
39.Ft CMS_ReceiptRequest *
40.Fn CMS_ReceiptRequest_new void
41.Ft void
42.Fn CMS_ReceiptRequest_free "CMS_ReceiptRequest *rr"
43.Sh DESCRIPTION
44.Fn CMS_ContentInfo_new
45allocates and initializes an empty
46.Vt CMS_ContentInfo
47object, representing an ASN.1
48.Vt ContentInfo
49structure defined in RFC 5652 section 3.
50It can hold a pointer to an ASN.1 OBJECT IDENTIFIER
51and a pointer to either a
52.Vt SignedData ,
53.Vt EnvelopedData ,
54.Vt DigestedData ,
55.Vt EncryptedData ,
56.Vt AuthenticatedData ,
57or
58.Vt CompressedData
59object or to an arbitrary ASN.1 object.
60.Fn CMS_ContentInfo_free
61frees
62.Fa cms .
63.Pp
64.Fn CMS_ContentInfo_print_ctx
65prints a human readable representation of
66.Fa cms
67to
68.Fa out .
69.Pp
70.Fn CMS_ReceiptRequest_new
71allocates and initializes an empty
72.Vt CMS_ReceiptRequest
73object, representing an ASN.1
74.Vt ReceiptRequest
75structure defined in RFC 2634 section 2.7.
76It can contain a content identifier, a list of recipients requested
77to return a signed receipt, and a list of users to send the receipt to.
78.Fn CMS_ReceiptRequest_free
79frees
80.Fa rr .
81.Sh RETURN VALUES
82.Fn CMS_ContentInfo_new
83and
84.Fn CMS_ReceiptRequest_new
85return the new
86.Vt CMS_ContentInfo
87or
88.Vt CMS_ReceiptRequest
89object, respectively, or
90.Dv NULL
91if an error occurs.
92.Sh SEE ALSO
93.Xr BIO_new_CMS 3 ,
94.Xr CMS_add0_cert 3 ,
95.Xr CMS_add1_recipient_cert 3 ,
96.Xr CMS_add1_signer 3 ,
97.Xr CMS_compress 3 ,
98.Xr CMS_decrypt 3 ,
99.Xr CMS_encrypt 3 ,
100.Xr CMS_final 3 ,
101.Xr CMS_get0_RecipientInfos 3 ,
102.Xr CMS_get0_SignerInfos 3 ,
103.Xr CMS_get0_type 3 ,
104.Xr CMS_get1_ReceiptRequest 3 ,
105.Xr CMS_sign 3 ,
106.Xr CMS_sign_receipt 3 ,
107.Xr CMS_signed_add1_attr 3 ,
108.Xr CMS_uncompress 3 ,
109.Xr CMS_verify 3 ,
110.Xr CMS_verify_receipt 3 ,
111.Xr crypto 3 ,
112.Xr d2i_CMS_ContentInfo 3 ,
113.Xr i2d_CMS_bio_stream 3 ,
114.Xr PEM_read_bio_PrivateKey 3 ,
115.Xr PEM_write_bio_CMS_stream 3 ,
116.Xr SMIME_read_CMS 3 ,
117.Xr SMIME_write_CMS 3
118.Sh STANDARDS
119RFC 5652: Cryptographic Message Syntax, section 3: General Syntax
120.Pp
121RFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS)
122.Pp
123RFC 2634: Enhanced Security Services for S/MIME,
124section 2.7: Receipt Request Syntax
125.Sh HISTORY
126.Fn CMS_ContentInfo_new ,
127.Fn CMS_ContentInfo_free ,
128.Fn CMS_ReceiptRequest_new ,
129and
130.Fn CMS_ReceiptRequest_free
131first appeared in OpenSSL 0.9.8h and
132.Fn CMS_ContentInfo_print_ctx
133in OpenSSL 1.0.0.
134This functions have been available since
135.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/CMS_add0_cert.3 b/src/lib/libcrypto/man/CMS_add0_cert.3
deleted file mode 100644
index be9357cc9a..0000000000
--- a/src/lib/libcrypto/man/CMS_add0_cert.3
+++ /dev/null
@@ -1,222 +0,0 @@
1.\" $OpenBSD: CMS_add0_cert.3,v 1.10 2024/11/30 21:21:40 tb Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: November 30 2024 $
69.Dt CMS_ADD0_CERT 3
70.Os
71.Sh NAME
72.Nm CMS_add0_cert ,
73.Nm CMS_add1_cert ,
74.Nm CMS_get1_certs ,
75.Nm CMS_add0_crl ,
76.Nm CMS_add1_crl ,
77.Nm CMS_get1_crls
78.Nd CMS certificate and CRL utility functions
79.Sh SYNOPSIS
80.In openssl/cms.h
81.Ft int
82.Fo CMS_add0_cert
83.Fa "CMS_ContentInfo *cms"
84.Fa "X509 *certificate"
85.Fc
86.Ft int
87.Fo CMS_add1_cert
88.Fa "CMS_ContentInfo *cms"
89.Fa "X509 *certificate"
90.Fc
91.Ft STACK_OF(X509) *
92.Fo CMS_get1_certs
93.Fa "CMS_ContentInfo *cms"
94.Fc
95.Ft int
96.Fo CMS_add0_crl
97.Fa "CMS_ContentInfo *cms"
98.Fa "X509_CRL *crl"
99.Fc
100.Ft int
101.Fo CMS_add1_crl
102.Fa "CMS_ContentInfo *cms"
103.Fa "X509_CRL *crl"
104.Fc
105.Ft STACK_OF(X509_CRL) *
106.Fo CMS_get1_crls
107.Fa "CMS_ContentInfo *cms"
108.Fc
109.Sh DESCRIPTION
110.Fn CMS_add0_cert
111adds the
112.Fa certificate
113to the
114.Fa certificates
115field of
116.Fa cms
117if it is of the type
118.Vt SignedData
119or to the
120.Fa originatorInfo.certs
121field if it is of the type
122.Vt EnvelopedData .
123.Fn CMS_add1_cert
124does the same and also increments the reference count of the
125.Fa certificate
126with
127.Xr X509_up_ref 3
128in case of success.
129.Pp
130.Fn CMS_get1_certs
131returns all certificates in
132.Fa cms .
133.Pp
134.Fn CMS_add0_crl
135adds the
136.Fa crl
137to the
138.Fa crls
139field of
140.Fa cms
141if it is of the type
142.Vt SignedData
143or to the
144.Fa originatorInfo.crls
145field if it is of the type
146.Vt EnvelopedData .
147.Fn CMS_add1_crl
148does the same and also increments the reference count of the
149.Fa crl
150with
151.Xr X509_CRL_up_ref 3
152in case of success.
153.Pp
154.Fn CMS_get1_crls
155returns any CRLs in
156.Fa cms .
157.Pp
158An error occurs if
159.Fa cms
160is of any type other than
161.Vt SignedData
162or
163.Vt EnvelopedData .
164.Pp
165The same
166.Fa certificate
167or
168.Fa crl
169must not be added to the same
170.Fa cms
171structure more than once.
172.Sh RETURN VALUES
173.Fn CMS_add0_cert ,
174.Fn CMS_add1_cert ,
175.Fn CMS_add0_crl ,
176and
177.Fn CMS_add1_crl
178return 1 for success or 0 for failure.
179.Pp
180.Fn CMS_get1_certs
181and
182.Fn CMS_get1_crls
183return the STACK of certificates or CRLs or
184.Dv NULL
185if there are none or an error occurs.
186Possible errors are that the
187.Fa cms
188type is invalid or memory allocation failure.
189Not all errors result in an error on the error stack.
190The returned stack must be freed using the appropriate
191macro wrapper of
192.Xr sk_pop_free 3 ,
193namely
194.Dv sk_X509_pop_free()
195or
196.Dv sk_X509_CRL_pop_free() .
197.Sh SEE ALSO
198.Xr CMS_ContentInfo_new 3 ,
199.Xr CMS_encrypt 3 ,
200.Xr CMS_final 3 ,
201.Xr CMS_sign 3 ,
202.Xr ERR_get_error 3
203.Sh STANDARDS
204RFC 5652: Cryptographic Message Syntax
205.Bl -dash -compact -offset indent
206.It
207section 5.1: SignedData Type
208.It
209section 6.1: EnvelopedData Type
210.El
211.Sh HISTORY
212.Fn CMS_add0_cert ,
213.Fn CMS_add1_cert ,
214.Fn CMS_get1_certs ,
215.Fn CMS_add0_crl ,
216and
217.Fn CMS_get1_crls
218first appeared in OpenSSL 0.9.8h and
219.Fn CMS_add1_crl
220in OpenSSL 1.0.0.
221These functions have been available since
222.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/CMS_add1_recipient_cert.3 b/src/lib/libcrypto/man/CMS_add1_recipient_cert.3
deleted file mode 100644
index 465119397d..0000000000
--- a/src/lib/libcrypto/man/CMS_add1_recipient_cert.3
+++ /dev/null
@@ -1,200 +0,0 @@
1.\" $OpenBSD: CMS_add1_recipient_cert.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: November 2 2019 $
69.Dt CMS_ADD1_RECIPIENT_CERT 3
70.Os
71.Sh NAME
72.Nm CMS_add1_recipient_cert ,
73.Nm CMS_add0_recipient_key
74.Nd add recipients to a CMS EnvelopedData structure
75.Sh SYNOPSIS
76.In openssl/cms.h
77.Ft CMS_RecipientInfo *
78.Fo CMS_add1_recipient_cert
79.Fa "CMS_ContentInfo *cms"
80.Fa "X509 *certificate"
81.Fa "unsigned int flags"
82.Fc
83.Ft CMS_RecipientInfo *
84.Fo CMS_add0_recipient_key
85.Fa "CMS_ContentInfo *cms"
86.Fa "int nid"
87.Fa "unsigned char *key"
88.Fa "size_t keylen"
89.Fa "unsigned char *id"
90.Fa "size_t idlen"
91.Fa "ASN1_GENERALIZEDTIME *date"
92.Fa "ASN1_OBJECT *otherTypeId"
93.Fa "ASN1_TYPE *otherType"
94.Fc
95.Sh DESCRIPTION
96These functions add a new
97.Vt RecipientInfo
98structure to the
99.Fa recipientInfos
100field of the
101.Vt EnvelopedData
102structure
103.Fa cms ,
104which should have been obtained from an initial call to
105.Xr CMS_encrypt 3
106with the flag
107.Dv CMS_PARTIAL
108set.
109.Pp
110.Fn CMS_add1_recipient_cert
111adds the recipient
112.Fa certificate
113as a
114.Vt KeyTransRecipientInfo
115structure.
116.Pp
117.Fn CMS_add0_recipient_key
118adds the symmetric
119.Fa key
120of length
121.Fa keylen
122using the wrapping algorithm
123.Fa nid ,
124the identifier
125.Fa id
126of length
127.Fa idlen ,
128and the optional values
129.Fa date ,
130.Fa otherTypeId
131and
132.Fa otherType
133as a
134.Vt KEKRecipientInfo
135structure.
136.Pp
137The main purpose of these functions is to provide finer control over a CMS
138.Vt EnvelopedData
139structure where the simpler
140.Xr CMS_encrypt 3
141function defaults are not appropriate,
142for example if one or more
143.Vt KEKRecipientInfo
144structures need to be added.
145New attributes can also be added using the returned
146.Vt CMS_RecipientInfo
147structure and the CMS attribute utility functions.
148.Pp
149By default, recipient certificates are identified using issuer
150name and serial number.
151If the flag
152.Dv CMS_USE_KEYID
153is set, the subject key identifier value is used instead.
154An error occurs if all recipient certificates do not have a subject key
155identifier extension.
156.Pp
157Currently only AES based key wrapping algorithms are supported for
158.Fa nid ,
159specifically
160.Dv NID_id_aes128_wrap ,
161.Dv NID_id_aes192_wrap ,
162and
163.Dv NID_id_aes256_wrap .
164If
165.Fa nid
166is set to
167.Dv NID_undef ,
168then an AES wrap algorithm will be used consistent with
169.Fa keylen .
170.Sh RETURN VALUES
171.Fn CMS_add1_recipient_cert
172and
173.Fn CMS_add0_recipient_key
174return an internal pointer to the
175.Vt CMS_RecipientInfo
176structure just added or
177.Dv NULL
178if an error occurs.
179.Sh SEE ALSO
180.Xr CMS_ContentInfo_new 3 ,
181.Xr CMS_encrypt 3 ,
182.Xr CMS_final 3 ,
183.Xr ERR_get_error 3
184.Sh STANDARDS
185RFC 5652: Cryptographic Message Syntax
186.Bl -dash -compact -offset indent
187.It
188section 6.1: EnvelopedData Type
189.It
190section 6.2.1: KeyTransRecipientInfo Type
191.It
192section 6.2.3: KEKRecipientInfo Type
193.El
194.Sh HISTORY
195.Fn CMS_add1_recipient_cert
196and
197.Fn CMS_add0_recipient_key
198first appeared in OpenSSL 0.9.8h
199and have been available since
200.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/CMS_add1_signer.3 b/src/lib/libcrypto/man/CMS_add1_signer.3
deleted file mode 100644
index 316d63c5ad..0000000000
--- a/src/lib/libcrypto/man/CMS_add1_signer.3
+++ /dev/null
@@ -1,249 +0,0 @@
1.\" $OpenBSD: CMS_add1_signer.3,v 1.10 2024/04/18 16:50:22 tb Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: April 18 2024 $
69.Dt CMS_ADD1_SIGNER 3
70.Os
71.Sh NAME
72.Nm CMS_add1_signer ,
73.Nm CMS_SignerInfo_sign
74.Nd add a signer to a CMS SignedData structure
75.Sh SYNOPSIS
76.In openssl/cms.h
77.Ft CMS_SignerInfo *
78.Fo CMS_add1_signer
79.Fa "CMS_ContentInfo *cms"
80.Fa "X509 *signcert"
81.Fa "EVP_PKEY *pkey"
82.Fa "const EVP_MD *md"
83.Fa "unsigned int flags"
84.Fc
85.Ft int
86.Fo CMS_SignerInfo_sign
87.Fa "CMS_SignerInfo *si"
88.Fc
89.Sh DESCRIPTION
90.Fn CMS_add1_signer
91adds a signer with certificate
92.Fa signcert
93and private key
94.Fa pkey
95using message digest
96.Fa md
97to the
98.Fa signerInfos
99field of the
100.Vt SignedData
101structure
102.Fa cms ,
103which should have been obtained from an initial call to
104.Xr CMS_sign 3
105with the flag
106.Dv CMS_PARTIAL
107set, or which can be a valid
108.Vt SignedData
109structure in the case of re-signing.
110.Pp
111If
112.Fa md
113is
114.Dv NULL ,
115the default digest for the public key algorithm of
116.Fa pkey
117is used.
118.Pp
119Unless the
120.Dv CMS_REUSE_DIGEST
121flag is set, the
122.Fa cms
123structure remains incomplete and must be finalized either by streaming
124(if applicable) or by a call to
125.Xr CMS_final 3 .
126.Pp
127The main purpose of
128.Fn CMS_add1_signer
129is to provide finer control over a CMS
130.Vt SignedData
131structure where the simpler
132.Xr CMS_sign 3
133function defaults are not appropriate, for example if multiple signers
134or non default digest algorithms are needed.
135New attributes can also be added using the returned
136.Vt CMS_SignerInfo
137structure and the CMS attribute utility functions or the CMS signed
138receipt request functions.
139.Pp
140Any of the following flags (OR'ed together) can be passed in the
141.Fa flags
142parameter:
143.Bl -tag -width Ds
144.It Dv CMS_REUSE_DIGEST
145Attempt to copy the content digest value from one of the existing
146.Vt CMS_SignerInfo
147structures in
148.Fa cms
149while adding another signer.
150An error occurs if a matching digest value cannot be found to copy.
151The
152.Fa cms
153structure will be valid and finalized when this flag is set.
154.It Dv CMS_PARTIAL
155If this flag is set in addition to
156.Dv CMS_REUSE_DIGEST ,
157the returned
158.Vt CMS_SignerInfo
159structure will not be finalized so additional attributes can be added.
160In this case an explicit call to
161.Fn CMS_SignerInfo_sign
162is needed to finalize it.
163.It Dv CMS_NOCERTS
164Do not add the signer's certificate to the
165.Fa certificates
166field of
167.Fa cms .
168The signer's certificate must still be supplied in the
169.Fa signcert
170parameter though.
171This flag can reduce the size of the signature if the signer's certificate can
172be obtained by other means, for example from a previously signed message.
173.It Dv CMS_NOATTR
174Leave the
175.Fa signedAttrs
176field of the returned
177.Vt CMS_SignedData
178structure empty.
179By default, several CMS
180.Vt SignedAttributes
181are added, including the signing time, the CMS content type,
182and the supported list of ciphers in an
183.Vt SMIMECapabilities
184attribute.
185.It Dv CMS_NOSMIMECAP
186Omit just the
187.Vt SMIMECapabilities
188attribute.
189.It Dv CMS_USE_KEYID
190Use the subject key identifier value to identify signing certificates.
191An error occurs if the signing certificate does not have a subject key
192identifier extension.
193By default, issuer name and serial number are used instead.
194.El
195.Pp
196If present, the
197.Vt SMIMECapabilities
198attribute indicates support for the
199following algorithms in preference order: 256-bit AES,
200192-bit AES, 128-bit AES, triple DES, 128-bit RC2, 64-bit
201RC2, DES and 40-bit RC2.
202If any of these algorithms is not available then it will not be
203included.
204.Pp
205The
206.Fn CMS_SignerInfo_sign
207function explicitly signs
208.Fa si .
209Its main use is when the
210.Dv CMS_REUSE_DIGEST
211and
212.Dv CMS_PARTIAL
213flags were both set in the call to
214.Fn CMS_add1_signer
215that created
216.Fa si .
217.Sh RETURN VALUES
218.Fn CMS_add1_signer
219returns an internal pointer to the new
220.Vt CMS_SignerInfo
221structure just added or
222.Dv NULL
223if an error occurs.
224.Sh SEE ALSO
225.Xr CMS_ContentInfo_new 3 ,
226.Xr CMS_final 3 ,
227.Xr CMS_sign 3 ,
228.Xr ERR_get_error 3
229.Sh STANDARDS
230RFC 5652: Cryptographic Message Syntax, section 5.1: SignedData Type
231.Pp
232RFC 8419: Use of Edwards-Curve Digital Signature Algorithm (EdDSA) Signatures
233in the Cryptographic Message Syntax (CMS)
234.Pp
235RFC 8551: Secure/Multipurpose Internet Mail Extensions (S/MIME)
236Version\ 4.0 Message Specification
237.Bl -dash -compact -offset indent
238.It
239section 2.5: Attributes and the SignerInfo Type
240.It
241section 2.5.2: SMIMECapabilities Attribute
242.El
243.Sh HISTORY
244.Fn CMS_add1_signer
245and
246.Fn CMS_SignerInfo_sign
247first appeared in OpenSSL 0.9.8h
248and have been available since
249.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/CMS_compress.3 b/src/lib/libcrypto/man/CMS_compress.3
deleted file mode 100644
index 242e4e96cb..0000000000
--- a/src/lib/libcrypto/man/CMS_compress.3
+++ /dev/null
@@ -1,170 +0,0 @@
1.\" $OpenBSD: CMS_compress.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: November 2 2019 $
69.Dt CMS_COMPRESS 3
70.Os
71.Sh NAME
72.Nm CMS_compress
73.Nd create a CMS CompressedData structure
74.Sh SYNOPSIS
75.In openssl/cms.h
76.Ft CMS_ContentInfo *
77.Fo CMS_compress
78.Fa "BIO *in"
79.Fa "int comp_nid"
80.Fa "unsigned int flags"
81.Fc
82.Sh DESCRIPTION
83.Fn CMS_compress
84creates and returns a CMS
85.Vt CompressedData
86structure.
87.Pp
88.Fa comp_nid
89is the compression algorithm to use or
90.Dv NID_undef
91to use the default algorithm.
92Currently, the default algorithm
93.Dv NID_zlib_compression
94is the only supported algorithm.
95If zlib support is not compiled in,
96.Fn CMS_compress
97always returns an error.
98.Pp
99.Fa in
100provides the content to be compressed.
101.Pp
102Any of the following flags (OR'ed together) can be passed in the
103.Fa flags
104parameter:
105.Bl -tag -width Ds
106.It Dv CMS_TEXT
107Prepend MIME headers for type text/plain to the data.
108.It Dv CMS_BINARY
109Do not translate the supplied content into MIME canonical format,
110even though that is required by the S/MIME specifications.
111This option should be used if the supplied data is in binary format.
112Otherwise, the translation will corrupt it.
113If
114.Dv CMS_BINARY
115is set,
116.Dv CMS_TEXT
117is ignored.
118.It Dv CMS_STREAM
119Return a partial
120.Vt CMS_ContentInfo
121structure suitable for streaming I/O: no data is read from
122.Fa in .
123Several functions including
124.Xr SMIME_write_CMS 3 ,
125.Xr i2d_CMS_bio_stream 3 ,
126or
127.Xr PEM_write_bio_CMS_stream 3
128can be used to finalize the structure.
129Alternatively, finalization can be performed by obtaining the streaming
130ASN1
131.Vt BIO
132directly using
133.Xr BIO_new_CMS 3 .
134Outputting the contents of the
135.Vt CMS_ContentInfo
136structure via a function that does not
137properly finalize it will give unpredictable results.
138.It Dv CMS_DETACHED
139Do not include the compressed data in the
140.Vt CMS_ContentInfo
141structure.
142This is rarely used in practice and is not supported by
143.Xr SMIME_write_CMS 3 .
144.El
145.Pp
146Additional compression parameters such as the zlib compression level
147cannot currently be set.
148.Sh RETURN VALUES
149.Fn CMS_compress
150returns either a
151.Vt CMS_ContentInfo
152structure or
153.Dv NULL
154if an error occurred.
155The error can be obtained from
156.Xr ERR_get_error 3 .
157.Sh SEE ALSO
158.Xr CMS_ContentInfo_new 3 ,
159.Xr CMS_uncompress 3
160.Sh STANDARDS
161RFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS)
162.Sh HISTORY
163.Fn CMS_compress
164first appeared in OpenSSL 0.9.8h
165and has been available since
166.Ox 6.7 .
167.Pp
168The
169.Dv CMS_STREAM
170flag first appeared in OpenSSL 1.0.0.
diff --git a/src/lib/libcrypto/man/CMS_decrypt.3 b/src/lib/libcrypto/man/CMS_decrypt.3
deleted file mode 100644
index 243ab2f30e..0000000000
--- a/src/lib/libcrypto/man/CMS_decrypt.3
+++ /dev/null
@@ -1,226 +0,0 @@
1.\" $OpenBSD: CMS_decrypt.3,v 1.8 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2008, 2014 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: November 2 2019 $
69.Dt CMS_DECRYPT 3
70.Os
71.Sh NAME
72.Nm CMS_decrypt ,
73.Nm CMS_decrypt_set1_pkey ,
74.Nm CMS_decrypt_set1_key
75.Nd decrypt content from a CMS EnvelopedData structure
76.Sh SYNOPSIS
77.In openssl/cms.h
78.Ft int
79.Fo CMS_decrypt
80.Fa "CMS_ContentInfo *cms"
81.Fa "EVP_PKEY *private_key"
82.Fa "X509 *certificate"
83.Fa "BIO *dcont"
84.Fa "BIO *out"
85.Fa "unsigned int flags"
86.Fc
87.Ft int
88.Fo CMS_decrypt_set1_pkey
89.Fa "CMS_ContentInfo *cms"
90.Fa "EVP_PKEY *private_key"
91.Fa "X509 *certificate"
92.Fc
93.Ft int
94.Fo CMS_decrypt_set1_key
95.Fa "CMS_ContentInfo *cms"
96.Fa "unsigned char *symmetric_key"
97.Fa "size_t keylen"
98.Fa "const unsigned char *id"
99.Fa "size_t idlen"
100.Fc
101.Sh DESCRIPTION
102.Fn CMS_decrypt
103extracts and decrypts the content from the CMS
104.Vt EnvelopedData
105structure
106.Fa cms
107using the
108.Fa private_key
109and the
110.Fa certificate
111of the recipient.
112It writes the decrypted content to
113.Fa out .
114.Pp
115In the rare case where the compressed content is detached, pass it in via
116.Fa dcont .
117For normal use, set
118.Fa dcont
119to
120.Dv NULL .
121.Pp
122Although the recipient's
123.Fa certificate
124is not needed to decrypt the data, it is needed to locate the
125appropriate (of possibly several) recipients in the CMS structure.
126.Pp
127If the
128.Fa certificate
129is set to
130.Dv NULL ,
131all possible recipients are tried.
132This case however is problematic.
133To thwart the MMA attack (Bleichenbacher's attack on PKCS #1 v1.5 RSA
134padding), all recipients are tried whether they succeed or not.
135If no recipient succeeds, a random symmetric key is used to decrypt
136the content: this will typically output garbage and may (but is not
137guaranteed to) ultimately return a padding error only.
138If
139.Fn CMS_decrypt
140just returned an error when all recipient encrypted keys failed to
141decrypt, an attacker could use this in a timing attack.
142If the special flag
143.Dv CMS_DEBUG_DECRYPT
144is set, the above behaviour is modified and an error
145.Em is
146returned if no recipient encrypted key can be decrypted
147.Em without
148generating a random content encryption key.
149Applications should use this flag with extreme caution
150especially in automated gateways as it can leave them open to attack.
151.Pp
152It is possible to determine the correct recipient key by other means
153(for example by looking them up in a database) and setting them in the
154.Fa cms
155structure in advance using the CMS utility functions such as
156.Fn CMS_decrypt_set1_pkey .
157In this case both
158.Fa certificate
159and
160.Fa private_key
161should be set to
162.Dv NULL
163when calling
164.Fn CMS_decrypt
165later on.
166.Pp
167To process
168.Vt KEKRecipientInfo
169types,
170.Fn CMS_decrypt_set1_key
171or
172.Xr CMS_RecipientInfo_set0_key 3
173and
174.Xr CMS_RecipientInfo_decrypt 3
175should be called before
176.Fn CMS_decrypt
177and
178.Fa certificate
179and
180.Fa private_key
181set to
182.Dv NULL
183when calling
184.Fn CMS_decrypt
185later on.
186.Pp
187If the
188.Dv CMS_TEXT
189bit is set in
190.Fa flags ,
191MIME headers for type text/plain are deleted from the content.
192If the content is not of type text/plain, an error occurs.
193.Sh RETURN VALUES
194.Fn CMS_decrypt ,
195.Fn CMS_decrypt_set1_pkey ,
196and
197.Fn CMS_decrypt_set1_key
198return 1 for success or 0 for failure.
199The error can be obtained from
200.Xr ERR_get_error 3 .
201.Sh SEE ALSO
202.Xr CMS_ContentInfo_new 3 ,
203.Xr CMS_encrypt 3 ,
204.Xr CMS_get0_RecipientInfos 3
205.Sh STANDARDS
206RFC 5652: Cryptographic Message Syntax (CMS)
207.Bl -dash -compact -offset indent
208.It
209section 6.1: EnvelopedData Type
210.It
211section 6.2.3: KEKRecipientInfo Type
212.El
213.Sh HISTORY
214.Fn CMS_decrypt ,
215.Fn CMS_decrypt_set1_pkey ,
216and
217.Fn CMS_decrypt_set1_key
218first appeared in OpenSSL 0.9.8h
219and have been available since
220.Ox 6.7 .
221.Sh BUGS
222The lack of single pass processing and the need to hold all data in
223memory as mentioned in
224.Xr CMS_verify 3
225also applies to
226.Fn CMS_decrypt .
diff --git a/src/lib/libcrypto/man/CMS_encrypt.3 b/src/lib/libcrypto/man/CMS_encrypt.3
deleted file mode 100644
index 03d8b4edbb..0000000000
--- a/src/lib/libcrypto/man/CMS_encrypt.3
+++ /dev/null
@@ -1,191 +0,0 @@
1.\" $OpenBSD: CMS_encrypt.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 2 2019 $
52.Dt CMS_ENCRYPT 3
53.Os
54.Sh NAME
55.Nm CMS_encrypt
56.Nd create a CMS EnvelopedData structure
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft CMS_ContentInfo *
60.Fo CMS_encrypt
61.Fa "STACK_OF(X509) *certificates"
62.Fa "BIO *in"
63.Fa "const EVP_CIPHER *cipher"
64.Fa "unsigned int flags"
65.Fc
66.Sh DESCRIPTION
67.Fn CMS_encrypt
68creates a CMS
69.Vt EnvelopedData
70structure, encrypting the content provided by
71.Fa in .
72.Pp
73The recipient
74.Fa certificates
75are added as
76.Vt KeyTransRecipientInfo
77structures by calling the function
78.Xr CMS_add1_recipient_cert 3
79internally.
80Only certificates carrying RSA, Diffie-Hellman or EC keys are supported
81by this function.
82The
83.Fa certificates
84argument can be set to
85.Dv NULL
86if the
87.Dv CMS_PARTIAL
88flag is set and recipients are added later using
89.Xr CMS_add1_recipient_cert 3
90or
91.Xr CMS_add0_recipient_key 3 .
92.Pp
93.Fa cipher
94is the symmetric cipher to use.
95It must support ASN.1 encoding of its parameters.
96.Xr EVP_des_ede3_cbc 3
97(triple DES) is the algorithm of choice for S/MIME use because most
98clients support it.
99.Pp
100Many browsers implement a "sign and encrypt" option which is simply an
101S/MIME
102.Vt EnvelopedData
103containing an S/MIME signed message.
104This can be readily produced by storing the S/MIME signed message in a
105memory BIO and passing it to
106.Fn CMS_encrypt .
107.Pp
108The following flags can be passed in the
109.Fa flags
110parameter:
111.Bl -tag -width Ds
112.It Dv CMS_TEXT
113MIME headers for type text/plain are prepended to the data.
114.It Dv CMS_BINARY
115Do not translate the supplied content into MIME canonical format
116even though that is required by the S/MIME specifications.
117This option should be used if the supplied data is in binary format.
118Otherwise, the translation will corrupt it.
119If
120.Dv CMS_BINARY
121is set, then
122.Dv CMS_TEXT
123is ignored.
124.It Dv CMS_USE_KEYID
125Use the subject key identifier value to identify recipient certificates.
126An error occurs if all recipient certificates do not have a subject key
127identifier extension.
128By default, issuer name and serial number are used instead.
129.It Dv CMS_STREAM
130Return a partial
131.Vt CMS_ContentInfo
132structure suitable for streaming I/O: no data is read from the BIO
133.Fa in .
134Several functions including
135.Xr SMIME_write_CMS 3 ,
136.Xr i2d_CMS_bio_stream 3 ,
137or
138.Xr PEM_write_bio_CMS_stream 3
139can be used to finalize the structure.
140Alternatively, finalization can be performed by obtaining the streaming
141ASN1
142.Vt BIO
143directly using
144.Xr BIO_new_CMS 3 .
145Outputting the content of the returned
146.Vt CMS_ContentInfo
147structure via a function that does not properly finalize it
148will give unpredictable results.
149.It Dv CMS_PARTIAL
150Return a partial
151.Vt CMS_ContentInfo
152structure to which additional recipients and attributes can
153be added before finalization.
154.It Dv CMS_DETACHED
155Omit the data being encrypted from the
156.Vt CMS_ContentInfo
157structure.
158This is rarely used in practice and is not supported by
159.Xr SMIME_write_CMS 3 .
160.El
161.Sh RETURN VALUES
162.Fn CMS_encrypt
163returns either a
164.Vt CMS_ContentInfo
165structure or
166.Dv NULL
167if an error occurred.
168The error can be obtained from
169.Xr ERR_get_error 3 .
170.Sh SEE ALSO
171.Xr CMS_add0_cert 3 ,
172.Xr CMS_add1_recipient_cert 3 ,
173.Xr CMS_ContentInfo_new 3 ,
174.Xr CMS_decrypt 3
175.Sh STANDARDS
176RFC 5652: Cryptographic Message Syntax (CMS)
177.Bl -dash -compact -offset indent
178.It
179section 6.1: EnvelopedData Type
180.It
181section 6.2.1: KeyTransRecipientInfo Type
182.El
183.Sh HISTORY
184.Fn CMS_encrypt
185first appeared in OpenSSL 0.9.8h
186and has been available since
187.Ox 6.7 .
188.Pp
189The
190.Dv CMS_STREAM
191flag first appeared in OpenSSL 1.0.0.
diff --git a/src/lib/libcrypto/man/CMS_final.3 b/src/lib/libcrypto/man/CMS_final.3
deleted file mode 100644
index 4ca8945923..0000000000
--- a/src/lib/libcrypto/man/CMS_final.3
+++ /dev/null
@@ -1,101 +0,0 @@
1.\" $OpenBSD: CMS_final.3,v 1.6 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL 25ccb589 Jul 1 02:02:06 2019 +0800
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 2 2019 $
52.Dt CMS_FINAL 3
53.Os
54.Sh NAME
55.Nm CMS_final
56.Nd finalise a CMS_ContentInfo structure
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft int
60.Fo CMS_final
61.Fa "CMS_ContentInfo *cms"
62.Fa "BIO *data"
63.Fa "BIO *dcont"
64.Fa "unsigned int flags"
65.Fc
66.Sh DESCRIPTION
67.Fn CMS_final
68finalises the structure
69.Fa cms .
70Its purpose is to perform any operations necessary on
71.Fa cms
72(digest computation for example) and set the appropriate fields.
73The parameter
74.Fa data
75contains the content to be processed.
76The
77.Fa dcont
78parameter contains a
79.Vt BIO
80to write content to after processing: this is
81only used with detached data and will usually be set to
82.Dv NULL .
83.Pp
84This function will normally be called when the
85.Dv CMS_PARTIAL
86flag is used.
87It should only be used when streaming is not performed because the
88streaming I/O functions perform finalisation operations internally.
89.Sh RETURN VALUES
90.Fn CMS_final
91returns 1 for success or 0 for failure.
92.Sh SEE ALSO
93.Xr CMS_ContentInfo_new 3 ,
94.Xr CMS_encrypt 3 ,
95.Xr CMS_sign 3 ,
96.Xr ERR_get_error 3
97.Sh HISTORY
98.Fn CMS_final
99first appeared in OpenSSL 0.9.8h
100and has been available since
101.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/CMS_get0_RecipientInfos.3 b/src/lib/libcrypto/man/CMS_get0_RecipientInfos.3
deleted file mode 100644
index 094d6ec487..0000000000
--- a/src/lib/libcrypto/man/CMS_get0_RecipientInfos.3
+++ /dev/null
@@ -1,328 +0,0 @@
1.\" $OpenBSD: CMS_get0_RecipientInfos.3,v 1.8 2022/03/31 17:27:16 naddy Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008, 2013 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 31 2022 $
52.Dt CMS_GET0_RECIPIENTINFOS 3
53.Os
54.Sh NAME
55.Nm CMS_get0_RecipientInfos ,
56.Nm CMS_RecipientInfo_type ,
57.Nm CMS_RecipientInfo_ktri_get0_signer_id ,
58.Nm CMS_RecipientInfo_ktri_cert_cmp ,
59.Nm CMS_RecipientInfo_set0_pkey ,
60.Nm CMS_RecipientInfo_kekri_get0_id ,
61.Nm CMS_RecipientInfo_kekri_id_cmp ,
62.Nm CMS_RecipientInfo_set0_key ,
63.Nm CMS_RecipientInfo_decrypt ,
64.Nm CMS_RecipientInfo_encrypt
65.Nd CMS EnvelopedData RecipientInfo routines
66.Sh SYNOPSIS
67.In openssl/cms.h
68.Ft STACK_OF(CMS_RecipientInfo) *
69.Fo CMS_get0_RecipientInfos
70.Fa "CMS_ContentInfo *cms"
71.Fc
72.Ft int
73.Fo CMS_RecipientInfo_type
74.Fa "CMS_RecipientInfo *ri"
75.Fc
76.Ft int
77.Fo CMS_RecipientInfo_ktri_get0_signer_id
78.Fa "CMS_RecipientInfo *ri"
79.Fa "ASN1_OCTET_STRING **keyid"
80.Fa "X509_NAME **issuer"
81.Fa "ASN1_INTEGER **sno"
82.Fc
83.Ft int
84.Fo CMS_RecipientInfo_ktri_cert_cmp
85.Fa "CMS_RecipientInfo *ri"
86.Fa "X509 *certificate"
87.Fc
88.Ft int
89.Fo CMS_RecipientInfo_set0_pkey
90.Fa "CMS_RecipientInfo *ri"
91.Fa "EVP_PKEY *pkey"
92.Fc
93.Ft int
94.Fo CMS_RecipientInfo_kekri_get0_id
95.Fa "CMS_RecipientInfo *ri"
96.Fa "X509_ALGOR **palg"
97.Fa "ASN1_OCTET_STRING **pid"
98.Fa "ASN1_GENERALIZEDTIME **pdate"
99.Fa "ASN1_OBJECT **potherid"
100.Fa "ASN1_TYPE **pothertype"
101.Fc
102.Ft int
103.Fo CMS_RecipientInfo_kekri_id_cmp
104.Fa "CMS_RecipientInfo *ri"
105.Fa "const unsigned char *id"
106.Fa "size_t idlen"
107.Fc
108.Ft int
109.Fo CMS_RecipientInfo_set0_key
110.Fa "CMS_RecipientInfo *ri"
111.Fa "unsigned char *key"
112.Fa "size_t keylen"
113.Fc
114.Ft int
115.Fo CMS_RecipientInfo_decrypt
116.Fa "CMS_ContentInfo *cms"
117.Fa "CMS_RecipientInfo *ri"
118.Fc
119.Ft int
120.Fo CMS_RecipientInfo_encrypt
121.Fa "CMS_ContentInfo *cms"
122.Fa "CMS_RecipientInfo *ri"
123.Fc
124.Sh DESCRIPTION
125.Fn CMS_get0_RecipientInfos
126returns all the
127.Vt RecipientInfo
128structures associated with the
129.Vt EnvelopedData
130structure
131.Fa cms .
132.Pp
133.Fn CMS_RecipientInfo_type
134returns the type of
135.Fa ri :
136.Bl -column CMS_RECIPINFO_TRANS for -compact
137.It Dv CMS_RECIPINFO_TRANS Ta for Ta Vt KeyTransRecipientInfo ,
138.It Dv CMS_RECIPINFO_AGREE Ta for Ta Vt KeyAgreeRecipientInfo ,
139.It Dv CMS_RECIPINFO_KEK Ta for Ta Vt KEKRecipientInfo ,
140.It Dv CMS_RECIPINFO_PASS Ta for Ta Vt PasswordRecipientinfo , No or
141.It Dv CMS_RECIPINFO_OTHER Ta for Ta Vt OtherRecipientInfo .
142.El
143.Pp
144.Fn CMS_RecipientInfo_ktri_get0_signer_id
145retrieves the certificate
146.Vt RecipientIdentifier
147associated with the
148.Vt KeyTransRecipientInfo
149structure
150.Fa ri .
151Either the
152.Vt SubjectKeyIdentifier
153will be set in
154.Fa keyid
155or both issuer name and serial number in
156.Fa issuer
157and
158.Fa sno .
159.Pp
160.Fn CMS_RecipientInfo_ktri_cert_cmp
161compares the
162.Fa certificate
163against the
164.Vt KeyTransRecipientInfo
165structure
166.Fa ri .
167.Pp
168.Fn CMS_RecipientInfo_set0_pkey
169associates the private key
170.Fa pkey
171with the
172.Vt KeyTransRecipientInfo
173structure
174.Fa ri .
175.Pp
176.Fn CMS_RecipientInfo_kekri_get0_id
177retrieves the key information from the
178.Vt KEKRecipientInfo
179structure
180.Fa ri .
181Fields are copied out as follows:
182.Bl -column keyEncryptionAlgorithm to -compact
183.It Fa keyEncryptionAlgorithm Ta to Ta Pf * Fa palg ,
184.It Fa keyIdentifier Ta to Ta Pf * Fa pid ,
185.It Fa date Ta to Ta Pf * Fa pdate Pq optional ,
186.It Fa other.keyAttrId Ta to Ta Pf * Fa potherid Pq optional ,
187.It Fa other.keyAttr Ta to Ta Pf * Fa pothertype Pq optional .
188.El
189Where a field is optional and absent,
190.Dv NULL
191is written to the corresponding parameter.
192Parameters the application is not interested in can be set to
193.Dv NULL .
194.Pp
195.Fn CMS_RecipientInfo_kekri_id_cmp
196compares the identifier in the
197.Fa id
198and
199.Fa idlen
200parameters against the
201.Fa keyIdentifier
202field of the
203.Vt KEKRecipientInfo
204structure
205.Fa ri .
206.Pp
207.Fn CMS_RecipientInfo_set0_key
208associates the symmetric
209.Fa key
210of length
211.Fa keylen
212with the
213.Vt KEKRecipientInfo
214structure
215.Fa ri .
216.Pp
217.Fn CMS_RecipientInfo_decrypt
218attempts to decrypt the
219.Vt RecipientInfo
220structure
221.Fa ri
222in
223.Fa cms .
224A key must have been associated with
225.Fa ri
226first.
227.Pp
228.Fn CMS_RecipientInfo_encrypt
229attempts to encrypt the
230.Vt RecipientInfo
231structure
232.Fa ri
233in
234.Fa cms .
235A key must have been associated with
236.Fa ri
237first and the content encryption key must be available,
238for example by a previous call to
239.Fn CMS_RecipientInfo_decrypt .
240.Pp
241The main purpose of these functions is to enable an application to
242lookup recipient keys using any appropriate technique when the simpler
243method of
244.Xr CMS_decrypt 3
245is not appropriate.
246.Pp
247In typical usage, an application retrieves all
248.Vt CMS_RecipientInfo
249structures using
250.Fn CMS_get0_RecipientInfos
251and checks the type of each using
252.Fn CMS_RecipientInfo_type .
253Depending on the type, the
254.Vt CMS_RecipientInfo
255structure can be ignored or its key identifier data retrieved using
256an appropriate function.
257If the corresponding secret or private key can be obtained by any
258appropriate means, it can then be associated with the structure and
259.Fn CMS_RecipientInfo_decrypt
260called.
261If successful,
262.Xr CMS_decrypt 3
263can be called with a
264.Dv NULL
265key to decrypt the enveloped content.
266.Pp
267The function
268.Fn CMS_RecipientInfo_encrypt
269can be used to add a new recipient to an existing enveloped data
270structure.
271Typically an application will first decrypt an appropriate
272.Vt CMS_RecipientInfo
273structure to make the content encrypt key available.
274It will then add a new recipient using a function such as
275.Xr CMS_add1_recipient_cert 3
276and finally encrypt the content encryption key using
277.Fn CMS_RecipientInfo_encrypt .
278.Sh RETURN VALUES
279.Fn CMS_get0_RecipientInfos
280returns an internal pointer to all the
281.Vt CMS_RecipientInfo
282structures, or
283.Dv NULL
284if an error occurs.
285.Pp
286.Fn CMS_RecipientInfo_type
287returns an integer constant.
288.Pp
289.Fn CMS_RecipientInfo_ktri_get0_signer_id ,
290.Fn CMS_RecipientInfo_set0_pkey ,
291.Fn CMS_RecipientInfo_kekri_get0_id ,
292.Fn CMS_RecipientInfo_set0_key ,
293.Fn CMS_RecipientInfo_decrypt ,
294and
295.Fn CMS_RecipientInfo_encrypt
296return 1 for success or 0 if an error occurs.
297.Pp
298.Fn CMS_RecipientInfo_ktri_cert_cmp
299and
300.Fn CMS_RecipientInfo_kekri_id_cmp
301return 0 when
302.Fa ri
303matches or non-zero otherwise.
304.Pp
305Any error can be obtained from
306.Xr ERR_get_error 3 .
307.Sh SEE ALSO
308.Xr CMS_ContentInfo_new 3 ,
309.Xr CMS_decrypt 3
310.Sh STANDARDS
311RFC 5652 Cryptographic Message Syntax (CMS):
312.Bl -dash -compact -offset indent
313.It
314section 6.1: EnvelopedData Type
315.It
316section 6.2: RecipientInfo Type
317.It
318section 6.2.1: KeyTransRecipientInfo Type
319.It
320section 6.2.3: KEKRecipientInfo Type
321.El
322.Sh HISTORY
323These functions first appeared in OpenSSL 0.9.8h,
324except that
325.Fn CMS_RecipientInfo_encrypt
326first appeared in OpenSSL 1.0.2.
327They have been available since
328.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/CMS_get0_SignerInfos.3 b/src/lib/libcrypto/man/CMS_get0_SignerInfos.3
deleted file mode 100644
index 017fdd40f2..0000000000
--- a/src/lib/libcrypto/man/CMS_get0_SignerInfos.3
+++ /dev/null
@@ -1,214 +0,0 @@
1.\" $OpenBSD: CMS_get0_SignerInfos.3,v 1.9 2024/01/22 14:00:13 tb Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008, 2013 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: January 22 2024 $
52.Dt CMS_GET0_SIGNERINFOS 3
53.Os
54.Sh NAME
55.Nm CMS_get0_SignerInfos ,
56.Nm CMS_SignerInfo_get_version ,
57.Nm CMS_SignerInfo_get0_signer_id ,
58.Nm CMS_SignerInfo_get0_signature ,
59.Nm CMS_SignerInfo_cert_cmp ,
60.Nm CMS_SignerInfo_set1_signer_cert
61.Nd CMS SignedData signer functions
62.Sh SYNOPSIS
63.In openssl/cms.h
64.Ft STACK_OF(CMS_SignerInfo) *
65.Fo CMS_get0_SignerInfos
66.Fa "CMS_ContentInfo *cms"
67.Fc
68.Ft int
69.Fo CMS_SignerInfo_get_version
70.Fa "CMS_SignerInfo *si"
71.Fa "long *version"
72.Fc
73.Ft int
74.Fo CMS_SignerInfo_get0_signer_id
75.Fa "CMS_SignerInfo *si"
76.Fa "ASN1_OCTET_STRING **keyid"
77.Fa "X509_NAME **issuer"
78.Fa "ASN1_INTEGER **sno"
79.Fc
80.Ft ASN1_OCTET_STRING *
81.Fo CMS_SignerInfo_get0_signature
82.Fa "CMS_SignerInfo *si"
83.Fc
84.Ft int
85.Fo CMS_SignerInfo_cert_cmp
86.Fa "CMS_SignerInfo *si"
87.Fa "X509 *certificate"
88.Fc
89.Ft void
90.Fo CMS_SignerInfo_set1_signer_cert
91.Fa "CMS_SignerInfo *si"
92.Fa "X509 *signer"
93.Fc
94.Sh DESCRIPTION
95.Fn CMS_get0_SignerInfos
96returns all the
97.Vt SignerInfo
98structures associated with the
99.Vt SignedData
100structure
101.Fa cms .
102.Pp
103.Fn CMS_SignerInfo_get_version
104sets
105.Pf * Fa version
106to the syntax version number of the
107.Vt SignerInfo
108structure
109.Fa si .
110.Pp
111.Fn CMS_SignerInfo_get0_signer_id
112retrieves the certificate
113.Vt SignerIdentifier
114associated with the
115.Vt SignerInfo
116structure
117.Fa si .
118Either the
119.Vt SubjectKeyIdentifier
120will be set in
121.Fa keyid
122or both issuer name and serial number in
123.Fa issuer
124and
125.Fa sno .
126.Pp
127.Fn CMS_SignerInfo_get0_signature
128retrieves the
129.Fa signature
130field of
131.Fa si .
132The application program is allowed to modify the data pointed to.
133.Pp
134.Fn CMS_SignerInfo_cert_cmp
135compares the
136.Fa certificate
137against the signer identifier of
138.Fa si .
139.Pp
140.Fn CMS_SignerInfo_set1_signer_cert
141sets the signer certificate of
142.Fa si
143to
144.Fa signer .
145.Pp
146The main purpose of these functions is to enable an application to
147look up signer certificates using any appropriate technique when the
148simpler method of
149.Xr CMS_verify 3
150is not appropriate.
151.Pp
152In typical usage, an application retrieves all
153.Vt CMS_SignerInfo
154structures using
155.Fn CMS_get0_SignerInfos
156and retrieves the identifier information using CMS.
157It will then obtain the signer certificate by some unspecified means
158(or return and error if it cannot be found) and set it using
159.Fn CMS_SignerInfo_set1_signer_cert .
160Once all signer certificates have been set,
161.Xr CMS_verify 3
162can be used.
163.Sh RETURN VALUES
164.Fn CMS_get0_SignerInfos
165returns an internal pointer to all the
166.Vt CMS_SignerInfo
167structures, or
168.Dv NULL
169if there are no signers or if
170.Fa cms
171is not of the type
172.Vt SignedData .
173.Pp
174.Fn CMS_SignerInfo_get_version
175always succeeds and returns 1.
176.Pp
177.Fn CMS_SignerInfo_get0_signer_id
178returns 1 for success or 0 for failure.
179.Pp
180.Fn CMS_SignerInfo_get0_signature
181returns an internal pointer to the signature.
182.Pp
183.Fn CMS_SignerInfo_cert_cmp
184returns 0 for a match or non-zero otherwise.
185.Pp
186Any error can be obtained from
187.Xr ERR_get_error 3 .
188.Sh SEE ALSO
189.Xr CMS_ContentInfo_new 3 ,
190.Xr CMS_signed_add1_attr 3 ,
191.Xr CMS_verify 3
192.Sh STANDARDS
193RFC 5652: Cryptographic Message Syntax (CMS)
194.Bl -dash -compact -offset indent
195.It
196section 5.1: SignedData Type
197.It
198section 5.3: SignerInfo Type
199.El
200.Sh HISTORY
201.Fn CMS_get0_SignerInfos ,
202.Fn CMS_SignerInfo_get0_signer_id ,
203.Fn CMS_SignerInfo_cert_cmp ,
204and
205.Fn CMS_SignerInfo_set1_signer_cert
206first appeared in OpenSSL 0.9.8h and
207.Fn CMS_SignerInfo_get0_signature
208in OpenSSL 1.0.2.
209These functions have been available since
210.Ox 6.7 .
211.Pp
212.Fn CMS_SignerInfo_get_version
213first appeared in
214.Ox 7.4 .
diff --git a/src/lib/libcrypto/man/CMS_get0_type.3 b/src/lib/libcrypto/man/CMS_get0_type.3
deleted file mode 100644
index 55adacd86d..0000000000
--- a/src/lib/libcrypto/man/CMS_get0_type.3
+++ /dev/null
@@ -1,226 +0,0 @@
1.\" $OpenBSD: CMS_get0_type.3,v 1.9 2023/07/27 05:31:28 tb Exp $
2.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2008, 2015 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: July 27 2023 $
69.Dt CMS_GET0_TYPE 3
70.Os
71.Sh NAME
72.Nm CMS_get0_type ,
73.Nm CMS_get_version ,
74.Nm CMS_set1_eContentType ,
75.Nm CMS_get0_eContentType ,
76.Nm CMS_get0_content
77.Nd get and set CMS content types and content
78.Sh SYNOPSIS
79.In openssl/cms.h
80.Ft const ASN1_OBJECT *
81.Fo CMS_get0_type
82.Fa "const CMS_ContentInfo *cms"
83.Fc
84.Ft int
85.Fo CMS_get_version
86.Fa "const CMS_ContentInfo *cms"
87.Fa "long *version"
88.Fc
89.Ft int
90.Fo CMS_set1_eContentType
91.Fa "CMS_ContentInfo *cms"
92.Fa "const ASN1_OBJECT *oid"
93.Fc
94.Ft const ASN1_OBJECT *
95.Fo CMS_get0_eContentType
96.Fa "CMS_ContentInfo *cms"
97.Fc
98.Ft ASN1_OCTET_STRING **
99.Fo CMS_get0_content
100.Fa "CMS_ContentInfo *cms"
101.Fc
102.Sh DESCRIPTION
103.Fn CMS_get0_type
104returns the content type of the
105.Vt ContentInfo
106structure
107.Fa cms .
108The
109.Vt ASN1_OBJECT
110value returned can be converted to an integer NID value using
111.Xr OBJ_obj2nid 3 .
112The following content types are identified by the following NIDs:
113.Pp
114.Bl -column AuthenticatedData NID_id_smime_ct_compressedData -compact
115.It Vt SignedData Ta Dv NID_pkcs7_signed
116.It Vt EnvelopedData Ta Dv NID_pkcs7_enveloped
117.It Vt DigestedData Ta Dv NID_pkcs7_digest
118.It Vt EncryptedData Ta Dv NID_pkcs7_encrypted
119.It Vt AuthenticatedData Ta Dv NID_id_smime_ct_authData
120.It Vt CompressedData Ta Dv NID_id_smime_ct_compressedData
121.It arbitrary data Ta Dv NID_pkcs7_data
122.El
123.Pp
124The
125.Vt SignedData ,
126.Vt DigestedData ,
127.Vt AuthenticatedData ,
128and
129.Vt CompressedData
130types contain a field
131.Fa encapContentInfo
132to allow embedding content, and
133.Vt EnvelopedData
134and
135.Vt EncryptedData
136contain a field
137.Fa encryptedContentInfo
138for that purpose.
139The type of the embedded content to be stored in that field can be
140set with the function
141.Fn CMS_set1_eContentType ,
142to be called on
143.Fa cms
144structures returned from functions such as
145.Xr CMS_sign 3
146or
147.Xr CMS_encrypt 3
148with the
149.Dv CMS_PARTIAL
150flag set and
151.Em before
152the structure is finalised; otherwise the results are undefined.
153.Fn CMS_set1_eContentType
154copies the supplied
155.Fa oid ,
156so it should be freed up after use.
157.Pp
158.Fn CMS_get_version
159sets
160.Pf * Fa version
161to the syntax version number of the
162.Vt ContentInfo
163structure
164.Fa cms .
165The version is a number between 0 and 5 and is defined for all the
166above content types except for arbitrary data.
167For arbitrary data and unsupported content types
168.Fn CMS_get_version
169fails and the content of
170.Pf * Fa version
171is unspecified.
172.Pp
173.Fn CMS_get0_eContentType
174returns the type of the embedded content.
175.Pp
176.Fn CMS_get0_content
177returns a pointer to the storage location where the pointer to the
178embedded content is stored.
179That means that for example after
180.Pp
181.Dl ASN1_OCTET_STRING **pconf = CMS_get0_content(cms);
182.Pp
183.Pf * Va pconf
184could be
185.Dv NULL
186if there is no embedded content.
187Applications can access, modify or create the embedded content in a
188.Vt CMS_ContentInfo
189structure using this function.
190Applications usually will not need to modify the embedded content as it
191is normally set by higher level functions.
192.Sh RETURN VALUES
193.Fn CMS_get0_type
194and
195.Fn CMS_get0_eContentType
196return internal pointers to
197.Vt OBJECT IDENTIFIER
198structures.
199.Pp
200.Fn CMS_get_version
201returns 1 on success and 0 on failure.
202.Pp
203.Fn CMS_get0_content
204returns an internal pointer to the storage location where the pointer
205to the embedded content is stored.
206.Pp
207.Fn CMS_set1_eContentType
208returns 1 for success or 0 if an error occurred.
209The error can be obtained from
210.Xr ERR_get_error 3 .
211.Sh SEE ALSO
212.Xr CMS_ContentInfo_new 3 ,
213.Xr d2i_CMS_ContentInfo 3 ,
214.Xr SMIME_read_CMS 3
215.Sh STANDARDS
216RFC 5652: Cryptographic Message Syntax
217.Pp
218RFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS)
219.Sh HISTORY
220These functions first appeared in OpenSSL 0.9.8h
221and have been available since
222.Ox 6.7 .
223.Pp
224.Fn CMS_get_version
225first appeared in
226.Ox 7.4 .
diff --git a/src/lib/libcrypto/man/CMS_get1_ReceiptRequest.3 b/src/lib/libcrypto/man/CMS_get1_ReceiptRequest.3
deleted file mode 100644
index 9feedd13a2..0000000000
--- a/src/lib/libcrypto/man/CMS_get1_ReceiptRequest.3
+++ /dev/null
@@ -1,198 +0,0 @@
1.\" $OpenBSD: CMS_get1_ReceiptRequest.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 2 2019 $
52.Dt CMS_GET1_RECEIPTREQUEST 3
53.Os
54.Sh NAME
55.Nm CMS_ReceiptRequest_create0 ,
56.Nm CMS_add1_ReceiptRequest ,
57.Nm CMS_get1_ReceiptRequest ,
58.Nm CMS_ReceiptRequest_get0_values
59.Nd CMS signed receipt request functions
60.Sh SYNOPSIS
61.In openssl/cms.h
62.Ft CMS_ReceiptRequest *
63.Fo CMS_ReceiptRequest_create0
64.Fa "unsigned char *id"
65.Fa "int idlen"
66.Fa "int allorfirst"
67.Fa "STACK_OF(GENERAL_NAMES) *receiptList"
68.Fa "STACK_OF(GENERAL_NAMES) *receiptsTo"
69.Fc
70.Ft int
71.Fo CMS_add1_ReceiptRequest
72.Fa "CMS_SignerInfo *si"
73.Fa "CMS_ReceiptRequest *rr"
74.Fc
75.Ft int
76.Fo CMS_get1_ReceiptRequest
77.Fa "CMS_SignerInfo *si"
78.Fa "CMS_ReceiptRequest **prr"
79.Fc
80.Ft void
81.Fo CMS_ReceiptRequest_get0_values
82.Fa "CMS_ReceiptRequest *rr"
83.Fa "ASN1_STRING **pcid"
84.Fa "int *pallorfirst"
85.Fa "STACK_OF(GENERAL_NAMES) **plist"
86.Fa "STACK_OF(GENERAL_NAMES) **prto"
87.Fc
88.Sh DESCRIPTION
89.Fn CMS_ReceiptRequest_create0
90creates a new
91.Vt ReceiptRequest
92structure.
93The
94.Fa signedContentIdentifier
95field is set using
96.Fa id
97and
98.Fa idlen ,
99or it is set to 32 bytes of pseudo random data if
100.Fa id
101is
102.Dv NULL .
103If
104.Fa receiptList
105is
106.Dv NULL ,
107the
108.Fa allOrFirstTier
109option in the
110.Fa receiptsFrom
111field is set to the value of the
112.Fa allorfirst
113argument.
114If
115.Fa receiptList
116is not
117.Dv NULL ,
118the
119.Fa receiptList
120option in the
121.Fa receiptsFrom
122field is used.
123The
124.Fa receiptsTo
125argument specifies the value of the
126.Fa receiptsTo
127field.
128.Pp
129.Fn CMS_add1_ReceiptRequest
130adds a BER-encoded copy of
131.Fa rr
132to
133.Fa si .
134.Pp
135.Fn CMS_get1_ReceiptRequest
136looks for a signed receipt request in
137.Fa si .
138If any is found, it is decoded and written to
139.Fa prr .
140.Pp
141.Fn CMS_ReceiptRequest_get0_values
142retrieves the values of a receipt request.
143The
144.Fa signedContentIdentifier
145is copied to
146.Fa pcid .
147If the
148.Fa allOrFirstTier
149option is used in the
150.Fa receiptsFrom
151field, its value is copied to
152.Fa pallorfirst ;
153otherwise the
154.Fa receiptList
155field is copied to
156.Fa plist .
157The
158.Fa receiptsTo
159field is copied to
160.Fa prto .
161.Pp
162The contents of a signed receipt should only be considered meaningful if
163the corresponding
164.Vt CMS_ContentInfo
165structure can be successfully verified using
166.Xr CMS_verify 3 .
167.Sh RETURN VALUES
168.Fn CMS_ReceiptRequest_create0
169returns the new signed receipt request structure or
170.Dv NULL
171if an error occurred.
172.Pp
173.Fn CMS_add1_ReceiptRequest
174returns 1 for success or 0 if an error occurred.
175.Pp
176.Fn CMS_get1_ReceiptRequest
177returns 1 is a signed receipt request is found and decoded.
178It returns 0 if a signed receipt request is not present or -1 if it is
179present but malformed.
180.Sh SEE ALSO
181.Xr CMS_ContentInfo_new 3 ,
182.Xr CMS_sign 3 ,
183.Xr CMS_sign_receipt 3 ,
184.Xr CMS_verify 3 ,
185.Xr CMS_verify_receipt 3 ,
186.Xr ERR_get_error 3
187.Sh STANDARDS
188RFC 2634: Enhanced Security Services for S/MIME,
189section 2.7: Receipt Request Syntax
190.Sh HISTORY
191.Fn CMS_ReceiptRequest_create0 ,
192.Fn CMS_add1_ReceiptRequest ,
193.Fn CMS_get1_ReceiptRequest ,
194and
195.Fn CMS_ReceiptRequest_get0_values
196first appeared in OpenSSL 0.9.8h
197and have been available since
198.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/CMS_sign.3 b/src/lib/libcrypto/man/CMS_sign.3
deleted file mode 100644
index 5261c190a6..0000000000
--- a/src/lib/libcrypto/man/CMS_sign.3
+++ /dev/null
@@ -1,246 +0,0 @@
1.\" $OpenBSD: CMS_sign.3,v 1.11 2024/04/18 16:50:22 tb Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: April 18 2024 $
52.Dt CMS_SIGN 3
53.Os
54.Sh NAME
55.Nm CMS_sign
56.Nd create a CMS SignedData structure
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft CMS_ContentInfo *
60.Fo CMS_sign
61.Fa "X509 *signcert"
62.Fa "EVP_PKEY *pkey"
63.Fa "STACK_OF(X509) *certs"
64.Fa "BIO *data"
65.Fa "unsigned int flags"
66.Fc
67.Sh DESCRIPTION
68.Fn CMS_sign
69creates and returns a CMS
70.Vt SignedData
71structure.
72.Fa signcert
73is the certificate to sign with,
74.Fa pkey
75is the corresponding private key.
76.Fa certs
77is an optional additional set of certificates to include in the CMS
78structure (for example any intermediate CAs in the chain).
79Any or all of these parameters can be
80.Dv NULL .
81.Pp
82The data to be signed is read from
83.Fa data .
84.Pp
85Any of the following flags (OR'ed together) can be passed in the
86.Fa flags
87argument:
88.Bl -tag -width Ds
89.It Dv CMS_TEXT
90Prepend MIME headers for the type text/plain to the data.
91Many S/MIME clients expect the signed content to include valid MIME
92headers.
93.It Dv CMS_NOCERTS
94Do not include the signer's certificate in the
95.Vt CMS_ContentInfo
96structure.
97The signer's certificate must still be supplied in the
98.Fa signcert
99parameter though.
100This can reduce the size of the signature if the signer's certificate can
101be obtained by other means, for example from a previously signed message.
102.It Dv CMS_DETACHED
103Omit the data being signed from the
104.Vt CMS_ContentInfo
105structure.
106This is used for
107.Vt CMS_ContentInfo
108detached signatures which are used in S/MIME plaintext signed messages
109for example.
110.It Dv CMS_BINARY
111Do not translate the supplied content into MIME canonical format
112even though that is required by the S/MIME specifications.
113This option should be used if the supplied data is in binary format.
114Otherwise the translation will corrupt it.
115.It Dv CMS_NOATTR
116Do not add any
117.Vt SignedAttributes .
118By default, the
119.Fa signerInfos
120field includes several CMS
121.Vt SignedAttributes
122including the signing time, the CMS content type,
123and the supported list of ciphers in an
124.Vt SMIMECapabilities
125attribute.
126.It Dv CMS_NOSMIMECAP
127Omit just the
128.Vt SMIMECapabilities .
129If present, the SMIMECapabilities attribute indicates support for the
130following algorithms in preference order: 256-bit AES,
131192-bit AES, 128-bit AES, triple DES, 128-bit RC2, 64-bit
132RC2, DES and 40-bit RC2.
133If any of these algorithms is not available, then it will not be
134included.
135.It Dv CMS_USE_KEYID
136Use the subject key identifier value to identify signing certificates.
137An error occurs if the signing certificate does not have a subject key
138identifier extension.
139By default, issuer name and serial number are used instead.
140.It Dv CMS_STREAM
141Only initialize the returned
142.Vt CMS_ContentInfo
143structure to prepare it for performing the signing operation.
144The signing is however
145.Em not
146performed and the data to be signed is not read from the
147.Fa data
148parameter.
149Signing is deferred until after the data has been written.
150In this way, data can be signed in a single pass.
151The returned
152.Vt CMS_ContentInfo
153structure is
154.Em not
155complete and outputting its contents via a function that does not
156properly finalize the
157.Vt CMS_ContentInfo
158structure will give unpredictable results.
159Several functions including
160.Xr SMIME_write_CMS 3 ,
161.Xr i2d_CMS_bio_stream 3 ,
162or
163.Xr PEM_write_bio_CMS_stream 3
164finalize the structure.
165Alternatively, finalization can be performed by obtaining the streaming
166ASN1
167.Vt BIO
168directly using
169.Xr BIO_new_CMS 3 .
170.It Dv CMS_PARTIAL
171Output a partial
172.Vt CMS_ContentInfo
173structure to which additional signers and capabilities can be
174added before finalization.
175.El
176.Pp
177If a signer is specified, it will use the default digest for the signing
178algorithm.
179This is SHA1 for both RSA and DSA keys.
180.Pp
181If
182.Fa signcert
183and
184.Fa pkey
185are
186.Dv NULL ,
187then a certificates only CMS structure is output.
188.Pp
189The function
190.Fn CMS_sign
191is a basic CMS signing function whose output will be suitable for many
192purposes.
193For finer control of the output format the
194.Fa certs ,
195.Fa signcert
196and
197.Fa pkey
198parameters can all be
199.Dv NULL
200and the
201.Dv CMS_PARTIAL
202flag set.
203Then one or more signers can be added using the function
204.Xr CMS_add1_signer 3 ,
205non default digests can be used and custom attributes added.
206.Xr CMS_final 3
207must then be called to finalize the structure if streaming is not
208enabled.
209.Sh RETURN VALUES
210.Fn CMS_sign
211returns either a valid
212.Vt CMS_ContentInfo
213structure or
214.Dv NULL
215if an error occurred.
216The error can be obtained from
217.Xr ERR_get_error 3 .
218.Sh SEE ALSO
219.Xr CMS_add0_cert 3 ,
220.Xr CMS_add1_signer 3 ,
221.Xr CMS_ContentInfo_new 3 ,
222.Xr CMS_final 3 ,
223.Xr CMS_sign_receipt 3 ,
224.Xr CMS_verify 3
225.Sh STANDARDS
226RFC 5652: Cryptographic Message Syntax (CMS)
227.Bl -dash -compact -offset indent
228.It
229section 5.1: SignedData Type
230.It
231section 5.3: SignerInfo Type
232.El
233.Pp
234RFC 8419: Use of Edwards-Curve Digital Signature Algorithm (EdDSA) Signatures
235in the Cryptographic Message Syntax (CMS)
236.Pp
237RFC 8551: Secure/Multipurpose Internet Mail Extensions (S/MIME)
238Version\ 4.0 Message Specification,
239section 2.5.2: SMIMECapabilities Attribute
240.Sh HISTORY
241.Fn CMS_sign
242first appeared in OpenSSL 0.9.8h
243and has been available since
244.Ox 6.7 .
245.Sh BUGS
246Some attributes such as counter signatures are not supported.
diff --git a/src/lib/libcrypto/man/CMS_sign_receipt.3 b/src/lib/libcrypto/man/CMS_sign_receipt.3
deleted file mode 100644
index 6394957846..0000000000
--- a/src/lib/libcrypto/man/CMS_sign_receipt.3
+++ /dev/null
@@ -1,119 +0,0 @@
1.\" $OpenBSD: CMS_sign_receipt.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 2 2019 $
52.Dt CMS_SIGN_RECEIPT 3
53.Os
54.Sh NAME
55.Nm CMS_sign_receipt
56.Nd create a CMS signed receipt
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft CMS_ContentInfo *
60.Fo CMS_sign_receipt
61.Fa "CMS_SignerInfo *si"
62.Fa "X509 *signcert"
63.Fa "EVP_PKEY *pkey"
64.Fa "STACK_OF(X509) *certs"
65.Fa "unsigned int flags"
66.Fc
67.Sh DESCRIPTION
68.Fn CMS_sign_receipt
69creates a new CMS
70.Vt SignedData
71structure containing a signed
72.Vt Receipt
73as its embedded content.
74.Fa si
75is the
76.Vt SignerInfo
77structure containing the signed receipt request.
78.Fa signcert
79is the certificate to sign with,
80.Fa pkey
81is the corresponding private key.
82.Fa certs
83is an optional additional set of certificates to include in the CMS
84structure (for example any intermediate CAs in the chain).
85.Pp
86This functions behaves in a similar way to
87.Xr CMS_sign 3
88except that the
89.Fa flags
90values
91.Dv CMS_DETACHED ,
92.Dv CMS_BINARY ,
93.Dv CMS_NOATTR ,
94.Dv CMS_TEXT ,
95and
96.Dv CMS_STREAM
97are not supported since they do not make sense in the context of
98signed receipts.
99.Sh RETURN VALUES
100.Fn CMS_sign_receipt
101returns either a valid
102.Vt CMS_ContentInfo
103structure or
104.Dv NULL
105if an error occurred.
106The error can be obtained from
107.Xr ERR_get_error 3 .
108.Sh SEE ALSO
109.Xr CMS_ContentInfo_new 3 ,
110.Xr CMS_get1_ReceiptRequest 3 ,
111.Xr CMS_sign 3 ,
112.Xr CMS_verify_receipt 3
113.Sh STANDARDS
114RFC 2634: Enhanced Security Services for S/MIME, section 2.8: Receipt Syntax
115.Sh HISTORY
116.Fn CMS_sign_receipt
117first appeared in OpenSSL 0.9.8h
118and has been available since
119.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/CMS_signed_add1_attr.3 b/src/lib/libcrypto/man/CMS_signed_add1_attr.3
deleted file mode 100644
index 1a50c0b9d1..0000000000
--- a/src/lib/libcrypto/man/CMS_signed_add1_attr.3
+++ /dev/null
@@ -1,360 +0,0 @@
1.\" $OpenBSD: CMS_signed_add1_attr.3,v 1.5 2024/09/02 07:54:21 tb Exp $
2.\"
3.\" Copyright (c) 2024 Job Snijders <job@openbsd.org>
4.\" Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
5.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
6.\"
7.\" Permission to use, copy, modify, and distribute this software for any
8.\" purpose with or without fee is hereby granted, provided that the above
9.\" copyright notice and this permission notice appear in all copies.
10.\"
11.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\"
19.Dd $Mdocdate: September 2 2024 $
20.Dt CMS_SIGNED_ADD1_ATTR 3
21.Os
22.Sh NAME
23.Nm CMS_signed_add1_attr ,
24.Nm CMS_signed_add1_attr_by_NID ,
25.Nm CMS_signed_add1_attr_by_OBJ ,
26.Nm CMS_signed_add1_attr_by_txt ,
27.Nm CMS_signed_delete_attr ,
28.Nm CMS_signed_get0_data_by_OBJ ,
29.Nm CMS_signed_get_attr ,
30.Nm CMS_signed_get_attr_by_NID ,
31.Nm CMS_signed_get_attr_by_OBJ ,
32.Nm CMS_signed_get_attr_count ,
33.Nm CMS_unsigned_add1_attr ,
34.Nm CMS_unsigned_add1_attr_by_NID ,
35.Nm CMS_unsigned_add1_attr_by_OBJ ,
36.Nm CMS_unsigned_add1_attr_by_txt ,
37.Nm CMS_unsigned_delete_attr ,
38.Nm CMS_unsigned_get0_data_by_OBJ ,
39.Nm CMS_unsigned_get_attr ,
40.Nm CMS_unsigned_get_attr_by_NID ,
41.Nm CMS_unsigned_get_attr_by_OBJ ,
42.Nm CMS_unsigned_get_attr_count
43.Nd change signed and unsigned attributes of a CMS SignerInfo object
44.Sh SYNOPSIS
45.In openssl/cms.h
46.Ft int
47.Fo CMS_signed_add1_attr
48.Fa "CMS_SignerInfo *si"
49.Fa "X509_ATTRIBUTE *attr"
50.Fc
51.Ft int
52.Fo CMS_signed_add1_attr_by_NID
53.Fa "CMS_SignerInfo *si"
54.Fa "int nid"
55.Fa "int type"
56.Fa "const void *bytes"
57.Fa "int len"
58.Fc
59.Ft int
60.Fo CMS_signed_add1_attr_by_OBJ
61.Fa "CMS_SignerInfo *si"
62.Fa "const ASN1_OBJECT *obj"
63.Fa "int type"
64.Fa "const void *bytes"
65.Fa "int len"
66.Fc
67.Ft int
68.Fo CMS_signed_add1_attr_by_txt
69.Fa "CMS_SignerInfo *si"
70.Fa "const char *attrname"
71.Fa "int type"
72.Fa "const void *bytes"
73.Fa "int len"
74.Fc
75.Ft "X509_ATTRIBUTE *"
76.Fo CMS_signed_delete_attr
77.Fa "CMS_SignerInfo *si"
78.Fa "int loc"
79.Fc
80.Ft "void *"
81.Fo CMS_signed_get0_data_by_OBJ
82.Fa "CMS_SignerInfo *si"
83.Fa "const ASN1_OBJECT *oid"
84.Fa "int start_after"
85.Fa "int type"
86.Fc
87.Ft "X509_ATTRIBUTE *"
88.Fo CMS_signed_get_attr
89.Fa "const CMS_SignerInfo *si"
90.Fa "int loc"
91.Fc
92.Ft int
93.Fo CMS_signed_get_attr_by_NID
94.Fa "const CMS_SignerInfo *si"
95.Fa "int nid"
96.Fa "int start_after"
97.Fc
98.Ft int
99.Fo CMS_signed_get_attr_by_OBJ
100.Fa "const CMS_SignerInfo *si"
101.Fa "const ASN1_OBJECT *obj"
102.Fa "int start_after"
103.Fc
104.Ft int
105.Fo CMS_signed_get_attr_count
106.Fa "const CMS_SignerInfo *si"
107.Fc
108.Ft int
109.Fo CMS_unsigned_add1_attr
110.Fa "CMS_SignerInfo *si"
111.Fa "X509_ATTRIBUTE *attr"
112.Fc
113.Ft int
114.Fo CMS_unsigned_add1_attr_by_NID
115.Fa "CMS_SignerInfo *si"
116.Fa "int nid"
117.Fa "int type"
118.Fa "const void *bytes"
119.Fa "int len"
120.Fc
121.Ft int
122.Fo CMS_unsigned_add1_attr_by_OBJ
123.Fa "CMS_SignerInfo *si"
124.Fa "const ASN1_OBJECT *obj"
125.Fa "int type"
126.Fa "const void *bytes"
127.Fa "int len"
128.Fc
129.Ft int
130.Fo CMS_unsigned_add1_attr_by_txt
131.Fa "CMS_SignerInfo *si"
132.Fa "const char *attrname"
133.Fa "int type"
134.Fa "const void *bytes"
135.Fa "int len"
136.Fc
137.Ft "X509_ATTRIBUTE *"
138.Fo CMS_unsigned_delete_attr
139.Fa "CMS_SignerInfo *si"
140.Fa "int loc"
141.Fc
142.Ft "void *"
143.Fo CMS_unsigned_get0_data_by_OBJ
144.Fa "CMS_SignerInfo *si"
145.Fa "ASN1_OBJECT *oid"
146.Fa "int start_after"
147.Fa "int type"
148.Fc
149.Ft "X509_ATTRIBUTE *"
150.Fo CMS_unsigned_get_attr
151.Fa "const CMS_SignerInfo *si"
152.Fa "int loc"
153.Fc
154.Ft int
155.Fo CMS_unsigned_get_attr_by_NID
156.Fa "const CMS_SignerInfo *si"
157.Fa "int nid"
158.Fa "int start_after"
159.Fc
160.Ft int
161.Fo CMS_unsigned_get_attr_by_OBJ
162.Fa "const CMS_SignerInfo *si"
163.Fa "const ASN1_OBJECT *obj"
164.Fa "int start_after"
165.Fc
166.Ft int
167.Fo CMS_unsigned_get_attr_count
168.Fa "const CMS_SignerInfo *si"
169.Fc
170.Sh DESCRIPTION
171A
172.Em CMS_SignerInfo
173object has two optional sets of X.501 attributes:
174a set of signed attributes in the
175.Fa signedAttrs
176array and a set of unsigned attributes in the
177.Fa unsignedAttrs
178array.
179The
180.Fn CMS_signed_*
181and
182.Fn CMS_unsigned_*
183functions are similar, except
184.Fn CMS_signed_*
185modifies the
186.Vt CMS_SignerInfo
187object's set of signed attributes and
188.Fn CMS_unsigned_*
189modifies the
190.Vt CMS_SignerInfo
191object's set of unsigned attributes.
192For brevity only the
193.Fn CMS_signed_*
194functions are described below.
195.Pp
196.Fn CMS_signed_add1_attr
197appends a deep copy of
198.Fa attr
199to the
200.Fa signedAttrs
201array of
202.Fa si ,
203allocating a new array if necessary.
204.Pp
205.Fn CMS_signed_add1_attr_by_NID ,
206.Fn CMS_signed_add1_attr_by_OBJ ,
207and
208.Fn CMS_signed_add1_attr_by_txt
209create a new X.501 Attribute object using
210.Xr X509_ATTRIBUTE_create_by_NID 3 ,
211.Xr X509_ATTRIBUTE_create_by_OBJ 3 ,
212or
213.Xr X509_ATTRIBUTE_create_by_txt 3 ,
214respectively,
215and append it to the
216.Fa signedAttrs
217array of
218.Fa si .
219.Pp
220.Fn CMS_signed_delete_attr
221deletes the element with the zero-based
222.Fa loc
223in
224.Fa signedAttrs
225of
226.Fa si .
227.Pp
228.Fn CMS_signed_get0_data_by_OBJ ,
229.Fn CMS_signed_get_attr_by_NID ,
230and
231.Fn CMS_signed_get_attr_by_OBJ
232search the array starting after the index
233.Fa start_after .
234They fail if no matching object is found.
235.Fn CMS_signed_get0_data_by_OBJ
236also fails if the data is not of the requested
237.Fa type .
238.Pp
239Additionally, the
240.Fa start_after
241argument of
242.Fn CMS_signed_get0_data_by_OBJ
243is interpreted in a special way.
244If
245.Fa start_after
246is \-2 or smaller, the function also fails if the
247.Fa signedAttrs
248array of
249.Fa si ,
250contains more than one matching object.
251If
252.Fa start_after
253is \-3 or smaller, it also fails unless the matching object contains exactly
254one value.
255.Pp
256.Fn CMS_signed_get_attr
257returns the array element at the zero-based
258.Fa loc .
259It fails if the
260.Fa loc
261argument is negative or greater than or equal to the number of objects in the
262array.
263.Pp
264.Fn CMS_signed_get_attr_count
265returns the number of objects currently stored in the
266.Fa signedAttrs
267array of
268.Fa si .
269.Sh RETURN VALUES
270.Fn CMS_signed_add1_attr ,
271.Fn CMS_signed_add1_attr_by_NID ,
272.Fn CMS_signed_add1_attr_by_OBJ ,
273.Fn CMS_signed_add1_attr_by_txt ,
274.Fn CMS_unsigned_add1_attr ,
275.Fn CMS_unsigned_add1_attr_by_NID ,
276.Fn CMS_unsigned_add1_attr_by_OBJ ,
277and
278.Fn CMS_unsigned_add1_attr_by_txt
279return 1 for success or 0 if an error occurs.
280.Pp
281.Fn CMS_signed_delete_attr
282returns the deleted element or
283.Dv NULL
284if the
285.Fa signedAttrs
286array is
287.Dv NULL ,
288or if the requested
289.Fa loc
290argument is negative, or greater than or equal to the number of objects in it.
291.Pp
292.Fn CMS_unsigned_delete_attr
293returns the deleted element or
294.Dv NULL
295if the
296.Fa unsignedAttrs
297array is
298.Dv NULL ,
299or if the requested
300.Fa loc
301argument is negative, or greater than or equal to the number of objects in it.
302.Pp
303.Fn CMS_signed_get0_data_by_OBJ
304and
305.Fn CMS_unsigned_get0_data_by_OBJ
306return an internal pointer to the data contained in the value of the first
307object that has an index greater than
308.Fa start_after
309and a type matching
310.Fa type ,
311or NULL on failure.
312.Pp
313.Fn CMS_signed_get_attr
314and
315.Fn CMS_unsigned_get_attr
316return an internal pointer or NULL on failure.
317.Pp
318.Fn CMS_signed_get_attr_by_NID ,
319.Fn CMS_signed_get_attr_by_OBJ ,
320.Fn CMS_unsigned_get_attr_by_NID ,
321and
322.Fn CMS_unsigned_get_attr_by_OBJ
323return the index of the first object in the array that has an index greater than
324.Fa start_after
325and a type matching
326.Fa nid
327or
328.Fa oid ,
329respectively, or \-1 on failure.
330In addition,
331.Fn CMS_signed_get_attr_by_OBJ
332and
333.Fn CMS_unsigned_get_attr_by_OBJ
334return \-2 if
335.Xr OBJ_nid2obj 3
336fails on the requested
337.Fa nid .
338.Pp
339.Fn CMS_signed_get_attr_count
340and
341.Fn CMS_unsigned_get_attr_count
342return the number of array elements or \-1 on failure.
343.Sh SEE ALSO
344.Xr CMS_add1_signer 3 ,
345.Xr CMS_ContentInfo_new 3 ,
346.Xr CMS_get0_SignerInfos 3 ,
347.Xr OBJ_nid2obj 3 ,
348.Xr X509_ATTRIBUTE_create_by_OBJ 3 ,
349.Xr X509_ATTRIBUTE_new 3
350.Sh STANDARDS
351RFC 5652: Cryptographic Message Syntax (CMS)
352.Bl -dash -compact -offset indent
353.It
354section 5.3: SignerInfo Type
355.It
356section 11: Useful Attributes
357.El
358.Sh HISTORY
359These functions first appeared in OpenSSL 0.9.9 and have been available since
360.Ox 6.6 .
diff --git a/src/lib/libcrypto/man/CMS_uncompress.3 b/src/lib/libcrypto/man/CMS_uncompress.3
deleted file mode 100644
index ed2172521e..0000000000
--- a/src/lib/libcrypto/man/CMS_uncompress.3
+++ /dev/null
@@ -1,115 +0,0 @@
1.\" $OpenBSD: CMS_uncompress.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 2 2019 $
52.Dt CMS_UNCOMPRESS 3
53.Os
54.Sh NAME
55.Nm CMS_uncompress
56.Nd uncompress a CMS CompressedData structure
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft int
60.Fo CMS_uncompress
61.Fa "CMS_ContentInfo *cms"
62.Fa "BIO *dcont"
63.Fa "BIO *out"
64.Fa "unsigned int flags"
65.Fc
66.Sh DESCRIPTION
67.Fn CMS_uncompress
68extracts and uncompresses the content of a CMS
69.Vt CompressedData
70structure
71.Fa cms
72and writes it to
73.Fa out .
74.Pp
75In the rare case where the compressed content is detached,
76pass it in via
77.Fa dcont .
78For normal use, set
79.Fa dcont
80to
81.Dv NULL .
82.Pp
83The only currently supported compression algorithm is zlib: if the
84structure indicates the use of any other algorithm, an error is returned.
85If zlib support is not compiled in,
86.Fn CMS_uncompress
87always returns an error.
88.Pp
89If the
90.Dv CMS_TEXT
91bit is set in
92.Fa flags ,
93MIME headers for type text/plain are deleted from the content.
94If the content is not of type text/plain, an error is returned.
95.Sh RETURN VALUES
96.Fn CMS_uncompress
97returns 1 for success or 0 for failure.
98The error can be obtained from
99.Xr ERR_get_error 3 .
100.Sh SEE ALSO
101.Xr CMS_compress 3 ,
102.Xr CMS_ContentInfo_new 3
103.Sh STANDARDS
104RFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS)
105.Sh HISTORY
106.Fn CMS_uncompress
107first appeared in OpenSSL 0.9.8h
108and has been available since
109.Ox 6.7 .
110.Sh BUGS
111The lack of single pass processing and the need to hold all data in
112memory as mentioned in
113.Xr CMS_verify 3
114also applies to
115.Fn CMS_uncompress .
diff --git a/src/lib/libcrypto/man/CMS_verify.3 b/src/lib/libcrypto/man/CMS_verify.3
deleted file mode 100644
index 63f1b8bb18..0000000000
--- a/src/lib/libcrypto/man/CMS_verify.3
+++ /dev/null
@@ -1,230 +0,0 @@
1.\" $OpenBSD: CMS_verify.3,v 1.10 2024/03/29 06:43:12 tb Exp $
2.\" full merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 29 2024 $
52.Dt CMS_VERIFY 3
53.Os
54.Sh NAME
55.Nm CMS_verify ,
56.Nm CMS_get0_signers
57.Nd verify a CMS SignedData structure
58.Sh SYNOPSIS
59.In openssl/cms.h
60.Ft int
61.Fo CMS_verify
62.Fa "CMS_ContentInfo *cms"
63.Fa "STACK_OF(X509) *certs"
64.Fa "X509_STORE *store"
65.Fa "BIO *indata"
66.Fa "BIO *out"
67.Fa "unsigned int flags"
68.Fc
69.Ft STACK_OF(X509) *
70.Fo CMS_get0_signers
71.Fa "CMS_ContentInfo *cms"
72.Fc
73.Sh DESCRIPTION
74.Fn CMS_verify
75verifies the CMS
76.Vt SignedData
77structure
78.Fa cms .
79.Fa certs
80is a set of certificates in which to search for the signing
81certificate(s).
82.Fa store
83is a trusted certificate store used for chain verification.
84.Fa indata
85is the detached content if the content is not present in
86.Fa cms .
87The content is written to
88.Fa out
89if it is not
90.Dv NULL .
91.Pp
92.Fn CMS_get0_signers
93retrieves the signing certificate(s) from
94.Fa cms .
95It may only be called after a successful
96.Fn CMS_verify
97operation.
98The signers must be freed with
99.Fn sk_X509_free .
100.Pp
101Normally the verify process proceeds as follows.
102.Pp
103Initially some sanity checks are performed on
104.Fa cms .
105There must be at least one signature on the data.
106If the content is detached,
107.Fa indata
108cannot be
109.Dv NULL .
110.Pp
111An attempt is made to locate all the signing certificate(s), first
112looking in the
113.Fa certs
114parameter (if it is not
115.Dv NULL )
116and then looking in any certificates contained in the
117.Fa cms
118structure itself.
119If any signing certificate cannot be located, the operation fails.
120.Pp
121Each signing certificate is chain verified using the
122.Sy smimesign
123purpose and the supplied trusted certificate
124.Fa store .
125Any internal certificates in the message are used as untrusted CAs.
126If CRL checking is enabled in
127.Fa store ,
128any internal CRLs are used in addition to attempting to look them up in
129.Fa store .
130If any chain verify fails, an error code is returned.
131.Pp
132Finally the signed content is read (and written to
133.Fa out
134if it is not
135.Dv NULL )
136and the signature is checked.
137.Pp
138If all signatures verify correctly, then the function is successful.
139.Pp
140Any of the following
141.Fa flags
142(OR'ed together) can be passed to change the default verify behaviour:
143.Bl -tag -width Ds
144.It Dv CMS_NOINTERN
145Do not use the certificates in the message itself when
146locating the signing certificate(s).
147This means that all the signing certificates must be in the
148.Fa certs
149parameter.
150.It Dv CMS_NOCRL
151If CRL checking is enabled in
152.Fa store ,
153then any CRLs in the message itself are ignored.
154.It Dv CMS_TEXT
155MIME headers for type text/plain are deleted from the content.
156If the content is not of type text/plain, an error is returned.
157.It Dv CMS_NO_SIGNER_CERT_VERIFY
158Do not verify signing certificates.
159.It Dv CMS_NO_ATTR_VERIFY
160Do not check the signed attributes signature.
161.It Dv CMS_NO_CONTENT_VERIFY
162Do not check the content digest.
163.El
164.Pp
165One application of
166.Dv CMS_NOINTERN
167is to only accept messages signed by a small number of certificates.
168The acceptable certificates would be passed in the
169.Fa certs
170parameter.
171In this case, if the signer is not one of the certificates supplied in
172.Fa certs ,
173then the verify will fail because the signer cannot be found.
174.Pp
175In some cases the standard techniques for looking up and validating
176certificates are not appropriate: for example an application may wish to
177lookup certificates in a database or perform customised verification.
178This can be achieved by setting and verifying the signers certificates
179manually using the signed data utility functions.
180.Pp
181Care should be taken when modifying the default verify behaviour, for
182example setting
183.Dv CMS_NO_CONTENT_VERIFY
184will totally disable all content verification and any modified content
185will be considered valid.
186This combination is however useful if one merely wishes to write the
187content to
188.Fa out
189and its validity is not considered important.
190.Pp
191Chain verification should arguably be performed using the signing time
192rather than the current time.
193However since the signing time is supplied by the signer it cannot be
194trusted without additional evidence (such as a trusted timestamp).
195.Sh RETURN VALUES
196.Fn CMS_verify
197returns 1 for a successful verification or 0 if an error occurred.
198.Pp
199.Fn CMS_get0_signers
200returns all signers or
201.Dv NULL
202if an error occurred.
203The signers must be freed with
204.Fn sk_X509_free .
205.Pp
206The error can be obtained from
207.Xr ERR_get_error 3 .
208.Sh SEE ALSO
209.Xr CMS_ContentInfo_new 3 ,
210.Xr CMS_get0_SignerInfos 3 ,
211.Xr CMS_sign 3 ,
212.Xr CMS_verify_receipt 3
213.Sh STANDARDS
214RFC 5652: Cryptographic Message Syntax (CMS),
215section 5.1: SignedData Type
216.Pp
217RFC 8419: Use of Edwards-Curve Digital Signature Algorithm (EdDSA) Signatures
218in the Cryptographic Message Syntax (CMS)
219.Sh HISTORY
220These functions first appeared in OpenSSL 0.9.8h
221and have been available since
222.Ox 6.7 .
223.Sh BUGS
224The trusted certificate store is not searched for the signing certificate.
225This is primarily due to the inadequacies of the current
226.Vt X509_STORE
227functionality.
228.Pp
229The lack of single pass processing means that the signed content must
230all be held in memory if it is not detached.
diff --git a/src/lib/libcrypto/man/CMS_verify_receipt.3 b/src/lib/libcrypto/man/CMS_verify_receipt.3
deleted file mode 100644
index ac50087a4c..0000000000
--- a/src/lib/libcrypto/man/CMS_verify_receipt.3
+++ /dev/null
@@ -1,110 +0,0 @@
1.\" $OpenBSD: CMS_verify_receipt.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 2 2019 $
52.Dt CMS_VERIFY_RECEIPT 3
53.Os
54.Sh NAME
55.Nm CMS_verify_receipt
56.Nd verify a CMS signed receipt
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft int
60.Fo CMS_verify_receipt
61.Fa "CMS_ContentInfo *rcms"
62.Fa "CMS_ContentInfo *ocms"
63.Fa "STACK_OF(X509) *certs"
64.Fa "X509_STORE *store"
65.Fa "unsigned int flags"
66.Fc
67.Sh DESCRIPTION
68.Fn CMS_verify_receipt
69verifies a CMS signed receipt.
70.Fa rcms
71is the signed receipt to verify.
72.Fa ocms
73is the original
74.Vt SignedData
75structure containing the receipt request.
76.Fa certs
77is a set of certificates in which to search for the signing certificate.
78.Fa store
79is a trusted certificate store (used for chain verification).
80.Pp
81This functions behaves in a similar way to
82.Xr CMS_verify 3
83except that the
84.Fa flags
85values
86.Dv CMS_DETACHED ,
87.Dv CMS_BINARY ,
88.Dv CMS_TEXT ,
89and
90.Dv CMS_STREAM
91are not supported since they do not make sense in the context of signed
92receipts.
93.Sh RETURN VALUES
94.Fn CMS_verify_receipt
95returns 1 for a successful verification or 0 if an error occurred.
96.Pp
97The error can be obtained from
98.Xr ERR_get_error 3 .
99.Sh SEE ALSO
100.Xr CMS_ContentInfo_new 3 ,
101.Xr CMS_get1_ReceiptRequest 3 ,
102.Xr CMS_sign_receipt 3 ,
103.Xr CMS_verify 3
104.Sh STANDARDS
105RFC 2634: Enhanced Security Services for S/MIME, section 2.8: Receipt Syntax
106.Sh HISTORY
107.Fn CMS_verify_receipt
108first appeared in OpenSSL 0.9.8h
109and has been available since
110.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/CONF_modules_free.3 b/src/lib/libcrypto/man/CONF_modules_free.3
deleted file mode 100644
index c5fb840942..0000000000
--- a/src/lib/libcrypto/man/CONF_modules_free.3
+++ /dev/null
@@ -1,100 +0,0 @@
1.\" $OpenBSD: CONF_modules_free.3,v 1.6 2023/07/21 10:46:54 tb Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2004, 2006 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: July 21 2023 $
52.Dt CONF_MODULES_FREE 3
53.Os
54.Sh NAME
55.Nm CONF_modules_free ,
56.Nm CONF_modules_finish ,
57.Nm CONF_modules_unload
58.Nd OpenSSL configuration cleanup functions
59.Sh SYNOPSIS
60.In openssl/conf.h
61.Ft void
62.Fo CONF_modules_free
63.Fa void
64.Fc
65.Ft void
66.Fo CONF_modules_finish
67.Fa void
68.Fc
69.Ft void
70.Fo CONF_modules_unload
71.Fa "int all"
72.Fc
73.Sh DESCRIPTION
74.Fn CONF_modules_free
75closes down and frees up all memory allocated by all configuration
76modules.
77Normally applications will only call this function
78at application exit to tidy up any configuration performed.
79.Pp
80.Fn CONF_modules_finish
81calls the configuration
82.Sy finish
83handler of each configuration module to free up any configuration
84that module may have performed.
85.Pp
86.Fn CONF_modules_unload
87finishes and unloads configuration modules.
88If
89.Fa all
90is set to 1, the builtin modules will be unloaded as well.
91.Sh SEE ALSO
92.Xr CONF_modules_load_file 3 ,
93.Xr OPENSSL_config 3
94.Sh HISTORY
95.Fn CONF_modules_free ,
96.Fn CONF_modules_finish ,
97and
98.Fn CONF_modules_unload
99first appeared in OpenSSL 0.9.7 and have been available since
100.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/CONF_modules_load_file.3 b/src/lib/libcrypto/man/CONF_modules_load_file.3
deleted file mode 100644
index d1bcd49a38..0000000000
--- a/src/lib/libcrypto/man/CONF_modules_load_file.3
+++ /dev/null
@@ -1,282 +0,0 @@
1.\" $OpenBSD: CONF_modules_load_file.3,v 1.14 2023/11/19 20:58:07 tb Exp $
2.\" full merge up to: e9b77246 Jan 20 19:58:49 2017 +0100
3.\" selective merge up to: d090fc00 Feb 26 13:11:10 2019 +0800
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: November 19 2023 $
70.Dt CONF_MODULES_LOAD_FILE 3
71.Os
72.Sh NAME
73.Nm CONF_modules_load_file ,
74.Nm CONF_modules_load ,
75.Nm X509_get_default_cert_area
76.Nd OpenSSL configuration functions
77.Sh SYNOPSIS
78.In openssl/conf.h
79.Ft int
80.Fo CONF_modules_load_file
81.Fa "const char *filename"
82.Fa "const char *appname"
83.Fa "unsigned long flags"
84.Fc
85.Ft int
86.Fo CONF_modules_load
87.Fa "const CONF *cnf"
88.Fa "const char *appname"
89.Fa "unsigned long flags"
90.Fc
91.In openssl/x509.h
92.Ft const char *
93.Fn X509_get_default_cert_area void
94.Sh DESCRIPTION
95The function
96.Fn CONF_modules_load_file
97configures OpenSSL using the file
98.Fa filename
99in
100.Xr openssl.cnf 5
101format and the application name
102.Fa appname .
103If
104.Fa filename
105is
106.Dv NULL ,
107the standard OpenSSL configuration file
108.Pa /etc/ssl/openssl.cnf
109is used.
110If
111.Fa appname
112is
113.Dv NULL ,
114the standard OpenSSL application name
115.Qq openssl_conf
116is used.
117The behaviour can be customized using
118.Fa flags .
119.Pp
120See the
121.Sx EXAMPLES
122section for additional functions that may need to be called.
123Calling configuration functions in the right order for the intended
124effect can be tricky because many configuration functions internally
125call each other.
126.Pp
127.Fn CONF_modules_load
128is identical to
129.Fn CONF_modules_load_file
130except it reads configuration information from
131.Fa cnf .
132.Pp
133The following
134.Fa flags
135are currently recognized:
136.Bl -tag -width Ds
137.It Dv CONF_MFLAGS_IGNORE_ERRORS
138Ignore errors returned by individual configuration modules.
139By default, the first module error is considered fatal and no further
140modules are loaded.
141.It Dv CONF_MFLAGS_SILENT
142Do not add any error information.
143By default, all module errors add error information to the error queue.
144.It Dv CONF_MFLAGS_NO_DSO
145Disable loading of configuration modules from DSOs.
146This flag is provided for compatibility and has no effect.
147.It Dv CONF_MFLAGS_IGNORE_MISSING_FILE
148Let
149.Fn CONF_modules_load_file
150ignore missing configuration files.
151By default, a missing configuration file returns an error.
152.It CONF_MFLAGS_DEFAULT_SECTION
153If
154.Fa appname
155is not
156.Dv NULL
157but does not exist, fall back to the default section
158.Qq openssl_conf .
159.El
160.Pp
161By using
162.Fn CONF_modules_load_file
163with appropriate flags, an application can customise application
164configuration to best suit its needs.
165In some cases the use of a configuration file is optional and its
166absence is not an error: in this case
167.Dv CONF_MFLAGS_IGNORE_MISSING_FILE
168would be set.
169.Pp
170Errors during configuration may also be handled differently by
171different applications.
172For example in some cases an error may simply print out a warning
173message and the application may continue.
174In other cases an application might consider a configuration file
175error fatal and exit immediately.
176.Pp
177Applications can use the
178.Fn CONF_modules_load
179function if they wish to load a configuration file themselves and
180have finer control over how errors are treated.
181.Sh RETURN VALUES
182.Fn CONF_modules_load_file
183and
184.Fn CONF_modules_load
185return 1 for success and zero or a negative value for failure.
186If module errors are not ignored, the return code will reflect the return
187value of the failing module (this will always be zero or negative).
188.Pp
189.Fn X509_get_default_cert_area
190returns a pointer to the constant string
191.Qq "/etc/ssl" .
192.Sh FILES
193.Bl -tag -width /etc/ssl/openssl.cnf -compact
194.It Pa /etc/ssl
195standard configuration directory
196.It Pa /etc/ssl/openssl.cnf
197standard configuration file
198.El
199.Sh EXAMPLES
200Load a configuration file and print out any errors and exit (missing
201file considered fatal):
202.Bd -literal
203if (CONF_modules_load_file(NULL, NULL, 0) <= 0) {
204 fprintf(stderr, "FATAL: error loading configuration file\en");
205 ERR_print_errors_fp(stderr);
206 exit(1);
207}
208.Ed
209.Pp
210Load default configuration file using the section indicated
211by "myapp", tolerate missing files, but exit on other errors:
212.Bd -literal
213if (CONF_modules_load_file(NULL, "myapp",
214 CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) {
215 fprintf(stderr, "FATAL: error loading configuration file\en");
216 ERR_print_errors_fp(stderr);
217 exit(1);
218}
219.Ed
220.Pp
221Load custom configuration file and section instead of the standard one,
222only print warnings on error, missing configuration file ignored:
223.Bd -literal
224OPENSSL_no_config();
225OPENSSL_load_builtin_modules();
226if (CONF_modules_load_file("/something/app.cnf", "myapp",
227 CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) {
228 fprintf(stderr, "WARNING: error loading configuration file\en");
229 ERR_print_errors_fp(stderr);
230}
231.Ed
232.Pp
233In the previous example, the call to
234.Xr OPENSSL_no_config 3
235is required first to suppress automatic loading
236of the standard configuration file, and the call to
237.Xr OPENSSL_load_builtin_modules 3
238is needed so that the configuration of builtin modules
239is loaded in addition to the configuration of
240.Qq myapp .
241.Pp
242Load and parse configuration file manually, custom error handling:
243.Bd -literal
244FILE *fp;
245CONF *cnf = NULL;
246long eline;
247
248fp = fopen("/somepath/app.cnf", "r");
249if (fp == NULL) {
250 fprintf(stderr, "Error opening configuration file\en");
251 /* Other missing configuration file behaviour */
252} else {
253 cnf = NCONF_new(NULL);
254 if (NCONF_load_fp(cnf, fp, &eline) == 0) {
255 fprintf(stderr, "Error on line %ld of configuration file\en",
256 eline);
257 ERR_print_errors_fp(stderr);
258 /* Other malformed configuration file behaviour */
259 } else if (CONF_modules_load(cnf, "appname", 0) <= 0) {
260 fprintf(stderr, "Error configuring application\en");
261 ERR_print_errors_fp(stderr);
262 /* Other configuration error behaviour */
263 }
264 fclose(fp);
265 NCONF_free(cnf);
266}
267.Ed
268.Sh SEE ALSO
269.Xr CONF_modules_free 3 ,
270.Xr ERR 3 ,
271.Xr OPENSSL_config 3 ,
272.Xr OPENSSL_load_builtin_modules 3
273.Sh HISTORY
274.Fn X509_get_default_cert_area
275first appeared in SSLeay 0.4.1 and has been available since
276.Ox 2.4 .
277.Pp
278.Fn CONF_modules_load_file
279and
280.Fn CONF_modules_load
281first appeared in OpenSSL 0.9.7 and have been available since
282.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/CRYPTO_lock.3 b/src/lib/libcrypto/man/CRYPTO_lock.3
deleted file mode 100644
index afc5eb54c5..0000000000
--- a/src/lib/libcrypto/man/CRYPTO_lock.3
+++ /dev/null
@@ -1,121 +0,0 @@
1.\" $OpenBSD: CRYPTO_lock.3,v 1.3 2024/03/14 22:09:40 tb Exp $
2.\" OpenSSL doc/crypto/threads.pod fb552ac6 Sep 30 23:43:01 2009 +0000
3.\"
4.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: March 14 2024 $
19.Dt CRYPTO_LOCK 3
20.Os
21.Sh NAME
22.Nm CRYPTO_lock ,
23.Nm CRYPTO_w_lock ,
24.Nm CRYPTO_w_unlock ,
25.Nm CRYPTO_r_lock ,
26.Nm CRYPTO_r_unlock ,
27.Nm CRYPTO_add
28.Nd thread support
29.Sh SYNOPSIS
30.In openssl/crypto.h
31.Ft void
32.Fo CRYPTO_lock
33.Fa "int mode"
34.Fa "int type"
35.Fa "const char *file"
36.Fa "int line"
37.Fc
38.Ft int
39.Fo CRYPTO_add
40.Fa "int *p"
41.Fa "int amount"
42.Fa "int type"
43.Fc
44.Bd -literal
45#define CRYPTO_w_lock(type) \e
46 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE, type, __FILE__, __LINE__)
47#define CRYPTO_w_unlock(type) \e
48 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE, type, __FILE__, __LINE__)
49#define CRYPTO_r_lock(type) \e
50 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ, type, __FILE__, __LINE__)
51#define CRYPTO_r_unlock(type) \e
52 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ, type, __FILE__, __LINE__)
53.Ed
54.Sh DESCRIPTION
55These functions are obsolete.
56.Pp
57.Fn CRYPTO_lock
58locks or unlocks a mutex lock.
59.Pp
60.Fa mode
61is a bitfield describing what should be done with the lock.
62For each call, either
63.Dv CRYPTO_LOCK
64or
65.Dv CRYPTO_UNLOCK
66must be included.
67In the LibreSSL implementation,
68.Dv CRYPTO_READ
69and
70.Dv CRYPTO_WRITE
71are ignored.
72.Pp
73.Fa type
74is a number in the range 0 <=
75.Fa type No < Dv CRYPTO_NUM_LOCKS
76identifying a particular lock.
77Currently, the value of
78.Dv CRYPTO_NUM_LOCKS
79is 41.
80.Pp
81The
82.Ar file
83and
84.Ar line
85arguments are ignored.
86.Pp
87In the LibreSSL implementation,
88.Fn CRYPTO_lock
89is a wrapper around
90.Xr pthread_mutex_lock 3
91and
92.Xr pthread_mutex_unlock 3 .
93.Pp
94.Fn CRYPTO_add
95locks the lock number
96.Fa type ,
97adds
98.Fa amount
99to
100.Pf * Fa p ,
101and unlocks the lock number
102.Fa type
103again.
104.Sh RETURN VALUES
105.Fn CRYPTO_add
106returns the new value of
107.Pf * Fa p .
108.Sh SEE ALSO
109.Xr crypto 3
110.Sh HISTORY
111.Fn CRYPTO_lock ,
112.Fn CRYPTO_w_lock ,
113.Fn CRYPTO_w_unlock ,
114.Fn CRYPTO_r_lock ,
115and
116.Fn CRYPTO_r_unlock
117first appeared in SSLeay 0.6.0.
118.Fn CRYPTO_add
119first appeared in SSLeay 0.6.2.
120These functions have been available since
121.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/CRYPTO_memcmp.3 b/src/lib/libcrypto/man/CRYPTO_memcmp.3
deleted file mode 100644
index cbc0030c55..0000000000
--- a/src/lib/libcrypto/man/CRYPTO_memcmp.3
+++ /dev/null
@@ -1,95 +0,0 @@
1.\" $OpenBSD: CRYPTO_memcmp.3,v 1.1 2019/08/25 06:20:22 schwarze Exp $
2.\" full merge up to: OpenSSL 1075139c Jun 24 09:18:48 2019 +1000
3.\"
4.\" This file was written by Pauli <paul.dale@oracle.com>.
5.\" Copyright (c) 2019 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: August 25 2019 $
52.Dt CRYPTO_MEMCMP 3
53.Os
54.Sh NAME
55.Nm CRYPTO_memcmp
56.Nd constant time memory comparison
57.Sh SYNOPSIS
58.In openssl/crypto.h
59.Ft int
60.Fo CRYPTO_memcmp
61.Fa "const void *a"
62.Fa "const void *b"
63.Fa "size_t len"
64.Fc
65.Sh DESCRIPTION
66.Fn CRYPTO_memcmp
67compares the
68.Fa len
69bytes pointed to by
70.Fa a
71and
72.Fa b
73for equality.
74It takes an amount of time dependent on
75.Fa len ,
76but independent of the contents of the memory regions pointed to by
77.Fa a
78and
79.Fa b .
80.Sh RETURN VALUES
81.Fn CRYPTO_memcmp
82returns 0 if the content of the memory regions is equal
83or non-zero otherwise.
84.Sh HISTORY
85.Fn CRYPTO_memcmp
86first appeared in OpenSSL 1.0.1d and has been available since
87.Ox 5.6 .
88.Sh BUGS
89Unlike
90.Xr memcmp 3
91and
92.Xr timingsafe_memcmp 3 ,
93this function cannot be used to order the two memory regions.
94In the current implementation, the return value is always greater
95than or equal to 0.
diff --git a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 b/src/lib/libcrypto/man/CRYPTO_set_ex_data.3
deleted file mode 100644
index c22fb22352..0000000000
--- a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3
+++ /dev/null
@@ -1,564 +0,0 @@
1.\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.15 2023/09/18 14:49:43 schwarze Exp $
2.\"
3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 18 2023 $
18.Dt CRYPTO_SET_EX_DATA 3
19.Os
20.Sh NAME
21.Nm CRYPTO_get_ex_new_index ,
22.Nm CRYPTO_EX_new ,
23.Nm CRYPTO_EX_free ,
24.Nm CRYPTO_EX_dup ,
25.Nm CRYPTO_new_ex_data ,
26.Nm CRYPTO_set_ex_data ,
27.Nm CRYPTO_get_ex_data ,
28.Nm CRYPTO_free_ex_data
29.Nd low-level functions for application specific data
30.Sh SYNOPSIS
31.In openssl/crypto.h
32.Ft int
33.Fo CRYPTO_get_ex_new_index
34.Fa "int class_index"
35.Fa "long argl"
36.Fa "void *argp"
37.Fa "CRYPTO_EX_new *new_func"
38.Fa "CRYPTO_EX_dup *dup_func"
39.Fa "CRYPTO_EX_free *free_func"
40.Fc
41.Ft typedef int
42.Fo CRYPTO_EX_new
43.Fa "void *parent"
44.Fa "void *data"
45.Fa "CRYPTO_EX_DATA *ad"
46.Fa "int idx"
47.Fa "long argl"
48.Fa "void *argp"
49.Fc
50.Ft typedef void
51.Fo CRYPTO_EX_free
52.Fa "void *parent"
53.Fa "void *data"
54.Fa "CRYPTO_EX_DATA *ad"
55.Fa "int idx"
56.Fa "long argl"
57.Fa "void *argp"
58.Fc
59.Ft typedef int
60.Fo CRYPTO_EX_dup
61.Fa "CRYPTO_EX_DATA *to"
62.Fa "const CRYPTO_EX_DATA *from"
63.Fa "void *datap"
64.Fa "int idx"
65.Fa "long argl"
66.Fa "void *argp"
67.Fc
68.Ft int
69.Fo CRYPTO_new_ex_data
70.Fa "int class_index"
71.Fa "void *parent"
72.Fa "CRYPTO_EX_DATA *ad"
73.Fc
74.Ft int
75.Fo CRYPTO_set_ex_data
76.Fa "CRYPTO_EX_DATA *ad"
77.Fa "int idx"
78.Fa "void *data"
79.Fc
80.Ft void *
81.Fo CRYPTO_get_ex_data
82.Fa "CRYPTO_EX_DATA *ad"
83.Fa "int idx"
84.Fc
85.Ft void
86.Fo CRYPTO_free_ex_data
87.Fa "int class_index"
88.Fa "void *parent"
89.Fa "CRYPTO_EX_DATA *ad"
90.Fc
91.Sh DESCRIPTION
92The library implements the functions documented in the
93.Xr RSA_get_ex_new_index 3
94manual page and similar functions for other parent object types
95using the functions documented in the present manual page.
96Application programs almost never need
97to call the functions documented here directly.
98.Pp
99.Fn CRYPTO_get_ex_new_index
100behaves in the same way as
101.Xr RSA_get_ex_new_index 3
102except that the parent object type that the new
103.Fa idx
104is reserved for is not part of the function name
105but instead specified by the additional
106.Fa class_index
107argument receiving one of the
108.Dv CRYPTO_EX_INDEX_*
109constants defined in
110.In openssl/crypto.h .
111The recommendation given in
112.Xr RSA_get_ex_new_index 3
113to set the
114.Fa argl
115argument to 0 and the last four arguments all to
116.Dv NULL
117applies.
118The library passes the
119.Fa argl
120and
121.Fa argp
122arguments through to the callback functions for the respective
123.Fa idx ,
124but ignores them otherwise.
125.Pp
126If a function pointer is passed for the
127.Fa new_func
128argument, that function is called for the returned
129.Fa idx
130whenever a new parent object is allocated with
131.Xr RSA_new 3
132or a similar function.
133.Pp
134If a function pointer is passed for the
135.Fa free_func
136argument, that function is called for the returned
137.Fa idx
138when a parent object is freed with
139.Xr RSA_free 3
140or a similar function.
141.Pp
142The arguments of
143.Fa new_func
144and
145.Fa free_func
146are as follows:
147.Pp
148.Bl -tag -width Ds -compact
149.It Fa parent
150the parent object that contains the
151.Fa data
152.It Fa data
153the
154.Fa data
155previously set by
156.Fn CRYPTO_set_ex_data
157at
158.Fa idx
159in
160.Fa parent
161.It Fa ad
162the
163.Vt CRYPTO_EX_DATA
164subobject of the
165.Fa parent
166object
167.It Fa idx
168return value of
169.Fn CRYPTO_get_ex_new_index
170that set this callback
171.It Fa argl
172the
173.Fa argl
174passed to
175.Fn CRYPTO_get_ex_new_index
176for this
177.Fa idx
178.It Fa argp
179the
180.Fa argp
181passed to
182.Fn CRYPTO_get_ex_new_index
183for this
184.Fa idx
185.El
186.Pp
187If a function pointer is passed for the
188.Fa dup_func ,
189that function is supposed to be called for the returned
190.Fa idx
191whenever a parent object of the respective type is copied.
192Actually, the only functions doing that are
193.Xr BIO_dup_chain 3 ,
194.Xr EC_KEY_copy 3 ,
195and
196.Xr SSL_dup 3 ,
197and the TLS 1.3 network stack does it internally when duplicating a
198.Vt SSL_SESSION
199object after receiving a new session ticket message.
200Most other object types supporting ex_data do not support
201copying in the first place, whereas
202.Xr DSA_dup_DH 3
203and
204.Xr X509_dup 3
205simply ignore
206.Fa dup_func .
207.Pp
208The arguments of
209.Fa dup_func
210are as follows:
211.Pp
212.Bl -tag -width Ds -compact
213.It Fa to
214the
215.Vt CRYPTO_EX_DATA
216subobject of the new parent object
217.It Fa from
218the
219.Vt CRYPTO_EX_DATA
220subobject of the original parent object
221.It Fa datap
222a pointer to a copy of the pointer to the original ex_data
223.It Fa idx
224return value of
225.Fn CRYPTO_get_ex_new_index
226that set this callback
227.It Fa argl
228the
229.Fa argl
230passed to
231.Fn CRYPTO_get_ex_new_index
232for this
233.Fa idx
234.It Fa argp
235the
236.Fa argp
237passed to
238.Fn CRYPTO_get_ex_new_index
239for this
240.Fa idx
241.El
242.Pp
243Inside
244.Fa dup_func ,
245the
246.Fa data
247pointer contained in the original parent object being copied
248can be accessed by casting and dereferencing
249.Fa datap ,
250for example:
251.Pp
252.Dl char *orig_data = *(char **)datap;
253.Pp
254If the original data is copied, for example in a manner similar to
255.Bd -literal -offset indent
256char *new_data;
257if ((new_data = strdup(orig_data)) == NULL)
258 return 0;
259.Ed
260.Pp
261then the pointer to the newly allocated memory needs to be passed
262back to the caller in the
263.Fa datap
264argument, for example:
265.Bd -literal -offset indent
266*(char **)datap = new_data;
267return 1;
268.Ed
269.Pp
270Calling
271.Fn CRYPTO_set_ex_data to idx new_data
272from inside
273.Fa dup_func
274has no effect because the code calling
275.Fa dup_func
276unconditionally calls
277.Fn CRYPTO_set_ex_data to idx *datap
278after
279.Fa dup_func
280returns successfully.
281Consequently, if
282.Fa dup_func
283does not change
284.Pf * Fa datap ,
285the new parent object ends up containing a pointer to the same memory
286as the original parent object and any memory allocated in
287.Fa dup_func
288is leaked.
289.Pp
290When multiple callback functions are called,
291they are called in increasing order of their
292.Fa idx
293value.
294.Pp
295.Fn CRYPTO_new_ex_data
296is an internal function that initializes the
297.Fa ad
298subobject of the
299.Fa parent
300object, with the type of the parent object specified by the
301.Fa class_index
302argument.
303Initialization includes calling the respective
304.Fa new_func
305callbacks for all reserved
306.Fa idx
307values that have such callbacks configured.
308Despite its name,
309.Fn CRYPTO_new_ex_data
310does not create a new object but requires that
311.Fa ad
312points to an already allocated but still uninitialized object.
313.Pp
314.Fn CRYPTO_set_ex_data
315and
316.Fn CRYPTO_get_ex_data
317behave in the same way as
318.Xr RSA_set_ex_data 3
319and
320.Xr RSA_get_ex_data 3 ,
321respectively, except that they do not accept a pointer
322to the parent object but instead require a pointer to the
323.Vt CRYPTO_EX_DATA
324subobject of that parent object.
325.Pp
326.Fn CRYPTO_free_ex_data
327is an internal function that frees any memory used inside the
328.Fa ad
329subobject of the
330.Fa parent
331object, with the type of the parent object specified by the
332.Fa class_index
333argument.
334This includes calling the respective
335.Fa free_func
336callbacks for all reserved
337.Fa idx
338values that have such callbacks configured.
339Despite its name,
340.Fn CRYPTO_free_ex_data
341does not free
342.Fa ad
343itself.
344.Sh RETURN VALUES
345.Fn CRYPTO_get_ex_new_index
346returns a new index equal to or greater than 1
347or \-1 if memory allocation fails.
348.Pp
349.Fn CRYPTO_EX_new
350and
351.Fn CRYPTO_EX_dup
352functions are supposed to return 1 on success or 0 on failure.
353.Pp
354.Fn CRYPTO_new_ex_data
355and
356.Fn CRYPTO_set_ex_data
357return 1 on success or 0 if memory allocation fails.
358.Pp
359.Fn CRYPTO_get_ex_data
360returns the application specific data or
361.Dv NULL
362if the parent object that contains
363.Fa ad
364does not contain application specific data at the given
365.Fa idx .
366.Sh ERRORS
367After failure of
368.Fn CRYPTO_get_ex_new_index ,
369.Fn CRYPTO_new_ex_data ,
370or
371.Fn CRYPTO_set_ex_data ,
372the following diagnostic can be retrieved with
373.Xr ERR_get_error 3 ,
374.Xr ERR_GET_REASON 3 ,
375and
376.Xr ERR_reason_error_string 3 :
377.Bl -tag -width Ds
378.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
379Memory allocation failed.
380.El
381.Pp
382In a few unusual failure cases,
383.Xr ERR_get_error 3
384may report different errors caused by
385.Xr OPENSSL_init_crypto 3
386or even none at all.
387.Pp
388Even though it cannot indicate failure,
389.Fn CRYPTO_free_ex_data
390may occasionally also set an error code that can be retrieved with
391.Xr ERR_get_error 3 .
392.Pp
393.Fn CRYPTO_get_ex_data
394does not distinguish success from failure.
395Consequently, after
396.Fn CRYPTO_get_ex_data
397returns
398.Dv NULL ,
399.Xr ERR_get_error 3
400returns 0 unless there is still an earlier error in the queue.
401.Sh SEE ALSO
402.Xr BIO_get_ex_new_index 3 ,
403.Xr DH_get_ex_new_index 3 ,
404.Xr DSA_get_ex_new_index 3 ,
405.Xr RSA_get_ex_new_index 3 ,
406.Xr SSL_CTX_get_ex_new_index 3 ,
407.Xr SSL_get_ex_new_index 3 ,
408.Xr SSL_SESSION_get_ex_new_index 3 ,
409.Xr X509_STORE_CTX_get_ex_new_index 3 ,
410.Xr X509_STORE_get_ex_new_index 3
411.Sh HISTORY
412.Fn CRYPTO_get_ex_new_index ,
413.Fn CRYPTO_new_ex_data ,
414.Fn CRYPTO_set_ex_data ,
415.Fn CRYPTO_get_ex_data ,
416and
417.Fn CRYPTO_free_ex_data
418first appeared in SSLeay 0.9.0 and have been available since
419.Ox 2.4 .
420.Pp
421.Fn CRYPTO_EX_new ,
422.Fn CRYPTO_EX_free ,
423and
424.Fn CRYPTO_EX_dup
425first appeared in OpenSSL 0.9.5 and have been available since
426.Ox 2.7 .
427.Sh CAVEATS
428If an program installs callback functions, the last call to
429.Fn CRYPTO_get_ex_new_index
430installing a function of a certain type for a certain
431.Fa class_index
432needs to be complete before the first object of that
433.Fa class_index
434can be created, freed, or copied, respectively.
435Otherwise, incomplete initialization or cleanup will result.
436.Pp
437At the time
438.Fa new_func
439is called, the
440.Fa parent
441object is only partially initialized,
442so trying to access any data in it is strongly discouraged.
443The
444.Fa data
445argument is typically
446.Dv NULL
447in
448.Fa new_func .
449.Pp
450At the time
451.Fa free_func
452is called, the
453.Fa parent
454object is already mostly deconstructed
455and part of its content may have been cleared and freed.
456Consequently, trying to access any data in
457.Fa parent
458is strongly discouraged.
459According to the OpenSSL API documentation, the library code calling
460.Fa free_func
461would even be permitted to pass a
462.Dv NULL
463pointer for the
464.Fa parent
465argument.
466.Pp
467.Fn CRYPTO_set_ex_data
468and
469.Fn CRYPTO_get_ex_data
470cannot reasonably be used outside the callback functions
471because no API function provides access to any pointers of the type
472.Vt CRYPTO_EX_DATA * .
473.Pp
474Inside
475.Fa new_func ,
476calling
477.Fn CRYPTO_get_ex_data
478makes no sense because it always returns
479.Dv NULL ,
480and calling
481.Fn CRYPTO_set_ex_data
482makes no sense because
483.Fa new_func
484does not have access to any meaningful
485.Fa data
486it could store, and the absence of application specific data at any given
487.Fa idx
488is already sufficiently indicated by the default return value
489.Dv NULL
490of
491.Fn CRYPTO_get_ex_data ,
492.Xr RSA_get_ex_data 3 ,
493and similar functions.
494.Pp
495Inside
496.Fa free_func ,
497calling
498.Fn CRYPTO_get_ex_data
499makes no sense because the return value is already available in
500.Fa data ,
501and calling
502.Fn CRYPTO_set_ex_data
503makes no sense because the parent object, including any ex_data
504contained in it, is already being deconstructed and will no longer
505exist by the time application code regains control.
506.Pp
507Inside
508.Fa dup_func ,
509calling
510.Fn CRYPTO_get_ex_data
511makes no sense because the return value for
512.Fa from
513is already available as
514.Pf * Fa datap ,
515and the return value for
516.Fa to
517is
518.Dv NULL .
519Calling
520.Fn CRYPTO_set_ex_data
521makes no sense because changing
522.Fa from
523would cause an undesirable side effect in this context
524and trying to change
525.Fa to
526is ineffective as explained above.
527.Pp
528Consequently, application code can never use
529.Fn CRYPTO_set_ex_data
530or
531.Fn CRYPTO_get_ex_data
532in a meaningful way.
533.Pp
534The fact that the functions documented in the present manual page
535are part of the public API might create the impression
536that application programs could add ex_data support
537to additional object types not offering it by default.
538However, for built-in object types not offering ex_support, this
539is not possible because such objects do not contain the required
540.Vt CRYPTO_EX_DATA
541subobject.
542.Pp
543It is theoretically possible to add ex_data support to an
544application-defined object type by adding a
545.Vt CRYPTO_EX_DATA
546field to the struct declaration, a call to
547.Fn CRYPTO_new_ex_data
548to the object constructor, and a call to
549.Fn CRYPTO_free_ex_data
550to the object destructor.
551The OpenSSL documentation mentions that the constant
552.Dv CRYPTO_EX_INDEX_APP
553is reserved for this very purpose.
554However, doing this would hardly be useful.
555It is much more straightforward to just add
556all the required data fields to the struct declaration itself.
557.Sh BUGS
558If
559.Fa new_func
560or
561.Fa dup_func
562fails, the failure is silently ignored by the library, potentially
563resulting in an incompletely initialized object.
564The application program cannot detect this kind of failure.
diff --git a/src/lib/libcrypto/man/CRYPTO_set_mem_functions.3 b/src/lib/libcrypto/man/CRYPTO_set_mem_functions.3
deleted file mode 100644
index d020d10ff6..0000000000
--- a/src/lib/libcrypto/man/CRYPTO_set_mem_functions.3
+++ /dev/null
@@ -1,96 +0,0 @@
1.\" $OpenBSD: CRYPTO_set_mem_functions.3,v 1.2 2025/03/08 17:17:09 tb Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 8 2025 $
18.Dt CRYPTO_SET_MEM_FUNCTIONS 3
19.Os
20.Sh NAME
21.Nm CRYPTO_set_mem_functions ,
22.Nm CRYPTO_mem_ctrl ,
23.Nm CRYPTO_mem_leaks ,
24.Nm CRYPTO_mem_leaks_fp ,
25.Nm CRYPTO_mem_leaks_cb
26.Nd legacy OpenSSL memory allocation control
27.Sh SYNOPSIS
28.In openssl/crypto.h
29.Ft int
30.Fo CRYPTO_set_mem_functions
31.Fa "void *(*m)(size_t, const char *, int)"
32.Fa "void *(*r)(void *, size_t, const char *, int)"
33.Fa "void (*f)(void *, const char *, int)"
34.Fc
35.Ft int
36.Fo CRYPTO_mem_ctrl
37.Fa "int mode"
38.Fc
39.Ft int
40.Fo CRYPTO_mem_leaks
41.Fa "BIO *b"
42.Fc
43.Ft int
44.Fo CRYPTO_mem_leaks_fp
45.Fa "FILE *fp"
46.Fc
47.Ft typedef int *
48.Fo CRYPTO_MEM_LEAK_CB
49.Fa "unsigned long"
50.Fa "const char *"
51.Fa int
52.Fa int
53.Fa "void *"
54.Fc
55.Ft int
56.Fo CRYPTO_mem_leaks_cb
57.Fa "CRYPTO_MEM_LEAK_CB *cb"
58.Fc
59.Sh DESCRIPTION
60Do not use any of the interfaces documented here.
61They are provided purely for compatibility with legacy application code.
62.Pp
63.Fn CRYPTO_set_mem_functions ,
64.Fn CRYPTO_mem_ctrl ,
65.Fn CRYPTO_mem_leaks ,
66.Fn CRYPTO_mem_leaks_fp ,
67and
68.Fn CRYPTO_mem_leaks_cb
69have no effect.
70.Sh RETURN VALUES
71.Fn CRYPTO_set_mem_functions
72always returns 0.
73.Pp
74.Fn CRYPTO_mem_ctrl
75always returns
76.Dv CRYPTO_MEM_CHECK_OFF .
77.Pp
78.Fn CRYPTO_mem_leaks ,
79.Fn CRYPTO_mem_leaks_fp ,
80and
81.Fn CRYPTO_mem_leaks_cb
82always return -1.
83.Sh SEE ALSO
84.Xr crypto 3
85.Sh HISTORY
86.Fn CRYPTO_mem_ctrl ,
87.Fn CRYPTO_mem_leaks ,
88and
89.Fn CRYPTO_mem_leaks_fp
90first appeared in SSLeay 0.6.4.
91.Fn CRYPTO_set_mem_functions
92first appeared in SSLeay 0.6.5.
93.Fn CRYPTO_mem_leaks_cb
94first appeared in SSLeay 0.6.6.
95All these functions have all been available since
96.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/ChaCha.3 b/src/lib/libcrypto/man/ChaCha.3
deleted file mode 100644
index 9aae6d70cf..0000000000
--- a/src/lib/libcrypto/man/ChaCha.3
+++ /dev/null
@@ -1,253 +0,0 @@
1.\" $OpenBSD: ChaCha.3,v 1.3 2022/02/18 10:24:32 jsg Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: February 18 2022 $
18.Dt CHACHA 3
19.Os
20.Sh NAME
21.Nm ChaCha_set_key ,
22.Nm ChaCha_set_iv ,
23.Nm ChaCha ,
24.Nm CRYPTO_chacha_20 ,
25.Nm CRYPTO_hchacha_20 ,
26.Nm CRYPTO_xchacha_20
27.Nd ChaCha20 stream cipher
28.Sh SYNOPSIS
29.In openssl/chacha.h
30.Ft void
31.Fo ChaCha_set_key
32.Fa "ChaCha_ctx *ctx"
33.Fa "const unsigned char *key"
34.Fa "unsigned int keybits"
35.Fc
36.Ft void
37.Fo ChaCha_set_iv
38.Fa "ChaCha_ctx *ctx"
39.Fa "const unsigned char *iv"
40.Fa "const unsigned char *counter"
41.Fc
42.Ft void
43.Fo ChaCha
44.Fa "ChaCha_ctx *ctx"
45.Fa "unsigned char *out"
46.Fa "const unsigned char *in"
47.Fa "size_t len"
48.Fc
49.Ft void
50.Fo CRYPTO_chacha_20
51.Fa "unsigned char *out"
52.Fa "const unsigned char *in"
53.Fa "size_t len"
54.Fa "const unsigned char key[32]"
55.Fa "const unsigned char iv[8]"
56.Fa "uint64_t counter"
57.Fc
58.Ft void
59.Fo CRYPTO_hchacha_20
60.Fa "unsigned char out[32]"
61.Fa "const unsigned char key[32]"
62.Fa "const unsigned char iv[16]"
63.Fc
64.Ft void
65.Fo CRYPTO_xchacha_20
66.Fa "unsigned char *out"
67.Fa "const unsigned char *in"
68.Fa "size_t len"
69.Fa "const unsigned char key[32]"
70.Fa "const unsigned char iv[24]"
71.Fc
72.Sh DESCRIPTION
73These functions provide a low-level implementation
74of the ChaCha stream cipher with 256 and 128-bit keys.
75The number of rounds is hardcoded to 20;
76variants with 8 or 12 rounds are not supported.
77.Pp
78Instead of using these functions directly,
79application programs normally use the more portable
80.Xr EVP_chacha20 3
81high-level interface.
82.Pp
83The ChaCha state is contained in the
84.Vt ChaCha_ctx
85structure and consists of sixteen 32-bit unsigned integers.
86.Pp
87For the recommended value of 256
88.Fa keybits ,
89.Fn ChaCha_set_key
90copies 32 bytes (256 bits) from
91.Fa key
92to the middle eight integers of the ChaCha state,
93using little endian order for each integer.
94For the alternative value of 128
95.Fa keybits ,
96only 16 bytes (128 bits) are copied from
97.Fa key
98to the ChaCha state, but they are copied twice,
99once to the second quarter and once to the third quarter.
100The first quarter of the ChaCha state is set to four constant integers;
101these constants differ depending on whether
102.Fa keybits
103is 128 or 256.
104The last quarter of the ChaCha state remains unchanged.
105.Pp
106.Fn ChaCha_set_iv
107copies eight bytes (64 bits) from
108.Fa counter
109and eight bytes (64 bits) from
110.Fa iv
111to the last quarter of the ChaCha state, the counter to the first
112two integers and the initialization vector to the last two integers,
113again in little endian order.
114If
115.Fa counter
116is
117.Dv NULL ,
118the two respective integers are set to 0 instead.
119The first three quarters of the ChaCha state remain unchanged.
120.Pp
121.Fn ChaCha
122encrypts
123.Fa len
124bytes of data from
125.Fa in
126to
127.Fa out
128using the
129.Fa ctx
130that was previously set up with
131.Fn ChaCha_set_key
132and
133.Fn ChaCha_set_iv .
134Providing an
135.Fa out
136buffer of at least
137.Fa len
138bytes is the responsibility of the caller.
139This function can be called multiple times in a row with varying
140.Fa len
141arguments.
142The
143.Fa len
144does not need to be a multiple of 64.
145.Pp
146.Fn CRYPTO_chacha_20
147encrypts
148.Fa len
149bytes of data from
150.Fa in
151to
152.Fa out
153in a one-shot operation, using the given
154.Fa key
155and
156.Fa iv
157as described for
158.Fn ChaCha_set_key
159and
160.Fn ChaCha_set_iv
161and copying the less significant half of
162.Fa counter
163to the first counter integer in the initial ChaCha state
164and the more significant half to the second integer.
165Providing an
166.Fa out
167buffer of at least
168.Fa len
169bytes is again the responsibility of the caller.
170The maximum supported value for
171.Fa len
172is 2^32 \- 1.
173.Pp
174XChaCha is a variant of ChaCha designed to support longer nonces,
175just like XSalsa20 is a variant of Salsa20 supporting longer nonces.
176.Pp
177.Fn CRYPTO_xchacha_20
178encrypts
179.Fa len
180bytes of data from
181.Fa in
182to
183.Fa out
184in a one-shot operation with the XChaCha algorithm, using the given
185.Fa key
186and
187.Fa iv .
188It is equivalent to
189.Fn CRYPTO_chacha_20
190with the last third of
191.Fa iv ,
192a
193.Fa counter
194of 0, and a key generated with
195.Fn CRYPTO_hchacha_20
196from the first two thirds of
197.Fa iv .
198.Sh SEE ALSO
199.Xr crypto 3 ,
200.Xr EVP_chacha20 3
201.Rs
202.%A Daniel J. Bernstein
203.%T ChaCha, a variant of Salsa20
204.%U https://cr.yp.to/chacha/chacha-20080128.pdf
205.%C Chicago
206.%D January 28, 2008
207.Re
208.Rs
209.%A Daniel J. Bernstein
210.%T Extending the Salsa20 nonce
211.%U https://cr.yp.to/snuffle/xsalsa-20110204.pdf
212.%C Chicago
213.%D August 22, 2017
214.Re
215.Sh STANDARDS
216RFC 8439: ChaCha20 and Poly1305 for IETF Protocols
217.Pp
218Note that the standard specifies
219a 32-bit counter and a 96-bit initialization vector whereas
220this implementation follows Bernstein's original specification
221and uses a 64-bit counter and a 64-bit initialization vector.
222.Pp
223These functions are specific to LibreSSL and not provided by OpenSSL.
224BoringSSL does provide
225.Fn CRYPTO_chacha_20 ,
226but with an incompatible interface, taking a 96-bit
227.Fa iv
228and a 32-bit
229.Fa counter .
230.Sh HISTORY
231.Fn ChaCha_set_key ,
232.Fn ChaCha_set_iv ,
233.Fn ChaCha ,
234and
235.Fn CRYPTO_chacha_20
236first appeared in
237.Ox 5.6 .
238.\" Committed on May 1, 2014.
239.\" BoringSSL added CRYPTO_chacha_20 on June 20, 2014.
240.Pp
241.Fn CRYPTO_hchacha_20
242and
243.Fn CRYPTO_xchacha_20
244first appeared in
245.Ox 6.5 .
246.Sh AUTHORS
247.An -nosplit
248This implementation was written by
249.An Daniel J. Bernstein Aq Mt djb@cr.yp.to .
250The API layer was added by
251.An Joel Sing Aq Mt jsing@openbsd.org
252for ChaCha, and for XChaCha by
253.An David Gwynne Aq Mt dlg@openbsd.org .
diff --git a/src/lib/libcrypto/man/DES_set_key.3 b/src/lib/libcrypto/man/DES_set_key.3
deleted file mode 100644
index fd09d77730..0000000000
--- a/src/lib/libcrypto/man/DES_set_key.3
+++ /dev/null
@@ -1,787 +0,0 @@
1.\" $OpenBSD: DES_set_key.3,v 1.17 2024/05/24 19:18:07 tb Exp $
2.\" full merge up to:
3.\" OpenSSL man3/DES_random_key 521738e9 Oct 5 14:58:30 2018 -0400
4.\"
5.\" --------------------------------------------------------------------------
6.\" Major patches to this file were contributed by
7.\" Ulf Moeller <ulf@openssl.org>, Ben Laurie <ben@openssl.org>,
8.\" and Richard Levitte <levitte@openssl.org>.
9.\" --------------------------------------------------------------------------
10.\" Copyright (c) 2000, 2001, 2017 The OpenSSL Project. All rights reserved.
11.\"
12.\" Redistribution and use in source and binary forms, with or without
13.\" modification, are permitted provided that the following conditions
14.\" are met:
15.\"
16.\" 1. Redistributions of source code must retain the above copyright
17.\" notice, this list of conditions and the following disclaimer.
18.\"
19.\" 2. Redistributions in binary form must reproduce the above copyright
20.\" notice, this list of conditions and the following disclaimer in
21.\" the documentation and/or other materials provided with the
22.\" distribution.
23.\"
24.\" 3. All advertising materials mentioning features or use of this
25.\" software must display the following acknowledgment:
26.\" "This product includes software developed by the OpenSSL Project
27.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
28.\"
29.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
30.\" endorse or promote products derived from this software without
31.\" prior written permission. For written permission, please contact
32.\" openssl-core@openssl.org.
33.\"
34.\" 5. Products derived from this software may not be called "OpenSSL"
35.\" nor may "OpenSSL" appear in their names without prior written
36.\" permission of the OpenSSL Project.
37.\"
38.\" 6. Redistributions of any form whatsoever must retain the following
39.\" acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
42.\"
43.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
44.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
47.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54.\" OF THE POSSIBILITY OF SUCH DAMAGE.
55.\"
56.\" --------------------------------------------------------------------------
57.\" Parts of this file are derived from SSLeay documentation,
58.\" which is covered by the following Copyright and license:
59.\" --------------------------------------------------------------------------
60.\"
61.\" Copyright (C) 1995-1998 Tim Hudson (tjh@cryptsoft.com)
62.\" All rights reserved.
63.\"
64.\" This package is an SSL implementation written
65.\" by Eric Young (eay@cryptsoft.com).
66.\" The implementation was written so as to conform with Netscapes SSL.
67.\"
68.\" This library is free for commercial and non-commercial use as long as
69.\" the following conditions are aheared to. The following conditions
70.\" apply to all code found in this distribution, be it the RC4, RSA,
71.\" lhash, DES, etc., code; not just the SSL code. The SSL documentation
72.\" included with this distribution is covered by the same copyright terms
73.\" except that the holder is Tim Hudson (tjh@cryptsoft.com).
74.\"
75.\" Copyright remains Eric Young's, and as such any Copyright notices in
76.\" the code are not to be removed.
77.\" If this package is used in a product, Eric Young should be given
78.\" attribution as the author of the parts of the library used.
79.\" This can be in the form of a textual message at program startup or
80.\" in documentation (online or textual) provided with the package.
81.\"
82.\" Redistribution and use in source and binary forms, with or without
83.\" modification, are permitted provided that the following conditions
84.\" are met:
85.\" 1. Redistributions of source code must retain the copyright
86.\" notice, this list of conditions and the following disclaimer.
87.\" 2. Redistributions in binary form must reproduce the above copyright
88.\" notice, this list of conditions and the following disclaimer in the
89.\" documentation and/or other materials provided with the distribution.
90.\" 3. All advertising materials mentioning features or use of this software
91.\" must display the following acknowledgement:
92.\" "This product includes cryptographic software written by
93.\" Eric Young (eay@cryptsoft.com)"
94.\" The word 'cryptographic' can be left out if the rouines from the
95.\" library being used are not cryptographic related :-).
96.\" 4. If you include any Windows specific code (or a derivative thereof)
97.\" from the apps directory (application code) you must include an
98.\" acknowledgement: "This product includes software written by
99.\" Tim Hudson (tjh@cryptsoft.com)"
100.\"
101.\" THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
102.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
103.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
104.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
105.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
106.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
107.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
108.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
109.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
110.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
111.\" SUCH DAMAGE.
112.\"
113.\" The licence and distribution terms for any publically available version or
114.\" derivative of this code cannot be changed. i.e. this code cannot simply be
115.\" copied and put under another distribution licence
116.\" [including the GNU Public Licence.]
117.\"
118.Dd $Mdocdate: May 24 2024 $
119.Dt DES_SET_KEY 3
120.Os
121.Sh NAME
122.Nm DES_random_key ,
123.Nm DES_set_key ,
124.Nm DES_key_sched ,
125.Nm DES_set_key_checked ,
126.Nm DES_set_key_unchecked ,
127.Nm DES_set_odd_parity ,
128.Nm DES_is_weak_key ,
129.Nm DES_ecb_encrypt ,
130.Nm DES_ecb2_encrypt ,
131.Nm DES_ecb3_encrypt ,
132.Nm DES_ncbc_encrypt ,
133.Nm DES_cfb_encrypt ,
134.Nm DES_ofb_encrypt ,
135.Nm DES_pcbc_encrypt ,
136.Nm DES_cfb64_encrypt ,
137.Nm DES_ofb64_encrypt ,
138.Nm DES_xcbc_encrypt ,
139.Nm DES_ede2_cbc_encrypt ,
140.Nm DES_ede2_cfb64_encrypt ,
141.Nm DES_ede2_ofb64_encrypt ,
142.Nm DES_ede3_cbc_encrypt ,
143.Nm DES_ede3_cbcm_encrypt ,
144.Nm DES_ede3_cfb64_encrypt ,
145.Nm DES_ede3_ofb64_encrypt ,
146.Nm DES_cbc_cksum ,
147.Nm DES_quad_cksum ,
148.Nm DES_string_to_key ,
149.Nm DES_string_to_2keys ,
150.Nm DES_fcrypt ,
151.Nm DES_crypt
152.Nd DES encryption
153.Sh SYNOPSIS
154.In openssl/des.h
155.Ft void
156.Fo DES_random_key
157.Fa "DES_cblock *ret"
158.Fc
159.Ft int
160.Fo DES_set_key
161.Fa "const_DES_cblock *key"
162.Fa "DES_key_schedule *schedule"
163.Fc
164.Ft int
165.Fo DES_key_sched
166.Fa "const_DES_cblock *key"
167.Fa "DES_key_schedule *schedule"
168.Fc
169.Ft int
170.Fo DES_set_key_checked
171.Fa "const_DES_cblock *key"
172.Fa "DES_key_schedule *schedule"
173.Fc
174.Ft void
175.Fo DES_set_key_unchecked
176.Fa "const_DES_cblock *key"
177.Fa "DES_key_schedule *schedule"
178.Fc
179.Ft void
180.Fo DES_set_odd_parity
181.Fa "DES_cblock *key"
182.Fc
183.Ft int
184.Fo DES_is_weak_key
185.Fa "const_DES_cblock *key"
186.Fc
187.Ft void
188.Fo DES_ecb_encrypt
189.Fa "const_DES_cblock *input"
190.Fa "DES_cblock *output"
191.Fa "DES_key_schedule *ks"
192.Fa "int enc"
193.Fc
194.Ft void
195.Fo DES_ecb2_encrypt
196.Fa "const_DES_cblock *input"
197.Fa "DES_cblock *output"
198.Fa "DES_key_schedule *ks1"
199.Fa "DES_key_schedule *ks2"
200.Fa "int enc"
201.Fc
202.Ft void
203.Fo DES_ecb3_encrypt
204.Fa "const_DES_cblock *input"
205.Fa "DES_cblock *output"
206.Fa "DES_key_schedule *ks1"
207.Fa "DES_key_schedule *ks2"
208.Fa "DES_key_schedule *ks3"
209.Fa "int enc"
210.Fc
211.Ft void
212.Fo DES_ncbc_encrypt
213.Fa "const unsigned char *input"
214.Fa "unsigned char *output"
215.Fa "long length"
216.Fa "DES_key_schedule *schedule"
217.Fa "DES_cblock *ivec"
218.Fa "int enc"
219.Fc
220.Ft void
221.Fo DES_cfb_encrypt
222.Fa "const unsigned char *in"
223.Fa "unsigned char *out"
224.Fa "int numbits"
225.Fa "long length"
226.Fa "DES_key_schedule *schedule"
227.Fa "DES_cblock *ivec"
228.Fa "int enc"
229.Fc
230.Ft void
231.Fo DES_ofb_encrypt
232.Fa "const unsigned char *in"
233.Fa "unsigned char *out"
234.Fa "int numbits"
235.Fa "long length"
236.Fa "DES_key_schedule *schedule"
237.Fa "DES_cblock *ivec"
238.Fc
239.Ft void
240.Fo DES_pcbc_encrypt
241.Fa "const unsigned char *input"
242.Fa "unsigned char *output"
243.Fa "long length"
244.Fa "DES_key_schedule *schedule"
245.Fa "DES_cblock *ivec"
246.Fa "int enc"
247.Fc
248.Ft void
249.Fo DES_cfb64_encrypt
250.Fa "const unsigned char *in"
251.Fa "unsigned char *out"
252.Fa "long length"
253.Fa "DES_key_schedule *schedule"
254.Fa "DES_cblock *ivec"
255.Fa "int *num"
256.Fa "int enc"
257.Fc
258.Ft void
259.Fo DES_ofb64_encrypt
260.Fa "const unsigned char *in"
261.Fa "unsigned char *out"
262.Fa "long length"
263.Fa "DES_key_schedule *schedule"
264.Fa "DES_cblock *ivec"
265.Fa "int *num"
266.Fc
267.Ft void
268.Fo DES_xcbc_encrypt
269.Fa "const unsigned char *input"
270.Fa "unsigned char *output"
271.Fa "long length"
272.Fa "DES_key_schedule *schedule"
273.Fa "DES_cblock *ivec"
274.Fa "const_DES_cblock *inw"
275.Fa "const_DES_cblock *outw"
276.Fa "int enc"
277.Fc
278.Ft void
279.Fo DES_ede2_cbc_encrypt
280.Fa "const unsigned char *input"
281.Fa "unsigned char *output"
282.Fa "long length"
283.Fa "DES_key_schedule *ks1"
284.Fa "DES_key_schedule *ks2"
285.Fa "DES_cblock *ivec"
286.Fa "int enc"
287.Fc
288.Ft void
289.Fo DES_ede2_cfb64_encrypt
290.Fa "const unsigned char *in"
291.Fa "unsigned char *out"
292.Fa "long length"
293.Fa "DES_key_schedule *ks1"
294.Fa "DES_key_schedule *ks2"
295.Fa "DES_cblock *ivec"
296.Fa "int *num"
297.Fa "int enc"
298.Fc
299.Ft void
300.Fo DES_ede2_ofb64_encrypt
301.Fa "const unsigned char *in"
302.Fa "unsigned char *out"
303.Fa "long length"
304.Fa "DES_key_schedule *ks1"
305.Fa "DES_key_schedule *ks2"
306.Fa "DES_cblock *ivec"
307.Fa "int *num"
308.Fc
309.Ft void
310.Fo DES_ede3_cbc_encrypt
311.Fa "const unsigned char *input"
312.Fa "unsigned char *output"
313.Fa "long length"
314.Fa "DES_key_schedule *ks1"
315.Fa "DES_key_schedule *ks2"
316.Fa "DES_key_schedule *ks3"
317.Fa "DES_cblock *ivec"
318.Fa "int enc"
319.Fc
320.Ft void
321.Fo DES_ede3_cbcm_encrypt
322.Fa "const unsigned char *in"
323.Fa "unsigned char *out"
324.Fa "long length"
325.Fa "DES_key_schedule *ks1"
326.Fa "DES_key_schedule *ks2"
327.Fa "DES_key_schedule *ks3"
328.Fa "DES_cblock *ivec1"
329.Fa "DES_cblock *ivec2"
330.Fa "int enc"
331.Fc
332.Ft void
333.Fo DES_ede3_cfb64_encrypt
334.Fa "const unsigned char *in"
335.Fa "unsigned char *out"
336.Fa "long length"
337.Fa "DES_key_schedule *ks1"
338.Fa "DES_key_schedule *ks2"
339.Fa "DES_key_schedule *ks3"
340.Fa "DES_cblock *ivec"
341.Fa "int *num"
342.Fa "int enc"
343.Fc
344.Ft void
345.Fo DES_ede3_ofb64_encrypt
346.Fa "const unsigned char *in"
347.Fa "unsigned char *out"
348.Fa "long length"
349.Fa "DES_key_schedule *ks1"
350.Fa "DES_key_schedule *ks2"
351.Fa "DES_key_schedule *ks3"
352.Fa "DES_cblock *ivec"
353.Fa "int *num"
354.Fc
355.Ft DES_LONG
356.Fo DES_cbc_cksum
357.Fa "const unsigned char *input"
358.Fa "DES_cblock *output"
359.Fa "long length"
360.Fa "DES_key_schedule *schedule"
361.Fa "const_DES_cblock *ivec"
362.Fc
363.Ft DES_LONG
364.Fo DES_quad_cksum
365.Fa "const unsigned char *input"
366.Fa "DES_cblock output[]"
367.Fa "long length"
368.Fa "int out_count"
369.Fa "DES_cblock *seed"
370.Fc
371.Ft void
372.Fo DES_string_to_key
373.Fa "const char *str"
374.Fa "DES_cblock *key"
375.Fc
376.Ft void
377.Fo DES_string_to_2keys
378.Fa "const char *str"
379.Fa "DES_cblock *key1"
380.Fa "DES_cblock *key2"
381.Fc
382.Ft char *
383.Fo DES_fcrypt
384.Fa "const char *buf"
385.Fa "const char *salt"
386.Fa "char *ret"
387.Fc
388.Ft char *
389.Fo DES_crypt
390.Fa "const char *buf"
391.Fa "const char *salt"
392.Fc
393.Sh DESCRIPTION
394This library contains a fast implementation of the DES encryption
395algorithm.
396.Pp
397There are two phases to the use of DES encryption.
398The first is the generation of a
399.Vt DES_key_schedule
400from a key, and the second is the actual encryption.
401A DES key is of type
402.Vt DES_cblock .
403This type consists of 8 bytes with odd parity.
404The least significant bit in each byte is the parity bit.
405The key schedule is an expanded form of the key; it is used to speed the
406encryption process.
407.Pp
408.Fn DES_random_key
409generates a random key in odd parity.
410.Pp
411Before a DES key can be used, it must be converted into the architecture
412dependent
413.Vt DES_key_schedule
414via the
415.Fn DES_set_key_checked
416or
417.Fn DES_set_key_unchecked
418function.
419.Pp
420.Fn DES_set_key_checked
421will check that the key passed is of odd parity and is not a weak or
422semi-weak key.
423If the parity is wrong, then -1 is returned.
424If the key is a weak key, then -2 is returned.
425If an error is returned, the key schedule is not generated.
426.Pp
427.Fn DES_set_key
428works like
429.Fn DES_set_key_checked
430if the
431.Em DES_check_key
432flag is non-zero, otherwise like
433.Fn DES_set_key_unchecked .
434These functions are available for compatibility; it is recommended to
435use a function that does not depend on a global variable.
436.Pp
437.Fn DES_set_odd_parity
438sets the parity of the passed
439.Fa key
440to odd.
441.Pp
442The following routines mostly operate on an input and output stream of
443.Vt DES_cblock Ns s .
444.Pp
445.Fn DES_ecb_encrypt
446is the basic DES encryption routine that encrypts or decrypts a single
4478-byte
448.Vt DES_cblock
449in electronic code book (ECB) mode.
450It always transforms the input data, pointed to by
451.Fa input ,
452into the output data, pointed to by the
453.Fa output
454argument.
455If the
456.Fa enc
457argument is non-zero
458.Pq Dv DES_ENCRYPT ,
459the
460.Fa input
461(cleartext) is encrypted into the
462.Fa output
463(ciphertext) using the key_schedule specified by the
464.Fa schedule
465argument, previously set via
466.Fn DES_set_key .
467If
468.Fa enc
469is zero
470.Pq Dv DES_DECRYPT ,
471the
472.Fa input
473(now ciphertext) is decrypted into the
474.Fa output
475(now cleartext).
476Input and output may overlap.
477.Fn DES_ecb_encrypt
478does not return a value.
479.Pp
480.Fn DES_ecb3_encrypt
481encrypts/decrypts the
482.Fa input
483block by using three-key Triple-DES encryption in ECB mode.
484This involves encrypting the input with
485.Fa ks1 ,
486decrypting with the key schedule
487.Fa ks2 ,
488and then encrypting with
489.Fa ks3 .
490This routine greatly reduces the chances of brute force breaking of DES
491and has the advantage of if
492.Fa ks1 ,
493.Fa ks2 ,
494and
495.Fa ks3
496are the same, it is equivalent to just encryption using ECB mode and
497.Fa ks1
498as the key.
499.Pp
500The macro
501.Fn DES_ecb2_encrypt
502is provided to perform two-key Triple-DES encryption by using
503.Fa ks1
504for the final encryption.
505.Pp
506.Fn DES_ncbc_encrypt
507encrypts/decrypts using the cipher-block-chaining (CBC) mode of DES.
508If the
509.Fa enc
510argument is non-zero, the routine cipher-block-chain encrypts the
511cleartext data pointed to by the
512.Fa input
513argument into the ciphertext pointed to by the
514.Fa output
515argument, using the key schedule provided by the
516.Fa schedule
517argument, and initialization vector provided by the
518.Fa ivec
519argument.
520If the
521.Fa length
522argument is not an integral multiple of eight bytes, the last block is
523copied to a temporary area and zero filled.
524The output is always an integral multiple of eight bytes.
525.Pp
526.Fn DES_xcbc_encrypt
527is RSA's DESX mode of DES.
528It uses
529.Fa inw
530and
531.Fa outw
532to "whiten" the encryption.
533.Fa inw
534and
535.Fa outw
536are secret (unlike the iv) and are as such, part of the key.
537So the key is sort of 24 bytes.
538This is much better than CBC DES.
539.Pp
540.Fn DES_ede3_cbc_encrypt
541implements outer triple CBC DES encryption with three keys.
542This means that each DES operation inside the CBC mode is
543.Qq Li C=E(ks3,D(ks2,E(ks1,M))) .
544This mode is used by SSL.
545.Pp
546The
547.Fn DES_ede2_cbc_encrypt
548macro implements two-key Triple-DES by reusing
549.Fa ks1
550for the final encryption.
551.Qq Li C=E(ks1,D(ks2,E(ks1,M))) .
552This form of Triple-DES is used by the RSAREF library.
553.Pp
554.Fn DES_pcbc_encrypt
555encrypts/decrypts using the propagating cipher block chaining mode used
556by Kerberos v4.
557Its parameters are the same as
558.Fn DES_ncbc_encrypt .
559.Pp
560.Fn DES_cfb_encrypt
561encrypts/decrypts using cipher feedback mode.
562This method takes an array of characters as input and outputs an array
563of characters.
564It does not require any padding to 8 character groups.
565Note: the
566.Fa ivec
567variable is changed and the new changed value needs to be passed to the
568next call to this function.
569Since this function runs a complete DES ECB encryption per
570.Fa numbits ,
571this function is only suggested for use when sending a small number of
572characters.
573.Pp
574.Fn DES_cfb64_encrypt
575implements CFB mode of DES with 64-bit feedback.
576Why is this useful you ask?
577Because this routine will allow you to encrypt an arbitrary number of
578bytes, without 8 byte padding.
579Each call to this routine will encrypt the input bytes to output and
580then update ivec and num.
581num contains "how far" we are though ivec.
582If this does not make much sense, read more about CFB mode of DES.
583.Pp
584The
585.Fn DES_ede3_cfb64_encrypt
586function and the
587.Fn DES_ede2_cfb64_encrypt
588macro are the same as
589.Fn DES_cfb64_encrypt
590except that Triple-DES is used.
591.Pp
592.Fn DES_ofb_encrypt
593encrypts using output feedback mode.
594This method takes an array of characters as input and outputs an array
595of characters.
596It does not require any padding to 8 character groups.
597Note: the
598.Fa ivec
599variable is changed and the new changed value needs to be passed to the
600next call to this function.
601Since this function runs a complete DES ECB encryption per
602.Fa numbits ,
603this function is only suggested for use when sending a small number
604of characters.
605.Pp
606.Fn DES_ofb64_encrypt
607is the same as
608.Fn DES_cfb64_encrypt
609using Output Feed Back mode.
610.Pp
611The
612.Fn DES_ede3_ofb64_encrypt
613function and the
614.Fn DES_ede2_ofb64_encrypt
615macro are the same as
616.Fn DES_ofb64_encrypt ,
617using Triple-DES.
618.Pp
619The following functions are included in the DES library for
620compatibility with the MIT Kerberos library.
621.Pp
622.Fn DES_cbc_cksum
623produces an 8-byte checksum based on the input stream (via CBC
624encryption).
625The last 4 bytes of the checksum are returned and the complete 8 bytes
626are placed in
627.Fa output .
628This function is used by Kerberos v4.
629Other applications should use
630.Xr EVP_DigestInit 3
631etc. instead.
632.Pp
633.Fn DES_quad_cksum
634is a Kerberos v4 function.
635It returns a 4-byte checksum from the input bytes.
636The algorithm can be iterated over the input, depending on
637.Fa out_count ,
6381, 2, 3 or 4 times.
639If
640.Fa output
641is
642.Pf non- Dv NULL ,
643the 8 bytes generated by each pass are written into
644.Fa output .
645.Pp
646The following are DES-based transformations:
647.Pp
648.Fn DES_fcrypt
649is a fast version of the Unix
650.Xr crypt 3
651function.
652The
653.Fa salt
654must be two ASCII characters.
655This version is different from the normal crypt in that the third
656parameter is the buffer that the return value is written into.
657It needs to be at least 14 bytes long.
658The fourteenth byte is set to NUL.
659This version takes only a small amount of space relative to other
660fast crypt implementations.
661It is thread safe, unlike the normal crypt.
662.Pp
663.Fn DES_crypt
664is a faster replacement for the normal system
665.Xr crypt 3 .
666This function calls
667.Fn DES_fcrypt
668with a static array passed as the third parameter.
669This emulates the normal non-thread safe semantics of
670.Xr crypt 3 .
671.Sh RETURN VALUES
672.Fn DES_set_key ,
673.Fn DES_key_sched ,
674and
675.Fn DES_set_key_checked
676return 0 on success or a negative value on error.
677.Pp
678.Fn DES_is_weak_key
679returns 1 if the passed key is a weak key or 0 if it is ok.
680.Pp
681.Fn DES_cbc_cksum
682and
683.Fn DES_quad_cksum
684return a 4-byte integer representing the last 4 bytes of the checksum
685of the input.
686.Pp
687.Fn DES_fcrypt
688returns a pointer to the caller-provided buffer
689.Fa ret ,
690and
691.Fn DES_crypt
692returns a pointer to a static buffer.
693Both are allowed to return
694.Dv NULL
695to indicate failure, but currently, they cannot fail.
696.Sh SEE ALSO
697.Xr crypt 3 ,
698.Xr EVP_des_cbc 3 ,
699.Xr EVP_EncryptInit 3
700.Sh STANDARDS
701ANSI X3.106
702.Pp
703The DES library was initially written to be source code compatible
704with the MIT Kerberos library.
705.Sh HISTORY
706.Fn DES_random_key ,
707.Fn DES_set_key ,
708.Fn DES_key_sched ,
709.Fn DES_set_odd_parity ,
710.Fn DES_is_weak_key ,
711.Fn DES_ecb_encrypt ,
712.Fn DES_cfb_encrypt ,
713.Fn DES_ofb_encrypt ,
714.Fn DES_pcbc_encrypt ,
715.Fn DES_cfb64_encrypt ,
716.Fn DES_ofb64_encrypt ,
717.Fn DES_ede3_cbc_encrypt ,
718.Fn DES_cbc_cksum ,
719.Fn DES_quad_cksum ,
720.Fn DES_string_to_key ,
721.Fn DES_string_to_2keys ,
722and
723.Fn DES_crypt
724appeared in SSLeay 0.4 or earlier.
725.Fn DES_ncbc_encrypt
726first appeared in SSLeay 0.4.2.
727.Fn DES_ede2_cbc_encrypt
728first appeared in SSLeay 0.4.4.
729.Fn DES_ecb2_encrypt ,
730.Fn DES_ecb3_encrypt ,
731.Fn DES_ede2_cfb64_encrypt ,
732.Fn DES_ede2_ofb64_encrypt ,
733.Fn DES_ede3_cfb64_encrypt ,
734and
735.Fn DES_ede3_ofb64_encrypt
736first appeared in SSLeay 0.5.1.
737.Fn DES_xcbc_encrypt
738first appeared in SSLeay 0.6.2.
739.Fn DES_fcrypt
740first appeared in SSLeay 0.6.5.
741These functions have been available since
742.Ox 2.4 .
743.Pp
744.Fn DES_set_key_checked
745and
746.Fn DES_set_key_unchecked
747first appeared in OpenSSL 0.9.5 and have been available since
748.Ox 2.7 .
749.Pp
750In OpenSSL 0.9.7 and
751.Ox 3.2 ,
752all
753.Sy des_
754functions were renamed to
755.Sy DES_
756to avoid clashes with older versions of libdes.
757.Sh AUTHORS
758.An Eric Young Aq Mt eay@cryptsoft.com
759.Sh CAVEATS
760Single-key DES is insecure due to its short key size.
761ECB mode is not suitable for most applications.
762.Sh BUGS
763DES_cbc_encrypt does not modify
764.Fa ivec ;
765use
766.Fn DES_ncbc_encrypt
767instead.
768.Pp
769.Fn DES_cfb_encrypt
770and
771.Fn DES_ofb_encrypt
772operates on input of 8 bits.
773What this means is that if you set numbits to 12, and length to 2, the
774first 12 bits will come from the 1st input byte and the low half of the
775second input byte.
776The second 12 bits will have the low 8 bits taken from the 3rd input
777byte and the top 4 bits taken from the 4th input byte.
778The same holds for output.
779This function has been implemented this way because most people will be
780using a multiple of 8 and because once you get into pulling input
781bytes apart things get ugly!
782.Pp
783.Fn DES_string_to_key
784is available for backward compatibility with the MIT library.
785New applications should use a cryptographic hash function.
786The same applies for
787.Fn DES_string_to_2key .
diff --git a/src/lib/libcrypto/man/DH_generate_key.3 b/src/lib/libcrypto/man/DH_generate_key.3
deleted file mode 100644
index 076b49f7a1..0000000000
--- a/src/lib/libcrypto/man/DH_generate_key.3
+++ /dev/null
@@ -1,122 +0,0 @@
1.\" $OpenBSD: DH_generate_key.3,v 1.12 2019/08/19 13:08:26 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: August 19 2019 $
52.Dt DH_GENERATE_KEY 3
53.Os
54.Sh NAME
55.Nm DH_generate_key ,
56.Nm DH_compute_key
57.Nd perform Diffie-Hellman key exchange
58.Sh SYNOPSIS
59.In openssl/dh.h
60.Ft int
61.Fo DH_generate_key
62.Fa "DH *dh"
63.Fc
64.Ft int
65.Fo DH_compute_key
66.Fa "unsigned char *key"
67.Fa "BIGNUM *pub_key"
68.Fa "DH *dh"
69.Fc
70.Sh DESCRIPTION
71.Fn DH_generate_key
72performs the first step of a Diffie-Hellman key exchange by generating
73private and public DH values.
74By calling
75.Fn DH_compute_key ,
76these are combined with the other party's public value to compute the
77shared key.
78.Pp
79.Fn DH_generate_key
80expects
81.Fa dh
82to contain the shared parameters
83.Sy dh->p
84and
85.Sy dh->g .
86It generates a random private DH value unless
87.Sy dh->priv_key
88is already set, and computes the corresponding public value
89.Sy dh->pub_key ,
90which can then be published.
91.Pp
92.Fn DH_compute_key
93computes the shared secret from the private DH value in
94.Fa dh
95and the other party's public value in
96.Fa pub_key
97and stores it in
98.Fa key .
99.Fa key
100must point to
101.Fn DH_size dh
102bytes of memory.
103.Sh RETURN VALUES
104.Fn DH_generate_key
105returns 1 on success, or 0 otherwise.
106.Pp
107.Fn DH_compute_key
108returns the size of the shared secret on success, or -1 on error.
109.Pp
110The error codes can be obtained by
111.Xr ERR_get_error 3 .
112.Sh SEE ALSO
113.Xr DH_get0_key 3 ,
114.Xr DH_new 3 ,
115.Xr DH_size 3 ,
116.Xr ECDH_compute_key 3
117.Sh HISTORY
118.Fn DH_generate_key
119and
120.Fn DH_compute_key
121first appeared in SSLeay 0.5.1 and have been available since
122.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/DH_generate_parameters.3 b/src/lib/libcrypto/man/DH_generate_parameters.3
deleted file mode 100644
index ac29521ec4..0000000000
--- a/src/lib/libcrypto/man/DH_generate_parameters.3
+++ /dev/null
@@ -1,241 +0,0 @@
1.\" $OpenBSD: DH_generate_parameters.3,v 1.14 2022/07/13 13:47:59 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" selective merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Ulf Moeller <ulf@openssl.org>
23.\" and Matt Caswell <matt@openssl.org>.
24.\" Copyright (c) 2000, 2016 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: July 13 2022 $
71.Dt DH_GENERATE_PARAMETERS 3
72.Os
73.Sh NAME
74.Nm DH_generate_parameters_ex ,
75.Nm DH_check ,
76.Nm DH_check_pub_key ,
77.Nm DH_generate_parameters
78.Nd generate and check Diffie-Hellman parameters
79.Sh SYNOPSIS
80.In openssl/dh.h
81.Ft int
82.Fo DH_generate_parameters_ex
83.Fa "DH *dh"
84.Fa "int prime_len"
85.Fa "int generator"
86.Fa "BN_GENCB *cb"
87.Fc
88.Ft int
89.Fo DH_check
90.Fa "DH *dh"
91.Fa "int *codes"
92.Fc
93.Ft int
94.Fo DH_check_pub_key
95.Fa "const DH *dh"
96.Fa "const BIGNUM *pub_key"
97.Fa "int *codes"
98.Fc
99.Pp
100Deprecated:
101.Pp
102.Ft DH *
103.Fo DH_generate_parameters
104.Fa "int prime_len"
105.Fa "int generator"
106.Fa "void (*callback)(int, int, void *)"
107.Fa "void *cb_arg"
108.Fc
109.Sh DESCRIPTION
110.Fn DH_generate_parameters_ex
111generates Diffie-Hellman parameters that can be shared among a group of
112users, and stores them in the provided
113.Vt DH
114structure.
115.Pp
116.Fa prime_len
117is the length in bits of the safe prime to be generated.
118.Fa generator
119is a small number > 1, typically 2 or 5.
120.Pp
121A callback function may be used to provide feedback about the progress
122of the key generation.
123If
124.Fa cb
125is not
126.Dv NULL ,
127it will be called as described in
128.Xr BN_generate_prime 3
129while a random prime number is generated, and when a prime has been
130found,
131.Fn BN_GENCB_call cb 3 0
132is called; see
133.Xr BN_GENCB_call 3 .
134.Pp
135.Fn DH_check
136validates Diffie-Hellman parameters.
137If no problems are found,
138.Pf * Ar codes
139is set to zero.
140Otherwise, one or more of the following bits are set:
141.Bl -tag -width Ds
142.It Dv DH_CHECK_P_NOT_PRIME
143The parameter
144.Fa dh->p
145is not prime.
146.It Dv DH_CHECK_P_NOT_SAFE_PRIME
147The parameter
148.Fa dh->p
149is not a safe prime.
150.It Dv DH_UNABLE_TO_CHECK_GENERATOR
151The generator
152.Fa dh->g
153cannot be checked for suitability: it is neither 2 nor 5.
154.It Dv DH_NOT_SUITABLE_GENERATOR
155The generator
156.Fa dh->g
157is not suitable.
158.El
159.Pp
160.Fn DH_check_pub_key
161checks whether
162.Fa pub_key
163is a valid public key when using the domain parameters contained in
164.Fa dh .
165If no problems are found,
166.Pf * Ar codes
167is set to zero.
168Otherwise, one or more of the following bits are set:
169.Bl -tag -width Ds
170.It Dv DH_CHECK_PUBKEY_TOO_SMALL
171.Fa pub_key
172is less than or equal to 1.
173.It Dv DH_CHECK_PUBKEY_TOO_LARGE
174.Fa pub_key
175is greater than or equal to
176.Fa dh->p No \- 1 .
177.It DH_CHECK_PUBKEY_INVALID
178.Fa dh->q
179is set but
180.Fa pub_key
181to the power of
182.Fa dh->q
183is not 1 modulo
184.Fa dh->p .
185.El
186.Sh RETURN VALUES
187.Fn DH_generate_parameters_ex ,
188.Fn DH_check ,
189and
190.Fn DH_check_pub_key
191return 1 if the check could be performed or 0 otherwise.
192.Pp
193.Fn DH_generate_parameters
194(deprecated) returns a pointer to the
195.Vt DH
196structure, or
197.Dv NULL
198if the parameter generation fails.
199.Pp
200The error codes can be obtained by
201.Xr ERR_get_error 3 .
202.Sh SEE ALSO
203.Xr DH_get0_pqg 3 ,
204.Xr DH_new 3
205.Sh HISTORY
206.Fn DH_check
207and
208.Fn DH_generate_parameters
209first appeared in SSLeay 0.5.1 and have been available since
210.Ox 2.4 .
211.Pp
212The
213.Fa cb_arg
214argument to
215.Fn DH_generate_parameters
216was added in SSLeay 0.9.0.
217.Pp
218.Fn DH_check_pub_key
219first appeared in OpenSSL 0.9.8a and has been available since
220.Ox 4.0 .
221.Pp
222.Fn DH_generate_parameters_ex
223first appeared in OpenSSL 0.9.8 and has been available since
224.Ox 4.5 .
225.Sh CAVEATS
226.Fn DH_generate_parameters_ex
227and
228.Fn DH_generate_parameters
229may run for several hours before finding a suitable prime.
230.Pp
231The parameters generated by
232.Fn DH_generate_parameters_ex
233and
234.Fn DH_generate_parameters
235are not to be used in signature schemes.
236.Sh BUGS
237If
238.Fa generator
239is not 2 or 5,
240.Fa dh->g Ns = Ns Fa generator
241is not a usable generator.
diff --git a/src/lib/libcrypto/man/DH_get0_pqg.3 b/src/lib/libcrypto/man/DH_get0_pqg.3
deleted file mode 100644
index eb012980f9..0000000000
--- a/src/lib/libcrypto/man/DH_get0_pqg.3
+++ /dev/null
@@ -1,342 +0,0 @@
1.\" $OpenBSD: DH_get0_pqg.3,v 1.8 2024/07/21 08:36:43 tb Exp $
2.\" selective merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>.
5.\" Copyright (c) 2016, 2018 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: July 21 2024 $
52.Dt DH_GET0_PQG 3
53.Os
54.Sh NAME
55.Nm DH_get0_pqg ,
56.Nm DH_get0_p ,
57.Nm DH_get0_q ,
58.Nm DH_get0_g ,
59.Nm DH_set0_pqg ,
60.Nm DH_get0_key ,
61.Nm DH_get0_pub_key ,
62.Nm DH_get0_priv_key ,
63.Nm DH_set0_key ,
64.Nm DH_clear_flags ,
65.Nm DH_test_flags ,
66.Nm DH_set_flags ,
67.Nm DH_get0_engine ,
68.Nm DH_set_length
69.Nd get data from and set data in a DH object
70.Sh SYNOPSIS
71.In openssl/dh.h
72.Ft void
73.Fo DH_get0_pqg
74.Fa "const DH *dh"
75.Fa "const BIGNUM **p"
76.Fa "const BIGNUM **q"
77.Fa "const BIGNUM **g"
78.Fc
79.Ft "const BIGNUM *"
80.Fo DH_get0_p
81.Fa "const DH *dh"
82.Fc
83.Ft "const BIGNUM *"
84.Fo DH_get0_q
85.Fa "const DH *dh"
86.Fc
87.Ft "const BIGNUM *"
88.Fo DH_get0_g
89.Fa "const DH *dh"
90.Fc
91.Ft int
92.Fo DH_set0_pqg
93.Fa "DH *dh"
94.Fa "BIGNUM *p"
95.Fa "BIGNUM *q"
96.Fa "BIGNUM *g"
97.Fc
98.Ft void
99.Fo DH_get0_key
100.Fa "const DH *dh"
101.Fa "const BIGNUM **pub_key"
102.Fa "const BIGNUM **priv_key"
103.Fc
104.Ft "const BIGNUM *"
105.Fo DH_get0_pub_key
106.Fa "const DH *dh"
107.Fc
108.Ft "const BIGNUM *"
109.Fo DH_get0_priv_key
110.Fa "const DH *dh"
111.Fc
112.Ft int
113.Fo DH_set0_key
114.Fa "DH *dh"
115.Fa "BIGNUM *pub_key"
116.Fa "BIGNUM *priv_key"
117.Fc
118.Ft void
119.Fo DH_clear_flags
120.Fa "DH *dh"
121.Fa "int flags"
122.Fc
123.Ft int
124.Fo DH_test_flags
125.Fa "const DH *dh"
126.Fa "int flags"
127.Fc
128.Ft void
129.Fo DH_set_flags
130.Fa "DH *dh"
131.Fa "int flags"
132.Fc
133.Ft ENGINE *
134.Fo DH_get0_engine
135.Fa "DH *d"
136.Fc
137.Ft int
138.Fo DH_set_length
139.Fa "DH *dh"
140.Fa "long length"
141.Fc
142.Sh DESCRIPTION
143A
144.Vt DH
145object contains the parameters
146.Fa p ,
147.Fa g ,
148and optionally
149.Fa q .
150It also contains a public key
151.Fa pub_key
152and an optional private key
153.Fa priv_key .
154.Pp
155The
156.Fa p ,
157.Fa q ,
158and
159.Fa g
160parameters can be obtained by calling
161.Fn DH_get0_pqg .
162If the parameters have not yet been set, then
163.Pf * Fa p ,
164.Pf * Fa q ,
165and
166.Pf * Fa g
167are set to
168.Dv NULL .
169Otherwise, they are set to pointers to the internal representations
170of the values that should not be freed by the application.
171Any of the out parameters
172.Fa p ,
173.Fa q ,
174and
175.Fa g
176can be
177.Dv NULL ,
178in which case no value is returned for that parameter.
179.Pp
180The
181.Fa p ,
182.Fa q ,
183and
184.Fa g
185values can be set by calling
186.Fn DH_set0_pqg .
187Calling this function transfers the memory management of the values to
188.Fa dh ,
189and therefore they should not be freed by the caller.
190The
191.Fa q
192argument may be
193.Dv NULL .
194.Pp
195The
196.Fn DH_get0_key
197function stores pointers to the internal representations
198of the public key in
199.Pf * Fa pub_key
200and to the private key in
201.Pf * Fa priv_key .
202Either may be
203.Dv NULL
204if it has not yet been set.
205If the private key has been set, then the public key must be.
206Any of the out parameters
207.Fa pub_key
208and
209.Fa priv_key
210can be
211.Dv NULL ,
212in which case no value is returned for that parameter.
213.Pp
214The public and private key values can be set using
215.Fn DH_set0_key .
216Either parameter may be
217.Dv NULL ,
218which means the corresponding
219.Vt DH
220field is left untouched.
221This function transfers the memory management of the key values to
222.Fa dh ,
223and therefore they should not be freed by the caller.
224.Pp
225Values retrieved with
226.Fn DH_get0_pqg
227and
228.Fn DH_get0_key
229are owned by the
230.Vt DH
231object and may therefore not be passed to
232.Fn DH_set0_pqg
233or
234.Fn DH_set0_key .
235If needed, duplicate the received values using
236.Xr BN_dup 3
237and pass the duplicates.
238.Pp
239Any of the values
240.Fa p ,
241.Fa q ,
242.Fa g ,
243.Fa pub_key ,
244and
245.Fa priv_key
246can also be retrieved separately by the corresponding functions
247.Fn DH_get0_p ,
248.Fn DH_get0_q ,
249.Fn DH_get0_g ,
250.Fn DH_get0_pub_key ,
251and
252.Fn DH_get0_priv_key ,
253respectively.
254The pointers are owned by the
255.Vt DH
256object.
257.Pp
258.Fn DH_clear_flags
259clears the specified
260.Fa flags
261in
262.Fa dh .
263.Fn DH_test_flags
264tests the
265.Fa flags
266in
267.Fa dh .
268.Fn DH_set_flags
269sets the
270.Fa flags
271in
272.Fa dh ;
273any flags already set remain set.
274For all three functions, multiple flags can be passed in one call,
275OR'ed together bitwise.
276.Pp
277.Fn DH_set_length
278sets the optional length attribute of
279.Fa dh ,
280indicating the length of the secret exponent (private key) in bits.
281If the length attribute is non-zero, it is used, otherwise it is ignored.
282.Sh RETURN VALUES
283+.Fn DH_get0_p ,
284+.Fn DH_get0_q ,
285+.Fn DH_get0_g ,
286+.Fn DH_get0_pub_key ,
287+and
288+.Fn DH_get0_priv_key ,
289+return a pointer owned by the
290+.Vt DH
291+object if the corresponding value has been set,
292+otherwise they return
293+.Dv NULL .
294.Fn DH_set0_pqg ,
295.Fn DH_set0_key ,
296and
297.Fn DH_set_length
298return 1 on success or 0 on failure.
299.Pp
300.Fn DH_test_flags
301return those of the given
302.Fa flags
303currently set in
304.Fa dh
305or 0 if none of the given
306.Fa flags
307are set.
308.Pp
309.Fn DH_get0_engine
310always returns
311.Dv NULL .
312.Sh SEE ALSO
313.Xr DH_generate_key 3 ,
314.Xr DH_generate_parameters 3 ,
315.Xr DH_new 3 ,
316.Xr DH_security_bits 3 ,
317.Xr DH_size 3 ,
318.Xr DHparams_print 3
319.Sh HISTORY
320.Fn DH_get0_pqg ,
321.Fn DH_set0_pqg ,
322.Fn DH_get0_key ,
323.Fn DH_set0_key ,
324.Fn DH_clear_flags ,
325.Fn DH_test_flags ,
326.Fn DH_set_flags ,
327.Fn DH_get0_engine ,
328and
329.Fn DH_set_length
330first appeared in OpenSSL 1.1.0
331and have been available since
332.Ox 6.3 .
333.Pp
334.Fn DH_get0_p ,
335.Fn DH_get0_q ,
336.Fn DH_get0_g ,
337.Fn DH_get0_pub_key ,
338and
339.Fn DH_get0_priv_key
340first appeared in OpenSSL 1.1.1
341and have been available since
342.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/DH_get_ex_new_index.3 b/src/lib/libcrypto/man/DH_get_ex_new_index.3
deleted file mode 100644
index 81a0aff8ec..0000000000
--- a/src/lib/libcrypto/man/DH_get_ex_new_index.3
+++ /dev/null
@@ -1,99 +0,0 @@
1.\" $OpenBSD: DH_get_ex_new_index.3,v 1.5 2018/03/23 23:18:17 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 23 2018 $
52.Dt DH_GET_EX_NEW_INDEX 3
53.Os
54.Sh NAME
55.Nm DH_get_ex_new_index ,
56.Nm DH_set_ex_data ,
57.Nm DH_get_ex_data
58.Nd add application specific data to DH structures
59.Sh SYNOPSIS
60.In openssl/dh.h
61.Ft int
62.Fo DH_get_ex_new_index
63.Fa "long argl"
64.Fa "void *argp"
65.Fa "CRYPTO_EX_new *new_func"
66.Fa "CRYPTO_EX_dup *dup_func"
67.Fa "CRYPTO_EX_free *free_func"
68.Fc
69.Ft int
70.Fo DH_set_ex_data
71.Fa "DH *d"
72.Fa "int idx"
73.Fa "void *arg"
74.Fc
75.Ft char *
76.Fo DH_get_ex_data
77.Fa "DH *d"
78.Fa "int idx"
79.Fc
80.Sh DESCRIPTION
81These functions handle application specific data in
82.Vt DH
83structures.
84Their usage is identical to that of
85.Xr RSA_get_ex_new_index 3 ,
86.Xr RSA_set_ex_data 3 ,
87and
88.Xr RSA_get_ex_data 3 .
89.Sh SEE ALSO
90.Xr DH_new 3 ,
91.Xr RSA_get_ex_new_index 3
92.Sh HISTORY
93.Fn DH_get_ex_new_index ,
94.Fn DH_set_ex_data ,
95and
96.Fn DH_get_ex_data
97first appeared in OpenSSL 0.9.5
98and have been available since
99.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/DH_new.3 b/src/lib/libcrypto/man/DH_new.3
deleted file mode 100644
index 4993456897..0000000000
--- a/src/lib/libcrypto/man/DH_new.3
+++ /dev/null
@@ -1,133 +0,0 @@
1.\" $OpenBSD: DH_new.3,v 1.12 2022/07/13 21:51:35 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: July 13 2022 $
52.Dt DH_NEW 3
53.Os
54.Sh NAME
55.Nm DH_new ,
56.Nm DH_up_ref ,
57.Nm DH_free
58.Nd allocate and free DH objects
59.Sh SYNOPSIS
60.In openssl/dh.h
61.Ft DH*
62.Fn DH_new void
63.Ft int
64.Fo DH_up_ref
65.Fa "DH *dh"
66.Fc
67.Ft void
68.Fo DH_free
69.Fa "DH *dh"
70.Fc
71.Sh DESCRIPTION
72The DH functions implement the Diffie-Hellman key agreement protocol.
73.Pp
74.Fn DH_new
75allocates and initializes a
76.Vt DH
77structure, setting the reference count to 1.
78It is equivalent to
79.Xr DH_new_method 3
80with a
81.Dv NULL
82argument.
83.Pp
84.Fn DH_up_ref
85increments the reference count by 1.
86.Pp
87.Fn DH_free
88decrements the reference count by 1.
89If it reaches 0, it frees the
90.Vt DH
91structure and its components.
92The values are erased before the memory is returned to the system.
93If
94.Fa dh
95is a
96.Dv NULL
97pointer, no action occurs.
98.Sh RETURN VALUES
99If the allocation fails,
100.Fn DH_new
101returns
102.Dv NULL
103and sets an error code that can be obtained by
104.Xr ERR_get_error 3 .
105Otherwise it returns a pointer to the newly allocated structure.
106.Pp
107.Fn DH_up_ref
108returns 1 for success or 0 for failure.
109.Sh SEE ALSO
110.Xr BN_new 3 ,
111.Xr crypto 3 ,
112.Xr d2i_DHparams 3 ,
113.Xr DH_generate_key 3 ,
114.Xr DH_generate_parameters 3 ,
115.Xr DH_get0_pqg 3 ,
116.Xr DH_get_ex_new_index 3 ,
117.Xr DH_security_bits 3 ,
118.Xr DH_set_method 3 ,
119.Xr DH_size 3 ,
120.Xr DHparams_print 3 ,
121.Xr DSA_dup_DH 3 ,
122.Xr EVP_PKEY_CTX_set_dh_paramgen_prime_len 3 ,
123.Xr EVP_PKEY_set1_DH 3
124.Sh HISTORY
125.Fn DH_new
126and
127.Fn DH_free
128first appeared in SSLeay 0.5.1 and have been available since
129.Ox 2.4 .
130.Pp
131.Fn DH_up_ref
132first appeared in OpenSSL 0.9.7 and has been available since
133.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/DH_set_method.3 b/src/lib/libcrypto/man/DH_set_method.3
deleted file mode 100644
index 70cf367c9d..0000000000
--- a/src/lib/libcrypto/man/DH_set_method.3
+++ /dev/null
@@ -1,195 +0,0 @@
1.\" $OpenBSD: DH_set_method.3,v 1.9 2023/11/19 10:34:26 tb Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2002, 2007 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 19 2023 $
52.Dt DH_SET_METHOD 3
53.Os
54.Sh NAME
55.Nm DH_set_default_method ,
56.Nm DH_get_default_method ,
57.Nm DH_set_method ,
58.Nm DH_new_method ,
59.Nm DH_OpenSSL
60.Nd select DH method
61.Sh SYNOPSIS
62.In openssl/dh.h
63.Ft void
64.Fo DH_set_default_method
65.Fa "const DH_METHOD *meth"
66.Fc
67.Ft const DH_METHOD *
68.Fo DH_get_default_method
69.Fa void
70.Fc
71.Ft int
72.Fo DH_set_method
73.Fa "DH *dh"
74.Fa "const DH_METHOD *meth"
75.Fc
76.Ft DH *
77.Fo DH_new_method
78.Fa "ENGINE *engine"
79.Fc
80.Ft const DH_METHOD *
81.Fo DH_OpenSSL
82.Fa void
83.Fc
84.Sh DESCRIPTION
85A
86.Vt DH_METHOD
87object contains pointers to the functions
88used for Diffie-Hellman operations.
89By default, the internal implementation returned by
90.Fn DH_OpenSSL
91is used.
92By selecting another method, alternative implementations
93such as hardware accelerators may be used.
94.Pp
95.Fn DH_set_default_method
96selects
97.Fa meth
98as the default method for all
99.Vt DH
100structures created later.
101.Pp
102.Fn DH_get_default_method
103returns a pointer to the current default method.
104.Pp
105.Fn DH_set_method
106selects
107.Fa meth
108to perform all operations using the key
109.Fa dh .
110This replaces the
111.Vt DH_METHOD
112used by the
113.Fa dh
114key.
115It is possible to have
116.Vt DH
117keys that only work with certain
118.Vt DH_METHOD
119implementations,
120and in such cases attempting to change the
121.Vt DH_METHOD
122for the key can have unexpected results.
123.Pp
124.Fn DH_new_method
125allocates and initializes a
126.Vt DH
127structure.
128The
129.Fa engine
130argument is ignored and
131the default method controlled by
132.Fn DH_set_default_method
133is used.
134.Pp
135The
136.Vt DH_METHOD
137structure is defined as follows:
138.Bd -literal
139typedef struct dh_meth_st
140{
141 /* name of the implementation */
142 const char *name;
143
144 /* generate private and public DH values for key agreement */
145 int (*generate_key)(DH *dh);
146
147 /* compute shared secret */
148 int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh);
149
150 /* compute r = a ^ p mod m (May be NULL for some implementations) */
151 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
152 const BIGNUM *m, BN_CTX *ctx,
153 BN_MONT_CTX *m_ctx);
154
155 /* called at DH_new */
156 int (*init)(DH *dh);
157
158 /* called at DH_free */
159 int (*finish)(DH *dh);
160
161 int flags;
162
163 char *app_data; /* ?? */
164
165} DH_METHOD;
166.Ed
167.Sh RETURN VALUES
168.Fn DH_OpenSSL
169and
170.Fn DH_get_default_method
171return pointers to the respective
172.Vt DH_METHOD .
173.Pp
174.Fn DH_set_method
175returns 1 on success or 0 on failure.
176Currently, it cannot fail.
177.Pp
178.Fn DH_new_method
179returns
180.Dv NULL
181and sets an error code that can be obtained by
182.Xr ERR_get_error 3
183if the allocation fails.
184Otherwise it returns a pointer to the newly allocated structure.
185.Sh SEE ALSO
186.Xr DH_new 3
187.Sh HISTORY
188.Fn DH_set_default_method ,
189.Fn DH_get_default_method ,
190.Fn DH_set_method ,
191.Fn DH_new_method
192and
193.Fn DH_OpenSSL
194first appeared in OpenSSL 0.9.5 and have been available since
195.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/DH_size.3 b/src/lib/libcrypto/man/DH_size.3
deleted file mode 100644
index 4e6dbc0cba..0000000000
--- a/src/lib/libcrypto/man/DH_size.3
+++ /dev/null
@@ -1,97 +0,0 @@
1.\" $OpenBSD: DH_size.3,v 1.10 2022/07/13 21:51:35 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>
5.\" and Kurt Roeckx <kurt@roeckx.be>.
6.\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: July 13 2022 $
53.Dt DH_SIZE 3
54.Os
55.Sh NAME
56.Nm DH_size ,
57.Nm DH_bits
58.Nd get Diffie-Hellman prime size
59.Sh SYNOPSIS
60.In openssl/dh.h
61.Ft int
62.Fo DH_size
63.Fa "const DH *dh"
64.Fc
65.Ft int
66.Fo DH_bits
67.Fa "const DH *dh"
68.Fc
69.Sh DESCRIPTION
70.Fn DH_size
71returns the Diffie-Hellman prime size in bytes.
72It can be used to determine how much memory must be allocated for the
73shared secret computed by
74.Xr DH_compute_key 3 .
75.Pp
76.Fn DH_bits
77returns the number of significant bits in the key.
78.Pp
79.Fa dh
80and
81.Fa dh->p
82must not be
83.Dv NULL .
84.Sh SEE ALSO
85.Xr BN_num_bytes 3 ,
86.Xr DH_generate_key 3 ,
87.Xr DH_get0_key 3 ,
88.Xr DH_new 3 ,
89.Xr DH_security_bits 3
90.Sh HISTORY
91.Fn DH_size
92first appeared in SSLeay 0.5.1 and has been available since
93.Ox 2.4 .
94.Pp
95.Fn DH_bits
96first appeared in OpenSSL 1.1.0 and has been available since
97.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/DIST_POINT_new.3 b/src/lib/libcrypto/man/DIST_POINT_new.3
deleted file mode 100644
index 6a5cc40468..0000000000
--- a/src/lib/libcrypto/man/DIST_POINT_new.3
+++ /dev/null
@@ -1,154 +0,0 @@
1.\" $OpenBSD: DIST_POINT_new.3,v 1.5 2019/06/06 01:06:58 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 6 2019 $
18.Dt DIST_POINT_NEW 3
19.Os
20.Sh NAME
21.Nm DIST_POINT_new ,
22.Nm DIST_POINT_free ,
23.Nm CRL_DIST_POINTS_new ,
24.Nm CRL_DIST_POINTS_free ,
25.Nm DIST_POINT_NAME_new ,
26.Nm DIST_POINT_NAME_free ,
27.Nm ISSUING_DIST_POINT_new ,
28.Nm ISSUING_DIST_POINT_free
29.Nd X.509 CRL distribution point extensions
30.Sh SYNOPSIS
31.In openssl/x509v3.h
32.Ft DIST_POINT *
33.Fn DIST_POINT_new void
34.Ft void
35.Fn DIST_POINT_free "DIST_POINT *dp"
36.Ft CRL_DIST_POINTS *
37.Fn CRL_DIST_POINTS_new void
38.Ft void
39.Fn CRL_DIST_POINTS_free "CRL_DIST_POINTS *dps"
40.Ft DIST_POINT_NAME *
41.Fn DIST_POINT_NAME_new void
42.Ft void
43.Fn DIST_POINT_NAME_free "DIST_POINT_NAME *name"
44.Ft ISSUING_DIST_POINT *
45.Fn ISSUING_DIST_POINT_new void
46.Ft void
47.Fn ISSUING_DIST_POINT_free "ISSUING_DIST_POINT *dp"
48.Sh DESCRIPTION
49Using the CRL distribution point extension, a certificate can specify
50where to obtain certificate revocation lists that might later revoke it.
51.Pp
52.Fn DIST_POINT_new
53allocates and initializes an empty
54.Vt DIST_POINT
55object, representing an ASN.1
56.Vt DistributionPoint
57structure defined in RFC 5280 section 4.2.1.13.
58It can hold issuer names, distribution point names, and reason flags.
59.Fn DIST_POINT_free
60frees
61.Fa dp .
62.Pp
63.Fn CRL_DIST_POINTS_new
64allocates and initializes an empty
65.Vt CRL_DIST_POINTS
66object, which is a
67.Vt STACK_OF(DIST_POINT)
68and represents the ASN.1
69.Vt CRLDistributionPoints
70structure defined in RFC 5280 section 4.2.1.13.
71It can be used as an extension in
72.Vt X509
73and in
74.Vt X509_CRL
75objects.
76.Fn CRL_DIST_POINTS_free
77frees
78.Fa dps .
79.Pp
80.Fn DIST_POINT_NAME_new
81allocates and initializes an empty
82.Vt DIST_POINT_NAME
83object, representing an ASN.1
84.Vt DistributionPointName
85structure defined in RFC 5280 section 4.2.1.13.
86It is used by the
87.Vt DIST_POINT
88and
89.Vt ISSUING_DIST_POINT
90objects and can hold multiple names, each representing a different
91way to obtain the same CRL.
92.Fn DIST_POINT_NAME_free
93frees
94.Fa name .
95.Pp
96.Fn ISSUING_DIST_POINT_new
97allocates and initializes an empty
98.Vt ISSUING_DIST_POINT
99object, representing an ASN.1
100.Vt IssuingDistributionPoint
101structure defined in RFC 5280 section 5.2.5.
102Using this extension, a CRL can specify which distribution point
103it was issued from and which kinds of certificates and revocation
104reasons it covers.
105.Fn ISSUING_DIST_POINT_free
106frees
107.Fa dp .
108.Sh RETURN VALUES
109.Fn DIST_POINT_new ,
110.Fn CRL_DIST_POINTS_new ,
111.Fn DIST_POINT_NAME_new ,
112and
113.Fn ISSUING_DIST_POINT_new
114return the new
115.Vt DIST_POINT ,
116.Vt CRL_DIST_POINTS ,
117.Vt DIST_POINT_NAME ,
118or
119.Vt ISSUING_DIST_POINT
120object, respectively, or
121.Dv NULL
122if an error occurs.
123.Sh SEE ALSO
124.Xr d2i_DIST_POINT 3 ,
125.Xr GENERAL_NAMES_new 3 ,
126.Xr X509_CRL_new 3 ,
127.Xr X509_EXTENSION_new 3 ,
128.Xr X509_NAME_new 3 ,
129.Xr X509_new 3
130.Sh STANDARDS
131RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
132Certificate Revocation List (CRL) Profile:
133.Bl -dash -compact
134.It
135section 4.2.1.13: CRL Distribution Points
136.It
137section 5.2.5: Issuing Distribution Point
138.El
139.Sh HISTORY
140.Fn DIST_POINT_new ,
141.Fn DIST_POINT_free ,
142.Fn CRL_DIST_POINTS_new ,
143.Fn CRL_DIST_POINTS_free ,
144.Fn DIST_POINT_NAME_new ,
145and
146.Fn DIST_POINT_NAME_free
147first appeared in OpenSSL 0.9.3 and have been available since
148.Ox 2.6 .
149.Pp
150.Fn ISSUING_DIST_POINT_new
151and
152.Fn ISSUING_DIST_POINT_free
153first appeared in OpenSSL 1.0.0 and have been available since
154.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/DSA_SIG_new.3 b/src/lib/libcrypto/man/DSA_SIG_new.3
deleted file mode 100644
index 160b453939..0000000000
--- a/src/lib/libcrypto/man/DSA_SIG_new.3
+++ /dev/null
@@ -1,141 +0,0 @@
1.\" $OpenBSD: DSA_SIG_new.3,v 1.8 2019/06/10 14:58:48 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>,
5.\" Dr. Stephen Henson <steve@openssl.org>, and
6.\" TJ Saunders <tj@castaglia.org>.
7.\" Copyright (c) 2000, 2016 The OpenSSL Project. All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: June 10 2019 $
54.Dt DSA_SIG_NEW 3
55.Os
56.Sh NAME
57.Nm DSA_SIG_new ,
58.Nm DSA_SIG_free ,
59.Nm DSA_SIG_get0 ,
60.Nm DSA_SIG_set0
61.Nd manipulate DSA signature objects
62.Sh SYNOPSIS
63.In openssl/dsa.h
64.Ft DSA_SIG *
65.Fn DSA_SIG_new void
66.Ft void
67.Fo DSA_SIG_free
68.Fa "DSA_SIG *sig"
69.Fc
70.Ft void
71.Fo DSA_SIG_get0
72.Fa "const DSA_SIG *sig"
73.Fa "const BIGNUM **r"
74.Fa "const BIGNUM **s"
75.Fc
76.Ft int
77.Fo DSA_SIG_set0
78.Fa "DSA_SIG *sig"
79.Fa "BIGNUM *r"
80.Fa "BIGNUM *s"
81.Fc
82.Sh DESCRIPTION
83.Fn DSA_SIG_new
84allocates an empty
85.Vt DSA_SIG
86structure.
87.Pp
88.Fn DSA_SIG_free
89frees the
90.Vt DSA_SIG
91structure and its components.
92The values are erased before the memory is returned to the system.
93If
94.Fa sig
95is a
96.Dv NULL
97pointer, no action occurs.
98.Pp
99.Fn DSA_SIG_get0
100retrieves internal pointers to the
101.Fa r
102and
103.Fa s
104values contained in
105.Fa sig .
106.Pp
107The
108.Fa r
109and
110.Fa s
111values can be set by calling
112.Fn DSA_SIG_set0 .
113Calling this function transfers the memory management of the values to
114.Fa sig ,
115and therefore they should not be freed by the caller.
116.Sh RETURN VALUES
117If the allocation fails,
118.Fn DSA_SIG_new
119returns
120.Dv NULL
121and sets an error code that can be obtained by
122.Xr ERR_get_error 3 .
123Otherwise it returns a pointer to the newly allocated structure.
124.Pp
125.Fn DSA_SIG_set0
126returns 1 on success or 0 on failure.
127.Sh SEE ALSO
128.Xr DSA_do_sign 3 ,
129.Xr DSA_new 3
130.Sh HISTORY
131.Fn DSA_SIG_new
132and
133.Fn DSA_SIG_free
134first appeared in OpenSSL 0.9.3 and have been available since
135.Ox 2.6 .
136.Pp
137.Fn DSA_SIG_get0
138and
139.Fn DSA_SIG_set0
140first appeared in OpenSSL 1.1.0 and have been available since
141.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/DSA_do_sign.3 b/src/lib/libcrypto/man/DSA_do_sign.3
deleted file mode 100644
index 4602bed872..0000000000
--- a/src/lib/libcrypto/man/DSA_do_sign.3
+++ /dev/null
@@ -1,119 +0,0 @@
1.\" $OpenBSD: DSA_do_sign.3,v 1.10 2019/06/10 14:58:48 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 10 2019 $
52.Dt DSA_DO_SIGN 3
53.Os
54.Sh NAME
55.Nm DSA_do_sign ,
56.Nm DSA_do_verify
57.Nd raw DSA signature operations
58.Sh SYNOPSIS
59.In openssl/dsa.h
60.Ft DSA_SIG *
61.Fo DSA_do_sign
62.Fa "const unsigned char *dgst"
63.Fa "int dlen"
64.Fa "DSA *dsa"
65.Fc
66.Ft int
67.Fo DSA_do_verify
68.Fa "const unsigned char *dgst"
69.Fa "int dgst_len"
70.Fa "DSA_SIG *sig"
71.Fa "DSA *dsa"
72.Fc
73.Sh DESCRIPTION
74.Fn DSA_do_sign
75computes a digital signature on the
76.Fa dlen
77byte message digest
78.Fa dgst
79using the private key
80.Fa dsa
81and returns it in a newly allocated
82.Vt DSA_SIG
83structure.
84.Pp
85.Xr DSA_sign_setup 3
86may be used to precompute part of the signing operation in case
87signature generation is time-critical.
88.Pp
89.Fn DSA_do_verify
90verifies that the signature
91.Fa sig
92matches a given message digest
93.Fa dgst
94of size
95.Fa dgst_len .
96.Fa dsa
97is the signer's public key.
98.Sh RETURN VALUES
99.Fn DSA_do_sign
100returns the signature or
101.Dv NULL
102on error.
103.Fn DSA_do_verify
104returns 1 for a valid signature, 0 for an incorrect signature,
105and -1 on error.
106The error codes can be obtained by
107.Xr ERR_get_error 3 .
108.Sh SEE ALSO
109.Xr DSA_get0_key 3 ,
110.Xr DSA_meth_set_sign 3 ,
111.Xr DSA_new 3 ,
112.Xr DSA_SIG_new 3 ,
113.Xr DSA_sign 3
114.Sh HISTORY
115.Fn DSA_do_sign
116and
117.Fn DSA_do_verify
118first appeared in OpenSSL 0.9.3 and have been available since
119.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/DSA_dup_DH.3 b/src/lib/libcrypto/man/DSA_dup_DH.3
deleted file mode 100644
index d6163fd3c3..0000000000
--- a/src/lib/libcrypto/man/DSA_dup_DH.3
+++ /dev/null
@@ -1,88 +0,0 @@
1.\" $OpenBSD: DSA_dup_DH.3,v 1.9 2023/08/12 08:26:38 tb Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2002 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: August 12 2023 $
52.Dt DSA_DUP_DH 3
53.Os
54.Sh NAME
55.Nm DSA_dup_DH
56.Nd create a DH structure out of DSA structure
57.Sh SYNOPSIS
58.In openssl/dsa.h
59.Ft DH *
60.Fo DSA_dup_DH
61.Fa "const DSA *r"
62.Fc
63.Sh DESCRIPTION
64.Fn DSA_dup_DH
65duplicates
66.Vt DSA
67parameters/keys as
68.Vt DH
69parameters/keys.
70.Sh RETURN VALUES
71.Fn DSA_dup_DH
72returns the new
73.Vt DH
74structure or
75.Dv NULL
76on error.
77The error codes can be obtained by
78.Xr ERR_get_error 3 .
79.Sh SEE ALSO
80.Xr DH_new 3 ,
81.Xr DSA_get0_pqg 3 ,
82.Xr DSA_new 3
83.Sh HISTORY
84.Fn DSA_dup_DH
85first appeared in OpenSSL 0.9.4 and has been available since
86.Ox 2.6 .
87.Sh CAVEATS
88Be careful to avoid small subgroup attacks when using this.
diff --git a/src/lib/libcrypto/man/DSA_generate_key.3 b/src/lib/libcrypto/man/DSA_generate_key.3
deleted file mode 100644
index 37d8ec1c0f..0000000000
--- a/src/lib/libcrypto/man/DSA_generate_key.3
+++ /dev/null
@@ -1,84 +0,0 @@
1.\" $OpenBSD: DSA_generate_key.3,v 1.11 2023/12/29 19:12:47 tb Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 29 2023 $
52.Dt DSA_GENERATE_KEY 3
53.Os
54.Sh NAME
55.Nm DSA_generate_key
56.Nd generate DSA key pair
57.Sh SYNOPSIS
58.In openssl/dsa.h
59.Ft int
60.Fo DSA_generate_key
61.Fa "DSA *a"
62.Fc
63.Sh DESCRIPTION
64.Fn DSA_generate_key
65expects
66.Fa a
67to contain DSA parameters.
68It generates a new key pair and stores it in
69.Fa a->pub_key
70and
71.Fa a->priv_key .
72.Sh RETURN VALUES
73.Fn DSA_generate_key
74returns 1 on success or 0 otherwise.
75The error codes can be obtained by
76.Xr ERR_get_error 3 .
77.Sh SEE ALSO
78.Xr DSA_generate_parameters_ex 3 ,
79.Xr DSA_get0_key 3 ,
80.Xr DSA_new 3
81.Sh HISTORY
82.Fn DSA_generate_key
83first appeared in SSLeay 0.6.0 and has been available since
84.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/DSA_generate_parameters_ex.3 b/src/lib/libcrypto/man/DSA_generate_parameters_ex.3
deleted file mode 100644
index a318bf8298..0000000000
--- a/src/lib/libcrypto/man/DSA_generate_parameters_ex.3
+++ /dev/null
@@ -1,174 +0,0 @@
1.\" $OpenBSD: DSA_generate_parameters_ex.3,v 1.1 2023/12/29 19:15:15 tb Exp $
2.\" OpenSSL 9b86974e Aug 7 22:14:47 2015 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>,
5.\" Bodo Moeller <bodo@openssl.org>, and Matt Caswell <matt@openssl.org>.
6.\" Copyright (c) 2000, 2013 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 29 2023 $
53.Dt DSA_GENERATE_PARAMETERS_EX 3
54.Os
55.Sh NAME
56.\" .Nm DSA_generate_parameters is intentionally undocumented
57.\" because it will be removed in the next major bump
58.Nm DSA_generate_parameters_ex
59.Nd generate DSA parameters
60.Sh SYNOPSIS
61.In openssl/dsa.h
62.Ft int
63.Fo DSA_generate_parameters_ex
64.Fa "DSA *dsa"
65.Fa "int bits"
66.Fa "const unsigned char *seed"
67.Fa "int seed_len"
68.Fa "int *counter_ret"
69.Fa "unsigned long *h_ret"
70.Fa "BN_GENCB *cb"
71.Fc
72.Sh DESCRIPTION
73.Fn DSA_generate_parameters_ex
74generates primes p and q and a generator g for use in the DSA and stores
75the result in
76.Fa dsa .
77.Pp
78.Fa bits
79is the length of the prime to be generated; the DSS allows a maximum of
801024 bits.
81.Pp
82If
83.Fa seed
84is
85.Dv NULL
86or
87.Fa seed_len
88< 20, the primes will be generated at random.
89Otherwise, the seed is used to generate them.
90If the given seed does not yield a prime q, a new random seed is chosen
91and placed at
92.Fa seed .
93.Pp
94.Fn DSA_generate_parameters_ex
95places the iteration count in
96.Pf * Fa counter_ret
97and a counter used for finding a generator in
98.Pf * Fa h_ret ,
99unless these are
100.Dv NULL .
101.Pp
102A callback function may be used to provide feedback about the progress
103of the key generation.
104If
105.Fa cb
106is not
107.Dv NULL ,
108it will be called as shown below.
109For information on the
110.Vt BN_GENCB
111structure, refer to
112.Xr BN_GENCB_call 3 .
113.Bl -bullet
114.It
115When a candidate for q is generated,
116.Fn BN_GENCB_call cb 0 m++
117is called
118.Pf ( Fa m
119is 0 for the first candidate).
120.It
121When a candidate for q has passed a test by trial division,
122.Fn BN_GENCB_call cb 1 -1
123is called.
124While a candidate for q is tested by Miller-Rabin primality tests,
125.Fn BN_GENCB_call cb 1 i
126is called in the outer loop (once for each witness that confirms that
127the candidate may be prime);
128.Fa i
129is the loop counter (starting at 0).
130.It
131When a prime q has been found,
132.Fn BN_GENCB_call cb 2 0
133and
134.Fn BN_GENCB_call cb 3 0
135are called.
136.It
137Before a candidate for p (other than the first) is generated and tested,
138.Fn BN_GENCB_call cb 0 counter
139is called.
140.It
141When a candidate for p has passed the test by trial division,
142.Fn BN_GENCB_call cb 1 -1
143is called.
144While it is tested by the Miller-Rabin primality test,
145.Fn BN_GENCB_call cb 1 i
146is called in the outer loop (once for each witness that confirms that
147the candidate may be prime).
148.Fa i
149is the loop counter (starting at 0).
150.It
151When p has been found,
152.Fn BN_GENCB_call cb 2 1
153is called.
154.It
155When the generator has been found,
156.Fn BN_GENCB_call cb 3 1
157is called.
158.El
159.Sh RETURN VALUES
160.Fn DSA_generate_parameters_ex
161returns a 1 on success, or 0 otherwise.
162.Pp
163The error codes can be obtained by
164.Xr ERR_get_error 3 .
165.Sh SEE ALSO
166.Xr BN_generate_prime 3 ,
167.Xr DSA_get0_pqg 3 ,
168.Xr DSA_new 3
169.Sh HISTORY
170.Fn DSA_generate_parameters_ex
171first appeared in OpenSSL 0.9.8 and has been available since
172.Ox 4.5 .
173.Sh BUGS
174Seed lengths > 20 are not supported.
diff --git a/src/lib/libcrypto/man/DSA_get0_pqg.3 b/src/lib/libcrypto/man/DSA_get0_pqg.3
deleted file mode 100644
index b82affba66..0000000000
--- a/src/lib/libcrypto/man/DSA_get0_pqg.3
+++ /dev/null
@@ -1,320 +0,0 @@
1.\" $OpenBSD: DSA_get0_pqg.3,v 1.11 2024/07/21 08:36:43 tb Exp $
2.\" full merge up to: OpenSSL e90fc053 Jul 15 09:39:45 2017 -0400
3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>.
5.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: July 21 2024 $
52.Dt DSA_GET0_PQG 3
53.Os
54.Sh NAME
55.Nm DSA_get0_pqg ,
56.Nm DSA_get0_p ,
57.Nm DSA_get0_q ,
58.Nm DSA_get0_g ,
59.Nm DSA_set0_pqg ,
60.Nm DSA_get0_key ,
61.Nm DSA_get0_pub_key ,
62.Nm DSA_get0_priv_key ,
63.Nm DSA_set0_key ,
64.Nm DSA_clear_flags ,
65.Nm DSA_test_flags ,
66.Nm DSA_set_flags ,
67.Nm DSA_get0_engine
68.Nd get data from and set data in a DSA object
69.Sh SYNOPSIS
70.In openssl/dsa.h
71.Ft void
72.Fo DSA_get0_pqg
73.Fa "const DSA *d"
74.Fa "const BIGNUM **p"
75.Fa "const BIGNUM **q"
76.Fa "const BIGNUM **g"
77.Fc
78.Ft "const BIGNUM *"
79.Fo DSA_get0_p
80.Fa "const DSA *d"
81.Fc
82.Ft "const BIGNUM *"
83.Fo DSA_get0_q
84.Fa "const DSA *d"
85.Fc
86.Ft "const BIGNUM *"
87.Fo DSA_get0_g
88.Fa "const DSA *d"
89.Fc
90.Ft int
91.Fo DSA_set0_pqg
92.Fa "DSA *d"
93.Fa "BIGNUM *p"
94.Fa "BIGNUM *q"
95.Fa "BIGNUM *g"
96.Fc
97.Ft void
98.Fo DSA_get0_key
99.Fa "const DSA *d"
100.Fa "const BIGNUM **pub_key"
101.Fa "const BIGNUM **priv_key"
102.Fc
103.Ft "const BIGNUM *"
104.Fo DSA_get0_pub_key
105.Fa "const DSA *d"
106.Fc
107.Ft "const BIGNUM *"
108.Fo DSA_get0_priv_key
109.Fa "const DSA *d"
110.Fc
111.Ft int
112.Fo DSA_set0_key
113.Fa "DSA *d"
114.Fa "BIGNUM *pub_key"
115.Fa "BIGNUM *priv_key"
116.Fc
117.Ft void
118.Fo DSA_clear_flags
119.Fa "DSA *d"
120.Fa "int flags"
121.Fc
122.Ft int
123.Fo DSA_test_flags
124.Fa "const DSA *d"
125.Fa "int flags"
126.Fc
127.Ft void
128.Fo DSA_set_flags
129.Fa "DSA *d"
130.Fa "int flags"
131.Fc
132.Ft ENGINE *
133.Fo DSA_get0_engine
134.Fa "DSA *d"
135.Fc
136.Sh DESCRIPTION
137A
138.Vt DSA
139object contains the parameters
140.Fa p ,
141.Fa q ,
142and
143.Fa g .
144It also contains a public key
145.Fa pub_key
146and an optional private key
147.Fa priv_key .
148.Pp
149The
150.Fa p ,
151.Fa q ,
152and
153.Fa g
154parameters can be obtained by calling
155.Fn DSA_get0_pqg .
156If the parameters have not yet been set, then
157.Pf * Fa p ,
158.Pf * Fa q ,
159and
160.Pf * Fa g
161are set to
162.Dv NULL .
163Otherwise, they are set to pointers to the internal representations
164of the values that should not be freed by the application.
165.Pp
166The
167.Fa p ,
168.Fa q ,
169and
170.Fa g
171values can be set by calling
172.Fn DSA_set0_pqg .
173Calling this function transfers the memory management of the values to
174.Fa d ,
175and therefore they should not be freed by the caller.
176.Pp
177The
178.Fn DSA_get0_key
179function stores pointers to the internal representations
180of the public key in
181.Pf * Fa pub_key
182and to the private key in
183.Pf * Fa priv_key .
184Either may be
185.Dv NULL
186if it has not yet been set.
187If the private key has been set, then the public key must be.
188.Pp
189The public and private key values can be set using
190.Fn DSA_set0_key .
191The public key must be
192.Pf non- Dv NULL
193the first time this function is called on a given
194.Vt DSA
195object.
196The private key may be
197.Dv NULL .
198On subsequent calls, either may be
199.Dv NULL ,
200which means the corresponding
201.Vt DSA
202field is left untouched.
203.Fn DSA_set0_key
204transfers the memory management of the key values to
205.Fa d ,
206and therefore they should not be freed by the caller.
207.Pp
208Values retrieved with
209.Fn DSA_get0_pqg
210and
211.Fn DSA_get0_key
212are owned by the
213.Vt DSA
214object and may therefore not be passed to
215.Fn DSA_set0_pqg
216or
217.Fn DSA_set0_key .
218If needed, duplicate the received values using
219.Xr BN_dup 3
220and pass the duplicates.
221.Pp
222Any of the values
223.Fa p ,
224.Fa q ,
225.Fa g ,
226.Fa pub_key ,
227and
228.Fa priv_key
229can also be retrieved separately by the corresponding functions
230.Fn DSA_get0_p ,
231.Fn DSA_get0_q ,
232.Fn DSA_get0_g ,
233.Fn DSA_get0_pub_key ,
234and
235.Fn DSA_get0_priv_key ,
236respectively.
237The pointers are owned by the
238.Vt DSA
239object.
240.Pp
241.Fn DSA_clear_flags
242clears the specified
243.Fa flags
244in
245.Fa d .
246.Fn DSA_test_flags
247tests the
248.Fa flags
249in
250.Fa d .
251.Fn DSA_set_flags
252sets the
253.Fa flags
254in
255.Fa d ;
256any flags already set remain set.
257For all three functions, multiple flags can be passed in one call,
258OR'ed together bitwise.
259.Sh RETURN VALUES
260.Fn DSA_get0_p ,
261.Fn DSA_get0_q ,
262.Fn DSA_get0_g ,
263.Fn DSA_get0_pub_key ,
264and
265.Fn DSA_get0_priv_key
266return a pointer owned by the
267.Vt DSA
268object if the corresponding value has been set,
269otherwise they return
270.Dv NULL .
271.Fn DSA_set0_pqg
272and
273.Fn DSA_set0_key
274return 1 on success or 0 on failure.
275.Pp
276.Fn DSA_test_flags
277returns those of the given
278.Fa flags
279currently set in
280.Fa d
281or 0 if none of the given
282.Fa flags
283are set.
284.Pp
285.Fn DSA_get0_engine
286always returns
287.Dv NULL .
288.Sh SEE ALSO
289.Xr DSA_do_sign 3 ,
290.Xr DSA_dup_DH 3 ,
291.Xr DSA_generate_key 3 ,
292.Xr DSA_generate_parameters_ex 3 ,
293.Xr DSA_new 3 ,
294.Xr DSA_print 3 ,
295.Xr DSA_security_bits 3 ,
296.Xr DSA_sign 3 ,
297.Xr DSA_size 3
298.Sh HISTORY
299.Fn DSA_get0_pqg ,
300.Fn DSA_set0_pqg ,
301.Fn DSA_get0_key ,
302.Fn DSA_set0_key ,
303.Fn DSA_clear_flags ,
304.Fn DSA_test_flags ,
305.Fn DSA_set_flags ,
306and
307.Fn DSA_get0_engine
308first appeared in OpenSSL 1.1.0
309and have been available since
310.Ox 6.3 .
311.Pp
312.Fn DSA_get0_p ,
313.Fn DSA_get0_q ,
314.Fn DSA_get0_g ,
315.Fn DSA_get0_pub_key ,
316and
317.Fn DSA_get0_priv_key
318first appeared in OpenSSL 1.1.1
319and have been available since
320.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/DSA_get_ex_new_index.3 b/src/lib/libcrypto/man/DSA_get_ex_new_index.3
deleted file mode 100644
index 8fe055f337..0000000000
--- a/src/lib/libcrypto/man/DSA_get_ex_new_index.3
+++ /dev/null
@@ -1,98 +0,0 @@
1.\" $OpenBSD: DSA_get_ex_new_index.3,v 1.5 2018/03/22 16:06:33 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2009 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 22 2018 $
52.Dt DSA_GET_EX_NEW_INDEX 3
53.Os
54.Sh NAME
55.Nm DSA_get_ex_new_index ,
56.Nm DSA_set_ex_data ,
57.Nm DSA_get_ex_data
58.Nd add application specific data to DSA structures
59.Sh SYNOPSIS
60.In openssl/dsa.h
61.Ft int
62.Fo DSA_get_ex_new_index
63.Fa "long argl"
64.Fa "void *argp"
65.Fa "CRYPTO_EX_new *new_func"
66.Fa "CRYPTO_EX_dup *dup_func"
67.Fa "CRYPTO_EX_free *free_func"
68.Fc
69.Ft int
70.Fo DSA_set_ex_data
71.Fa "DSA *d"
72.Fa "int idx"
73.Fa "void *arg"
74.Fc
75.Ft char *
76.Fo DSA_get_ex_data
77.Fa "DSA *d"
78.Fa "int idx"
79.Fc
80.Sh DESCRIPTION
81These functions handle application specific data in
82.Vt DSA
83structures.
84Their usage is identical to that of
85.Xr RSA_get_ex_new_index 3 ,
86.Xr RSA_set_ex_data 3 ,
87and
88.Xr RSA_get_ex_data 3 .
89.Sh SEE ALSO
90.Xr DSA_new 3 ,
91.Xr RSA_get_ex_new_index 3
92.Sh HISTORY
93.Fn DSA_get_ex_new_index ,
94.Fn DSA_set_ex_data ,
95and
96.Fn DSA_get_ex_data
97first appeared in OpenSSL 0.9.5 and have been available since
98.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/DSA_meth_new.3 b/src/lib/libcrypto/man/DSA_meth_new.3
deleted file mode 100644
index d89cd397b0..0000000000
--- a/src/lib/libcrypto/man/DSA_meth_new.3
+++ /dev/null
@@ -1,230 +0,0 @@
1.\" $OpenBSD: DSA_meth_new.3,v 1.3 2022/07/10 13:41:59 schwarze Exp $
2.\" selective merge up to: OpenSSL c4d3c19b Apr 3 13:57:12 2018 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018, 2022 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Matt Caswell <matt@openssl.org>.
22.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: July 10 2022 $
69.Dt DSA_METH_NEW 3
70.Os
71.Sh NAME
72.Nm DSA_meth_new ,
73.Nm DSA_meth_free ,
74.Nm DSA_meth_dup ,
75.Nm DSA_meth_get0_name ,
76.Nm DSA_meth_set1_name ,
77.Nm DSA_meth_set_sign ,
78.Nm DSA_meth_set_finish
79.Nd build up DSA methods
80.Sh SYNOPSIS
81.In openssl/dsa.h
82.Ft DSA_METHOD *
83.Fo DSA_meth_new
84.Fa "const char *name"
85.Fa "int flags"
86.Fc
87.Ft void
88.Fo DSA_meth_free
89.Fa "DSA_METHOD *meth"
90.Fc
91.Ft DSA_METHOD *
92.Fo DSA_meth_dup
93.Fa "const DSA_METHOD *meth"
94.Fc
95.Ft const char *
96.Fo DSA_meth_get0_name
97.Fa "const DSA_METHOD *meth"
98.Fc
99.Ft int
100.Fo DSA_meth_set1_name
101.Fa "DSA_METHOD *meth"
102.Fa "const char *name"
103.Fc
104.Ft int
105.Fo DSA_meth_set_sign
106.Fa "DSA_METHOD *meth"
107.Fa "DSA_SIG *(*sign)(const unsigned char *, int, DSA *)"
108.Fc
109.Ft int
110.Fo DSA_meth_set_finish
111.Fa "DSA_METHOD *meth"
112.Fa "int (*finish)(DSA *)"
113.Fc
114.Sh DESCRIPTION
115The
116.Vt DSA_METHOD
117structure holds function pointers for custom DSA implementations.
118.Pp
119.Fn DSA_meth_new
120creates a new
121.Vt DSA_METHOD
122structure.
123A copy of the NUL-terminated
124.Fa name
125is stored in the new
126.Vt DSA_METHOD
127object.
128Any new
129.Vt DSA
130object constructed from this
131.Vt DSA_METHOD
132will have the given
133.Fa flags
134set by default.
135.Pp
136.Fn DSA_meth_dup
137creates a deep copy of
138.Fa meth .
139This might be useful for creating a new
140.Vt DSA_METHOD
141based on an existing one, but with some differences.
142.Pp
143.Fn DSA_meth_free
144destroys
145.Fa meth
146and frees any memory associated with it.
147.Pp
148.Fn DSA_meth_get0_name
149returns an internal pointer to the name of
150.Fa meth .
151.Fn DSA_meth_set1_name
152stores a copy of the NUL-terminated
153.Fa name
154in
155.Fa meth
156after freeing the previously stored name.
157Method names are ignored by the default DSA implementation but can be
158used by alternative implementations and by the application program.
159.Pp
160.Fn DSA_meth_set_sign
161sets the function used for creating a DSA signature.
162This function will be called from
163.Xr DSA_do_sign 3
164and indirectly from
165.Xr DSA_sign 3 .
166The parameters of
167.Fa sign
168have the same meaning as for
169.Xr DSA_do_sign 3 .
170.Pp
171.Fn DSA_meth_set_finish
172sets an optional function for destroying a
173.Vt DSA
174object.
175Unless
176.Fa finish
177is
178.Dv NULL ,
179it will be called from
180.Xr DSA_free 3 .
181It takes the same argument
182and is intended to do DSA implementation specific cleanup.
183The memory used by the
184.Vt DSA
185object itself should not be freed by the
186.Fa finish
187function.
188.Sh RETURN VALUES
189.Fn DSA_meth_new
190and
191.Fn DSA_meth_dup
192return the newly allocated
193.Vt DSA_METHOD
194object or
195.Dv NULL
196on failure.
197.Pp
198.Fn DSA_meth_get0_name
199returns an internal pointer which must not be freed by the caller.
200.Pp
201.Fn DSA_meth_set1_name
202and all
203.Fn DSA_meth_set_*
204functions return 1 on success or 0 on failure.
205In the current implementation, only
206.Fn DSA_meth_set1_name
207can actually fail.
208.Sh SEE ALSO
209.Xr DSA_do_sign 3 ,
210.Xr DSA_new 3 ,
211.Xr DSA_set_method 3 ,
212.Xr DSA_SIG_new 3 ,
213.Xr DSA_sign 3
214.Sh HISTORY
215These functions first appeared in OpenSSL 1.1.0.
216.Pp
217.Fn DSA_meth_new ,
218.Fn DSA_meth_free ,
219.Fn DSA_meth_dup ,
220.Fn DSA_meth_set_sign ,
221and
222.Fn DSA_meth_set_finish
223have been available since
224.Ox 6.3 .
225.Pp
226.Fn DSA_meth_get0_name
227and
228.Fn DSA_meth_set1_name
229have been available since
230.Ox 7.2 .
diff --git a/src/lib/libcrypto/man/DSA_new.3 b/src/lib/libcrypto/man/DSA_new.3
deleted file mode 100644
index 5a958b58c4..0000000000
--- a/src/lib/libcrypto/man/DSA_new.3
+++ /dev/null
@@ -1,141 +0,0 @@
1.\" $OpenBSD: DSA_new.3,v 1.14 2023/12/29 19:12:47 tb Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2002 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 29 2023 $
52.Dt DSA_NEW 3
53.Os
54.Sh NAME
55.Nm DSA_new ,
56.Nm DSA_up_ref ,
57.Nm DSA_free
58.Nd allocate and free DSA objects
59.Sh SYNOPSIS
60.In openssl/dsa.h
61.Ft DSA*
62.Fn DSA_new void
63.Ft int
64.Fo DSA_up_ref
65.Fa "DSA *dsa"
66.Fc
67.Ft void
68.Fo DSA_free
69.Fa "DSA *dsa"
70.Fc
71.Sh DESCRIPTION
72The DSA functions implement the Digital Signature Algorithm.
73.Pp
74.Fn DSA_new
75allocates and initializes a
76.Vt DSA
77structure, setting the reference count to 1.
78It is equivalent to calling
79.Xr DSA_new_method 3
80with a
81.Dv NULL
82argument.
83.Pp
84.Fn DSA_up_ref
85increments the reference count by 1.
86.Pp
87.Fn DSA_free
88decrements the reference count by 1.
89If it reaches 0, it frees the
90.Vt DSA
91structure and its components.
92The values are erased before the memory is returned to the system.
93If
94.Fa dsa
95is a
96.Dv NULL
97pointer, no action occurs.
98.Sh RETURN VALUES
99If the allocation fails,
100.Fn DSA_new
101returns
102.Dv NULL
103and sets an error code that can be obtained by
104.Xr ERR_get_error 3 .
105Otherwise it returns a pointer to the newly allocated structure.
106.Pp
107.Fn DSA_up_ref
108returns 1 for success or 0 for failure.
109.Sh SEE ALSO
110.Xr BN_new 3 ,
111.Xr crypto 3 ,
112.Xr d2i_DSAPublicKey 3 ,
113.Xr DH_new 3 ,
114.Xr DSA_do_sign 3 ,
115.Xr DSA_dup_DH 3 ,
116.Xr DSA_generate_key 3 ,
117.Xr DSA_generate_parameters_ex 3 ,
118.Xr DSA_get0_pqg 3 ,
119.Xr DSA_get_ex_new_index 3 ,
120.Xr DSA_meth_new 3 ,
121.Xr DSA_print 3 ,
122.Xr DSA_security_bits 3 ,
123.Xr DSA_set_method 3 ,
124.Xr DSA_SIG_new 3 ,
125.Xr DSA_sign 3 ,
126.Xr DSA_size 3 ,
127.Xr EVP_PKEY_set1_DSA 3 ,
128.Xr RSA_new 3
129.Sh STANDARDS
130US Federal Information Processing Standard FIPS 186 (Digital Signature
131Standard, DSS), ANSI X9.30
132.Sh HISTORY
133.Fn DSA_new
134and
135.Fn DSA_free
136first appeared in SSLeay 0.6.0 and have been available since
137.Ox 2.4 .
138.Pp
139.Fn DSA_up_ref
140first appeared in OpenSSL 0.9.7 and has been available since
141.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/DSA_set_method.3 b/src/lib/libcrypto/man/DSA_set_method.3
deleted file mode 100644
index c60a3e29c3..0000000000
--- a/src/lib/libcrypto/man/DSA_set_method.3
+++ /dev/null
@@ -1,178 +0,0 @@
1.\" $OpenBSD: DSA_set_method.3,v 1.12 2024/05/11 06:53:19 tb Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2002, 2007 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: May 11 2024 $
52.Dt DSA_SET_METHOD 3
53.Os
54.Sh NAME
55.Nm DSA_set_default_method ,
56.Nm DSA_get_default_method ,
57.Nm DSA_set_method ,
58.Nm DSA_new_method ,
59.Nm DSA_OpenSSL
60.Nd select DSA method
61.Sh SYNOPSIS
62.In openssl/dsa.h
63.Ft void
64.Fo DSA_set_default_method
65.Fa "const DSA_METHOD *meth"
66.Fc
67.Ft const DSA_METHOD *
68.Fn DSA_get_default_method void
69.Ft int
70.Fo DSA_set_method
71.Fa "DSA *dsa"
72.Fa "const DSA_METHOD *meth"
73.Fc
74.Ft DSA *
75.Fo DSA_new_method
76.Fa "ENGINE *engine"
77.Fc
78.Ft DSA_METHOD *
79.Fn DSA_OpenSSL void
80.Sh DESCRIPTION
81A
82.Vt DSA_METHOD
83object contains pointers to the functions used for DSA operations.
84By default, the internal implementation returned by
85.Fn DSA_OpenSSL
86is used.
87By selecting another method, alternative implementations
88such as hardware accelerators may be used.
89.Pp
90.Fn DSA_set_default_method
91selects
92.Fa meth
93as the default method for all
94.Vt DSA
95structures created later.
96.Pp
97.Fn DSA_get_default_method
98returns a pointer to the current default method.
99.Pp
100.Fn DSA_set_method
101selects
102.Fa meth
103to perform all operations using the key
104.Fa dsa .
105This replaces the
106.Vt DSA_METHOD
107used by the DSA key.
108It is possible to have DSA keys that only work with certain
109.Vt DSA_METHOD
110implementations,
111and in such cases attempting to change the
112.Vt DSA_METHOD
113for the key can have unexpected results.
114.Pp
115.Fn DSA_new_method
116allocates and initializes a
117.Vt DSA
118structure.
119The
120.Fa engine
121argument is ignored and
122the default method controlled by
123.Fn DSA_set_default_method
124is used.
125.Pp
126The
127.Vt DSA_METHOD
128structure is defined as follows:
129.Bd -literal
130struct {
131 /* name of the implementation */
132 const char *name;
133 /* sign */
134 DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen,
135 DSA *dsa);
136 /* pre-compute k^-1 and r */
137 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
138 BIGNUM **rp);
139 /* verify */
140 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
141 DSA_SIG *sig, DSA *dsa);
142 /* called at DSA_new */
143 int (*init)(DSA *DSA);
144 /* called at DSA_free */
145 int (*finish)(DSA *DSA);
146 int flags;
147} DSA_METHOD;
148.Ed
149.Sh RETURN VALUES
150.Fn DSA_OpenSSL
151and
152.Fn DSA_get_default_method
153return pointers to the respective
154.Vt DSA_METHOD .
155.Pp
156.Fn DSA_set_method
157returns 1 on success or 0 on failure.
158Currently, it cannot fail.
159.Pp
160.Fn DSA_new_method
161returns
162.Dv NULL
163and sets an error code that can be obtained by
164.Xr ERR_get_error 3
165if the allocation fails.
166Otherwise it returns a pointer to the newly allocated structure.
167.Sh SEE ALSO
168.Xr DSA_meth_new 3 ,
169.Xr DSA_new 3
170.Sh HISTORY
171.Fn DSA_set_default_method ,
172.Fn DSA_get_default_method ,
173.Fn DSA_set_method ,
174.Fn DSA_new_method ,
175and
176.Fn DSA_OpenSSL
177first appeared in OpenSSL 0.9.5 and have been available since
178.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/DSA_sign.3 b/src/lib/libcrypto/man/DSA_sign.3
deleted file mode 100644
index 59f9042ba6..0000000000
--- a/src/lib/libcrypto/man/DSA_sign.3
+++ /dev/null
@@ -1,173 +0,0 @@
1.\" $OpenBSD: DSA_sign.3,v 1.10 2019/06/10 14:58:48 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 10 2019 $
52.Dt DSA_SIGN 3
53.Os
54.Sh NAME
55.Nm DSA_sign ,
56.Nm DSA_sign_setup ,
57.Nm DSA_verify
58.Nd DSA signatures
59.Sh SYNOPSIS
60.In openssl/dsa.h
61.Ft int
62.Fo DSA_sign
63.Fa "int type"
64.Fa "const unsigned char *dgst"
65.Fa "int len"
66.Fa "unsigned char *sigret"
67.Fa "unsigned int *siglen"
68.Fa "DSA *dsa"
69.Fc
70.Ft int
71.Fo DSA_sign_setup
72.Fa "DSA *dsa"
73.Fa "BN_CTX *ctx"
74.Fa "BIGNUM **kinvp"
75.Fa "BIGNUM **rp"
76.Fc
77.Ft int
78.Fo DSA_verify
79.Fa "int type"
80.Fa "const unsigned char *dgst"
81.Fa "int len"
82.Fa "unsigned char *sigbuf"
83.Fa "int siglen"
84.Fa "DSA *dsa"
85.Fc
86.Sh DESCRIPTION
87.Fn DSA_sign
88computes a digital signature on the
89.Fa len
90byte message digest
91.Fa dgst
92using the private key
93.Fa dsa
94and places its ASN.1 DER encoding at
95.Fa sigret .
96The length of the signature is placed in
97.Pf * Fa siglen .
98.Fa sigret
99must point to
100.Fn DSA_size dsa
101bytes of memory.
102.Pp
103.Fn DSA_sign_setup
104may be used to precompute part of the signing operation in case
105signature generation is time-critical.
106It expects
107.Fa dsa
108to contain DSA parameters.
109It places the precomputed values in newly allocated
110.Vt BIGNUM Ns s
111at
112.Pf * Fa kinvp
113and
114.Pf * Fa rp ,
115after freeing the old ones unless
116.Fa kinvp
117and
118.Fa rp
119are
120.Dv NULL .
121These values may be passed to
122.Fn DSA_sign
123in
124.Fa dsa->kinv
125and
126.Sy dsa->r .
127.Fa ctx
128is a pre-allocated
129.Vt BN_CTX
130or
131.Dv NULL .
132.Pp
133.Fn DSA_verify
134verifies that the signature
135.Fa sigbuf
136of size
137.Fa siglen
138matches a given message digest
139.Fa dgst
140of size
141.Fa len .
142.Fa dsa
143is the signer's public key.
144.Pp
145The
146.Fa type
147parameter is ignored.
148.Sh RETURN VALUES
149.Fn DSA_sign
150and
151.Fn DSA_sign_setup
152return 1 on success or 0 on error.
153.Fn DSA_verify
154returns 1 for a valid signature, 0 for an incorrect signature,
155and -1 on error.
156The error codes can be obtained by
157.Xr ERR_get_error 3 .
158.Sh SEE ALSO
159.Xr DSA_do_sign 3 ,
160.Xr DSA_get0_key 3 ,
161.Xr DSA_new 3
162.Sh STANDARDS
163US Federal Information Processing Standard FIPS 186 (Digital Signature
164Standard, DSS), ANSI X9.30
165.Sh HISTORY
166.Fn DSA_sign
167and
168.Fn DSA_verify
169first appeared in SSLeay 0.6.0.
170.Fn DSA_sign_setup
171first appeared in SSLeay 0.8.0.
172All these functions have been available since
173.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/DSA_size.3 b/src/lib/libcrypto/man/DSA_size.3
deleted file mode 100644
index 4786acc7e9..0000000000
--- a/src/lib/libcrypto/man/DSA_size.3
+++ /dev/null
@@ -1,122 +0,0 @@
1.\" $OpenBSD: DSA_size.3,v 1.8 2022/07/13 21:44:23 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ulf Moeller <ulf@openssl.org>
22.\" and Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000, 2002, 2016 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: July 13 2022 $
70.Dt DSA_SIZE 3
71.Os
72.Sh NAME
73.Nm DSA_size ,
74.Nm DSA_bits
75.Nd get DSA signature or key size
76.Sh SYNOPSIS
77.In openssl/dsa.h
78.Ft int
79.Fo DSA_size
80.Fa "const DSA *dsa"
81.Fc
82.Ft int
83.Fo DSA_bits
84.Fa "const DSA *dsa"
85.Fc
86.Sh DESCRIPTION
87.Fn DSA_size
88returns the maximum size of an ASN.1 encoded DSA signature for the key
89.Fa dsa
90in bytes.
91It can be used to determine how much memory must be allocated for a DSA
92signature.
93.Pp
94.Fa dsa->q
95must not be
96.Dv NULL .
97.Pp
98.Fn DSA_bits
99returns the number of significant bits in the public domain parameter
100.Fa p
101contained in
102.Fa dsa .
103This is also the number of bits in the public key.
104.Sh RETURN VALUES
105.Fn DSA_size
106returns the size of the signature in bytes.
107.Pp
108.Fn DSA_bits
109returns the size of the public key in bits.
110.Sh SEE ALSO
111.Xr DSA_get0_pqg 3 ,
112.Xr DSA_new 3 ,
113.Xr DSA_security_bits 3 ,
114.Xr DSA_sign 3
115.Sh HISTORY
116.Fn DSA_size
117first appeared in SSLeay 0.6.0 and has been available since
118.Ox 2.4 .
119.Pp
120.Fn DSA_bits
121first appeared in OpenSSL 1.1.0 and has been available since
122.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/ECDH_compute_key.3 b/src/lib/libcrypto/man/ECDH_compute_key.3
deleted file mode 100644
index c49988e141..0000000000
--- a/src/lib/libcrypto/man/ECDH_compute_key.3
+++ /dev/null
@@ -1,88 +0,0 @@
1.\" $OpenBSD: ECDH_compute_key.3,v 1.3 2023/08/29 10:07:42 tb Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\"
4.\" Permission to use, copy, modify, and distribute this software for any
5.\" purpose with or without fee is hereby granted, provided that the above
6.\" copyright notice and this permission notice appear in all copies.
7.\"
8.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\"
16.Dd $Mdocdate: August 29 2023 $
17.Dt ECDH_COMPUTE_KEY 3
18.Os
19.Sh NAME
20.Nm ECDH_compute_key ,
21.Nm ECDH_size
22.Nd Elliptic Curve Diffie-Hellman key exchange
23.Sh SYNOPSIS
24.In openssl/ec.h
25.Ft int
26.Fo ECDH_compute_key
27.Fa "void *out"
28.Fa "size_t outlen"
29.Fa "const EC_POINT *public_key"
30.Fa "EC_KEY *ecdh"
31.Fa "void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)"
32.Fc
33.Ft int
34.Fo ECDH_size
35.Fa "const EC_KEY *ecdh"
36.Fc
37.Sh DESCRIPTION
38.Fn ECDH_compute_key
39performs Elliptic Curve Diffie-Hellman key agreement.
40It combines the private key contained in
41.Fa ecdh
42with the other party's
43.Fa public_key ,
44takes the
45.Fa x
46component of the affine coordinates,
47and optionally applies the key derivation function
48.Fa KDF .
49It stores the resulting symmetric key in the buffer
50.Fa out ,
51which is
52.Fa outlen
53bytes long.
54If
55.Fa KDF
56is
57.Dv NULL ,
58.Fa outlen
59must be at least
60.Fn ECDH_size ecdh .
61.Pp
62.Fn ECDH_size
63returns the number of bytes needed to store an affine coordinate of a
64point on the elliptic curve used by
65.Fa ecdh ,
66which is one eighth of the degree of the finite field underlying
67that elliptic curve, rounded up to the next integer number.
68.Sh RETURN VALUES
69.Fn ECDH_compute_key
70returns the length of the computed key in bytes or -1 if an error occurs.
71.Pp
72.Fn ECDH_size
73returns the number of bytes needed to store an affine coordinate.
74.Sh SEE ALSO
75.Xr DH_generate_key 3 ,
76.Xr DH_size 3 ,
77.Xr EC_GROUP_new 3 ,
78.Xr EC_KEY_new 3 ,
79.Xr EC_POINT_new 3 ,
80.Xr X25519 3
81.Sh HISTORY
82.Fn ECDH_compute_key
83first appeared in OpenSSL 0.9.8 and has been available since
84.Ox 4.5 .
85.Pp
86.Fn ECDH_size
87first appeared in
88.Ox 6.1 .
diff --git a/src/lib/libcrypto/man/ECDSA_SIG_new.3 b/src/lib/libcrypto/man/ECDSA_SIG_new.3
deleted file mode 100644
index 2b72e6f1b9..0000000000
--- a/src/lib/libcrypto/man/ECDSA_SIG_new.3
+++ /dev/null
@@ -1,452 +0,0 @@
1.\" $OpenBSD: ECDSA_SIG_new.3,v 1.21 2024/11/15 20:14:58 tb Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" selective merge up to: OpenSSL da4ea0cf Aug 5 16:13:24 2019 +0100
4.\"
5.\" This file was written by Nils Larsch <nils@openssl.org>.
6.\" Copyright (c) 2004, 2005, 2013, 2016 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: November 15 2024 $
54.Dt ECDSA_SIG_NEW 3
55.Os
56.Sh NAME
57.Nm ECDSA_SIG_new ,
58.Nm ECDSA_SIG_free ,
59.Nm ECDSA_SIG_get0 ,
60.Nm ECDSA_SIG_get0_r ,
61.Nm ECDSA_SIG_get0_s ,
62.Nm ECDSA_SIG_set0 ,
63.Nm i2d_ECDSA_SIG ,
64.Nm d2i_ECDSA_SIG ,
65.Nm ECDSA_size ,
66.Nm ECDSA_sign ,
67.Nm ECDSA_verify ,
68.Nm ECDSA_do_sign ,
69.Nm ECDSA_do_verify
70.Nd Elliptic Curve Digital Signature Algorithm
71.Sh SYNOPSIS
72.In openssl/ec.h
73.Ft ECDSA_SIG*
74.Fo ECDSA_SIG_new
75.Fa void
76.Fc
77.Ft void
78.Fo ECDSA_SIG_free
79.Fa "ECDSA_SIG *sig"
80.Fc
81.Ft void
82.Fo ECDSA_SIG_get0
83.Fa "const ECDSA_SIG *sig"
84.Fa "const BIGNUM **r"
85.Fa "const BIGNUM **s"
86.Fc
87.Ft "const BIGNUM *"
88.Fo ECDSA_SIG_get0_r
89.Fa "const ECDSA_SIG *sig"
90.Fc
91.Ft "const BIGNUM *"
92.Fo ECDSA_SIG_get0_s
93.Fa "const ECDSA_SIG *sig"
94.Fc
95.Ft int
96.Fo ECDSA_SIG_set0
97.Fa "ECDSA_SIG *sig"
98.Fa "BIGNUM *r"
99.Fa "BIGNUM *s"
100.Fc
101.Ft int
102.Fo i2d_ECDSA_SIG
103.Fa "const ECDSA_SIG *sig_in"
104.Fa "unsigned char **der_out"
105.Fc
106.Ft ECDSA_SIG*
107.Fo d2i_ECDSA_SIG
108.Fa "ECDSA_SIG **sig_out"
109.Fa "const unsigned char **der_in"
110.Fa "long len"
111.Fc
112.Ft int
113.Fo ECDSA_size
114.Fa "const EC_KEY *eckey"
115.Fc
116.Ft int
117.Fo ECDSA_sign
118.Fa "int type"
119.Fa "const unsigned char *dgst"
120.Fa "int dgstlen"
121.Fa "unsigned char *sig"
122.Fa "unsigned int *siglen"
123.Fa "EC_KEY *eckey"
124.Fc
125.Ft int
126.Fo ECDSA_verify
127.Fa "int type"
128.Fa "const unsigned char *dgst"
129.Fa "int dgstlen"
130.Fa "const unsigned char *sig"
131.Fa "int siglen"
132.Fa "EC_KEY *eckey"
133.Fc
134.Ft ECDSA_SIG*
135.Fo ECDSA_do_sign
136.Fa "const unsigned char *dgst"
137.Fa "int dgst_len"
138.Fa "EC_KEY *eckey"
139.Fc
140.Ft int
141.Fo ECDSA_do_verify
142.Fa "const unsigned char *dgst"
143.Fa "int dgst_len"
144.Fa "const ECDSA_SIG *sig"
145.Fa "EC_KEY* eckey"
146.Fc
147.Sh DESCRIPTION
148These functions provide a low level interface to ECDSA.
149Most applications should use the higher level EVP interface such as
150.Xr EVP_DigestSignInit 3
151or
152.Xr EVP_DigestVerifyInit 3
153instead.
154Creation of the required
155.Vt EC_KEY
156objects is described in
157.Xr EC_KEY_new 3 .
158.Pp
159The
160.Vt ECDSA_SIG
161structure consists of two
162.Vt BIGNUM Ns s
163for the
164.Fa r
165and
166.Fa s
167value of an ECDSA signature (see X9.62 or FIPS 186-2).
168.Bd -literal -offset indent
169struct {
170 BIGNUM *r;
171 BIGNUM *s;
172} ECDSA_SIG;
173.Ed
174.Pp
175.Fn ECDSA_SIG_new
176allocates a new
177.Vt ECDSA_SIG
178structure (note: this function also allocates the
179.Vt BIGNUM Ns s )
180and initializes it.
181.Pp
182.Fn ECDSA_SIG_free
183frees the
184.Vt ECDSA_SIG
185structure
186.Fa sig .
187.Pp
188.Fn ECDSA_SIG_get0
189retrieves internal pointers the
190.Fa r
191and
192.Fa s
193values contained in
194.Fa sig .
195The values
196.Fa r
197and
198.Fa s
199can also be retrieved separately by the corresponding function
200.Fn ECDSA_SIG_get0_r
201and
202.Fn ECDSA_SIG_get0_s ,
203respectively.
204.Pp
205.Fn ECDSA_SIG_set0
206sets the
207.Fa r
208and
209.Fa s
210values in
211.Fa sig .
212Calling this function transfers the memory management of the values to
213.Fa sig .
214Therefore, the values that have been passed in
215should not be freed by the caller.
216.Pp
217.Fn i2d_ECDSA_SIG
218creates the DER encoding of the ECDSA signature
219.Fa sig_in
220and writes the encoded signature to
221.Pf * Fa der_out .
222.Fn d2i_ECDSA_SIG
223decodes the DER-encoded signature stored in the buffer
224.Pf * Fa der_in
225which is
226.Fa len
227bytes long into
228.Pf * Fa sig_out .
229For details about the semantics, examples, caveats, and bugs, see
230.Xr ASN1_item_d2i 3 .
231.Pp
232.Fn ECDSA_size
233returns the maximum length of a DER-encoded ECDSA signature created with
234the private EC key
235.Fa eckey .
236.Pp
237.Fn ECDSA_sign
238computes a digital signature of the
239.Fa dgstlen
240bytes hash value
241.Fa dgst
242using the private EC key
243.Fa eckey .
244The DER-encoded signature is stored in
245.Fa sig
246and its length is returned in
247.Fa siglen .
248Note:
249.Fa sig
250must point to
251.Fn ECDSA_size
252bytes of memory.
253The parameter
254.Fa type
255is ignored.
256.Pp
257.Fn ECDSA_verify
258verifies that the signature in
259.Fa sig
260of size
261.Fa siglen
262is a valid ECDSA signature of the hash value
263.Fa dgst
264of size
265.Fa dgstlen
266using the public key
267.Fa eckey .
268The parameter
269.Fa type
270is ignored.
271.Pp
272.Fn ECDSA_do_sign
273computes a digital signature of the
274.Fa dgst_len
275bytes hash value
276.Fa dgst
277using the private key
278.Fa eckey .
279The signature is returned in a newly allocated
280.Vt ECDSA_SIG
281structure (or
282.Dv NULL
283on error).
284.Pp
285.Fn ECDSA_do_verify
286verifies that the signature
287.Fa sig
288is a valid ECDSA signature of the hash value
289.Fa dgst
290of size
291.Fa dgst_len
292using the public key
293.Fa eckey .
294.Sh RETURN VALUES
295.Fn ECDSA_SIG_new
296returns the new
297.Vt ECDSA_SIG
298object or
299.Dv NULL
300if an error occurs.
301.Pp
302.Fn i2d_ECDSA_SIG
303returns the number of bytes successfully encoded
304or a negative value if an error occurs.
305.Pp
306.Fn d2i_ECDSA_SIG
307returns a pointer to the decoded
308.Vt ECDSA_SIG
309structure or
310.Dv NULL
311if an error occurs.
312.Pp
313.Fn ECDSA_size
314returns the maximum length signature or 0 on error.
315.Pp
316.Fn ECDSA_SIG_get0_r
317and
318.Fn ECDSA_SIG_get0_s
319return a pointer owned by the
320.Vt ECDSA_SIG
321object if it has been set or
322.Dv NULL
323otherwise.
324.Pp
325.Fn ECDSA_SIG_set0
326and
327.Fn ECDSA_sign
328return 1 if successful or 0 on error.
329.Pp
330.Fn ECDSA_do_sign
331returns a pointer to an allocated
332.Vt ECDSA_SIG
333structure or
334.Dv NULL
335on error.
336.Pp
337.Fn ECDSA_verify
338and
339.Fn ECDSA_do_verify
340return 1 for a valid signature, 0 for an invalid signature and -1 on
341error.
342The error codes can be obtained by
343.Xr ERR_get_error 3 .
344.Sh EXAMPLES
345Creating an ECDSA signature of given SHA-384 hash value using the named
346curve secp384r1.
347.Pp
348First step: create an
349.Vt EC_KEY
350object.
351This part is
352.Em not
353ECDSA specific.
354.Bd -literal -offset indent
355int ret;
356ECDSA_SIG *sig;
357EC_KEY *eckey;
358
359eckey = EC_KEY_new_by_curve_name(NID_secp384r1);
360if (eckey == NULL) {
361 /* error */
362}
363if (!EC_KEY_generate_key(eckey)) {
364 /* error */
365}
366.Ed
367.Pp
368Second step: compute the ECDSA signature of a SHA-384 hash value using
369.Fn ECDSA_do_sign
370.Bd -literal -offset indent
371sig = ECDSA_do_sign(digest, SHA384_DIGEST_LENGTH, eckey);
372if (sig == NULL) {
373 /* error */
374}
375.Ed
376.Pp
377or using
378.Fn ECDSA_sign
379.Bd -literal -offset indent
380unsigned char *buffer, *pp;
381int buf_len;
382
383buf_len = ECDSA_size(eckey);
384buffer = malloc(buf_len);
385pp = buffer;
386if (!ECDSA_sign(0, dgst, dgstlen, pp, &buf_len, eckey) {
387 /* error */
388}
389.Ed
390.Pp
391Third step: verify the created ECDSA signature using
392.Fn ECDSA_do_verify
393.Pp
394.Dl ret = ECDSA_do_verify(digest, SHA384_DIGEST_LENGTH, sig, eckey);
395.Pp
396or using
397.Fn ECDSA_verify
398.Pp
399.Dl ret = ECDSA_verify(0, digest, SHA384_DIGEST_LENGTH, buffer, buf_len, eckey);
400.Pp
401and finally evaluate the return value:
402.Bd -literal -offset indent
403if (ret == -1) {
404 /* error */
405} else if (ret == 0) {
406 /* incorrect signature */
407} else {
408 /* ret == 1 */
409 /* signature ok */
410}
411.Ed
412.Sh SEE ALSO
413.Xr crypto 3 ,
414.Xr d2i_ECPKParameters 3 ,
415.Xr DSA_new 3 ,
416.Xr EC_GROUP_new 3 ,
417.Xr EC_KEY_METHOD_new 3 ,
418.Xr EC_KEY_new 3 ,
419.Xr EC_KEY_set_ex_data 3 ,
420.Xr EVP_DigestSignInit 3 ,
421.Xr EVP_DigestVerifyInit 3 ,
422.Xr RSA_new 3
423.Sh STANDARDS
424ANSI X9.62, US Federal Information Processing Standard FIPS 186-5
425(Digital Signature Standard, DSS)
426.Sh HISTORY
427.Fn ECDSA_SIG_new ,
428.Fn ECDSA_SIG_free ,
429.Fn i2d_ECDSA_SIG ,
430.Fn d2i_ECDSA_SIG ,
431.Fn ECDSA_size ,
432.Fn ECDSA_sign ,
433.Fn ECDSA_verify ,
434.Fn ECDSA_do_sign ,
435and
436.Fn ECDSA_do_verify
437first appeared in OpenSSL 0.9.8 and have been available since
438.Ox 4.5 .
439.Pp
440.Fn ECDSA_SIG_get0
441and
442.Fn ECDSA_SIG_set0
443first appeared in OpenSSL 1.1.0 and have been available since
444.Ox 6.3 .
445.Fn ECDSA_SIG_get0_r
446and
447.Fn ECDSA_SIG_get0_s
448first appeared in OpenSSL 1.1.1 and have been available since
449.Ox 7.1 .
450.Sh AUTHORS
451.An Nils Larsch
452for the OpenSSL project.
diff --git a/src/lib/libcrypto/man/EC_GROUP_copy.3 b/src/lib/libcrypto/man/EC_GROUP_copy.3
deleted file mode 100644
index 2e5e798236..0000000000
--- a/src/lib/libcrypto/man/EC_GROUP_copy.3
+++ /dev/null
@@ -1,492 +0,0 @@
1.\" $OpenBSD: EC_GROUP_copy.3,v 1.16 2025/03/08 16:40:59 tb Exp $
2.\" full merge up to: OpenSSL d900a015 Oct 8 14:40:42 2015 +0200
3.\" selective merge up to: OpenSSL 24c23e1f Aug 22 10:51:25 2019 +0530
4.\"
5.\" This file was written by Matt Caswell <matt@openssl.org>,
6.\" Dr. Stephen Henson <steve@openssl.org>,
7.\" and Jayaram X Matta <jayaramx.matta@intel.com>.
8.\" Copyright (c) 2013, 2015, 2019 The OpenSSL Project. All rights reserved.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\"
14.\" 1. Redistributions of source code must retain the above copyright
15.\" notice, this list of conditions and the following disclaimer.
16.\"
17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\" notice, this list of conditions and the following disclaimer in
19.\" the documentation and/or other materials provided with the
20.\" distribution.
21.\"
22.\" 3. All advertising materials mentioning features or use of this
23.\" software must display the following acknowledgment:
24.\" "This product includes software developed by the OpenSSL Project
25.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
26.\"
27.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
28.\" endorse or promote products derived from this software without
29.\" prior written permission. For written permission, please contact
30.\" openssl-core@openssl.org.
31.\"
32.\" 5. Products derived from this software may not be called "OpenSSL"
33.\" nor may "OpenSSL" appear in their names without prior written
34.\" permission of the OpenSSL Project.
35.\"
36.\" 6. Redistributions of any form whatsoever must retain the following
37.\" acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
40.\"
41.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
42.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
45.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\"
54.Dd $Mdocdate: March 8 2025 $
55.Dt EC_GROUP_COPY 3
56.Os
57.Sh NAME
58.Nm EC_GROUP_copy ,
59.Nm EC_GROUP_dup ,
60.Nm EC_GROUP_set_generator ,
61.Nm EC_GROUP_get0_generator ,
62.Nm EC_GROUP_get_order ,
63.Nm EC_GROUP_order_bits ,
64.Nm EC_GROUP_get_cofactor ,
65.Nm EC_GROUP_set_curve_name ,
66.Nm EC_GROUP_get_curve_name ,
67.Nm EC_GROUP_set_asn1_flag ,
68.Nm EC_GROUP_get_asn1_flag ,
69.Nm EC_GROUP_set_point_conversion_form ,
70.Nm EC_GROUP_get_point_conversion_form ,
71.Nm EC_GROUP_get0_seed ,
72.Nm EC_GROUP_get_seed_len ,
73.Nm EC_GROUP_set_seed ,
74.Nm EC_GROUP_get_degree ,
75.Nm EC_GROUP_check ,
76.Nm EC_GROUP_check_discriminant ,
77.Nm EC_GROUP_cmp ,
78.Nm EC_GROUP_get_basis_type
79.Nd manipulate EC_GROUP objects
80.Sh SYNOPSIS
81.In openssl/ec.h
82.In openssl/bn.h
83.Ft int
84.Fo EC_GROUP_copy
85.Fa "EC_GROUP *dst"
86.Fa "const EC_GROUP *src"
87.Fc
88.Ft EC_GROUP *
89.Fo EC_GROUP_dup
90.Fa "const EC_GROUP *src"
91.Fc
92.Ft int
93.Fo EC_GROUP_set_generator
94.Fa "EC_GROUP *group"
95.Fa "const EC_POINT *generator"
96.Fa "const BIGNUM *order"
97.Fa "const BIGNUM *cofactor"
98.Fc
99.Ft const EC_POINT *
100.Fo EC_GROUP_get0_generator
101.Fa "const EC_GROUP *group"
102.Fc
103.Ft int
104.Fo EC_GROUP_get_order
105.Fa "const EC_GROUP *group"
106.Fa "BIGNUM *order"
107.Fa "BN_CTX *ctx"
108.Fc
109.Ft int
110.Fo EC_GROUP_order_bits
111.Fa "const EC_GROUP *group"
112.Fc
113.Ft int
114.Fo EC_GROUP_get_cofactor
115.Fa "const EC_GROUP *group"
116.Fa "BIGNUM *cofactor"
117.Fa "BN_CTX *ctx"
118.Fc
119.Ft void
120.Fo EC_GROUP_set_curve_name
121.Fa "EC_GROUP *group"
122.Fa "int nid"
123.Fc
124.Ft int
125.Fo EC_GROUP_get_curve_name
126.Fa "const EC_GROUP *group"
127.Fc
128.Ft void
129.Fo EC_GROUP_set_asn1_flag
130.Fa "EC_GROUP *group"
131.Fa "int flag"
132.Fc
133.Ft int
134.Fo EC_GROUP_get_asn1_flag
135.Fa "const EC_GROUP *group"
136.Fc
137.Ft void
138.Fo EC_GROUP_set_point_conversion_form
139.Fa "EC_GROUP *group"
140.Fa "point_conversion_form_t form"
141.Fc
142.Ft point_conversion_form_t
143.Fo EC_GROUP_get_point_conversion_form
144.Fa "const EC_GROUP *"
145.Fc
146.Ft unsigned char *
147.Fo EC_GROUP_get0_seed
148.Fa "const EC_GROUP *x"
149.Fc
150.Ft size_t
151.Fo EC_GROUP_get_seed_len
152.Fa "const EC_GROUP *"
153.Fc
154.Ft size_t
155.Fo EC_GROUP_set_seed
156.Fa "EC_GROUP *"
157.Fa "const unsigned char *"
158.Fa "size_t len"
159.Fc
160.Ft int
161.Fo EC_GROUP_get_degree
162.Fa "const EC_GROUP *group"
163.Fc
164.Ft int
165.Fo EC_GROUP_check
166.Fa "const EC_GROUP *group"
167.Fa "BN_CTX *ctx"
168.Fc
169.Ft int
170.Fo EC_GROUP_check_discriminant
171.Fa "const EC_GROUP *group"
172.Fa "BN_CTX *ctx"
173.Fc
174.Ft int
175.Fo EC_GROUP_cmp
176.Fa "const EC_GROUP *a"
177.Fa "const EC_GROUP *b"
178.Fa "BN_CTX *ctx"
179.Fc
180.Ft int
181.Fo EC_GROUP_get_basis_type
182.Fa "const EC_GROUP *"
183.Fc
184.Sh DESCRIPTION
185These functions operate on
186.Vt EC_GROUP
187objects created by the functions described in
188.Xr EC_GROUP_new 3 .
189.Pp
190.Fn EC_GROUP_copy
191copies the curve
192.Fa src
193into
194.Fa dst .
195Both
196.Fa src
197and
198.Fa dst
199must use the same
200.Vt EC_METHOD .
201.Pp
202.Fn EC_GROUP_dup
203creates a new
204.Vt EC_GROUP
205object and copies the content from
206.Fa src
207to the newly created
208.Vt EC_GROUP
209object.
210.Pp
211.Fn EC_GROUP_set_generator
212sets curve parameters that must be agreed by all participants using
213the curve.
214These parameters include the
215.Fa generator ,
216the
217.Fa order
218and the
219.Fa cofactor .
220The
221.Fa generator
222is a well defined point on the curve chosen for cryptographic
223operations.
224Integers used for point multiplications will be between 0 and
225.Fa order No - 1 .
226The
227.Fa order
228multiplied by the
229.Fa cofactor
230gives the number of points on the curve.
231.Pp
232.Fn EC_GROUP_get0_generator
233returns the generator for the identified
234.Fa group .
235.Pp
236.Fn EC_GROUP_get_order
237retrieves the order of the
238.Fa group
239and copies its value into
240.Fa order .
241It fails if the order of the
242.Fa group
243is not set or set to zero.
244.Pp
245.Fn EC_GROUP_get_cofactor
246retrieves the cofactor of the
247.Fa group
248and copies its value into
249.Fa cofactor .
250It fails if the cofactor of the
251.Fa group
252is not set or set to zero.
253.Pp
254The functions
255.Fn EC_GROUP_set_curve_name
256and
257.Fn EC_GROUP_get_curve_name
258set and get the NID for the curve, respectively (see
259.Xr EC_GROUP_new 3 ) .
260If a curve does not have a NID associated with it, then
261.Fn EC_GROUP_get_curve_name
262will return
263.Dv NID_undef .
264.Pp
265The asn1_flag value is used to determine whether the curve encoding
266uses explicit parameters or a named curve using an ASN.1 OID:
267many applications only support the latter form.
268If asn1_flag is the default value
269.Dv OPENSSL_EC_NAMED_CURVE ,
270then the named curve form is used and the parameters must have a
271corresponding named curve NID set.
272If asn1_flags is
273.Dv OPENSSL_EC_EXPLICIT_CURVE ,
274the parameters are explicitly encoded.
275The functions
276.Fn EC_GROUP_get_asn1_flag
277and
278.Fn EC_GROUP_set_asn1_flag
279get and set the status of the asn1_flag for the curve.
280.Pp
281The point_conversion_form for a curve controls how
282.Vt EC_POINT
283data is encoded as ASN.1 as defined in X9.62 (ECDSA).
284.Vt point_conversion_form_t
285is an enum defined as follows:
286.Bd -literal
287typedef enum {
288 /** the point is encoded as z||x, where the octet z specifies
289 * which solution of the quadratic equation y is */
290 POINT_CONVERSION_COMPRESSED = 2,
291 /** the point is encoded as z||x||y, where z is the octet 0x04 */
292 POINT_CONVERSION_UNCOMPRESSED = 4,
293 /** the point is encoded as z||x||y, where the octet z specifies
294 * which solution of the quadratic equation y is */
295 POINT_CONVERSION_HYBRID = 6
296} point_conversion_form_t;
297.Ed
298.Pp
299For
300.Dv POINT_CONVERSION_UNCOMPRESSED
301the point is encoded as an octet signifying the UNCOMPRESSED form
302has been used followed by the octets for x, followed by the octets
303for y.
304.Pp
305For any given x coordinate for a point on a curve it is possible to
306derive two possible y values.
307For
308.Dv POINT_CONVERSION_COMPRESSED
309the point is encoded as an octet signifying that the COMPRESSED
310form has been used AND which of the two possible solutions for y
311has been used, followed by the octets for x.
312.Pp
313For
314.Dv POINT_CONVERSION_HYBRID
315the point is encoded as an octet signifying the HYBRID form has
316been used AND which of the two possible solutions for y has been
317used, followed by the octets for x, followed by the octets for y.
318.Pp
319The functions
320.Fn EC_GROUP_set_point_conversion_form
321and
322.Fn EC_GROUP_get_point_conversion_form
323set and get the point_conversion_form for the curve, respectively.
324.Pp
325ANSI X9.62 (ECDSA standard) defines a method of generating the curve
326parameter b from a random number.
327This provides advantages in that a parameter obtained in this way is
328highly unlikely to be susceptible to special purpose attacks, or have
329any trapdoors in it.
330If the seed is present for a curve then the b parameter was generated in
331a verifiable fashion using that seed.
332The OpenSSL EC library does not use this seed value but does enable you
333to inspect it using
334.Fn EC_GROUP_get0_seed .
335This returns a pointer to a memory block containing the seed that was
336used.
337The length of the memory block can be obtained using
338.Fn EC_GROUP_get_seed_len .
339A number of the builtin curves within the library provide seed values
340that can be obtained.
341It is also possible to set a custom seed using
342.Fn EC_GROUP_set_seed
343and passing a pointer to a memory block, along with the length of
344the seed.
345Again, the EC library will not use this seed value, although it will be
346preserved in any ASN.1 based communications.
347.Pp
348.Fn EC_GROUP_get_degree
349gets the degree of the field.
350For Fp fields this will be the number of bits in p.
351For F2^m fields this will be the value m.
352.Pp
353The function
354.Fn EC_GROUP_check_discriminant
355calculates the discriminant for the curve and verifies that it is
356valid.
357For a curve defined over Fp the discriminant is given by the formula
3584*a^3 + 27*b^2 whilst for F2^m curves the discriminant is simply b.
359In either case for the curve to be valid the discriminant must be
360non-zero.
361.Pp
362The function
363.Fn EC_GROUP_check
364performs a number of checks on a curve to verify that it is valid.
365Checks performed include verifying that the discriminant is non-zero;
366that a generator has been defined; that the generator is on the curve
367and has the correct order.
368.Pp
369.Fn EC_GROUP_cmp
370compares
371.Fa a
372and
373.Fa b
374to determine whether they represent the same curve or not.
375.Pp
376.Fn EC_GROUP_get_basis_type
377always returns 0 and is only provided for compatibility.
378.Sh RETURN VALUES
379The following functions return 1 on success or 0 on error:
380.Fn EC_GROUP_copy ,
381.Fn EC_GROUP_set_generator ,
382.Fn EC_GROUP_check ,
383and
384.Fn EC_GROUP_check_discriminant .
385.Pp
386.Fn EC_GROUP_dup
387returns a pointer to the duplicated curve or
388.Dv NULL
389on error.
390.Pp
391.Fn EC_GROUP_get0_generator
392returns the generator for the given curve or
393.Dv NULL
394on error.
395.Pp
396.Fn EC_GROUP_get_order
397returns 0 if the order is not set or set to zero for the
398.Fa group
399or if copying into
400.Fa order
401fails, or 1 otherwise.
402.Pp
403.Fn EC_GROUP_order_bits
404returns the number of bits in the group order.
405.Pp
406.Fn EC_GROUP_get_cofactor
407returns 0 if the cofactor is not set or set to zero for the
408.Fa group
409or if copying into
410.Fa cofactor
411fails, or 1 otherwise.
412.Pp
413.Fn EC_GROUP_get_curve_name
414returns the curve name (NID) for the
415.Fa group
416or
417.Dv NID_undef
418if no curve name is associated.
419.Pp
420.Fn EC_GROUP_get_asn1_flag
421returns the ASN.1 flag for the specified
422.Fa group .
423.Pp
424.Fn EC_GROUP_get_point_conversion_form
425returns the point_conversion_form for the
426.Fa group .
427.Pp
428.Fn EC_GROUP_get_degree
429returns the degree for the
430.Fa group
431or 0 if the operation is not supported
432by the underlying group implementation.
433.Pp
434.Fn EC_GROUP_get0_seed
435returns a pointer to the seed that was used to generate the parameter
436b, or
437.Dv NULL
438if the seed is not specified.
439.Fn EC_GROUP_get_seed_len
440returns the length of the seed or 0 if the seed is not specified.
441.Pp
442.Fn EC_GROUP_set_seed
443returns the length of the seed that has been set.
444If the supplied seed is
445.Dv NULL
446or the supplied seed length is 0, the return value will be 1.
447On error 0 is returned.
448.Pp
449.Fn EC_GROUP_cmp
450returns 0 if the curves are equal, 1 if they are not equal,
451or -1 on error.
452.Pp
453.Fn EC_GROUP_get_basis_type
454always returns 0.
455.Sh SEE ALSO
456.Xr d2i_ECPKParameters 3 ,
457.Xr EC_GROUP_new 3 ,
458.Xr EC_KEY_new 3 ,
459.Xr EC_POINT_add 3 ,
460.Xr EC_POINT_new 3
461.Sh HISTORY
462.Fn EC_GROUP_copy ,
463.Fn EC_GROUP_set_generator ,
464.Fn EC_GROUP_get0_generator ,
465.Fn EC_GROUP_get_order ,
466and
467.Fn EC_GROUP_get_cofactor
468first appeared in OpenSSL 0.9.7 and have been available since
469.Ox 3.2 .
470.Pp
471.Fn EC_GROUP_dup ,
472.Fn EC_GROUP_set_curve_name ,
473.Fn EC_GROUP_get_curve_name ,
474.Fn EC_GROUP_set_asn1_flag ,
475.Fn EC_GROUP_get_asn1_flag ,
476.Fn EC_GROUP_set_point_conversion_form ,
477.Fn EC_GROUP_get_point_conversion_form ,
478.Fn EC_GROUP_get0_seed ,
479.Fn EC_GROUP_get_seed_len ,
480.Fn EC_GROUP_set_seed ,
481.Fn EC_GROUP_get_degree ,
482.Fn EC_GROUP_check ,
483.Fn EC_GROUP_check_discriminant ,
484.Fn EC_GROUP_cmp ,
485and
486.Fn EC_GROUP_get_basis_type
487first appeared in OpenSSL 0.9.8 and have been available since
488.Ox 4.5 .
489.Pp
490.Fn EC_GROUP_order_bits
491first appeared in OpenSSL 1.1.0 and has been available since
492.Ox 7.0 .
diff --git a/src/lib/libcrypto/man/EC_GROUP_new.3 b/src/lib/libcrypto/man/EC_GROUP_new.3
deleted file mode 100644
index 83e3e4c870..0000000000
--- a/src/lib/libcrypto/man/EC_GROUP_new.3
+++ /dev/null
@@ -1,353 +0,0 @@
1.\" $OpenBSD: EC_GROUP_new.3,v 1.18 2025/03/08 16:38:13 tb Exp $
2.\" OpenSSL 6328d367 Sat Jul 4 21:58:30 2020 +0200
3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>.
5.\" Copyright (c) 2013 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 8 2025 $
52.Dt EC_GROUP_NEW 3
53.Os
54.Sh NAME
55.Nm EC_GROUP_new ,
56.Nm EC_GROUP_free ,
57.Nm EC_GROUP_clear_free ,
58.Nm EC_GROUP_new_curve_GFp ,
59.Nm EC_GROUP_new_by_curve_name ,
60.Nm EC_GROUP_set_curve ,
61.Nm EC_GROUP_get_curve ,
62.Nm EC_GROUP_set_curve_GFp ,
63.Nm EC_GROUP_get_curve_GFp ,
64.Nm EC_get_builtin_curves ,
65.Nm EC_curve_nid2nist ,
66.Nm EC_curve_nist2nid
67.Nd create and destroy EC_GROUP objects
68.Sh SYNOPSIS
69.In openssl/ec.h
70.In openssl/bn.h
71.Ft EC_GROUP *
72.Fo EC_GROUP_new
73.Fa "const EC_METHOD *meth"
74.Fc
75.Ft void
76.Fo EC_GROUP_free
77.Fa "EC_GROUP *group"
78.Fc
79.Ft void
80.Fo EC_GROUP_clear_free
81.Fa "EC_GROUP *group"
82.Fc
83.Ft EC_GROUP *
84.Fo EC_GROUP_new_curve_GFp
85.Fa "const BIGNUM *p"
86.Fa "const BIGNUM *a"
87.Fa "const BIGNUM *b"
88.Fa "BN_CTX *ctx"
89.Fc
90.Ft EC_GROUP *
91.Fo EC_GROUP_new_by_curve_name
92.Fa "int nid"
93.Fc
94.Ft int
95.Fo EC_GROUP_set_curve
96.Fa "EC_GROUP *group"
97.Fa "const BIGNUM *p"
98.Fa "const BIGNUM *a"
99.Fa "const BIGNUM *b"
100.Fa "BN_CTX *ctx"
101.Fc
102.Ft int
103.Fo EC_GROUP_get_curve
104.Fa "const EC_GROUP *group"
105.Fa "BIGNUM *p"
106.Fa "BIGNUM *a"
107.Fa "BIGNUM *b"
108.Fa "BN_CTX *ctx"
109.Fc
110.Ft int
111.Fo EC_GROUP_set_curve_GFp
112.Fa "EC_GROUP *group"
113.Fa "const BIGNUM *p"
114.Fa "const BIGNUM *a"
115.Fa "const BIGNUM *b"
116.Fa "BN_CTX *ctx"
117.Fc
118.Ft int
119.Fo EC_GROUP_get_curve_GFp
120.Fa "const EC_GROUP *group"
121.Fa "BIGNUM *p"
122.Fa "BIGNUM *a"
123.Fa "BIGNUM *b"
124.Fa "BN_CTX *ctx"
125.Fc
126.Ft size_t
127.Fo EC_get_builtin_curves
128.Fa "EC_builtin_curve *r"
129.Fa "size_t nitems"
130.Fc
131.Ft "const char *"
132.Fo EC_curve_nid2nist
133.Fa "int nid"
134.Fc
135.Ft int
136.Fo EC_curve_nist2nid
137.Fa "const char *name"
138.Fc
139.Sh DESCRIPTION
140The EC library provides functions for performing operations on
141elliptic curves in Weierstrass form.
142Such curves are defined over the prime field of order
143.Fa p
144and satisfy the Weierstrass equation with coefficients
145.Fa a
146and
147.Fa b
148.Pp
149.Dl y^2 = x^3 + ax + b
150.Pp
151An
152.Vt EC_GROUP
153structure is used to represent the definition of an elliptic curve.
154A new curve can be constructed by calling
155.Fn EC_GROUP_new ,
156using the implementation provided by
157.Fa meth .
158It is then necessary to call
159.Fn EC_GROUP_set_curve
160to set the curve parameters.
161.Pp
162.Fn EC_GROUP_set_curve
163sets the curve parameters
164.Fa p ,
165.Fa a ,
166and
167.Fa b ,
168where
169.Fa a
170and
171.Fa b
172represent the coefficients of the curve equation.
173.Pp
174.Fn EC_GROUP_set_curve_GFp
175is a deprecated synonym for
176.Fn EC_GROUP_set_curve .
177.Pp
178.Fn EC_GROUP_get_curve
179obtains the previously set curve parameters.
180.Pp
181.Fn EC_GROUP_get_curve_GFp
182is a deprecated synonym for
183.Fn EC_GROUP_get_curve .
184.Pp
185The function
186.Fn EC_GROUP_new_curve_GFp
187is a shortcut for calling
188.Fn EC_GROUP_new
189and
190.Fn EC_GROUP_set_curve .
191An appropriate default implementation method will be used.
192.Pp
193Whilst the library can be used to create any curve using the functions
194described above, there are also a number of predefined curves that are
195available.
196In order to obtain a list of all of the predefined curves, call the
197function
198.Fn EC_get_builtin_curves .
199The parameter
200.Fa r
201should be an array of
202.Vt EC_builtin_cure
203structures of size
204.Fa nitems .
205The function will populate the
206.Fa r
207array with information about the builtin curves.
208If
209.Fa nitems
210is less than the total number of curves available, then the first
211.Fa nitems
212curves will be returned.
213Otherwise the total number of curves will be provided.
214The return value is the total number of curves available (whether that
215number has been populated in
216.Fa r
217or not).
218Passing a
219.Dv NULL
220.Fa r ,
221or setting
222.Fa nitems
223to 0, will do nothing other than return the total number of curves
224available.
225The
226.Vt EC_builtin_curve
227structure is defined as follows:
228.Bd -literal
229typedef struct {
230 int nid;
231 const char *comment;
232} EC_builtin_curve;
233.Ed
234.Pp
235Each
236.Vt EC_builtin_curve
237item has a unique integer ID
238.Pq Fa nid
239and a human readable comment string describing the curve.
240.Pp
241In order to construct a builtin curve, use the function
242.Fn EC_GROUP_new_by_curve_name
243and provide the
244.Fa nid
245of the curve to be constructed.
246.Pp
247.Fn EC_GROUP_free
248frees the memory associated with the
249.Vt EC_GROUP .
250If
251.Fa group
252is a
253.Dv NULL
254pointer, no action occurs.
255.Pp
256.Fn EC_GROUP_clear_free
257destroys any sensitive data held within the
258.Vt EC_GROUP
259and then frees its memory.
260If
261.Fa group
262is a
263.Dv NULL
264pointer, no action occurs.
265.Pp
266Some builtin curves can be identified by their NIST name
267in addition to a numerical identifier (NID).
268.Fn EC_curve_nid2nist
269and
270.Fn EC_curve_nist2nid
271translate between the two.
272The five built-in prime curves are:
273.Pp
274.Bl -column "NIST name" NID_X9_62_prime256v1 "deprecated in SP800-186" -compact
275.It No NIST Fa name Ta Em ASN.1 NID Ta Em notes
276.It Qq P-192 Ta Dv NID_X9_62_prime192v1 Ta No deprecated in SP800-186
277.It Qq P-224 Ta Dv NID_secp224r1 Ta
278.It Qq P-256 Ta Dv NID_X9_62_prime256v1 Ta
279.It Qq P-384 Ta Dv NID_secp384r1 Ta
280.It Qq P-521 Ta Dv NID_secp521r1 Ta
281.El
282.Pp
283.Fn EC_curve_nid2nist
284and
285.Fn EC_curve_nist2nid
286also accept the ten binary curves defined in FIPS\& 186-4
287and deprecated in SP800-186,
288although they no longer correspond to builtin curves in LibreSSL.
289.Sh RETURN VALUES
290All
291.Fn EC_GROUP_new*
292functions return a pointer to the newly constructed group or
293.Dv NULL
294on error.
295.Pp
296.Fn EC_get_builtin_curves
297returns the number of builtin curves that are available.
298.Pp
299.Fn EC_curve_nid2nist
300returns a string constant containing the NIST name if
301.Fa nid
302identifies a NIST curve or
303.Dv NULL
304otherwise.
305.Pp
306.Fn EC_curve_nist2nid
307returns the NID corresponding to the NIST curve
308.Fa name ,
309or
310.Dv NID_undef .
311.Pp
312.Fn EC_GROUP_set_curve ,
313.Fn EC_GROUP_get_curve ,
314.Fn EC_GROUP_set_curve_GFp ,
315and
316.Fn EC_GROUP_get_curve_GFp
317return 1 on success or 0 on error.
318.Sh SEE ALSO
319.Xr crypto 3 ,
320.Xr d2i_ECPKParameters 3 ,
321.Xr EC_GROUP_copy 3 ,
322.Xr EC_KEY_new 3 ,
323.Xr EC_POINT_add 3 ,
324.Xr EC_POINT_new 3 ,
325.Xr ECDH_compute_key 3 ,
326.Xr ECDSA_SIG_new 3
327.Sh HISTORY
328.Fn EC_GROUP_new ,
329.Fn EC_GROUP_free ,
330.Fn EC_GROUP_clear_free ,
331.Fn EC_GROUP_new_curve_GFp ,
332.Fn EC_GROUP_set_curve_GFp ,
333and
334.Fn EC_GROUP_get_curve_GFp
335first appeared in OpenSSL 0.9.7 and have been available since
336.Ox 3.2 .
337.Pp
338.Fn EC_GROUP_new_by_curve_name
339and
340.Fn EC_get_builtin_curves
341first appeared in OpenSSL 0.9.8 and have been available since
342.Ox 4.5 .
343.Fn EC_curve_nid2nist ,
344and
345.Fn EC_curve_nist2nid
346first appeared in OpenSSL 1.1.0 and have been available since
347.Ox 5.8 .
348.Pp
349.Fn EC_GROUP_set_curve
350and
351.Fn EC_GROUP_get_curve
352first appeared in OpenSSL 1.1.1 and have been available since
353.Ox 7.0 .
diff --git a/src/lib/libcrypto/man/EC_KEY_METHOD_new.3 b/src/lib/libcrypto/man/EC_KEY_METHOD_new.3
deleted file mode 100644
index 79c16ef014..0000000000
--- a/src/lib/libcrypto/man/EC_KEY_METHOD_new.3
+++ /dev/null
@@ -1,320 +0,0 @@
1.\" $OpenBSD: EC_KEY_METHOD_new.3,v 1.4 2024/07/21 08:36:43 tb Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\"
4.\" Permission to use, copy, modify, and distribute this software for any
5.\" purpose with or without fee is hereby granted, provided that the above
6.\" copyright notice and this permission notice appear in all copies.
7.\"
8.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\"
16.Dd $Mdocdate: July 21 2024 $
17.Dt EC_KEY_METHOD_NEW 3
18.Os
19.Sh NAME
20.Nm EC_KEY_METHOD_new ,
21.Nm EC_KEY_METHOD_free ,
22.Nm EC_KEY_METHOD_set_init ,
23.Nm EC_KEY_METHOD_get_init ,
24.Nm EC_KEY_METHOD_set_sign ,
25.Nm EC_KEY_METHOD_get_sign ,
26.Nm EC_KEY_METHOD_set_verify ,
27.Nm EC_KEY_METHOD_get_verify ,
28.Nm EC_KEY_METHOD_set_keygen ,
29.Nm EC_KEY_METHOD_get_keygen ,
30.Nm EC_KEY_METHOD_set_compute_key ,
31.Nm EC_KEY_METHOD_get_compute_key ,
32.Nm EC_KEY_OpenSSL ,
33.Nm EC_KEY_set_default_method ,
34.Nm EC_KEY_get_default_method ,
35.Nm EC_KEY_new_method ,
36.Nm EC_KEY_set_method ,
37.Nm EC_KEY_get_method
38.Nd custom EC_KEY implementations
39.Sh SYNOPSIS
40.In openssl/ec.h
41.Ft EC_KEY_METHOD *
42.Fo EC_KEY_METHOD_new
43.Fa "const EC_KEY_METHOD *meth"
44.Fc
45.Ft void
46.Fo EC_KEY_METHOD_free
47.Fa "EC_KEY_METHOD *meth"
48.Fc
49.Ft void
50.Fo EC_KEY_METHOD_set_init
51.Fa "EC_KEY_METHOD *meth"
52.Fa "int (*init)(EC_KEY *key)"
53.Fa "void (*finish)(EC_KEY *key)"
54.Fa "int (*copy)(EC_KEY *dest, const EC_KEY *src)"
55.Fa "int (*set_group)(EC_KEY *key, const EC_GROUP *grp)"
56.Fa "int (*set_private)(EC_KEY *key, const BIGNUM *priv_key)"
57.Fa "int (*set_public)(EC_KEY *key, const EC_POINT *pub_key)"
58.Fc
59.Ft void
60.Fo EC_KEY_METHOD_get_init
61.Fa "const EC_KEY_METHOD *meth"
62.Fa "int (**pinit)(EC_KEY *key)"
63.Fa "void (**pfinish)(EC_KEY *key)"
64.Fa "int (**pcopy)(EC_KEY *dest, const EC_KEY *src)"
65.Fa "int (**pset_group)(EC_KEY *key, const EC_GROUP *grp)"
66.Fa "int (**pset_private)(EC_KEY *key, const BIGNUM *priv_key)"
67.Fa "int (**pset_public)(EC_KEY *key, const EC_POINT *pub_key)"
68.Fc
69.Ft void
70.Fo EC_KEY_METHOD_set_sign
71.Fa "EC_KEY_METHOD *meth"
72.Fa "int (*sign)(int type, const unsigned char *dgst, int dgstlen,\
73 unsigned char *sig, unsigned int *siglen,\
74 const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey)"
75.Fa "int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx,\
76 BIGNUM **kinv, BIGNUM **rp)"
77.Fa "ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgstlen,\
78 const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey)"
79.Fc
80.Ft void
81.Fo EC_KEY_METHOD_get_sign
82.Fa "const EC_KEY_METHOD *meth"
83.Fa "int (**psign)(int type, const unsigned char *dgst, int dgstlen,\
84 unsigned char *sig, unsigned int *siglen,\
85 const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey)"
86.Fa "int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx,\
87 BIGNUM **kinv, BIGNUM **rp)"
88.Fa "ECDSA_SIG *(**psign_sig)(const unsigned char *dgst, int dgstlen,\
89 const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey)"
90.Fc
91.Ft void
92.Fo EC_KEY_METHOD_set_verify
93.Fa "EC_KEY_METHOD *meth"
94.Fa "int (*verify)(int type, const unsigned char *dgst, int dgst_len,\
95 const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)"
96.Fa "int (*verify_sig)(const unsigned char *dgst, int dgst_len,\
97 const ECDSA_SIG *sig, EC_KEY *eckey)"
98.Fc
99.Ft void
100.Fo EC_KEY_METHOD_get_verify
101.Fa "const EC_KEY_METHOD *meth"
102.Fa "int (**pverify)(int type, const unsigned char *dgst, int dgst_len,\
103 const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)"
104.Fa "int (**pverify_sig)(const unsigned char *dgst, int dgst_len,\
105 const ECDSA_SIG *sig, EC_KEY *eckey)"
106.Fc
107.Ft void
108.Fo EC_KEY_METHOD_set_keygen
109.Fa "EC_KEY_METHOD *meth"
110.Fa "int (*keygen)(EC_KEY *key)"
111.Fc
112.Ft void
113.Fo EC_KEY_METHOD_get_keygen
114.Fa "const EC_KEY_METHOD *meth"
115.Fa "int (**pkeygen)(EC_KEY *key)"
116.Fc
117.Ft void
118.Fo EC_KEY_METHOD_set_compute_key
119.Fa "EC_KEY_METHOD *meth"
120.Fa "int (*ckey)(void *out, size_t outlen,\
121 const EC_POINT *pub_key, EC_KEY *ecdh,\
122 void *(*KDF) (const void *in, size_t inlen, void *out, size_t *outlen))"
123.Fc
124.Ft void
125.Fo EC_KEY_METHOD_get_compute_key
126.Fa "const EC_KEY_METHOD *meth"
127.Fa "int (**pck)(void *out, size_t outlen,\
128 const EC_POINT *pub_key, EC_KEY *ecdh,\
129 void *(*KDF) (const void *in, size_t inlen, void *out, size_t *outlen))"
130.Fc
131.Ft const EC_KEY_METHOD *
132.Fn EC_KEY_OpenSSL void
133.Ft void
134.Fo EC_KEY_set_default_method
135.Fa "const EC_KEY_METHOD *meth"
136.Fc
137.Ft const EC_KEY_METHOD *
138.Fn EC_KEY_get_default_method void
139.Ft EC_KEY *
140.Fo EC_KEY_new_method
141.Fa "ENGINE *engine"
142.Fc
143.Ft int
144.Fo EC_KEY_set_method
145.Fa "EC_KEY *key"
146.Fa "const EC_KEY_METHOD *meth"
147.Fc
148.Ft const EC_KEY_METHOD *
149.Fo EC_KEY_get_method
150.Fa "const EC_KEY *key"
151.Fc
152.Sh DESCRIPTION
153An
154.Vt EC_KEY_METHOD
155object holds function pointers used for
156.Vt EC_KEY
157operations.
158.Pp
159.Fn EC_KEY_METHOD_new
160creates a shallow copy of
161.Fa meth ,
162or an empty
163.Vt EC_KEY_METHOD
164object if
165.Fa meth
166is
167.Dv NULL .
168.Pp
169.Fn EC_KEY_METHOD_free
170frees
171.Fa meth .
172If
173.Fa meth
174is
175.Dv NULL
176or the return value of
177.Fn EC_KEY_OpenSSL ,
178no action occurs.
179.Pp
180.Fn EC_KEY_METHOD_set_init
181and
182.Fn EC_KEY_METHOD_get_init
183set and retrieve optional callback functions called at the following places:
184.Pp
185.Bl -tag -width set_private -compact
186.It Fa init
187at the end of
188.Fn EC_KEY_new_method
189and
190.Fn EC_KEY_set_method
191.It Fa finish
192at the beginning of
193.Xr EC_KEY_free 3 ,
194.Xr EC_KEY_copy 3 ,
195and
196.Fn EC_KEY_set_method
197.It Fa copy
198at the end of
199.Xr EC_KEY_copy 3
200.It Fa set_group
201at the end of
202.Xr EC_KEY_set_group 3
203and
204.Xr EC_KEY_new_by_curve_name 3
205.It Fa set_private
206at the beginning of
207.Xr EC_KEY_set_private_key 3
208.It Fa set_public
209at the beginning of
210.Xr EC_KEY_set_public_key 3
211.El
212.Pp
213If any of these callbacks returns 0, the calling function fails.
214By default, all these callbacks are
215.Dv NULL .
216Arguments of
217.Fn EC_KEY_METHOD_get_init
218can be set to
219.Dv NULL
220to selectively retrieve callback function pointers.
221.Pp
222.Fn EC_KEY_METHOD_set_sign
223and
224.Fn EC_KEY_METHOD_get_sign
225set and retrieve the functions implementing
226.Xr ECDSA_sign 3
227and
228.Xr ECDSA_do_sign 3 .
229.Pp
230.Fn EC_KEY_METHOD_set_verify
231and
232.Fn EC_KEY_METHOD_get_verify
233set and retrieve the functions implementing
234.Xr ECDSA_verify 3
235and
236.Xr ECDSA_do_verify 3 .
237.Pp
238.Fn EC_KEY_METHOD_set_keygen
239and
240.Fn EC_KEY_METHOD_get_keygen
241set and retrieve the function implementing
242.Xr EC_KEY_generate_key 3 .
243.Pp
244.Fn EC_KEY_METHOD_set_compute_key
245and
246.Fn EC_KEY_METHOD_get_compute_key
247set and retrieve the function implementing
248.Xr ECDH_compute_key 3 .
249.Pp
250.Fn EC_KEY_set_default_method
251chooses the
252.Fa meth
253to be used for the creation of new
254.Vt EC_KEY
255objects by future invocations of
256.Fn EC_KEY_new_method ,
257or reverts to the default implementation if
258.Fa meth
259is
260.Dv NULL .
261.Pp
262.Fn EC_KEY_new_method
263creates and initializes a new
264.Vt EC_KEY
265object using the
266.Vt EC_KEY_METHOD
267set with
268.Fn EC_KEY_set_default_method .
269The
270.Fa ENGINE *engine
271argument is always ignored and passing
272.Dv NULL
273is recommended.
274.Pp
275.Fn EC_KEY_set_method
276dissociates the
277.Fa key
278from the
279.Vt ENGINE
280it is using, if any, and causes it to use
281.Fa meth
282in the future.
283.Sh RETURN VALUES
284.Fn EC_KEY_METHOD_new
285returns the newly allocated
286.Vt EC_KEY_METHOD
287object or
288.Dv NULL
289if an error occurs.
290.Pp
291.Fn EC_KEY_OpenSSL
292returns a static object representing the default EC_KEY implementation.
293.Pp
294.Fn EC_KEY_get_default_method
295returns the
296.Vt EC_KEY_METHOD
297that
298.Fn EC_KEY_new_method
299will use for the creation of new
300.Vt EC_KEY
301objects in the future.
302.Pp
303.Fn EC_KEY_new_method
304returns the newly allocated
305.Vt EC_KEY
306object or NULL if an error occurs.
307.Pp
308.Fn EC_KEY_set_method
309returns 1 for success or 0 for failure.
310.Pp
311.Fn EC_KEY_get_method
312returns the EC_KEY implementation used by the given
313.Fa key .
314.Sh SEE ALSO
315.Xr EC_KEY_new 3 ,
316.Xr ECDSA_sign 3
317.Sh HISTORY
318These functions first appeared in OpenSSL 1.1.0
319and have been available since
320.Ox 6.5 .
diff --git a/src/lib/libcrypto/man/EC_KEY_new.3 b/src/lib/libcrypto/man/EC_KEY_new.3
deleted file mode 100644
index c24cb080ef..0000000000
--- a/src/lib/libcrypto/man/EC_KEY_new.3
+++ /dev/null
@@ -1,532 +0,0 @@
1.\" $OpenBSD: EC_KEY_new.3,v 1.21 2025/03/08 16:38:13 tb Exp $
2.\" full merge up to: OpenSSL 3aef36ff Jan 5 13:06:03 2016 -0500
3.\" partial merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
4.\"
5.\" This file was written by Matt Caswell <matt@openssl.org>.
6.\" Copyright (c) 2013, 2014 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: March 8 2025 $
53.Dt EC_KEY_NEW 3
54.Os
55.Sh NAME
56.Nm EC_KEY_new ,
57.Nm EC_KEY_get_flags ,
58.Nm EC_KEY_set_flags ,
59.Nm EC_KEY_clear_flags ,
60.Nm EC_KEY_new_by_curve_name ,
61.Nm EC_KEY_free ,
62.Nm EC_KEY_copy ,
63.Nm EC_KEY_dup ,
64.Nm EC_KEY_up_ref ,
65.Nm EC_KEY_get0_group ,
66.Nm EC_KEY_set_group ,
67.Nm EC_KEY_get0_private_key ,
68.Nm EC_KEY_set_private_key ,
69.Nm EC_KEY_get0_public_key ,
70.Nm EC_KEY_set_public_key ,
71.Nm EC_KEY_get_enc_flags ,
72.Nm EC_KEY_set_enc_flags ,
73.Nm EC_KEY_get_conv_form ,
74.Nm EC_KEY_set_conv_form ,
75.Nm EC_KEY_set_asn1_flag ,
76.Nm EC_KEY_precompute_mult ,
77.Nm EC_KEY_generate_key ,
78.Nm EC_KEY_check_key ,
79.Nm EC_KEY_set_public_key_affine_coordinates ,
80.Nm EC_KEY_print ,
81.Nm EC_KEY_print_fp
82.Nd create, destroy and manipulate EC_KEY objects
83.Sh SYNOPSIS
84.In openssl/ec.h
85.In openssl/bn.h
86.Ft EC_KEY *
87.Fn EC_KEY_new void
88.Ft int
89.Fo EC_KEY_get_flags
90.Fa "const EC_KEY *key"
91.Fc
92.Ft void
93.Fo EC_KEY_set_flags
94.Fa "EC_KEY *key"
95.Fa "int flags"
96.Fc
97.Ft void
98.Fo EC_KEY_clear_flags
99.Fa "EC_KEY *key"
100.Fa "int flags"
101.Fc
102.Ft EC_KEY *
103.Fo EC_KEY_new_by_curve_name
104.Fa "int nid"
105.Fc
106.Ft void
107.Fo EC_KEY_free
108.Fa "EC_KEY *key"
109.Fc
110.Ft EC_KEY *
111.Fo EC_KEY_copy
112.Fa "EC_KEY *dst"
113.Fa "const EC_KEY *src"
114.Fc
115.Ft EC_KEY *
116.Fo EC_KEY_dup
117.Fa "const EC_KEY *src"
118.Fc
119.Ft int
120.Fo EC_KEY_up_ref
121.Fa "EC_KEY *key"
122.Fc
123.Ft const EC_GROUP *
124.Fo EC_KEY_get0_group
125.Fa "const EC_KEY *key"
126.Fc
127.Ft int
128.Fo EC_KEY_set_group
129.Fa "EC_KEY *key"
130.Fa "const EC_GROUP *group"
131.Fc
132.Ft const BIGNUM *
133.Fo EC_KEY_get0_private_key
134.Fa "const EC_KEY *key"
135.Fc
136.Ft int
137.Fo EC_KEY_set_private_key
138.Fa "EC_KEY *key"
139.Fa "const BIGNUM *prv"
140.Fc
141.Ft const EC_POINT *
142.Fo EC_KEY_get0_public_key
143.Fa "const EC_KEY *key"
144.Fc
145.Ft int
146.Fo EC_KEY_set_public_key
147.Fa "EC_KEY *key"
148.Fa "const EC_POINT *pub"
149.Fc
150.Ft unsigned int
151.Fo EC_KEY_get_enc_flags
152.Fa "const EC_KEY *key"
153.Fc
154.Ft void
155.Fo EC_KEY_set_enc_flags
156.Fa "EC_KEY *key"
157.Fa "unsigned int flags"
158.Fc
159.Ft point_conversion_form_t
160.Fo EC_KEY_get_conv_form
161.Fa "const EC_KEY *key"
162.Fc
163.Ft void
164.Fo EC_KEY_set_conv_form
165.Fa "EC_KEY *key"
166.Fa "point_conversion_form_t cform"
167.Fc
168.Ft void
169.Fo EC_KEY_set_asn1_flag
170.Fa "EC_KEY *key"
171.Fa "int asn1_flag"
172.Fc
173.Ft int
174.Fo EC_KEY_precompute_mult
175.Fa "EC_KEY *key"
176.Fa "BN_CTX *ctx"
177.Fc
178.Ft int
179.Fo EC_KEY_generate_key
180.Fa "EC_KEY *key"
181.Fc
182.Ft int
183.Fo EC_KEY_check_key
184.Fa "const EC_KEY *key"
185.Fc
186.Ft int
187.Fo EC_KEY_set_public_key_affine_coordinates
188.Fa "EC_KEY *key"
189.Fa "BIGNUM *x"
190.Fa "BIGNUM *y"
191.Fc
192.Ft int
193.Fo EC_KEY_print
194.Fa "BIO *bp"
195.Fa "const EC_KEY *key"
196.Fa "int off"
197.Fc
198.Ft int
199.Fo EC_KEY_print_fp
200.Fa "FILE *fp"
201.Fa "const EC_KEY *key"
202.Fa "int off"
203.Fc
204.Sh DESCRIPTION
205An
206.Vt EC_KEY
207represents a public key and (optionally) an associated private key.
208The public key is a point on a curve represented by an
209.Vt EC_POINT ,
210see
211.Xr EC_POINT_new 3 .
212The private key is simply a
213.Vt BIGNUM ,
214see
215.Xr BN_new 3 .
216.Pp
217A new
218.Vt EC_KEY
219(with no associated curve) can be constructed by calling
220.Fn EC_KEY_new .
221The reference count for the newly created
222.Vt EC_KEY
223is initially set to 1.
224A curve can be associated with the
225.Vt EC_KEY
226by calling
227.Fn EC_KEY_set_group .
228.Pp
229Alternatively a new
230.Vt EC_KEY
231can be constructed by calling
232.Fn EC_KEY_new_by_curve_name
233and supplying the
234.Fa nid
235of the associated curve.
236Refer to
237.Xr EC_GROUP_new 3
238for a description of curve names.
239This function simply wraps calls to
240.Fn EC_KEY_new
241and
242.Fn EC_GROUP_new_by_curve_name .
243.Pp
244Calling
245.Fn EC_KEY_free
246decrements the reference count for the
247.Vt EC_KEY
248object and, if it has dropped to zero, then frees the memory associated
249with it.
250If
251.Fa key
252is a
253.Dv NULL
254pointer, no action occurs.
255.Pp
256.Fn EC_KEY_copy
257copies the contents of the
258.Vt EC_KEY
259in
260.Fa src
261into
262.Fa dst .
263.Pp
264.Fn EC_KEY_dup
265creates a new
266.Vt EC_KEY
267object and copies
268.Fa src
269into it.
270.Pp
271.Fn EC_KEY_up_ref
272increments the reference count associated with the
273.Vt EC_KEY
274object.
275.Pp
276.Fn EC_KEY_generate_key
277generates a new public and private key for the supplied
278.Fa key
279object.
280.Fa key
281must have an
282.Vt EC_GROUP
283object associated with it before calling this function.
284The private key is a random integer (0 < priv_key < order, where order
285is the order of the
286.Vt EC_GROUP
287object).
288The public key is an
289.Vt EC_POINT
290on the curve calculated by multiplying the generator for the curve
291by the private key.
292.Pp
293.Fn EC_KEY_check_key
294performs various sanity checks on the
295.Vt EC_KEY
296object to confirm that it is valid.
297.Pp
298.Fn EC_KEY_set_public_key_affine_coordinates
299sets the public key for
300.Fa key
301based on its affine coordinates, i.e. it constructs an
302.Vt EC_POINT
303object based on the supplied
304.Fa x
305and
306.Fa y
307values and sets the public key to be this
308.Vt EC_POINT .
309It also performs certain sanity checks on the key to confirm that
310it is valid.
311.Pp
312The functions
313.Fn EC_KEY_get0_group ,
314.Fn EC_KEY_set_group ,
315.Fn EC_KEY_get0_private_key ,
316.Fn EC_KEY_set_private_key ,
317.Fn EC_KEY_get0_public_key ,
318and
319.Fn EC_KEY_set_public_key
320get and set the
321.Vt EC_GROUP
322object, the private key and the
323.Vt EC_POINT
324public key for the
325.Fa key ,
326respectively.
327The setters copy the group and key objects without sanity checks
328and it is the caller's responsibility to ensure that
329the resulting key is valid, for example using
330.Fn EC_KEY_check_key .
331.Pp
332The functions
333.Fn EC_KEY_get_enc_flags
334and
335.Fn EC_KEY_set_enc_flags
336get and set the value of the encoding flags for the
337.Fa key .
338There are two encoding flags currently defined:
339.Dv EC_PKEY_NO_PARAMETERS
340and
341.Dv EC_PKEY_NO_PUBKEY .
342These flags define the behaviour of how the
343.Fa key
344is converted into ASN.1 in a call to
345.Fn i2d_ECPrivateKey .
346If
347.Dv EC_PKEY_NO_PARAMETERS
348is set then the public parameters for the curve
349are not encoded along with the private key.
350If
351.Dv EC_PKEY_NO_PUBKEY
352is set then the public key is not encoded along with the private
353key.
354.Pp
355The format of the external representation of the public key written by
356.Xr i2d_ECPrivateKey 3 ,
357such as whether it is stored in a compressed form or not,
358is described by the point_conversion_form.
359See
360.Xr EC_GROUP_copy 3
361for a description of point_conversion_form.
362.Pp
363When reading a private key encoded without an associated public key,
364for example if
365.Dv EC_PKEY_NO_PUBKEY
366was used,
367.Xr d2i_ECPrivateKey 3
368generates the missing public key automatically.
369Private keys encoded without parameters, for example if
370.Dv EC_PKEY_NO_PARAMETERS
371was used, cannot be loaded using
372.Xr d2i_ECPrivateKey 3 .
373.Pp
374The functions
375.Fn EC_KEY_get_conv_form
376and
377.Fn EC_KEY_set_conv_form
378get and set the point_conversion_form for the
379.Fa key .
380For a description of point_conversion_form refer to
381.Xr EC_GROUP_copy 3 .
382.Pp
383.Fn EC_KEY_set_flags
384sets the flags in the
385.Fa flags
386parameter on the
387.Vt EC_KEY
388object.
389Any flags that are already set are left set.
390The currently defined standard flags are
391.Dv EC_FLAG_NON_FIPS_ALLOW
392and
393.Dv EC_FLAG_FIPS_CHECKED .
394In addition there is the ECDH-specific flag
395.Dv EC_FLAG_COFACTOR_ECDH .
396.Fn EC_KEY_get_flags
397returns the current flags that are set for this
398.Vt EC_KEY .
399.Fn EC_KEY_clear_flags
400clears the flags indicated by the
401.Fa flags
402parameter.
403All other flags are left in their existing state.
404.Pp
405.Fn EC_KEY_set_asn1_flag
406sets the asn1_flag on the underlying
407.Vt EC_GROUP
408object (if set).
409Refer to
410.Xr EC_GROUP_copy 3
411for further information on the asn1_flag.
412.Pp
413.Fn EC_KEY_precompute_mult
414stores multiples of the underlying
415.Vt EC_GROUP
416generator for faster point multiplication.
417See also
418.Xr EC_POINT_add 3 .
419.Pp
420.Fn EC_KEY_print
421and
422.Fn EC_KEY_print_fp
423print out the content of
424.Fa key
425to the
426.Vt BIO
427.Fa bp
428or to the
429.Vt FILE
430pointer
431.Fa fp ,
432respectively.
433Each line is indented by
434.Fa indent
435spaces.
436.Sh RETURN VALUES
437.Fn EC_KEY_new ,
438.Fn EC_KEY_new_by_curve_name ,
439and
440.Fn EC_KEY_dup
441return a pointer to the newly created
442.Vt EC_KEY object
443or
444.Dv NULL
445on error.
446.Pp
447.Fn EC_KEY_get_flags
448returns the flags associated with the
449.Vt EC_KEY object .
450.Pp
451.Fn EC_KEY_copy
452returns a pointer to the destination key or
453.Dv NULL
454on error.
455In the latter case, part of the content may already have been copied.
456.Pp
457.Fn EC_KEY_up_ref ,
458.Fn EC_KEY_set_group ,
459.Fn EC_KEY_set_private_key ,
460.Fn EC_KEY_set_public_key ,
461.Fn EC_KEY_precompute_mult ,
462.Fn EC_KEY_generate_key ,
463.Fn EC_KEY_check_key ,
464.Fn EC_KEY_set_public_key_affine_coordinates ,
465.Fn EC_KEY_print ,
466and
467.Fn EC_KEY_print_fp
468return 1 on success or 0 on error.
469.Pp
470.Fn EC_KEY_get0_group
471returns the
472.Vt EC_GROUP
473associated with the
474.Vt EC_KEY .
475.Pp
476.Fn EC_KEY_get0_private_key
477and
478.Fn EC_KEY_get0_public_key
479return the private or public keys, respectively, associated with the
480.Vt EC_KEY .
481.Pp
482.Fn EC_KEY_get_enc_flags
483returns the value of the current encoding flags for the
484.Vt EC_KEY .
485.Pp
486.Fn EC_KEY_get_conv_form
487returns the point_conversion_form for the
488.Vt EC_KEY .
489.Sh SEE ALSO
490.Xr d2i_ECPKParameters 3 ,
491.Xr EC_GROUP_copy 3 ,
492.Xr EC_GROUP_new 3 ,
493.Xr EC_KEY_METHOD_new 3 ,
494.Xr EC_POINT_add 3 ,
495.Xr EC_POINT_new 3 ,
496.Xr ECDH_compute_key 3 ,
497.Xr ECDSA_SIG_new 3 ,
498.Xr EVP_PKEY_set1_EC_KEY 3
499.Sh HISTORY
500.Fn EC_KEY_new ,
501.Fn EC_KEY_new_by_curve_name ,
502.Fn EC_KEY_free ,
503.Fn EC_KEY_copy ,
504.Fn EC_KEY_dup ,
505.Fn EC_KEY_up_ref ,
506.Fn EC_KEY_get0_group ,
507.Fn EC_KEY_set_group ,
508.Fn EC_KEY_get0_private_key ,
509.Fn EC_KEY_set_private_key ,
510.Fn EC_KEY_get0_public_key ,
511.Fn EC_KEY_set_public_key ,
512.Fn EC_KEY_get_enc_flags ,
513.Fn EC_KEY_set_enc_flags ,
514.Fn EC_KEY_get_conv_form ,
515.Fn EC_KEY_set_conv_form ,
516.Fn EC_KEY_set_asn1_flag ,
517.Fn EC_KEY_precompute_mult ,
518.Fn EC_KEY_generate_key ,
519.Fn EC_KEY_check_key ,
520.Fn EC_KEY_print ,
521and
522.Fn EC_KEY_print_fp
523first appeared in OpenSSL 0.9.8 and have been available since
524.Ox 4.5 .
525.Pp
526.Fn EC_KEY_get_flags ,
527.Fn EC_KEY_set_flags ,
528.Fn EC_KEY_clear_flags ,
529and
530.Fn EC_KEY_set_public_key_affine_coordinates
531first appeared in OpenSSL 1.0.1 and have been available since
532.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/EC_POINT_add.3 b/src/lib/libcrypto/man/EC_POINT_add.3
deleted file mode 100644
index cc35499c0e..0000000000
--- a/src/lib/libcrypto/man/EC_POINT_add.3
+++ /dev/null
@@ -1,216 +0,0 @@
1.\" $OpenBSD: EC_POINT_add.3,v 1.15 2025/03/08 16:48:22 tb Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>.
5.\" Copyright (c) 2013 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 8 2025 $
52.Dt EC_POINT_ADD 3
53.Os
54.Sh NAME
55.Nm EC_POINT_add ,
56.Nm EC_POINT_dbl ,
57.Nm EC_POINT_invert ,
58.Nm EC_POINT_is_at_infinity ,
59.Nm EC_POINT_is_on_curve ,
60.Nm EC_POINT_cmp ,
61.Nm EC_POINT_make_affine ,
62.Nm EC_POINT_mul
63.Nd perform mathematical operations and tests on EC_POINT objects
64.Sh SYNOPSIS
65.In openssl/ec.h
66.In openssl/bn.h
67.Ft int
68.Fo EC_POINT_add
69.Fa "const EC_GROUP *group"
70.Fa "EC_POINT *r"
71.Fa "const EC_POINT *a"
72.Fa "const EC_POINT *b"
73.Fa "BN_CTX *ctx"
74.Fc
75.Ft int
76.Fo EC_POINT_dbl
77.Fa "const EC_GROUP *group"
78.Fa "EC_POINT *r"
79.Fa "const EC_POINT *a"
80.Fa "BN_CTX *ctx"
81.Fc
82.Ft int
83.Fo EC_POINT_invert
84.Fa "const EC_GROUP *group"
85.Fa "EC_POINT *a"
86.Fa "BN_CTX *ctx"
87.Fc
88.Ft int
89.Fo EC_POINT_is_at_infinity
90.Fa "const EC_GROUP *group"
91.Fa "const EC_POINT *p"
92.Fc
93.Ft int
94.Fo EC_POINT_is_on_curve
95.Fa "const EC_GROUP *group"
96.Fa "const EC_POINT *point"
97.Fa "BN_CTX *ctx"
98.Fc
99.Ft int
100.Fo EC_POINT_cmp
101.Fa "const EC_GROUP *group"
102.Fa "const EC_POINT *a"
103.Fa "const EC_POINT *b"
104.Fa "BN_CTX *ctx"
105.Fc
106.Ft int
107.Fo EC_POINT_make_affine
108.Fa "const EC_GROUP *group"
109.Fa "EC_POINT *point"
110.Fa "BN_CTX *ctx"
111.Fc
112.Ft int
113.Fo EC_POINT_mul
114.Fa "const EC_GROUP *group"
115.Fa "EC_POINT *r"
116.Fa "const BIGNUM *n"
117.Fa "const EC_POINT *q"
118.Fa "const BIGNUM *m"
119.Fa "BN_CTX *ctx"
120.Fc
121.Sh DESCRIPTION
122These functions operate on
123.Vt EC_POINT
124objects created by
125.Xr EC_POINT_new 3 .
126.Pp
127.Fn EC_POINT_add
128adds the two points
129.Fa a
130and
131.Fa b
132and places the result in
133.Fa r .
134Similarly
135.Fn EC_POINT_dbl
136doubles the point
137.Fa a
138and places the result in
139.Fa r .
140In both cases it is valid for
141.Fa r
142to be one of
143.Fa a
144or
145.Fa b .
146.Pp
147.Fn EC_POINT_invert
148calculates the inverse of the supplied point
149.Fa a .
150The result is placed back in
151.Fa a .
152.Pp
153The function
154.Fn EC_POINT_is_at_infinity
155tests whether the supplied point is at infinity or not.
156.Pp
157.Fn EC_POINT_is_on_curve
158tests whether the supplied point is on the curve or not.
159.Pp
160.Fn EC_POINT_cmp
161compares the two supplied points and tests whether or not they are
162equal.
163.Pp
164.Fn EC_POINT_mul
165calculates the value
166.Pp
167.D1 generator * n + q * m
168.Pp
169and stores the result in
170.Fa r .
171The value
172.Fa n
173may be
174.Dv NULL ,
175in which case the result is just
176.Pp
177.Dl q * m.
178.Pp
179See
180.Xr EC_GROUP_copy 3
181for information about the generator.
182.Sh RETURN VALUES
183The following functions return 1 on success or 0 on error:
184.Fn EC_POINT_add ,
185.Fn EC_POINT_dbl ,
186.Fn EC_POINT_invert ,
187.Fn EC_POINT_make_affine ,
188and
189.Fn EC_POINT_mul
190.Pp
191.Fn EC_POINT_is_at_infinity
192returns 1 if the point is at infinity or 0 otherwise.
193.Pp
194.Fn EC_POINT_is_on_curve
195returns 1 if the point is on the curve, 0 if not, or -1 on error.
196.Pp
197.Fn EC_POINT_cmp
198returns 1 if the points are not equal, 0 if they are, or -1 on error.
199.Sh SEE ALSO
200.Xr d2i_ECPKParameters 3 ,
201.Xr EC_GROUP_copy 3 ,
202.Xr EC_GROUP_new 3 ,
203.Xr EC_KEY_new 3 ,
204.Xr EC_POINT_new 3
205.Sh HISTORY
206.Fn EC_POINT_add ,
207.Fn EC_POINT_dbl ,
208.Fn EC_POINT_invert ,
209.Fn EC_POINT_is_at_infinity ,
210.Fn EC_POINT_is_on_curve ,
211.Fn EC_POINT_cmp ,
212.Fn EC_POINT_make_affine ,
213and
214.Fn EC_POINT_mul
215first appeared in OpenSSL 0.9.7 and have been available since
216.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/EC_POINT_new.3 b/src/lib/libcrypto/man/EC_POINT_new.3
deleted file mode 100644
index db6280fce7..0000000000
--- a/src/lib/libcrypto/man/EC_POINT_new.3
+++ /dev/null
@@ -1,455 +0,0 @@
1.\" $OpenBSD: EC_POINT_new.3,v 1.17 2025/03/08 17:04:07 tb Exp $
2.\" full merge up to: OpenSSL 50db8163 Jul 30 16:56:41 2018 +0100
3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>.
5.\" Copyright (c) 2013, 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 8 2025 $
52.Dt EC_POINT_NEW 3
53.Os
54.Sh NAME
55.Nm EC_POINT_new ,
56.Nm EC_POINT_free ,
57.Nm EC_POINT_clear_free ,
58.Nm EC_POINT_copy ,
59.Nm EC_POINT_dup ,
60.Nm EC_POINT_set_to_infinity ,
61.Nm EC_POINT_set_affine_coordinates ,
62.Nm EC_POINT_set_affine_coordinates_GFp ,
63.Nm EC_POINT_get_affine_coordinates ,
64.Nm EC_POINT_get_affine_coordinates_GFp ,
65.Nm EC_POINT_set_compressed_coordinates ,
66.Nm EC_POINT_set_compressed_coordinates_GFp ,
67.Nm EC_POINT_point2oct ,
68.Nm EC_POINT_oct2point ,
69.Nm EC_POINT_point2bn ,
70.Nm EC_POINT_bn2point ,
71.Nm EC_POINT_point2hex ,
72.Nm EC_POINT_hex2point
73.Nd create, destroy, and manipulate EC_POINT objects
74.Sh SYNOPSIS
75.In openssl/ec.h
76.In openssl/bn.h
77.Ft EC_POINT *
78.Fo EC_POINT_new
79.Fa "const EC_GROUP *group"
80.Fc
81.Ft void
82.Fo EC_POINT_free
83.Fa "EC_POINT *point"
84.Fc
85.Ft void
86.Fo EC_POINT_clear_free
87.Fa "EC_POINT *point"
88.Fc
89.Ft int
90.Fo EC_POINT_copy
91.Fa "EC_POINT *dst"
92.Fa "const EC_POINT *src"
93.Fc
94.Ft EC_POINT *
95.Fo EC_POINT_dup
96.Fa "const EC_POINT *src"
97.Fa "const EC_GROUP *group"
98.Fc
99.Ft int
100.Fo EC_POINT_set_to_infinity
101.Fa "const EC_GROUP *group"
102.Fa "EC_POINT *point"
103.Fc
104.Ft int
105.Fo EC_POINT_set_affine_coordinates
106.Fa "const EC_GROUP *group"
107.Fa "EC_POINT *p"
108.Fa "const BIGNUM *x"
109.Fa "const BIGNUM *y"
110.Fa "BN_CTX *ctx"
111.Fc
112.Ft int
113.Fo EC_POINT_set_affine_coordinates_GFp
114.Fa "const EC_GROUP *group"
115.Fa "EC_POINT *p"
116.Fa "const BIGNUM *x"
117.Fa "const BIGNUM *y"
118.Fa "BN_CTX *ctx"
119.Fc
120.Ft int
121.Fo EC_POINT_get_affine_coordinates
122.Fa "const EC_GROUP *group"
123.Fa "const EC_POINT *p"
124.Fa "BIGNUM *x"
125.Fa "BIGNUM *y"
126.Fa "BN_CTX *ctx"
127.Fc
128.Ft int
129.Fo EC_POINT_get_affine_coordinates_GFp
130.Fa "const EC_GROUP *group"
131.Fa "const EC_POINT *p"
132.Fa "BIGNUM *x"
133.Fa "BIGNUM *y"
134.Fa "BN_CTX *ctx"
135.Fc
136.Ft int
137.Fo EC_POINT_set_compressed_coordinates
138.Fa "const EC_GROUP *group"
139.Fa "EC_POINT *p"
140.Fa "const BIGNUM *x"
141.Fa "int y_bit"
142.Fa "BN_CTX *ctx"
143.Fc
144.Ft int
145.Fo EC_POINT_set_compressed_coordinates_GFp
146.Fa "const EC_GROUP *group"
147.Fa "EC_POINT *p"
148.Fa "const BIGNUM *x"
149.Fa "int y_bit"
150.Fa "BN_CTX *ctx"
151.Fc
152.Ft size_t
153.Fo EC_POINT_point2oct
154.Fa "const EC_GROUP *group"
155.Fa "const EC_POINT *p"
156.Fa "point_conversion_form_t form"
157.Fa "unsigned char *buf"
158.Fa "size_t len"
159.Fa "BN_CTX *ctx"
160.Fc
161.Ft int
162.Fo EC_POINT_oct2point
163.Fa "const EC_GROUP *group"
164.Fa "EC_POINT *p"
165.Fa "const unsigned char *buf"
166.Fa "size_t len"
167.Fa "BN_CTX *ctx"
168.Fc
169.Ft BIGNUM *
170.Fo EC_POINT_point2bn
171.Fa "const EC_GROUP *"
172.Fa "const EC_POINT *"
173.Fa "point_conversion_form_t form"
174.Fa "BIGNUM *"
175.Fa "BN_CTX *"
176.Fc
177.Ft EC_POINT *
178.Fo EC_POINT_bn2point
179.Fa "const EC_GROUP *"
180.Fa "const BIGNUM *"
181.Fa "EC_POINT *"
182.Fa "BN_CTX *"
183.Fc
184.Ft char *
185.Fo EC_POINT_point2hex
186.Fa "const EC_GROUP *"
187.Fa "const EC_POINT *"
188.Fa "point_conversion_form_t form"
189.Fa "BN_CTX *"
190.Fc
191.Ft EC_POINT *
192.Fo EC_POINT_hex2point
193.Fa "const EC_GROUP *"
194.Fa "const char *"
195.Fa "EC_POINT *"
196.Fa "BN_CTX *"
197.Fc
198.Sh DESCRIPTION
199An
200.Vt EC_POINT
201represents a point on a curve.
202A curve is represented by an
203.Vt EC_GROUP
204object created by the functions described in
205.Xr EC_GROUP_new 3 .
206.Pp
207A new point is constructed by calling the function
208.Fn EC_POINT_new
209and providing the
210.Fa group
211object that the point relates to.
212.Pp
213.Fn EC_POINT_free
214frees the memory associated with the
215.Vt EC_POINT .
216If
217.Fa point
218is a
219.Dv NULL
220pointer, no action occurs.
221.Pp
222.Fn EC_POINT_clear_free
223destroys any sensitive data held within the
224.Vt EC_POINT
225and then frees its memory.
226If
227.Fa point
228is a
229.Dv NULL
230pointer, no action occurs.
231.Pp
232.Fn EC_POINT_copy
233copies the point
234.Fa src
235into
236.Fa dst .
237Both
238.Fa src
239and
240.Fa dst
241must use the same
242.Vt EC_METHOD .
243.Pp
244.Fn EC_POINT_dup
245creates a new
246.Vt EC_POINT
247object and copies the content from
248.Fa src
249to the newly created
250.Vt EC_POINT
251object.
252.Pp
253A valid point on a curve is the special point at infinity.
254A point is set to be at infinity by calling
255.Fn EC_POINT_set_to_infinity .
256.Pp
257The affine coordinates for a point describe a point in terms of its
258.Fa x
259and
260.Fa y
261position.
262The function
263.Fn EC_POINT_set_affine_coordinates
264sets the
265.Fa x
266and
267.Fa y
268coordinates for the point
269.Fa p
270defined over the curve given in
271.Fa group .
272The function
273.Fn EC_POINT_get_affine_coordinates
274sets
275.Fa x
276and
277.Fa y ,
278either of which may be
279.Dv NULL ,
280to the corresponding coordinates of
281.Fa p .
282.Pp
283The functions
284.Fn EC_POINT_set_affine_coordinates_GFp
285is a deprecated synonym for
286.Fn EC_POINT_set_affine_coordinates
287and the function
288.Fn EC_POINT_get_affine_coordinates_GFp
289is a deprecated synonym for
290.Fn EC_POINT_get_affine_coordinates .
291.Pp
292Points can also be described in terms of their compressed coordinates.
293For a point
294.Pq Fa x , y ,
295for any given value for
296.Fa x
297such that the point is on the curve, there will only ever be two
298possible values for
299.Fa y .
300Therefore, a point can be set using the
301.Fn EC_POINT_set_compressed_coordinates
302function where
303.Fa x
304is the x coordinate and
305.Fa y_bit
306is a value 0 or 1 to identify which of the two possible values for y
307should be used.
308.Pp
309The functions
310.Fn EC_POINT_set_compressed_coordinates_GFp
311is a deprecated synonym for
312.Fn EC_POINT_set_compressed_coordinates .
313.Pp
314In addition
315.Vt EC_POINT Ns s
316can be converted to and from various external representations.
317Supported representations are octet strings,
318.Vt BIGNUM Ns s ,
319and hexadecimal.
320The format of the external representation is described by the
321point_conversion_form.
322See
323.Xr EC_GROUP_copy 3
324for a description of point_conversion_form.
325Octet strings are stored in a buffer along with an associated buffer
326length.
327A point held in a
328.Vt BIGNUM
329is calculated by converting the point to an octet string and then
330converting that octet string into a
331.Vt BIGNUM
332integer.
333Points in hexadecimal format are stored in a NUL terminated character
334string where each character is one of the printable values 0-9 or A-F
335(or a-f).
336.Pp
337The functions
338.Fn EC_POINT_point2oct ,
339.Fn EC_POINT_oct2point ,
340.Fn EC_POINT_point2bn ,
341.Fn EC_POINT_bn2point ,
342.Fn EC_POINT_point2hex ,
343and
344.Fn EC_POINT_hex2point
345convert from and to
346.Vt EC_POINT Ns s
347for the formats octet string,
348.Vt BIGNUM ,
349and hexadecimal, respectively.
350.Pp
351The function
352.Fn EC_POINT_point2oct
353must be supplied with a
354.Fa buf
355long enough to store the octet string.
356The return value provides the number of octets stored.
357Calling the function with a
358.Dv NULL
359.Fa buf
360will not perform the conversion but will still return the required
361buffer length.
362.Pp
363The function
364.Fn EC_POINT_point2hex
365will allocate sufficient memory to store the hexadecimal string.
366It is the caller's responsibility to free this memory with a subsequent
367call to
368.Xr free 3 .
369.Sh RETURN VALUES
370.Fn EC_POINT_new
371and
372.Fn EC_POINT_dup
373return the newly allocated
374.Vt EC_POINT
375or
376.Dv NULL
377on error.
378.Pp
379The following functions return 1 on success or 0 on error:
380.Fn EC_POINT_copy ,
381.Fn EC_POINT_set_to_infinity ,
382.Fn EC_POINT_set_affine_coordinates ,
383.Fn EC_POINT_set_affine_coordinates_GFp ,
384.Fn EC_POINT_get_affine_coordinates ,
385.Fn EC_POINT_get_affine_coordinates_GFp ,
386.Fn EC_POINT_set_compressed_coordinates ,
387.Fn EC_POINT_set_compressed_coordinates_GFp ,
388and
389.Fn EC_POINT_oct2point .
390.Pp
391.Fn EC_POINT_point2oct
392returns the length of the required buffer, or 0 on error.
393.Pp
394.Fn EC_POINT_point2bn
395returns the pointer to the
396.Vt BIGNUM
397supplied or
398.Dv NULL
399on error.
400.Pp
401.Fn EC_POINT_bn2point
402returns the pointer to the
403.Vt EC_POINT
404supplied or
405.Dv NULL
406on error.
407.Pp
408.Fn EC_POINT_point2hex
409returns a pointer to the hex string or
410.Dv NULL
411on error.
412.Pp
413.Fn EC_POINT_hex2point
414returns the pointer to the
415.Vt EC_POINT
416supplied or
417.Dv NULL
418on error.
419.Sh SEE ALSO
420.Xr d2i_ECPKParameters 3 ,
421.Xr EC_GROUP_copy 3 ,
422.Xr EC_GROUP_new 3 ,
423.Xr EC_KEY_new 3 ,
424.Xr EC_POINT_add 3 ,
425.Xr ECDH_compute_key 3
426.Sh HISTORY
427.Fn EC_POINT_new ,
428.Fn EC_POINT_free ,
429.Fn EC_POINT_clear_free ,
430.Fn EC_POINT_copy ,
431.Fn EC_POINT_set_to_infinity ,
432.Fn EC_POINT_set_affine_coordinates_GFp ,
433.Fn EC_POINT_get_affine_coordinates_GFp ,
434.Fn EC_POINT_set_compressed_coordinates_GFp ,
435.Fn EC_POINT_point2oct ,
436and
437.Fn EC_POINT_oct2point
438first appeared in OpenSSL 0.9.7 and have been available since
439.Ox 3.2 .
440.Pp
441.Fn EC_POINT_dup ,
442.Fn EC_POINT_point2bn ,
443.Fn EC_POINT_bn2point ,
444.Fn EC_POINT_point2hex ,
445and
446.Fn EC_POINT_hex2point
447first appeared in OpenSSL 0.9.8 and have been available since
448.Ox 4.5 .
449.Pp
450.Fn EC_POINT_set_affine_coordinates ,
451.Fn EC_POINT_get_affine_coordinates ,
452and
453.Fn EC_POINT_set_compressed_coordinates
454first appeared in OpenSSL 1.1.1 and have been available since
455.Ox 7.0 .
diff --git a/src/lib/libcrypto/man/ENGINE_new.3 b/src/lib/libcrypto/man/ENGINE_new.3
deleted file mode 100644
index 55ed963563..0000000000
--- a/src/lib/libcrypto/man/ENGINE_new.3
+++ /dev/null
@@ -1,174 +0,0 @@
1.\" $OpenBSD: ENGINE_new.3,v 1.10 2023/11/19 21:13:47 tb Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: November 19 2023 $
19.Dt ENGINE_NEW 3
20.Os
21.Sh NAME
22.Nm ENGINE_new ,
23.Nm ENGINE_free ,
24.Nm ENGINE_init ,
25.Nm ENGINE_finish ,
26.Nm ENGINE_ctrl_cmd ,
27.Nm ENGINE_ctrl_cmd_string ,
28.Nm ENGINE_by_id ,
29.Nm ENGINE_get_id ,
30.Nm ENGINE_get_name ,
31.Nm ENGINE_set_default ,
32.Nm ENGINE_get_default_RSA ,
33.Nm ENGINE_set_default_RSA ,
34.Nm ENGINE_load_private_key ,
35.Nm ENGINE_load_public_key ,
36.Nm ENGINE_load_builtin_engines ,
37.Nm ENGINE_load_dynamic ,
38.Nm ENGINE_load_openssl ,
39.Nm ENGINE_register_all_complete ,
40.Nm ENGINE_cleanup
41.Nd ENGINE stub functions
42.Sh SYNOPSIS
43.In openssl/engine.h
44.Ft ENGINE *
45.Fn ENGINE_new void
46.Ft int
47.Fo ENGINE_free
48.Fa "ENGINE *engine"
49.Fc
50.Ft int
51.Fn ENGINE_init "ENGINE *engine"
52.Ft int
53.Fn ENGINE_finish "ENGINE *engine"
54.Ft int
55.Fo ENGINE_ctrl_cmd
56.Fa "ENGINE *engine"
57.Fa "const char *cmd_name"
58.Fa "long i"
59.Fa "void *p"
60.Fa "void (*f)(void)"
61.Fa "int cmd_optional"
62.Fc
63.Ft int
64.Fo ENGINE_ctrl_cmd_string
65.Fa "ENGINE *engine"
66.Fa "const char *cmd_name"
67.Fa "const char *arg"
68.Fa "int cmd_optional"
69.Fc
70.Ft ENGINE *
71.Fn ENGINE_by_id "const char *id"
72.Ft const char *
73.Fn ENGINE_get_id "const ENGINE *engine"
74.Ft const char *
75.Fn ENGINE_get_name "const ENGINE *engine"
76.Ft int
77.Fn ENGINE_set_default "ENGINE *engine" "unsigned int flags"
78.Ft ENGINE *
79.Fn ENGINE_get_default_RSA "ENGINE *engine"
80.Ft int
81.Fn ENGINE_set_default_RSA "ENGINE *engine"
82.Ft EVP_PKEY *
83.Fo ENGINE_load_private_key
84.Fa "ENGINE *engine"
85.Fa "const char *key_id"
86.Fa "UI_METHOD *ui_method"
87.Fa "void *callback_data"
88.Fc
89.Ft EVP_PKEY *
90.Fo ENGINE_load_public_key
91.Fa "ENGINE *engine"
92.Fa "const char *key_id"
93.Fa "UI_METHOD *ui_method"
94.Fa "void *callback_data"
95.Fc
96.Ft void
97.Fn ENGINE_load_builtin_engines "void"
98.Ft void
99.Fn ENGINE_load_dynamic "void"
100.Ft void
101.Fn ENGINE_load_openssl "void"
102.Ft int
103.Fn ENGINE_register_all_complete "void"
104.Ft void
105.Fn ENGINE_cleanup "void"
106.Sh DESCRIPTION
107.Vt ENGINE
108objects used to provide alternative implementations of
109cryptographic algorithms, for example using specialized hardware.
110LibreSSL no longer supports this feature.
111.Pp
112All functions in this manual ignore all their arguments and
113do nothing except return failure if possible.
114They are provided only to avoid patching software that expects
115.Vt ENGINE
116support to be available.
117.Sh RETURN VALUES
118.Fn ENGINE_new ,
119.Fn ENGINE_by_id ,
120.Fn ENGINE_get_default_RSA ,
121.Fn ENGINE_load_private_key ,
122and
123.Fn ENGINE_load_public_key
124always return
125.Dv NULL .
126.Pp
127.Fn ENGINE_free ,
128.Fn ENGINE_init ,
129.Fn ENGINE_finish ,
130.Fn ENGINE_ctrl_cmd ,
131.Fn ENGINE_ctrl_cmd_string ,
132.Fn ENGINE_set_default ,
133.Fn ENGINE_set_default_RSA ,
134and
135.Fn ENGINE_register_all_complete
136always return 0.
137.Pp
138.Fn ENGINE_get_id
139and
140.Fn ENGINE_get_name
141always return the constant empty string.
142.Sh SEE ALSO
143.Xr crypto 3
144.Sh HISTORY
145.Fn ENGINE_new ,
146.Fn ENGINE_free ,
147.Fn ENGINE_init ,
148.Fn ENGINE_finish ,
149.Fn ENGINE_by_id ,
150.Fn ENGINE_get_id ,
151.Fn ENGINE_get_name ,
152.Fn ENGINE_set_default ,
153.Fn ENGINE_get_default_RSA ,
154.Fn ENGINE_set_default_RSA ,
155.Fn ENGINE_load_private_key ,
156and
157.Fn ENGINE_load_public_key
158first appeared in OpenSSL 0.9.7
159and have been available since
160.Ox 2.9 .
161.Pp
162.Fn ENGINE_ctrl_cmd ,
163.Fn ENGINE_ctrl_cmd_string ,
164.Fn ENGINE_load_builtin_engines ,
165.Fn ENGINE_load_openssl ,
166.Fn ENGINE_register_all_complete ,
167and
168.Fn ENGINE_cleanup
169first appeared in OpenSSL 0.9.7
170and have been available since
171.Ox 3.4 .
172.Pp
173All these functions were turned into stubs in
174.Ox 7.4 .
diff --git a/src/lib/libcrypto/man/ERR.3 b/src/lib/libcrypto/man/ERR.3
deleted file mode 100644
index 8f17e7a329..0000000000
--- a/src/lib/libcrypto/man/ERR.3
+++ /dev/null
@@ -1,152 +0,0 @@
1.\" $OpenBSD: ERR.3,v 1.11 2023/07/26 20:15:51 tb Exp $
2.\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
5.\" Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: July 26 2023 $
53.Dt ERR 3
54.Os
55.Sh NAME
56.Nm ERR
57.Nd OpenSSL error codes
58.Sh SYNOPSIS
59.In openssl/err.h
60.Sh DESCRIPTION
61When a call to the OpenSSL library fails, this is usually signaled by
62the return value, and an error code is stored in an error queue
63associated with the current thread.
64The
65.Nm
66library provides functions to obtain these error codes and textual error
67messages.
68The
69.Xr ERR_get_error 3
70manpage describes how to access error codes.
71.Pp
72Error codes contain information about where the error occurred, and what
73went wrong.
74.Xr ERR_GET_LIB 3
75describes how to extract this information.
76A method to obtain human-readable error messages is described in
77.Xr ERR_error_string 3 .
78.Pp
79.Xr ERR_clear_error 3
80can be used to clear the error queue.
81.Pp
82Note that
83.Xr ERR_remove_state 3
84should be used to avoid memory leaks when threads are terminated.
85.Sh ADDING NEW ERROR CODES TO OPENSSL
86See
87.Xr ERR_put_error 3
88if you want to record error codes in the OpenSSL error system from
89within your application.
90.Pp
91The remainder of this section is of interest only if you want to add new
92error codes to OpenSSL or add error codes from external libraries.
93.Pp
94When you are using new function or reason codes, run
95.Sy make errors .
96The necessary
97.Sy #define Ns s
98will then automatically be added to the sub-library's header file.
99.Ss Adding new libraries
100When adding a new sub-library to OpenSSL, assign it a library number
101.Dv ERR_LIB_XXX ,
102define a macro
103.Fn XXXerr
104(both in
105.In openssl/err.h ) ,
106add its name to
107.Va ERR_str_libraries[]
108(in
109.Pa /usr/src/lib/libcrypto/err/err.c ) ,
110and add
111.Fn ERR_load_XXX_strings
112to the
113.Fn ERR_load_crypto_strings
114function (in
115.Sy /usr/src/lib/libcrypto/err/err_all.c ) .
116Finally, add
117.Pa xxx_err.c
118to the
119.Pa Makefile .
120.Sh USING ERROR CODES IN EXTERNAL LIBRARIES
121It is also possible to use OpenSSL's error code scheme in external
122libraries.
123.Sh INTERNALS
124The error queues are stored in a hash table with one
125.Vt ERR_STATE
126entry for each PID.
127.Fn ERR_get_state
128returns the current thread's
129.Vt ERR_STATE .
130An
131.Vt ERR_STATE
132can hold up to
133.Dv ERR_NUM_ERRORS
134error codes.
135When more error codes are added, the old ones are overwritten, on the
136assumption that the most recent errors are most important.
137.Pp
138Error strings are also stored in a hash table.
139.Sh SEE ALSO
140.Xr crypto 3 ,
141.Xr ERR_asprintf_error_data 3 ,
142.Xr ERR_clear_error 3 ,
143.Xr ERR_error_string 3 ,
144.Xr ERR_get_error 3 ,
145.Xr ERR_GET_LIB 3 ,
146.Xr ERR_load_crypto_strings 3 ,
147.Xr ERR_load_strings 3 ,
148.Xr ERR_print_errors 3 ,
149.Xr ERR_put_error 3 ,
150.Xr ERR_remove_state 3 ,
151.Xr ERR_set_mark 3 ,
152.Xr SSL_get_error 3
diff --git a/src/lib/libcrypto/man/ERR_GET_LIB.3 b/src/lib/libcrypto/man/ERR_GET_LIB.3
deleted file mode 100644
index bc14f0e2ac..0000000000
--- a/src/lib/libcrypto/man/ERR_GET_LIB.3
+++ /dev/null
@@ -1,126 +0,0 @@
1.\" $OpenBSD: ERR_GET_LIB.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $
2.\" OpenSSL doc/man3/ERR_GET_LIB.pod 3dfda1a6 Dec 12 11:14:40 2016 -0500
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 27 2018 $
52.Dt ERR_GET_LIB 3
53.Os
54.Sh NAME
55.Nm ERR_GET_LIB ,
56.Nm ERR_GET_FUNC ,
57.Nm ERR_GET_REASON ,
58.Nm ERR_FATAL_ERROR
59.Nd get library, function and reason codes for OpenSSL errors
60.Sh SYNOPSIS
61.In openssl/err.h
62.Ft int
63.Fo ERR_GET_LIB
64.Fa "unsigned long e"
65.Fc
66.Ft int
67.Fo ERR_GET_FUNC
68.Fa "unsigned long e"
69.Fc
70.Ft int
71.Fo ERR_GET_REASON
72.Fa "unsigned long e"
73.Fc
74.Ft int
75.Fo ERR_FATAL_ERROR
76.Fa "unsigned long e"
77.Fc
78.Sh DESCRIPTION
79The error code returned by
80.Xr ERR_get_error 3
81consists of a library number, function code, and reason code.
82.Fn ERR_GET_LIB ,
83.Fn ERR_GET_FUNC ,
84and
85.Fn ERR_GET_REASON
86can be used to extract these.
87.Pp
88The library number and function code describe where the error occurred,
89whereas the reason code is the information about what went wrong.
90.Pp
91Each sub-library of OpenSSL has a unique library number; function and
92reason codes are unique within each sub-library.
93Note that different libraries may use the same value to signal different
94functions and reasons.
95.Pp
96.Dv ERR_R_*
97reason codes such as
98.Dv ERR_R_MALLOC_FAILURE
99are globally unique.
100However, when checking for sub-library specific reason codes, be sure to
101also compare the library number.
102.Pp
103.Fn ERR_FATAL_ERROR
104indicates whether a given error code is a fatal error.
105.Pp
106These functions are implemented as macros.
107.Sh RETURN VALUES
108.Fn ERR_GET_LIB ,
109.Fn ERR_GET_FUNC ,
110and
111.Fn ERR_GET_REASON
112return the library number, function code, and reason code, respectively.
113.Pp
114.Fn ERR_FATAL_ERROR
115returns non-zero if the error is fatal or 0 otherwise.
116.Sh SEE ALSO
117.Xr ERR 3 ,
118.Xr ERR_get_error 3
119.Sh HISTORY
120.Fn ERR_GET_LIB ,
121.Fn ERR_GET_FUNC ,
122.Fn ERR_GET_REASON ,
123and
124.Fn ERR_FATAL_ERROR
125first appeared in SSLeay 0.4.4 and have been available since
126.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/ERR_asprintf_error_data.3 b/src/lib/libcrypto/man/ERR_asprintf_error_data.3
deleted file mode 100644
index 4291dea23e..0000000000
--- a/src/lib/libcrypto/man/ERR_asprintf_error_data.3
+++ /dev/null
@@ -1,55 +0,0 @@
1.\" $OpenBSD: ERR_asprintf_error_data.3,v 1.3 2024/08/29 20:23:21 tb Exp $
2.\"
3.\" Copyright (c) 2017 Bob Beck <beck@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.Dd $Mdocdate: August 29 2024 $
17.Dt ERR_ASPRINTF_ERROR_DATA 3
18.Os
19.Sh NAME
20.Nm ERR_asprintf_error_data
21.Nd record a LibreSSL error using a formatted string
22.Sh SYNOPSIS
23.In openssl/err.h
24.Ft void
25.Fo ERR_asprintf_error_data
26.Fa "char * format"
27.Fa ...
28.Fc
29.Sh DESCRIPTION
30.Nm
31builds a string using
32.Xr asprintf 3
33called with the provided
34.Ar format
35and arguments.
36The resulting string is then associated with the error code that was most
37recently added.
38If
39.Xr asprintf 3
40fails, the string "malloc failed" is associated instead.
41.Pp
42.Nm
43is intended to be used instead of the OpenSSL functions
44.Fn ERR_add_error_data
45and
46.Fn ERR_add_error_vdata .
47.Sh SEE ALSO
48.Xr ERR 3 ,
49.Xr ERR_put_error 3 ,
50.Xr printf 3
51.Sh HISTORY
52.Nm
53appeared in
54.Ox 5.6
55and is available in all versions of LibreSSL.
diff --git a/src/lib/libcrypto/man/ERR_clear_error.3 b/src/lib/libcrypto/man/ERR_clear_error.3
deleted file mode 100644
index 54f563e166..0000000000
--- a/src/lib/libcrypto/man/ERR_clear_error.3
+++ /dev/null
@@ -1,70 +0,0 @@
1.\" $OpenBSD: ERR_clear_error.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 27 2018 $
52.Dt ERR_CLEAR_ERROR 3
53.Os
54.Sh NAME
55.Nm ERR_clear_error
56.Nd clear the OpenSSL error queue
57.Sh SYNOPSIS
58.In openssl/err.h
59.Ft void
60.Fn ERR_clear_error void
61.Sh DESCRIPTION
62.Fn ERR_clear_error
63empties the current thread's error queue.
64.Sh SEE ALSO
65.Xr ERR 3 ,
66.Xr ERR_get_error 3
67.Sh HISTORY
68.Fn ERR_clear_error
69first appeared in SSLeay 0.4.4 and has been available since
70.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/ERR_error_string.3 b/src/lib/libcrypto/man/ERR_error_string.3
deleted file mode 100644
index 60f9132859..0000000000
--- a/src/lib/libcrypto/man/ERR_error_string.3
+++ /dev/null
@@ -1,176 +0,0 @@
1.\" $OpenBSD: ERR_error_string.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2004 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 27 2018 $
52.Dt ERR_ERROR_STRING 3
53.Os
54.Sh NAME
55.Nm ERR_error_string ,
56.Nm ERR_error_string_n ,
57.Nm ERR_lib_error_string ,
58.Nm ERR_func_error_string ,
59.Nm ERR_reason_error_string
60.Nd obtain human-readable OpenSSL error messages
61.Sh SYNOPSIS
62.In openssl/err.h
63.Ft char *
64.Fo ERR_error_string
65.Fa "unsigned long e"
66.Fa "char *buf"
67.Fc
68.Ft void
69.Fo ERR_error_string_n
70.Fa "unsigned long e"
71.Fa "char *buf"
72.Fa "size_t len"
73.Fc
74.Ft const char *
75.Fo ERR_lib_error_string
76.Fa "unsigned long e"
77.Fc
78.Ft const char *
79.Fo ERR_func_error_string
80.Fa "unsigned long e"
81.Fc
82.Ft const char *
83.Fo ERR_reason_error_string
84.Fa "unsigned long e"
85.Fc
86.Sh DESCRIPTION
87.Fn ERR_error_string
88generates a human-readable string representing the error code
89.Fa e
90and places it in
91.Fa buf .
92.Fa buf
93must be at least 256 bytes long.
94If
95.Fa buf
96is
97.Dv NULL ,
98the error string is placed in a static buffer.
99Note that this function is not thread-safe and does no checks on
100the size of the buffer; use
101.Fn ERR_error_string_n
102instead.
103.Pp
104.Fn ERR_error_string_n
105is a variant of
106.Fn ERR_error_string
107that writes at most
108.Fa len
109characters (including the terminating NUL) and truncates the string
110if necessary.
111For
112.Fn ERR_error_string_n ,
113.Fa buf
114may not be
115.Dv NULL .
116.Pp
117The string will have the following format:
118.Pp
119.Dl error:[error code]:[library name]:[function name]:[reason string]
120.Pp
121The error code is an 8-digit hexadecimal number.
122The library name, the function name, and the reason string are ASCII
123text.
124.Pp
125.Fn ERR_lib_error_string ,
126.Fn ERR_func_error_string ,
127and
128.Fn ERR_reason_error_string
129return the library name, the function name, and the reason string,
130respectively.
131.Pp
132The OpenSSL error strings should be loaded by calling
133.Xr ERR_load_crypto_strings 3
134or, for SSL applications,
135.Xr SSL_load_error_strings 3
136first.
137If there is no text string registered for the given error code, the
138error string will contain the numeric code.
139.Pp
140.Xr ERR_print_errors 3
141can be used to print all error codes currently in the queue.
142.Sh RETURN VALUES
143.Fn ERR_error_string
144returns a pointer to a static buffer containing the string if
145.Fa buf
146is
147.Dv NULL ,
148or
149.Fa buf
150otherwise.
151.Pp
152.Fn ERR_lib_error_string ,
153.Fn ERR_func_error_string ,
154and
155.Fn ERR_reason_error_string
156return the strings, or
157.Dv NULL
158if none is registered for the error code.
159.Sh SEE ALSO
160.Xr ERR 3 ,
161.Xr ERR_get_error 3 ,
162.Xr ERR_load_crypto_strings 3 ,
163.Xr ERR_print_errors 3 ,
164.Xr SSL_load_error_strings 3
165.Sh HISTORY
166.Fn ERR_error_string ,
167.Fn ERR_lib_error_string ,
168.Fn ERR_func_error_string ,
169and
170.Fn ERR_reason_error_string
171first appeared in SSLeay 0.4.4 and have been available since
172.Ox 2.4 .
173.Pp
174.Fn ERR_error_string_n
175first appeared in OpenSSL 0.9.6 and has been available since
176.Ox 2.9 .
diff --git a/src/lib/libcrypto/man/ERR_get_error.3 b/src/lib/libcrypto/man/ERR_get_error.3
deleted file mode 100644
index f3bcc09cbc..0000000000
--- a/src/lib/libcrypto/man/ERR_get_error.3
+++ /dev/null
@@ -1,191 +0,0 @@
1.\" $OpenBSD: ERR_get_error.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2002, 2014 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 27 2018 $
52.Dt ERR_GET_ERROR 3
53.Os
54.Sh NAME
55.Nm ERR_get_error ,
56.Nm ERR_peek_error ,
57.Nm ERR_peek_last_error ,
58.Nm ERR_get_error_line ,
59.Nm ERR_peek_error_line ,
60.Nm ERR_peek_last_error_line ,
61.Nm ERR_get_error_line_data ,
62.Nm ERR_peek_error_line_data ,
63.Nm ERR_peek_last_error_line_data
64.Nd obtain OpenSSL error code and data
65.Sh SYNOPSIS
66.In openssl/err.h
67.Ft unsigned long
68.Fn ERR_get_error void
69.Ft unsigned long
70.Fn ERR_peek_error void
71.Ft unsigned long
72.Fn ERR_peek_last_error void
73.Ft unsigned long
74.Fo ERR_get_error_line
75.Fa "const char **file"
76.Fa "int *line"
77.Fc
78.Ft unsigned long
79.Fo ERR_peek_error_line
80.Fa "const char **file"
81.Fa "int *line"
82.Fc
83.Ft unsigned long
84.Fo ERR_peek_last_error_line
85.Fa "const char **file"
86.Fa "int *line"
87.Fc
88.Ft unsigned long
89.Fo ERR_get_error_line_data
90.Fa "const char **file"
91.Fa "int *line"
92.Fa "const char **data"
93.Fa "int *flags"
94.Fc
95.Ft unsigned long
96.Fo ERR_peek_error_line_data
97.Fa "const char **file"
98.Fa "int *line"
99.Fa "const char **data"
100.Fa "int *flags"
101.Fc
102.Ft unsigned long
103.Fo ERR_peek_last_error_line_data
104.Fa "const char **file"
105.Fa "int *line"
106.Fa "const char **data"
107.Fa "int *flags"
108.Fc
109.Sh DESCRIPTION
110.Fn ERR_get_error
111returns the earliest error code from the thread's error queue and
112removes the entry.
113This function can be called repeatedly until there are no more error
114codes to return.
115.Pp
116.Fn ERR_peek_error
117returns the earliest error code from the thread's error queue without
118modifying it.
119.Pp
120.Fn ERR_peek_last_error
121returns the latest error code from the thread's error queue without
122modifying it.
123.Pp
124See
125.Xr ERR_GET_LIB 3
126for obtaining information about the location and reason for the error, and
127.Xr ERR_error_string 3
128for human-readable error messages.
129.Pp
130.Fn ERR_get_error_line ,
131.Fn ERR_peek_error_line ,
132and
133.Fn ERR_peek_last_error_line
134are the same as the above, but they additionally store the file name and
135line number where the error occurred in
136.Pf * Fa file
137and
138.Pf * Fa line ,
139unless these are
140.Dv NULL .
141.Pp
142.Fn ERR_get_error_line_data ,
143.Fn ERR_peek_error_line_data ,
144and
145.Fn ERR_peek_last_error_line_data
146store additional data and flags associated with the error code in
147.Pf * Fa data
148and
149.Pf * Fa flags ,
150unless these are
151.Dv NULL .
152.Pf * Fa data
153contains a string if
154.Pf * Fa flags Ns & Ns Dv ERR_TXT_STRING
155is true.
156.Pp
157An application
158.Sy MUST NOT
159free the
160.Pf * Fa data
161pointer (or any other pointers returned by these functions) with
162.Xr free 3
163as freeing is handled automatically by the error library.
164.Sh RETURN VALUES
165The error code, or 0 if there is no error in the queue.
166.Sh SEE ALSO
167.Xr ERR 3 ,
168.Xr ERR_error_string 3 ,
169.Xr ERR_GET_LIB 3
170.Sh HISTORY
171.Fn ERR_get_error
172and
173.Fn ERR_peek_error
174first appeared in SSLeay 0.4.4.
175.Fn ERR_get_error_line
176and
177.Fn ERR_peek_error_line
178first appeared in SSLeay 0.6.0.
179.Fn ERR_get_error_line_data
180and
181.Fn ERR_peek_error_line_data
182first appeared in SSLeay 0.9.0.
183All these functions have been available since
184.Ox 2.4 .
185.Pp
186.Fn ERR_peek_last_error ,
187.Fn ERR_peek_last_error_line ,
188and
189.Fn ERR_peek_last_error_line_data
190first appeared in OpenSSL 0.9.7 and have been available since
191.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/ERR_load_crypto_strings.3 b/src/lib/libcrypto/man/ERR_load_crypto_strings.3
deleted file mode 100644
index 2bca8af60f..0000000000
--- a/src/lib/libcrypto/man/ERR_load_crypto_strings.3
+++ /dev/null
@@ -1,150 +0,0 @@
1.\" $OpenBSD: ERR_load_crypto_strings.3,v 1.12 2024/03/05 19:21:31 tb Exp $
2.\" full merge up to: OpenSSL f672aee4 Feb 9 11:52:40 2016 -0500
3.\" selective merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Ulf Moeller <ulf@openssl.org>.
23.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: March 5 2024 $
70.Dt ERR_LOAD_CRYPTO_STRINGS 3
71.Os
72.Sh NAME
73.Nm ERR_load_crypto_strings ,
74.Nm ERR_free_strings ,
75.Nm SSL_load_error_strings
76.Nd load and free OpenSSL error strings
77.\" The following functions are intentionally undocumented
78.\" because they are merely subroutines of ERR_load_crypto_strings(3)
79.\" and should not have been made a part of the API:
80.\" ERR_load_ASN1_strings()
81.\" ERR_load_BIO_strings()
82.\" ERR_load_BN_strings()
83.\" ERR_load_BUF_strings()
84.\" ERR_load_CMS_strings()
85.\" ERR_load_CONF_strings()
86.\" ERR_load_CRYPTO_strings()
87.\" ERR_load_DH_strings()
88.\" ERR_load_DSA_strings()
89.\" ERR_load_EC_strings()
90.\" ERR_load_ERR_strings()
91.\" ERR_load_EVP_strings()
92.\" ERR_load_OBJ_strings()
93.\" ERR_load_OCSP_strings()
94.\" ERR_load_PEM_strings()
95.\" ERR_load_PKCS12_strings()
96.\" ERR_load_PKCS7_strings()
97.\" ERR_load_RAND_strings()
98.\" ERR_load_RSA_strings()
99.\" ERR_load_TS_strings()
100.\" ERR_load_UI_strings()
101.\" ERR_load_X509_strings()
102.\" ERR_load_X509V3_strings()
103.Sh SYNOPSIS
104.In openssl/err.h
105.Ft void
106.Fn ERR_load_crypto_strings void
107.Ft void
108.Fn ERR_free_strings void
109.In openssl/ssl.h
110.Ft void
111.Fn SSL_load_error_strings void
112.Sh DESCRIPTION
113These functions are deprecated.
114It is never useful for any application program to call any of them explicitly.
115The library automatically calls them internally whenever needed.
116.Pp
117.Fn ERR_load_crypto_strings
118registers the error strings for all
119.Xr crypto 3
120functions.
121.Fn SSL_load_error_strings
122does the same, but also registers the
123.Xr ssl 3
124error strings.
125.Pp
126If the error strings were already loaded before, no action occurs.
127.Pp
128.Fn ERR_free_strings
129frees all previously loaded error strings.
130.Sh SEE ALSO
131.Xr ERR 3 ,
132.Xr ERR_error_string 3 ,
133.Xr OPENSSL_config 3
134.Sh HISTORY
135.Fn ERR_load_crypto_strings
136and
137.Fn SSL_load_error_strings
138first appeared in SSLeay 0.4.4.
139.Fn ERR_free_strings
140first appeared in SSLeay 0.5.1.
141These functions been available since
142.Ox 2.4 .
143.Sh BUGS
144Even though the error strings are already compiled into the object
145code of the library as static strings, these functions store them
146again using dynamically allocated memory on the heap.
147That may fail if insufficient memory is available,
148but these functions do not report such errors.
149Instead, they fail silently, possibly having registered none or only
150a part of the strings requested.
diff --git a/src/lib/libcrypto/man/ERR_load_strings.3 b/src/lib/libcrypto/man/ERR_load_strings.3
deleted file mode 100644
index 1020743954..0000000000
--- a/src/lib/libcrypto/man/ERR_load_strings.3
+++ /dev/null
@@ -1,116 +0,0 @@
1.\" $OpenBSD: ERR_load_strings.3,v 1.8 2024/07/26 03:40:43 tb Exp $
2.\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: July 26 2024 $
52.Dt ERR_LOAD_STRINGS 3
53.Os
54.Sh NAME
55.Nm ERR_load_strings ,
56.Nm ERR_PACK ,
57.Nm ERR_get_next_error_library
58.Nd load arbitrary OpenSSL error strings
59.Sh SYNOPSIS
60.In openssl/err.h
61.Ft void
62.Fo ERR_load_strings
63.Fa "int lib"
64.Fa "ERR_STRING_DATA str[]"
65.Fc
66.Ft unsigned long
67.Fo ERR_PACK
68.Fa "int lib"
69.Fa "int func"
70.Fa "int reason"
71.Fc
72.Ft int
73.Fn ERR_get_next_error_library void
74.Sh DESCRIPTION
75.Fn ERR_load_strings
76registers error strings for library number
77.Fa lib .
78.Pp
79.Fa str
80is an array of error string data:
81.Bd -literal -offset indent
82typedef struct ERR_string_data_st {
83 unsigned long error;
84 char *string;
85} ERR_STRING_DATA;
86.Ed
87.Pp
88The error code is generated from the library number and a function and
89reason code:
90.Pp
91.Dl error = ERR_PACK(lib, func, reason)
92.Pp
93.Fn ERR_PACK
94is a macro.
95.Pp
96The last entry in the array is
97.Brq 0 , Dv NULL .
98.Pp
99.Fn ERR_get_next_error_library
100can be used to assign library numbers to user libraries at runtime.
101.Sh RETURN VALUES
102.Fn ERR_PACK
103returns the error code.
104.Fn ERR_get_next_error_library
105returns a new library number.
106.Sh SEE ALSO
107.Xr ERR 3
108.Sh HISTORY
109.Fn ERR_load_strings
110and
111.Fn ERR_PACK
112first appeared in SSLeay 0.4.4.
113.Fn ERR_get_next_error_library
114first appeared in SSLeay 0.9.0.
115These functions have been available since
116.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/ERR_print_errors.3 b/src/lib/libcrypto/man/ERR_print_errors.3
deleted file mode 100644
index a5c7c03287..0000000000
--- a/src/lib/libcrypto/man/ERR_print_errors.3
+++ /dev/null
@@ -1,122 +0,0 @@
1.\" $OpenBSD: ERR_print_errors.3,v 1.8 2020/03/28 22:40:58 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>,
5.\" with additions by Rich Salz <rsalz@openssl.org>.
6.\" Copyright (c) 2000, 2016 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: March 28 2020 $
53.Dt ERR_PRINT_ERRORS 3
54.Os
55.Sh NAME
56.Nm ERR_print_errors ,
57.Nm ERR_print_errors_fp ,
58.Nm ERR_print_errors_cb
59.Nd print OpenSSL error messages
60.Sh SYNOPSIS
61.In openssl/err.h
62.Ft void
63.Fo ERR_print_errors
64.Fa "BIO *bp"
65.Fc
66.Ft void
67.Fo ERR_print_errors_fp
68.Fa "FILE *fp"
69.Fc
70.Ft void
71.Fo ERR_print_errors_cb
72.Fa "int (*cb)(const char *str, size_t len, void *u)"
73.Fa "void *u"
74.Fc
75.Sh DESCRIPTION
76.Fn ERR_print_errors
77is a convenience function that prints the error strings for all errors
78that OpenSSL has recorded to
79.Fa bp ,
80thus emptying the error queue.
81.Pp
82.Fn ERR_print_errors_fp
83is the same, except that the output goes to a
84.Vt FILE .
85.Pp
86.Fn ERR_print_errors_cb
87is the same, except that the callback function,
88.Fa cb ,
89is called for each error line with the string, length, and userdata
90.Fa u
91as the callback parameters.
92.Pp
93The error strings have the following format:
94.Bd -literal
95[pid]:error:[error code]:[library name]:[function name]:[reason string]:
96[file name]:[line]:[optional text message]
97.Ed
98.Pp
99The error code is an 8-digit hexadecimal number.
100The library name, the function name, and the reason string are ASCII
101text, as is the optional text message if one was set for the
102respective error code.
103.Pp
104If there is no text string registered for the given error code, the
105error string will contain the numeric code.
106.Sh SEE ALSO
107.Xr ERR 3 ,
108.Xr ERR_error_string 3 ,
109.Xr ERR_get_error 3 ,
110.Xr ERR_load_crypto_strings 3 ,
111.Xr SSL_load_error_strings 3
112.Sh HISTORY
113.Fn ERR_print_errors
114first appeared in SSLeay 0.4.5.
115.Fn ERR_print_errors_fp
116first appeared in SSLeay 0.6.0.
117Both functions have been available since
118.Ox 2.4 .
119.Pp
120.Fn ERR_print_errors_cb
121first appeared in OpenSSL 0.9.7 and has been available since
122.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/ERR_put_error.3 b/src/lib/libcrypto/man/ERR_put_error.3
deleted file mode 100644
index 37e1b4d1ab..0000000000
--- a/src/lib/libcrypto/man/ERR_put_error.3
+++ /dev/null
@@ -1,125 +0,0 @@
1.\" $OpenBSD: ERR_put_error.3,v 1.11 2024/08/29 20:23:21 tb Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: August 29 2024 $
52.Dt ERR_PUT_ERROR 3
53.Os
54.Sh NAME
55.Nm ERR_put_error
56.Nd record an OpenSSL error
57.Sh SYNOPSIS
58.In openssl/err.h
59.Ft void
60.Fo ERR_put_error
61.Fa "int lib"
62.Fa "int func"
63.Fa "int reason"
64.Fa "const char *file"
65.Fa "int line"
66.Fc
67.Sh DESCRIPTION
68.Fn ERR_put_error
69adds an error code to the thread's error queue.
70It signals that the error of reason code
71.Fa reason
72occurred in function
73.Fa func
74of library
75.Fa lib ,
76in line number
77.Fa line
78of
79.Fa file .
80This function is usually called by a macro.
81.Pp
82.Xr ERR_load_strings 3
83can be used to register error strings so that the application can
84generate human-readable error messages for the error code.
85.Pp
86Each sub-library has a specific macro
87.Fn XXXerr f r
88that is used to report errors.
89Its first argument is a function code
90.Dv XXX_F_* ;
91the second argument is a reason code
92.Dv XXX_R_* .
93Function codes are derived from the function names
94whereas reason codes consist of textual error descriptions.
95For example, the function
96.Fn ssl23_read
97reports a "handshake failure" as follows:
98.Pp
99.Dl SSLerr(SSL_F_SSL23_READ, SSL_R_SSL_HANDSHAKE_FAILURE);
100.Pp
101Function and reason codes should consist of upper case characters,
102numbers and underscores only.
103The error file generation script translates function codes into function
104names by looking in the header files for an appropriate function name.
105If none is found, it just uses the capitalized form such as "SSL23_READ"
106in the above example.
107.Pp
108The trailing section of a reason code (after the "_R_") is translated
109into lower case and underscores changed to spaces.
110.Pp
111Although a library will normally report errors using its own specific
112.Fn XXXerr
113macro, another library's macro can be used.
114This is normally only done when a library wants to include ASN.1 code
115which must use the
116.Fn ASN1err
117macro.
118.Sh SEE ALSO
119.Xr ERR 3 ,
120.Xr ERR_asprintf_error_data 3 ,
121.Xr ERR_load_strings 3
122.Sh HISTORY
123.Fn ERR_put_error
124first appeared in SSLeay 0.4.4 and has been available since
125.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/ERR_remove_state.3 b/src/lib/libcrypto/man/ERR_remove_state.3
deleted file mode 100644
index bc28f15dea..0000000000
--- a/src/lib/libcrypto/man/ERR_remove_state.3
+++ /dev/null
@@ -1,108 +0,0 @@
1.\" $OpenBSD: ERR_remove_state.3,v 1.7 2020/03/28 22:40:58 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
5.\" Matt Caswell <matt@openssl.org>.
6.\" Copyright (c) 2000, 2013 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: March 28 2020 $
53.Dt ERR_REMOVE_STATE 3
54.Os
55.Sh NAME
56.Nm ERR_remove_thread_state ,
57.Nm ERR_remove_state
58.Nd free a thread's OpenSSL error queue
59.Sh SYNOPSIS
60.In openssl/err.h
61.Ft void
62.Fo ERR_remove_thread_state
63.Fa "const CRYPTO_THREADID *tid"
64.Fc
65.Pp
66Deprecated:
67.Pp
68.Ft void
69.Fo ERR_remove_state
70.Fa "unsigned long pid"
71.Fc
72.Sh DESCRIPTION
73.Fn ERR_remove_thread_state
74frees the error queue associated with thread
75.Fa tid .
76If
77.Fa tid
78is
79.Dv NULL ,
80the current thread will have its error queue removed.
81.Pp
82Since error queue data structures are allocated automatically for new
83threads, they must be freed when threads are terminated in order to
84avoid memory leaks.
85.Pp
86.Fn ERR_remove_state
87is deprecated and has been replaced by
88.Fn ERR_remove_thread_state .
89Since threads in OpenSSL are no longer identified by unsigned long
90values, any argument to this function is ignored.
91Calling
92.Fn ERR_remove_state
93is equivalent to
94.Fn ERR_remove_thread_state NULL .
95.Sh SEE ALSO
96.Xr ERR 3
97.Sh HISTORY
98.Fn ERR_remove_state
99first appeared in SSLeay 0.6.1 and has been available since
100.Ox 2.4 .
101.Pp
102It was deprecated in OpenSSL 1.0.0 and
103.Ox 4.9
104when
105.Fn ERR_remove_thread_state
106was introduced and thread IDs were introduced to identify threads
107instead of
108.Vt unsigned long .
diff --git a/src/lib/libcrypto/man/ERR_set_mark.3 b/src/lib/libcrypto/man/ERR_set_mark.3
deleted file mode 100644
index 2f3486d8c0..0000000000
--- a/src/lib/libcrypto/man/ERR_set_mark.3
+++ /dev/null
@@ -1,86 +0,0 @@
1.\" $OpenBSD: ERR_set_mark.3,v 1.4 2018/03/23 00:09:11 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org>.
5.\" Copyright (c) 2003 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 23 2018 $
52.Dt ERR_SET_MARK 3
53.Os
54.Sh NAME
55.Nm ERR_set_mark ,
56.Nm ERR_pop_to_mark
57.Nd set marks and pop OpenSSL errors until mark
58.Sh SYNOPSIS
59.In openssl/err.h
60.Ft int
61.Fn ERR_set_mark void
62.Ft int
63.Fn ERR_pop_to_mark void
64.Sh DESCRIPTION
65.Fn ERR_set_mark
66sets a mark on the current topmost error record if there is one.
67.Pp
68.Fn ERR_pop_to_mark
69will pop the top of the error stack until a mark is found.
70The mark is then removed.
71If there is no mark, the whole stack is removed.
72.Sh RETURN VALUES
73.Fn ERR_set_mark
74returns 0 if the error stack is empty, otherwise 1.
75.Pp
76.Fn ERR_pop_to_mark
77returns 0 if there was no mark in the error stack, which implies that
78the stack became empty, otherwise 1.
79.Sh SEE ALSO
80.Xr ERR 3
81.Sh HISTORY
82.Fn ERR_set_mark
83and
84.Fn ERR_pop_to_mark
85first appeared in OpenSSL 0.9.8 and have been available since
86.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/ESS_SIGNING_CERT_new.3 b/src/lib/libcrypto/man/ESS_SIGNING_CERT_new.3
deleted file mode 100644
index 4baabbcd99..0000000000
--- a/src/lib/libcrypto/man/ESS_SIGNING_CERT_new.3
+++ /dev/null
@@ -1,117 +0,0 @@
1.\" $OpenBSD: ESS_SIGNING_CERT_new.3,v 1.5 2019/06/06 01:06:58 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 6 2019 $
18.Dt ESS_SIGNING_CERT_NEW 3
19.Os
20.Sh NAME
21.Nm ESS_SIGNING_CERT_new ,
22.Nm ESS_SIGNING_CERT_free ,
23.Nm ESS_CERT_ID_new ,
24.Nm ESS_CERT_ID_free ,
25.Nm ESS_ISSUER_SERIAL_new ,
26.Nm ESS_ISSUER_SERIAL_free
27.Nd signing certificates for S/MIME
28.Sh SYNOPSIS
29.In openssl/ts.h
30.Ft ESS_SIGNING_CERT *
31.Fn ESS_SIGNING_CERT_new void
32.Ft void
33.Fn ESS_SIGNING_CERT_free "ESS_SIGNING_CERT *signing_cert"
34.Ft ESS_CERT_ID *
35.Fn ESS_CERT_ID_new void
36.Ft void
37.Fn ESS_CERT_ID_free "ESS_CERT_ID *cert_id"
38.Ft ESS_ISSUER_SERIAL *
39.Fn ESS_ISSUER_SERIAL_new void
40.Ft void
41.Fn ESS_ISSUER_SERIAL_free "ESS_ISSUER_SERIAL *issuer_serial"
42.Sh DESCRIPTION
43The signing certificate may be included in the signedAttributes
44field of a
45.Vt SignerInfo
46structure to mitigate simple substitution and re-issue attacks.
47.Pp
48.Fn ESS_SIGNING_CERT_new
49allocates and initializes an empty
50.Vt ESS_SIGNING_CERT
51object, representing an ASN.1
52.Vt SigningCertificate
53structure defined in RFC 2634 section 5.4.
54It can hold the certificate used for signing the data,
55additional authorization certificates that can be used during
56validation, and policies applying to the certificate.
57.Fn ESS_SIGNING_CERT_free
58frees
59.Fa signing_cert .
60.Pp
61.Fn ESS_CERT_ID_new
62allocates and initializes an empty
63.Vt ESS_CERT_ID
64object, representing an ASN.1
65.Vt ESSCertID
66structure defined in RFC 2634 section 5.4.1.
67Such objects can be used inside
68.Vt ESS_SIGNING_CERT
69objects, and each one can hold a SHA1 hash of one certificate.
70.Fn ESS_CERT_ID_free
71frees
72.Fa cert_id .
73.Pp
74.Fn ESS_ISSUER_SERIAL_new
75allocates and initializes an empty
76.Vt ESS_ISSUER_SERIAL
77object, representing an ASN.1
78.Vt IssuerSerial
79structure defined in RFC 2634 section 5.4.1.
80It can hold an issuer name and a serial number and can be included in an
81.Vt ESS_CERT_ID
82object, which is useful for additional authorization certificates,
83but redundant for the signing certificate itself.
84.Fn ESS_ISSUER_SERIAL_free
85frees
86.Fa issuer_serial .
87.Sh RETURN VALUES
88.Fn ESS_SIGNING_CERT_new ,
89.Fn ESS_CERT_ID_new ,
90and
91.Fn ESS_ISSUER_SERIAL_new
92return the new
93.Vt ESS_SIGNING_CERT ,
94.Vt ESS_CERT_ID ,
95or
96.Vt ESS_ISSUER_SERIAL
97object, respectively, or
98.Dv NULL
99if an error occurred.
100.Sh SEE ALSO
101.Xr d2i_ESS_SIGNING_CERT 3
102.Sh STANDARDS
103RFC 2634: Enhanced Security Services for S/MIME,
104section 5: Signing Certificate Attribute
105.Pp
106Note that RFC 2634 has been updated by RFC 5035:
107Enhanced Security Services (ESS) Update:
108Adding CertID Algorithm Agility.
109But the current implementation only supports the
110Signing Certificate Attribute Definition Version 1
111according to RFC 2634, not the
112Signing Certificate Attribute Definition Version 2
113according to RFC 5035.
114.Sh HISTORY
115These functions first appeared in OpenSSL 1.0.0
116and have been available since
117.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_AEAD_CTX_init.3 b/src/lib/libcrypto/man/EVP_AEAD_CTX_init.3
deleted file mode 100644
index 8b3b8adb0f..0000000000
--- a/src/lib/libcrypto/man/EVP_AEAD_CTX_init.3
+++ /dev/null
@@ -1,411 +0,0 @@
1.\" $OpenBSD: EVP_AEAD_CTX_init.3,v 1.16 2024/07/21 08:36:43 tb Exp $
2.\"
3.\" Copyright (c) 2014, Google Inc.
4.\" Parts of the text were written by Adam Langley and David Benjamin.
5.\" Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
6.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
7.\"
8.\" Permission to use, copy, modify, and/or distribute this software for any
9.\" purpose with or without fee is hereby granted, provided that the above
10.\" copyright notice and this permission notice appear in all copies.
11.\"
12.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\"
20.Dd $Mdocdate: July 21 2024 $
21.Dt EVP_AEAD_CTX_INIT 3
22.Os
23.Sh NAME
24.Nm EVP_AEAD_CTX_new ,
25.Nm EVP_AEAD_CTX_free ,
26.Nm EVP_AEAD_CTX_init ,
27.Nm EVP_AEAD_CTX_cleanup ,
28.Nm EVP_AEAD_CTX_open ,
29.Nm EVP_AEAD_CTX_seal ,
30.Nm EVP_AEAD_key_length ,
31.Nm EVP_AEAD_max_overhead ,
32.Nm EVP_AEAD_max_tag_len ,
33.Nm EVP_AEAD_nonce_length ,
34.Nm EVP_aead_aes_128_gcm ,
35.Nm EVP_aead_aes_256_gcm ,
36.Nm EVP_aead_chacha20_poly1305 ,
37.Nm EVP_aead_xchacha20_poly1305
38.Nd authenticated encryption with additional data
39.Sh SYNOPSIS
40.In openssl/evp.h
41.Ft EVP_AEAD_CTX *
42.Fn EVP_AEAD_CTX_new void
43.Ft void
44.Fo EVP_AEAD_CTX_free
45.Fa "EVP_AEAD_CTX *ctx"
46.Fc
47.Ft int
48.Fo EVP_AEAD_CTX_init
49.Fa "EVP_AEAD_CTX *ctx"
50.Fa "const EVP_AEAD *aead"
51.Fa "const unsigned char *key"
52.Fa "size_t key_len"
53.Fa "size_t tag_len"
54.Fa "ENGINE *engine"
55.Fc
56.Ft void
57.Fo EVP_AEAD_CTX_cleanup
58.Fa "EVP_AEAD_CTX *ctx"
59.Fc
60.Ft int
61.Fo EVP_AEAD_CTX_open
62.Fa "const EVP_AEAD_CTX *ctx"
63.Fa "unsigned char *out"
64.Fa "size_t *out_len"
65.Fa "size_t max_out_len"
66.Fa "const unsigned char *nonce"
67.Fa "size_t nonce_len"
68.Fa "const unsigned char *in"
69.Fa "size_t in_len"
70.Fa "const unsigned char *ad"
71.Fa "size_t ad_len"
72.Fc
73.Ft int
74.Fo EVP_AEAD_CTX_seal
75.Fa "const EVP_AEAD_CTX *ctx"
76.Fa "unsigned char *out"
77.Fa "size_t *out_len"
78.Fa "size_t max_out_len"
79.Fa "const unsigned char *nonce"
80.Fa "size_t nonce_len"
81.Fa "const unsigned char *in"
82.Fa "size_t in_len"
83.Fa "const unsigned char *ad"
84.Fa "size_t ad_len"
85.Fc
86.Ft size_t
87.Fo EVP_AEAD_key_length
88.Fa "const EVP_AEAD *aead"
89.Fc
90.Ft size_t
91.Fo EVP_AEAD_max_overhead
92.Fa "const EVP_AEAD *aead"
93.Fc
94.Ft size_t
95.Fo EVP_AEAD_max_tag_len
96.Fa "const EVP_AEAD *aead"
97.Fc
98.Ft size_t
99.Fo EVP_AEAD_nonce_length
100.Fa "const EVP_AEAD *aead"
101.Fc
102.Ft const EVP_AEAD *
103.Fo EVP_aead_aes_128_gcm
104.Fa void
105.Fc
106.Ft const EVP_AEAD *
107.Fo EVP_aead_aes_256_gcm
108.Fa void
109.Fc
110.Ft const EVP_AEAD *
111.Fo EVP_aead_chacha20_poly1305
112.Fa void
113.Fc
114.Ft const EVP_AEAD *
115.Fo EVP_aead_xchacha20_poly1305
116.Fa void
117.Fc
118.Sh DESCRIPTION
119AEAD (Authenticated Encryption with Additional Data) couples
120confidentiality and integrity in a single primitive.
121AEAD algorithms take a key and can then seal and open individual
122messages.
123Each message has a unique, per-message nonce and, optionally, additional
124data which is authenticated but not included in the output.
125.Pp
126.Fn EVP_AEAD_CTX_new
127allocates a new context for use with
128.Fn EVP_AEAD_CTX_init .
129It can be cleaned up for reuse with
130.Fn EVP_AEAD_CTX_cleanup
131and must be freed with
132.Fn EVP_AEAD_CTX_free .
133.Pp
134.Fn EVP_AEAD_CTX_free
135cleans up
136.Fa ctx
137and frees the space allocated to it.
138.Pp
139.Fn EVP_AEAD_CTX_init
140initializes the context
141.Fa ctx
142for the given AEAD algorithm
143.Fa aead .
144The
145.Fa engine
146argument must be
147.Dv NULL
148for the default implementation;
149other values are not supported.
150Authentication tags may be truncated by passing a tag length.
151A
152.Fa tag_len
153argument of
154.Dv EVP_AEAD_DEFAULT_TAG_LENGTH ,
155which has the value 0, causes the default tag length to be used.
156.Pp
157.Fn EVP_AEAD_CTX_cleanup
158frees any data allocated for the context
159.Fa ctx .
160After
161.Fn EVP_AEAD_CTX_cleanup ,
162.Fa ctx
163is in the same state as after
164.Fn EVP_AEAD_CTX_new .
165.Pp
166.Fn EVP_AEAD_CTX_open
167authenticates the input
168.Fa in
169and optional additional data
170.Fa ad ,
171decrypting the input and writing it as output
172.Fa out .
173This function may be called (with the same
174.Vt EVP_AEAD_CTX )
175concurrently with itself or with
176.Fn EVP_AEAD_CTX_seal .
177At most the number of input bytes are written as output.
178In order to ensure success,
179.Fa max_out_len
180should be at least the same as the input length
181.Fa in_len .
182On successful return
183.Fa out_len
184is set to the actual number of bytes written.
185The length of the
186.Fa nonce
187specified with
188.Fa nonce_len
189must be equal to the result of EVP_AEAD_nonce_length for this AEAD.
190.Fn EVP_AEAD_CTX_open
191never results in partial output.
192If
193.Fa max_out_len
194is insufficient, zero will be returned and
195.Fa out_len
196will be set to zero.
197If the input and output are aliased then
198.Fa out
199must be <=
200.Fa in .
201.Pp
202.Fn EVP_AEAD_CTX_seal
203encrypts and authenticates the input and authenticates any additional
204data provided in
205.Fa ad ,
206the encrypted input and authentication tag being written as output
207.Fa out .
208This function may be called (with the same
209.Vt EVP_AEAD_CTX )
210concurrently with itself or with
211.Fn EVP_AEAD_CTX_open .
212At most
213.Fa max_out_len
214bytes are written as output and, in order to ensure success, this value
215should be the
216.Fa in_len
217plus the result of
218.Fn EVP_AEAD_max_overhead .
219On successful return,
220.Fa out_len
221is set to the actual number of bytes written.
222The length of the
223.Fa nonce
224specified with
225.Fa nonce_len
226must be equal to the result of
227.Fn EVP_AEAD_nonce_length
228for this AEAD.
229.Fn EVP_AEAD_CTX_seal
230never results in a partial output.
231If
232.Fa max_out_len
233is insufficient, zero will be returned and
234.Fa out_len
235will be set to zero.
236If the input and output are aliased then
237.Fa out
238must be <=
239.Fa in .
240.Pp
241.Fn EVP_AEAD_key_length ,
242.Fn EVP_AEAD_max_overhead ,
243.Fn EVP_AEAD_max_tag_len ,
244and
245.Fn EVP_AEAD_nonce_length
246provide information about the AEAD algorithm
247.Fa aead .
248.Pp
249.Fn EVP_AEAD_max_tag_len
250returns the maximum tag length that can be used with the given
251.Fa aead .
252This is the largest value that can be passed as the
253.Fa tag_len
254argument to
255.Fn EVP_AEAD_CTX_init .
256No built-in
257.Vt EVP_AEAD
258object has a maximum tag length larger than the constant
259.Dv EVP_AEAD_MAX_TAG_LENGTH .
260.Pp
261All cipher algorithms have a fixed key length unless otherwise stated.
262The following ciphers are available:
263.Bl -tag -width Ds -offset indent
264.It Fn EVP_aead_aes_128_gcm
265AES-128 in Galois Counter Mode, using a
266.Fa key_len
267of 16 bytes and a
268.Fa nonce_len
269of 12 bytes.
270.It Fn EVP_aead_aes_256_gcm
271AES-256 in Galois Counter Mode, using a
272.Fa key_len
273of 32 bytes and a
274.Fa nonce_len
275of 12 bytes.
276.It Fn EVP_aead_chacha20_poly1305
277ChaCha20 with a Poly1305 authenticator, using a
278.Fa key_len
279of 32 bytes and a
280.Fa nonce_len
281of 12 bytes.
282The constant
283.Dv EVP_CHACHAPOLY_TLS_TAG_LEN
284specifies the length of the authentication tag in bytes and has a value of 16.
285.It Fn EVP_aead_xchacha20_poly1305
286XChaCha20 with a Poly1305 authenticator, using a
287.Fa key_len
288of 32 bytes and a
289.Fa nonce_len
290of 24 bytes.
291.El
292.Pp
293Unless compatibility with other implementations
294like OpenSSL or BoringSSL is required, using the
295.Sy EVP_AEAD
296interface to AEAD ciphers is recommended
297in preference to the functions documented in the
298.Xr EVP_EncryptInit 3 ,
299.Xr EVP_aes_256_gcm 3 ,
300and
301.Xr EVP_chacha20_poly1305 3
302manual pages.
303The code then becomes transparent to the AEAD cipher used
304and much more flexible.
305It is also safer to use as it prevents common mistakes with the EVP APIs.
306.Sh RETURN VALUES
307.Fn EVP_AEAD_CTX_new
308returns the new
309.Vt EVP_AEAD_CTX
310object on success;
311otherwise
312.Dv NULL
313is returned and
314.Va errno
315is set to
316.Er ENOMEM .
317.Pp
318.Fn EVP_AEAD_CTX_init ,
319.Fn EVP_AEAD_CTX_open ,
320and
321.Fn EVP_AEAD_CTX_seal
322return 1 for success or zero for failure.
323.Pp
324.Fn EVP_AEAD_key_length
325returns the length of the key used for this AEAD.
326.Pp
327.Fn EVP_AEAD_max_overhead
328returns the maximum number of additional bytes added by the act of
329sealing data with the AEAD.
330.Pp
331.Fn EVP_AEAD_max_tag_len
332returns the maximum tag length when using this AEAD.
333.Pp
334.Fn EVP_AEAD_nonce_length
335returns the length of the per-message nonce.
336.Sh EXAMPLES
337Encrypt a string using ChaCha20-Poly1305:
338.Bd -literal -offset indent
339const EVP_AEAD *aead = EVP_aead_chacha20_poly1305();
340static const unsigned char nonce[32] = {0};
341size_t buf_len, nonce_len;
342EVP_AEAD_CTX *ctx;
343
344ctx = EVP_AEAD_CTX_new();
345EVP_AEAD_CTX_init(ctx, aead, key32, EVP_AEAD_key_length(aead),
346 EVP_AEAD_DEFAULT_TAG_LENGTH, NULL);
347nonce_len = EVP_AEAD_nonce_length(aead);
348
349EVP_AEAD_CTX_seal(ctx, out, &out_len, BUFSIZE, nonce,
350 nonce_len, in, in_len, NULL, 0);
351
352EVP_AEAD_CTX_free(ctx);
353.Ed
354.Sh SEE ALSO
355.Xr evp 3 ,
356.Xr EVP_EncryptInit 3
357.Sh STANDARDS
358.Rs
359.%A A. Langley
360.%A W. Chang
361.%A N. Mavrogiannopoulos
362.%A J. Strombergson
363.%A S. Josefsson
364.%D June 2016
365.%R RFC 7905
366.%T ChaCha20-Poly1305 Cipher Suites for Transport Layer Security (TLS)
367.Re
368.Pp
369.Rs
370.%A S. Arciszewski
371.%D October 2018
372.%R draft-arciszewski-xchacha-02
373.%T XChaCha: eXtended-nonce ChaCha and AEAD_XChaCha20_Poly1305
374.Re
375.Sh HISTORY
376AEAD is based on the implementation by
377.An Adam Langley
378.\" OpenSSL commit 9a8646510b Sep 9 12:13:24 2013 -0400
379for Chromium/BoringSSL and first appeared in
380.Ox 5.6 .
381.Pp
382.Fn EVP_AEAD_CTX_new
383and
384.Fn EVP_AEAD_CTX_free
385first appeared in
386.Ox 7.1 .
387.Sh CAVEATS
388The original publications and code by
389.An Adam Langley
390used a modified AEAD construction that is incompatible with the common
391style used by AEAD in TLS and incompatible with RFC 7905:
392.Pp
393.Rs
394.%A A. Langley
395.%A W. Chang
396.%D November 2013
397.%R draft-agl-tls-chacha20poly1305-04
398.%T ChaCha20 and Poly1305 based Cipher Suites for TLS
399.Re
400.Pp
401.Rs
402.%A Y. Nir
403.%A A. Langley
404.%D June 2018
405.%R RFC 8439
406.%T ChaCha20 and Poly1305 for IETF Protocols
407.Re
408.Pp
409In particular, the original version used a
410.Fa nonce_len
411of 8 bytes.
diff --git a/src/lib/libcrypto/man/EVP_BytesToKey.3 b/src/lib/libcrypto/man/EVP_BytesToKey.3
deleted file mode 100644
index 1f78b4de06..0000000000
--- a/src/lib/libcrypto/man/EVP_BytesToKey.3
+++ /dev/null
@@ -1,145 +0,0 @@
1.\" $OpenBSD: EVP_BytesToKey.3,v 1.9 2024/12/05 15:12:37 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2001, 2011, 2013, 2014, 2015 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 5 2024 $
53.Dt EVP_BYTESTOKEY 3
54.Os
55.Sh NAME
56.Nm EVP_BytesToKey
57.Nd password based encryption routine
58.Sh SYNOPSIS
59.In openssl/evp.h
60.Ft int
61.Fo EVP_BytesToKey
62.Fa "const EVP_CIPHER *type"
63.Fa "const EVP_MD *md"
64.Fa "const unsigned char *salt"
65.Fa "const unsigned char *data"
66.Fa "int datal"
67.Fa "int count"
68.Fa "unsigned char *key"
69.Fa "unsigned char *iv"
70.Fc
71.Sh DESCRIPTION
72.Fn EVP_BytesToKey
73derives a key and IV from various parameters.
74.Fa type
75is the cipher to derive the key and IV for.
76.Fa md
77is the message digest to use.
78The
79.Fa salt
80parameter is used as a salt in the derivation:
81it should point to a buffer containing
82.Dv PKCS5_SALT_LEN No = 8
83bytes or
84.Dv NULL
85if no salt is used.
86.Fa data
87is a buffer containing
88.Fa datal
89bytes which is used to derive the keying data.
90.Fa count
91is the iteration count to use.
92The derived key and IV will be written to
93.Fa key
94and
95.Fa iv ,
96respectively.
97.Pp
98A typical application of this function is to derive keying material for
99an encryption algorithm from a password in the
100.Fa data
101parameter.
102.Pp
103Increasing the
104.Fa count
105parameter slows down the algorithm, which makes it harder for an attacker
106to perform a brute force attack using a large number of candidate
107passwords.
108.Pp
109If the total key and IV length is less than the digest length and MD5
110is used, then the derivation algorithm is compatible with PKCS#5 v1.5.
111Otherwise, a non-standard extension is used to derive the extra data.
112.Pp
113Newer applications should use more standard algorithms such as PBKDF2 as
114defined in PKCS#5v2.1 for key derivation.
115.Sh KEY DERIVATION ALGORITHM
116The key and IV is derived by concatenating D_1, D_2, etc. until enough
117data is available for the key and IV.
118D_i is defined recursively as:
119.Pp
120.Dl D_i = HASH^count(D_(i-1) || data || salt)
121.Pp
122where || denotes concatenation, D_0 is empty, HASH is the digest
123algorithm in use, HASH^1(data) is simply HASH(data), HASH^2(data) is
124HASH(HASH(data)) and so on.
125.Pp
126The initial bytes are used for the key and the subsequent bytes for the
127IV.
128.Sh RETURN VALUES
129If
130.Fa data
131is
132.Dv NULL ,
133.Fn EVP_BytesToKey
134returns the number of bytes needed to store the derived key.
135Otherwise,
136.Fn EVP_BytesToKey
137returns the size of the derived key in bytes or 0 on error.
138.Sh SEE ALSO
139.Xr evp 3 ,
140.Xr EVP_EncryptInit 3 ,
141.Xr PKCS5_PBKDF2_HMAC 3
142.Sh HISTORY
143.Fn EVP_BytesToKey
144first appeared in SSLeay 0.5.1 and has been available since
145.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3
deleted file mode 100644
index d7ab36e711..0000000000
--- a/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3
+++ /dev/null
@@ -1,261 +0,0 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_ctrl.3,v 1.4 2025/03/25 11:54:34 tb Exp $
2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018, 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\" Copyright (c) 2018 Damien Miller <djm@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000, 2001, 2016 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: March 25 2025 $
71.Dt EVP_CIPHER_CTX_CTRL 3
72.Os
73.Sh NAME
74.Nm EVP_CIPHER_CTX_ctrl ,
75.Nm EVP_CIPHER_CTX_set_padding ,
76.Nm EVP_CIPHER_CTX_set_key_length ,
77.Nm EVP_CIPHER_CTX_key_length ,
78.Nm EVP_CIPHER_key_length ,
79.Nm EVP_CIPHER_CTX_iv_length ,
80.Nm EVP_CIPHER_iv_length ,
81.Nm EVP_CIPHER_CTX_set_iv ,
82.Nm EVP_CIPHER_CTX_get_iv
83.Nd configure EVP cipher contexts
84.Sh SYNOPSIS
85.In openssl/evp.h
86.Ft int
87.Fo EVP_CIPHER_CTX_ctrl
88.Fa "EVP_CIPHER_CTX *ctx"
89.Fa "int type"
90.Fa "int arg"
91.Fa "void *ptr"
92.Fc
93.Ft int
94.Fo EVP_CIPHER_CTX_set_padding
95.Fa "EVP_CIPHER_CTX *x"
96.Fa "int padding"
97.Fc
98.Ft int
99.Fo EVP_CIPHER_CTX_set_key_length
100.Fa "EVP_CIPHER_CTX *x"
101.Fa "int keylen"
102.Fc
103.Ft int
104.Fo EVP_CIPHER_CTX_key_length
105.Fa "const EVP_CIPHER_CTX *ctx"
106.Fc
107.Ft int
108.Fo EVP_CIPHER_key_length
109.Fa "const EVP_CIPHER *e"
110.Fc
111.Ft int
112.Fo EVP_CIPHER_CTX_iv_length
113.Fa "const EVP_CIPHER_CTX *ctx"
114.Fc
115.Ft int
116.Fo EVP_CIPHER_iv_length
117.Fa "const EVP_CIPHER *e"
118.Fc
119.Ft int
120.Fo EVP_CIPHER_CTX_set_iv
121.Fa "EVP_CIPHER_CTX *ctx"
122.Fa "const unsigned char *iv"
123.Fa "size_t len"
124.Fc
125.Ft int
126.Fo EVP_CIPHER_CTX_get_iv
127.Fa "const EVP_CIPHER_CTX *ctx"
128.Fa "unsigned char *iv"
129.Fa "size_t len"
130.Fc
131.Sh DESCRIPTION
132.Fn EVP_CIPHER_CTX_ctrl
133allows various cipher specific parameters to be determined and set.
134Currently only the RC2 effective key length can be set; see
135.Xr EVP_rc2_cbc 3
136for details.
137.Pp
138.Fn EVP_CIPHER_CTX_set_padding
139enables or disables padding.
140This function should be called after the context is set up for
141encryption or decryption with
142.Xr EVP_EncryptInit_ex 3 ,
143.Xr EVP_DecryptInit_ex 3 ,
144or
145.Xr EVP_CipherInit_ex 3 .
146By default encryption operations are padded using standard block padding
147and the padding is checked and removed when decrypting.
148If the
149.Fa padding
150parameter is zero, then no padding is performed, the total amount of data
151encrypted or decrypted must then be a multiple of the block size or an
152error will occur.
153.Pp
154.Fn EVP_CIPHER_CTX_set_key_length
155sets the key length of the cipher ctx.
156If the cipher is a fixed length cipher, then attempting to set the key
157length to any value other than the fixed value is an error.
158.Pp
159.Fn EVP_CIPHER_CTX_key_length
160and
161.Fn EVP_CIPHER_key_length
162return the key length of a cipher when passed an
163.Vt EVP_CIPHER_CTX
164or
165.Vt EVP_CIPHER
166structure.
167The constant
168.Dv EVP_MAX_KEY_LENGTH
169is the maximum key length for all ciphers.
170Note: although
171.Fn EVP_CIPHER_key_length
172is fixed for a given cipher, the value of
173.Fn EVP_CIPHER_CTX_key_length
174may be different for variable key length ciphers.
175.Pp
176.Fn EVP_CIPHER_CTX_iv_length
177and
178.Fn EVP_CIPHER_iv_length
179return the IV length of a cipher when passed an
180.Vt EVP_CIPHER_CTX
181or
182.Vt EVP_CIPHER .
183They will return zero if the cipher does not use an IV.
184.Fn EVP_CIPHER_CTX_iv_length
185can fail and return \-1.
186The constant
187.Dv EVP_MAX_IV_LENGTH
188is the maximum IV length for all ciphers.
189.Pp
190.Fn EVP_CIPHER_CTX_set_iv
191and
192.Fn EVP_CIPHER_CTX_get_iv
193set and retrieve the IV for an
194.Vt EVP_CIPHER_CTX ,
195respectively.
196In both cases, the specified IV length must exactly equal the expected
197IV length for the context as returned by
198.Fn EVP_CIPHER_CTX_iv_length .
199.Sh RETURN VALUES
200.Fn EVP_CIPHER_CTX_ctrl
201returns 1 for success or 0 for failure.
202Some implementations may return negative values for some errors.
203.Pp
204.Fn EVP_CIPHER_CTX_set_padding
205always returns 1.
206.Pp
207.Fn EVP_CIPHER_CTX_set_key_length ,
208.Fn EVP_CIPHER_CTX_set_iv ,
209and
210.Fn EVP_CIPHER_CTX_get_iv
211return 1 for success or 0 for failure.
212.Pp
213.Fn EVP_CIPHER_CTX_key_length
214and
215.Fn EVP_CIPHER_key_length
216return the key length.
217.Pp
218.Fn EVP_CIPHER_CTX_iv_length
219and
220.Fn EVP_CIPHER_iv_length
221return the IV length or zero if the cipher does not use an IV.
222.Fn EVP_CIPHER_CTX_iv_length
223can fail and return \-1.
224.Sh SEE ALSO
225.Xr evp 3 ,
226.Xr EVP_CIPHER_nid 3 ,
227.Xr EVP_EncryptInit 3
228.Sh HISTORY
229.Fn EVP_CIPHER_CTX_key_length ,
230.Fn EVP_CIPHER_key_length ,
231.Fn EVP_CIPHER_CTX_iv_length ,
232and
233.Fn EVP_CIPHER_iv_length
234first appeared in SSLeay 0.6.5 and have been available since
235.Ox 2.4 .
236.Pp
237.Fn EVP_CIPHER_CTX_ctrl
238and
239.Fn EVP_CIPHER_CTX_set_key_length
240first appeared in OpenSSL 0.9.6 and have been available since
241.Ox 2.9 .
242.Pp
243.Fn EVP_CIPHER_CTX_set_padding
244first appeared in OpenSSL 0.9.7 and has been available since
245.Ox 3.2 .
246.Pp
247.Fn EVP_CIPHER_CTX_set_iv
248and
249.Fn EVP_CIPHER_CTX_get_iv
250first appeared in LibreSSL 2.8.1 and have been available since
251.Ox 6.4 .
252.Sh BUGS
253.Dv EVP_MAX_KEY_LENGTH
254and
255.Dv EVP_MAX_IV_LENGTH
256only refer to the internal ciphers with default key lengths.
257If custom ciphers exceed these values, the results are unpredictable.
258This is because it has become standard practice to define a generic key
259as a fixed unsigned char array containing
260.Dv EVP_MAX_KEY_LENGTH
261bytes.
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3
deleted file mode 100644
index 4f75c8b008..0000000000
--- a/src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3
+++ /dev/null
@@ -1,146 +0,0 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_get_cipher_data.3,v 1.3 2023/08/26 15:12:04 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Matt Caswell <matt@openssl.org>.
22.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: August 26 2023 $
69.Dt EVP_CIPHER_CTX_GET_CIPHER_DATA 3
70.Os
71.Sh NAME
72.Nm EVP_CIPHER_CTX_get_cipher_data ,
73.Nm EVP_CIPHER_CTX_set_cipher_data ,
74.Nm EVP_CIPHER_CTX_buf_noconst
75.Nd inspect and modify EVP_CIPHER_CTX objects
76.Sh SYNOPSIS
77.In openssl/evp.h
78.Ft void *
79.Fo EVP_CIPHER_CTX_get_cipher_data
80.Fa "const EVP_CIPHER_CTX *ctx"
81.Fc
82.Ft void *
83.Fo EVP_CIPHER_CTX_set_cipher_data
84.Fa "EVP_CIPHER_CTX *ctx"
85.Fa "void *cipher_data"
86.Fc
87.Ft unsigned char *
88.Fo EVP_CIPHER_CTX_buf_noconst
89.Fa "EVP_CIPHER_CTX *ctx"
90.Fc
91.Sh DESCRIPTION
92.Fn EVP_CIPHER_CTX_get_cipher_data
93returns a pointer to the cipher data of
94.Fa ctx .
95The format and content of this data is specific to the algorithm
96and to the particular implementation of the cipher.
97For example, this data can be used by engines
98to store engine specific information.
99The data is automatically allocated and freed by OpenSSL, so
100applications and engines should not normally free this directly (but see
101below).
102.Pp
103.Fn EVP_CIPHER_CTX_set_cipher_data
104allows an application or engine to replace the existing cipher data
105with new data, transferring ownership of
106.Fa cipher_data
107to the
108.Fa ctx
109object.
110A pointer to any existing cipher data is returned from this function.
111If the old data is no longer required,
112it should be freed through a call to
113.Xr free 3 .
114.Pp
115.Fn EVP_CIPHER_CTX_buf_noconst
116provides engines and custom cipher implementations
117with access to the internal buffer that
118.Xr EVP_EncryptUpdate 3
119copies input data into before encrypting it.
120This function can for example be used
121inside callback functions installed with
122.Xr EVP_CIPHER_meth_set_do_cipher 3 .
123.Sh RETURN VALUES
124.Fn EVP_CIPHER_CTX_get_cipher_data
125returns an internal pointer owned by
126.Fa ctx .
127.Pp
128.Fn EVP_CIPHER_CTX_set_cipher_data
129returns a pointer to the old cipher data of
130.Fa ctx
131and transfers ownership to the caller.
132.Pp
133.Fn EVP_CIPHER_CTX_buf_noconst
134returns a pointer to an internal buffer owned by
135.Fa ctx .
136.Sh SEE ALSO
137.Xr evp 3 ,
138.Xr EVP_CIPHER_meth_new 3 ,
139.Xr EVP_EncryptInit 3
140.Sh HISTORY
141.Fn EVP_CIPHER_CTX_get_cipher_data ,
142.Fn EVP_CIPHER_CTX_set_cipher_data ,
143and
144.Fn EVP_CIPHER_CTX_buf_noconst
145first appeared in OpenSSL 1.1.0 and have been available since
146.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3
deleted file mode 100644
index 79a8e540af..0000000000
--- a/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3
+++ /dev/null
@@ -1,209 +0,0 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_init.3,v 1.4 2024/12/06 15:01:01 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2018, 2019, 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
23.\" and Richard Levitte <levitte@openssl.org>.
24.\" Copyright (c) 2000-2001, 2015 The OpenSSL Project.
25.\" All rights reserved.
26.\"
27.\" Redistribution and use in source and binary forms, with or without
28.\" modification, are permitted provided that the following conditions
29.\" are met:
30.\"
31.\" 1. Redistributions of source code must retain the above copyright
32.\" notice, this list of conditions and the following disclaimer.
33.\"
34.\" 2. Redistributions in binary form must reproduce the above copyright
35.\" notice, this list of conditions and the following disclaimer in
36.\" the documentation and/or other materials provided with the
37.\" distribution.
38.\"
39.\" 3. All advertising materials mentioning features or use of this
40.\" software must display the following acknowledgment:
41.\" "This product includes software developed by the OpenSSL Project
42.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
43.\"
44.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
45.\" endorse or promote products derived from this software without
46.\" prior written permission. For written permission, please contact
47.\" openssl-core@openssl.org.
48.\"
49.\" 5. Products derived from this software may not be called "OpenSSL"
50.\" nor may "OpenSSL" appear in their names without prior written
51.\" permission of the OpenSSL Project.
52.\"
53.\" 6. Redistributions of any form whatsoever must retain the following
54.\" acknowledgment:
55.\" "This product includes software developed by the OpenSSL Project
56.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
57.\"
58.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
59.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
62.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
67.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\"
71.Dd $Mdocdate: December 6 2024 $
72.Dt EVP_CIPHER_CTX_INIT 3
73.Os
74.Sh NAME
75.Nm EVP_CIPHER_CTX_init ,
76.Nm EVP_CIPHER_CTX_cleanup ,
77.Nm EVP_Cipher
78.Nd obsolete EVP cipher functions
79.Sh SYNOPSIS
80.In openssl/evp.h
81.Ft int
82.Fo EVP_CIPHER_CTX_init
83.Fa "EVP_CIPHER_CTX *ctx"
84.Fc
85.Ft int
86.Fo EVP_CIPHER_CTX_cleanup
87.Fa "EVP_CIPHER_CTX *ctx"
88.Fc
89.Ft int
90.Fo EVP_Cipher
91.Fa "EVP_CIPHER_CTX *ctx"
92.Fa "unsigned char *out"
93.Fa "const unsigned char *in"
94.Fa "unsigned int in_len"
95.Fc
96.Sh DESCRIPTION
97.Fn EVP_CIPHER_CTX_init
98is a deprecated function that could be used to clear a cipher context
99on the stack before
100.Vt EVP_CIPHER_CTX
101was made opaque.
102Calling it on a cipher context just returned from
103.Xr EVP_CIPHER_CTX_new 3
104has no effect.
105Calling it on a cipher context that was already used may leak memory
106with older versions of the library.
107Instead, use
108.Xr EVP_CIPHER_CTX_reset 3
109or
110.Xr EVP_CIPHER_CTX_free 3 .
111.Pp
112.Fn EVP_CIPHER_CTX_cleanup
113is a deprecated alias for
114.Xr EVP_CIPHER_CTX_reset 3 .
115It clears all information from
116.Fa ctx
117and frees all allocated memory associated with it, except the
118.Fa ctx
119object itself.
120.Pp
121.Fn EVP_Cipher
122exposes implementation details of the functions
123.Xr EVP_CipherUpdate 3
124and
125.Xr EVP_CipherFinal 3
126that should never have become part of the public API.
127.Pp
128If the flag
129.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER
130is set for the cipher used by
131.Fa ctx ,
132behaviour depends on
133.Fa in .
134If that argument is
135.Dv NULL
136and
137.Fa in_len
138is 0, behaviour is similar to
139.Xr EVP_CipherFinal 3 ;
140if
141.Fa in_len
142is not 0, behaviour is undefined.
143If
144.Fa in
145is not
146.Dv NULL ,
147behaviour is similar to
148.Xr EVP_CipherUpdate 3 .
149In both cases, the exceptions to the similarity are that arguments
150and return values differ.
151.Pp
152If the flag
153.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER
154is not set for the cipher used by
155.Fa ctx ,
156it encrypts or decrypts aligned blocks of data
157whose lengths match the cipher block size.
158It requires that the previous encryption or decryption operation
159using the same
160.Fa ctx ,
161if there was any, ended exactly on a block boundary and that
162.Fa in_len
163is an integer multiple of the cipher block size.
164If either of these conditions is violated,
165.Fn EVP_Cipher
166silently produces incorrect results.
167For that reason, using the function
168.Xr EVP_CipherUpdate 3
169instead is strongly recommended.
170The latter can safely handle partial blocks, and even if
171.Fa in_len
172actually is a multiple of the cipher block size for all calls,
173the overhead incurred by using
174.Xr EVP_CipherUpdate 3
175is minimal.
176.Sh RETURN VALUES
177.Fn EVP_CIPHER_CTX_init
178always returns 1.
179.Pp
180.Fn EVP_CIPHER_CTX_cleanup
181returns 1 for success or 0 for failure.
182.Pp
183With
184.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER ,
185.Fn EVP_Cipher
186returns the number of bytes written to
187.Fa out
188for success or \-1 for failure.
189Without
190.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER ,
191it returns 1 for success or 0 for failure.
192.Sh SEE ALSO
193.Xr evp 3 ,
194.Xr EVP_EncryptInit 3
195.Sh HISTORY
196.Fn EVP_Cipher
197first appeared in SSLeay 0.6.5.
198.Fn EVP_CIPHER_CTX_cleanup
199first appeared in SSLeay 0.8.0.
200.Fn EVP_CIPHER_CTX_init
201first appeared in SSLeay 0.9.0.
202All these functions have been available since
203.Ox 2.4 .
204.Sh CAVEATS
205Checking the return value of
206.Fn EVP_Cipher
207requires unusual caution: zero signals success if
208.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER
209is set or failure otherwise.
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_set_flags.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_set_flags.3
deleted file mode 100644
index 67ef8679bc..0000000000
--- a/src/lib/libcrypto/man/EVP_CIPHER_CTX_set_flags.3
+++ /dev/null
@@ -1,233 +0,0 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_set_flags.3,v 1.2 2023/09/06 16:26:49 schwarze Exp $
2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
22.\" and Patrick Steuer <patrick.steuer@de.ibm.com>.
23.\" Copyright (c) 2000, 2017 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: September 6 2023 $
71.Dt EVP_CIPHER_CTX_SET_FLAGS 3
72.Os
73.Sh NAME
74.Nm EVP_CIPHER_CTX_set_flags ,
75.Nm EVP_CIPHER_CTX_clear_flags ,
76.Nm EVP_CIPHER_CTX_test_flags ,
77.Nm EVP_CIPHER_CTX_rand_key ,
78.Nm EVP_CIPHER_param_to_asn1 ,
79.Nm EVP_CIPHER_asn1_to_param ,
80.\" .Nm EVP_CIPHER_set_asn1_iv and
81.\" .Nm EVP_CIPHER_get_asn1_iv are intentionally undocumented
82.\" because they are unused according to codesearch.debian.net
83.\" and should probably not be public: they seem hardly useful
84.\" even for implementing custom EVP_CIPHER algorithms.
85.Nm EVP_CIPHER_CTX_get_app_data ,
86.Nm EVP_CIPHER_CTX_set_app_data
87.Nd unusual EVP cipher context configuration
88.Sh SYNOPSIS
89.In openssl/evp.h
90.Ft void
91.Fo EVP_CIPHER_CTX_set_flags
92.Fa "EVP_CIPHER_CTX *ctx"
93.Fa "int flags"
94.Fc
95.Ft void
96.Fo EVP_CIPHER_CTX_clear_flags
97.Fa "EVP_CIPHER_CTX *ctx"
98.Fa "int flags"
99.Fc
100.Ft int
101.Fo EVP_CIPHER_CTX_test_flags
102.Fa "EVP_CIPHER_CTX *ctx"
103.Fa "int flags"
104.Fc
105.Ft int
106.Fo EVP_CIPHER_CTX_rand_key
107.Fa "EVP_CIPHER_CTX *ctx"
108.Fa "unsigned char *key"
109.Fc
110.Ft int
111.Fo EVP_CIPHER_param_to_asn1
112.Fa "EVP_CIPHER_CTX *c"
113.Fa "ASN1_TYPE *type"
114.Fc
115.Ft int
116.Fo EVP_CIPHER_asn1_to_param
117.Fa "EVP_CIPHER_CTX *c"
118.Fa "ASN1_TYPE *type"
119.Fc
120.Ft void *
121.Fo EVP_CIPHER_CTX_get_app_data
122.Fa "const EVP_CIPHER_CTX *ctx"
123.Fc
124.Ft void
125.Fo EVP_CIPHER_CTX_set_app_data
126.Fa "const EVP_CIPHER_CTX *ctx"
127.Fa "void *data"
128.Fc
129.Sh DESCRIPTION
130.Fn EVP_CIPHER_CTX_set_flags
131enables the given
132.Fa flags
133in
134.Fa ctx .
135.Fn EVP_CIPHER_CTX_clear_flags
136disables the given
137.Fa flags
138in
139.Fa ctx .
140.Fn EVP_CIPHER_CTX_test_flags
141checks whether any of the given
142.Fa flags
143are currently set in
144.Fa ctx ,
145returning the subset of the
146.Fa flags
147that are set, or 0 if none of them are set.
148Currently, the only supported cipher context flag is
149.Dv EVP_CIPHER_CTX_FLAG_WRAP_ALLOW ;
150see
151.Xr EVP_aes_128_wrap 3
152for details.
153.Pp
154.Fn EVP_CIPHER_CTX_rand_key
155generates a random key of the appropriate length based on the cipher
156context.
157The
158.Vt EVP_CIPHER
159can provide its own random key generation routine to support keys
160of a specific form.
161The
162.Fa key
163argument must point to a buffer at least as big as the value returned by
164.Xr EVP_CIPHER_CTX_key_length 3 .
165.Pp
166.Fn EVP_CIPHER_param_to_asn1
167sets the ASN.1
168.Vt AlgorithmIdentifier
169parameter based on the passed cipher.
170This will typically include any parameters and an IV.
171The cipher IV (if any) must be set when this call is made.
172This call should be made before the cipher is actually "used" (before any
173.Xr EVP_EncryptUpdate 3
174or
175.Xr EVP_DecryptUpdate 3
176calls, for example).
177This function may fail if the cipher does not have any ASN.1 support.
178.Pp
179.Fn EVP_CIPHER_asn1_to_param
180sets the cipher parameters based on an ASN.1
181.Vt AlgorithmIdentifier
182parameter.
183The precise effect depends on the cipher.
184In the case of RC2, for example, it will set the IV and effective
185key length.
186This function should be called after the base cipher type is set but
187before the key is set.
188For example
189.Xr EVP_CipherInit 3
190will be called with the IV and key set to
191.Dv NULL ,
192.Fn EVP_CIPHER_asn1_to_param
193will be called and finally
194.Xr EVP_CipherInit 3
195again with all parameters except the key set to
196.Dv NULL .
197It is possible for this function to fail if the cipher does not
198have any ASN.1 support or the parameters cannot be set (for example
199the RC2 effective key length is not supported).
200.Sh RETURN VALUES
201.Fn EVP_CIPHER_CTX_rand_key
202return 1 for success or 0 for failure.
203.Pp
204.Fn EVP_CIPHER_param_to_asn1
205and
206.Fn EVP_CIPHER_asn1_to_param
207return greater than zero for success and zero or a negative number
208for failure.
209.Sh SEE ALSO
210.Xr evp 3 ,
211.Xr EVP_CIPHER_CTX_ctrl 3 ,
212.Xr EVP_CIPHER_CTX_get_cipher_data 3 ,
213.Xr EVP_CIPHER_nid 3 ,
214.Xr EVP_EncryptInit 3
215.Sh HISTORY
216.Fn EVP_CIPHER_CTX_set_app_data
217and
218.Fn EVP_CIPHER_CTX_get_app_data
219first appeared in SSLeay 0.8.0.
220.Fn EVP_CIPHER_param_to_asn1
221and
222.Fn EVP_CIPHER_asn1_to_param
223first appeared in SSLeay 0.9.0.
224These functions have been available since
225.Ox 2.4 .
226.Pp
227.Fn EVP_CIPHER_CTX_rand_key
228first appeared in OpenSSL 0.9.8 and has been available since
229.Ox 4.5 .
230.Sh BUGS
231The ASN.1 code is incomplete (and sometimes inaccurate).
232It has only been tested for certain common S/MIME ciphers
233(RC2, DES, triple DES) in CBC mode.
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_do_all.3 b/src/lib/libcrypto/man/EVP_CIPHER_do_all.3
deleted file mode 100644
index e912044978..0000000000
--- a/src/lib/libcrypto/man/EVP_CIPHER_do_all.3
+++ /dev/null
@@ -1,211 +0,0 @@
1.\" $OpenBSD: EVP_CIPHER_do_all.3,v 1.3 2024/03/14 23:54:55 tb Exp $
2.\"
3.\" Copyright (c) 2023,2024 Theo Buehler <tb@openbsd.org>
4.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: March 14 2024 $
19.Dt EVP_CIPHER_DO_ALL 3
20.Os
21.Sh NAME
22.Nm EVP_CIPHER_do_all ,
23.Nm EVP_CIPHER_do_all_sorted ,
24.Nm EVP_MD_do_all ,
25.Nm EVP_MD_do_all_sorted ,
26.Nm OBJ_NAME_do_all ,
27.Nm OBJ_NAME_do_all_sorted
28.Nd iterate over lookup tables for ciphers and digests
29.Sh SYNOPSIS
30.In openssl/evp.h
31.Ft void
32.Fo EVP_CIPHER_do_all
33.Fa "void (*fn)(const EVP_CIPHER *cipher, const char *from,\
34 const char *to, void *arg)"
35.Fa "void *arg"
36.Fc
37.Ft void
38.Fo EVP_CIPHER_do_all_sorted
39.Fa "void (*fn)(const EVP_CIPHER *cipher, const char *from,\
40 const char *to, void *arg)"
41.Fa "void *arg"
42.Fc
43.Ft void
44.Fo EVP_MD_do_all
45.Fa "void (*fn)(const EVP_MD *md, const char *from,\
46 const char *to, void *arg)"
47.Fa "void *arg"
48.Fc
49.Ft void
50.Fo EVP_MD_do_all_sorted
51.Fa "void (*fn)(const EVP_MD *md, const char *from,\
52 const char *to, void *arg)"
53.Fa "void *arg"
54.Fc
55.Bd -literal
56typedef struct {
57 int type;
58 int alias;
59 const char *name;
60 const char *data;
61} OBJ_NAME;
62.Ed
63.Pp
64.Ft void
65.Fo OBJ_NAME_do_all
66.Fa "int type"
67.Fa "void (*fn)(const OBJ_NAME *obj_name, void *arg)"
68.Fa "void *arg"
69.Fc
70.Ft void
71.Fo OBJ_NAME_do_all_sorted
72.Fa "int type"
73.Fa "void (*fn)(const OBJ_NAME *obj_name, void *arg)"
74.Fa "void *arg"
75.Fc
76.Sh DESCRIPTION
77.Fn EVP_CIPHER_do_all
78calls
79.Fa fn
80on every entry of the global table of cipher names and aliases.
81For a cipher name entry,
82.Fa fn
83is called with a non-NULL
84.Fa cipher ,
85its non-NULL cipher name
86.Fa from ,
87a NULL
88.Fa to ,
89and the
90.Fa arg
91pointer.
92For an alias entry,
93.Fa fn
94is called with a NULL
95.Fa cipher ,
96its alias
97.Fa from ,
98the cipher name that alias points
99.Fa to ,
100and the
101.Fa arg
102pointer.
103.Pp
104.Fn EVP_CIPHER_do_all_sorted
105is similar, except that it processes the cipher names and aliases
106in lexicographic order of their
107.Fa from
108names as determined by
109.Xr strcmp 3 .
110.Pp
111.Fn EVP_MD_do_all
112calls
113.Fa fn
114on every entry of the global table of digest names and aliases.
115For a digest name entry,
116.Fa fn
117is called with a non-NULL
118.Fa md ,
119its non-NULL digest name
120.Fa from ,
121a NULL
122.Fa to ,
123and the
124.Fa arg
125pointer.
126For an alias entry,
127.Fa fn
128is called with a NULL
129.Fa md ,
130its alias
131.Fa from ,
132the digest name that alias points
133.Fa to ,
134and the
135.Fa arg
136pointer.
137.Pp
138.Fn EVP_MD_do_all_sorted
139is similar, except that it processes the digest names and aliases
140in lexicographic order of their
141.Fa from
142names as determined by
143.Xr strcmp 3 .
144.Pp
145.Vt OBJ_NAME
146is an abstraction of the types underlying the lookup tables
147for ciphers and their aliases, and digests and their aliases, respectively.
148For a cipher,
149.Fa type
150is
151.Dv OBJ_NAME_TYPE_CIPHER_METH ,
152.Fa alias
153is 0,
154.Fa name
155is its lookup name and
156.Fa data
157is the
158.Vt EVP_CIPHER
159object it represents, cast to
160.Vt const char * .
161For a cipher alias,
162.Fa type
163is
164.Dv OBJ_NAME_TYPE_CIPHER_METH ,
165.Fa alias
166is
167.Dv OBJ_NAME_ALIAS ,
168.Fa name
169is its lookup name and
170.Fa data
171is the name it aliases.
172Digests representing an
173.Vt EVP_MD
174object and their aliases are represented similarly, except that their type is
175.Dv OBJ_NAME_TYPE_MD_METH .
176.Pp
177.Fn OBJ_NAME_do_all
178calls
179.Fa fn
180on every
181.Fa obj_name
182in the table that has the given
183.Fa type
184(either
185.Dv OBJ_NAME_TYPE_CIPHER_METH
186or
187.Dv OBJ_NAME_TYPE_MD_METH ) ,
188also passing the
189.Fa arg
190pointer.
191.Fn OBJ_NAME_do_all_sorted
192is similar except that it processes the
193.Fa obj_name
194in lexicographic order of their names as determined by
195.Xr strcmp 3 .
196.Sh SEE ALSO
197.Xr evp 3 ,
198.Xr EVP_get_cipherbyname 3 ,
199.Xr EVP_get_digestbyname 3
200.Sh HISTORY
201These functions first appeared in OpenSSL 1.0.0 and have been available since
202.Ox 4.9 .
203.Sh CAVEATS
204.Fn EVP_CIPHER_do_all_sorted ,
205.Fn EVP_MD_do_all_sorted ,
206and
207.Fn OBJ_NAME_do_all_sorted
208cannot report errors.
209In some implementations they need to allocate internally and
210if memory allocation fails they do nothing at all,
211without telling the caller about the problem.
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_meth_new.3 b/src/lib/libcrypto/man/EVP_CIPHER_meth_new.3
deleted file mode 100644
index 187dab6d8a..0000000000
--- a/src/lib/libcrypto/man/EVP_CIPHER_meth_new.3
+++ /dev/null
@@ -1,388 +0,0 @@
1.\" $OpenBSD: EVP_CIPHER_meth_new.3,v 1.6 2024/03/04 09:49:07 tb Exp $
2.\" selective merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Richard Levitte <levitte@openssl.org>
22.\" Copyright (c) 2015 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: March 4 2024 $
70.Dt EVP_CIPHER_METH_NEW 3
71.Os
72.Sh NAME
73.Nm EVP_CIPHER_meth_new ,
74.Nm EVP_CIPHER_meth_dup ,
75.Nm EVP_CIPHER_meth_free ,
76.Nm EVP_CIPHER_meth_set_iv_length ,
77.Nm EVP_CIPHER_meth_set_flags ,
78.Nm EVP_CIPHER_meth_set_impl_ctx_size ,
79.Nm EVP_CIPHER_meth_set_init ,
80.Nm EVP_CIPHER_meth_set_do_cipher ,
81.Nm EVP_CIPHER_meth_set_cleanup ,
82.Nm EVP_CIPHER_meth_set_set_asn1_params ,
83.Nm EVP_CIPHER_meth_set_get_asn1_params ,
84.Nm EVP_CIPHER_meth_set_ctrl
85.Nd Routines to build up EVP_CIPHER methods
86.Sh SYNOPSIS
87.In openssl/evp.h
88.Ft EVP_CIPHER *
89.Fo EVP_CIPHER_meth_new
90.Fa "int cipher_type"
91.Fa "int block_size"
92.Fa "int key_len"
93.Fc
94.Ft EVP_CIPHER *
95.Fo EVP_CIPHER_meth_dup
96.Fa "const EVP_CIPHER *cipher"
97.Fc
98.Ft void
99.Fo EVP_CIPHER_meth_free
100.Fa "EVP_CIPHER *cipher"
101.Fc
102.Ft int
103.Fo EVP_CIPHER_meth_set_iv_length
104.Fa "EVP_CIPHER *cipher"
105.Fa "int iv_len"
106.Fc
107.Ft int
108.Fo EVP_CIPHER_meth_set_flags
109.Fa "EVP_CIPHER *cipher"
110.Fa "unsigned long flags"
111.Fc
112.Ft int
113.Fo EVP_CIPHER_meth_set_impl_ctx_size
114.Fa "EVP_CIPHER *cipher"
115.Fa "int ctx_size"
116.Fc
117.Ft int
118.Fo EVP_CIPHER_meth_set_init
119.Fa "EVP_CIPHER *cipher"
120.Fa "int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,\
121 const unsigned char *iv, int enc)"
122.Fc
123.Ft int
124.Fo EVP_CIPHER_meth_set_do_cipher
125.Fa "EVP_CIPHER *cipher"
126.Fa "int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,\
127 const unsigned char *in, size_t inl)"
128.Fc
129.Ft int
130.Fo EVP_CIPHER_meth_set_cleanup
131.Fa "EVP_CIPHER *cipher"
132.Fa "int (*cleanup)(EVP_CIPHER_CTX *)"
133.Fc
134.Ft int
135.Fo EVP_CIPHER_meth_set_set_asn1_params
136.Fa "EVP_CIPHER *cipher"
137.Fa "int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)"
138.Fc
139.Ft int
140.Fo EVP_CIPHER_meth_set_get_asn1_params
141.Fa "EVP_CIPHER *cipher"
142.Fa "int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)"
143.Fc
144.Ft int
145.Fo EVP_CIPHER_meth_set_ctrl
146.Fa "EVP_CIPHER *cipher"
147.Fa "int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr)"
148.Fc
149.Sh DESCRIPTION
150The
151.Vt EVP_CIPHER
152type is a structure holding function pointers for
153a symmetric cipher implementation.
154.Pp
155.Fn EVP_CIPHER_meth_new
156allocates a new
157.Vt EVP_CIPHER
158structure.
159The cipher's NID (see
160.Xr EVP_CIPHER_nid 3 )
161is set to
162.Fa cipher_type ,
163the block size and key length are set to
164.Fa block_size
165and
166.Fa key_len ,
167respectively.
168.Pp
169.Fn EVP_CIPHER_meth_dup
170creates a copy of
171.Fa cipher .
172.Pp
173.Fn EVP_CIPHER_meth_free
174frees an
175.Vt EVP_CIPHER
176structure.
177.Pp
178.Fn EVP_CIPHER_meth_set_iv_length
179sets the length of the initialization vector.
180This is only needed when the implemented cipher mode requires it.
181.Pp
182.Fn EVP_CIPHER_meth_set_flags
183overwrites the flags to describe optional behaviours in
184.Fa cipher
185with
186.Fa flags .
187At most one of the following cipher modes can be set:
188.Dv EVP_CIPH_STREAM_CIPHER ,
189.Dv EVP_CIPH_ECB_MODE ,
190.Dv EVP_CIPH_CBC_MODE ,
191.Dv EVP_CIPH_CFB_MODE ,
192.Dv EVP_CIPH_OFB_MODE ,
193.Dv EVP_CIPH_CTR_MODE ,
194.Dv EVP_CIPH_GCM_MODE ,
195.Dv EVP_CIPH_CCM_MODE ,
196.Dv EVP_CIPH_XTS_MODE ,
197and
198.Dv EVP_CIPH_WRAP_MODE .
199.Pp
200Zero or more of the following flags can be OR'ed into the
201.Fa flags
202argument:
203.Bl -tag -width Ds
204.It Dv EVP_CIPH_VARIABLE_LENGTH
205This cipher has a variable key length, and the function
206.Xr EVP_CIPHER_CTX_set_key_length 3
207can be used with it.
208.It Dv EVP_CIPH_CUSTOM_IV
209Instruct
210.Xr EVP_CipherInit_ex 3
211and similar initialization functions to leave storing and initialising
212the IV entirely to the implementation.
213If this flag is set,
214the implementation is typically expected to do that in its
215.Fa init
216function.
217.It Dv EVP_CIPH_ALWAYS_CALL_INIT
218Instruct
219.Xr EVP_CipherInit_ex 3
220and similar initialization functions to call the implementation's
221.Fa init
222function even if the
223.Fa key
224argument is
225.Dv NULL .
226.It Dv EVP_CIPH_CTRL_INIT
227Instruct
228.Xr EVP_CipherInit_ex 3
229and similar initialization functions to call the implementation's
230.Fa ctrl
231function with a command
232.Fa type
233of
234.Dv EVP_CTRL_INIT
235early during the setup.
236.It Dv EVP_CIPH_NO_PADDING
237Instruct
238.Xr EVP_CipherFinal_ex 3
239and similar finalization functions to not use standard block padding
240but instead report an error if the total amount of data
241to be encrypted or decrypted is not a multiple of the block size.
242.It Dv EVP_CIPH_RAND_KEY
243Instruct
244.Xr EVP_CIPHER_CTX_rand_key 3
245to not generate a random key using
246.Xr arc4random_buf 3
247but instead leave that to the implementation by calling the
248.Fa ctrl
249function with a command
250.Fa type
251of
252.Dv EVP_CTRL_RAND_KEY
253and the pointer to the key memory storage in
254.Fa ptr .
255.It Dv EVP_CIPH_CUSTOM_COPY
256Instruct
257.Xr EVP_CIPHER_CTX_copy 3
258to call the implementation's
259.Fa ctrl
260function with a command
261.Fa type
262of
263.Dv EVP_CTRL_COPY
264and the destination
265.Fa "EVP_CIPHER_CTX *out"
266in the
267.Fa ptr
268argument immediately before returning successfully.
269The intended use is for further things to deal with after the
270implementation specific data block has been copied.
271The implementation-specific data block is reached with
272.Xr EVP_CIPHER_CTX_get_cipher_data 3 .
273.It Dv EVP_CIPH_FLAG_DEFAULT_ASN1
274Instruct
275.Xr EVP_CIPHER_param_to_asn1 3
276to use
277.Xr ASN1_TYPE_set_octetstring 3
278if no
279.Fa set_asn1_parameters
280function is installed, and instruct
281.Xr EVP_CIPHER_asn1_to_param 3
282to use
283.Xr ASN1_TYPE_get_octetstring 3
284if no
285.Fa get_asn1_parameters
286function is installed.
287.It Dv EVP_CIPH_FLAG_LENGTH_BITS
288Signals that the length of the input buffer for encryption / decryption
289is to be understood as the number of bits instead of bytes for this
290implementation.
291This is only useful for CFB1 ciphers.
292.It Dv EVP_CIPH_FLAG_CUSTOM_CIPHER
293Instruct
294.Xr EVP_CipherUpdate 3 ,
295.Xr EVP_CipherFinal_ex 3 ,
296and similar encryption, decryption, and finalization functions
297that the implementation's
298.Fa do_cipher
299function takes care of everything,
300including padding, buffering and finalization.
301.It Dv EVP_CIPH_FLAG_AEAD_CIPHER
302This indicates that this is an AEAD cipher implementation.
303.El
304.Pp
305.Fn EVP_CIPHER_meth_set_impl_ctx_size
306sets the size of the EVP_CIPHER's implementation context so that it can
307be automatically allocated.
308.Pp
309.Fn EVP_CIPHER_meth_set_init
310sets the
311.Fa init
312function for
313.Fa cipher .
314The cipher init function is called by
315.Xr EVP_CipherInit 3 ,
316.Xr EVP_CipherInit_ex 3 ,
317.Xr EVP_EncryptInit 3 ,
318.Xr EVP_EncryptInit_ex 3 ,
319.Xr EVP_DecryptInit 3 ,
320and
321.Xr EVP_DecryptInit_ex 3 .
322.Pp
323.Fn EVP_CIPHER_meth_set_do_cipher
324sets the cipher function for
325.Fa cipher .
326The cipher function is called by
327.Xr EVP_CipherUpdate 3 ,
328.Xr EVP_EncryptUpdate 3 ,
329.Xr EVP_DecryptUpdate 3 ,
330.Xr EVP_CipherFinal 3 ,
331.Xr EVP_EncryptFinal 3 ,
332.Xr EVP_EncryptFinal_ex 3 ,
333.Xr EVP_DecryptFinal 3
334and
335.Xr EVP_DecryptFinal_ex 3 .
336.Pp
337.Fn EVP_CIPHER_meth_set_cleanup
338sets the function for
339.Fa cipher
340to do extra cleanup before the method's private data structure is
341cleaned out and freed.
342Note that the cleanup function is passed a
343.Sy EVP_CIPHER_CTX * ,
344the private data structure is then available with
345.Xr EVP_CIPHER_CTX_get_cipher_data 3 .
346This cleanup function is called by
347.Xr EVP_CIPHER_CTX_reset 3
348and
349.Xr EVP_CIPHER_CTX_free 3 .
350.Pp
351.Fn EVP_CIPHER_meth_set_set_asn1_params
352sets the function for
353.Fa cipher
354to set the AlgorithmIdentifier "parameter" based on the passed cipher.
355This function is called by
356.Xr EVP_CIPHER_param_to_asn1 3 .
357.Fn EVP_CIPHER_meth_set_get_asn1_params
358sets the function for
359.Fa cipher
360that sets the cipher parameters based on an ASN.1 AlgorithmIdentifier
361"parameter".
362Both these functions are needed when there is a need for custom data
363(more or other than the cipher IV). They are called by
364.Xr EVP_CIPHER_param_to_asn1 3
365and
366.Xr EVP_CIPHER_asn1_to_param 3
367respectively if defined.
368.Pp
369.Fn EVP_CIPHER_meth_set_ctrl
370sets the control function for
371.Fa cipher .
372.Sh RETURN VALUES
373.Fn EVP_CIPHER_meth_new
374and
375.Fn EVP_CIPHER_meth_dup
376return a pointer to a newly created
377.Vt EVP_CIPHER ,
378or NULL on failure.
379.Pp
380All
381.Fn EVP_CIPHER_meth_set_*
382functions return 1.
383.Sh SEE ALSO
384.Xr evp 3 ,
385.Xr EVP_EncryptInit 3
386.Sh HISTORY
387These functions first appeared in OpenSSL 1.1.0 and have been available since
388.Ox 7.3 .
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_nid.3 b/src/lib/libcrypto/man/EVP_CIPHER_nid.3
deleted file mode 100644
index 1feff4f34e..0000000000
--- a/src/lib/libcrypto/man/EVP_CIPHER_nid.3
+++ /dev/null
@@ -1,306 +0,0 @@
1.\" $OpenBSD: EVP_CIPHER_nid.3,v 1.3 2023/09/05 14:54:21 schwarze Exp $
2.\" full merge up to: OpenSSL man3/EVP_EncryptInit.pod
3.\" 0874d7f2 Oct 11 13:13:47 2022 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2018, 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: September 5 2023 $
70.Dt EVP_CIPHER_NID 3
71.Os
72.Sh NAME
73.Nm EVP_CIPHER_nid ,
74.Nm EVP_CIPHER_CTX_nid ,
75.Nm EVP_CIPHER_name ,
76.Nm EVP_CIPHER_type ,
77.Nm EVP_CIPHER_CTX_type ,
78.Nm EVP_CIPHER_block_size ,
79.Nm EVP_CIPHER_CTX_block_size ,
80.Nm EVP_CIPHER_flags ,
81.Nm EVP_CIPHER_CTX_flags ,
82.Nm EVP_CIPHER_mode ,
83.Nm EVP_CIPHER_CTX_mode
84.Nd inspect EVP_CIPHER objects
85.Sh SYNOPSIS
86.In openssl/evp.h
87.Ft int
88.Fo EVP_CIPHER_nid
89.Fa "const EVP_CIPHER *cipher"
90.Fc
91.Ft int
92.Fo EVP_CIPHER_CTX_nid
93.Fa "const EVP_CIPHER_CTX *ctx"
94.Fc
95.Ft const char *
96.Fo EVP_CIPHER_name
97.Fa "const EVP_CIPHER *cipher"
98.Fc
99.Ft int
100.Fo EVP_CIPHER_type
101.Fa "const EVP_CIPHER *ctx"
102.Fc
103.Ft int
104.Fo EVP_CIPHER_CTX_type
105.Fa "const EVP_CIPHER_CTX *ctx"
106.Fc
107.Ft int
108.Fo EVP_CIPHER_block_size
109.Fa "const EVP_CIPHER *cipher"
110.Fc
111.Ft int
112.Fo EVP_CIPHER_CTX_block_size
113.Fa "const EVP_CIPHER_CTX *ctx"
114.Fc
115.Ft unsigned long
116.Fo EVP_CIPHER_flags
117.Fa "const EVP_CIPHER *cipher"
118.Fc
119.Ft unsigned long
120.Fo EVP_CIPHER_CTX_flags
121.Fa "const EVP_CIPHER_CTX *ctx"
122.Fc
123.Ft unsigned long
124.Fo EVP_CIPHER_mode
125.Fa "const EVP_CIPHER *cipher"
126.Fc
127.Ft unsigned long
128.Fo EVP_CIPHER_CTX_mode
129.Fa "const EVP_CIPHER_CTX *ctx"
130.Fc
131.Sh DESCRIPTION
132.Fn EVP_CIPHER_nid
133returns the numerical identifier (NID) of the
134.Fa cipher .
135The NID is an internal value which may or may not have a corresponding
136ASN.1 OBJECT IDENTIFIER; see
137.Xr OBJ_nid2obj 3
138for details.
139.Pp
140.Fn EVP_CIPHER_CTX_nid
141returns the NID of the cipher that
142.Fa ctx
143is configured to use.
144.Pp
145.Fn EVP_CIPHER_name
146converts the NID of the
147.Fa cipher
148to its short name with
149.Xr OBJ_nid2sn 3 .
150.Pp
151.Fn EVP_CIPHER_type
152returns the NID associated with the ASN.1 OBJECT IDENTIFIER of the
153.Fa cipher ,
154ignoring the cipher parameters.
155For example,
156.Xr EVP_aes_256_cfb1 3 ,
157.Xr EVP_aes_256_cfb8 3 ,
158and
159.Xr EVP_aes_256_cfb128 3
160all return the same NID,
161.Dv NID_aes_256_cfb128 .
162.Pp
163.Fn EVP_CIPHER_CTX_type
164returns the NID associated with the ASN.1 OBJECT IDENTIFIER of the cipher that
165.Fa ctx
166is configured to use.
167.Pp
168.Fn EVP_CIPHER_block_size
169returns the block size of the
170.Fa cipher
171in bytes.
172.Fn EVP_CIPHER_CTX_block_size
173returns the block size of the cipher that
174.Fa ctx
175is configured to use.
176Block sizes are guaranteed to be less than or equal to the constant
177.Dv EVP_MAX_BLOCK_LENGTH .
178Currently,
179.Xr EVP_CipherInit_ex 3
180and the other functions documented in the same manual page
181only support block sizes of 1, 8, and 16 bytes.
182.Pp
183.Fn EVP_CIPHER_flags
184returns the cipher flags used by the
185.Fa cipher .
186The meaning of the flags is described in the
187.Xr EVP_CIPHER_meth_set_flags 3
188manual page.
189.Pp
190.Fn EVP_CIPHER_CTX_flags
191returns the cipher flags of the cipher that
192.Fa ctx
193is configured to use.
194Be careful to not confuse these with the unrelated cipher context flags
195that can be inspected with
196.Xr EVP_CIPHER_CTX_test_flags 3 .
197.Pp
198.Fn EVP_CIPHER_mode
199returns the
200.Fa cipher
201mode, which is the logical AND of the constant
202.Dv EVP_CIPH_MODE
203and the return value of
204.Fn EVP_CIPHER_flags .
205.Pp
206.Fn EVP_CIPHER_CTX_mode
207returns the cipher mode of the cipher that
208.Fa ctx
209is configured to use.
210.Pp
211.Fn EVP_CIPHER_name ,
212.Fn EVP_CIPHER_CTX_type ,
213.Fn EVP_CIPHER_mode ,
214and
215.Fn EVP_CIPHER_CTX_mode
216are implemented as macros.
217.Sh RETURN VALUES
218.Fn EVP_CIPHER_nid
219and
220.Fn EVP_CIPHER_CTX_nid
221return an NID.
222.Pp
223.Fn EVP_CIPHER_name
224returns a pointer to a string that is owned by an internal library object or
225.Dv NULL
226if the NID is neither built into the library nor added to the global
227object table by one of the functions documented in the manual page
228.Xr OBJ_create 3 ,
229of if the object does not contain a short name.
230.Pp
231.Fn EVP_CIPHER_type
232and
233.Fn EVP_CIPHER_CTX_type
234return the NID of the cipher's OBJECT IDENTIFIER or
235.Dv NID_undef
236if it is not associated with an OBJECT IDENTIFIER.
237.Pp
238.Fn EVP_CIPHER_block_size
239and
240.Fn EVP_CIPHER_CTX_block_size
241return the block size in bytes.
242.Pp
243.Fn EVP_CIPHER_flags
244and
245.Fn EVP_CIPHER_CTX_flags
246return one or more
247.Dv EVP_CIPH_*
248flag bits OR'ed together.
249.Pp
250.Fn EVP_CIPHER_mode
251and
252.Fn EVP_CIPHER_CTX_mode
253return one of the constants
254.Dv EVP_CIPH_ECB_MODE ,
255.Dv EVP_CIPH_CBC_MODE ,
256.Dv EVP_CIPH_CFB_MODE ,
257.Dv EVP_CIPH_OFB_MODE ,
258.Dv EVP_CIPH_CTR_MODE ,
259.Dv EVP_CIPH_GCM_MODE ,
260.Dv EVP_CIPH_CCM_MODE ,
261.Dv EVP_CIPH_XTS_MODE ,
262or
263.Dv EVP_CIPH_WRAP_MODE
264to indicate a block cipher or
265.Dv EVP_CIPH_STREAM_CIPHER
266to indicate a stream cipher.
267.Sh SEE ALSO
268.Xr evp 3 ,
269.Xr EVP_CIPHER_CTX_ctrl 3 ,
270.Xr EVP_EncryptInit 3 ,
271.Xr OBJ_nid2obj 3
272.Sh HISTORY
273.Fn EVP_CIPHER_type ,
274.Fn EVP_CIPHER_CTX_type ,
275.Fn EVP_CIPHER_block_size ,
276and
277.Fn EVP_CIPHER_CTX_block_size
278first appeared in SSLeay 0.6.5.
279.Fn EVP_CIPHER_nid
280and
281.Fn EVP_CIPHER_CTX_nid
282first appeared in SSLeay 0.8.0.
283All these functions have been available since
284.Ox 2.4 .
285.Pp
286.Fn EVP_CIPHER_flags ,
287.Fn EVP_CIPHER_CTX_flags ,
288.Fn EVP_CIPHER_mode ,
289and
290.Fn EVP_CIPHER_CTX_mode
291first appeared in OpenSSL 0.9.6 and have been available since
292.Ox 2.9 .
293.Pp
294.Fn EVP_CIPHER_name
295first appeared in OpenSSL 0.9.7 and has been available since
296.Ox 3.2 .
297.Sh CAVEATS
298The behaviour of the functions taking an
299.Vt EVP_CIPHER_CTX
300argument is undefined if they are called on a
301.Fa ctx
302that has no cipher configured yet, for example one freshly returned from
303.Xr EVP_CIPHER_CTX_new 3 .
304In that case, the program may for example be terminated by a
305.Dv NULL
306pointer access.
diff --git a/src/lib/libcrypto/man/EVP_DigestInit.3 b/src/lib/libcrypto/man/EVP_DigestInit.3
deleted file mode 100644
index 668c189bc1..0000000000
--- a/src/lib/libcrypto/man/EVP_DigestInit.3
+++ /dev/null
@@ -1,606 +0,0 @@
1.\" $OpenBSD: EVP_DigestInit.3,v 1.37 2024/12/06 15:01:01 schwarze Exp $
2.\" full merge up to: OpenSSL 7f572e95 Dec 2 13:57:04 2015 +0000
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2019, 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>,
23.\" Richard Levitte <levitte@openssl.org>,
24.\" Paul Yang <yang.yang@baishancloud.com>, and
25.\" Antoine Salon <asalon@vmware.com>.
26.\" Copyright (c) 2000-2004, 2009, 2012-2016, 2018, 2019 The OpenSSL Project.
27.\" All rights reserved.
28.\"
29.\" Redistribution and use in source and binary forms, with or without
30.\" modification, are permitted provided that the following conditions
31.\" are met:
32.\"
33.\" 1. Redistributions of source code must retain the above copyright
34.\" notice, this list of conditions and the following disclaimer.
35.\"
36.\" 2. Redistributions in binary form must reproduce the above copyright
37.\" notice, this list of conditions and the following disclaimer in
38.\" the documentation and/or other materials provided with the
39.\" distribution.
40.\"
41.\" 3. All advertising materials mentioning features or use of this
42.\" software must display the following acknowledgment:
43.\" "This product includes software developed by the OpenSSL Project
44.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
45.\"
46.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
47.\" endorse or promote products derived from this software without
48.\" prior written permission. For written permission, please contact
49.\" openssl-core@openssl.org.
50.\"
51.\" 5. Products derived from this software may not be called "OpenSSL"
52.\" nor may "OpenSSL" appear in their names without prior written
53.\" permission of the OpenSSL Project.
54.\"
55.\" 6. Redistributions of any form whatsoever must retain the following
56.\" acknowledgment:
57.\" "This product includes software developed by the OpenSSL Project
58.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
59.\"
60.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
61.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
63.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
64.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
65.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
66.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
67.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
69.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
70.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
71.\" OF THE POSSIBILITY OF SUCH DAMAGE.
72.\"
73.Dd $Mdocdate: December 6 2024 $
74.Dt EVP_DIGESTINIT 3
75.Os
76.Sh NAME
77.Nm EVP_MD_CTX_new ,
78.Nm EVP_MD_CTX_reset ,
79.Nm EVP_MD_CTX_free ,
80.Nm EVP_MD_CTX_init ,
81.Nm EVP_MD_CTX_create ,
82.Nm EVP_MD_CTX_cleanup ,
83.Nm EVP_MD_CTX_destroy ,
84.Nm EVP_DigestInit_ex ,
85.Nm EVP_DigestUpdate ,
86.Nm EVP_DigestFinal_ex ,
87.Nm EVP_Digest ,
88.Nm EVP_MD_CTX_copy_ex ,
89.Nm EVP_DigestInit ,
90.Nm EVP_DigestFinal ,
91.Nm EVP_MD_CTX_copy ,
92.Nm EVP_MD_CTX_md ,
93.Nm EVP_md_null ,
94.Nm EVP_sha224 ,
95.Nm EVP_sha256 ,
96.Nm EVP_sha384 ,
97.Nm EVP_sha512 ,
98.Nm EVP_sha512_224 ,
99.Nm EVP_sha512_256 ,
100.Nm EVP_ripemd160 ,
101.Nm EVP_get_digestbyname ,
102.Nm EVP_get_digestbynid ,
103.Nm EVP_get_digestbyobj
104.Nd EVP digest routines
105.Sh SYNOPSIS
106.In openssl/evp.h
107.Ft EVP_MD_CTX *
108.Fn EVP_MD_CTX_new void
109.Ft int
110.Fo EVP_MD_CTX_reset
111.Fa "EVP_MD_CTX *ctx"
112.Fc
113.Ft void
114.Fo EVP_MD_CTX_free
115.Fa "EVP_MD_CTX *ctx"
116.Fc
117.Ft int
118.Fo EVP_MD_CTX_init
119.Fa "EVP_MD_CTX *ctx"
120.Fc
121.Ft EVP_MD_CTX *
122.Fn EVP_MD_CTX_create void
123.Ft int
124.Fo EVP_MD_CTX_cleanup
125.Fa "EVP_MD_CTX *ctx"
126.Fc
127.Ft void
128.Fo EVP_MD_CTX_destroy
129.Fa "EVP_MD_CTX *ctx"
130.Fc
131.Ft int
132.Fo EVP_DigestInit_ex
133.Fa "EVP_MD_CTX *ctx"
134.Fa "const EVP_MD *type"
135.Fa "ENGINE *engine"
136.Fc
137.Ft int
138.Fo EVP_DigestUpdate
139.Fa "EVP_MD_CTX *ctx"
140.Fa "const void *d"
141.Fa "size_t cnt"
142.Fc
143.Ft int
144.Fo EVP_DigestFinal_ex
145.Fa "EVP_MD_CTX *ctx"
146.Fa "unsigned char *md"
147.Fa "unsigned int *s"
148.Fc
149.Ft int
150.Fo EVP_Digest
151.Fa "const void *d"
152.Fa "size_t cnt"
153.Fa "unsigned char *md"
154.Fa "unsigned int *s"
155.Fa "const EVP_MD *type"
156.Fa "ENGINE *engine"
157.Fc
158.Ft int
159.Fo EVP_MD_CTX_copy_ex
160.Fa "EVP_MD_CTX *out"
161.Fa "const EVP_MD_CTX *in"
162.Fc
163.Ft int
164.Fo EVP_DigestInit
165.Fa "EVP_MD_CTX *ctx"
166.Fa "const EVP_MD *type"
167.Fc
168.Ft int
169.Fo EVP_DigestFinal
170.Fa "EVP_MD_CTX *ctx"
171.Fa "unsigned char *md"
172.Fa "unsigned int *s"
173.Fc
174.Ft int
175.Fo EVP_MD_CTX_copy
176.Fa "EVP_MD_CTX *out"
177.Fa "EVP_MD_CTX *in"
178.Fc
179.Ft const EVP_MD *
180.Fo EVP_MD_CTX_md
181.Fa "const EVP_MD_CTX *ctx"
182.Fc
183.Ft const EVP_MD *
184.Fn EVP_md_null void
185.Ft const EVP_MD *
186.Fn EVP_sha224 void
187.Ft const EVP_MD *
188.Fn EVP_sha256 void
189.Ft const EVP_MD *
190.Fn EVP_sha384 void
191.Ft const EVP_MD *
192.Fn EVP_sha512 void
193.Ft const EVP_MD *
194.Fn EVP_sha512_224 void
195.Ft const EVP_MD *
196.Fn EVP_sha512_256 void
197.Ft const EVP_MD *
198.Fn EVP_ripemd160 void
199.Ft const EVP_MD *
200.Fo EVP_get_digestbyname
201.Fa "const char *name"
202.Fc
203.Ft const EVP_MD *
204.Fo EVP_get_digestbynid
205.Fa "int type"
206.Fc
207.Ft const EVP_MD *
208.Fo EVP_get_digestbyobj
209.Fa "const ASN1_OBJECT *o"
210.Fc
211.Sh DESCRIPTION
212The EVP digest routines are a high-level interface to message digests
213and should be used instead of the cipher-specific functions.
214.Pp
215.Fn EVP_MD_CTX_new
216allocates a new, empty digest context.
217.Pp
218.Fn EVP_MD_CTX_reset
219cleans up
220.Fa ctx
221and resets it to the state it had after
222.Fn EVP_MD_CTX_new ,
223such that it can be reused.
224.Pp
225.Fn EVP_MD_CTX_free
226cleans up
227.Fa ctx
228and frees the space allocated to it.
229.Pp
230.Fn EVP_MD_CTX_init
231is a deprecated function to clear a digest context on the stack
232before use.
233Do not use it on a digest context returned from
234.Fn EVP_MD_CTX_new
235or one that was already used.
236.Pp
237.Fn EVP_MD_CTX_create ,
238.Fn EVP_MD_CTX_cleanup ,
239and
240.Fn EVP_MD_CTX_destroy
241are deprecated aliases for
242.Fn EVP_MD_CTX_new ,
243.Fn EVP_MD_CTX_reset ,
244and
245.Fn EVP_MD_CTX_free ,
246respectively.
247.Pp
248.Fn EVP_DigestInit_ex
249sets up the digest context
250.Fa ctx
251to use a digest
252.Fa type .
253The
254.Fa type
255will typically be supplied by a function such as
256.Fn EVP_sha512 .
257The
258.Fa ENGINE *engine
259argument is always ignored and passing
260.Dv NULL
261is recommended.
262.Pp
263.Fn EVP_DigestUpdate
264hashes
265.Fa cnt
266bytes of data at
267.Fa d
268into the digest context
269.Fa ctx .
270This function can be called several times on the same
271.Fa ctx
272to hash additional data.
273.Pp
274.Fn EVP_DigestFinal_ex
275retrieves the digest value from
276.Fa ctx
277and places it in
278.Fa md .
279If the
280.Fa s
281parameter is not
282.Dv NULL ,
283then the number of bytes of data written (i.e. the length of the
284digest) will be written to the integer at
285.Fa s ;
286at most
287.Dv EVP_MAX_MD_SIZE
288bytes will be written.
289After calling
290.Fn EVP_DigestFinal_ex ,
291no additional calls to
292.Fn EVP_DigestUpdate
293can be made, but
294.Fn EVP_DigestInit_ex
295can be called to initialize a new digest operation.
296.Pp
297.Fn EVP_Digest
298is a simple wrapper function to hash
299.Fa cnt
300bytes of data at
301.Fa d
302using the digest
303.Fa type
304in a one-shot operation and place the digest value into
305.Fa md ,
306and, unless
307.Fa s
308is
309.Dv NULL ,
310the length of the digest in bytes into
311.Pf * Fa s .
312This wrapper uses a temporary digest context and passes its arguments to
313.Fn EVP_DigestInit_ex ,
314.Fn EVP_DigestUpdate ,
315and
316.Fn EVP_DigestFinal_ex
317internally.
318The
319.Fa ENGINE *engine
320argument is always ignored and passing
321.Dv NULL
322is recommended.
323.Pp
324.Fn EVP_MD_CTX_copy_ex
325can be used to copy the message digest state from
326.Fa in
327to
328.Fa out .
329This is useful if large amounts of data are to be hashed which only
330differ in the last few bytes.
331.Pp
332.Fn EVP_DigestInit
333is a deprecated function behaving like
334.Fn EVP_DigestInit_ex
335except that it requires
336.Fn EVP_MD_CTX_reset
337before it can be used on a context that was already used.
338.Pp
339.Fn EVP_DigestFinal
340is a deprecated function behaving like
341.Fn EVP_DigestFinal_ex
342except that the digest context
343.Fa ctx
344is automatically cleaned up after use by calling
345.Fn EVP_MD_CTX_reset
346internally.
347.Pp
348.Fn EVP_MD_CTX_copy
349is a deprecated function behaving like
350.Fn EVP_MD_CTX_copy_ex
351except that it requires
352.Fn EVP_MD_CTX_reset
353before a context that was already used can be passed as
354.Fa out .
355.Pp
356.Fn EVP_sha224 ,
357.Fn EVP_sha256 ,
358.Fn EVP_sha384 ,
359.Fn EVP_sha512 ,
360and
361.Fn EVP_ripemd160
362return
363.Vt EVP_MD
364structures for the SHA224, SHA256, SHA384, SHA512 and
365RIPEMD160 digest algorithms respectively.
366.Pp
367.Fn EVP_sha512_224
368and
369.Fn EVP_sha512_256
370return an
371.Vt EVP_MD
372structure that provides the truncated SHA512 variants SHA512/224 and SHA512/256,
373respectively.
374.Pp
375.Fn EVP_md_null
376is a "null" message digest that does nothing:
377i.e. the hash it returns is of zero length.
378.Pp
379.Fn EVP_get_digestbyname ,
380.Fn EVP_get_digestbynid ,
381and
382.Fn EVP_get_digestbyobj
383return an
384.Vt EVP_MD
385structure when passed a digest name, a digest NID, or an ASN1_OBJECT
386structure respectively.
387.Pp
388.Fn EVP_get_digestbynid
389and
390.Fn EVP_get_digestbyobj
391are implemented as macros.
392.Pp
393The EVP interface to message digests should almost always be used
394in preference to the low-level interfaces.
395This is because the code then becomes transparent to the digest used and
396much more flexible.
397.Pp
398The
399.Fa ENGINE *engine
400argument is always ignored and passing
401.Dv NULL
402is recommended.
403.Pp
404The functions
405.Fn EVP_DigestInit ,
406.Fn EVP_DigestFinal ,
407and
408.Fn EVP_MD_CTX_copy
409are obsolete but are retained to maintain compatibility with existing
410code.
411New applications should use
412.Fn EVP_DigestInit_ex ,
413.Fn EVP_DigestFinal_ex ,
414and
415.Fn EVP_MD_CTX_copy_ex
416because they can efficiently reuse a digest context instead of
417initializing and cleaning it up on each call.
418.Pp
419If digest contexts are not cleaned up after use, memory leaks will occur.
420.Sh RETURN VALUES
421.Fn EVP_MD_CTX_new
422and
423.Fn EVP_MD_CTX_create
424return the new
425.Vt EVP_MD_CTX
426object or
427.Dv NULL
428for failure.
429.Pp
430.Fn EVP_MD_CTX_reset ,
431.Fn EVP_MD_CTX_init ,
432and
433.Fn EVP_MD_CTX_cleanup
434always return 1.
435.Pp
436.Fn EVP_DigestInit_ex ,
437.Fn EVP_DigestUpdate ,
438.Fn EVP_DigestFinal_ex ,
439.Fn EVP_Digest ,
440.Fn EVP_MD_CTX_copy_ex ,
441.Fn EVP_DigestInit ,
442.Fn EVP_DigestFinal ,
443and
444.Fn EVP_MD_CTX_copy
445return 1 for success or 0 for failure.
446.Pp
447.Fn EVP_MD_CTX_md
448returns the
449.Vt EVP_MD
450object used by
451.Fa ctx ,
452or
453.Dv NULL
454if
455.Fa ctx
456is
457.Dv NULL
458or does not have any message digest algorithm assigned yet.
459.Pp
460.Fn EVP_md_null ,
461.Fn EVP_sha224 ,
462.Fn EVP_sha256 ,
463.Fn EVP_sha384 ,
464.Fn EVP_sha512 ,
465.Fn EVP_sha512_224 ,
466.Fn EVP_sha512_256 ,
467and
468.Fn EVP_ripemd160
469return pointers to constant static objects owned by the library.
470.Pp
471.Fn EVP_get_digestbyname ,
472.Fn EVP_get_digestbynid ,
473and
474.Fn EVP_get_digestbyobj
475return either an
476.Vt EVP_MD
477structure or
478.Dv NULL
479if an error occurs.
480.Sh EXAMPLES
481This example digests the data "Test Message\en" and "Hello World\en",
482using the digest name passed on the command line.
483.Bd -literal -offset indent
484#include <stdio.h>
485#include <string.h>
486#include <openssl/evp.h>
487
488int
489main(int argc, char *argv[])
490{
491 EVP_MD_CTX *mdctx;
492 const EVP_MD *md;
493 const char mess1[] = "Test Message\en";
494 const char mess2[] = "Hello World\en";
495 unsigned char md_value[EVP_MAX_MD_SIZE];
496 unsigned int md_len, i;
497
498 if (argc <= 1) {
499 printf("Usage: mdtest digestname\en");
500 exit(1);
501 }
502
503 md = EVP_get_digestbyname(argv[1]);
504 if (md == NULL) {
505 printf("Unknown message digest %s\en", argv[1]);
506 exit(1);
507 }
508
509 mdctx = EVP_MD_CTX_new();
510 EVP_DigestInit_ex(mdctx, md, NULL);
511 EVP_DigestUpdate(mdctx, mess1, strlen(mess1));
512 EVP_DigestUpdate(mdctx, mess2, strlen(mess2));
513 EVP_DigestFinal_ex(mdctx, md_value, &md_len);
514 EVP_MD_CTX_free(mdctx);
515
516 printf("Digest is: ");
517 for(i = 0; i < md_len; i++)
518 printf("%02x", md_value[i]);
519 printf("\en");
520
521 return 0;
522}
523.Ed
524.Sh SEE ALSO
525.Xr BIO_f_md 3 ,
526.Xr CMAC_Init 3 ,
527.Xr evp 3 ,
528.Xr EVP_BytesToKey 3 ,
529.Xr EVP_DigestSignInit 3 ,
530.Xr EVP_DigestVerifyInit 3 ,
531.Xr EVP_MD_CTX_ctrl 3 ,
532.Xr EVP_MD_nid 3 ,
533.Xr EVP_PKEY_CTX_set_signature_md 3 ,
534.Xr EVP_sha1 3 ,
535.Xr EVP_sha3_224 3 ,
536.Xr EVP_SignInit 3 ,
537.Xr EVP_sm3 3 ,
538.Xr EVP_VerifyInit 3 ,
539.Xr HMAC 3 ,
540.Xr OCSP_basic_sign 3 ,
541.Xr OCSP_request_sign 3 ,
542.Xr PKCS5_PBKDF2_HMAC 3 ,
543.Xr PKCS7_sign_add_signer 3 ,
544.Xr X509_ALGOR_set0 3 ,
545.Xr X509_digest 3 ,
546.Xr X509_sign 3
547.Sh HISTORY
548.Fn EVP_DigestInit ,
549.Fn EVP_DigestUpdate ,
550and
551.Fn EVP_DigestFinal
552first appeared in SSLeay 0.5.1.
553.Fn EVP_md_null
554and
555.Fn EVP_get_digestbyname
556first appeared in SSLeay 0.8.0.
557.Fn EVP_get_digestbynid
558and
559.Fn EVP_get_digestbyobj
560first appeared in SSLeay 0.8.1.
561.Fn EVP_ripemd160
562first appeared in SSLeay 0.9.0.
563All these functions have been available since
564.Ox 2.4 .
565.Pp
566.Fn EVP_MD_CTX_copy
567first appeared in OpenSSL 0.9.2b and has been available since
568.Ox 2.6 .
569.Pp
570.Fn EVP_MD_CTX_md
571first appeared in OpenSSL 0.9.5 and has been available since
572.Ox 2.7 .
573.Pp
574.Fn EVP_MD_CTX_init ,
575.Fn EVP_MD_CTX_create ,
576.Fn EVP_MD_CTX_cleanup ,
577.Fn EVP_MD_CTX_destroy ,
578.Fn EVP_DigestInit_ex ,
579.Fn EVP_DigestFinal_ex ,
580.Fn EVP_Digest ,
581and
582.Fn EVP_MD_CTX_copy_ex
583first appeared in OpenSSL 0.9.7 and have been available since
584.Ox 3.2 .
585.Pp
586.Fn EVP_sha224 ,
587.Fn EVP_sha256 ,
588.Fn EVP_sha384 ,
589and
590.Fn EVP_sha512
591first appeared in OpenSSL 0.9.7h and 0.9.8a
592and have been available since
593.Ox 4.0 .
594.Pp
595.Fn EVP_MD_CTX_new ,
596.Fn EVP_MD_CTX_reset ,
597and
598.Fn EVP_MD_CTX_free
599first appeared in OpenSSL 1.1.0 and have been available since
600.Ox 6.3 .
601.Pp
602.Fn EVP_sha512_224
603and
604.Fn EVP_sha512_256
605first appeared in OpenSSL 1.1.1 and have been available since
606.Ox 7.4 .
diff --git a/src/lib/libcrypto/man/EVP_DigestSignInit.3 b/src/lib/libcrypto/man/EVP_DigestSignInit.3
deleted file mode 100644
index caf519e28c..0000000000
--- a/src/lib/libcrypto/man/EVP_DigestSignInit.3
+++ /dev/null
@@ -1,243 +0,0 @@
1.\" $OpenBSD: EVP_DigestSignInit.3,v 1.15 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to: OpenSSL 28428130 Apr 17 15:18:40 2018 +0200
3.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2006, 2009, 2015, 2016, 2017 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: December 6 2024 $
54.Dt EVP_DIGESTSIGNINIT 3
55.Os
56.Sh NAME
57.Nm EVP_DigestSignInit ,
58.Nm EVP_DigestSignUpdate ,
59.Nm EVP_DigestSignFinal ,
60.Nm EVP_DigestSign
61.Nd EVP signing functions
62.Sh SYNOPSIS
63.In openssl/evp.h
64.Ft int
65.Fo EVP_DigestSignInit
66.Fa "EVP_MD_CTX *ctx"
67.Fa "EVP_PKEY_CTX **pctx"
68.Fa "const EVP_MD *type"
69.Fa "ENGINE *engine"
70.Fa "EVP_PKEY *pkey"
71.Fc
72.Ft int
73.Fo EVP_DigestSignUpdate
74.Fa "EVP_MD_CTX *ctx"
75.Fa "const void *d"
76.Fa "size_t cnt"
77.Fc
78.Ft int
79.Fo EVP_DigestSignFinal
80.Fa "EVP_MD_CTX *ctx"
81.Fa "unsigned char *sig"
82.Fa "size_t *siglen"
83.Fc
84.Ft int
85.Fo EVP_DigestSign
86.Fa "EVP_MD_CTX *ctx"
87.Fa "unsigned char *sigret"
88.Fa "size_t *siglen"
89.Fa "const unsigned char *tbs"
90.Fa "size_t tbslen"
91.Fc
92.Sh DESCRIPTION
93The EVP signature routines are a high-level interface to digital
94signatures.
95.Pp
96.Fn EVP_DigestSignInit
97sets up the signing context
98.Fa ctx
99to use the digest
100.Fa type
101and the private key
102.Fa pkey .
103Before calling this function, obtain
104.Fa ctx
105from
106.Xr EVP_MD_CTX_new 3
107or call
108.Xr EVP_MD_CTX_reset 3
109on it.
110The
111.Fa engine
112argument is always ignored and passing
113.Dv NULL
114is recommended.
115.Pp
116If
117.Fa pctx
118is not
119.Dv NULL ,
120any pointer passed in as
121.Pf * Fa pctx
122is ignored and overwritten by an internal pointer to the
123.Vt EVP_PKEY_CTX
124used by the signing operation:
125this can be used to set alternative signing options.
126The returned
127.Vt EVP_PKEY_CTX
128must not be freed by the application.
129It is freed automatically when the
130.Vt EVP_MD_CTX
131is freed.
132.Pp
133.Fn EVP_DigestSignUpdate
134hashes
135.Fa cnt
136bytes of data at
137.Fa d
138into the signature context
139.Fa ctx .
140This function can be called several times on the same
141.Fa ctx
142to include additional data.
143This function is currently implemented using a macro.
144.Pp
145.Fn EVP_DigestSignFinal
146signs the data in
147.Fa ctx
148and places the signature in
149.Fa sig .
150If
151.Fa sig
152is
153.Dv NULL ,
154then the maximum size of the output buffer is written to
155.Pf * Fa siglen .
156If
157.Fa sig
158is not
159.Dv NULL ,
160then before the call
161.Fa siglen
162should contain the length of the
163.Fa sig
164buffer.
165If the call is successful, the signature is written to
166.Fa sig
167and the amount of data written to
168.Fa siglen .
169.Pp
170.Fn EVP_DigestSign
171signs
172.Fa tbslen
173bytes of data at
174.Fa tbs
175and places the signature in
176.Fa sigret
177and its length in
178.Fa siglen
179in a similar way to
180.Fn EVP_DigestSignFinal .
181.Fn EVP_DigestSign
182is a one shot operation which signs a single block of data
183with one function call.
184For algorithms that support streaming it is equivalent to calling
185.Fn EVP_DigestSignUpdate
186and
187.Fn EVP_DigestSignFinal .
188.\" For algorithms which do not support streaming
189.\" (e.g. PureEdDSA)
190.\" it is the only way to sign data.
191.Pp
192The EVP interface to digital signatures should almost always be
193used in preference to the low-level interfaces.
194This is because the code then becomes transparent to the algorithm used
195and much more flexible.
196.Pp
197The call to
198.Fn EVP_DigestSignFinal
199internally finalizes a copy of the digest context.
200This means that
201.Fn EVP_DigestSignUpdate
202and
203.Fn EVP_DigestSignFinal
204can be called later to digest and sign additional data.
205.Pp
206Since only a copy of the digest context is ever finalized, the context
207must be cleaned up after use by calling
208.Xr EVP_MD_CTX_free 3 ,
209or a memory leak will occur.
210.Pp
211The use of
212.Xr EVP_PKEY_size 3
213with these functions is discouraged because some signature operations
214may have a signature length which depends on the parameters set.
215As a result,
216.Xr EVP_PKEY_size 3
217would have to return a value which indicates the maximum possible
218signature for any set of parameters.
219.Sh RETURN VALUES
220.Fn EVP_DigestSignInit ,
221.Fn EVP_DigestSignUpdate ,
222.Fn EVP_DigestSignFinal ,
223and
224.Fn EVP_DigestSign
225return 1 for success and 0 for failure.
226.Pp
227The error codes can be obtained from
228.Xr ERR_get_error 3 .
229.Sh SEE ALSO
230.Xr evp 3 ,
231.Xr EVP_DigestInit 3 ,
232.Xr EVP_DigestVerifyInit 3
233.Sh HISTORY
234.Fn EVP_DigestSignInit ,
235.Fn EVP_DigestSignUpdate ,
236and
237.Fn EVP_DigestSignFinal
238first appeared in OpenSSL 1.0.0 and have been available since
239.Ox 4.9 .
240.Pp
241.Fn EVP_DigestSign
242first appeared in OpenSSL 1.1.1 and has been available since
243.Ox 7.0 .
diff --git a/src/lib/libcrypto/man/EVP_DigestVerifyInit.3 b/src/lib/libcrypto/man/EVP_DigestVerifyInit.3
deleted file mode 100644
index fa62f5a0a5..0000000000
--- a/src/lib/libcrypto/man/EVP_DigestVerifyInit.3
+++ /dev/null
@@ -1,223 +0,0 @@
1.\" $OpenBSD: EVP_DigestVerifyInit.3,v 1.17 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to OpenSSL f097e875 Aug 23 11:37:22 2018 +0100
3.\" selective merge up to 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2006, 2009, 2014, 2015, 2016, 2017 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: December 6 2024 $
54.Dt EVP_DIGESTVERIFYINIT 3
55.Os
56.Sh NAME
57.Nm EVP_DigestVerifyInit ,
58.Nm EVP_DigestVerifyUpdate ,
59.Nm EVP_DigestVerifyFinal ,
60.Nm EVP_DigestVerify
61.Nd EVP signature verification functions
62.Sh SYNOPSIS
63.In openssl/evp.h
64.Ft int
65.Fo EVP_DigestVerifyInit
66.Fa "EVP_MD_CTX *ctx"
67.Fa "EVP_PKEY_CTX **pctx"
68.Fa "const EVP_MD *type"
69.Fa "ENGINE *engine"
70.Fa "EVP_PKEY *pkey"
71.Fc
72.Ft int
73.Fo EVP_DigestVerifyUpdate
74.Fa "EVP_MD_CTX *ctx"
75.Fa "const void *d"
76.Fa "size_t cnt"
77.Fc
78.Ft int
79.Fo EVP_DigestVerifyFinal
80.Fa "EVP_MD_CTX *ctx"
81.Fa "const unsigned char *sig"
82.Fa "size_t siglen"
83.Fc
84.Ft int
85.Fo EVP_DigestVerify
86.Fa "EVP_MD_CTX *ctx"
87.Fa "const unsigned char *sig"
88.Fa "size_t siglen"
89.Fa "const unsigned char *tbs"
90.Fa "size_t *tbslen"
91.Fc
92.Sh DESCRIPTION
93The EVP signature routines are a high-level interface to digital
94signatures.
95.Pp
96.Fn EVP_DigestVerifyInit
97sets up the verification context
98.Fa ctx
99to use the digest
100.Fa type
101and the public key
102.Fa pkey .
103Before calling this function, obtain
104.Fa ctx
105from
106.Xr EVP_MD_CTX_new 3
107or call
108.Xr EVP_MD_CTX_reset 3
109on it.
110The
111.Fa engine
112argument is always ignored and passing
113.Dv NULL
114is recommended.
115.Pp
116If
117.Fa pctx
118is not
119.Dv NULL ,
120any pointer passed in as
121.Pf * Fa pctx
122is ignored and overwritten by an internal pointer to the
123.Vt EVP_PKEY_CTX
124used by the verification operation:
125this can be used to set alternative signing options.
126The returned
127.Vt EVP_PKEY_CTX
128must not be freed by the application.
129It is freed automatically when the
130.Vt EVP_MD_CTX
131is freed.
132.Pp
133.Fn EVP_DigestVerifyUpdate
134hashes
135.Fa cnt
136bytes of data at
137.Fa d
138into the verification context
139.Fa ctx .
140This function can be called several times on the same
141.Fa ctx
142to include additional data.
143This function is currently implemented using a macro.
144.Pp
145.Fn EVP_DigestVerifyFinal
146verifies the data in
147.Fa ctx
148against the signature in
149.Fa sig
150of length
151.Fa siglen .
152.Pp
153.Fn EVP_DigestVerify
154verifies
155.Fa tbslen
156bytes at
157.Fa tbs
158against the signature in
159.Fa sig
160of length
161.Fa siglen .
162.Fn EVP_DigestVerify
163is a one shot operation which verifies a single block of data
164in one function call.
165For algorithms that support streaming it is equivalent to calling
166.Fn EVP_DigestVerifyUpdate
167and
168.Fn EVP_DigestVerifyFinal .
169.\" For algorithms which do not support streaming
170.\" (e.g. PureEdDSA)
171.\" it is the only way to verify data.
172.Pp
173The EVP interface to digital signatures should almost always be
174used in preference to the low-level interfaces.
175This is because the code then becomes transparent to the algorithm used
176and much more flexible.
177.Pp
178The call to
179.Fn EVP_DigestVerifyFinal
180internally finalizes a copy of the digest context.
181This means that
182.Xr EVP_VerifyUpdate 3
183and
184.Xr EVP_VerifyFinal 3
185can be called later to digest and verify additional data.
186.Pp
187Since only a copy of the digest context is ever finalized, the context
188must be cleaned up after use by calling
189.Xr EVP_MD_CTX_free 3
190or a memory leak will occur.
191.Sh RETURN VALUES
192.Fn EVP_DigestVerifyInit
193and
194.Fn EVP_DigestVerifyUpdate
195return 1 for success and 0 for failure.
196.Pp
197.Fn EVP_DigestVerifyFinal
198and
199.Fn EVP_DigestVerify
200return 1 for success; any other value indicates failure.
201A return value of 0 indicates that the signature did not verify
202successfully (that is, the signature did not match the original
203data or the signature had an invalid form), while other values
204indicate a more serious error (and sometimes also indicate an invalid
205signature form).
206.Pp
207The error codes can be obtained from
208.Xr ERR_get_error 3 .
209.Sh SEE ALSO
210.Xr evp 3 ,
211.Xr EVP_DigestInit 3 ,
212.Xr EVP_DigestSignInit 3
213.Sh HISTORY
214.Fn EVP_DigestVerifyInit ,
215.Fn EVP_DigestVerifyUpdate ,
216and
217.Fn EVP_DigestVerifyFinal
218first appeared in OpenSSL 1.0.0 and have been available since
219.Ox 4.9 .
220.Pp
221.Fn EVP_DigestVerify
222first appeared in OpenSSL 1.1.1 and has been available since
223.Ox 7.0 .
diff --git a/src/lib/libcrypto/man/EVP_EncodeInit.3 b/src/lib/libcrypto/man/EVP_EncodeInit.3
deleted file mode 100644
index da79af84cf..0000000000
--- a/src/lib/libcrypto/man/EVP_EncodeInit.3
+++ /dev/null
@@ -1,334 +0,0 @@
1.\" $OpenBSD: EVP_EncodeInit.3,v 1.7 2019/06/06 01:06:58 schwarze Exp $
2.\" full merge up to: OpenSSL f430ba31 Jun 19 19:39:01 2016 +0200
3.\" selective merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
4.\"
5.\" This file was written by Matt Caswell <matt@openssl.org>.
6.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: June 6 2019 $
53.Dt EVP_ENCODEINIT 3
54.Os
55.Sh NAME
56.Nm EVP_ENCODE_CTX_new ,
57.Nm EVP_ENCODE_CTX_free ,
58.Nm EVP_EncodeInit ,
59.Nm EVP_EncodeUpdate ,
60.Nm EVP_EncodeFinal ,
61.Nm EVP_EncodeBlock ,
62.Nm EVP_DecodeInit ,
63.Nm EVP_DecodeUpdate ,
64.Nm EVP_DecodeFinal ,
65.Nm EVP_DecodeBlock
66.Nd EVP base64 encode/decode routines
67.Sh SYNOPSIS
68.In openssl/evp.h
69.Ft EVP_ENCODE_CTX *
70.Fn EVP_ENCODE_CTX_new void
71.Ft void
72.Fo EVP_ENCODE_CTX_free
73.Fa "EVP_ENCODE_CTX *ctx"
74.Fc
75.Ft void
76.Fo EVP_EncodeInit
77.Fa "EVP_ENCODE_CTX *ctx"
78.Fc
79.Ft int
80.Fo EVP_EncodeUpdate
81.Fa "EVP_ENCODE_CTX *ctx"
82.Fa "unsigned char *out"
83.Fa "int *outl"
84.Fa "const unsigned char *in"
85.Fa "int inl"
86.Fc
87.Ft void
88.Fo EVP_EncodeFinal
89.Fa "EVP_ENCODE_CTX *ctx"
90.Fa "unsigned char *out"
91.Fa "int *outl"
92.Fc
93.Ft int
94.Fo EVP_EncodeBlock
95.Fa "unsigned char *t"
96.Fa "const unsigned char *f"
97.Fa "int n"
98.Fc
99.Ft void
100.Fo EVP_DecodeInit
101.Fa "EVP_ENCODE_CTX *ctx"
102.Fc
103.Ft int
104.Fo EVP_DecodeUpdate
105.Fa "EVP_ENCODE_CTX *ctx"
106.Fa "unsigned char *out"
107.Fa "int *outl"
108.Fa "const unsigned char *in"
109.Fa "int inl"
110.Fc
111.Ft int
112.Fo EVP_DecodeFinal
113.Fa "EVP_ENCODE_CTX *ctx"
114.Fa "unsigned char *out"
115.Fa "int *outl"
116.Fc
117.Ft int
118.Fo EVP_DecodeBlock
119.Fa "unsigned char *t"
120.Fa "const unsigned char *f"
121.Fa "int n"
122.Fc
123.Sh DESCRIPTION
124The EVP encode routines provide a high level interface to base64
125encoding and decoding.
126Base64 encoding converts binary data into a printable form that uses
127the characters A-Z, a-z, 0-9, "+" and "/" to represent the data.
128For every 3 bytes of binary data provided, 4 bytes of base64-encoded
129data will be produced, plus some occasional newlines.
130If the input data length is not a multiple of 3, then the output data
131will be padded at the end using the "=" character.
132.Pp
133.Fn EVP_ENCODE_CTX_new
134allocates, initializes and returns a context to be used for the encode
135and decode functions.
136.Pp
137.Fn EVP_ENCODE_CTX_free
138frees
139.Fa ctx .
140.Pp
141Encoding of binary data is performed in blocks of 48 input bytes (or
142less for the final block).
143For each 48-byte input block encoded, 64 bytes of base64 data is output,
144plus an additional newline character, i.e. 65 bytes in total.
145The final block, which may be less than 48 bytes, will output 4 bytes
146for every 3 bytes of input.
147If the data length is not divisible by 3, then a full 4 bytes is still
148output for the final 1 or 2 bytes of input.
149Similarly a newline character will also be output.
150.Pp
151.Fn EVP_EncodeInit
152initialises
153.Fa ctx
154for the start of a new encoding operation.
155.Pp
156.Fn EVP_EncodeUpdate
157encodes
158.Fa inl
159bytes of data found in the buffer pointed to by
160.Fa in .
161The output is stored in the buffer
162.Fa out
163and the number of bytes output is stored in
164.Pf * Fa outl .
165It is the caller's responsibility to ensure that the buffer at
166.Fa out
167is sufficiently large to accommodate the output data.
168Only full blocks of data (48 bytes) will be immediately processed and
169output by this function.
170Any remainder is held in the
171.Fa ctx
172object and will be processed by a subsequent call to
173.Fn EVP_EncodeUpdate
174or
175.Fn EVP_EncodeFinal .
176To calculate the required size of the output buffer, add together the
177value of
178.Fa inl
179with the amount of unprocessed data held in
180.Fa ctx
181and divide the result by 48 (ignore any remainder).
182This gives the number of blocks of data that will be processed.
183Ensure the output buffer contains 65 bytes of storage for each block,
184plus an additional byte for a NUL terminator.
185.Fn EVP_EncodeUpdate
186may be called repeatedly to process large amounts of input data.
187In the event of an error ,
188.Fn EVP_EncodeUpdate
189will set
190.Pf * Fa outl
191to 0 and return 0.
192On success 1 will be returned.
193.Pp
194.Fn EVP_EncodeFinal
195must be called at the end of an encoding operation.
196It will process any partial block of data remaining in the
197.Fa ctx
198object.
199The output data will be stored in
200.Fa out
201and the length of the data written will be stored in
202.Pf * Fa outl .
203It is the caller's responsibility to ensure that
204.Fa out
205is sufficiently large to accommodate the output data, which will
206never be more than 65 bytes plus an additional NUL terminator, i.e.
20766 bytes in total.
208.Pp
209.Fn EVP_EncodeBlock
210encodes a full block of input data in
211.Fa f
212and of length
213.Fa n
214and stores it in
215.Fa t .
216For every 3 bytes of input provided, 4 bytes of output data will be
217produced.
218If
219.Sy n
220is not divisible by 3, then the block is encoded as a final block
221of data and the output is padded such that it is always divisible
222by 4.
223Additionally a NUL terminator character will be added.
224For example, if 16 bytes of input data are provided, then 24 bytes
225of encoded data is created plus 1 byte for a NUL terminator,
226i.e. 25 bytes in total.
227The length of the data generated
228.Em without
229the NUL terminator is returned from the function.
230.Pp
231.Fn EVP_DecodeInit
232initialises
233.Fa ctx
234for the start of a new decoding operation.
235.Pp
236.Fn EVP_DecodeUpdate
237decodes
238.Fa inl
239characters of data found in the buffer pointed to by
240.Fa in .
241The output is stored in the buffer
242.Fa out
243and the number of bytes output is stored in
244.Pf * Fa outl .
245It is the caller's responsibility to ensure that the buffer at
246.Fa out
247is sufficiently large to accommodate the output data.
248This function will attempt to decode as much data as possible in 4-byte
249chunks.
250Any whitespace, newline or carriage return characters are ignored.
251Any partial chunk of unprocessed data (1, 2 or 3 bytes) that remains at
252the end will be held in the
253.Fa ctx
254object and processed by a subsequent call to
255.Fn EVP_DecodeUpdate .
256If any illegal base64 characters are encountered or if the base64
257padding character "=" is encountered in the middle of the data,
258then the function returns -1 to indicate an error.
259A return value of 0 or 1 indicates successful processing of the data.
260A return value of 0 additionally indicates that the last input data
261characters processed included the base64 padding character "=" and
262therefore no more non-padding character data is expected to be
263processed.
264For every 4 valid base64 bytes processed \(em ignoring whitespace,
265carriage returns and line feeds \(em 3 bytes of binary output data
266will be produced, or less at the end of the data where the padding
267character "=" has been used.
268.Pp
269.Fn EVP_DecodeFinal
270must be called at the end of a decoding operation.
271If there is any unprocessed data still in
272.Fa ctx ,
273then the input data must not have been a multiple of 4 and therefore an
274error has occurred.
275The function will return -1 in this case.
276Otherwise the function returns 1 on success.
277.Pp
278.Fn EVP_DecodeBlock
279will decode the block of
280.Fa n
281characters of base64 data contained in
282.Fa f
283and store the result in
284.Fa t .
285Any leading whitespace will be trimmed as will any trailing whitespace,
286newlines, carriage returns or EOF characters.
287After such trimming the length of the data in
288.Fa f
289must be divisible by 4.
290For every 4 input bytes, exactly 3 output bytes will be produced.
291The output will be padded with 0 bits if necessary to ensure that the
292output is always 3 bytes for every 4 input bytes.
293This function will return the length of the data decoded or -1 on error.
294.Sh RETURN VALUES
295.Fn EVP_ENCODE_CTX_new
296returns a pointer to the newly allocated
297.Vt EVP_ENCODE_CTX
298object or
299.Dv NULL
300on error.
301.Pp
302.Fn EVP_EncodeUpdate
303returns 0 on error or 1 on success.
304.Pp
305.Fn EVP_EncodeBlock
306returns the number of bytes encoded excluding the NUL terminator.
307.Pp
308.Fn EVP_DecodeUpdate
309returns -1 on error and 0 or 1 on success.
310If 0 is returned, then no more non-padding base64 characters are
311expected.
312.Pp
313.Fn EVP_DecodeFinal
314returns -1 on error or 1 on success.
315.Pp
316.Fn EVP_DecodeBlock
317returns the length of the data decoded or -1 on error.
318.Sh SEE ALSO
319.Xr BIO_f_base64 3 ,
320.Xr evp 3
321.Sh HISTORY
322The
323.Fn EVP_Encode*
324and
325.Fn EVP_Decode*
326functions first appeared in SSLeay 0.5.1
327and have been available since
328.Ox 2.4 .
329.Pp
330.Fn EVP_ENCODE_CTX_new
331and
332.Fn EVP_ENCODE_CTX_free
333first appeared in OpenSSL 1.1.0 and have been available since
334.Ox 6.5 .
diff --git a/src/lib/libcrypto/man/EVP_EncryptInit.3 b/src/lib/libcrypto/man/EVP_EncryptInit.3
deleted file mode 100644
index 7765be2ca6..0000000000
--- a/src/lib/libcrypto/man/EVP_EncryptInit.3
+++ /dev/null
@@ -1,813 +0,0 @@
1.\" $OpenBSD: EVP_EncryptInit.3,v 1.56 2024/12/20 01:54:03 schwarze Exp $
2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800
3.\" EVP_bf_cbc.pod EVP_cast5_cbc.pod EVP_idea_cbc.pod EVP_rc2_cbc.pod
4.\" 7c6d372a Nov 20 13:20:01 2018 +0000
5.\"
6.\" This file is a derived work.
7.\" The changes are covered by the following Copyright and license:
8.\"
9.\" Copyright (c) 2019, 2023 Ingo Schwarze <schwarze@openbsd.org>
10.\"
11.\" Permission to use, copy, modify, and distribute this software for any
12.\" purpose with or without fee is hereby granted, provided that the above
13.\" copyright notice and this permission notice appear in all copies.
14.\"
15.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22.\"
23.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
24.\" and Richard Levitte <levitte@openssl.org>.
25.\" Copyright (c) 2000-2002, 2005, 2012-2016 The OpenSSL Project.
26.\" All rights reserved.
27.\"
28.\" Redistribution and use in source and binary forms, with or without
29.\" modification, are permitted provided that the following conditions
30.\" are met:
31.\"
32.\" 1. Redistributions of source code must retain the above copyright
33.\" notice, this list of conditions and the following disclaimer.
34.\"
35.\" 2. Redistributions in binary form must reproduce the above copyright
36.\" notice, this list of conditions and the following disclaimer in
37.\" the documentation and/or other materials provided with the
38.\" distribution.
39.\"
40.\" 3. All advertising materials mentioning features or use of this
41.\" software must display the following acknowledgment:
42.\" "This product includes software developed by the OpenSSL Project
43.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
44.\"
45.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
46.\" endorse or promote products derived from this software without
47.\" prior written permission. For written permission, please contact
48.\" openssl-core@openssl.org.
49.\"
50.\" 5. Products derived from this software may not be called "OpenSSL"
51.\" nor may "OpenSSL" appear in their names without prior written
52.\" permission of the OpenSSL Project.
53.\"
54.\" 6. Redistributions of any form whatsoever must retain the following
55.\" acknowledgment:
56.\" "This product includes software developed by the OpenSSL Project
57.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
58.\"
59.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
60.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
62.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
63.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
64.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
65.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
66.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
68.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\"
72.Dd $Mdocdate: December 20 2024 $
73.Dt EVP_ENCRYPTINIT 3
74.Os
75.Sh NAME
76.Nm EVP_CIPHER_CTX_new ,
77.Nm EVP_CIPHER_CTX_reset ,
78.Nm EVP_CIPHER_CTX_free ,
79.Nm EVP_CIPHER_CTX_copy ,
80.Nm EVP_EncryptInit_ex ,
81.Nm EVP_EncryptUpdate ,
82.Nm EVP_EncryptFinal_ex ,
83.Nm EVP_DecryptInit_ex ,
84.Nm EVP_DecryptUpdate ,
85.Nm EVP_DecryptFinal_ex ,
86.Nm EVP_CipherInit_ex ,
87.Nm EVP_CipherUpdate ,
88.Nm EVP_CipherFinal_ex ,
89.Nm EVP_EncryptInit ,
90.Nm EVP_EncryptFinal ,
91.Nm EVP_DecryptInit ,
92.Nm EVP_DecryptFinal ,
93.Nm EVP_CipherInit ,
94.Nm EVP_CipherFinal ,
95.Nm EVP_CIPHER_CTX_encrypting ,
96.Nm EVP_get_cipherbyname ,
97.Nm EVP_get_cipherbynid ,
98.Nm EVP_get_cipherbyobj ,
99.Nm EVP_CIPHER_CTX_cipher ,
100.Nm EVP_enc_null ,
101.Nm EVP_idea_cbc ,
102.Nm EVP_idea_ecb ,
103.Nm EVP_idea_cfb64 ,
104.Nm EVP_idea_cfb ,
105.Nm EVP_idea_ofb ,
106.Nm EVP_bf_cbc ,
107.Nm EVP_bf_ecb ,
108.Nm EVP_bf_cfb64 ,
109.Nm EVP_bf_cfb ,
110.Nm EVP_bf_ofb ,
111.Nm EVP_cast5_cbc ,
112.Nm EVP_cast5_ecb ,
113.Nm EVP_cast5_cfb64 ,
114.Nm EVP_cast5_cfb ,
115.Nm EVP_cast5_ofb
116.Nd EVP cipher routines
117.Sh SYNOPSIS
118.In openssl/evp.h
119.Ft EVP_CIPHER_CTX *
120.Fn EVP_CIPHER_CTX_new void
121.Ft int
122.Fo EVP_CIPHER_CTX_reset
123.Fa "EVP_CIPHER_CTX *ctx"
124.Fc
125.Ft void
126.Fo EVP_CIPHER_CTX_free
127.Fa "EVP_CIPHER_CTX *ctx"
128.Fc
129.Ft int
130.Fo EVP_CIPHER_CTX_copy
131.Fa "EVP_CIPHER_CTX *out"
132.Fa "const EVP_CIPHER_CTX *in"
133.Fc
134.Ft int
135.Fo EVP_EncryptInit_ex
136.Fa "EVP_CIPHER_CTX *ctx"
137.Fa "const EVP_CIPHER *type"
138.Fa "ENGINE *engine"
139.Fa "const unsigned char *key"
140.Fa "const unsigned char *iv"
141.Fc
142.Ft int
143.Fo EVP_EncryptUpdate
144.Fa "EVP_CIPHER_CTX *ctx"
145.Fa "unsigned char *out"
146.Fa "int *out_len"
147.Fa "const unsigned char *in"
148.Fa "int in_len"
149.Fc
150.Ft int
151.Fo EVP_EncryptFinal_ex
152.Fa "EVP_CIPHER_CTX *ctx"
153.Fa "unsigned char *out"
154.Fa "int *out_len"
155.Fc
156.Ft int
157.Fo EVP_DecryptInit_ex
158.Fa "EVP_CIPHER_CTX *ctx"
159.Fa "const EVP_CIPHER *type"
160.Fa "ENGINE *engine"
161.Fa "const unsigned char *key"
162.Fa "const unsigned char *iv"
163.Fc
164.Ft int
165.Fo EVP_DecryptUpdate
166.Fa "EVP_CIPHER_CTX *ctx"
167.Fa "unsigned char *out"
168.Fa "int *out_len"
169.Fa "const unsigned char *in"
170.Fa "int in_len"
171.Fc
172.Ft int
173.Fo EVP_DecryptFinal_ex
174.Fa "EVP_CIPHER_CTX *ctx"
175.Fa "unsigned char *out"
176.Fa "int *out_len"
177.Fc
178.Ft int
179.Fo EVP_CipherInit_ex
180.Fa "EVP_CIPHER_CTX *ctx"
181.Fa "const EVP_CIPHER *type"
182.Fa "ENGINE *engine"
183.Fa "const unsigned char *key"
184.Fa "const unsigned char *iv"
185.Fa "int enc"
186.Fc
187.Ft int
188.Fo EVP_CipherUpdate
189.Fa "EVP_CIPHER_CTX *ctx"
190.Fa "unsigned char *out"
191.Fa "int *out_len"
192.Fa "const unsigned char *in"
193.Fa "int in_len"
194.Fc
195.Ft int
196.Fo EVP_CipherFinal_ex
197.Fa "EVP_CIPHER_CTX *ctx"
198.Fa "unsigned char *out"
199.Fa "int *out_len"
200.Fc
201.Ft int
202.Fo EVP_EncryptInit
203.Fa "EVP_CIPHER_CTX *ctx"
204.Fa "const EVP_CIPHER *type"
205.Fa "const unsigned char *key"
206.Fa "const unsigned char *iv"
207.Fc
208.Ft int
209.Fo EVP_EncryptFinal
210.Fa "EVP_CIPHER_CTX *ctx"
211.Fa "unsigned char *out"
212.Fa "int *out_len"
213.Fc
214.Ft int
215.Fo EVP_DecryptInit
216.Fa "EVP_CIPHER_CTX *ctx"
217.Fa "const EVP_CIPHER *type"
218.Fa "const unsigned char *key"
219.Fa "const unsigned char *iv"
220.Fc
221.Ft int
222.Fo EVP_DecryptFinal
223.Fa "EVP_CIPHER_CTX *ctx"
224.Fa "unsigned char *out"
225.Fa "int *out_len"
226.Fc
227.Ft int
228.Fo EVP_CipherInit
229.Fa "EVP_CIPHER_CTX *ctx"
230.Fa "const EVP_CIPHER *type"
231.Fa "const unsigned char *key"
232.Fa "const unsigned char *iv"
233.Fa "int enc"
234.Fc
235.Ft int
236.Fo EVP_CipherFinal
237.Fa "EVP_CIPHER_CTX *ctx"
238.Fa "unsigned char *out"
239.Fa "int *out_len"
240.Fc
241.Ft int
242.Fo EVP_CIPHER_CTX_encrypting
243.Fa "const EVP_CIPHER_CTX *ctx"
244.Fc
245.Ft const EVP_CIPHER *
246.Fo EVP_get_cipherbyname
247.Fa "const char *name"
248.Fc
249.Ft const EVP_CIPHER *
250.Fo EVP_get_cipherbynid
251.Fa "int nid"
252.Fc
253.Ft const EVP_CIPHER *
254.Fo EVP_get_cipherbyobj
255.Fa "const ASN1_OBJECT *a"
256.Fc
257.Ft const EVP_CIPHER *
258.Fo EVP_CIPHER_CTX_cipher
259.Fa "const EVP_CIPHER_CTX *ctx"
260.Fc
261.Sh DESCRIPTION
262The EVP cipher routines are a high level interface to certain symmetric
263ciphers.
264.Pp
265.Fn EVP_CIPHER_CTX_new
266creates a new, empty cipher context.
267.Pp
268.Fn EVP_CIPHER_CTX_reset
269clears all information from
270.Fa ctx
271and frees all allocated memory associated with it, except the
272.Fa ctx
273object itself, such that it can be reused for another series of calls to
274.Fn EVP_CipherInit ,
275.Fn EVP_CipherUpdate ,
276and
277.Fn EVP_CipherFinal .
278.Pp
279.Fn EVP_CIPHER_CTX_free
280clears all information from
281.Fa ctx
282and frees all allocated memory associated with it, including
283.Fa ctx
284itself.
285This function should be called after all operations using a cipher
286are complete, so sensitive information does not remain in memory.
287If
288.Fa ctx
289is a
290.Dv NULL
291pointer, no action occurs.
292.Pp
293.Fn EVP_CIPHER_CTX_copy
294calls
295.Fn EVP_CIPHER_CTX_reset
296on
297.Fa out
298and copies all the data from
299.Fa in
300to
301.Fa out ,
302except that the
303.Vt EVP_CIPHER
304object used by
305.Fa in
306and any application specific data set with
307.Xr EVP_CIPHER_CTX_set_app_data 3
308are not copied and
309.Fa out
310will point to the same two objects.
311The algorithm- and implementation-specific cipher data described in
312.Xr EVP_CIPHER_CTX_get_cipher_data 3
313is copied with
314.Xr malloc 3
315and
316.Xr memcpy 3 ,
317i.e. assuming that it does not contain pointers to any sub-objects.
318If the bit
319.Dv EVP_CIPH_CUSTOM_COPY
320has been set with
321.Xr EVP_CIPHER_meth_set_flags 3 ,
322.Xr EVP_CIPHER_CTX_ctrl 3
323is called at the end with arguments
324.Fa in ,
325.Dv EVP_CTRL_COPY ,
326.No 0 ,
327and
328.Fa out
329such that the cipher implementation can perform further algorithm-
330and implementation-specific initializations after the algorithm-
331and implementation-specific cipher data has been copied.
332Among the cipher algorithms built into the library,
333.Dv EVP_CIPH_CUSTOM_COPY
334and
335.Dv EVP_CTRL_COPY
336are used by some of the ciphers documented in the
337.Xr EVP_aes_256_gcm 3
338manual page.
339.Pp
340.Fn EVP_EncryptInit
341and
342.Fn EVP_EncryptInit_ex
343set up the cipher context
344.Fa ctx
345for encryption with cipher
346.Fa type .
347.Fa type
348is normally supplied by a function such as
349.Xr EVP_aes_256_cbc 3 .
350.Fa key
351is the symmetric key to use and
352.Fa iv
353is the IV to use (if necessary).
354The actual number of bytes used for the
355key and IV depends on the cipher.
356The
357.Fa ENGINE *engine
358argument is always ignored and passing
359.Dv NULL
360is recommended.
361It is possible to set all parameters to
362.Dv NULL
363except
364.Fa type
365in an initial call and supply the remaining parameters in subsequent
366calls, all of which have
367.Fa type
368set to
369.Dv NULL .
370This is done when the default cipher parameters are not appropriate.
371.Pp
372.Fn EVP_EncryptUpdate
373encrypts
374.Fa in_len
375bytes from the buffer
376.Fa in
377and writes the encrypted version to
378.Fa out .
379This function can be called multiple times to encrypt successive blocks
380of data.
381The amount of data written depends on the block alignment of the
382encrypted data: as a result the amount of data written may be anything
383from zero bytes to
384.Pq Fa in_len No + cipher_block_size - 1
385so
386.Fa out
387should contain sufficient room.
388The actual number of bytes written is placed in
389.Pf * Fa out_len .
390.Pp
391If padding is enabled (the default) then
392.Fn EVP_EncryptFinal
393and
394.Fn EVP_EncryptFinal_ex ,
395which behave identically,
396encrypt the "final" data, that is any data that remains in a partial
397block.
398It uses NOTES (aka PKCS padding).
399The encrypted final data is written to
400.Fa out
401which should have sufficient space for one cipher block.
402The number of bytes written is placed in
403.Pf * Fa out_len .
404After this function is called, the encryption operation is finished and
405no further calls to
406.Fn EVP_EncryptUpdate
407should be made.
408.Pp
409If padding is disabled then
410.Fn EVP_EncryptFinal
411and
412.Fn EVP_EncryptFinal_ex
413do not encrypt any more data and return an error if any data
414remains in a partial block: that is if the total data length is not a
415multiple of the block size.
416.Pp
417.Fn EVP_DecryptInit ,
418.Fn EVP_DecryptInit_ex ,
419.Fn EVP_DecryptUpdate ,
420.Fn EVP_DecryptFinal ,
421and
422.Fn EVP_DecryptFinal_ex
423are the corresponding decryption operations.
424.Fn EVP_DecryptFinal
425and
426.Fn EVP_DecryptFinal_ex
427return an error code if padding is enabled and the final block is
428not correctly formatted.
429The parameters and restrictions are identical to the encryption
430operations except that if padding is enabled the decrypted data buffer
431.Fa out
432passed to
433.Fn EVP_DecryptUpdate
434should have sufficient room for
435.Pq Fa in_len No + cipher_block_size
436bytes unless the cipher block size is 1 in which case
437.Fa in_len
438bytes is sufficient.
439.Pp
440.Fn EVP_CipherInit ,
441.Fn EVP_CipherInit_ex ,
442.Fn EVP_CipherUpdate ,
443.Fn EVP_CipherFinal ,
444and
445.Fn EVP_CipherFinal_ex
446are functions that can be used for decryption or encryption.
447The operation performed depends on the value of the
448.Fa enc
449parameter.
450It should be set to 1 for encryption, 0 for decryption and -1 to leave
451the value unchanged (the actual value of
452.Fa enc
453being supplied in a previous call).
454.Pp
455.Fn EVP_get_cipherbyname ,
456.Fn EVP_get_cipherbynid ,
457and
458.Fn EVP_get_cipherbyobj
459return an
460.Vt EVP_CIPHER
461structure when passed a cipher name, a NID or an
462.Vt ASN1_OBJECT
463structure.
464.Pp
465.Fn EVP_CIPHER_CTX_cipher
466returns the
467.Vt EVP_CIPHER
468structure when passed an
469.Vt EVP_CIPHER_CTX
470structure.
471.Pp
472Where possible the EVP interface to symmetric ciphers should be
473used in preference to the low level interfaces.
474This is because the code then becomes transparent to the cipher used and
475much more flexible.
476.Pp
477PKCS padding works by adding n padding bytes of value n to make the
478total length of the encrypted data a multiple of the block size.
479Padding is always added so if the data is already a multiple of the
480block size n will equal the block size.
481For example if the block size is 8 and 11 bytes are to be encrypted then
4825 padding bytes of value 5 will be added.
483.Pp
484When decrypting, the final block is checked to see if it has the correct
485form.
486.Pp
487Although the decryption operation can produce an error if padding is
488enabled, it is not a strong test that the input data or key is correct.
489A random block has better than 1 in 256 chance of being of the correct
490format and problems with the input data earlier on will not produce a
491final decrypt error.
492.Pp
493If padding is disabled then the decryption operation will always succeed
494if the total amount of data decrypted is a multiple of the block size.
495.Pp
496.Fn EVP_get_cipherbynid
497and
498.Fn EVP_get_cipherbyobj
499are implemented as macros.
500.Sh RETURN VALUES
501.Fn EVP_CIPHER_CTX_new
502returns a pointer to a newly created
503.Vt EVP_CIPHER_CTX
504for success or
505.Dv NULL
506for failure.
507.Pp
508.Fn EVP_CIPHER_CTX_reset ,
509.Fn EVP_CIPHER_CTX_copy ,
510.Fn EVP_EncryptInit_ex ,
511.Fn EVP_EncryptUpdate ,
512.Fn EVP_EncryptFinal_ex ,
513.Fn EVP_DecryptInit_ex ,
514.Fn EVP_DecryptUpdate ,
515.Fn EVP_DecryptFinal_ex ,
516.Fn EVP_CipherInit_ex ,
517.Fn EVP_CipherUpdate ,
518.Fn EVP_CipherFinal_ex ,
519.Fn EVP_EncryptInit ,
520.Fn EVP_EncryptFinal ,
521.Fn EVP_DecryptInit ,
522.Fn EVP_DecryptFinal ,
523.Fn EVP_CipherInit ,
524and
525.Fn EVP_CipherFinal
526return 1 for success or 0 for failure.
527.Pp
528.Fn EVP_CIPHER_CTX_encrypting
529returns 1 if
530.Fa ctx
531is initialized for encryption or 0 otherwise, in which case
532it may be uninitialized or initialized for decryption.
533.Pp
534.Fn EVP_get_cipherbyname ,
535.Fn EVP_get_cipherbynid ,
536and
537.Fn EVP_get_cipherbyobj
538return an
539.Vt EVP_CIPHER
540structure or
541.Dv NULL
542on error.
543.Pp
544.Fn EVP_CIPHER_CTX_cipher
545returns an
546.Vt EVP_CIPHER
547structure.
548.Sh CIPHER LISTING
549.Bl -tag -width Ds
550.It Fn EVP_enc_null
551Null cipher: does nothing.
552.It Xo
553.Fn EVP_idea_cbc ,
554.Fn EVP_idea_ecb ,
555.Fn EVP_idea_cfb64 ,
556.Fn EVP_idea_ofb
557.Xc
558IDEA encryption algorithm in CBC, ECB, CFB and OFB modes respectively.
559IDEA is a block cipher operating on 64 bit blocks using a 128 bit
560.Fa key .
561.Fn EVP_idea_cfb
562is an alias for
563.Fn EVP_idea_cfb64 ,
564implemented as a macro.
565.It Xo
566.Fn EVP_bf_cbc ,
567.Fn EVP_bf_ecb ,
568.Fn EVP_bf_cfb64 ,
569.Fn EVP_bf_ofb
570.Xc
571Blowfish encryption algorithm in CBC, ECB, CFB and OFB modes
572respectively.
573Blowfish is a block cipher operating on 64 bit blocks using a variable
574.Fa key
575length.
576The default key length is 128 bits.
577.Fn EVP_bf_cfb
578is an alias for
579.Fn EVP_bf_cfb64 ,
580implemented as a macro.
581.It Xo
582.Fn EVP_cast5_cbc ,
583.Fn EVP_cast5_ecb ,
584.Fn EVP_cast5_cfb64 ,
585.Fn EVP_cast5_ofb
586.Xc
587CAST-128 encryption algorithm in CBC, ECB, CFB and OFB modes respectively.
588CAST-128 is a block cipher operating on 64 bit blocks using a variable
589.Fa key
590length.
591The default and maximum key length is 128 bits.
592.Fn EVP_cast5_cfb
593is an alias for
594.Fn EVP_cast5_cfb64 ,
595implemented as a macro.
596.El
597.Pp
598Some algorithms are documented in separate manual pages:
599.Pp
600.Bl -column "EVP_camellia_128_cbc(3)" "block size" -compact
601.It manual page Ta block size Ta Fa key No size Pq in bits
602.It Xr EVP_aes_128_cbc 3 Ta 128 Ta 128, 192, 256
603.It Xr EVP_aes_128_ccm 3 Ta 128 Ta 128, 192, 256
604.It Xr EVP_aes_128_gcm 3 Ta 128 Ta 128, 192, 256
605.It Xr EVP_camellia_128_cbc 3 Ta 128 Ta 128, 192, 256
606.It Xr EVP_chacha20 3 Ta stream Ta 256
607.It Xr EVP_des_cbc 3 Ta 64 Ta 64
608.It Xr EVP_rc2_cbc 3 Ta 64 Ta variable, default 128
609.It Xr EVP_rc4 3 Ta stream Ta variable, default 128
610.It Xr EVP_sm4_cbc 3 Ta 128 Ta 128
611.El
612.Sh EXAMPLES
613Encrypt a string using blowfish:
614.Bd -literal -offset 3n
615int
616do_crypt(char *out_filename)
617{
618 unsigned char out_buf[1024];
619 int out_len, tmp_len;
620 /*
621 * Bogus key and IV: we'd normally set these from
622 * another source.
623 */
624 unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
625 unsigned char iv[] = {1,2,3,4,5,6,7,8};
626 const char in_text[] = "Some Crypto Text";
627 EVP_CIPHER_CTX *ctx;
628 FILE *out_fileptr;
629
630 ctx = EVP_CIPHER_CTX_new();
631 EVP_EncryptInit_ex(ctx, EVP_bf_cbc(), NULL, key, iv);
632
633 if (!EVP_EncryptUpdate(ctx, out_buf, &out_len, in_text,
634 strlen(in_text))) {
635 /* Error */
636 EVP_CIPHER_CTX_free(ctx);
637 return 0;
638 }
639 /*
640 * Buffer passed to EVP_EncryptFinal() must be after data just
641 * encrypted to avoid overwriting it.
642 */
643 if (!EVP_EncryptFinal_ex(ctx, out_buf + out_len, &tmp_len)) {
644 /* Error */
645 EVP_CIPHER_CTX_free(ctx);
646 return 0;
647 }
648 out_len += tmp_len;
649 EVP_CIPHER_CTX_free(ctx);
650 /*
651 * Need binary mode for fopen because encrypted data is
652 * binary data. Also cannot use strlen() on it because
653 * it won't be NUL terminated and may contain embedded
654 * NULs.
655 */
656 out_fileptr = fopen(out_filename, "wb");
657 if (out_fileptr == NULL) {
658 /* Error */
659 return 0;
660 }
661 fwrite(out_buf, 1, out_len, out_fileptr);
662 fclose(out_fileptr);
663 return 1;
664}
665.Ed
666.Pp
667The ciphertext from the above example can be decrypted using the
668.Xr openssl 1
669utility with the command line:
670.Bd -literal -offset indent
671openssl bf -in cipher.bin -K 000102030405060708090A0B0C0D0E0F \e
672 -iv 0102030405060708 -d
673.Ed
674.Pp
675General encryption, decryption function example using FILE I/O and AES128
676with a 128-bit key:
677.Bd -literal
678int
679do_crypt(FILE *in_fileptr, FILE *out_fileptr, int do_encrypt)
680{
681 /* Allow enough space in output buffer for additional block */
682 unsigned char in_buf[1024], out_buf[1024 + EVP_MAX_BLOCK_LENGTH];
683 int in_len, out_len;
684 EVP_CIPHER_CTX *ctx;
685
686 /*
687 * Bogus key and IV: we'd normally set these from
688 * another source.
689 */
690 unsigned char key[] = "0123456789abcdeF";
691 unsigned char iv[] = "1234567887654321";
692
693 ctx = EVP_CIPHER_CTX_new();
694 EVP_CipherInit_ex(ctx, EVP_aes_128_cbc(), NULL, NULL, NULL,
695 do_encrypt);
696 EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, do_encrypt);
697
698 for (;;) {
699 in_len = fread(in_buf, 1, 1024, in_fileptr);
700 if (in_len <= 0)
701 break;
702 if (!EVP_CipherUpdate(ctx, out_buf, &out_len, in_buf,
703 in_len)) {
704 /* Error */
705 EVP_CIPHER_CTX_free(ctx);
706 return 0;
707 }
708 fwrite(out_buf, 1, out_len, out_fileptr);
709 }
710 if (!EVP_CipherFinal_ex(ctx, out_buf, &out_len)) {
711 /* Error */
712 EVP_CIPHER_CTX_free(ctx);
713 return 0;
714 }
715 fwrite(out_buf, 1, out_len, out_fileptr);
716
717 EVP_CIPHER_CTX_free(ctx);
718 return 1;
719}
720.Ed
721.Sh SEE ALSO
722.Xr BIO_f_cipher 3 ,
723.Xr evp 3 ,
724.Xr EVP_AEAD_CTX_init 3 ,
725.Xr EVP_aes_128_cbc 3 ,
726.Xr EVP_aes_128_ccm 3 ,
727.Xr EVP_aes_128_gcm 3 ,
728.Xr EVP_camellia_128_cbc 3 ,
729.Xr EVP_chacha20 3 ,
730.Xr EVP_CIPHER_CTX_ctrl 3 ,
731.Xr EVP_CIPHER_CTX_get_cipher_data 3 ,
732.Xr EVP_CIPHER_CTX_init 3 ,
733.Xr EVP_CIPHER_CTX_set_flags 3 ,
734.Xr EVP_CIPHER_nid 3 ,
735.Xr EVP_des_cbc 3 ,
736.Xr EVP_OpenInit 3 ,
737.Xr EVP_rc2_cbc 3 ,
738.Xr EVP_rc4 3 ,
739.Xr EVP_SealInit 3 ,
740.Xr EVP_sm4_cbc 3
741.Sh HISTORY
742.Fn EVP_EncryptInit ,
743.Fn EVP_EncryptUpdate ,
744.Fn EVP_EncryptFinal ,
745.Fn EVP_DecryptInit ,
746.Fn EVP_DecryptUpdate ,
747.Fn EVP_DecryptFinal ,
748.Fn EVP_CipherInit ,
749.Fn EVP_CipherUpdate ,
750.Fn EVP_CipherFinal ,
751.Fn EVP_get_cipherbyname ,
752.Fn EVP_idea_cbc ,
753.Fn EVP_idea_ecb ,
754.Fn EVP_idea_cfb ,
755and
756.Fn EVP_idea_ofb
757first appeared in SSLeay 0.5.1.
758.Fn EVP_bf_cbc ,
759.Fn EVP_bf_ecb ,
760.Fn EVP_bf_cfb ,
761and
762.Fn EVP_bf_ofb
763first appeared in SSLeay 0.6.6.
764.Fn EVP_get_cipherbyobj ,
765.Fn EVP_CIPHER_CTX_cipher ,
766and
767.Fn EVP_enc_null
768first appeared in SSLeay 0.8.0.
769.Fn EVP_get_cipherbynid
770first appeared in SSLeay 0.8.1.
771All these functions have been available since
772.Ox 2.4 .
773.Pp
774.Fn EVP_EncryptInit_ex ,
775.Fn EVP_EncryptFinal_ex ,
776.Fn EVP_DecryptInit_ex ,
777.Fn EVP_DecryptFinal_ex ,
778.Fn EVP_CipherInit_ex ,
779and
780.Fn EVP_CipherFinal_ex
781first appeared in OpenSSL 0.9.7 and have been available since
782.Ox 3.2 .
783.Pp
784.Fn EVP_bf_cfb64 ,
785.Fn EVP_cast5_cfb64 ,
786and
787.Fn EVP_idea_cfb64
788first appeared in OpenSSL 0.9.7e and have been available since
789.Ox 3.8 .
790.Pp
791.Fn EVP_CIPHER_CTX_new
792and
793.Fn EVP_CIPHER_CTX_free
794first appeared in OpenSSL 0.9.8b and have been available since
795.Ox 4.5 .
796.Pp
797.Fn EVP_CIPHER_CTX_copy
798first appeared in OpenSSL 1.0.0
799and has been available since
800.Ox 4.9 .
801.Pp
802.Fn EVP_CIPHER_CTX_reset
803first appeared in OpenSSL 1.1.0 and has been available since
804.Ox 6.3 .
805.Pp
806.Fn EVP_CIPHER_CTX_encrypting
807first appeared in OpenSSL 1.1.0 and has been available since
808.Ox 6.4 .
809.Sh BUGS
810.Fn EVP_CIPHER_CTX_copy
811may already have cleared the data in
812.Fa out
813and copied some new data into it even if it fails and returns 0.
diff --git a/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3 b/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3
deleted file mode 100644
index c8c148faf0..0000000000
--- a/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3
+++ /dev/null
@@ -1,279 +0,0 @@
1.\" $OpenBSD: EVP_MD_CTX_ctrl.3,v 1.3 2024/03/05 17:21:40 tb Exp $
2.\" full merge up to: OpenSSL man3/EVP_DigestInit.pod
3.\" 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Richard Levitte <levitte@openssl.org>,
23.\" Todd Short <tshort@akamai.com>, Paul Yang <yang.yang@baishancloud.com>,
24.\" and Antoine Salon <asalon@vmware.com>.
25.\" Copyright (c) 2015, 2016, 2018, 2019 The OpenSSL Project.
26.\" All rights reserved.
27.\"
28.\" Redistribution and use in source and binary forms, with or without
29.\" modification, are permitted provided that the following conditions
30.\" are met:
31.\"
32.\" 1. Redistributions of source code must retain the above copyright
33.\" notice, this list of conditions and the following disclaimer.
34.\"
35.\" 2. Redistributions in binary form must reproduce the above copyright
36.\" notice, this list of conditions and the following disclaimer in
37.\" the documentation and/or other materials provided with the
38.\" distribution.
39.\"
40.\" 3. All advertising materials mentioning features or use of this
41.\" software must display the following acknowledgment:
42.\" "This product includes software developed by the OpenSSL Project
43.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
44.\"
45.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
46.\" endorse or promote products derived from this software without
47.\" prior written permission. For written permission, please contact
48.\" openssl-core@openssl.org.
49.\"
50.\" 5. Products derived from this software may not be called "OpenSSL"
51.\" nor may "OpenSSL" appear in their names without prior written
52.\" permission of the OpenSSL Project.
53.\"
54.\" 6. Redistributions of any form whatsoever must retain the following
55.\" acknowledgment:
56.\" "This product includes software developed by the OpenSSL Project
57.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
58.\"
59.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
60.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
62.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
63.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
64.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
65.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
66.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
68.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\"
72.Dd $Mdocdate: March 5 2024 $
73.Dt EVP_MD_CTX_CTRL 3
74.Os
75.Sh NAME
76.Nm EVP_MD_CTX_ctrl ,
77.Nm EVP_MD_CTX_set_flags ,
78.Nm EVP_MD_CTX_clear_flags ,
79.Nm EVP_MD_CTX_test_flags ,
80.Nm EVP_MD_CTX_pkey_ctx ,
81.Nm EVP_MD_CTX_set_pkey_ctx ,
82.Nm EVP_MD_CTX_md_data
83.Nd configure EVP message digest contexts
84.Sh SYNOPSIS
85.In openssl/evp.h
86.Ft int
87.Fo EVP_MD_CTX_ctrl
88.Fa "EVP_MD_CTX *ctx"
89.Fa "int command"
90.Fa "int p1"
91.Fa "void* p2"
92.Fc
93.Ft void
94.Fo EVP_MD_CTX_set_flags
95.Fa "EVP_MD_CTX *ctx"
96.Fa "int flags"
97.Fc
98.Ft void
99.Fo EVP_MD_CTX_clear_flags
100.Fa "EVP_MD_CTX *ctx"
101.Fa "int flags"
102.Fc
103.Ft int
104.Fo EVP_MD_CTX_test_flags
105.Fa "const EVP_MD_CTX *ctx"
106.Fa "int flags"
107.Fc
108.Ft EVP_PKEY_CTX *
109.Fo EVP_MD_CTX_pkey_ctx
110.Fa "const EVP_MD_CTX *ctx"
111.Fc
112.Ft void
113.Fo EVP_MD_CTX_set_pkey_ctx
114.Fa "EVP_MD_CTX *ctx"
115.Fa "EVP_PKEY_CTX *pctx"
116.Fc
117.Ft void *
118.Fo EVP_MD_CTX_md_data
119.Fa "const EVP_MD_CTX *ctx"
120.Fc
121.Sh DESCRIPTION
122.Fn EVP_MD_CTX_ctrl
123performs the digest-specific control
124.Fa command
125with the command-specific arguments
126.Fa p1
127and
128.Fa p2
129on
130.Fa ctx ,
131which needs to already be set up with
132.Xr EVP_DigestInit_ex 3
133before calling this function.
134Other restrictions may apply depending on the control
135.Fa command
136and digest implementation.
137.Pp
138If the
139.Fa command
140is
141.Dv EVP_MD_CTRL_MICALG ,
142.Fa p1
143is ignored and
144.Fa p2
145is an output argument of the type
146.Fa "char **p2" .
147A string specifying the digest Message Integrity Check algorithm
148is allocated and a pointer to this string is returned in
149.Pf * Fa p2 .
150It is the responsibility of the caller to
151.Xr free 3
152.Pf * Fa p2
153when it is no longer needed.
154This
155.Fa command
156is used by
157.Xr SMIME_write_ASN1 3
158when creating S/MIME multipart/signed messages as specified in RFC 3851.
159.Pp
160.Fn EVP_MD_CTX_set_flags
161sets and
162.Fn EVP_MD_CTX_clear_flags
163clears all the flag bits in
164.Fa ctx
165that are set in the
166.Fa flags
167argument.
168.Fn EVP_MD_CTX_test_flags
169tests which of the flag bits that are set in the
170.Fa flags
171argument are also set in
172.Fa ctx .
173Possible flag bits are:
174.Bl -tag -width Ds -offset 2n
175.It Dv EVP_MD_CTX_FLAG_NO_INIT
176Instruct
177.Xr EVP_DigestInit_ex 3
178and functions calling it not to initialise the internal data
179that is specific to the digest method and its implementation.
180.It Dv EVP_MD_CTX_FLAG_ONESHOT
181Instruct the digest to optimize for one update only, if possible.
182For digest algorithms built into the library, this flag usually
183has no effect.
184.El
185.Pp
186.Fn EVP_MD_CTX_pkey_ctx
187returns the
188.Vt EVP_PKEY_CTX
189assigned to
190.Fa ctx .
191The returned pointer should not be freed by the caller.
192.Pp
193.Fn EVP_MD_CTX_set_pkey_ctx
194assigns
195.Fa pctx
196to
197.Fa ctx .
198This is normally used to provide a customized
199.Vt EVP_PKEY_CTX
200to
201.Xr EVP_DigestSignInit 3
202or
203.Xr EVP_DigestVerifyInit 3 .
204The caller retains ownership of the
205.Fa pctx
206passed to this function and is responsible for freeing it
207when it is no longer needed.
208.Pp
209If the
210.Fa ctx
211already contains a
212.Vt EVP_PKEY_CTX
213when this function is called, that old
214.Vt EVP_PKEY_CTX
215is freed if it was created internally, but if it was also installed with
216.Fn EVP_MD_CTX_set_pkey_ctx ,
217the pointer to the old
218.Vt EVP_PKEY_CTX
219is merely replaced by the new pointer and ownership of the old
220.Vt EVP_PKEY_CTX
221remains with the previous caller.
222.Pp
223Passing a
224.Dv NULL
225pointer for the
226.Fa pctx
227argument is also allowed.
228In that case, any
229.Vt EVP_PKEY_CTX
230already assigned to
231.Fa ctx
232is dissociated from it as described above, but no new
233.Vt EVP_PKEY_CTX
234is assigned.
235.Pp
236.Fn EVP_MD_CTX_md_data
237returns the digest method private data of
238.Fa ctx .
239The space is allocated with a size determined at compile time.
240The size is not exposed by an API.
241.Sh RETURN VALUES
242.Fn EVP_MD_CTX_ctrl
243returns 1 for success or 0 for failure.
244.Pp
245.Fn EVP_MD_CTX_test_flags
246returns the bitwise OR of the
247.Fa flags
248argument and the flags set in
249.Fa ctx .
250.Pp
251.Fn EVP_MD_CTX_pkey_ctx
252and
253.Fn EVP_MD_CTX_md_data
254return pointers to storage owned by
255.Fa ctx .
256.Sh SEE ALSO
257.Xr evp 3 ,
258.Xr EVP_DigestInit 3 ,
259.Xr EVP_MD_nid 3
260.Sh HISTORY
261.Fn EVP_MD_CTX_set_flags ,
262.Fn EVP_MD_CTX_clear_flags ,
263and
264.Fn EVP_MD_CTX_test_flags ,
265first appeared in OpenSSL 0.9.7 and have been available since
266.Ox 3.2 .
267.Pp
268.Fn EVP_MD_CTX_ctrl
269first appeared in OpenSSL 1.1.0 and has been available since
270.Ox 5.7 .
271.Pp
272.Fn EVP_MD_CTX_pkey_ctx
273and
274.Fn EVP_MD_CTX_md_data
275first appeared in OpenSSL 1.1.0 and
276.Fn EVP_MD_CTX_set_pkey_ctx
277in OpenSSL 1.1.1.
278These functions have been available since
279.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/EVP_MD_nid.3 b/src/lib/libcrypto/man/EVP_MD_nid.3
deleted file mode 100644
index 15806091de..0000000000
--- a/src/lib/libcrypto/man/EVP_MD_nid.3
+++ /dev/null
@@ -1,315 +0,0 @@
1.\" $OpenBSD: EVP_MD_nid.3,v 1.4 2024/03/05 17:21:40 tb Exp $
2.\" full merge up to: OpenSSL man3/EVP_DigestInit.pod
3.\" 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
23.\" and Antoine Salon <asalon@vmware.com>.
24.\" Copyright (c) 2000, 2012, 2019 The OpenSSL Project.
25.\" All rights reserved.
26.\"
27.\" Redistribution and use in source and binary forms, with or without
28.\" modification, are permitted provided that the following conditions
29.\" are met:
30.\"
31.\" 1. Redistributions of source code must retain the above copyright
32.\" notice, this list of conditions and the following disclaimer.
33.\"
34.\" 2. Redistributions in binary form must reproduce the above copyright
35.\" notice, this list of conditions and the following disclaimer in
36.\" the documentation and/or other materials provided with the
37.\" distribution.
38.\"
39.\" 3. All advertising materials mentioning features or use of this
40.\" software must display the following acknowledgment:
41.\" "This product includes software developed by the OpenSSL Project
42.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
43.\"
44.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
45.\" endorse or promote products derived from this software without
46.\" prior written permission. For written permission, please contact
47.\" openssl-core@openssl.org.
48.\"
49.\" 5. Products derived from this software may not be called "OpenSSL"
50.\" nor may "OpenSSL" appear in their names without prior written
51.\" permission of the OpenSSL Project.
52.\"
53.\" 6. Redistributions of any form whatsoever must retain the following
54.\" acknowledgment:
55.\" "This product includes software developed by the OpenSSL Project
56.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
57.\"
58.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
59.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
62.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
67.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\"
71.Dd $Mdocdate: March 5 2024 $
72.Dt EVP_MD_NID 3
73.Os
74.Sh NAME
75.Nm EVP_MD_nid ,
76.Nm EVP_MD_type ,
77.Nm EVP_MD_CTX_type ,
78.Nm EVP_MD_name ,
79.Nm EVP_MD_size ,
80.Nm EVP_MD_CTX_size ,
81.Nm EVP_MD_block_size ,
82.Nm EVP_MD_CTX_block_size ,
83.Nm EVP_MD_flags ,
84.Nm EVP_MD_pkey_type
85.Nd inspect EVP_MD objects
86.Sh SYNOPSIS
87.In openssl/evp.h
88.Ft int
89.Fo EVP_MD_nid
90.Fa "const EVP_MD *md"
91.Fc
92.Ft int
93.Fo EVP_MD_type
94.Fa "const EVP_MD *md"
95.Fc
96.Ft int
97.Fo EVP_MD_CTX_type
98.Fa "const EVP_MD_CTX *ctx"
99.Fc
100.Ft const char *
101.Fo EVP_MD_name
102.Fa "const EVP_MD *md"
103.Fc
104.Ft int
105.Fo EVP_MD_size
106.Fa "const EVP_MD *md"
107.Fc
108.Ft int
109.Fo EVP_MD_CTX_size
110.Fa "const EVP_MD_CTX *ctx"
111.Fc
112.Ft int
113.Fo EVP_MD_block_size
114.Fa "const EVP_MD *md"
115.Fc
116.Ft int
117.Fo EVP_MD_CTX_block_size
118.Fa "const EVP_MD_CTX *ctx"
119.Fc
120.Ft unsigned long
121.Fo EVP_MD_flags
122.Fa "const EVP_MD *md"
123.Fc
124.Ft int
125.Fo EVP_MD_pkey_type
126.Fa "const EVP_MD *md"
127.Fc
128.Sh DESCRIPTION
129.Fn EVP_MD_nid
130and
131.Fn EVP_MD_type
132are identical and return the numerical identifier (NID) of
133.Fa md .
134The NID is an internal value which may or may not have
135a corresponding ASN.1 OBJECT IDENTIFIER; see
136.Xr OBJ_nid2obj 3
137for details.
138For example ,
139.Fn EVP_MD_type EVP_sha512()
140returns
141.Dv NID_sha512 .
142.Fn EVP_MD_CTX_type
143returns the NID of the message digest algorithm that
144.Fa ctx
145is configured to use.
146These functions are normally used when setting ASN.1 OIDs.
147.Pp
148.Fn EVP_MD_name
149converts the NID of
150.Fa md
151to its short name with
152.Xr OBJ_nid2sn 3 .
153.Pp
154.Fn EVP_MD_size
155returns the size in bytes of the message digests (hashes) produced by
156.Fa md .
157.Fn EVP_MD_CTX_size
158return the size of the hashes produced by the message digest algorithm that
159.Fa ctx
160is configured to use.
161.Pp
162.Fn EVP_MD_block_size
163returns the block size in bytes of
164.Fa md .
165.Fn EVP_MD_CTX_block_size
166returns the block size of the message digest algorithm that
167.Fa ctx
168is configured to use.
169.Pp
170.Fn EVP_MD_flags
171returns the message digest flags used by
172.Fa md .
173Be careful to not confuse these flags with the unrelated
174message digest context flags that can be inspected with
175.Xr EVP_MD_CTX_test_flags 3 .
176The available flags are:
177.Bl -tag -width Ds
178.It Dv EVP_MD_FLAG_DIGALGID_NULL
179The parameters in a
180.Vt DigestAlgorithmIdentifier
181are encoded using an explicit ASN.1
182.Dv NULL
183rather than omitting them.
184This is the default, which means that it takes effect for
185.Vt EVP_MD
186objects that do not have
187.Dv EVP_MD_FLAG_DIGALGID_ABSENT
188set.
189.It Dv EVP_MD_FLAG_DIGALGID_ABSENT
190The parameters in a
191.Vt DigestAlgorithmIdentifier
192are omitted from the ASN.1 encoding.
193This is used by the
194.Vt EVP_MD
195objects documented in the manual page
196.Xr EVP_sha3_224 3
197and by the objects returned from
198.Xr EVP_sha512 3 ,
199.Xr EVP_sha512_256 3 ,
200.Xr EVP_sha512_224 3 ,
201.Xr EVP_sha384 3 ,
202.Xr EVP_sha256 3 ,
203.Xr EVP_sha224 3 ,
204.Xr EVP_sha1 3 ,
205and
206.Xr EVP_sm3 3 .
207.It Dv EVP_MD_FLAG_DIGALGID_CUSTOM
208This flag is reserved for user-defined
209.Vt EVP_MD
210objects supporting custom
211.Vt DigestAlgorithmIdentifier
212handling via
213.Xr EVP_MD_CTX_ctrl 3 ,
214but actually, it is ignored by both LibreSSL and OpenSSL
215and such user-defined behaviour is not supported by the libraries.
216.It Dv EVP_MD_FLAG_FIPS
217Mark the digest method as suitable for FIPS mode.
218This flag is ignored by both LibreSSL and OpenSSL.
219.It Dv EVP_MD_FLAG_ONESHOT
220Intended to indicate that the digest method can only handle one block
221of input, but actually, this flag is ignored by both LibreSSL and OpenSSL.
222.El
223.Pp
224.Fn EVP_MD_pkey_type
225returns the NID of the public key signing algorithm associated with this
226digest.
227For example,
228.Xr EVP_sha512 3
229is associated with RSA, so this returns
230.Dv NID_sha512WithRSAEncryption .
231Since digests and signature algorithms are no longer linked, this
232function is only retained for compatibility reasons.
233.Pp
234.Fn EVP_MD_nid ,
235.Fn EVP_MD_CTX_type ,
236.Fn EVP_MD_name ,
237.Fn EVP_MD_CTX_size ,
238and
239.Fn EVP_MD_CTX_block_size
240are implemented as macros.
241.Sh RETURN VALUES
242.Fn EVP_MD_nid ,
243.Fn EVP_MD_type ,
244.Fn EVP_MD_CTX_type ,
245and
246.Fn EVP_MD_pkey_type
247return the NID of the corresponding OBJECT IDENTIFIER or
248.Dv NID_undef
249if none exists.
250.Pp
251.Fn EVP_MD_name
252returns a pointer to a string
253that is owned by an internal library object or
254.Dv NULL
255if the NID is neither built into the library nor added to the global
256object table by one of the functions documented in the manual page
257.Xr OBJ_create 3 ,
258or if the object does not contain a short name.
259.Pp
260.Fn EVP_MD_size ,
261.Fn EVP_MD_CTX_size ,
262.Fn EVP_MD_block_size ,
263and
264.Fn EVP_MD_CTX_block_size
265return the digest or block size in bytes.
266.Sh SEE ALSO
267.Xr evp 3 ,
268.Xr EVP_DigestInit 3 ,
269.Xr EVP_MD_CTX_ctrl 3 ,
270.Xr OBJ_nid2obj 3
271.Sh STANDARDS
272RFC 5754: Using SHA2 Algorithms with Cryptographic Message Syntax
273.Bl -dash -compact -offset indent
274.It
275section 2: Message Digest Algorithms
276.El
277.Sh HISTORY
278.Fn EVP_MD_size
279first appeared in SSLeay 0.6.6,
280.Fn EVP_MD_CTX_size
281and
282.Fn EVP_MD_CTX_type
283in SSLeay 0.8.0,
284.Fn EVP_MD_type
285and
286.Fn EVP_MD_pkey_type
287in SSLeay 0.8.1, and
288.Fn EVP_MD_block_size
289and
290.Fn EVP_MD_CTX_block_size
291in SSLeay 0.9.0.
292All these functions have been available since
293.Ox 2.4 .
294.Pp
295.Fn EVP_MD_nid
296and
297.Fn EVP_MD_name
298first appeared in OpenSSL 0.9.7 and have been available since
299.Ox 3.2 .
300.Pp
301.Fn EVP_MD_flags
302first appeared in OpenSSL 1.0.0
303and has been available since
304.Ox 4.9 .
305.Sh CAVEATS
306The behaviour of the functions taking an
307.Vt EVP_MD_CTX
308argument is undefined if they are called on a
309.Fa ctx
310that has no message digest configured yet,
311for example one freshly returned from
312.Xr EVP_MD_CTX_new 3 .
313In that case, the program may for example be terminated by a
314.Dv NULL
315pointer access.
diff --git a/src/lib/libcrypto/man/EVP_OpenInit.3 b/src/lib/libcrypto/man/EVP_OpenInit.3
deleted file mode 100644
index fbd0e75571..0000000000
--- a/src/lib/libcrypto/man/EVP_OpenInit.3
+++ /dev/null
@@ -1,157 +0,0 @@
1.\" $OpenBSD: EVP_OpenInit.3,v 1.9 2023/11/16 20:27:43 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 16 2023 $
52.Dt EVP_OPENINIT 3
53.Os
54.Sh NAME
55.Nm EVP_OpenInit ,
56.Nm EVP_OpenUpdate ,
57.Nm EVP_OpenFinal
58.Nd EVP envelope decryption
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft int
62.Fo EVP_OpenInit
63.Fa "EVP_CIPHER_CTX *ctx"
64.Fa "EVP_CIPHER *type"
65.Fa "unsigned char *ek"
66.Fa "int ekl"
67.Fa "unsigned char *iv"
68.Fa "EVP_PKEY *priv"
69.Fc
70.Ft int
71.Fo EVP_OpenUpdate
72.Fa "EVP_CIPHER_CTX *ctx"
73.Fa "unsigned char *out"
74.Fa "int *outl"
75.Fa "unsigned char *in"
76.Fa "int inl"
77.Fc
78.Ft int
79.Fo EVP_OpenFinal
80.Fa "EVP_CIPHER_CTX *ctx"
81.Fa "unsigned char *out"
82.Fa "int *outl"
83.Fc
84.Sh DESCRIPTION
85The EVP envelope routines are a high level interface to envelope
86decryption.
87They decrypt a public key encrypted symmetric key and then decrypt data
88using it.
89.Pp
90.Fn EVP_OpenInit
91initializes a cipher context
92.Fa ctx
93for decryption with cipher
94.Fa type .
95It decrypts the encrypted symmetric key of length
96.Fa ekl
97bytes passed in the
98.Fa ek
99parameter using the private key
100.Fa priv .
101The IV is supplied in the
102.Fa iv
103parameter.
104.Pp
105.Fn EVP_OpenUpdate
106and
107.Fn EVP_OpenFinal
108have exactly the same properties as the
109.Xr EVP_DecryptUpdate 3
110and
111.Xr EVP_DecryptFinal 3
112routines.
113.Pp
114It is possible to call
115.Fn EVP_OpenInit
116twice in the same way as
117.Xr EVP_DecryptInit 3 .
118The first call should have
119.Fa priv
120set to
121.Dv NULL
122and (after setting any cipher parameters) it should be
123called again with
124.Fa type
125set to
126.Dv NULL .
127.Pp
128If the cipher passed in the
129.Fa type
130parameter is a variable length cipher then the key length will be set to
131the value of the recovered key length.
132If the cipher is a fixed length cipher then the recovered key length
133must match the fixed cipher length.
134.Pp
135.Fn EVP_OpenUpdate
136is implemented as a macro.
137.Sh RETURN VALUES
138.Fn EVP_OpenInit
139returns 0 on error or a non-zero integer (actually the recovered secret
140key size) if successful.
141.Pp
142.Fn EVP_OpenUpdate
143returns 1 for success or 0 for failure.
144.Pp
145.Fn EVP_OpenFinal
146returns 0 if the decrypt failed or 1 for success.
147.Sh SEE ALSO
148.Xr evp 3 ,
149.Xr EVP_EncryptInit 3 ,
150.Xr EVP_SealInit 3
151.Sh HISTORY
152.Fn EVP_OpenInit ,
153.Fn EVP_OpenUpdate ,
154and
155.Fn EVP_OpenFinal
156first appeared in SSLeay 0.5.1 and have been available since
157.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/EVP_PKCS82PKEY.3 b/src/lib/libcrypto/man/EVP_PKCS82PKEY.3
deleted file mode 100644
index 30a43b8dca..0000000000
--- a/src/lib/libcrypto/man/EVP_PKCS82PKEY.3
+++ /dev/null
@@ -1,60 +0,0 @@
1.\" $OpenBSD: EVP_PKCS82PKEY.3,v 1.3 2024/03/05 19:21:31 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 5 2024 $
18.Dt EVP_PKCS82PKEY 3
19.Os
20.Sh NAME
21.Nm EVP_PKCS82PKEY ,
22.Nm EVP_PKEY2PKCS8
23.Nd convert between EVP_PKEY and PKCS#8 PrivateKeyInfo
24.Sh SYNOPSIS
25.In openssl/x509.h
26.Ft EVP_PKEY *
27.Fn EVP_PKCS82PKEY "const PKCS8_PRIV_KEY_INFO *keyinfo"
28.Ft PKCS8_PRIV_KEY_INFO *
29.Fn EVP_PKEY2PKCS8 "EVP_PKEY *pkey"
30.Sh DESCRIPTION
31.Fn EVP_PKCS82PKEY
32extracts the private key from a PKCS#8
33.Vt PrivateKeyInfo
34structure.
35.Pp
36.Fn EVP_PKEY2PKCS8
37creates a PKCS#8
38.Vt PrivateKeyInfo
39structure representing the private key contained in
40.Fa pkey .
41.Pp
42Supported algorithms include DH, DSA, EC, and RSA.
43.Sh RETURN VALUES
44These functions return a newly allocated object or
45.Dv NULL
46if the algorithm indicated in
47.Fa keyinfo
48or
49.Fa pkey
50is unsupported or if memory allocation, decoding, or encoding fails.
51.Sh SEE ALSO
52.Xr EVP_PKEY_base_id 3 ,
53.Xr EVP_PKEY_new 3 ,
54.Xr PKCS8_pkey_set0 3 ,
55.Xr PKCS8_PRIV_KEY_INFO_new 3 ,
56.Xr X509_ALGOR_get0 3
57.Sh HISTORY
58These functions first appeared in OpenSSL 0.9.3
59and have been available since
60.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_ctrl.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_ctrl.3
deleted file mode 100644
index 137e576c46..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_ctrl.3
+++ /dev/null
@@ -1,582 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_CTX_ctrl.3,v 1.28 2024/12/10 14:54:20 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" Parts were split out into RSA_pkey_ctx_ctrl(3).
5.\"
6.\" This file is a derived work.
7.\" The changes are covered by the following Copyright and license:
8.\"
9.\" Copyright (c) 2019, 2023, 2024 Ingo Schwarze <schwarze@openbsd.org>
10.\"
11.\" Permission to use, copy, modify, and distribute this software for any
12.\" purpose with or without fee is hereby granted, provided that the above
13.\" copyright notice and this permission notice appear in all copies.
14.\"
15.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22.\"
23.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
24.\" and Antoine Salon <asalon@vmware.com>.
25.\" Copyright (c) 2006, 2009, 2013, 2014, 2015, 2018 The OpenSSL Project.
26.\" All rights reserved.
27.\"
28.\" Redistribution and use in source and binary forms, with or without
29.\" modification, are permitted provided that the following conditions
30.\" are met:
31.\"
32.\" 1. Redistributions of source code must retain the above copyright
33.\" notice, this list of conditions and the following disclaimer.
34.\"
35.\" 2. Redistributions in binary form must reproduce the above copyright
36.\" notice, this list of conditions and the following disclaimer in
37.\" the documentation and/or other materials provided with the
38.\" distribution.
39.\"
40.\" 3. All advertising materials mentioning features or use of this
41.\" software must display the following acknowledgment:
42.\" "This product includes software developed by the OpenSSL Project
43.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
44.\"
45.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
46.\" endorse or promote products derived from this software without
47.\" prior written permission. For written permission, please contact
48.\" openssl-core@openssl.org.
49.\"
50.\" 5. Products derived from this software may not be called "OpenSSL"
51.\" nor may "OpenSSL" appear in their names without prior written
52.\" permission of the OpenSSL Project.
53.\"
54.\" 6. Redistributions of any form whatsoever must retain the following
55.\" acknowledgment:
56.\" "This product includes software developed by the OpenSSL Project
57.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
58.\"
59.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
60.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
62.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
63.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
64.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
65.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
66.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
68.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\"
72.Dd $Mdocdate: December 10 2024 $
73.Dt EVP_PKEY_CTX_CTRL 3
74.Os
75.Sh NAME
76.Nm EVP_PKEY_CTX_ctrl ,
77.Nm EVP_PKEY_CTX_ctrl_str ,
78.Nm EVP_PKEY_CTX_set_signature_md ,
79.Nm EVP_PKEY_CTX_get_signature_md ,
80.Nm EVP_PKEY_CTX_set_dsa_paramgen_bits ,
81.Nm EVP_PKEY_CTX_set_dh_paramgen_prime_len ,
82.Nm EVP_PKEY_CTX_set_dh_paramgen_generator ,
83.Nm EVP_PKEY_CTX_set_ec_paramgen_curve_nid ,
84.Nm EVP_PKEY_CTX_set_ec_param_enc ,
85.Nm EVP_PKEY_CTX_set_ecdh_cofactor_mode ,
86.Nm EVP_PKEY_CTX_get_ecdh_cofactor_mode ,
87.Nm EVP_PKEY_CTX_set_ecdh_kdf_type ,
88.Nm EVP_PKEY_CTX_get_ecdh_kdf_type ,
89.Nm EVP_PKEY_CTX_set_ecdh_kdf_md ,
90.Nm EVP_PKEY_CTX_get_ecdh_kdf_md ,
91.Nm EVP_PKEY_CTX_set_ecdh_kdf_outlen ,
92.Nm EVP_PKEY_CTX_get_ecdh_kdf_outlen ,
93.Nm EVP_PKEY_CTX_set0_ecdh_kdf_ukm ,
94.Nm EVP_PKEY_CTX_get0_ecdh_kdf_ukm ,
95.Nm EVP_PKEY_CTX_set1_id ,
96.Nm EVP_PKEY_CTX_get1_id ,
97.Nm EVP_PKEY_CTX_get1_id_len
98.Nd algorithm specific control operations
99.Sh SYNOPSIS
100.In openssl/evp.h
101.Ft int
102.Fo EVP_PKEY_CTX_ctrl
103.Fa "EVP_PKEY_CTX *ctx"
104.Fa "int keytype"
105.Fa "int optype"
106.Fa "int cmd"
107.Fa "int p1"
108.Fa "void *p2"
109.Fc
110.Ft int
111.Fo EVP_PKEY_CTX_ctrl_str
112.Fa "EVP_PKEY_CTX *ctx"
113.Fa "const char *type"
114.Fa "const char *value"
115.Fc
116.Ft int
117.Fo EVP_PKEY_CTX_set_signature_md
118.Fa "EVP_PKEY_CTX *ctx"
119.Fa "const EVP_MD *md"
120.Fc
121.Ft int
122.Fo EVP_PKEY_CTX_get_signature_md
123.Fa "EVP_PKEY_CTX *ctx"
124.Fa "const EVP_MD **pmd"
125.Fc
126.In openssl/dsa.h
127.Ft int
128.Fo EVP_PKEY_CTX_set_dsa_paramgen_bits
129.Fa "EVP_PKEY_CTX *ctx"
130.Fa "int nbits"
131.Fc
132.In openssl/dh.h
133.Ft int
134.Fo EVP_PKEY_CTX_set_dh_paramgen_prime_len
135.Fa "EVP_PKEY_CTX *ctx"
136.Fa "int len"
137.Fc
138.Ft int
139.Fo EVP_PKEY_CTX_set_dh_paramgen_generator
140.Fa "EVP_PKEY_CTX *ctx"
141.Fa "int gen"
142.Fc
143.In openssl/ec.h
144.Ft int
145.Fo EVP_PKEY_CTX_set_ec_paramgen_curve_nid
146.Fa "EVP_PKEY_CTX *ctx"
147.Fa "int nid"
148.Fc
149.Fa int
150.Fo EVP_PKEY_CTX_set_ec_param_enc
151.Fa "EVP_PKEY_CTX *ctx"
152.Fa "int param_enc"
153.Fc
154.Ft int
155.Fo EVP_PKEY_CTX_set_ecdh_cofactor_mode
156.Fa "EVP_PKEY_CTX *ctx"
157.Fa "int cofactor_mode"
158.Fc
159.Ft int
160.Fo EVP_PKEY_CTX_get_ecdh_cofactor_mode
161.Fa "EVP_PKEY_CTX *ctx"
162.Fc
163.Ft int
164.Fo EVP_PKEY_CTX_set_ecdh_kdf_type
165.Fa "EVP_PKEY_CTX *ctx"
166.Fa "int kdf"
167.Fc
168.Ft int
169.Fo EVP_PKEY_CTX_get_ecdh_kdf_type
170.Fa "EVP_PKEY_CTX *ctx"
171.Fc
172.Ft int
173.Fo EVP_PKEY_CTX_set_ecdh_kdf_md
174.Fa "EVP_PKEY_CTX *ctx"
175.Fa "const EVP_MD *md"
176.Fc
177.Ft int
178.Fo EVP_PKEY_CTX_get_ecdh_kdf_md
179.Fa "EVP_PKEY_CTX *ctx"
180.Fa "const EVP_MD **pmd"
181.Fc
182.Ft int
183.Fo EVP_PKEY_CTX_set_ecdh_kdf_outlen
184.Fa "EVP_PKEY_CTX *ctx"
185.Fa "int len"
186.Fc
187.Ft int
188.Fo EVP_PKEY_CTX_get_ecdh_kdf_outlen
189.Fa "EVP_PKEY_CTX *ctx"
190.Fa "int *plen"
191.Fc
192.Ft int
193.Fo EVP_PKEY_CTX_set0_ecdh_kdf_ukm
194.Fa "EVP_PKEY_CTX *ctx"
195.Fa "unsigned char *ukm"
196.Fa "int len"
197.Fc
198.Ft int
199.Fo EVP_PKEY_CTX_get0_ecdh_kdf_ukm
200.Fa "EVP_PKEY_CTX *ctx"
201.Fa "unsigned char **pukm"
202.Fc
203.Ft int
204.Fo EVP_PKEY_CTX_set1_id
205.Fa "EVP_PKEY_CTX *ctx"
206.Fa "void *id"
207.Fa "size_t id_len"
208.Fc
209.Ft int
210.Fo EVP_PKEY_CTX_get1_id
211.Fa "EVP_PKEY_CTX *ctx"
212.Fa "void *id"
213.Fc
214.Ft int
215.Fo EVP_PKEY_CTX_get1_id_len
216.Fa "EVP_PKEY_CTX *ctx"
217.Fa "size_t *pid_len"
218.Fc
219.Sh DESCRIPTION
220The function
221.Fn EVP_PKEY_CTX_ctrl
222sends a control operation to the context
223.Fa ctx .
224The key type used must match
225.Fa keytype
226if it is not -1.
227The parameter
228.Fa optype
229is a mask indicating which operations the control can be applied to.
230The control command is indicated in
231.Fa cmd
232and any additional arguments in
233.Fa p1
234and
235.Fa p2 .
236.Pp
237Applications will not normally call
238.Fn EVP_PKEY_CTX_ctrl
239directly but will instead call one of the algorithm specific macros
240described below and in
241.Xr RSA_pkey_ctx_ctrl 3 .
242.Pp
243The function
244.Fn EVP_PKEY_CTX_ctrl_str
245allows an application to send an algorithm specific control operation to
246a context
247.Fa ctx
248in string form.
249This is intended to be used for options specified on the command line or
250in text files.
251The commands supported are documented in the
252.Xr openssl 1
253utility command line pages for the option
254.Fl pkeyopt
255which is supported by the
256.Cm pkeyutl ,
257.Cm genpkey ,
258and
259.Cm req
260commands.
261.Pp
262All the remaining "functions" are implemented as macros.
263.Pp
264The
265.Fn EVP_PKEY_CTX_set_signature_md
266and
267.Fn EVP_PKEY_CTX_get_signature_md
268macros set and get the message digest type used in a signature.
269They can be used with the RSA, DSA, and ECDSA algorithms.
270If the key is of the type
271.Dv EVP_PKEY_RSA_PSS
272and has usage restrictions, an error occurs if an attempt is made
273to set the digest to anything other than the restricted value.
274.Pp
275These two macros expand to
276.Fn EVP_PKEY_CTX_ctrl
277with an
278.Fa optype
279of
280.Dv EVP_PKEY_OP_TYPE_SIG
281and the following command arguments:
282.Pp
283.Bl -column -compact EVP_PKEY_CTRL_GET_MD EVP_PKEY_CTX_get_signature_md()
284.It Fa cmd No constant Ta corresponding macro
285.It Dv EVP_PKEY_CTRL_MD Ta Fn EVP_PKEY_CTX_set_signature_md
286.It Dv EVP_PKEY_CTRL_GET_MD Ta Fn EVP_PKEY_CTX_get_signature_md
287.El
288.Ss DSA parameters
289The macro
290.Fn EVP_PKEY_CTX_set_dsa_paramgen_bits
291sets the number of bits used for DSA parameter generation to
292.Fa nbits .
293If not specified, 1024 is used.
294.Ss DH parameters
295The macro
296.Fn EVP_PKEY_CTX_set_dh_paramgen_prime_len
297sets the length of the DH prime parameter
298.Fa len
299for DH parameter generation.
300It only accepts lengths greater than or equal to 256.
301If this macro is not called, then 1024 is used.
302.Pp
303The
304.Fn EVP_PKEY_CTX_set_dh_paramgen_generator
305macro sets DH generator to
306.Fa gen
307for DH parameter generation.
308If not specified, 2 is used.
309.Ss EC parameters
310The
311.Fn EVP_PKEY_CTX_set_ec_paramgen_curve_nid
312macro sets the EC curve for EC parameter generation to
313.Fa nid .
314For EC parameter generation, this macro must be called or an error occurs
315because there is no default curve.
316.Pp
317The
318.Fn EVP_PKEY_CTX_set_ec_param_enc
319macro sets the EC parameter encoding to
320.Fa param_enc
321when generating EC parameters or an EC key.
322The encoding can be set to 0 for explicit parameters or to
323.Dv OPENSSL_EC_NAMED_CURVE
324to use named curve form.
325.Ss ECDH parameters
326The
327.Fn EVP_PKEY_CTX_set_ecdh_cofactor_mode
328macro sets the cofactor mode to
329.Fa cofactor_mode
330for ECDH key derivation.
331Possible values are 1 to enable cofactor key derivation, 0 to disable
332it, or -1 to clear the stored cofactor mode and fall back to the
333private key cofactor mode.
334.Pp
335The
336.Fn EVP_PKEY_CTX_get_ecdh_cofactor_mode
337macro returns the cofactor mode for
338.Fa ctx
339used for ECDH key derivation.
340Possible return values are 1 when cofactor key derivation is enabled
341or 0 otherwise.
342.Ss ECDH key derivation function parameters
343The
344.Fn EVP_PKEY_CTX_set_ecdh_kdf_type
345macro sets the key derivation function type to
346.Fa kdf
347for ECDH key derivation.
348Possible values are
349.Dv EVP_PKEY_ECDH_KDF_NONE
350or
351.Dv EVP_PKEY_ECDH_KDF_X9_63
352which uses the key derivation specified in X9.63.
353When using key derivation, the
354.Fa kdf_md
355and
356.Fa kdf_outlen
357parameters must also be specified.
358.Pp
359The
360.Fn EVP_PKEY_CTX_get_ecdh_kdf_type
361macro returns the key derivation function type for
362.Fa ctx
363used for ECDH key derivation.
364Possible return values are
365.Dv EVP_PKEY_ECDH_KDF_NONE
366or
367.Dv EVP_PKEY_ECDH_KDF_X9_63 .
368.Pp
369The
370.Fn EVP_PKEY_CTX_set_ecdh_kdf_md
371macro sets the key derivation function message digest to
372.Fa md
373for ECDH key derivation.
374Note that X9.63 specifies that this digest should be SHA1,
375but OpenSSL tolerates other digests.
376.Pp
377The
378.Fn EVP_PKEY_CTX_get_ecdh_kdf_md
379macro gets the key derivation function message digest for
380.Fa ctx
381used for ECDH key derivation.
382.Pp
383The
384.Fn EVP_PKEY_CTX_set_ecdh_kdf_outlen
385macro sets the key derivation function output length to
386.Fa len
387for ECDH key derivation.
388.Pp
389The
390.Fn EVP_PKEY_CTX_get_ecdh_kdf_outlen
391macro gets the key derivation function output length for
392.Fa ctx
393used for ECDH key derivation.
394.Pp
395The
396.Fn EVP_PKEY_CTX_set0_ecdh_kdf_ukm
397macro sets the user key material to
398.Fa ukm
399for ECDH key derivation.
400This parameter is optional and corresponds to the shared info
401in X9.63 terms.
402The library takes ownership of the user key material, so the caller
403should not free the original memory pointed to by
404.Fa ukm .
405.Pp
406The
407.Fn EVP_PKEY_CTX_get0_ecdh_kdf_ukm
408macro gets the user key material for
409.Fa ctx .
410The return value is the user key material length.
411The resulting pointer is owned by the library and should not be
412freed by the caller.
413.Ss CMAC parameters
414Application programs normally implement CMAC as described in
415.Xr EVP_PKEY_new_CMAC_key 3
416and do not need the control commands documented here.
417.Pp
418Alternatively, the call to
419.Xr EVP_PKEY_new_CMAC_key 3
420can be replaced as follows,
421leaving the rest of the example code given there unchanged:
422.Pp
423.Bl -enum -width 2n -compact
424.It
425Create an empty
426.Vt EVP_PKEY_CTX
427object by passing the
428.Dv EVP_PKEY_CMAC
429constant to
430.Xr EVP_PKEY_CTX_new_id 3 .
431.It
432Initialize it with
433.Xr EVP_PKEY_keygen_init 3 .
434.It
435Select the block cipher by calling
436.Fn EVP_PKEY_CTX_ctrl
437with an
438.Fa optype
439of
440.Dv EVP_PKEY_OP_KEYGEN ,
441a
442.Fa cmd
443of
444.Dv EVP_PKEY_CTRL_CIPHER ,
445and
446.Fa p2
447pointing to an
448.Vt EVP_CIPHER
449object, which can be obtained from the functions in the CIPHER LISTING in
450.Xr EVP_EncryptInit 3 .
451The
452.Fa p1
453argument is ignored; passing 0 is recommended.
454.It
455Call
456.Fn EVP_PKEY_CTX_ctrl
457again with an
458.Fa optype
459of
460.Dv EVP_PKEY_OP_KEYGEN ,
461a
462.Fa cmd
463of
464.Dv EVP_PKEY_CTRL_SET_MAC_KEY ,
465.Fa p2
466pointing to the symmetric key, and
467.Fa p1
468specifying the length of the symmetric key in bytes.
469.It
470Extract the desired
471.Vt EVP_PKEY
472object using
473.Xr EVP_PKEY_keygen 3 ,
474making sure the
475.Fa ppkey
476argument points to a storage location containing a
477.Dv NULL
478pointer.
479.It
480Proceed with
481.Xr EVP_MD_CTX_new 3 ,
482.Xr EVP_DigestSignInit 3 ,
483and
484.Xr EVP_DigestSign 3
485as usual.
486.El
487.Ss HMAC parameters
488Application programs normally implement HMAC as described in
489.Xr EVP_PKEY_new_raw_private_key 3 .
490While it is possible to instead use
491.Dv EVP_PKEY_CTRL_SET_MAC_KEY
492directly, similar to the above description for CMAC,
493that is strongly discouraged.
494It's essentially what the deprecated function
495.Xr EVP_PKEY_new_mac_key 3
496does internally, and compared to the direct approach with
497.Xr EVP_PKEY_new_raw_private_key 3 ,
498it requires a lot of cumbersome and unnecessary work.
499.Ss Other parameters
500The
501.Fn EVP_PKEY_CTX_set1_id ,
502.Fn EVP_PKEY_CTX_get1_id ,
503and
504.Fn EVP_PKEY_CTX_get1_id_len
505macros manipulate a special identifier field used for some specific
506signature algorithms such as SM2.
507The
508.Fn EVP_PKEY_set1_id
509macro sets the ID to a copy of
510.Fa id
511with the length
512.Fa id_len .
513The caller can safely free the original memory pointed to by
514.Fa id .
515The
516.Fn EVP_PKEY_CTX_get1_id_len
517macro returns the length of the ID set via a previous call to
518.Fn EVP_PKEY_set1_id .
519That length is typically used to allocate memory for a subsequent call to
520.Fn EVP_PKEY_CTX_get1_id ,
521which copies the previously set ID into
522.Pf * Fa id .
523The caller is responsible for allocating sufficient memory for
524.Fa id
525before calling
526.Fn EVP_PKEY_CTX_get1_id .
527.Sh RETURN VALUES
528.Fn EVP_PKEY_CTX_ctrl
529and its macros return a positive value for success and 0 or a negative
530value for failure.
531In particular, a return value of -2 indicates the operation is not
532supported by the public key algorithm.
533.Sh SEE ALSO
534.Xr DH_new 3 ,
535.Xr EVP_DigestInit 3 ,
536.Xr EVP_PKEY_CTX_new 3 ,
537.Xr EVP_PKEY_decrypt 3 ,
538.Xr EVP_PKEY_derive 3 ,
539.Xr EVP_PKEY_encrypt 3 ,
540.Xr EVP_PKEY_get_default_digest_nid 3 ,
541.Xr EVP_PKEY_keygen 3 ,
542.Xr EVP_PKEY_sign 3 ,
543.Xr EVP_PKEY_verify 3 ,
544.Xr EVP_PKEY_verify_recover 3 ,
545.Xr RSA_pkey_ctx_ctrl 3
546.Sh HISTORY
547The functions
548.Fn EVP_PKEY_CTX_ctrl ,
549.Fn EVP_PKEY_CTX_ctrl_str ,
550.Fn EVP_PKEY_CTX_set_signature_md ,
551.Fn EVP_PKEY_CTX_set_dsa_paramgen_bits ,
552.Fn EVP_PKEY_CTX_set_dh_paramgen_prime_len ,
553.Fn EVP_PKEY_CTX_set_dh_paramgen_generator ,
554and
555.Fn EVP_PKEY_CTX_set_ec_paramgen_curve_nid
556first appeared in OpenSSL 1.0.0 and have been available since
557.Ox 4.9 .
558.Pp
559The functions
560.Fn EVP_PKEY_CTX_get_signature_md ,
561.Fn EVP_PKEY_CTX_set_ec_param_enc ,
562.Fn EVP_PKEY_CTX_set_ecdh_cofactor_mode ,
563.Fn EVP_PKEY_CTX_get_ecdh_cofactor_mode ,
564.Fn EVP_PKEY_CTX_set_ecdh_kdf_type ,
565.Fn EVP_PKEY_CTX_get_ecdh_kdf_type ,
566.Fn EVP_PKEY_CTX_set_ecdh_kdf_md ,
567.Fn EVP_PKEY_CTX_get_ecdh_kdf_md ,
568.Fn EVP_PKEY_CTX_set_ecdh_kdf_outlen ,
569.Fn EVP_PKEY_CTX_get_ecdh_kdf_outlen ,
570.Fn EVP_PKEY_CTX_set0_ecdh_kdf_ukm ,
571and
572.Fn EVP_PKEY_CTX_get0_ecdh_kdf_ukm
573first appeared in OpenSSL 1.0.2 and have been available since
574.Ox 6.6 .
575.Pp
576The functions
577.Fn EVP_PKEY_CTX_set1_id ,
578.Fn EVP_PKEY_CTX_get1_id ,
579and
580.Fn EVP_PKEY_CTX_get1_id_len
581first appeared in OpenSSL 1.1.1 and have been available since
582.Ox 6.6 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_get_operation.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_get_operation.3
deleted file mode 100644
index 2482c746d4..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_get_operation.3
+++ /dev/null
@@ -1,137 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_CTX_get_operation.3,v 1.3 2023/09/12 16:15:23 schwarze Exp $
2.\"
3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 12 2023 $
18.Dt EVP_PKEY_CTX_GET_OPERATION 3
19.Os
20.Sh NAME
21.Nm EVP_PKEY_CTX_get_operation ,
22.Nm EVP_PKEY_CTX_get0_pkey
23.Nd inspect EVP_PKEY_CTX objects
24.Sh SYNOPSIS
25.In openssl/evp.h
26.Ft int
27.Fo EVP_PKEY_CTX_get_operation
28.Fa "EVP_PKEY_CTX *ctx"
29.Fc
30.Ft EVP_PKEY *
31.Fo EVP_PKEY_CTX_get0_pkey
32.Fa "EVP_PKEY_CTX *ctx"
33.Fc
34.Sh DESCRIPTION
35.Fn EVP_PKEY_CTX_get_operation
36finds out which initialization function has been called on
37.Fa ctx ,
38if any:
39.Bl -column EVP_PKEY_OP_VERIFYRECO EVP_PKEY_verify_recover_init
40.It return value Ta initialized with Ta e.g. for
41.It Dv EVP_PKEY_OP_DECRYPT Ta Xr EVP_PKEY_decrypt_init 3 Ta RSA, SM2
42.It Dv EVP_PKEY_OP_DERIVE Ta Xr EVP_PKEY_derive_init 3 Ta HKDF
43.It Dv EVP_PKEY_OP_ENCRYPT Ta Xr EVP_PKEY_encrypt_init 3 Ta RSA, SM2
44.It Dv EVP_PKEY_OP_KEYGEN Ta Xr EVP_PKEY_keygen_init 3 Ta almost all
45.It Dv EVP_PKEY_OP_PARAMGEN Ta Xr EVP_PKEY_paramgen_init 3 Ta DH, DSA, EC
46.It Dv EVP_PKEY_OP_SIGN Ta Xr EVP_PKEY_sign_init 3 Ta DSA,EC,RSA,SM2
47.It Dv EVP_PKEY_OP_SIGN Ta Xr EVP_DigestSignInit 3 Ta ED25519
48.It Dv EVP_PKEY_OP_SIGNCTX Ta Xr EVP_DigestSignInit 3 Ta CMAC, HMAC
49.It Dv EVP_PKEY_OP_UNDEFINED Ta not initialized Ta NONE
50.It Dv EVP_PKEY_OP_VERIFY Ta Xr EVP_PKEY_verify_init 3 Ta DSA,EC,RSA,SM2
51.It Dv EVP_PKEY_OP_VERIFY Ta Xr EVP_DigestVerifyInit 3 Ta ED25519
52.It Dv EVP_PKEY_OP_VERIFYCTX Ta Xr EVP_DigestVerifyInit 3 Ta no built-in
53.It Dv EVP_PKEY_OP_VERIFYRECOVER Ta Xr EVP_PKEY_verify_recover_init 3 Ta RSA
54.El
55.Pp
56The rightmost column of the above table shows examples of algorithms
57the return values can occur for.
58For example, if
59.Xr EVP_PKEY_base_id 3
60returns
61.Dv EVP_PKEY_HKDF ,
62then calling
63.Fn EVP_PKEY_CTX_get_operation
64on a
65.Vt EVP_PKEY_CTX
66using that key may return
67.Dv EVP_PKEY_OP_DERIVE .
68.Pp
69If the return value is
70.Dv EVP_PKEY_OP_SIGNCTX
71or
72.Dv EVP_PKEY_OP_VERIFYCTX ,
73the
74.Fa ctx
75supports
76.Xr EVP_DigestSignUpdate 3
77or
78.Xr EVP_DigestVerifyUpdate 3 ,
79respectively.
80If the return value is
81.Dv EVP_PKEY_OP_SIGN
82or
83.Dv EVP_PKEY_OP_VERIFY ,
84if does not, and only one-shot signing or verification is supported.
85.Pp
86The return value
87.Dv EVP_PKEY_OP_UNDEFINED
88can for example occur if the
89.Fa ctx
90was freshly returned from
91.Xr EVP_PKEY_CTX_new 3
92or
93.Xr EVP_PKEY_CTX_new_id 3
94and not yet initialized.
95.Pp
96The following masks are defined as the logical OR of two or more of the above
97.Dv EVP_PKEY_OP_*
98bits:
99.Pp
100.Bl -tag -width EVP_PKEY_OP_TYPE_NOGEN -compact
101.It Dv EVP_PKEY_OP_TYPE_CRYPT
102DECRYPT | ENCRYPT
103.It Dv EVP_PKEY_OP_TYPE_GEN
104KEYGEN | PARAMGEN
105.It Dv EVP_PKEY_OP_TYPE_NOGEN
106CRYPT | DERIVE | SIG
107.It Dv EVP_PKEY_OP_TYPE_SIG
108SIGN | SIGNCTX | VERIFY | VERIFYCTX | VERIFYRECOVER
109.El
110.Sh RETURN VALUES
111.Fn EVP_PKEY_CTX_get_operation
112returns one of the single-bit
113.Dv EVP_PKEY_OP_*
114constants or
115.Dv EVP_PKEY_OP_UNDEFINED
116if
117.Fa ctx
118is not initialized.
119.Pp
120.Fn EVP_PKEY_CTX_get0_pkey
121returns an internal pointer to the
122.Vt EVP_PKEY
123object used by
124.Fa ctx ,
125without incrementing its reference count.
126.Sh SEE ALSO
127.Xr evp 3 ,
128.Xr EVP_PKEY_base_id 3 ,
129.Xr EVP_PKEY_CTX_ctrl 3 ,
130.Xr EVP_PKEY_CTX_new 3 ,
131.Xr EVP_PKEY_new 3
132.Sh HISTORY
133.Fn EVP_PKEY_CTX_get_operation
134and
135.Fn EVP_PKEY_CTX_get0_pkey
136first appeared in OpenSSL 1.0.0 and have been available since
137.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_new.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_new.3
deleted file mode 100644
index e74bce9dfb..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_new.3
+++ /dev/null
@@ -1,183 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_CTX_new.3,v 1.16 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019, 2020 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2006, 2009, 2015 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 6 2024 $
69.Dt EVP_PKEY_CTX_NEW 3
70.Os
71.Sh NAME
72.Nm EVP_PKEY_CTX_new ,
73.Nm EVP_PKEY_CTX_new_id ,
74.Nm EVP_PKEY_CTX_dup ,
75.Nm EVP_PKEY_CTX_free
76.Nd public key algorithm context functions
77.Sh SYNOPSIS
78.In openssl/evp.h
79.Ft EVP_PKEY_CTX *
80.Fo EVP_PKEY_CTX_new
81.Fa "EVP_PKEY *pkey"
82.Fa "ENGINE *engine"
83.Fc
84.Ft EVP_PKEY_CTX *
85.Fo EVP_PKEY_CTX_new_id
86.Fa "int id"
87.Fa "ENGINE *engine"
88.Fc
89.Ft EVP_PKEY_CTX *
90.Fo EVP_PKEY_CTX_dup
91.Fa "EVP_PKEY_CTX *ctx"
92.Fc
93.Ft void
94.Fo EVP_PKEY_CTX_free
95.Fa "EVP_PKEY_CTX *ctx"
96.Fc
97.Sh DESCRIPTION
98The
99.Fn EVP_PKEY_CTX_new
100function allocates a public key algorithm context using the algorithm
101specified in
102.Fa pkey .
103The
104.Fa ENGINE *engine
105argument is always ignored and passing
106.Dv NULL
107is recommended.
108.Pp
109The
110.Fn EVP_PKEY_CTX_new_id
111function allocates a public key algorithm context using the algorithm
112specified by
113.Fa id .
114The
115.Fa ENGINE *engine
116argument is always ignored and passing
117.Dv NULL
118is recommended.
119It is normally used when no
120.Vt EVP_PKEY
121structure is associated with the operations, for example during
122parameter generation of key generation for some algorithms.
123The
124.Fa id
125argument can be any of the constants that
126.Xr EVP_PKEY_base_id 3
127and
128.Xr EVP_PKEY_id 3
129may return.
130.Pp
131.Fn EVP_PKEY_CTX_dup
132duplicates the context
133.Fa ctx .
134.Pp
135.Fn EVP_PKEY_CTX_free
136frees up the context
137.Fa ctx .
138If
139.Fa ctx
140is a
141.Dv NULL
142pointer, no action occurs.
143.Sh RETURN VALUES
144.Fn EVP_PKEY_CTX_new ,
145.Fn EVP_PKEY_CTX_new_id ,
146and
147.Fn EVP_PKEY_CTX_dup
148return either the newly allocated
149.Vt EVP_PKEY_CTX
150structure or
151.Dv NULL
152if an error occurred.
153.Sh SEE ALSO
154.Xr EVP_DigestSignInit 3 ,
155.Xr EVP_DigestVerifyInit 3 ,
156.Xr EVP_PKEY_base_id 3 ,
157.Xr EVP_PKEY_CTX_ctrl 3 ,
158.Xr EVP_PKEY_CTX_get_operation 3 ,
159.Xr EVP_PKEY_CTX_hkdf_mode 3 ,
160.Xr EVP_PKEY_decrypt 3 ,
161.Xr EVP_PKEY_derive 3 ,
162.Xr EVP_PKEY_encrypt 3 ,
163.Xr EVP_PKEY_keygen 3 ,
164.Xr EVP_PKEY_new 3 ,
165.Xr EVP_PKEY_sign 3 ,
166.Xr EVP_PKEY_verify 3 ,
167.Xr EVP_PKEY_verify_recover 3 ,
168.Xr RSA_pkey_ctx_ctrl 3 ,
169.Xr X25519 3
170.Sh HISTORY
171These functions first appeared in OpenSSL 1.0.0
172and have been available since
173.Ox 4.9 .
174.Sh CAVEATS
175The
176.Vt EVP_PKEY_CTX
177structure is an opaque public key algorithm context used by the OpenSSL
178high level public key API.
179Contexts
180.Sy MUST NOT
181be shared between threads.
182It is not permissible to use the same context simultaneously in two
183threads.
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_set_hkdf_md.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_set_hkdf_md.3
deleted file mode 100644
index 973ae95974..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_set_hkdf_md.3
+++ /dev/null
@@ -1,258 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_CTX_set_hkdf_md.3,v 1.4 2024/07/10 07:57:37 tb Exp $
2.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100
3.\"
4.\" This file was written by Alessandro Ghedini <alessandro@ghedini.me>,
5.\" Matt Caswell <matt@openssl.org>, and Viktor Dukhovni <viktor@dukhovni.org>.
6.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: July 10 2024 $
53.Dt EVP_PKEY_CTX_SET_HKDF_MD 3
54.Os
55.Sh NAME
56.Nm EVP_PKEY_CTX_set_hkdf_md ,
57.Nm EVP_PKEY_CTX_set1_hkdf_salt ,
58.Nm EVP_PKEY_CTX_set1_hkdf_key ,
59.Nm EVP_PKEY_CTX_add1_hkdf_info ,
60.Nm EVP_PKEY_CTX_hkdf_mode
61.Nd HMAC-based Extract-and-Expand key derivation algorithm
62.Sh SYNOPSIS
63.In openssl/evp.h
64.In openssl/kdf.h
65.Ft int
66.Fo EVP_PKEY_CTX_hkdf_mode
67.Fa "EVP_PKEY_CTX *pctx"
68.Fa "int mode"
69.Fc
70.Ft int
71.Fo EVP_PKEY_CTX_set_hkdf_md
72.Fa "EVP_PKEY_CTX *pctx"
73.Fa "const EVP_MD *md"
74.Fc
75.Ft int
76.Fo EVP_PKEY_CTX_set1_hkdf_salt
77.Fa "EVP_PKEY_CTX *pctx"
78.Fa "unsigned char *salt"
79.Fa "int saltlen"
80.Fc
81.Ft int
82.Fo EVP_PKEY_CTX_set1_hkdf_key
83.Fa "EVP_PKEY_CTX *pctx"
84.Fa "unsigned char *key"
85.Fa "int keylen"
86.Fc
87.Ft int
88.Fo EVP_PKEY_CTX_add1_hkdf_info
89.Fa "EVP_PKEY_CTX *pctx"
90.Fa "unsigned char *info"
91.Fa "int infolen"
92.Fc
93.Sh DESCRIPTION
94The
95.Dv EVP_PKEY_HKDF
96algorithm implements the HKDF key derivation function.
97HKDF follows the "extract-then-expand" paradigm, where the KDF logically
98consists of two modules.
99The first stage takes the input keying material and "extracts" from it a
100fixed-length pseudorandom key K.
101The second stage "expands" the key K
102into several additional pseudorandom keys (the output of the KDF).
103.Pp
104.Fn EVP_PKEY_CTX_hkdf_mode
105sets the mode for the HKDF operation.
106There are three modes that are currently defined:
107.Bl -tag -width Ds
108.It Dv EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND
109This is the default mode.
110Calling
111.Xr EVP_PKEY_derive 3
112on an
113.Vt EVP_PKEY_CTX
114set up for HKDF will perform an extract followed by
115an expand operation in one go.
116The derived key returned will be the result after the expand operation.
117The intermediate fixed-length pseudorandom key K is not returned.
118.Pp
119In this mode the digest, key, salt and info values must be set before a
120key is derived or an error occurs.
121.It Dv EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY
122In this mode calling
123.Xr EVP_PKEY_derive 3
124will just perform the extract operation.
125The value returned will be the intermediate fixed-length pseudorandom
126key K.
127.Pp
128The digest, key and salt values must be set before a key is derived or
129an error occurs.
130.It Dv EVP_PKEY_HKDEF_MODE_EXPAND_ONLY
131In this mode calling
132.Xr EVP_PKEY_derive 3
133will just perform the expand operation.
134The input key should be set to the intermediate fixed-length
135pseudorandom key K returned from a previous extract operation.
136.Pp
137The digest, key and info values must be set before a key is derived or
138an error occurs.
139.El
140.Pp
141.Fn EVP_PKEY_CTX_set_hkdf_md
142sets the message digest associated with the HKDF.
143.Pp
144.Fn EVP_PKEY_CTX_set1_hkdf_salt
145sets the salt to
146.Fa saltlen
147bytes of the buffer
148.Fa salt .
149Any existing value is replaced.
150.Pp
151.Fn EVP_PKEY_CTX_set1_hkdf_key
152sets the key to
153.Fa keylen
154bytes of the buffer
155.Fa key .
156Any existing value is replaced.
157.Pp
158.Fn EVP_PKEY_CTX_add1_hkdf_info
159sets the info value to
160.Fa infolen
161bytes of the buffer
162.Fa info .
163If a value is already set, it is appended to the existing value.
164.Sh STRING CTRLS
165HKDF also supports string based control operations via
166.Xr EVP_PKEY_CTX_ctrl_str 3 .
167The
168.Fa type
169parameter "md" uses the supplied
170.Fa value
171as the name of the digest algorithm to use.
172The
173.Fa type
174parameter "mode" accepts "EXTRACT_AND_EXPAND", "EXTRACT_ONLY"
175and "EXPAND_ONLY" as
176.Fa value
177to determine the mode to use.
178The
179.Fa type
180parameters "salt", "key" and "info" use the supplied
181.Fa value
182parameter as a
183seed, key, or info.
184The names "hexsalt", "hexkey" and "hexinfo" are similar except they take
185a hex string which is converted to binary.
186.Sh NOTES
187All these functions are implemented as macros.
188.Pp
189A context for HKDF can be obtained by calling:
190.Bd -literal
191 EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL);
192.Ed
193.Pp
194The total length of the info buffer cannot exceed 1024 bytes in length:
195this should be more than enough for any normal use of HKDF.
196.Pp
197The output length of an HKDF expand operation is specified via the
198length parameter to the
199.Xr EVP_PKEY_derive 3
200function.
201Since the HKDF output length is variable, passing a
202.Dv NULL
203buffer as a means to obtain the requisite length is not meaningful with
204HKDF in any mode that performs an expand operation.
205Instead, the caller must allocate a buffer of the desired length, and
206pass that buffer to
207.Xr EVP_PKEY_derive 3
208along with (a pointer initialized to) the desired length.
209Passing a
210.Dv NULL
211buffer to obtain the length is allowed when using
212.Dv EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY .
213.Sh RETURN VALUES
214All these functions return 1 for success and 0 or a negative value for
215failure.
216In particular a return value of -2 indicates the operation is not
217supported by the public key algorithm.
218.Sh EXAMPLES
219This example derives 10 bytes using SHA-256 with the secret key
220"secret", salt value "salt" and info value "label":
221.Bd -literal
222EVP_PKEY_CTX *pctx;
223unsigned char out[10];
224size_t outlen = sizeof(out);
225
226if ((pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL)) == NULL)
227 /* Error */
228
229if (EVP_PKEY_derive_init(pctx) <= 0)
230 /* Error */
231if (EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256()) <= 0)
232 /* Error */
233if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, "salt", 4) <= 0)
234 /* Error */
235if (EVP_PKEY_CTX_set1_hkdf_key(pctx, "secret", 6) <= 0)
236 /* Error */
237if (EVP_PKEY_CTX_add1_hkdf_info(pctx, "label", 5) <= 0)
238 /* Error */
239if (EVP_PKEY_derive(pctx, out, &outlen) <= 0)
240 /* Error */
241.Ed
242.Sh SEE ALSO
243.Xr EVP_PKEY_CTX_ctrl_str 3 ,
244.Xr EVP_PKEY_CTX_new 3 ,
245.Xr EVP_PKEY_derive 3
246.Sh STANDARDS
247RFC 5869: HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
248.Sh HISTORY
249.Fn EVP_PKEY_CTX_set_hkdf_md ,
250.Fn EVP_PKEY_CTX_set1_hkdf_salt ,
251.Fn EVP_PKEY_CTX_set1_hkdf_key ,
252and
253.Fn EVP_PKEY_CTX_add1_hkdf_info
254first appeared in OpenSSL 1.1.0 and
255.Fn EVP_PKEY_CTX_hkdf_mode
256in OpenSSL 1.1.1.
257These functions have been available since
258.Ox 7.2 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_set_tls1_prf_md.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_set_tls1_prf_md.3
deleted file mode 100644
index 1b95bbaa98..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_set_tls1_prf_md.3
+++ /dev/null
@@ -1,171 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_CTX_set_tls1_prf_md.3,v 1.2 2024/07/10 10:22:03 tb Exp $
2.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100
3.\"
4.\" This file was written by Dr Stephen Henson <steve@openssl.org>,
5.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: July 10 2024 $
52.Dt EVP_PKEY_CTX_SET_TLS1_PRF_MD 3
53.Os
54.Sh NAME
55.Nm EVP_PKEY_CTX_set_tls1_prf_md ,
56.Nm EVP_PKEY_CTX_set1_tls1_prf_secret ,
57.Nm EVP_PKEY_CTX_add1_tls1_prf_seed
58.Nd TLS PRF key derivation algorithm
59.Sh SYNOPSIS
60.In openssl/evp.h
61.In openssl/kdf.h
62.Ft int
63.Fo EVP_PKEY_CTX_set_tls1_prf_md
64.Fa "EVP_PKEY_CTX *pctx"
65.Fa "const EVP_MD *md"
66.Fc
67.Ft int
68.Fo EVP_PKEY_CTX_set1_tls1_prf_secret
69.Fa "EVP_PKEY_CTX *pctx"
70.Fa "unsigned char *sec"
71.Fa "int seclen"
72.Fc
73.Ft int
74.Fo EVP_PKEY_CTX_add1_tls1_prf_seed
75.Fa "EVP_PKEY_CTX *pctx"
76.Fa "unsigned char *seed"
77.Fa "int seedlen"
78.Fc
79.Sh DESCRIPTION
80The
81.Dv EVP_PKEY_TLS1_PRF
82algorithm implements the PRF key derivation function for TLS.
83It has no associated private key and only implements key derivation using
84.Xr EVP_PKEY_derive 3 .
85.Pp
86.Fn EVP_PKEY_set_tls1_prf_md
87sets the message digest associated with the TLS PRF.
88.Xr EVP_md5_sha1 3
89is treated as a special case which uses the PRF algorithm using both
90MD5 and SHA1 as used in TLS 1.0 and 1.1.
91.Pp
92.Fn EVP_PKEY_CTX_set_tls1_prf_secret
93sets the secret value of the TLS PRF to
94.Fa seclen
95bytes of the buffer
96.Fa sec .
97Any existing secret value is replaced and any seed is reset.
98.Pp
99.Fn EVP_PKEY_CTX_add1_tls1_prf_seed
100sets the seed to
101.Fa seedlen
102bytes of
103.Fa seed .
104If a seed is already set it is appended to the existing value.
105.Sh STRING CTRLS
106The TLS PRF also supports string based control operations using
107.Xr EVP_PKEY_CTX_ctrl_str 3 .
108The
109.Fa type
110parameter "md" uses the supplied
111.Fa value
112as the name of the digest algorithm to use.
113The
114.Fa type
115parameters "secret" and "seed" use the supplied
116.Fa value
117parameter as a secret or seed value.
118The names "hexsecret" and "hexseed" are similar except they take a hex
119string which is converted to binary.
120.Sh NOTES
121All these functions are implemented as macros.
122.Pp
123A context for the TLS PRF can be obtained by calling:
124.Bd -literal
125 EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
126.Ed
127.Pp
128The digest, secret value and seed must be set before a key is derived or
129an error occurs.
130.Pp
131The total length of all seeds cannot exceed 1024 bytes in length: this
132should be more than enough for any normal use of the TLS PRF.
133.Pp
134The output length of the PRF is specified by the length parameter in the
135.Xr EVP_PKEY_derive 3
136function.
137Since the output length is variable, setting the buffer to
138.Dv NULL
139is not meaningful for the TLS PRF.
140.Sh RETURN VALUES
141All these functions return 1 for success and 0 or a negative value for
142failure.
143In particular a return value of -2 indicates the operation is not
144supported by the public key algorithm.
145.Sh EXAMPLES
146This example derives 10 bytes using SHA-256 with the secret key "secret"
147and seed value "seed":
148.Bd -literal
149 EVP_PKEY_CTX *pctx;
150 unsigned char out[10];
151 size_t outlen = sizeof(out);
152
153 pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
154 if (EVP_PKEY_derive_init(pctx) <= 0)
155 /* Error */
156 if (EVP_PKEY_CTX_set_tls1_prf_md(pctx, EVP_sha256()) <= 0)
157 /* Error */
158 if (EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, "secret", 6) <= 0)
159 /* Error */
160 if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, "seed", 4) <= 0)
161 /* Error */
162 if (EVP_PKEY_derive(pctx, out, &outlen) <= 0)
163 /* Error */
164.Ed
165.Sh SEE ALSO
166.Xr EVP_PKEY_CTX_ctrl_str 3 ,
167.Xr EVP_PKEY_CTX_new 3 ,
168.Xr EVP_PKEY_derive 3
169.Sh HISTORY
170These functions first appeared in OpenSSL 1.1.0 and have been available since
171.Ox 7.6 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 b/src/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3
deleted file mode 100644
index f7810789b6..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3
+++ /dev/null
@@ -1,242 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_asn1_get_count.3,v 1.10 2024/12/06 12:51:13 schwarze Exp $
2.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2020, 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Richard Levitte <levitte@openssl.org>.
22.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 6 2024 $
69.Dt EVP_PKEY_ASN1_GET_COUNT 3
70.Os
71.Sh NAME
72.Nm EVP_PKEY_asn1_get_count ,
73.Nm EVP_PKEY_asn1_get0 ,
74.Nm EVP_PKEY_get0_asn1 ,
75.Nm EVP_PKEY_asn1_find ,
76.Nm EVP_PKEY_asn1_find_str ,
77.Nm EVP_PKEY_asn1_get0_info
78.Nd enumerate public key ASN.1 methods
79.Sh SYNOPSIS
80.In openssl/evp.h
81.Ft int
82.Fn EVP_PKEY_asn1_get_count void
83.Ft const EVP_PKEY_ASN1_METHOD *
84.Fo EVP_PKEY_asn1_get0
85.Fa "int idx"
86.Fc
87.Ft const EVP_PKEY_ASN1_METHOD *
88.Fo EVP_PKEY_get0_asn1
89.Fa "const EVP_PKEY *pkey"
90.Fc
91.Ft const EVP_PKEY_ASN1_METHOD *
92.Fo EVP_PKEY_asn1_find
93.Fa "ENGINE **engine"
94.Fa "int type"
95.Fc
96.Ft const EVP_PKEY_ASN1_METHOD *
97.Fo EVP_PKEY_asn1_find_str
98.Fa "ENGINE **engine"
99.Fa "const char *str"
100.Fa "int len"
101.Fc
102.Ft int
103.Fo EVP_PKEY_asn1_get0_info
104.Fa "int *ppkey_id"
105.Fa "int *pkey_base_id"
106.Fa "int *ppkey_flags"
107.Fa "const char **pinfo"
108.Fa "const char **ppem_str"
109.Fa "const EVP_PKEY_ASN1_METHOD *ameth"
110.Fc
111.Sh DESCRIPTION
112.Fn EVP_PKEY_asn1_get_count
113returns the number of public key ASN.1 methods available.
114.Pp
115.Fn EVP_PKEY_asn1_get0
116returns the public key ASN.1 method
117.Fa idx .
118The value of
119.Fa idx
120must be in the range from zero to
121.Fn EVP_PKEY_asn1_get_count
122\- 1.
123.Pp
124.Fn EVP_PKEY_asn1_find
125looks up the method with NID
126.Fa type ,
127which can be any of the values that
128.Xr EVP_PKEY_base_id 3
129and
130.Xr EVP_PKEY_id 3
131may return.
132If
133.Fa engine
134is not
135.Dv NULL ,
136.Pf * Fa engine
137is set to
138.Dv NULL .
139.Pp
140.Fn EVP_PKEY_asn1_find_str
141looks up the method with the PEM type string given by the first
142.Fa len
143bytes of
144.Fa str .
145If
146.Fa len
147is \-1, the
148.Xr strlen 3
149of
150.Fa str
151is used instead.
152The PEM type strings supported by default are listed in the
153.Xr EVP_PKEY_base_id 3
154manual page.
155Just like
156.Fn EVP_PKEY_asn1_find ,
157if
158.Fa engine
159is not
160.Dv NULL ,
161.Pf * Fa engine
162is set to
163.Dv NULL .
164.Pp
165.Fn EVP_PKEY_asn1_get0_info
166retrieves the public key ID as returned by
167.Xr EVP_PKEY_id 3 ,
168the base public key ID as returned by
169.Xr EVP_PKEY_base_id 3
170.Pq both NIDs ,
171any flags, and internal pointers owned by
172.Fa ameth
173pointing to its method description string and its PEM type string.
174.Pp
175The following flags bits can occur, OR'ed together in
176.Pf * Fa ppkey_flags :
177.Bl -tag -width Ds
178.It Dv ASN1_PKEY_ALIAS
179This
180.Fa ameth
181object serves as an alias for another
182.Vt EVP_PKEY_ASN1_METHOD
183object and will never be returned from
184.Fn EVP_PKEY_asn1_find
185or
186.Fn EVP_PKEY_asn1_find_str .
187.It Dv ASN1_PKEY_DYNAMIC
188This flag is unused.
189It could formerly be used to mark an
190.Fa ameth
191object as dynamically allocated.
192.It Dv ASN1_PKEY_SIGPARAM_NULL
193If the signing
194.Fa ctx
195uses an
196.Vt EVP_PKEY
197private key associated with this
198.Fa ameth ,
199instruct
200.Xr ASN1_item_sign_ctx 3
201to use a parameter type of
202.Dv V_ASN1_NULL
203instead of the default
204.Dv V_ASN1_UNDEF
205when encoding the ASN.1
206.Vt AlgorithmIdentifier
207objects with
208.Xr X509_ALGOR_set0 3 .
209In particular, this is used for
210.Dv EVP_PKEY_RSA .
211.El
212.Sh RETURN VALUES
213.Fn EVP_PKEY_asn1_get_count
214returns the number of available public key methods.
215.Pp
216.Fn EVP_PKEY_asn1_get0
217returns a public key method or
218.Dv NULL
219if
220.Fa idx
221is out of range.
222.Pp
223.Fn EVP_PKEY_get0_asn1
224returns the public key method used by
225.Fa pkey .
226.Pp
227.Fn EVP_PKEY_asn1_find
228and
229.Fn EVP_PKEY_asn1_find_str
230return a matching public key method or
231.Dv NULL
232if no match is found.
233.Pp
234.Fn EVP_PKEY_asn1_get0_info
235returns 1 on success or 0 on failure.
236.Sh SEE ALSO
237.Xr EVP_PKEY_base_id 3 ,
238.Xr EVP_PKEY_new 3
239.Sh HISTORY
240These functions first appeared in OpenSSL 1.0.0
241and have been available since
242.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_cmp.3 b/src/lib/libcrypto/man/EVP_PKEY_cmp.3
deleted file mode 100644
index c12843854d..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_cmp.3
+++ /dev/null
@@ -1,179 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_cmp.3,v 1.15 2024/12/06 12:51:13 schwarze Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2006, 2013, 2014, 2016 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: December 6 2024 $
71.Dt EVP_PKEY_CMP 3
72.Os
73.Sh NAME
74.Nm EVP_PKEY_missing_parameters ,
75.Nm EVP_PKEY_copy_parameters ,
76.Nm EVP_PKEY_cmp_parameters ,
77.Nm EVP_PKEY_cmp
78.\" .Nm EVP_PKEY_save_parameters is intentionally undocumented
79.\" because nothing uses it according to codesearch.debian.net
80.\" and it only affects X509_PUBKEY_set(3) for DSA,
81.\" resulting in incomplete output without the public key parameters.
82.Nd public key parameter and comparison functions
83.Sh SYNOPSIS
84.In openssl/evp.h
85.Ft int
86.Fo EVP_PKEY_missing_parameters
87.Fa "const EVP_PKEY *pkey"
88.Fc
89.Ft int
90.Fo EVP_PKEY_copy_parameters
91.Fa "EVP_PKEY *destination"
92.Fa "const EVP_PKEY *source"
93.Fc
94.Ft int
95.Fo EVP_PKEY_cmp_parameters
96.Fa "const EVP_PKEY *a"
97.Fa "const EVP_PKEY *b"
98.Fc
99.Ft int
100.Fo EVP_PKEY_cmp
101.Fa "const EVP_PKEY *a"
102.Fa "const EVP_PKEY *b"
103.Fc
104.Sh DESCRIPTION
105.Fn EVP_PKEY_missing_parameters
106checks whether any public key parameters are missing from
107.Fa pkey .
108.Pp
109.Fn EVP_PKEY_copy_parameters
110copies all public key parameters from the
111.Fa source
112to the
113.Fa destination .
114If the algorithm does not use parameters, no action occurs.
115.Pp
116.Fn EVP_PKEY_cmp_parameters
117compares the public key parameters of
118.Fa a
119and
120.Fa b .
121This is only supported for algorithms that use parameters.
122.Pp
123.Fn EVP_PKEY_cmp
124compares the public key components of
125.Fa a
126and
127.Fa b .
128If the algorithm uses public key parameters,
129it also compares the parameters.
130.Pp
131The main purpose of the functions
132.Fn EVP_PKEY_missing_parameters
133and
134.Fn EVP_PKEY_copy_parameters
135is to handle public keys in certificates where the parameters are
136sometimes omitted from a public key if they are inherited from the CA
137that signed it.
138.Pp
139Since OpenSSL private keys contain public key components too, the
140function
141.Fn EVP_PKEY_cmp
142can also be used to determine if a private key matches a public key.
143.Sh RETURN VALUES
144.Fn EVP_PKEY_missing_parameters
145returns 1 if the public key parameters of
146.Fa pkey
147are missing or incomplete or 0 if they are present and complete
148or if the algorithm doesn't use parameters.
149.Pp
150.Fn EVP_PKEY_copy_parameters
151returns 1 for success or 0 for failure.
152In particular, it fails if the key types mismatch or if the public
153key parameters in the
154.Fa source
155are missing or incomplete.
156.Pp
157.Fn EVP_PKEY_cmp_parameters
158and
159.Fn EVP_PKEY_cmp
160return 1 if the keys match, 0 if they don't match, -1 if the key types
161are different and -2 if the operation is not supported.
162.Sh SEE ALSO
163.Xr EVP_PKEY_CTX_new 3 ,
164.Xr EVP_PKEY_keygen 3 ,
165.Xr EVP_PKEY_new 3 ,
166.Xr X509_get_pubkey_parameters 3
167.Sh HISTORY
168.Fn EVP_PKEY_missing_parameters
169and
170.Fn EVP_PKEY_copy_parameters
171first appeared in SSLeay 0.8.0.
172.Fn EVP_PKEY_cmp_parameters
173first appeared in SSLeay 0.9.0.
174These functions have been available since
175.Ox 2.4 .
176.Pp
177.Fn EVP_PKEY_cmp
178first appeared in OpenSSL 0.9.8 and has been available since
179.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_decrypt.3 b/src/lib/libcrypto/man/EVP_PKEY_decrypt.3
deleted file mode 100644
index c063847b10..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_decrypt.3
+++ /dev/null
@@ -1,175 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_decrypt.3,v 1.10 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2006, 2009, 2013, 2018 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 6 2024 $
53.Dt EVP_PKEY_DECRYPT 3
54.Os
55.Sh NAME
56.Nm EVP_PKEY_decrypt_init ,
57.Nm EVP_PKEY_decrypt
58.Nd decrypt using a public key algorithm
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft int
62.Fo EVP_PKEY_decrypt_init
63.Fa "EVP_PKEY_CTX *ctx"
64.Fc
65.Ft int
66.Fo EVP_PKEY_decrypt
67.Fa "EVP_PKEY_CTX *ctx"
68.Fa "unsigned char *out"
69.Fa "size_t *outlen"
70.Fa "const unsigned char *in"
71.Fa "size_t inlen"
72.Fc
73.Sh DESCRIPTION
74The
75.Fn EVP_PKEY_decrypt_init
76function initializes a public key algorithm context using key
77.Fa ctx->pkey
78for a decryption operation.
79.Pp
80The
81.Fn EVP_PKEY_decrypt
82function performs a public key decryption operation using
83.Fa ctx .
84The data to be decrypted is specified using the
85.Fa in
86and
87.Fa inlen
88parameters.
89If
90.Fa out
91is
92.Dv NULL
93then the maximum size of the output buffer is written to the
94.Fa outlen
95parameter.
96If
97.Fa out
98is not
99.Dv NULL
100then before the call the
101.Fa outlen
102parameter should contain the length of the
103.Fa out
104buffer.
105If the call is successful, the decrypted data is written to
106.Fa out
107and the amount of data written to
108.Fa outlen .
109.Pp
110After the call to
111.Fn EVP_PKEY_decrypt_init ,
112algorithm specific control operations can be performed to set any
113appropriate parameters for the operation.
114.Pp
115The function
116.Fn EVP_PKEY_decrypt
117can be called more than once on the same context if several operations
118are performed using the same parameters.
119.Sh RETURN VALUES
120.Fn EVP_PKEY_decrypt_init
121and
122.Fn EVP_PKEY_decrypt
123return 1 for success and 0 or a negative value for failure.
124In particular, a return value of -2 indicates the operation is not
125supported by the public key algorithm.
126.Sh EXAMPLES
127Decrypt data using OAEP (for RSA keys):
128.Bd -literal -offset indent
129#include <openssl/evp.h>
130#include <openssl/rsa.h>
131
132EVP_PKEY_CTX *ctx;
133unsigned char *out, *in;
134size_t outlen, inlen;
135EVP_PKEY *key;
136
137/*
138 * Assumes that key, in, and inlen are already set up
139 * and that key is an RSA private key.
140 */
141ctx = EVP_PKEY_CTX_new(key, NULL);
142if (!ctx)
143 /* Error occurred */
144if (EVP_PKEY_decrypt_init(ctx) <= 0)
145 /* Error */
146if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING) <= 0)
147 /* Error */
148
149/* Determine buffer length */
150if (EVP_PKEY_decrypt(ctx, NULL, &outlen, in, inlen) <= 0)
151 /* Error */
152
153out = malloc(outlen);
154
155if (!out)
156 /* malloc failure */
157
158if (EVP_PKEY_decrypt(ctx, out, &outlen, in, inlen) <= 0)
159 /* Error */
160
161/* Decrypted data is outlen bytes written to buffer out */
162.Ed
163.Sh SEE ALSO
164.Xr EVP_PKEY_CTX_new 3 ,
165.Xr EVP_PKEY_derive 3 ,
166.Xr EVP_PKEY_encrypt 3 ,
167.Xr EVP_PKEY_sign 3 ,
168.Xr EVP_PKEY_verify 3 ,
169.Xr EVP_PKEY_verify_recover 3
170.Sh HISTORY
171.Fn EVP_PKEY_decrypt_init
172and
173.Fn EVP_PKEY_decrypt
174first appeared in OpenSSL 1.0.0 and have been available since
175.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_derive.3 b/src/lib/libcrypto/man/EVP_PKEY_derive.3
deleted file mode 100644
index 47f467fea1..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_derive.3
+++ /dev/null
@@ -1,254 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_derive.3,v 1.12 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2006, 2009, 2013, 2018 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: December 6 2024 $
70.Dt EVP_PKEY_DERIVE 3
71.Os
72.Sh NAME
73.Nm EVP_PKEY_derive_init ,
74.Nm EVP_PKEY_derive_set_peer ,
75.Nm EVP_PKEY_CTX_get0_peerkey ,
76.Nm EVP_PKEY_derive
77.Nd derive public key algorithm shared secret
78.Sh SYNOPSIS
79.In openssl/evp.h
80.Ft int
81.Fo EVP_PKEY_derive_init
82.Fa "EVP_PKEY_CTX *ctx"
83.Fc
84.Ft int
85.Fo EVP_PKEY_derive_set_peer
86.Fa "EVP_PKEY_CTX *ctx"
87.Fa "EVP_PKEY *peerkey"
88.Fc
89.Ft EVP_PKEY *
90.Fo EVP_PKEY_CTX_get0_peerkey
91.Fa "EVP_PKEY_CTX *ctx"
92.Fc
93.Ft int
94.Fo EVP_PKEY_derive
95.Fa "EVP_PKEY_CTX *ctx"
96.Fa "unsigned char *key"
97.Fa "size_t *keylen"
98.Fc
99.Sh DESCRIPTION
100.Fn EVP_PKEY_derive_init
101initializes the public key algorithm context
102.Fa ctx
103for shared secret derivation using the
104.Vt EVP_PKEY
105object already stored in
106.Fa ctx .
107The library provides built-in support for keys with an
108.Xr EVP_PKEY_base_id 3
109of
110.Dv EVP_PKEY_DH ,
111.Dv EVP_PKEY_EC ,
112.Dv EVP_PKEY_HKDF ,
113and
114.Dv EVP_PKEY_X25519 .
115.Pp
116After the call to
117.Fn EVP_PKEY_derive_init ,
118algorithm specific control operations can optionally be performed
119to set any appropriate parameters for the operation.
120.Pp
121.Fn EVP_PKEY_derive_set_peer
122configures the
123.Fa ctx ,
124which already needs to be initialized with
125.Fn EVP_PKEY_derive_init ,
126.Xr EVP_PKEY_encrypt_init 3 ,
127or
128.Xr EVP_PKEY_decrypt_init 3 ,
129to use the
130.Fa peerkey ,
131which is normally a public key.
132In case of success, the reference count of the
133.Fa peerkey
134is incremented by one.
135Consequently, the caller needs to call
136.Xr EVP_PKEY_free 3
137on the
138.Fa peerkey
139when the caller no longer needs it, even if it is still in use by
140.Fa ctx .
141.Pp
142.Fn EVP_PKEY_derive
143derives a shared secret using
144.Fa ctx .
145If
146.Fa key
147is
148.Dv NULL ,
149then the maximum size of the output buffer is written to the
150.Fa keylen
151parameter.
152If
153.Fa key
154is not
155.Dv NULL
156then before the call the
157.Fa keylen
158parameter should contain the length of the
159.Fa key
160buffer.
161If the call is successful, the shared secret is written to
162.Fa key
163and the amount of data written to
164.Fa keylen .
165.Pp
166The function
167.Fn EVP_PKEY_derive
168can be called more than once on the same context if several operations
169are performed using the same parameters.
170.Sh RETURN VALUES
171.Fn EVP_PKEY_derive_init ,
172.Fn EVP_PKEY_derive_set_peer ,
173and
174.Fn EVP_PKEY_derive
175return 1 for success and 0 or a negative value for failure.
176In particular, a return value of \-2 indicates the operation is not
177supported by the public key algorithm.
178.Pp
179For
180.Fn EVP_PKEY_derive_set_peer ,
181a return value of \-1 can for example occur if
182.Fa ctx
183is not properly initialized, does not contain an
184.Vt EVP_PKEY
185that can be retrieved with
186.Xr EVP_PKEY_CTX_get0_pkey 3 ,
187the
188.Xr EVP_PKEY_id 3
189of both keys mismatch, or
190.Xr EVP_PKEY_cmp_parameters 3
191reports mismatching key parameters.
192.Pp
193.Fn EVP_PKEY_derive
194fails with a return value of \-1 for example if
195.Fa ctx
196has not been successfully initialized with
197.Fn EVP_PKEY_derive_init .
198.Pp
199.Fn EVP_PKEY_CTX_get0_peerkey
200returns an internal pointer to the
201.Fa peerkey
202used by
203.Fa ctx
204without incrementing its reference count.
205.Sh EXAMPLES
206Derive shared secret (for example DH or EC keys):
207.Bd -literal -offset indent
208#include <openssl/evp.h>
209#include <openssl/rsa.h>
210
211EVP_PKEY_CTX *ctx;
212unsigned char *skey;
213size_t skeylen;
214EVP_PKEY *pkey, *peerkey;
215
216/* Assumes that pkey and peerkey have already been set up. */
217ctx = EVP_PKEY_CTX_new(pkey, NULL);
218if (!ctx)
219 /* Error occurred */
220if (EVP_PKEY_derive_init(ctx) <= 0)
221 /* Error */
222if (EVP_PKEY_derive_set_peer(ctx, peerkey) <= 0)
223 /* Error */
224
225/* Determine buffer length */
226if (EVP_PKEY_derive(ctx, NULL, &skeylen) <= 0)
227 /* Error */
228
229skey = malloc(skeylen);
230
231if (!skey)
232 /* malloc failure */
233
234if (EVP_PKEY_derive(ctx, skey, &skeylen) <= 0)
235 /* Error */
236
237/* Shared secret is skey bytes written to buffer skey */
238.Ed
239.Sh SEE ALSO
240.Xr EVP_PKEY_CTX_new 3 ,
241.Xr EVP_PKEY_decrypt 3 ,
242.Xr EVP_PKEY_encrypt 3 ,
243.Xr EVP_PKEY_sign 3 ,
244.Xr EVP_PKEY_verify 3 ,
245.Xr EVP_PKEY_verify_recover 3 ,
246.Xr X25519 3
247.Sh HISTORY
248.Fn EVP_PKEY_derive_init ,
249.Fn EVP_PKEY_derive_set_peer ,
250.Fn EVP_PKEY_CTX_get0_peerkey ,
251and
252.Fn EVP_PKEY_derive
253first appeared in OpenSSL 1.0.0 and have been available since
254.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_encrypt.3 b/src/lib/libcrypto/man/EVP_PKEY_encrypt.3
deleted file mode 100644
index c2e70cb31f..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_encrypt.3
+++ /dev/null
@@ -1,183 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_encrypt.3,v 1.10 2024/12/06 14:27:49 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2006, 2009, 2013, 2014, 2016 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 6 2024 $
53.Dt EVP_PKEY_ENCRYPT 3
54.Os
55.Sh NAME
56.Nm EVP_PKEY_encrypt_init ,
57.Nm EVP_PKEY_encrypt
58.Nd encrypt using a public key algorithm
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft int
62.Fo EVP_PKEY_encrypt_init
63.Fa "EVP_PKEY_CTX *ctx"
64.Fc
65.Ft int
66.Fo EVP_PKEY_encrypt
67.Fa "EVP_PKEY_CTX *ctx"
68.Fa "unsigned char *out"
69.Fa "size_t *outlen"
70.Fa "const unsigned char *in"
71.Fa "size_t inlen"
72.Fc
73.Sh DESCRIPTION
74The
75.Fn EVP_PKEY_encrypt_init
76function initializes a public key algorithm context using key
77.Fa ctx->pkey
78for an encryption operation.
79.Pp
80The
81.Fn EVP_PKEY_encrypt
82function performs a public key encryption operation using
83.Fa ctx .
84The data to be encrypted is specified using the
85.Fa in
86and
87.Fa inlen
88parameters.
89If
90.Fa out
91is
92.Dv NULL ,
93then the maximum size of the output buffer is written to the
94.Fa outlen
95parameter.
96If
97.Fa out
98is not
99.Dv NULL ,
100then before the call the
101.Fa outlen
102parameter should contain the length of the
103.Fa out
104buffer.
105If the call is successful, the encrypted data is written to
106.Fa out
107and the amount of data written to
108.Fa outlen .
109.Pp
110After the call to
111.Fn EVP_PKEY_encrypt_init ,
112algorithm specific control operations can be performed to set any
113appropriate parameters for the operation.
114.Pp
115The function
116.Fn EVP_PKEY_encrypt
117can be called more than once on the same context if several operations
118are performed using the same parameters.
119.Sh RETURN VALUES
120.Fn EVP_PKEY_encrypt_init
121and
122.Fn EVP_PKEY_encrypt
123return 1 for success and 0 or a negative value for failure.
124In particular, a return value of -2 indicates the operation is not
125supported by the public key algorithm.
126.Sh EXAMPLES
127Encrypt data using OAEP (for RSA keys).
128See also
129.Xr PEM_read_PUBKEY 3
130and
131.Xr d2i_X509 3
132for means to load a public key.
133You may also simply set
134.Dq eng
135to
136.Dv NULL
137to start with the default OpenSSL RSA implementation:
138.Bd -literal -offset indent
139#include <openssl/evp.h>
140#include <openssl/rsa.h>
141
142EVP_PKEY_CTX *ctx;
143unsigned char *out, *in;
144size_t outlen, inlen;
145EVP_PKEY *key;
146/* NB: assumes that key, in, inlen are already set up
147 * and that key is an RSA public key
148 */
149ctx = EVP_PKEY_CTX_new(key, NULL);
150if (!ctx)
151 /* Error occurred */
152if (EVP_PKEY_encrypt_init(ctx) <= 0)
153 /* Error */
154if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING) <= 0)
155 /* Error */
156
157/* Determine buffer length */
158if (EVP_PKEY_encrypt(ctx, NULL, &outlen, in, inlen) <= 0)
159 /* Error */
160
161out = malloc(outlen);
162
163if (!out)
164 /* malloc failure */
165
166if (EVP_PKEY_encrypt(ctx, out, &outlen, in, inlen) <= 0)
167 /* Error */
168
169/* Encrypted data is outlen bytes written to buffer out */
170.Ed
171.Sh SEE ALSO
172.Xr EVP_PKEY_CTX_new 3 ,
173.Xr EVP_PKEY_decrypt 3 ,
174.Xr EVP_PKEY_derive 3 ,
175.Xr EVP_PKEY_sign 3 ,
176.Xr EVP_PKEY_verify 3 ,
177.Xr EVP_PKEY_verify_recover 3
178.Sh HISTORY
179.Fn EVP_PKEY_encrypt_init
180and
181.Fn EVP_PKEY_encrypt
182first appeared in OpenSSL 1.0.0 and have been available since
183.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.3 b/src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.3
deleted file mode 100644
index e9ff7c4609..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.3
+++ /dev/null
@@ -1,128 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_get_default_digest_nid.3,v 1.10 2024/12/06 12:51:13 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2006, 2009, 2013, 2018 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: December 6 2024 $
70.Dt EVP_PKEY_GET_DEFAULT_DIGEST_NID 3
71.Os
72.Sh NAME
73.Nm EVP_PKEY_get_default_digest_nid
74.Nd get default signature digest
75.Sh SYNOPSIS
76.In openssl/evp.h
77.Ft int
78.Fo EVP_PKEY_get_default_digest_nid
79.Fa "EVP_PKEY *pkey"
80.Fa "int *pnid"
81.Fc
82.Sh DESCRIPTION
83The
84.Fn EVP_PKEY_get_default_digest_nid
85function sets
86.Pf * Fa pnid
87to the default message digest NID for the public key signature
88operations associated with
89.Fa pkey .
90.Pp
91Some signature algorithms, for example
92.Dv EVP_PKEY_ED25519 ,
93do not use a digest during signing.
94In this case,
95.Pf * Fa pnid
96is set to
97.Dv NID_undef .
98.Pp
99Support for the following public key algorithms is built into the library:
100.Pp
101.Bl -column -compact EVP_PKEY_base_id(3) NID_sha256 mandatory
102.It Xr EVP_PKEY_base_id 3 Ta Pf * Fa pnid Ta return value
103.It Dv EVP_PKEY_DSA Ta Dv NID_sha1 Ta mandatory
104.It Dv EVP_PKEY_EC Ta Dv NID_sha1 Ta mandatory
105.It Dv EVP_PKEY_ED25519 Ta Dv NID_undef Ta mandatory
106.It Dv EVP_PKEY_HMAC Ta Dv NID_sha1 Ta advisory
107.It Dv EVP_PKEY_RSA Ta Dv NID_sha256 Ta advisory
108.El
109.Sh RETURN VALUES
110The
111.Fn EVP_PKEY_get_default_digest_nid
112function returns 1 if the message digest is advisory (that is other
113digests can be used) and 2 if it is mandatory (other digests cannot be
114used).
115It returns 0 or a negative value for failure.
116In particular, a return value of -2 indicates the operation is not
117supported by the public key algorithm.
118.Sh SEE ALSO
119.Xr EVP_PKEY_CTX_ctrl 3 ,
120.Xr EVP_PKEY_CTX_new 3 ,
121.Xr EVP_PKEY_new 3 ,
122.Xr EVP_PKEY_sign 3 ,
123.Xr EVP_PKEY_verify 3 ,
124.Xr EVP_PKEY_verify_recover 3
125.Sh HISTORY
126.Fn EVP_PKEY_get_default_digest_nid
127first appeared in OpenSSL 1.0.0 and has been available since
128.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_keygen.3 b/src/lib/libcrypto/man/EVP_PKEY_keygen.3
deleted file mode 100644
index e75859b486..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_keygen.3
+++ /dev/null
@@ -1,369 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_keygen.3,v 1.15 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023, 2024 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2006, 2009, 2013, 2015, 2016, 2018 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: December 6 2024 $
70.Dt EVP_PKEY_KEYGEN 3
71.Os
72.Sh NAME
73.Nm EVP_PKEY_keygen_init ,
74.Nm EVP_PKEY_keygen ,
75.Nm EVP_PKEY_paramgen_init ,
76.Nm EVP_PKEY_paramgen ,
77.Nm EVP_PKEY_gen_cb ,
78.Nm EVP_PKEY_CTX_set_cb ,
79.Nm EVP_PKEY_CTX_get_cb ,
80.Nm EVP_PKEY_CTX_set0_keygen_info ,
81.Nm EVP_PKEY_CTX_get_keygen_info ,
82.Nm EVP_PKEY_CTX_set_app_data ,
83.Nm EVP_PKEY_CTX_get_app_data ,
84.Nm EVP_PKEY_CTX_set_data ,
85.Nm EVP_PKEY_CTX_get_data
86.Nd key and parameter generation functions
87.Sh SYNOPSIS
88.In openssl/evp.h
89.Ft int
90.Fo EVP_PKEY_keygen_init
91.Fa "EVP_PKEY_CTX *ctx"
92.Fc
93.Ft int
94.Fo EVP_PKEY_keygen
95.Fa "EVP_PKEY_CTX *ctx"
96.Fa "EVP_PKEY **ppkey"
97.Fc
98.Ft int
99.Fo EVP_PKEY_paramgen_init
100.Fa "EVP_PKEY_CTX *ctx"
101.Fc
102.Ft int
103.Fo EVP_PKEY_paramgen
104.Fa "EVP_PKEY_CTX *ctx"
105.Fa "EVP_PKEY **ppkey"
106.Fc
107.Ft typedef int
108.Fo EVP_PKEY_gen_cb
109.Fa "EVP_PKEY_CTX *ctx"
110.Fc
111.Ft void
112.Fo EVP_PKEY_CTX_set_cb
113.Fa "EVP_PKEY_CTX *ctx"
114.Fa "EVP_PKEY_gen_cb *cb"
115.Fc
116.Ft EVP_PKEY_gen_cb *
117.Fo EVP_PKEY_CTX_get_cb
118.Fa "EVP_PKEY_CTX *ctx"
119.Fc
120.Ft void
121.Fo EVP_PKEY_CTX_set0_keygen_info
122.Fa "EVP_PKEY_CTX *ctx"
123.Fa "int *dat"
124.Fa "int datlen"
125.Fc
126.Ft int
127.Fo EVP_PKEY_CTX_get_keygen_info
128.Fa "EVP_PKEY_CTX *ctx"
129.Fa "int idx"
130.Fc
131.Ft void
132.Fo EVP_PKEY_CTX_set_app_data
133.Fa "EVP_PKEY_CTX *ctx"
134.Fa "void *app_data"
135.Fc
136.Ft void *
137.Fo EVP_PKEY_CTX_get_app_data
138.Fa "EVP_PKEY_CTX *ctx"
139.Fc
140.Ft void
141.Fo EVP_PKEY_CTX_set_data
142.Fa "EVP_PKEY_CTX *ctx"
143.Fa "void *data"
144.Fc
145.Ft void *
146.Fo EVP_PKEY_CTX_get_data
147.Fa "EVP_PKEY_CTX *ctx"
148.Fc
149.Sh DESCRIPTION
150The
151.Fn EVP_PKEY_keygen_init
152function initializes a public key algorithm context using key
153.Fa ctx->pkey
154for a key generation operation.
155.Pp
156The
157.Fn EVP_PKEY_keygen
158function performs a key generation operation.
159The generated key is written to
160.Fa ppkey .
161.Pp
162The functions
163.Fn EVP_PKEY_paramgen_init
164and
165.Fn EVP_PKEY_paramgen
166are similar except parameters are generated.
167.Pp
168The functions
169.Fn EVP_PKEY_CTX_set_cb
170and
171.Fn EVP_PKEY_CTX_get_cb
172set and retrieve the key or parameter generation callback, respectively.
173.Pp
174The function
175.Fn EVP_PKEY_CTX_set0_keygen_info
176sets the parameters associated with the generation operation to the array
177.Fa dat
178containing
179.Ft datlen
180integer parameters.
181The caller retains ownership of the
182.Fa dat
183array; it will never be freed by the library.
184.Pp
185The function
186.Fn EVP_PKEY_CTX_get_keygen_info
187returns parameters associated with the generation operation.
188If
189.Fa idx
190is -1, the total number of parameters available is returned.
191Any non-negative value returns the value of that parameter.
192.Fn EVP_PKEY_CTX_get_keygen_info
193with a non-negative value for
194.Fa idx
195should only be called within the generation callback.
196.Pp
197If the callback returns 0, then the key generation operation is aborted
198and an error occurs.
199This might occur during a time consuming operation where a user clicks
200on a "cancel" button.
201.Pp
202The functions
203.Fn EVP_PKEY_CTX_set_app_data
204and
205.Fn EVP_PKEY_CTX_get_app_data
206set and retrieve an opaque pointer.
207This can be used to set some application defined value which can be
208retrieved in the callback: for example a handle which is used to update
209a "progress dialog".
210.Pp
211The deprecated functions
212.Fn EVP_PKEY_CTX_set_data
213and
214.Fn EVP_PKEY_CTX_get_data
215set and retrieve a
216.Em different
217opaque pointer that is ignored by the library.
218.Pp
219After the call to
220.Fn EVP_PKEY_keygen_init
221or
222.Fn EVP_PKEY_paramgen_init ,
223algorithm specific control operations can be performed to set any
224appropriate parameters for the operation.
225.Pp
226The functions
227.Fn EVP_PKEY_keygen
228and
229.Fn EVP_PKEY_paramgen
230can be called more than once on the same context if several operations
231are performed using the same parameters.
232.Pp
233The meaning of the parameters passed to the callback will depend on the
234algorithm and the specific implementation of the algorithm.
235Some might not give any useful information at all during key or
236parameter generation.
237Others might not even call the callback.
238.Pp
239The operation performed by key or parameter generation depends on the
240algorithm used.
241In some cases (e.g. EC with a supplied named curve) the "generation"
242option merely sets the appropriate fields in an
243.Vt EVP_PKEY
244structure.
245.Pp
246In OpenSSL, an
247.Vt EVP_PKEY
248structure containing a private key also contains the public key
249components and parameters (if any).
250An OpenSSL private key is equivalent to what some libraries call a "key
251pair".
252A private key can be used in functions which require the use of a public
253key or parameters.
254.Sh RETURN VALUES
255.Fn EVP_PKEY_keygen_init ,
256.Fn EVP_PKEY_paramgen_init ,
257.Fn EVP_PKEY_keygen ,
258and
259.Fn EVP_PKEY_paramgen
260return 1 for success and 0 or a negative value for failure.
261In particular, a return value of -2 indicates the operation is not
262supported by the public key algorithm.
263.Pp
264Callback functions of the type
265.Fn EVP_PKEY_gen_cb
266are supposed to return 1 on success or 0 on error.
267.Pp
268.Fn EVP_PKEY_CTX_get_cb
269returns a function pointer to the currently installed callback function or
270.Dv NULL
271if no callback function is installed.
272.Pp
273.Fn EVP_PKEY_CTX_get_keygen_info
274returns the number of available parameters if
275.Fa idx
276is \-1, one of these parameters if
277.Fa idx
278is greater than or equal to zero but less than the number
279of available parameters, or 0 otherwise.
280.Pp
281.Fn EVP_PKEY_CTX_get_app_data
282and
283.Fn EVP_PKEY_CTX_get_data
284return the pointer that was last passed to the corresponding set function, or
285.Dv NULL
286if the corresponding set function was never called on
287.Fa ctx .
288.Sh EXAMPLES
289Generate a 2048-bit RSA key:
290.Bd -literal -offset indent
291#include <openssl/evp.h>
292#include <openssl/rsa.h>
293
294EVP_PKEY_CTX *ctx;
295EVP_PKEY *pkey = NULL;
296
297ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL);
298if (!ctx)
299 /* Error occurred */
300if (EVP_PKEY_keygen_init(ctx) <= 0)
301 /* Error */
302if (EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, 2048) <= 0)
303 /* Error */
304
305/* Generate key */
306if (EVP_PKEY_keygen(ctx, &pkey) <= 0)
307 /* Error */
308.Ed
309.Pp
310Generate a key from a set of parameters:
311.Bd -literal -offset indent
312#include <openssl/evp.h>
313#include <openssl/rsa.h>
314
315EVP_PKEY_CTX *ctx;
316EVP_PKEY *pkey = NULL, *param;
317
318/* Assumes that param is already set up. */
319ctx = EVP_PKEY_CTX_new(param, NULL);
320if (!ctx)
321 /* Error occurred */
322if (EVP_PKEY_keygen_init(ctx) <= 0)
323 /* Error */
324
325/* Generate key */
326if (EVP_PKEY_keygen(ctx, &pkey) <= 0)
327 /* Error */
328.Ed
329.Pp
330Example of generation callback for OpenSSL public key implementations:
331.Bd -literal -offset indent
332/* Application data is a BIO to output status to */
333
334EVP_PKEY_CTX_set_app_data(ctx, status_bio);
335
336static int
337genpkey_cb(EVP_PKEY_CTX *ctx)
338{
339 char c = '*';
340 BIO *b = EVP_PKEY_CTX_get_app_data(ctx);
341 int p;
342
343 p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);
344 if (p == 0)
345 c = '.';
346 if (p == 1)
347 c = '+';
348 if (p == 2)
349 c = '*';
350 if (p == 3)
351 c = '\en';
352 BIO_write(b, &c, 1);
353 (void)BIO_flush(b);
354 return 1;
355}
356.Ed
357.Sh SEE ALSO
358.Xr EVP_PKEY_CTX_new 3 ,
359.Xr EVP_PKEY_decrypt 3 ,
360.Xr EVP_PKEY_derive 3 ,
361.Xr EVP_PKEY_encrypt 3 ,
362.Xr EVP_PKEY_sign 3 ,
363.Xr EVP_PKEY_verify 3 ,
364.Xr EVP_PKEY_verify_recover 3 ,
365.Xr X25519 3
366.Sh HISTORY
367These functions first appeared in OpenSSL 1.0.0
368and have been available since
369.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_new.3 b/src/lib/libcrypto/man/EVP_PKEY_new.3
deleted file mode 100644
index 3b1ef029c3..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_new.3
+++ /dev/null
@@ -1,347 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_new.3,v 1.26 2024/12/10 15:10:26 schwarze Exp $
2.\" full merge up to: OpenSSL 4dcfdfce May 27 11:50:05 2020 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2022, 2024 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
22.\" and Matt Caswell <matt@openssl.org>.
23.\" Copyright (c) 2002, 2018, 2020 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: December 10 2024 $
70.Dt EVP_PKEY_NEW 3
71.Os
72.Sh NAME
73.Nm EVP_PKEY_new ,
74.Nm EVP_PKEY_up_ref ,
75.Nm EVP_PKEY_free ,
76.Nm EVP_PKEY_new_raw_private_key ,
77.Nm EVP_PKEY_new_raw_public_key ,
78.Nm EVP_PKEY_new_mac_key ,
79.Nm EVP_PKEY_get_raw_private_key ,
80.Nm EVP_PKEY_get_raw_public_key
81.Nd public and private key allocation and raw key handling functions
82.Sh SYNOPSIS
83.In openssl/evp.h
84.Ft EVP_PKEY *
85.Fn EVP_PKEY_new void
86.Ft int
87.Fo EVP_PKEY_up_ref
88.Fa "EVP_PKEY *pkey"
89.Fc
90.Ft void
91.Fo EVP_PKEY_free
92.Fa "EVP_PKEY *pkey"
93.Fc
94.Ft EVP_PKEY *
95.Fo EVP_PKEY_new_raw_private_key
96.Fa "int type"
97.Fa "ENGINE *engine"
98.Fa "const unsigned char *rawpriv"
99.Fa "size_t rawlen"
100.Fc
101.Ft EVP_PKEY *
102.Fo EVP_PKEY_new_raw_public_key
103.Fa "int type"
104.Fa "ENGINE *engine"
105.Fa "const unsigned char *rawpub"
106.Fa "size_t rawlen"
107.Fc
108.Ft EVP_PKEY *
109.Fo EVP_PKEY_new_mac_key
110.Fa "int type"
111.Fa "ENGINE *engine"
112.Fa "const unsigned char *rawpriv"
113.Fa "int rawlen"
114.Fc
115.Ft int
116.Fo EVP_PKEY_get_raw_private_key
117.Fa "const EVP_PKEY *pkey"
118.Fa "unsigned char *rawpriv"
119.Fa "size_t *rawlen"
120.Fc
121.Ft int
122.Fo EVP_PKEY_get_raw_public_key
123.Fa "const EVP_PKEY *pkey"
124.Fa "unsigned char *rawpub"
125.Fa "size_t *rawlen"
126.Fc
127.Sh DESCRIPTION
128The
129.Vt EVP_PKEY
130structure is used by various OpenSSL functions which require a general
131private or public key without reference to any particular algorithm.
132.Pp
133The
134.Fn EVP_PKEY_new
135function allocates an empty
136.Vt EVP_PKEY
137structure.
138The reference count is set to 1.
139To add a private or public key to it, use the functions described in
140.Xr EVP_PKEY_set1_RSA 3 .
141.Pp
142.Fn EVP_PKEY_up_ref
143increments the reference count of
144.Fa pkey
145by 1.
146.Pp
147.Fn EVP_PKEY_free
148decrements the reference count of
149.Fa pkey
150by 1, and if the reference count reaches zero, frees it up.
151If
152.Fa pkey
153is a
154.Dv NULL
155pointer, no action occurs.
156.Pp
157.Fn EVP_PKEY_new_raw_private_key
158allocates a new
159.Vt EVP_PKEY .
160The NID of a public key algorithm that supports raw private keys, i.e.\&
161.Dv EVP_PKEY_HMAC ,
162.Dv EVP_PKEY_X25519 ,
163or
164.Dv EVP_PKEY_ED25519 ,
165is provided in the
166.Fa type
167argument and
168.Fa rawlen
169bytes of raw private key data of that type in
170.Fa rawpriv .
171The public key data is automatically derived from the given private
172key data, if appropriate for the algorithm type.
173The
174.Fa ENGINE *engine
175argument is always ignored and passing
176.Dv NULL
177is recommended.
178.Pp
179.Fn EVP_PKEY_new_raw_public_key
180works in the same way as
181.Fn EVP_PKEY_new_raw_private_key
182except that
183.Fa rawpub
184points to the raw public key data.
185The
186.Vt EVP_PKEY
187structure is initialised without any private key information.
188Algorithm types that support raw public keys are
189.Dv EVP_PKEY_X25519
190and
191.Dv EVP_PKEY_ED25519 .
192.Pp
193.Fn EVP_PKEY_new_mac_key
194is a deprecated function that achieves the same effect as
195.Fn EVP_PKEY_new_raw_private_key
196in a more complicated way and only works with a
197.Fa type
198of
199.Dv EVP_PKEY_HMAC .
200.Pp
201.Fn EVP_PKEY_get_raw_private_key
202writes up to
203.Pf * Fa rawlen
204bytes of raw private key data to the buffer starting at
205.Fa rawpriv
206and stores the number of bytes written in
207.Pf * Fa rawlen .
208The calling application is responsible for ensuring that the buffer
209is large enough to receive the private key data.
210If the
211.Fa rawpriv
212argument is
213.Dv NULL ,
214the number of bytes required to hold the key is stored in
215.Pf * Fa rawlen .
216This function only works for algorithms that support raw private keys.
217Currently these are
218.Dv EVP_PKEY_HMAC ,
219.Dv EVP_PKEY_X25519 ,
220and
221.Dv EVP_PKEY_ED25519 .
222.Pp
223.Fn EVP_PKEY_get_raw_public_key
224is similar to
225.Fn EVP_PKEY_get_raw_private_key
226except that it writes raw public key data.
227This function only works for algorithms that support raw public keys.
228Currently these are
229.Dv EVP_PKEY_X25519
230and
231.Dv EVP_PKEY_ED25519 .
232.Sh RETURN VALUES
233.Fn EVP_PKEY_new ,
234.Fn EVP_PKEY_new_raw_private_key ,
235.Fn EVP_PKEY_new_raw_public_key ,
236and
237.Fn EVP_PKEY_new_mac_key
238return either the newly allocated
239.Vt EVP_PKEY
240structure or
241.Dv NULL
242if an error occurred.
243.Pp
244.Fn EVP_PKEY_up_ref ,
245.Fn EVP_PKEY_get_raw_private_key ,
246and
247.Fn EVP_PKEY_get_raw_public_key
248return 1 for success or 0 for failure.
249.Sh EXAMPLES
250The following code digests a message with HMAC-SHA256:
251.Bd -literal -offset indent
252/* Bogus key: would normally be set from another source */
253const unsigned char *key = "key";
254const size_t key_len = strlen(key);
255
256const char *msg = "The quick brown fox jumps over the lazy dog";
257const size_t msg_len = strlen(msg);
258
259unsigned char *out_mac;
260size_t out_len, i;
261
262EVP_PKEY *pkey;
263EVP_MD_CTX *md_ctx;
264
265pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, NULL,
266 key, key_len);
267if (pkey == NULL)
268 err(1, "EVP_PKEY_new_raw_private_key");
269
270md_ctx = EVP_MD_CTX_new();
271if (md_ctx == NULL)
272 err(1, "EVP_MD_CTX_new");
273
274if (EVP_DigestSignInit(md_ctx, NULL, EVP_sha256(), NULL, pkey) == 0)
275 err(1, "EVP_DigestSignInit");
276if (EVP_DigestSign(md_ctx, NULL, &out_len, msg, msg_len) == 0)
277 err(1, "EVP_DigestSign(NULL)");
278if ((out_mac = calloc(1, out_len)) == NULL)
279 err(1, "calloc");
280if (EVP_DigestSign(md_ctx, out_mac, &out_len, msg, msg_len) == 0)
281 err(1, "EVP_DigestSign(MAC)");
282
283EVP_MD_CTX_free(md_ctx);
284EVP_PKEY_free(pkey);
285
286printf(" MAC = ");
287for (i = 0; i < out_len; i++)
288 printf("%02x", out_mac[i]);
289printf("\en");
290free(out_mac);
291.Ed
292.Pp
293Even though the type name
294.Vt EVP_PKEY
295was originally intended to stand for
296.Dq private key
297and the
298.Xr EVP_DigestSignInit 3
299API was designed for digital signatures in the context of public key
300cryptography, both are also used here because a MAC also requires a key,
301even though that is a symmetric key.
302.Pp
303The same code can be used for signing with Ed25519 by making the key
304.Dv ED25519_PRIVATE_KEY_LENGTH No = 32
305bytes long, replacing
306.Dv EVP_PKEY_HMAC
307with
308.Dv EVP_PKEY_ED25519 ,
309and replacing the call to
310.Xr EVP_sha256 3
311with
312.Dv NULL .
313.Sh SEE ALSO
314.Xr CMAC_Init 3 ,
315.Xr d2i_PrivateKey 3 ,
316.Xr evp 3 ,
317.Xr EVP_PKCS82PKEY 3 ,
318.Xr EVP_PKEY_cmp 3 ,
319.Xr EVP_PKEY_CTX_new 3 ,
320.Xr EVP_PKEY_get_default_digest_nid 3 ,
321.Xr EVP_PKEY_new_CMAC_key 3 ,
322.Xr EVP_PKEY_print_private 3 ,
323.Xr EVP_PKEY_set1_RSA 3 ,
324.Xr EVP_PKEY_size 3 ,
325.Xr X509_get_pubkey_parameters 3
326.Sh HISTORY
327.Fn EVP_PKEY_new
328and
329.Fn EVP_PKEY_free
330first appeared in SSLeay 0.6.0 and have been available since
331.Ox 2.4 .
332.Pp
333.Fn EVP_PKEY_new_mac_key
334first appeared in OpenSSL 1.0.0 and has been available since
335.Ox 4.9 .
336.Pp
337.Fn EVP_PKEY_up_ref
338first appeared in OpenSSL 1.1.0 and has been available since
339.Ox 6.3 .
340.Pp
341.Fn EVP_PKEY_new_raw_private_key ,
342.Fn EVP_PKEY_new_raw_public_key ,
343.Fn EVP_PKEY_get_raw_private_key ,
344and
345.Fn EVP_PKEY_get_raw_public_key
346first appeared in OpenSSL 1.1.1 and have been available since
347.Ox 7.3 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_new_CMAC_key.3 b/src/lib/libcrypto/man/EVP_PKEY_new_CMAC_key.3
deleted file mode 100644
index d09af3a012..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_new_CMAC_key.3
+++ /dev/null
@@ -1,159 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_new_CMAC_key.3,v 1.1 2024/11/12 20:00:36 schwarze Exp $
2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 12 2024 $
18.Dt EVP_PKEY_NEW_CMAC_KEY 3
19.Os
20.Sh NAME
21.Nm EVP_PKEY_new_CMAC_key
22.Nd CMAC in the EVP framework
23.Sh SYNOPSIS
24.In openssl/evp.h
25.Ft EVP_PKEY *
26.Fo EVP_PKEY_new_CMAC_key
27.Fa "ENGINE *engine"
28.Fa "const unsigned char *key"
29.Fa "size_t key_len"
30.Fa "const EVP_CIPHER *cipher"
31.Fc
32.Sh DESCRIPTION
33.Fn EVP_PKEY_new_CMAC_key
34allocates a new
35.Vt EVP_PKEY
36object, sets its type to
37.Dv EVP_PKEY_CMAC ,
38and configures it as a wrapper around the low-level functions documented in
39.Xr CMAC_Init 3
40using the block
41.Fa cipher
42with the symmetric
43.Fa key
44that is
45.Fa key_len
46bytes long.
47.Pp
48Functions to obtain suitable
49.Vt EVP_CIPHER
50objects are listed in the CIPHER LISTING section of the
51.Xr EVP_EncryptInit 3
52manual page.
53Always use an object that implements the CBC mode of operation.
54As in
55.Xr CMAC_Init 3 ,
56only ciphers with a block size of either 64 or 128 bits
57are supported by this implementation.
58.Pp
59The
60.Fa engine
61argument is ignored; passing
62.Dv NULL
63is recommended.
64.Sh RETURN VALUES
65.Fn EVP_PKEY_new_CMAC_key
66returns the newly allocated
67.Vt EVP_PKEY
68structure or
69.Dv NULL
70if an error occurred.
71.Sh EXAMPLES
72The following code digests a message with AES-CMAC
73using the key length of 128 bits specified in RFC 4493.
74.Bd -literal -offset indent
75/* Bogus key: would normally be set from another source. */
76const unsigned char key[] = "symmetric secret";
77const size_t key_len = strlen(key); /* 16 = 128/8 */
78
79const char *msg = "Hello World!";
80const size_t msg_len = strlen(msg);
81
82unsigned char out_mac[16];
83size_t out_len = sizeof(out_mac);
84size_t i;
85
86EVP_PKEY *pkey;
87EVP_MD_CTX *md_ctx;
88
89pkey = EVP_PKEY_new_CMAC_key(NULL, key, key_len, EVP_aes_128_cbc());
90if (pkey == NULL)
91 err(1, "EVP_PKEY_new_CMAC_key");
92md_ctx = EVP_MD_CTX_new();
93if (md_ctx == NULL)
94 err(1, "EVP_MD_CTX_new");
95
96if (EVP_DigestSignInit(md_ctx, NULL, NULL, NULL, pkey) == 0)
97 err(1, "EVP_DigestSignInit");
98if (EVP_DigestSign(md_ctx, out_mac, &out_len, msg, msg_len) == 0)
99 err(1, "EVP_DigestSign");
100EVP_MD_CTX_free(md_ctx);
101EVP_PKEY_free(pkey);
102
103printf(" MAC = ");
104for (i = 0; i < out_len; i++)
105 printf("%02x:", out_mac[i]);
106printf("\en");
107.Ed
108.Pp
109Consider the following details:
110.Bl -bullet -width 1n
111.It
112Even though the type name
113.Vt EVP_PKEY
114was originally intended to stand for
115.Dq private key
116and the
117.Xr EVP_DigestSignInit 3
118API was designed for digital signatures in the context
119of public key cryptography, both are also used here because a MAC
120also requires a key, even though that is a symmetric key.
121.It
122In contrast to digital signing which requires both a digest algorithm
123and a private key, the CMAC algorithm only requires a block cipher
124and a shared key, both of which are stored in the somewhat abused
125.Vt EVP_PKEY
126object.
127Consequently, the
128.Vt "EVP_MD *type"
129argument of
130.Xr EVP_DigestSignInit 3
131has to be set to
132.Dv NULL .
133.It
134The size of the resulting message digest equals the block size
135of the used cipher.
136.It
137The function
138.Xr EVP_DigestSignInit 3
139does not transfer ownership of the
140.Fa pkey
141object to
142.Ft md_ctx
143but merely increments the reference count.
144Consequently, the caller is responsible for freeing the
145.Vt EVP_PKEY
146object when it is no longer needed.
147.El
148.Sh SEE ALSO
149.Xr CMAC_Init 3 ,
150.Xr evp 3 ,
151.Xr EVP_DigestSignInit 3 ,
152.Xr EVP_EncryptInit 3 ,
153.Xr EVP_PKEY_new 3
154.Sh STANDARDS
155RFC 4493: The AES-CMAC Algorithm
156.Sh HISTORY
157.Fn EVP_PKEY_new_CMAC_key
158first appeared in OpenSSL 1.1.1 and has been available since
159.Ox 6.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_print_private.3 b/src/lib/libcrypto/man/EVP_PKEY_print_private.3
deleted file mode 100644
index a4b51a4bbb..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_print_private.3
+++ /dev/null
@@ -1,129 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_print_private.3,v 1.8 2024/12/06 12:51:13 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2006, 2009 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 6 2024 $
52.Dt EVP_PKEY_PRINT_PRIVATE 3
53.Os
54.Sh NAME
55.Nm EVP_PKEY_print_public ,
56.Nm EVP_PKEY_print_private ,
57.Nm EVP_PKEY_print_params
58.Nd public key algorithm printing routines
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft int
62.Fo EVP_PKEY_print_public
63.Fa "BIO *out"
64.Fa "const EVP_PKEY *pkey"
65.Fa "int indent"
66.Fa "ASN1_PCTX *pctx"
67.Fc
68.Ft int
69.Fo EVP_PKEY_print_private
70.Fa "BIO *out"
71.Fa "const EVP_PKEY *pkey"
72.Fa "int indent"
73.Fa "ASN1_PCTX *pctx"
74.Fc
75.Ft int
76.Fo EVP_PKEY_print_params
77.Fa "BIO *out"
78.Fa "const EVP_PKEY *pkey"
79.Fa "int indent"
80.Fa "ASN1_PCTX *pctx"
81.Fc
82.Sh DESCRIPTION
83The functions
84.Fn EVP_PKEY_print_public ,
85.Fn EVP_PKEY_print_private ,
86and
87.Fn EVP_PKEY_print_params
88print out the public, private or parameter components of key
89.Fa pkey ,
90respectively.
91The key is sent to
92.Vt BIO
93.Fa out
94in human readable form.
95The parameter
96.Fa indent
97indicates how far the printout should be indented.
98.Pp
99The
100.Fa pctx
101parameter allows the print output to be finely tuned by using ASN.1
102printing options.
103If
104.Fa pctx
105is set to
106.Dv NULL ,
107then default values will be used.
108Currently, no public key algorithms include any options in the
109.Fa pctx
110parameter.
111.Pp
112If the key does not include all the components indicated by the function,
113then only those contained in the key will be printed.
114For example, passing a public key to
115.Fn EVP_PKEY_print_private
116will only print the public components.
117.Sh RETURN VALUES
118These functions all return 1 for success and 0 or a negative value for
119failure.
120In particular, a return value of -2 indicates the operation is not
121supported by the public key algorithm.
122.Sh SEE ALSO
123.Xr EVP_PKEY_CTX_new 3 ,
124.Xr EVP_PKEY_keygen 3 ,
125.Xr EVP_PKEY_new 3
126.Sh HISTORY
127These functions first appeared in OpenSSL 1.0.0
128and have been available since
129.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 b/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3
deleted file mode 100644
index 39404f5286..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3
+++ /dev/null
@@ -1,498 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.24 2024/12/09 11:25:25 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019, 2020, 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2002, 2015, 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 9 2024 $
69.Dt EVP_PKEY_SET1_RSA 3
70.Os
71.Sh NAME
72.Nm EVP_PKEY_set1_RSA ,
73.Nm EVP_PKEY_set1_DSA ,
74.Nm EVP_PKEY_set1_DH ,
75.Nm EVP_PKEY_set1_EC_KEY ,
76.Nm EVP_PKEY_get1_RSA ,
77.Nm EVP_PKEY_get1_DSA ,
78.Nm EVP_PKEY_get1_DH ,
79.Nm EVP_PKEY_get1_EC_KEY ,
80.Nm EVP_PKEY_get0_RSA ,
81.Nm EVP_PKEY_get0_DSA ,
82.Nm EVP_PKEY_get0_DH ,
83.Nm EVP_PKEY_get0_EC_KEY ,
84.Nm EVP_PKEY_get0_hmac ,
85.Nm EVP_PKEY_get0 ,
86.Nm EVP_PKEY_assign_RSA ,
87.Nm EVP_PKEY_assign_DSA ,
88.Nm EVP_PKEY_assign_DH ,
89.Nm EVP_PKEY_assign_EC_KEY ,
90.Nm EVP_PKEY_assign ,
91.Nm EVP_PKEY_base_id ,
92.Nm EVP_PKEY_id ,
93.Nm EVP_PKEY_type ,
94.Nm EVP_PKEY_set_type ,
95.Nm EVP_PKEY_set_type_str
96.\" The function X509_certificate_type(3) is intentionally undocumented
97.\" and scheduled for deletion from the library. BoringSSL already
98.\" deleted it and OpenSSL deprecates it in version 3.0.
99.\" The following constants are also intentionally undocumented
100.\" because they are only used by that function:
101.\" EVP_PK_DH EVP_PK_DSA EVP_PK_EC EVP_PK_RSA
102.\" EVP_PKS_DSA EVP_PKS_EC EVP_PKS_RSA
103.\" EVP_PKT_ENC EVP_PKT_EXCH EVP_PKT_EXP EVP_PKT_SIGN
104.Nd EVP_PKEY assignment functions
105.Sh SYNOPSIS
106.In openssl/evp.h
107.Ft int
108.Fo EVP_PKEY_set1_RSA
109.Fa "EVP_PKEY *pkey"
110.Fa "RSA *key"
111.Fc
112.Ft int
113.Fo EVP_PKEY_set1_DSA
114.Fa "EVP_PKEY *pkey"
115.Fa "DSA *key"
116.Fc
117.Ft int
118.Fo EVP_PKEY_set1_DH
119.Fa "EVP_PKEY *pkey"
120.Fa "DH *key"
121.Fc
122.Ft int
123.Fo EVP_PKEY_set1_EC_KEY
124.Fa "EVP_PKEY *pkey"
125.Fa "EC_KEY *key"
126.Fc
127.Ft RSA *
128.Fo EVP_PKEY_get1_RSA
129.Fa "EVP_PKEY *pkey"
130.Fc
131.Ft DSA *
132.Fo EVP_PKEY_get1_DSA
133.Fa "EVP_PKEY *pkey"
134.Fc
135.Ft DH *
136.Fo EVP_PKEY_get1_DH
137.Fa "EVP_PKEY *pkey"
138.Fc
139.Ft EC_KEY *
140.Fo EVP_PKEY_get1_EC_KEY
141.Fa "EVP_PKEY *pkey"
142.Fc
143.Ft RSA *
144.Fo EVP_PKEY_get0_RSA
145.Fa "EVP_PKEY *pkey"
146.Fc
147.Ft DSA *
148.Fo EVP_PKEY_get0_DSA
149.Fa "EVP_PKEY *pkey"
150.Fc
151.Ft DH *
152.Fo EVP_PKEY_get0_DH
153.Fa "EVP_PKEY *pkey"
154.Fc
155.Ft EC_KEY *
156.Fo EVP_PKEY_get0_EC_KEY
157.Fa "EVP_PKEY *pkey"
158.Fc
159.Ft const unsigned char *
160.Fo EVP_PKEY_get0_hmac
161.Fa "const EVP_PKEY *pkey"
162.Fa "size_t *len"
163.Fc
164.Ft void *
165.Fo EVP_PKEY_get0
166.Fa "const EVP_PKEY *pkey"
167.Fc
168.Ft int
169.Fo EVP_PKEY_assign_RSA
170.Fa "EVP_PKEY *pkey"
171.Fa "RSA *key"
172.Fc
173.Ft int
174.Fo EVP_PKEY_assign_DSA
175.Fa "EVP_PKEY *pkey"
176.Fa "DSA *key"
177.Fc
178.Ft int
179.Fo EVP_PKEY_assign_DH
180.Fa "EVP_PKEY *pkey"
181.Fa "DH *key"
182.Fc
183.Ft int
184.Fo EVP_PKEY_assign_EC_KEY
185.Fa "EVP_PKEY *pkey"
186.Fa "EC_KEY *key"
187.Fc
188.Ft int
189.Fo EVP_PKEY_assign
190.Fa "EVP_PKEY *pkey"
191.Fa "int type"
192.Fa "void *key"
193.Fc
194.Ft int
195.Fo EVP_PKEY_base_id
196.Fa "EVP_PKEY *pkey"
197.Fc
198.Ft int
199.Fo EVP_PKEY_id
200.Fa "EVP_PKEY *pkey"
201.Fc
202.Ft int
203.Fo EVP_PKEY_type
204.Fa "int type"
205.Fc
206.Ft int
207.Fo EVP_PKEY_set_type
208.Fa "EVP_PKEY *pkey"
209.Fa "int type"
210.Fc
211.Ft int
212.Fo EVP_PKEY_set_type_str
213.Fa "EVP_PKEY *pkey"
214.Fa "const char *str"
215.Fa "int len"
216.Fc
217.Sh DESCRIPTION
218.Fn EVP_PKEY_set1_RSA ,
219.Fn EVP_PKEY_set1_DSA ,
220.Fn EVP_PKEY_set1_DH ,
221and
222.Fn EVP_PKEY_set1_EC_KEY
223set the key referenced by
224.Fa pkey
225to
226.Fa key
227and increment the reference count of
228.Fa key
229by 1 in case of success.
230.Pp
231.Fn EVP_PKEY_get1_RSA ,
232.Fn EVP_PKEY_get1_DSA ,
233.Fn EVP_PKEY_get1_DH ,
234and
235.Fn EVP_PKEY_get1_EC_KEY
236return the key referenced in
237.Fa pkey ,
238incrementing its reference count by 1, or
239.Dv NULL
240if the key is not of the correct type.
241.Pp
242.Fn EVP_PKEY_get0_RSA ,
243.Fn EVP_PKEY_get0_DSA ,
244.Fn EVP_PKEY_get0_DH ,
245.Fn EVP_PKEY_get0_EC_KEY ,
246and
247.Fn EVP_PKEY_get0
248are identical except that they do not increment the reference count.
249Consequently, the returned key must not be freed by the caller.
250.Pp
251.Fn EVP_PKEY_get0_hmac
252returns an internal pointer to the key referenced in
253.Fa pkey
254and sets
255.Pf * Fa len
256to its length in bytes.
257The returned pointer must not be freed by the caller.
258If
259.Fa pkey
260is not of the correct type,
261.Dv NULL
262is returned and the content of
263.Pf * Fa len
264becomes unspecified.
265.Pp
266.Fn EVP_PKEY_assign_RSA ,
267.Fn EVP_PKEY_assign_DSA ,
268.Fn EVP_PKEY_assign_DH ,
269.Fn EVP_PKEY_assign_EC_KEY ,
270and
271.Fn EVP_PKEY_assign
272also set the referenced key to
273.Fa key ;
274however these use the supplied
275.Fa key
276internally without incrementing its reference count, such that
277.Fa key
278will be freed when the parent
279.Fa pkey
280is freed.
281If the
282.Fa key
283is of the wrong type, these functions report success even though
284.Fa pkey
285ends up in a corrupted state.
286Even the functions explicitly containing the type in their name are
287.Em not
288type safe because they are implemented as macros.
289The following types are supported:
290.Dv EVP_PKEY_RSA ,
291.Dv EVP_PKEY_DSA ,
292.Dv EVP_PKEY_DH ,
293and
294.Dv EVP_PKEY_EC .
295.Pp
296.Fn EVP_PKEY_base_id
297returns the type of
298.Fa pkey
299according to the following table:
300.Pp
301.Bl -column -compact -offset 2n EVP_PKEY_RSA_PSS NID_X9_62_id_ecPublicKey
302.It Sy return value Ta Ta Sy PEM type string
303.It Dv EVP_PKEY_CMAC Ta = Dv NID_cmac Ta CMAC
304.It Dv EVP_PKEY_DH Ta = Dv NID_dhKeyAgreement Ta DH
305.It Dv EVP_PKEY_DSA Ta = Dv NID_dsa Ta DSA
306.It Dv EVP_PKEY_EC Ta = Dv NID_X9_62_id_ecPublicKey Ta EC
307.It Dv EVP_PKEY_HMAC Ta = Dv NID_hmac Ta HMAC
308.It Dv EVP_PKEY_RSA Ta = Dv NID_rsaEncryption Ta RSA
309.It Dv EVP_PKEY_RSA_PSS Ta = Dv NID_rsassaPss Ta RSA-PSS
310.El
311.Pp
312.Fn EVP_PKEY_id
313returns the actual OID associated with
314.Fa pkey .
315Historically keys using the same algorithm could use different OIDs.
316The following deprecated aliases are still supported:
317.Pp
318.Bl -column -compact -offset 2n EVP_PKEY_DSA4 NID_dsaWithSHA1_2
319.It Sy return value Ta Ta Sy alias for
320.It Dv EVP_PKEY_DSA1 Ta = Dv NID_dsa_2 Ta DSA
321.It Dv EVP_PKEY_DSA2 Ta = Dv NID_dsaWithSHA Ta DSA
322.It Dv EVP_PKEY_DSA3 Ta = Dv NID_dsaWithSHA1 Ta DSA
323.It Dv EVP_PKEY_DSA4 Ta = Dv NID_dsaWithSHA1_2 Ta DSA
324.It Dv EVP_PKEY_RSA2 Ta = Dv NID_rsa Ta RSA
325.El
326.Pp
327Most applications wishing to know a key type will simply call
328.Fn EVP_PKEY_base_id
329and will not care about the actual type,
330which will be identical in almost all cases.
331.Pp
332.Fn EVP_PKEY_type
333returns the underlying type of the NID
334.Fa type .
335For example,
336.Fn EVP_PKEY_type EVP_PKEY_RSA2
337will return
338.Dv EVP_PKEY_RSA .
339.Pp
340.Fn EVP_PKEY_set_type
341frees the key referenced in
342.Fa pkey ,
343if any, and sets the key type of
344.Fa pkey
345to
346.Fa type
347without referencing a new key from
348.Fa pkey
349yet.
350For
351.Fa type ,
352any of the possible return values of
353.Fn EVP_PKEY_base_id
354and
355.Fn EVP_PKEY_id
356can be passed.
357.Pp
358.Fn EVP_PKEY_set_type_str
359frees the key referenced in
360.Fa pkey ,
361if any, and sets the key type of
362.Fa pkey
363according to the PEM type string given by the first
364.Fa len
365bytes of
366.Fa str .
367If
368.Fa len
369is \-1, the
370.Xr strlen 3
371of
372.Fa str
373is used instead.
374The PEM type strings supported by default are listed in the table above.
375This function does not reference a new key from
376.Fa pkey .
377.Pp
378If
379.Fa pkey
380is a
381.Dv NULL
382pointer,
383.Fn EVP_PKEY_set_type
384and
385.Fn EVP_PKEY_set_type_str
386check that a matching key type exists but do not change any object.
387.Pp
388In accordance with the OpenSSL naming convention, the key obtained from
389or assigned to
390.Fa pkey
391using the
392.Sy 1
393functions must be freed as well as
394.Fa pkey .
395.Sh RETURN VALUES
396.Fn EVP_PKEY_set1_RSA ,
397.Fn EVP_PKEY_set1_DSA ,
398.Fn EVP_PKEY_set1_DH ,
399.Fn EVP_PKEY_set1_EC_KEY ,
400.Fn EVP_PKEY_assign_RSA ,
401.Fn EVP_PKEY_assign_DSA ,
402.Fn EVP_PKEY_assign_DH ,
403.Fn EVP_PKEY_assign_EC_KEY ,
404.Fn EVP_PKEY_assign ,
405.Fn EVP_PKEY_set_type ,
406and
407.Fn EVP_PKEY_set_type_str
408return 1 for success or 0 for failure.
409.Pp
410.Fn EVP_PKEY_get1_RSA ,
411.Fn EVP_PKEY_get1_DSA ,
412.Fn EVP_PKEY_get1_DH ,
413.Fn EVP_PKEY_get1_EC_KEY ,
414.Fn EVP_PKEY_get0_RSA ,
415.Fn EVP_PKEY_get0_DSA ,
416.Fn EVP_PKEY_get0_DH ,
417.Fn EVP_PKEY_get0_EC_KEY ,
418.Fn EVP_PKEY_get0_hmac ,
419and
420.Fn EVP_PKEY_get0
421return the referenced key or
422.Dv NULL
423if an error occurred.
424For
425.Fn EVP_PKEY_get0 ,
426the return value points to an
427.Vt RSA ,
428.Vt DSA ,
429.Vt DH ,
430.Vt EC_KEY ,
431or
432.Vt ASN1_OCTET_STRING
433object depending on the type of
434.Fa pkey .
435.Pp
436.Fn EVP_PKEY_base_id ,
437.Fn EVP_PKEY_id ,
438and
439.Fn EVP_PKEY_type
440return a key type or
441.Dv NID_undef
442(equivalently
443.Dv EVP_PKEY_NONE )
444on error.
445.Sh SEE ALSO
446.Xr DH_new 3 ,
447.Xr DSA_new 3 ,
448.Xr EC_KEY_new 3 ,
449.Xr EVP_PKEY_get0_asn1 3 ,
450.Xr EVP_PKEY_new 3 ,
451.Xr RSA_new 3
452.Sh HISTORY
453.Fn EVP_PKEY_assign_RSA ,
454.Fn EVP_PKEY_assign_DSA ,
455.Fn EVP_PKEY_assign_DH ,
456.Fn EVP_PKEY_assign ,
457and
458.Fn EVP_PKEY_type
459first appeared in SSLeay 0.8.0 and have been available since
460.Ox 2.4 .
461.Pp
462.Fn EVP_PKEY_set1_RSA ,
463.Fn EVP_PKEY_set1_DSA ,
464.Fn EVP_PKEY_set1_DH ,
465.Fn EVP_PKEY_get1_RSA ,
466.Fn EVP_PKEY_get1_DSA ,
467and
468.Fn EVP_PKEY_get1_DH
469first appeared in OpenSSL 0.9.5 and have been available since
470.Ox 2.7 .
471.Pp
472.Fn EVP_PKEY_set1_EC_KEY ,
473.Fn EVP_PKEY_get1_EC_KEY ,
474and
475.Fn EVP_PKEY_assign_EC_KEY
476first appeared in OpenSSL 0.9.8 and have been available since
477.Ox 4.5 .
478.Pp
479.Fn EVP_PKEY_get0 ,
480.Fn EVP_PKEY_base_id ,
481.Fn EVP_PKEY_id ,
482.Fn EVP_PKEY_set_type ,
483and
484.Fn EVP_PKEY_set_type_str
485first appeared in OpenSSL 1.0.0 and have been available since
486.Ox 4.9 .
487.Pp
488.Fn EVP_PKEY_get0_RSA ,
489.Fn EVP_PKEY_get0_DSA ,
490.Fn EVP_PKEY_get0_DH ,
491and
492.Fn EVP_PKEY_get0_EC_KEY
493first appeared in OpenSSL 1.1.0 and have been available since
494.Ox 6.3 .
495.Pp
496.Fn EVP_PKEY_get0_hmac
497first appeared in OpenSSL 1.1.0 and has been available since
498.Ox 6.5 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_sign.3 b/src/lib/libcrypto/man/EVP_PKEY_sign.3
deleted file mode 100644
index d73b0abb7b..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_sign.3
+++ /dev/null
@@ -1,190 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_sign.3,v 1.9 2024/12/06 14:27:49 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2006, 2009, 2013, 2014 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 6 2024 $
53.Dt EVP_PKEY_SIGN 3
54.Os
55.Sh NAME
56.Nm EVP_PKEY_sign_init ,
57.Nm EVP_PKEY_sign
58.Nd sign using a public key algorithm
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft int
62.Fo EVP_PKEY_sign_init
63.Fa "EVP_PKEY_CTX *ctx"
64.Fc
65.Ft int
66.Fo EVP_PKEY_sign
67.Fa "EVP_PKEY_CTX *ctx"
68.Fa "unsigned char *sig"
69.Fa "size_t *siglen"
70.Fa "const unsigned char *tbs"
71.Fa "size_t tbslen"
72.Fc
73.Sh DESCRIPTION
74The
75.Fn EVP_PKEY_sign_init
76function initializes a public key algorithm context using the key
77.Fa ctx->pkey
78for a signing operation.
79.Pp
80The
81.Fn EVP_PKEY_sign
82function performs a public key signing operation using
83.Fa ctx .
84The data to be signed is specified using the
85.Fa tbs
86and
87.Fa tbslen
88parameters.
89If
90.Fa sig
91is
92.Dv NULL ,
93then the maximum size of the output buffer is written to the
94.Fa siglen
95parameter.
96If
97.Fa sig
98is not
99.Dv NULL ,
100then before the call the
101.Fa siglen
102parameter should contain the length of the
103.Fa sig
104buffer.
105If the call is successful, the signature is written to
106.Fa sig
107and the amount of data written to
108.Fa siglen .
109.Pp
110.Fn EVP_PKEY_sign
111does not hash the data to be signed, and therefore is normally used
112to sign digests.
113For signing arbitrary messages, see the
114.Xr EVP_DigestSignInit 3
115and
116.Xr EVP_SignInit 3
117signing interfaces instead.
118.Pp
119After the call to
120.Fn EVP_PKEY_sign_init ,
121algorithm specific control operations can be performed to set any
122appropriate parameters for the operation; see
123.Xr EVP_PKEY_CTX_ctrl 3 .
124.Pp
125The function
126.Fn EVP_PKEY_sign
127can be called more than once on the same context if several operations
128are performed using the same parameters.
129.Sh RETURN VALUES
130.Fn EVP_PKEY_sign_init
131and
132.Fn EVP_PKEY_sign
133return 1 for success and 0 or a negative value for failure.
134In particular, a return value of -2 indicates the operation is not
135supported by the public key algorithm.
136.Sh EXAMPLES
137Sign data using RSA with PKCS#1 padding and SHA256 digest:
138.Bd -literal -offset indent
139#include <openssl/evp.h>
140#include <openssl/rsa.h>
141
142EVP_PKEY_CTX *ctx;
143/* md is a SHA-256 digest in this example. */
144unsigned char *md, *sig;
145size_t mdlen = 32, siglen;
146EVP_PKEY *signing_key;
147
148/*
149 * NB: assumes signing_key and md are set up before the next
150 * step. signing_key must be an RSA private key and md must
151 * point to the SHA-256 digest to be signed.
152 */
153ctx = EVP_PKEY_CTX_new(signing_key, NULL /* no engine */);
154if (!ctx)
155 /* Error occurred */
156if (EVP_PKEY_sign_init(ctx) <= 0)
157 /* Error */
158if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
159 /* Error */
160if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
161 /* Error */
162
163/* Determine buffer length */
164if (EVP_PKEY_sign(ctx, NULL, &siglen, md, mdlen) <= 0)
165 /* Error */
166
167sig = malloc(siglen);
168
169if (!sig)
170 /* malloc failure */
171
172if (EVP_PKEY_sign(ctx, sig, &siglen, md, mdlen) <= 0)
173 /* Error */
174
175/* Signature is siglen bytes written to buffer sig */
176.Ed
177.Sh SEE ALSO
178.Xr EVP_PKEY_CTX_ctrl 3 ,
179.Xr EVP_PKEY_CTX_new 3 ,
180.Xr EVP_PKEY_decrypt 3 ,
181.Xr EVP_PKEY_derive 3 ,
182.Xr EVP_PKEY_encrypt 3 ,
183.Xr EVP_PKEY_verify 3 ,
184.Xr EVP_PKEY_verify_recover 3
185.Sh HISTORY
186.Fn EVP_PKEY_sign_init
187and
188.Fn EVP_PKEY_sign
189first appeared in OpenSSL 1.0.0 and have been available since
190.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_size.3 b/src/lib/libcrypto/man/EVP_PKEY_size.3
deleted file mode 100644
index cd25eec9c2..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_size.3
+++ /dev/null
@@ -1,224 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_size.3,v 1.4 2024/12/06 12:51:13 schwarze Exp $
2.\" full merge up to: OpenSSL eed9d03b Jan 8 11:04:15 2020 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2022, 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Richard Levitte <levitte@openssl.org>.
22.\" Copyright (c) 2020 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 6 2024 $
69.Dt EVP_PKEY_SIZE 3
70.Os
71.Sh NAME
72.Nm EVP_PKEY_size ,
73.Nm EVP_PKEY_bits ,
74.Nm EVP_PKEY_security_bits
75.Nd EVP_PKEY information functions
76.Sh SYNOPSIS
77.In openssl/evp.h
78.Ft int
79.Fo EVP_PKEY_size
80.Fa "const EVP_PKEY *pkey"
81.Fc
82.Ft int
83.Fo EVP_PKEY_bits
84.Fa "const EVP_PKEY *pkey"
85.Fc
86.Ft int
87.Fo EVP_PKEY_security_bits
88.Fa "const EVP_PKEY *pkey"
89.Fc
90.Sh DESCRIPTION
91.Fn EVP_PKEY_size
92returns the maximum size in bytes needed for the output buffer
93for almost any operation that can be done with
94.Fa pkey .
95The primary use is with
96.Xr EVP_SignFinal 3
97and
98.Xr EVP_SealInit 3 .
99The returned size is also large enough for the output buffer of
100.Xr EVP_PKEY_sign 3 ,
101.Xr EVP_PKEY_encrypt 3 ,
102.Xr EVP_PKEY_decrypt 3 ,
103and
104.Xr EVP_PKEY_derive 3 .
105.Pp
106Unless the documentation for the operation says otherwise,
107the size returned by
108.Fn EVP_PKEY_size
109is only an upper limit and the final content of the target
110buffer may be smaller.
111It is therefore crucial to take note of the size given back by the
112function that performs the operation.
113For example,
114.Xr EVP_PKEY_sign 3
115returns that length in the
116.Pf * Fa siglen
117argument.
118.Pp
119Using
120.Fn EVP_PKEY_size
121is discouraged with
122.Xr EVP_DigestSignFinal 3 .
123.Pp
124Most functions using an output buffer support passing
125.Dv NULL
126for the buffer and a pointer to an integer
127to get the exact size that this function call delivers
128in the context that it is called in.
129This allows those functions to be called twice, once to find out the
130exact buffer size, then allocate the buffer in between, and call that
131function again to actually output the data.
132For those functions, it isn't strictly necessary to call
133.Fn EVP_PKEY_size
134to find out the buffer size, but it may still be useful in cases
135where it's desirable to know the upper limit in advance.
136.Pp
137.Fn EVP_PKEY_size
138is supported for the following algorithms:
139.Bl -column ED25519 "EVP_MAX_BLOCK_LENGTH = 32"
140.It Ta same result as from:
141.It CMAC Ta Dv EVP_MAX_BLOCK_LENGTH No = 32
142.It DH Ta Xr DH_size 3
143.It DSA Ta Xr DSA_size 3
144.It EC Ta Xr ECDSA_size 3
145.It ED25519 Ta 64, but see below
146.It HMAC Ta Dv EVP_MAX_MD_SIZE No = 64
147.It RSA Ta Xr RSA_size 3
148.It X25519 Ta Dv X25519_KEYLEN No = 32
149.El
150.Pp
151For
152.Dv EVP_PKEY_ED25519 ,
153the situation is special: while the key size is
154.Dv ED25519_KEYLEN No = 32 bytes ,
155.Fn EVP_PKEY_size
156returns 64 because the signature is longer than the keys.
157.Pp
158.Fn EVP_PKEY_bits
159returns the cryptographic length of the cryptosystem to which the key in
160.Fa pkey
161belongs, in bits.
162The definition of cryptographic length is specific to the key cryptosystem.
163The following algorithms are supported:
164.Bl -column ED25519 "the public domain parameter p" DSA_bits(3)
165.It Ta cryptographic length = Ta same result as from:
166.It Ta significant bits in ... Ta
167.It DH Ta the public domain parameter Fa p Ta Xr DH_bits 3
168.It DSA Ta the public domain parameter Fa p Ta Xr DSA_bits 3
169.It EC Ta the order of the group Ta Xr EC_GROUP_order_bits 3
170.It ED25519 Ta 253 Ta \(em
171.It RSA Ta the public modulus Ta Xr RSA_bits 3
172.It X25519 Ta 253 Ta \(em
173.El
174.Pp
175.Fn EVP_PKEY_security_bits
176returns the security strength measured in bits of the given
177.Fa pkey
178as defined in NIST SP800-57.
179The following algorithms are supported:
180.Bl -column ED25519 DSA_security_bits(3)
181.It Ta same result as from:
182.It DH Ta Xr DH_security_bits 3
183.It DSA Ta Xr DSA_security_bits 3
184.It EC Ta Xr EC_GROUP_order_bits 3 divided by 2
185.It ED25519 Ta 128
186.It RSA Ta Xr RSA_security_bits 3
187.It X25519 Ta 128
188.El
189.Pp
190For EC keys, if the result is greater than 80, it is rounded down
191to 256, 192, 128, 112, or 80.
192.Sh RETURN VALUES
193.Fn EVP_PKEY_size
194and
195.Fn EVP_PKEY_bits
196return a positive number or 0 if this size isn't available.
197.Pp
198.Fn EVP_PKEY_security_bits
199returns a number in the range from 0 to 256 inclusive
200or \-2 if this function is unsupported for the algorithm used by
201.Fa pkey .
202It returns 0 if
203.Fa pkey
204is
205.Dv NULL .
206.Sh SEE ALSO
207.Xr EVP_PKEY_decrypt 3 ,
208.Xr EVP_PKEY_derive 3 ,
209.Xr EVP_PKEY_encrypt 3 ,
210.Xr EVP_PKEY_new 3 ,
211.Xr EVP_PKEY_sign 3 ,
212.Xr EVP_SealInit 3 ,
213.Xr EVP_SignFinal 3
214.Sh HISTORY
215.Fn EVP_PKEY_size
216first appeared in SSLeay 0.6.0 and
217.Fn EVP_PKEY_bits
218in SSLeay 0.9.0.
219Both functions have been available since
220.Ox 2.4 .
221.Pp
222.Fn EVP_PKEY_security_bits
223first appeared in OpenSSL 1.1.0 and has been available since
224.Ox 7.2 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_verify.3 b/src/lib/libcrypto/man/EVP_PKEY_verify.3
deleted file mode 100644
index d096a3a7be..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_verify.3
+++ /dev/null
@@ -1,167 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_verify.3,v 1.8 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2006, 2009, 2010, 2013, 2018 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 6 2024 $
53.Dt EVP_PKEY_VERIFY 3
54.Os
55.Sh NAME
56.Nm EVP_PKEY_verify_init ,
57.Nm EVP_PKEY_verify
58.Nd signature verification using a public key algorithm
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft int
62.Fo EVP_PKEY_verify_init
63.Fa "EVP_PKEY_CTX *ctx"
64.Fc
65.Ft int
66.Fo EVP_PKEY_verify
67.Fa "EVP_PKEY_CTX *ctx"
68.Fa "const unsigned char *sig"
69.Fa "size_t siglen"
70.Fa "const unsigned char *tbs"
71.Fa "size_t tbslen"
72.Fc
73.Sh DESCRIPTION
74The
75.Fn EVP_PKEY_verify_init
76function initializes a public key algorithm context using key
77.Fa ctx->pkey
78for a signature verification operation.
79.Pp
80The
81.Fn EVP_PKEY_verify
82function performs a public key verification operation using
83.Fa ctx .
84The signature is specified using the
85.Fa sig
86and
87.Fa siglen
88parameters.
89The verified data (i.e. the data believed originally signed) is
90specified using the
91.Fa tbs
92and
93.Fa tbslen
94parameters.
95.Pp
96After the call to
97.Fn EVP_PKEY_verify_init ,
98algorithm specific control operations can be performed to set any
99appropriate parameters for the operation.
100.Pp
101The function
102.Fn EVP_PKEY_verify
103can be called more than once on the same context if several operations
104are performed using the same parameters.
105.Sh RETURN VALUES
106.Fn EVP_PKEY_verify_init
107and
108.Fn EVP_PKEY_verify
109return 1 if the verification was successful and 0 if it failed.
110Unlike other functions the return value 0 from
111.Fn EVP_PKEY_verify
112only indicates that the signature did not verify successfully.
113That is,
114.Fa tbs
115did not match the original data or the signature was of invalid form.
116It is not an indication of a more serious error.
117.Pp
118A negative value indicates an error other that signature verification
119failure.
120In particular, a return value of -2 indicates the operation is not
121supported by the public key algorithm.
122.Sh EXAMPLES
123Verify signature using PKCS#1 and SHA256 digest:
124.Bd -literal -offset 3n
125#include <openssl/evp.h>
126#include <openssl/rsa.h>
127
128EVP_PKEY_CTX *ctx;
129unsigned char *md, *sig;
130size_t mdlen, siglen;
131EVP_PKEY *verify_key;
132
133/*
134 * Assumes that verify_key, sig, siglen, md, and mdlen are already set up
135 * and that verify_key is an RSA public key.
136 */
137ctx = EVP_PKEY_CTX_new(verify_key, NULL);
138if (!ctx)
139 /* Error occurred */
140if (EVP_PKEY_verify_init(ctx) <= 0)
141 /* Error */
142if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
143 /* Error */
144if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
145 /* Error */
146
147/* Perform operation */
148ret = EVP_PKEY_verify(ctx, sig, siglen, md, mdlen);
149
150/*
151 * ret == 1 indicates success, 0 verify failure,
152 * and < 0 some other error.
153 */
154.Ed
155.Sh SEE ALSO
156.Xr EVP_PKEY_CTX_new 3 ,
157.Xr EVP_PKEY_decrypt 3 ,
158.Xr EVP_PKEY_derive 3 ,
159.Xr EVP_PKEY_encrypt 3 ,
160.Xr EVP_PKEY_sign 3 ,
161.Xr EVP_PKEY_verify_recover 3
162.Sh HISTORY
163.Fn EVP_PKEY_verify_init
164and
165.Fn EVP_PKEY_verify
166first appeared in OpenSSL 1.0.0 and have been available since
167.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_PKEY_verify_recover.3 b/src/lib/libcrypto/man/EVP_PKEY_verify_recover.3
deleted file mode 100644
index 30c034cdb5..0000000000
--- a/src/lib/libcrypto/man/EVP_PKEY_verify_recover.3
+++ /dev/null
@@ -1,188 +0,0 @@
1.\" $OpenBSD: EVP_PKEY_verify_recover.3,v 1.10 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2006, 2009, 2010, 2013, 2018 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 6 2024 $
53.Dt EVP_PKEY_VERIFY_RECOVER 3
54.Os
55.Sh NAME
56.Nm EVP_PKEY_verify_recover_init ,
57.Nm EVP_PKEY_verify_recover
58.Nd recover signature using a public key algorithm
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft int
62.Fo EVP_PKEY_verify_recover_init
63.Fa "EVP_PKEY_CTX *ctx"
64.Fc
65.Ft int
66.Fo EVP_PKEY_verify_recover
67.Fa "EVP_PKEY_CTX *ctx"
68.Fa "unsigned char *rout"
69.Fa "size_t *routlen"
70.Fa "const unsigned char *sig"
71.Fa "size_t siglen"
72.Fc
73.Sh DESCRIPTION
74The
75.Fn EVP_PKEY_verify_recover_init
76function initializes a public key algorithm context using key
77.Fa ctx->pkey
78for a verify recover operation.
79.Pp
80The
81.Fn EVP_PKEY_verify_recover
82function recovers signed data using
83.Fa ctx .
84The signature is specified using the
85.Fa sig
86and
87.Fa siglen
88parameters.
89If
90.Fa rout
91is
92.Dv NULL ,
93then the maximum size of the output buffer is written to the
94.Fa routlen
95parameter.
96If
97.Fa rout
98is not
99.Dv NULL ,
100then before the call the
101.Fa routlen
102parameter should contain the length of the
103.Fa rout
104buffer.
105If the call is successful, recovered data is written to
106.Fa rout
107and the amount of data written to
108.Fa routlen .
109.Pp
110Normally an application is only interested in whether a signature
111verification operation is successful.
112In those cases, the
113.Xr EVP_PKEY_verify 3
114function should be used.
115.Pp
116Sometimes however it is useful to obtain the data originally signed
117using a signing operation.
118Only certain public key algorithms can recover a signature in this way
119(for example RSA in PKCS padding mode).
120.Pp
121After the call to
122.Fn EVP_PKEY_verify_recover_init ,
123algorithm specific control operations can be performed to set any
124appropriate parameters for the operation.
125.Pp
126The function
127.Fn EVP_PKEY_verify_recover
128can be called more than once on the same context if several operations
129are performed using the same parameters.
130.Sh RETURN VALUES
131.Fn EVP_PKEY_verify_recover_init
132and
133.Fn EVP_PKEY_verify_recover
134return 1 for success and 0 or a negative value for failure.
135In particular, a return value of -2 indicates the operation is not
136supported by the public key algorithm.
137.Sh EXAMPLES
138Recover digest originally signed using PKCS#1 and SHA256 digest:
139.Bd -literal -offset indent
140#include <openssl/evp.h>
141#include <openssl/rsa.h>
142
143EVP_PKEY_CTX *ctx;
144unsigned char *rout, *sig;
145size_t routlen, siglen;
146EVP_PKEY *verify_key;
147
148/*
149 * Assumes that verify_key, sig, and siglen are already set up
150 * and that verify_key is an RSA public key.
151 */
152ctx = EVP_PKEY_CTX_new(verify_key, NULL);
153if (!ctx)
154 /* Error occurred */
155if (EVP_PKEY_verify_recover_init(ctx) <= 0)
156 /* Error */
157if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
158 /* Error */
159if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
160 /* Error */
161
162/* Determine buffer length */
163if (EVP_PKEY_verify_recover(ctx, NULL, &routlen, sig, siglen) <= 0)
164 /* Error */
165
166rout = malloc(routlen);
167
168if (!rout)
169 /* malloc failure */
170
171if (EVP_PKEY_verify_recover(ctx, rout, &routlen, sig, siglen) <= 0)
172 /* Error */
173
174/* Recovered data is routlen bytes written to buffer rout */
175.Ed
176.Sh SEE ALSO
177.Xr EVP_PKEY_CTX_new 3 ,
178.Xr EVP_PKEY_decrypt 3 ,
179.Xr EVP_PKEY_derive 3 ,
180.Xr EVP_PKEY_encrypt 3 ,
181.Xr EVP_PKEY_sign 3 ,
182.Xr EVP_PKEY_verify 3
183.Sh HISTORY
184.Fn EVP_PKEY_verify_recover_init
185and
186.Fn EVP_PKEY_verify_recover
187first appeared in OpenSSL 1.0.0 and have been available since
188.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/EVP_SealInit.3 b/src/lib/libcrypto/man/EVP_SealInit.3
deleted file mode 100644
index da53535274..0000000000
--- a/src/lib/libcrypto/man/EVP_SealInit.3
+++ /dev/null
@@ -1,191 +0,0 @@
1.\" $OpenBSD: EVP_SealInit.3,v 1.9 2023/11/16 20:27:43 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000, 2002, 2003, 2005, 2015 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: November 16 2023 $
53.Dt EVP_SEALINIT 3
54.Os
55.Sh NAME
56.Nm EVP_SealInit ,
57.Nm EVP_SealUpdate ,
58.Nm EVP_SealFinal
59.Nd EVP envelope encryption
60.Sh SYNOPSIS
61.In openssl/evp.h
62.Ft int
63.Fo EVP_SealInit
64.Fa "EVP_CIPHER_CTX *ctx"
65.Fa "const EVP_CIPHER *type"
66.Fa "unsigned char **ek"
67.Fa "int *ekl"
68.Fa "unsigned char *iv"
69.Fa "EVP_PKEY **pubk"
70.Fa "int npubk"
71.Fc
72.Ft int
73.Fo EVP_SealUpdate
74.Fa "EVP_CIPHER_CTX *ctx"
75.Fa "unsigned char *out"
76.Fa "int *outl"
77.Fa "unsigned char *in"
78.Fa "int inl"
79.Fc
80.Ft int
81.Fo EVP_SealFinal
82.Fa "EVP_CIPHER_CTX *ctx"
83.Fa "unsigned char *out"
84.Fa "int *outl"
85.Fc
86.Sh DESCRIPTION
87The EVP envelope routines are a high level interface to envelope
88encryption.
89They generate a random key and IV (if required) then "envelope" it by
90using public key encryption.
91Data can then be encrypted using this key.
92.Pp
93.Fn EVP_SealInit
94initializes a cipher context
95.Fa ctx
96for encryption with cipher
97.Fa type
98using a random secret key and IV.
99.Fa type
100is normally supplied by a function such as
101.Xr EVP_aes_256_cbc 3 ;
102see
103.Xr EVP_EncryptInit 3
104for details.
105The secret key is encrypted using one or more public keys.
106This allows the same encrypted data to be decrypted using any of
107the corresponding private keys.
108.Fa ek
109is an array of buffers where the public key encrypted secret key will be
110written.
111Each buffer must contain enough room for the corresponding encrypted
112key: that is
113.Fa ek[i]
114must have room for
115.Fn EVP_PKEY_size pubk[i]
116bytes.
117The actual size of each encrypted secret key is written to the array
118.Fa ekl .
119.Fa pubk
120is an array of
121.Fa npubk
122public keys.
123.Pp
124The
125.Fa iv
126parameter is a buffer where the generated IV is written to.
127It must contain enough room for the corresponding cipher's IV, as
128determined by (for example)
129.Fn EVP_CIPHER_iv_length type .
130.Pp
131If the cipher does not require an IV then the
132.Fa iv
133parameter is ignored and can be
134.Dv NULL .
135.Pp
136.Fn EVP_SealUpdate
137and
138.Fn EVP_SealFinal
139have exactly the same properties as the
140.Xr EVP_EncryptUpdate 3
141and
142.Xr EVP_EncryptFinal 3
143routines.
144.Pp
145The public key must be RSA because it is the only OpenSSL public key
146algorithm that supports key transport.
147.Pp
148Envelope encryption is the usual method of using public key encryption
149on large amounts of data.
150This is because public key encryption is slow but symmetric encryption
151is fast.
152So symmetric encryption is used for bulk encryption and the small random
153symmetric key used is transferred using public key encryption.
154.Pp
155It is possible to call
156.Fn EVP_SealInit
157twice in the same way as
158.Xr EVP_EncryptInit 3 .
159The first call should have
160.Fa npubk
161set to 0 and (after setting any cipher parameters) it should be called
162again with
163.Fa type
164set to NULL.
165.Pp
166.Fn EVP_SealUpdate
167is implemented as a macro.
168.Sh RETURN VALUES
169.Fn EVP_SealInit
170returns 0 on error or
171.Fa npubk
172if successful.
173.Pp
174.Fn EVP_SealUpdate
175and
176.Fn EVP_SealFinal
177return 1 for success and 0 for failure.
178.Sh SEE ALSO
179.Xr evp 3 ,
180.Xr EVP_EncryptInit 3 ,
181.Xr EVP_OpenInit 3
182.Sh HISTORY
183.Fn EVP_SealInit ,
184.Fn EVP_SealUpdate ,
185and
186.Fn EVP_SealFinal
187first appeared in SSLeay 0.5.1 and have been available since
188.Ox 2.4 .
189.Pp
190.Fn EVP_SealFinal
191did not return a value before OpenSSL 0.9.7.
diff --git a/src/lib/libcrypto/man/EVP_SignInit.3 b/src/lib/libcrypto/man/EVP_SignInit.3
deleted file mode 100644
index 8158b21dbf..0000000000
--- a/src/lib/libcrypto/man/EVP_SignInit.3
+++ /dev/null
@@ -1,211 +0,0 @@
1.\" $OpenBSD: EVP_SignInit.3,v 1.21 2024/12/06 12:51:13 schwarze Exp $
2.\" full merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000-2002, 2005, 2006, 2014-2016 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 6 2024 $
53.Dt EVP_SIGNINIT 3
54.Os
55.Sh NAME
56.Nm EVP_SignInit_ex ,
57.Nm EVP_SignUpdate ,
58.Nm EVP_SignFinal ,
59.Nm EVP_SignInit
60.Nd EVP signing functions
61.Sh SYNOPSIS
62.In openssl/evp.h
63.Ft int
64.Fo EVP_SignInit_ex
65.Fa "EVP_MD_CTX *ctx"
66.Fa "const EVP_MD *type"
67.Fa "ENGINE *engine"
68.Fc
69.Ft int
70.Fo EVP_SignUpdate
71.Fa "EVP_MD_CTX *ctx"
72.Fa "const void *d"
73.Fa "unsigned int cnt"
74.Fc
75.Ft int
76.Fo EVP_SignFinal
77.Fa "EVP_MD_CTX *ctx"
78.Fa "unsigned char *sig"
79.Fa "unsigned int *s"
80.Fa "EVP_PKEY *pkey"
81.Fc
82.Ft void
83.Fo EVP_SignInit
84.Fa "EVP_MD_CTX *ctx"
85.Fa "const EVP_MD *type"
86.Fc
87.Sh DESCRIPTION
88The EVP signature routines are a high-level interface to digital
89signatures.
90.Pp
91.Fn EVP_SignInit_ex
92sets up the signing context
93.Fa ctx
94to use the digest
95.Fa type .
96Before calling this function, obtain
97.Fa ctx
98from
99.Xr EVP_MD_CTX_new 3
100or call
101.Xr EVP_MD_CTX_reset 3
102on it.
103The
104.Fa engine
105argument is always ignored and passing
106.Dv NULL
107is recommended.
108.Pp
109.Fn EVP_SignUpdate
110hashes
111.Fa cnt
112bytes of data at
113.Fa d
114into the signature context
115.Fa ctx .
116This function can be called several times on the same
117.Fa ctx
118to include additional data.
119.Pp
120.Fn EVP_SignFinal
121signs the data in
122.Fa ctx
123using the private key
124.Fa pkey
125and places the signature in
126.Fa sig .
127.Fa sig
128must be at least
129.Xr EVP_PKEY_size 3
130bytes in size.
131.Fa s
132is an OUT parameter, and not used as an IN parameter.
133The number of bytes of data written (i.e.\&
134the length of the signature) will be written to the integer at
135.Fa s .
136At most
137.Xr EVP_PKEY_size 3
138bytes will be written.
139.Pp
140.Fn EVP_SignInit
141initializes a signing context
142.Fa ctx
143to use the default implementation of digest
144.Fa type .
145.Pp
146The EVP interface to digital signatures should almost always be
147used in preference to the low-level interfaces.
148This is because the code then becomes transparent to the algorithm used
149and much more flexible.
150.Pp
151The call to
152.Fn EVP_SignFinal
153internally finalizes a copy of the digest context.
154This means that calls to
155.Fn EVP_SignUpdate
156and
157.Fn EVP_SignFinal
158can be called later to digest and sign additional data.
159.Pp
160Since only a copy of the digest context is ever finalized, the context
161must be cleaned up after use by calling
162.Xr EVP_MD_CTX_free 3
163or a memory leak will occur.
164.Pp
165.Fn EVP_SignInit_ex ,
166.Fn EVP_SignUpdate ,
167and
168.Fn EVP_SignInit
169are implemented as macros.
170.Sh RETURN VALUES
171.Fn EVP_SignInit_ex ,
172.Fn EVP_SignUpdate ,
173and
174.Fn EVP_SignFinal
175return 1 for success and 0 for failure.
176.Pp
177The error codes can be obtained by
178.Xr ERR_get_error 3 .
179.Sh SEE ALSO
180.Xr evp 3 ,
181.Xr EVP_DigestInit 3 ,
182.Xr EVP_PKEY_size 3 ,
183.Xr EVP_VerifyInit 3
184.Sh HISTORY
185.Fn EVP_SignInit ,
186.Fn EVP_SignUpdate ,
187and
188.Fn EVP_SignFinal
189first appeared in SSLeay 0.5.1 and have been available since
190.Ox 2.4 .
191.Pp
192.Fn EVP_SignInit_ex
193first appeared in OpenSSL 0.9.7 and has been available since
194.Ox 3.2 .
195.Sh BUGS
196Older versions of this documentation wrongly stated that calls to
197.Fn EVP_SignUpdate
198could not be made after calling
199.Fn EVP_SignFinal .
200.Pp
201Since the private key is passed in the call to
202.Fn EVP_SignFinal ,
203any error relating to the private key (for example an unsuitable key and
204digest combination) will not be indicated until after potentially large
205amounts of data have been passed through
206.Fn EVP_SignUpdate .
207.Pp
208It is not possible to change the signing parameters using these
209function.
210.Pp
211The previous two bugs are fixed in the newer EVP_DigestSign* function.
diff --git a/src/lib/libcrypto/man/EVP_VerifyInit.3 b/src/lib/libcrypto/man/EVP_VerifyInit.3
deleted file mode 100644
index 0baadfb9fb..0000000000
--- a/src/lib/libcrypto/man/EVP_VerifyInit.3
+++ /dev/null
@@ -1,205 +0,0 @@
1.\" $OpenBSD: EVP_VerifyInit.3,v 1.13 2024/11/08 22:23:35 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000, 2001, 2006, 2016 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: November 8 2024 $
53.Dt EVP_VERIFYINIT 3
54.Os
55.Sh NAME
56.Nm EVP_VerifyInit_ex ,
57.Nm EVP_VerifyUpdate ,
58.Nm EVP_VerifyFinal ,
59.Nm EVP_VerifyInit
60.Nd EVP signature verification functions
61.Sh SYNOPSIS
62.In openssl/evp.h
63.Ft int
64.Fo EVP_VerifyInit_ex
65.Fa "EVP_MD_CTX *ctx"
66.Fa "const EVP_MD *type"
67.Fa "ENGINE *engine"
68.Fc
69.Ft int
70.Fo EVP_VerifyUpdate
71.Fa "EVP_MD_CTX *ctx"
72.Fa "const void *d"
73.Fa "unsigned int cnt"
74.Fc
75.Ft int
76.Fo EVP_VerifyFinal
77.Fa "EVP_MD_CTX *ctx"
78.Fa "unsigned char *sigbuf"
79.Fa "unsigned int siglen"
80.Fa "EVP_PKEY *pkey"
81.Fc
82.Ft int
83.Fo EVP_VerifyInit
84.Fa "EVP_MD_CTX *ctx"
85.Fa "const EVP_MD *type"
86.Fc
87.Sh DESCRIPTION
88The EVP signature verification routines are a high-level interface to
89digital signatures.
90.Pp
91.Fn EVP_VerifyInit_ex
92sets up the verification context
93.Fa ctx
94to use the digest
95.Fa type .
96Before calling this function, obtain
97.Fa ctx
98from
99.Xr EVP_MD_CTX_new 3
100or call
101.Xr EVP_MD_CTX_reset 3
102on it.
103The
104.Fa engine
105argument is always ignored and passing
106.Dv NULL
107is recommended.
108.Pp
109.Fn EVP_VerifyUpdate
110hashes
111.Fa cnt
112bytes of data at
113.Fa d
114into the verification context
115.Fa ctx .
116This function can be called several times on the same
117.Fa ctx
118to include additional data.
119.Pp
120.Fn EVP_VerifyFinal
121verifies the data in
122.Fa ctx
123using the public key
124.Fa pkey
125and against the
126.Fa siglen
127bytes at
128.Fa sigbuf .
129.Pp
130.Fn EVP_VerifyInit
131initializes a verification context
132.Fa ctx
133to use the default implementation of digest
134.Fa type .
135.Pp
136The EVP interface to digital signatures should almost always be
137used in preference to the low-level interfaces.
138This is because the code then becomes transparent to the algorithm used
139and much more flexible.
140.Pp
141The call to
142.Fn EVP_VerifyFinal
143internally finalizes a copy of the digest context.
144This means that calls to
145.Fn EVP_VerifyUpdate
146and
147.Fn EVP_VerifyFinal
148can be called later to digest and verify additional data.
149.Pp
150Since only a copy of the digest context is ever finalized, the context
151must be cleaned up after use by calling
152.Xr EVP_MD_CTX_free 3 ,
153or a memory leak will occur.
154.Pp
155.Fn EVP_VerifyInit_ex ,
156.Fn EVP_VerifyUpdate ,
157and
158.Fn EVP_VerifyInit
159are implemented as macros.
160.Sh RETURN VALUES
161.Fn EVP_VerifyInit_ex
162and
163.Fn EVP_VerifyUpdate
164return 1 for success and 0 for failure.
165.Pp
166.Fn EVP_VerifyFinal
167returns 1 for a correct signature, 0 for failure, and -1 if some other
168error occurred.
169.Pp
170The error codes can be obtained by
171.Xr ERR_get_error 3 .
172.Sh SEE ALSO
173.Xr evp 3 ,
174.Xr EVP_DigestInit 3 ,
175.Xr EVP_SignInit 3
176.Sh HISTORY
177.Fn EVP_VerifyInit ,
178.Fn EVP_VerifyUpdate ,
179and
180.Fn EVP_VerifyFinal
181first appeared in SSLeay 0.5.1 and have been available since
182.Ox 2.4 .
183.Pp
184.Fn EVP_VerifyInit_ex
185first appeared in OpenSSL 0.9.7 and has been available since
186.Ox 3.2 .
187.Sh BUGS
188Older versions of this documentation wrongly stated that calls to
189.Fn EVP_VerifyUpdate
190could not be made after calling
191.Fn EVP_VerifyFinal .
192.Pp
193Since the public key is passed in the call to
194.Xr EVP_SignFinal 3 ,
195any error relating to the private key (for example an unsuitable key and
196digest combination) will not be indicated until after potentially large
197amounts of data have been passed through
198.Xr EVP_SignUpdate 3 .
199.Pp
200It is not possible to change the signing parameters using these
201functions.
202.Pp
203The previous two bugs are fixed in the newer functions of the
204.Xr EVP_DigestVerifyInit 3
205family.
diff --git a/src/lib/libcrypto/man/EVP_aes_128_cbc.3 b/src/lib/libcrypto/man/EVP_aes_128_cbc.3
deleted file mode 100644
index 46e3ef0bdc..0000000000
--- a/src/lib/libcrypto/man/EVP_aes_128_cbc.3
+++ /dev/null
@@ -1,304 +0,0 @@
1.\" $OpenBSD: EVP_aes_128_cbc.3,v 1.8 2024/12/20 01:54:03 schwarze Exp $
2.\" selective merge up to: OpenSSL 7c6d372a Nov 20 13:20:01 2018 +0000
3.\"
4.\" This file was written by Ronald Tse <ronald.tse@ribose.com>
5.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 20 2024 $
52.Dt EVP_AES_128_CBC 3
53.Os
54.Sh NAME
55.Nm EVP_aes_128_cbc ,
56.Nm EVP_aes_192_cbc ,
57.Nm EVP_aes_256_cbc ,
58.Nm EVP_aes_128_cfb1 ,
59.Nm EVP_aes_192_cfb1 ,
60.Nm EVP_aes_256_cfb1 ,
61.Nm EVP_aes_128_cfb8 ,
62.Nm EVP_aes_192_cfb8 ,
63.Nm EVP_aes_256_cfb8 ,
64.Nm EVP_aes_128_cfb128 ,
65.Nm EVP_aes_192_cfb128 ,
66.Nm EVP_aes_256_cfb128 ,
67.Nm EVP_aes_128_cfb ,
68.Nm EVP_aes_192_cfb ,
69.Nm EVP_aes_256_cfb ,
70.Nm EVP_aes_128_ctr ,
71.Nm EVP_aes_192_ctr ,
72.Nm EVP_aes_256_ctr ,
73.Nm EVP_aes_128_ecb ,
74.Nm EVP_aes_192_ecb ,
75.Nm EVP_aes_256_ecb ,
76.Nm EVP_aes_128_ofb ,
77.Nm EVP_aes_192_ofb ,
78.Nm EVP_aes_256_ofb ,
79.Nm EVP_aes_128_cbc_hmac_sha1 ,
80.Nm EVP_aes_256_cbc_hmac_sha1 ,
81.Nm EVP_aes_128_wrap ,
82.Nm EVP_aes_192_wrap ,
83.Nm EVP_aes_256_wrap ,
84.Nm EVP_aes_128_xts ,
85.Nm EVP_aes_256_xts
86.Nd EVP AES cipher
87.Sh SYNOPSIS
88.In openssl/evp.h
89.Ft const EVP_CIPHER *
90.Fn EVP_aes_128_cbc void
91.Ft const EVP_CIPHER *
92.Fn EVP_aes_192_cbc void
93.Ft const EVP_CIPHER *
94.Fn EVP_aes_256_cbc void
95.Ft const EVP_CIPHER *
96.Fn EVP_aes_128_cfb1 void
97.Ft const EVP_CIPHER *
98.Fn EVP_aes_192_cfb1 void
99.Ft const EVP_CIPHER *
100.Fn EVP_aes_256_cfb1 void
101.Ft const EVP_CIPHER *
102.Fn EVP_aes_128_cfb8 void
103.Ft const EVP_CIPHER *
104.Fn EVP_aes_192_cfb8 void
105.Ft const EVP_CIPHER *
106.Fn EVP_aes_256_cfb8 void
107.Ft const EVP_CIPHER *
108.Fn EVP_aes_128_cfb128 void
109.Ft const EVP_CIPHER *
110.Fn EVP_aes_192_cfb128 void
111.Ft const EVP_CIPHER *
112.Fn EVP_aes_256_cfb128 void
113.Ft const EVP_CIPHER *
114.Fn EVP_aes_128_cfb void
115.Ft const EVP_CIPHER *
116.Fn EVP_aes_192_cfb void
117.Ft const EVP_CIPHER *
118.Fn EVP_aes_256_cfb void
119.Ft const EVP_CIPHER *
120.Fn EVP_aes_128_ctr void
121.Ft const EVP_CIPHER *
122.Fn EVP_aes_192_ctr void
123.Ft const EVP_CIPHER *
124.Fn EVP_aes_256_ctr void
125.Ft const EVP_CIPHER *
126.Fn EVP_aes_128_ecb void
127.Ft const EVP_CIPHER *
128.Fn EVP_aes_192_ecb void
129.Ft const EVP_CIPHER *
130.Fn EVP_aes_256_ecb void
131.Ft const EVP_CIPHER *
132.Fn EVP_aes_128_ofb void
133.Ft const EVP_CIPHER *
134.Fn EVP_aes_192_ofb void
135.Ft const EVP_CIPHER *
136.Fn EVP_aes_256_ofb void
137.Ft const EVP_CIPHER *
138.Fn EVP_aes_128_cbc_hmac_sha1 void
139.Ft const EVP_CIPHER *
140.Fn EVP_aes_256_cbc_hmac_sha1 void
141.Ft const EVP_CIPHER *
142.Fn EVP_aes_128_wrap void
143.Ft const EVP_CIPHER *
144.Fn EVP_aes_192_wrap void
145.Ft const EVP_CIPHER *
146.Fn EVP_aes_256_wrap void
147.Ft const EVP_CIPHER *
148.Fn EVP_aes_128_xts void
149.Ft const EVP_CIPHER *
150.Fn EVP_aes_256_xts void
151.Sh DESCRIPTION
152These functions provide the AES encryption algorithm in the
153.Xr evp 3
154framework.
155AES is a family of block ciphers operating on 128 bit blocks
156using key lengths of 128, 192, and 256 bits.
157.Pp
158.Fn EVP_aes_128_cbc ,
159.Fn EVP_aes_192_cbc ,
160.Fn EVP_aes_256_cbc ,
161.Fn EVP_aes_128_cfb1 ,
162.Fn EVP_aes_192_cfb1 ,
163.Fn EVP_aes_256_cfb1 ,
164.Fn EVP_aes_128_cfb8 ,
165.Fn EVP_aes_192_cfb8 ,
166.Fn EVP_aes_256_cfb8 ,
167.Fn EVP_aes_128_cfb128 ,
168.Fn EVP_aes_192_cfb128 ,
169.Fn EVP_aes_256_cfb128 ,
170.Fn EVP_aes_128_ctr ,
171.Fn EVP_aes_192_ctr ,
172.Fn EVP_aes_256_ctr ,
173.Fn EVP_aes_128_ecb ,
174.Fn EVP_aes_192_ecb ,
175.Fn EVP_aes_256_ecb ,
176.Fn EVP_aes_128_ofb ,
177.Fn EVP_aes_192_ofb ,
178and
179.Fn EVP_aes_256_ofb
180provide AES for 128, 192, and 256-bit keys in the following modes:
181CBC, CFB with 1-bit shift, CFB with 8-bit shift, CFB with 128-bit shift,
182CTR, ECB, and OFB.
183.Pp
184.Fn EVP_aes_128_cfb ,
185.Fn EVP_aes_192_cfb ,
186and
187.Fn EVP_aes_256_cfb
188are aliases for
189.Fn EVP_aes_128_cfb128 ,
190.Fn EVP_aes_192_cfb128 ,
191and
192.Fn EVP_aes_256_cfb128 ,
193implemented as macros.
194.Pp
195.Fn EVP_aes_128_cbc_hmac_sha1
196and
197.Fn EVP_aes_256_cbc_hmac_sha1
198provide authenticated encryption with AES in CBC mode using SHA-1 as HMAC,
199with keys of 128 and 256-bit length respectively.
200The authentication tag is 160 bits long.
201This is not intended for usage outside of TLS and requires
202calling of some undocumented control functions.
203These ciphers do not conform to the EVP AEAD interface.
204.Pp
205.Fn EVP_aes_128_wrap ,
206.Fn EVP_aes_192_wrap ,
207and
208.Fn EVP_aes_256_wrap
209provide AES key wrap with 128, 192 and 256-bit keys
210according to RFC 3394 section 2.2.1 ("wrap").
211When the returned
212.Vt EVP_CIPHER
213object is later passed to
214.Xr EVP_CipherInit_ex 3 ,
215.Xr EVP_EncryptInit_ex 3 ,
216or
217.Xr EVP_DecryptInit_ex 3
218together with an
219.Vt EVP_CIPHER_CTX
220object, the flag
221.Dv EVP_CIPHER_CTX_FLAG_WRAP_ALLOW
222must have been set in the
223.Vt EVP_CIPHER_CTX
224using
225.Xr EVP_CIPHER_CTX_set_flags 3 .
226Otherwise, or when passing the returned
227.Vt EVP_CIPHER
228object to
229.Xr EVP_CipherInit 3 ,
230.Xr EVP_EncryptInit 3 ,
231or
232.Xr EVP_DecryptInit 3 ,
233initialization fails with a
234.Dq wrap not allowed
235error.
236.Pp
237.Fn EVP_aes_128_xts
238and
239.Fn EVP_aes_256_xts
240provide XEX-based tweaked-codebook mode with ciphertext stealing (XTS-AES)
241as specified in IEEE Std. 1619-2007 and described in NIST SP 800-38E.
242It was designed for encrypting data on a storage device,
243provides confidentiality but not authentication of data,
244and requires a key of double length for protection of a certain key size.
245In particular, XTS-AES-128 takes input of a 256-bit key to achieve
246AES 128-bit security, and XTS-AES-256 takes input of a 512-bit key
247to achieve AES 256-bit security.
248.Sh RETURN VALUES
249These functions return an
250.Vt EVP_CIPHER
251structure that provides the implementation of the symmetric cipher.
252.Sh SEE ALSO
253.Xr AES_encrypt 3 ,
254.Xr evp 3 ,
255.Xr EVP_aes_128_ccm 3 ,
256.Xr EVP_aes_128_gcm 3 ,
257.Xr EVP_EncryptInit 3
258.Sh HISTORY
259.Fn EVP_aes_128_cbc ,
260.Fn EVP_aes_192_cbc ,
261.Fn EVP_aes_256_cbc ,
262.Fn EVP_aes_128_cfb ,
263.Fn EVP_aes_192_cfb ,
264.Fn EVP_aes_256_cfb ,
265.Fn EVP_aes_128_ebc ,
266.Fn EVP_aes_192_ebc ,
267.Fn EVP_aes_256_ebc ,
268.Fn EVP_aes_128_ofb ,
269.Fn EVP_aes_192_ofb ,
270and
271.Fn EVP_aes_256_ofb
272first appeared in OpenSSL 0.9.7 and have been available since
273.Ox 3.2 .
274.Pp
275.Fn EVP_aes_128_cfb1 ,
276.Fn EVP_aes_192_cfb1 ,
277.Fn EVP_aes_256_cfb1 ,
278.Fn EVP_aes_128_cfb8 ,
279.Fn EVP_aes_192_cfb8 ,
280.Fn EVP_aes_256_cfb8 ,
281.Fn EVP_aes_128_cfb128 ,
282.Fn EVP_aes_192_cfb128 ,
283and
284.Fn EVP_aes_256_cfb128
285first appeared in OpenSSL 0.9.7e and have been available since
286.Ox 3.8 .
287.Pp
288.Fn EVP_aes_128_ctr ,
289.Fn EVP_aes_192_ctr ,
290.Fn EVP_aes_256_ctr ,
291.Fn EVP_aes_128_cbc_hmac_sha1 ,
292.Fn EVP_aes_256_cbc_hmac_sha1 ,
293.Fn EVP_aes_128_xts ,
294and
295.Fn EVP_aes_256_xts
296first appeared in OpenSSL 1.0.1 and have been available since
297.Ox 5.3 .
298.Pp
299.Fn EVP_aes_128_wrap ,
300.Fn EVP_aes_192_wrap ,
301and
302.Fn EVP_aes_256_wrap
303first appeared in OpenSSL 1.0.2 and have been available since
304.Ox 6.5 .
diff --git a/src/lib/libcrypto/man/EVP_aes_128_ccm.3 b/src/lib/libcrypto/man/EVP_aes_128_ccm.3
deleted file mode 100644
index e9023a5b67..0000000000
--- a/src/lib/libcrypto/man/EVP_aes_128_ccm.3
+++ /dev/null
@@ -1,573 +0,0 @@
1.\" $OpenBSD: EVP_aes_128_ccm.3,v 1.5 2024/12/29 12:27:28 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100
4.\" OpenSSL EVP_aes.pod a1ec85c1 Apr 21 10:49:12 2020 +0100
5.\"
6.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
7.\"
8.\" Permission to use, copy, modify, and distribute this software for any
9.\" purpose with or without fee is hereby granted, provided that the above
10.\" copyright notice and this permission notice appear in all copies.
11.\"
12.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\"
20.\" This file is a derived work containing a few sentences
21.\" written by Dr. Stephen Henson <steve@openssl.org>
22.\" covered by the following license:
23.\"
24.\" Copyright (c) 2012 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: December 29 2024 $
71.Dt EVP_AES_128_CCM 3
72.Os
73.Sh NAME
74.Nm EVP_aes_128_ccm ,
75.Nm EVP_aes_192_ccm ,
76.Nm EVP_aes_256_ccm
77.Nd EVP AES cipher in Counter with CBC-MAC mode
78.Sh SYNOPSIS
79.In openssl/evp.h
80.Ft const EVP_CIPHER *
81.Fn EVP_aes_128_ccm void
82.Ft const EVP_CIPHER *
83.Fn EVP_aes_192_ccm void
84.Ft const EVP_CIPHER *
85.Fn EVP_aes_256_ccm void
86.\" The following #define'd constants are intentionally undocumented:
87.\" Completely unused by anything:
88.\" EVP_CTRL_CCM_SET_MSGLEN, EVP_CCM_TLS_FIXED_IV_LEN, EVP_CCM_TLS_IV_LEN
89.\" Very rarely used and unused in LibreSSL:
90.\" EVP_CCM_TLS_EXPLICIT_IV_LEN, EVP_CCM_TLS_TAG_LEN, EVP_CCM8_TLS_TAG_LEN
91.Sh DESCRIPTION
92.Fn EVP_aes_128_ccm ,
93.Fn EVP_aes_192_ccm ,
94and
95.Fn EVP_aes_256_ccm
96provide the Advanced Encryption Standard algorithm for 128, 192 and 256-bit
97keys in Counter with CBC-MAC (CCM) mode in the
98.Xr evp 3
99framework.
100This mode supports Authenticated Encryption with Additional Data (AEAD)
101and can be used in a number of communication protocols.
102Longer keys make precomputation attacks harder at a cost in performance.
103.Pp
104For CCM mode ciphers, the behaviour of the EVP interface is subtly
105altered and several additional
106.Xr EVP_CIPHER_CTX_ctrl 3
107operations are required to function correctly.
108Some of the
109.Dv EVP_CTRL_CCM_*
110control commands are older aliases for corresponding
111.Dv EVP_CTRL_AEAD_*
112constants as indicated below.
113.Pp
114The less cumbersome and less error-prone
115.Xr EVP_AEAD_CTX_new 3
116API does not provide CCM modes.
117Some communication protocols support alternatives to CCM, which may
118sometimes allow choosing the better API by avoiding CCM.
119.Ss Configuration controls
120The following two control commands can be issued as soon as
121.Xr EVP_EncryptInit 3
122has been called with a CCM
123.Fa type
124and
125.Dv NULL
126pointers for
127.Fa key
128and
129.Fa iv .
130Both commands are optional and override each other.
131If issued when a nonce is already set, they silently cause data corruption.
132The
133.Fa ptr
134argument is ignored by both; passing
135.Dv NULL
136is recommended.
137.Bl -tag -width Ds
138.It Dv EVP_CTRL_CCM_SET_L
139Set the size
140.Ms L
141of the length field to
142.Fa arg
143bytes and the size of the nonce to
144.No 15 \- Fa arg
145bytes.
146By default, 8 bytes are used for the length field and 7 for the nonce.
147Selecting a smaller size
148.Ms L
149for the length field reduces des maximum size of messages that can be sent,
150but in return allows transmitting more messages with the same key.
151It is an error to pass less than 2 or more than the default value of 8 for
152.Fa arg .
153.It Dv EVP_CTRL_AEAD_SET_IVLEN Pq == Dv EVP_CTRL_CCM_SET_IVLEN
154Set the size of the nonce to
155.Fa arg
156bytes and the size
157.Ms L
158of the length field to
159.No 15 \- Fa arg
160bytes.
161By default, 7 bytes are used for the nonce and 8 for the length field.
162Selecting a larger size of the nonce allows transmitting more messages with
163the same key at the expense of reducing the maximum size for each message.
164It is an error to pass more than 13 or less than the default value of 7 for
165.Fa arg .
166.El
167.Pp
168After optionally issuing one of the above control commands,
169.Xr EVP_EncryptInit 3
170can be called a second time, this time passing
171.Dv NULL
172for the
173.Fa type
174argument, with the other two arguments pointing to the desired AES key
175and to the desired nonce.
176.Ss Encryption controls
177.Bl -tag -width Ds
178.It Dv EVP_CTRL_AEAD_SET_TAG Pq == Dv EVP_CTRL_CCM_SET_TAG
179If the
180.Fa ptr
181argument is
182.Dv NULL ,
183set the tag length
184.Ms M
185to
186.Fa arg
187bytes.
188The default value is 12.
189Selecting a larger value makes tampering harder for an attacker,
190at a small expense of making the messages slightly longer.
191Selecting a smaller value is not recommended.
192It is an error to pass an odd number for
193.Fa arg ,
194or a number that is less than 4 or greater than 16, or to pass
195.Dv NULL
196to
197.Fa ptr
198when
199.Fa ctx
200is not configured for encrypting.
201Issuing this control command when an encryption key is already configured
202silently causes data corruption.
203.It Dv EVP_CTRL_AEAD_GET_TAG Pq == Dv EVP_CTRL_CCM_GET_TAG
204Store the
205.Fa arg
206bytes of the tag in the memory provided by the caller starting at
207.Fa ptr .
208It is an error to issue this control command when
209.Fa ctx
210is not configured for encrypting, when no data was encrypted yet, with an
211.Fa arg
212that does not match the configured tag length
213.Ms M ,
214or when the tag has already been retrieved earlier.
215.El
216.Pp
217Before passing any plaintext data to
218.Xr EVP_EncryptUpdate 3 ,
219call
220.Xr EVP_EncryptUpdate 3
221with both
222.Fa in
223and
224.Fa out
225set to
226.Dv NULL ,
227passing the total plaintext length in bytes as
228.Fa in_len .
229This constructs the first block to be digested with CBC-MAC
230and copies the text length to
231.Pf * Fa out_len .
232It does not check whether
233.Fa in_len
234exceeds the limit of
235.Pf 256\(ha Ms L ;
236the most significant bytes of excessive values are silently discarded.
237.Pp
238It is an error if the
239.Fa in_len
240argument of the
241.Xr EVP_EncryptUpdate 3
242call passing the plaintext data does not match the total length
243specified earlier.
244Splitting the text into more than one chunks to be passed in multiple calls of
245.Xr EVP_EncryptUpdate 3
246is not supported for CCM.
247.Pp
248To specify any additional authenticated data (AAD), call
249.Xr EVP_EncryptUpdate 3
250with the
251.Fa out
252argument set to
253.Dv NULL .
254.Ss Decryption controls
255.Bl -tag -width Ds
256.It Dv EVP_CTRL_AEAD_SET_TAG Pq == Dv EVP_CTRL_CCM_SET_TAG
257If the
258.Fa ptr
259argument is not
260.Dv NULL ,
261copy
262.Fa arg
263bytes starting at
264.Fa ptr
265to the expected CCM tag value.
266It is an error to pass an odd number for
267.Fa arg ,
268or a number that is less than 4 or greater than 16.
269Passing a number that does not correspond to the tag length
270.Ms M
271that was used for encryption does not raise an error right away,
272but results in undefined behaviour
273and typically causes subsequent authentication failure.
274It is also an error to pass a
275.Pf non- Dv NULL
276.Fa ptr
277when
278.Fa ctx
279is configured for encryption.
280.El
281.Pp
282Before passing any ciphertext data to
283.Xr EVP_DecryptUpdate 3 ,
284call
285.Xr EVP_DecryptUpdate 3
286with both
287.Fa in
288and
289.Fa out
290set to
291.Dv NULL ,
292passing the total ciphertext length in bytes as
293.Fa in_len .
294This constructs the first block to be digested with CBC-MAC
295and copies the text length to
296.Pf * Fa out_len .
297It does not check whether
298.Fa in_len
299exceeds the limit of
300.Pf 256\(ha Ms L ;
301the most significant bytes of excessive values are silently discarded.
302.Pp
303It is an error if the
304.Fa in_len
305argument of the
306.Xr EVP_DecryptUpdate 3
307call passing the ciphertext data does not match the total length
308specified earlier.
309Splitting the text into more than one chunks to be passed in multiple calls of
310.Xr EVP_DecryptUpdate 3
311is not supported for CCM.
312.Pp
313To specify any additional authenticated data (AAD), call
314.Xr EVP_DecryptUpdate 3
315with the
316.Fa out
317argument set to
318.Dv NULL .
319.Pp
320If the return value of
321.Xr EVP_DecryptUpdate 3
322does not indicate success, the authentication operation may have failed.
323In that case, regard any output data as corrupted.
324.Pp
325Do not call
326.Xr EVP_DecryptFinal 3
327when using CCM.
328Such a call would not do anything useful, and it would fail
329because the tag that was set with
330.Dv EVP_CTRL_CCM_SET_TAG
331was already consumed by
332.Xr EVP_DecryptUpdate 3 .
333.Sh RETURN VALUES
334These functions return a static constant
335.Vt EVP_CIPHER
336structure that provides the implementation of the respective AEAD cipher mode.
337.Sh EXAMPLES
338The following code encrypts and digests some secret text
339and some additional, public data with AES-CCM.
340Specifically, it implements the Test Vector #1
341given in section 8 of RFC 3610.
342.Bd -literal -offset indent
343/* input data */
344const unsigned char key[] = {
345 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
346 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
347};
348const unsigned char nonce[] = {
349 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
350 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
351};
352const int nonce_len = sizeof(nonce);
353const int size_len = 15 - nonce_len;
354
355const unsigned char aad[] = {
356 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
357};
358const int aad_len = sizeof(aad);
359
360const unsigned char plaintext[] = {
361 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
362 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
363 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E
364};
365const int text_len = sizeof(plaintext);
366
367/* expected output data */
368const unsigned char ciphertext[] = {
369 0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
370 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
371 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84
372};
373
374const unsigned char wanted_tag[] = {
375 0x17, 0xE8, 0xD1, 0x2C, 0xFD, 0xF9, 0x26, 0xE0
376};
377const int tag_len = sizeof(wanted_tag);
378
379const int out_len = aad_len + text_len + tag_len;
380unsigned char out_buf[out_len];
381unsigned char *out_p = out_buf;
382unsigned char *out_end = out_buf + out_len;
383
384/* auxiliary variables */
385EVP_CIPHER_CTX *ctx;
386int irv, i;
387
388/* configuration */
389ctx = EVP_CIPHER_CTX_new();
390if (ctx == NULL)
391 err(1, "EVP_CIPHER_CTX_new");
392
393if (EVP_EncryptInit(ctx, EVP_aes_128_ccm(), NULL, NULL) != 1)
394 err(1, "EVP_EncryptInit(NULL)");
395
396if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_L,
397 size_len, NULL) <= 0)
398 err(1, "EVP_CTRL_CCM_SET_L(%d)", size_len);
399
400if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG,
401 tag_len, NULL) <= 0)
402 err(1, "EVP_CTRL_CCM_SET_TAG(%d)", tag_len);
403
404/* process input data */
405if (EVP_EncryptInit(ctx, NULL, key, nonce) != 1)
406 err(1, "EVP_EncryptInit(key, nonce)");
407
408if (EVP_EncryptUpdate(ctx, NULL, &irv, NULL, text_len) != 1)
409 err(1, "EVP_EncryptUpdate(len = %d)", text_len);
410if (irv != text_len)
411 errx(1, "text length: want %d, got %d", text_len, irv);
412
413irv = -1;
414if (EVP_EncryptUpdate(ctx, NULL, &irv, aad, aad_len) != 1)
415 err(1, "EVP_EncryptUpdate(AAD)");
416memcpy(out_p, aad, aad_len);
417out_p += aad_len;
418
419irv = -1;
420if (EVP_EncryptUpdate(ctx, out_p, &irv, plaintext, text_len) != 1)
421 err(1, "EVP_EncryptUpdate(plaintext)");
422if (irv != text_len)
423 errx(1, "text_len: want %d, got %d", text_len, irv);
424out_p += irv;
425
426/*
427 * EVP_EncryptFinal(3) doesn't really do anything for CCM.
428 * Call it anyway to stay closer to normal EVP_Encrypt*(3) idioms,
429 * to match what the OpenSSL Wiki suggests since 2013, and to ease
430 * later migration of the code to a different AEAD algorithm.
431 */
432irv = -1;
433if (EVP_EncryptFinal(ctx, out_p, &irv) != 1)
434 err(1, "EVP_EncryptFinal");
435if (irv != 0)
436 errx(1, "final_len: want 0, got %d", irv);
437
438/* check output data */
439if (memcmp(out_buf + aad_len, ciphertext, text_len) != 0)
440 errx(1, "ciphertext mismatch");
441
442if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_GET_TAG,
443 tag_len, out_p) <= 0)
444 err(1, "EVP_CTRL_CCM_GET_TAG");
445if (memcmp(out_p, wanted_tag, tag_len) != 0)
446 errx(1, "tag mismatch");
447out_p += tag_len;
448if (out_p != out_end)
449 errx(1, "end of output: want %p, got %p", out_end, out_p);
450
451printf("Total packet length = %d.", out_len);
452printf(" [Authenticated and Encrypted Output]");
453for (i = 0; i < out_len; i++) {
454 if (i % 16 == 0)
455 printf("\en ");
456 if (i % 4 == 0)
457 putchar(' ');
458 printf(" %02X", out_buf[i]);
459}
460putchar('\en');
461
462EVP_CIPHER_CTX_free(ctx);
463.Ed
464.Pp
465The reverse operation for the same test vector,
466i.e. decrypting and comparing the digest,
467is implemented by the following code.
468.Pp
469The variable declarations and definitions up to the call of
470.Xr EVP_CIPHER_CTX_new 3
471are the same as above.
472The chief differences are:
473.Bl -dash -width 1n -compact
474.It
475The tag is not part of the output,
476so the total output length is shorter.
477.It
478No
479.Xr memcmp 3
480of the tag takes place.
481Instead, the control command
482.Dv EVP_CTRL_CCM_SET_TAG
483requires the tag that is going to be verified as an additional argument.
484.It
485While
486.Xr EVP_EncryptFinal 3
487is an optional no-op,
488.Xr EVP_DecryptFinal 3
489is not called and would fail.
490.El
491.Bd -literal -offset indent
492const int out_len = aad_len + text_len;
493
494/* configuration */
495ctx = EVP_CIPHER_CTX_new();
496if (ctx == NULL)
497 err(1, "EVP_CIPHER_CTX_new");
498
499if (EVP_DecryptInit(ctx, EVP_aes_128_ccm(), NULL, NULL) != 1)
500 err(1, "EVP_DecryptInit(NULL)");
501
502if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_L, size_len, NULL) <= 0)
503 err(1, "EVP_CTRL_CCM_SET_L(%d)", size_len);
504
505if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG,
506 tag_len, (void *)wanted_tag) <= 0)
507 err(1, "EVP_CTRL_CCM_SET_TAG(%d)", tag_len);
508
509/* process input data */
510if (EVP_DecryptInit(ctx, NULL, key, nonce) != 1)
511 err(1, "EVP_DecryptInit(key, nonce)");
512
513if (EVP_DecryptUpdate(ctx, NULL, &irv, NULL, text_len) != 1)
514 err(1, "EVP_DecryptUpdate(len = %d)", text_len);
515if (irv != text_len)
516 errx(1, "text length: want %d, got %d", text_len, irv);
517
518irv = -1;
519if (EVP_DecryptUpdate(ctx, NULL, &irv, aad, aad_len) != 1)
520 err(1, "EVP_DecryptUpdate(AAD)");
521memcpy(out_p, aad, aad_len);
522out_p += aad_len;
523
524irv = -1;
525if (EVP_DecryptUpdate(ctx, out_p, &irv, ciphertext, text_len) != 1)
526 err(1, "EVP_DecryptUpdate(ciphertext)");
527if (irv != text_len)
528 errx(1, "text_len: want %d, got %d", text_len, irv);
529out_p += irv;
530
531/* Do not call EVP_DecryptFinal(3); it would fail and do nothing. */
532
533/* check output data */
534if (memcmp(out_buf + aad_len, plaintext, text_len) != 0)
535 errx(1, "plaintext mismatch");
536if (out_p != out_end)
537 errx(1, "end of output: want %p, got %p", out_end, out_p);
538
539printf("Total packet length = %d.", out_len);
540printf(" [Decrypted and Authenticated Input]");
541for (i = 0; i < out_len; i++) {
542 if (i % 16 == 0)
543 printf("\n ");
544 if (i % 4 == 0)
545 putchar(' ');
546 printf(" %02X", out_buf[i]);
547}
548putchar('\n');
549
550EVP_CIPHER_CTX_free(ctx);
551.Ed
552.Sh SEE ALSO
553.Xr AES_encrypt 3 ,
554.Xr evp 3 ,
555.Xr EVP_aes_128_cbc 3 ,
556.Xr EVP_aes_128_gcm 3 ,
557.Xr EVP_EncryptInit 3
558.Sh STANDARDS
559.Rs
560.%A Doug Whiting
561.%A Russ Housley
562.%A Niels Ferguson
563.%T Counter with CBC-MAC (CCM)
564.%R RFC 3610
565.%D September 2003
566.Re
567.Sh HISTORY
568.Fn EVP_aes_128_ccm ,
569.Fn EVP_aes_192_ccm ,
570and
571.Fn EVP_aes_256_ccm
572first appeared in OpenSSL 1.0.1 and have been available since
573.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/EVP_aes_128_gcm.3 b/src/lib/libcrypto/man/EVP_aes_128_gcm.3
deleted file mode 100644
index 53c41ea162..0000000000
--- a/src/lib/libcrypto/man/EVP_aes_128_gcm.3
+++ /dev/null
@@ -1,254 +0,0 @@
1.\" $OpenBSD: EVP_aes_128_gcm.3,v 1.2 2024/12/29 12:27:28 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100
4.\" OpenSSL EVP_aes.pod a1ec85c1 Apr 21 10:49:12 2020 +0100
5.\"
6.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
7.\"
8.\" Permission to use, copy, modify, and distribute this software for any
9.\" purpose with or without fee is hereby granted, provided that the above
10.\" copyright notice and this permission notice appear in all copies.
11.\"
12.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\"
20.\" This file is a derived work containing a few sentences
21.\" written by Dr. Stephen Henson <steve@openssl.org>
22.\" covered by the following license:
23.\"
24.\" Copyright (c) 2012 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: December 29 2024 $
71.Dt EVP_AES_128_GCM 3
72.Os
73.Sh NAME
74.Nm EVP_aes_128_gcm ,
75.Nm EVP_aes_192_gcm ,
76.Nm EVP_aes_256_gcm
77.Nd EVP AES cipher in Galois Counter Mode
78.Sh SYNOPSIS
79.In openssl/evp.h
80.Ft const EVP_CIPHER *
81.Fn EVP_aes_128_gcm void
82.Ft const EVP_CIPHER *
83.Fn EVP_aes_192_gcm void
84.Ft const EVP_CIPHER *
85.Fn EVP_aes_256_gcm void
86.Sh DESCRIPTION
87.Fn EVP_aes_128_gcm ,
88.Fn EVP_aes_192_gcm ,
89and
90.Fn EVP_aes_256_gcm
91provide the Advanced Encryption Standard algorithm for 128, 192 and 256-bit
92keys in and Galois Counter Mode in the
93.Xr evp 3
94framework.
95.Pp
96For GCM mode ciphers, the behaviour of the EVP interface is subtly
97altered and several additional
98.Xr EVP_CIPHER_CTX_ctrl 3
99operations are required to function correctly.
100Some of the
101.Dv EVP_CTRL_GCM_*
102control commands are older aliases for corresponding
103.Dv EVP_CTRL_AEAD_*
104constants as indicated below.
105.Pp
106To avoid using the cumbersome and error-prone API documented
107in the present manual page, consider using the functions documented in
108.Xr EVP_AEAD_CTX_init 3
109instead.
110.Ss Configuration controls
111.\" The following constants are intentionally undocumented
112.\" because they are very rarely used in application programs:
113.\" EVP_GCM_TLS_FIXED_IV_LEN (unused in the library)
114.\" EVP_GCM_TLS_EXPLICIT_IV_LEN and EVP_GCM_TLS_TAG_LEN (used internally
115.\" only in aes_gcm_tls_cipher(), which is unused)
116.Bl -tag -width Ds
117.It Dv EVP_CTRL_AEAD_SET_IVLEN Pq == Dv EVP_CTRL_GCM_SET_IVLEN
118Set the length of the initialization vector to
119.Fa arg
120bytes; the
121.Fa ptr
122argument is ignored and passing
123.Dv NULL
124is recommended.
125This call can only be made before specifying an initialization vector.
126If not called, the default IV length of 12 bytes is used.
127.Pp
128Using this control command is discouraged because section 5.2.1.1 of the
129specification explicitly recommends that implementations of GCM restrict
130support to the default IV length of 12 bytes for interoperability,
131efficiency, and simplicity of design.
132.It Dv EVP_CTRL_AEAD_SET_IV_FIXED Pq == Dv EVP_CTRL_GCM_SET_IV_FIXED
133Usually, \-1 is passed for
134.Fa arg .
135In that case, the complete initialization vector is copied from
136.Fa ptr .
137.Pp
138Otherwise, set the fixed field at the beginning of the initialization
139vector to the
140.Fa arg
141bytes pointed to by
142.Fa ptr .
143When encrypting, also generate the remaining bytes
144of the initialization vector at random.
145It is an error to specify an
146.Fa arg
147that is less than 4 or so large that less than 8 bytes remain.
148.El
149.Ss Encryption controls
150.Bl -tag -width Ds
151.It Dv EVP_CTRL_GCM_IV_GEN
152Generate the precounter block from the initialization vector,
153copy the last
154.Fa arg
155bytes of the initialization vector to the location pointed to by
156.Fa ptr ,
157or all of it if
158.Fa arg
159is less than 1 or greater than the length of the initialization vector,
160and increment the initialization vector by 1.
161Incrementing ignores the IV length and the fixed field length
162that may have been configured earlier and always operates on the
163last eight bytes of the initialization vector.
164It is an error to issue this command
165when no key or no initialization vector is set.
166.It Dv EVP_CTRL_AEAD_GET_TAG Pq == Dv EVP_CTRL_GCM_GET_TAG
167Write
168.Fa arg
169bytes of the tag value to the location pointed to by
170.Fa ptr .
171This control command only makes sense after all data has been processed,
172e.g. after calling
173.Xr EVP_EncryptFinal 3 .
174It is an error to issue this command while decrypting,
175before any data has been processed, or to specify an
176.Fa arg
177that is less than 1 or greater than 16.
178.El
179.Pp
180To specify any additional authenticated data (AAD), call
181.Xr EVP_EncryptUpdate 3
182with the
183.Fa out
184argument set to
185.Dv NULL .
186.Ss Decryption controls
187.Bl -tag -width Ds
188.It Dv EVP_CTRL_GCM_SET_IV_INV
189Copy
190.Fa arg
191bytes from
192.Fa ptr
193to the last bytes of the initialization vector
194and generate the precounter block from the initialization vector.
195The library does not check whether the arguments are consistent
196with the configured initialization vector and fixed field lengths.
197When default lengths are in use, pass 8 for
198.Fa arg .
199In that case, this control command sets the invocation field.
200It is an error to issue this command
201when no key or no initialization vector is set, or when encrypting.
202.It Dv EVP_CTRL_AEAD_SET_TAG Pq == Dv EVP_CTRL_GCM_SET_TAG
203Set the expected tag to the
204.Fa arg
205bytes located at
206.Fa ptr .
207This control command is mandatory before any data is processed,
208e.g. before calling
209.Xr EVP_DecryptUpdate 3 .
210It is an error to issue this command while encrypting or to specify an
211.Fa arg
212that is less than 1 or greater than 16.
213.El
214.Pp
215To specify any additional authenticated data (AAD), call
216.Xr EVP_DecryptUpdate 3
217with the
218.Fa out
219argument set to
220.Dv NULL .
221.Pp
222If the return value of
223.Xr EVP_DecryptFinal 3 ,
224.Xr EVP_DecryptFinal_ex 3 ,
225.Xr EVP_CipherFinal 3 ,
226or
227.Xr EVP_CipherFinal_ex 3
228does not indicate success when decrypting,
229the authentication operation failed.
230In that case, regard any output data as corrupted.
231.Sh SEE ALSO
232.Xr AES_encrypt 3 ,
233.Xr evp 3 ,
234.Xr EVP_AEAD_CTX_init 3 ,
235.Xr EVP_aes_128_cbc 3 ,
236.Xr EVP_CIPHER_CTX_ctrl 3 ,
237.Xr EVP_EncryptInit 3
238.Sh STANDARDS
239.Rs
240.%A Morris Dworkin
241.%I National Institute of Standards and Technology
242.%R Recommendation for Block Cipher Modes of Operation:\
243 Galois/Counter Mode (GCM) and GMAC
244.%N NIST Special Publication 800-38D
245.%C Gaithersburg, Maryland
246.%D November 2007
247.Re
248.Sh HISTORY
249.Fn EVP_aes_128_gcm ,
250.Fn EVP_aes_192_gcm ,
251and
252.Fn EVP_aes_256_gcm
253first appeared in OpenSSL 1.0.1 and have been available since
254.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/EVP_camellia_128_cbc.3 b/src/lib/libcrypto/man/EVP_camellia_128_cbc.3
deleted file mode 100644
index 6f15a85f7f..0000000000
--- a/src/lib/libcrypto/man/EVP_camellia_128_cbc.3
+++ /dev/null
@@ -1,151 +0,0 @@
1.\" $OpenBSD: EVP_camellia_128_cbc.3,v 1.3 2024/11/09 22:03:49 schwarze Exp $
2.\" selective merge up to: OpenSSL 7c6d372a Nov 20 13:20:01 2018 +0000
3.\"
4.\" This file was written by Ronald Tse <ronald.tse@ribose.com>
5.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: November 9 2024 $
52.Dt EVP_CAMELLIA_128_CBC 3
53.Os
54.Sh NAME
55.Nm EVP_camellia_128_cbc ,
56.Nm EVP_camellia_192_cbc ,
57.Nm EVP_camellia_256_cbc ,
58.Nm EVP_camellia_128_cfb ,
59.Nm EVP_camellia_192_cfb ,
60.Nm EVP_camellia_256_cfb ,
61.Nm EVP_camellia_128_cfb1 ,
62.Nm EVP_camellia_192_cfb1 ,
63.Nm EVP_camellia_256_cfb1 ,
64.Nm EVP_camellia_128_cfb8 ,
65.Nm EVP_camellia_192_cfb8 ,
66.Nm EVP_camellia_256_cfb8 ,
67.Nm EVP_camellia_128_cfb128 ,
68.Nm EVP_camellia_192_cfb128 ,
69.Nm EVP_camellia_256_cfb128 ,
70.Nm EVP_camellia_128_ecb ,
71.Nm EVP_camellia_192_ecb ,
72.Nm EVP_camellia_256_ecb ,
73.Nm EVP_camellia_128_ofb ,
74.Nm EVP_camellia_192_ofb ,
75.Nm EVP_camellia_256_ofb
76.Nd EVP Camellia cipher
77.Sh SYNOPSIS
78.In openssl/evp.h
79.Ft const EVP_CIPHER *
80.Fn EVP_camellia_128_cbc void
81.Ft const EVP_CIPHER *
82.Fn EVP_camellia_192_cbc void
83.Ft const EVP_CIPHER *
84.Fn EVP_camellia_256_cbc void
85.Ft const EVP_CIPHER *
86.Fn EVP_camellia_128_cfb void
87.Ft const EVP_CIPHER *
88.Fn EVP_camellia_192_cfb void
89.Ft const EVP_CIPHER *
90.Fn EVP_camellia_256_cfb void
91.Ft const EVP_CIPHER *
92.Fn EVP_camellia_128_cfb1 void
93.Ft const EVP_CIPHER *
94.Fn EVP_camellia_192_cfb1 void
95.Ft const EVP_CIPHER *
96.Fn EVP_camellia_256_cfb1 void
97.Ft const EVP_CIPHER *
98.Fn EVP_camellia_128_cfb8 void
99.Ft const EVP_CIPHER *
100.Fn EVP_camellia_192_cfb8 void
101.Ft const EVP_CIPHER *
102.Fn EVP_camellia_256_cfb8 void
103.Ft const EVP_CIPHER *
104.Fn EVP_camellia_128_cfb128 void
105.Ft const EVP_CIPHER *
106.Fn EVP_camellia_192_cfb128 void
107.Ft const EVP_CIPHER *
108.Fn EVP_camellia_256_cfb128 void
109.Ft const EVP_CIPHER *
110.Fn EVP_camellia_128_ecb void
111.Ft const EVP_CIPHER *
112.Fn EVP_camellia_192_ecb void
113.Ft const EVP_CIPHER *
114.Fn EVP_camellia_256_ecb void
115.Ft const EVP_CIPHER *
116.Fn EVP_camellia_128_ofb void
117.Ft const EVP_CIPHER *
118.Fn EVP_camellia_192_ofb void
119.Ft const EVP_CIPHER *
120.Fn EVP_camellia_256_ofb void
121.Sh DESCRIPTION
122These functions provide the Camellia encryption algorithm in the
123.Xr evp 3
124framework.
125Camellia is a block cipher operating on 128 bit blocks.
126These functions use 128, 192, and 256-bit keys
127in the following modes, respectively:
128CBC, CFB with 1-bit shift, CFB with 8-bit shift, CFB with 128-bit shift,
129ECB, and OFB.
130.Pp
131.Fn EVP_camellia_128_cfb ,
132.Fn EVP_camellia_192_cfb ,
133and
134.Fn EVP_camellia_256_cfb
135are aliases for
136.Fn EVP_camellia_128_cfb128 ,
137.Fn EVP_camellia_192_cfb128 ,
138and
139.Fn EVP_camellia_256_cfb128 ,
140implemented as macros.
141.Sh RETURN VALUES
142These functions return an
143.Vt EVP_CIPHER
144structure that provides the implementation of the symmetric cipher.
145.Sh SEE ALSO
146.Xr evp 3 ,
147.Xr EVP_EncryptInit 3
148.Sh HISTORY
149These functions first appeared in OpenSSL 0.9.8c
150and have been available since
151.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/EVP_chacha20.3 b/src/lib/libcrypto/man/EVP_chacha20.3
deleted file mode 100644
index 8fc79dbf2b..0000000000
--- a/src/lib/libcrypto/man/EVP_chacha20.3
+++ /dev/null
@@ -1,292 +0,0 @@
1.\" $OpenBSD: EVP_chacha20.3,v 1.8 2024/12/09 11:55:52 schwarze Exp $
2.\" full merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ronald Tse <ronald.tse@ribose.com>.
22.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 9 2024 $
69.Dt EVP_CHACHA20 3
70.Os
71.Sh NAME
72.Nm EVP_chacha20 ,
73.Nm EVP_chacha20_poly1305
74.Nd ChaCha20 stream cipher for EVP
75.Sh SYNOPSIS
76.In openssl/evp.h
77.Ft const EVP_CIPHER *
78.Fn EVP_chacha20 void
79.Ft const EVP_CIPHER *
80.Fn EVP_chacha20_poly1305 void
81.Sh DESCRIPTION
82.Fn EVP_chacha20
83provides the ChaCha20 stream cipher in the EVP framework.
84.Xr EVP_EncryptInit_ex 3 ,
85.Xr EVP_DecryptInit_ex 3 ,
86and
87.Xr EVP_CipherInit_ex 3
88take a
89.Fa key
90argument of 32 bytes = 256 bits and an
91.Fa iv
92argument of 16 bytes = 128 bits, internally using
93.Xr ChaCha_set_key 3
94and
95.Xr ChaCha_set_iv 3 .
96The lower 8 bytes = 64 bits of
97.Fa iv
98are used as counter and the remaining 8 bytes are used as
99the initialization vector of
100.Xr ChaCha_set_iv 3 .
101.Xr EVP_EncryptUpdate 3 ,
102.Xr EVP_EncryptFinal_ex 3 ,
103.Xr EVP_DecryptUpdate 3 ,
104and
105.Xr EVP_DecryptFinal_ex 3
106internally use
107.Xr ChaCha 3
108to perform encryption and decryption.
109.Xr EVP_CIPHER_CTX_ctrl 3
110always fails for
111.Fa ctx
112objects created from
113.Fn EVP_chacha20 .
114.Pp
115.Fn EVP_chacha20_poly1305
116provides authenticated encryption with ChaCha20-Poly1305.
117Unless compatibility with other implementations
118like OpenSSL or BoringSSL is required, using
119.Xr EVP_AEAD_CTX_init 3
120with
121.Xr EVP_aead_chacha20_poly1305 3
122is recommended instead because the code then becomes transparent
123to the AEAD cipher used, more flexible, and less error prone.
124.Pp
125With
126.Fn EVP_chacha20_poly1305 ,
127.Xr EVP_EncryptInit_ex 3 ,
128.Xr EVP_DecryptInit_ex 3 ,
129and
130.Xr EVP_CipherInit_ex 3
131take a
132.Fa key
133argument of 32 bytes = 256 bits and an
134.Fa iv
135argument of 12 bytes = 96 bits.
136This supports additional authenticated data (AAD) and produces a 128-bit
137authentication tag.
138The constant
139.Dv EVP_CHACHAPOLY_TLS_TAG_LEN
140specifies the length of the authentication tag in bytes and has a value of 16.
141.Pp
142The following
143.Fa type
144arguments are supported for
145.Xr EVP_CIPHER_CTX_ctrl 3 :
146.Bl -tag -width Ds
147.It Dv EVP_CTRL_AEAD_GET_TAG
148Copy the number of bytes indicated by the
149.Fa arg
150argument from the tag to the location indicated by the
151.Fa ptr
152argument;
153to be called after
154.Xr EVP_EncryptFinal_ex 3 .
155This control operation fails if the
156.Fa ctx
157is not configured for encryption or if
158.Fa arg
159is less than 1 or greater than 16.
160.It Dv EVP_CTRL_AEAD_SET_TAG
161Copy the number of bytes indicated by the
162.Fa arg
163argument from the location indicated by the
164.Fa ptr
165argument and designate them as the expected tag length and tag,
166causing subsequent
167.Xr EVP_DecryptFinal_ex 3
168to fail if the tag calculated during decryption does not match.
169It is strongly recommended to specify
170.Fa arg
171as exactly 16.
172Otherwise, only the initial part of the tag may be compared
173and mismatches near the end of the tag may get silently ignored.
174This control operation fails if the
175.Fa ctx
176is configured for encryption or if
177.Fa arg
178is less than 1 or greater than 16.
179If the
180.Fa ptr
181argument is a
182.Dv NULL
183pointer, this control operation succeeds without having any effect.
184.It Dv EVP_CTRL_AEAD_SET_IV_FIXED
185Set the initialization vector by reading the 12 bytes pointed to by the
186.Fa ptr
187argument, independently of
188.Xr EVP_EncryptInit_ex 3 ,
189.Xr EVP_DecryptInit_ex 3 ,
190and
191.Xr EVP_CipherInit_ex 3 .
192This control operation fails if the
193.Fa arg
194argument is not exactly 12.
195.It Dv EVP_CTRL_AEAD_SET_IVLEN
196Instruct subsequent
197.Xr EVP_EncryptInit_ex 3 ,
198.Xr EVP_DecryptInit_ex 3 ,
199or
200.Xr EVP_CipherInit_ex 3
201to expect an
202.Fa iv
203argument shorter than the default of 12 bytes; the
204.Fa arg
205argument specifies the number of bytes to be used.
206The initialization functions will only read
207the specified smaller number of bytes from
208.Fa iv
209and internally zero-pad them on the left.
210Using this is not recommended because it is likely more fragile
211and less often tested than the equivalent method of simply providing
212a full-sized
213.Fa iv .
214This control operation fails if
215.Fa arg
216is less than 1 or greater than 16.
217.It Dv EVP_CTRL_INIT
218Set the length of the initialization vector to the default value
219of 12 bytes and clear the Poly1305 internal state.
220The application program usually does not need to invoke this control
221operation manually because it is automatically called internally by
222.Xr EVP_EncryptInit_ex 3 ,
223.Xr EVP_DecryptInit_ex 3 ,
224and
225.Xr EVP_CipherInit_ex 3 .
226.El
227.Sh RETURN VALUES
228.Fn EVP_chacha20
229and
230.Fn EVP_chacha20_poly1305
231return pointers to static
232.Vt EVP_CIPHER
233objects that contain the implementations of the symmetric cipher.
234.Pp
235If
236.Fa ctx
237was created from
238.Fn EVP_chacha20
239or
240.Fn EVP_chacha20_poly1305 ,
241.Xr EVP_CIPHER_CTX_ctrl 3
242returns 1 for success or 0 for failure.
243.Sh SEE ALSO
244.Xr ChaCha 3 ,
245.Xr evp 3 ,
246.Xr EVP_aead_chacha20_poly1305 3 ,
247.Xr EVP_CIPHER_meth_new 3 ,
248.Xr EVP_EncryptInit 3
249.Sh STANDARDS
250.Rs
251.%A A. Langley
252.%A W. Chang
253.%A N. Mavrogiannopoulos
254.%A J. Strombergson
255.%A S. Josefsson
256.%D June 2016
257.%R RFC 7905
258.%T ChaCha20-Poly1305 Cipher Suites for Transport Layer Security (TLS)
259.Re
260.Sh HISTORY
261.Fn EVP_chacha20
262first appeared in
263.Ox 5.6 .
264.Pp
265.Fn EVP_chacha20_poly1305
266first appeared in OpenSSL 1.1.0
267.\" OpenSSL commit bd989745 Dec 9 21:30:56 2015 +0100 Andy Polyakov
268and has been available since
269.Ox 7.2 .
270.Sh CAVEATS
271The original publications and code by
272.An Adam Langley
273used a modified AEAD construction that is incompatible with the common
274style used by AEAD in TLS and incompatible with RFC 7905:
275.Pp
276.Rs
277.%A A. Langley
278.%A W. Chang
279.%D November 2013
280.%R draft-agl-tls-chacha20poly1305-04
281.%T ChaCha20 and Poly1305 based Cipher Suites for TLS
282.Re
283.Pp
284.Rs
285.%A Y. Nir
286.%A A. Langley
287.%D May 2018
288.%R RFC 8439
289.%T ChaCha20 and Poly1305 for IETF Protocols
290.Re
291.Pp
292In particular, the original version used a nonce of 8 instead of 12 bytes.
diff --git a/src/lib/libcrypto/man/EVP_des_cbc.3 b/src/lib/libcrypto/man/EVP_des_cbc.3
deleted file mode 100644
index 7c8a08c7db..0000000000
--- a/src/lib/libcrypto/man/EVP_des_cbc.3
+++ /dev/null
@@ -1,230 +0,0 @@
1.\" $OpenBSD: EVP_des_cbc.3,v 1.2 2024/11/09 22:03:49 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL EVP_desx_cbc.pod 8fa4d95e Oct 21 11:59:09 2017 +0900
4.\" selective merge up to:
5.\" OpenSSL EVP_des.pod 7c6d372a Nov 20 13:20:01 2018 +0000
6.\"
7.\" This file was written by Ronald Tse <ronald.tse@ribose.com>
8.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\"
14.\" 1. Redistributions of source code must retain the above copyright
15.\" notice, this list of conditions and the following disclaimer.
16.\"
17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\" notice, this list of conditions and the following disclaimer in
19.\" the documentation and/or other materials provided with the
20.\" distribution.
21.\"
22.\" 3. All advertising materials mentioning features or use of this
23.\" software must display the following acknowledgment:
24.\" "This product includes software developed by the OpenSSL Project
25.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
26.\"
27.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
28.\" endorse or promote products derived from this software without
29.\" prior written permission. For written permission, please contact
30.\" openssl-core@openssl.org.
31.\"
32.\" 5. Products derived from this software may not be called "OpenSSL"
33.\" nor may "OpenSSL" appear in their names without prior written
34.\" permission of the OpenSSL Project.
35.\"
36.\" 6. Redistributions of any form whatsoever must retain the following
37.\" acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
40.\"
41.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
42.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
45.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\"
54.Dd $Mdocdate: November 9 2024 $
55.Dt EVP_DES_CBC 3
56.Os
57.Sh NAME
58.Nm EVP_des_cbc ,
59.Nm EVP_des_cfb ,
60.Nm EVP_des_cfb1 ,
61.Nm EVP_des_cfb8 ,
62.Nm EVP_des_cfb64 ,
63.Nm EVP_des_ecb ,
64.Nm EVP_des_ofb ,
65.Nm EVP_des_ede ,
66.Nm EVP_des_ede_cbc ,
67.Nm EVP_des_ede_cfb ,
68.Nm EVP_des_ede_cfb64 ,
69.Nm EVP_des_ede_ecb ,
70.Nm EVP_des_ede_ofb ,
71.Nm EVP_des_ede3 ,
72.Nm EVP_des_ede3_cbc ,
73.Nm EVP_des_ede3_cfb ,
74.Nm EVP_des_ede3_cfb1 ,
75.Nm EVP_des_ede3_cfb8 ,
76.Nm EVP_des_ede3_cfb64 ,
77.Nm EVP_des_ede3_ecb ,
78.Nm EVP_des_ede3_ofb ,
79.Nm EVP_desx_cbc
80.Nd EVP DES cipher
81.Sh SYNOPSIS
82.In openssl/evp.h
83.Ft const EVP_CIPHER *
84.Fn EVP_des_cbc void
85.Ft const EVP_CIPHER *
86.Fn EVP_des_cfb void
87.Ft const EVP_CIPHER *
88.Fn EVP_des_cfb1 void
89.Ft const EVP_CIPHER *
90.Fn EVP_des_cfb8 void
91.Ft const EVP_CIPHER *
92.Fn EVP_des_cfb64 void
93.Ft const EVP_CIPHER *
94.Fn EVP_des_ecb void
95.Ft const EVP_CIPHER *
96.Fn EVP_des_ofb void
97.Ft const EVP_CIPHER *
98.Fn EVP_des_ede void
99.Ft const EVP_CIPHER *
100.Fn EVP_des_ede_cbc void
101.Ft const EVP_CIPHER *
102.Fn EVP_des_ede_cfb void
103.Ft const EVP_CIPHER *
104.Fn EVP_des_ede_cfb64 void
105.Ft const EVP_CIPHER *
106.Fn EVP_des_ede_ecb void
107.Ft const EVP_CIPHER *
108.Fn EVP_des_ede_ofb void
109.Ft const EVP_CIPHER *
110.Fn EVP_des_ede3 void
111.Ft const EVP_CIPHER *
112.Fn EVP_des_ede3_cbc void
113.Ft const EVP_CIPHER *
114.Fn EVP_des_ede3_cfb void
115.Ft const EVP_CIPHER *
116.Fn EVP_des_ede3_cfb1 void
117.Ft const EVP_CIPHER *
118.Fn EVP_des_ede3_cfb8 void
119.Ft const EVP_CIPHER *
120.Fn EVP_des_ede3_cfb64 void
121.Ft const EVP_CIPHER *
122.Fn EVP_des_ede3_ecb void
123.Ft const EVP_CIPHER *
124.Fn EVP_des_ede3_ofb void
125.Ft const EVP_CIPHER *
126.Fn EVP_desx_cbc void
127.Sh DESCRIPTION
128These functions provide the DES encryption algorithm in the
129.Xr evp 3
130framework.
131DES is a block cipher operating on 64 bit blocks.
132The key length to be used for
133.Xr EVP_EncryptInit 3
134is 64 bits.
135However, only 56 of these bits are used in the encryption algorithm.
136The least significant bit in each of the eight bytes is only used
137for checking parity.
138Using this algorithm is discouraged because the short key length
139makes it vulnerable to brute force attacks.
140.Pp
141.Fn EVP_des_cbc ,
142.Fn EVP_des_cfb1 ,
143.Fn EVP_des_cfb8 ,
144.Fn EVP_des_cfb64 ,
145.Fn EVP_des_ecb ,
146and
147.Fn EVP_des_ofb
148provide DES in CBC, CFB with 1-bit shift, CFB with 8-bit shift,
149CFB with 64-bit shift, ECB, and OFB modes.
150.Fn EVP_des_cfb
151is an alias for
152.Fn EVP_des_cfb64 ,
153implemented as a macro.
154.Pp
155.Fn EVP_des_ede_cbc ,
156.Fn EVP_des_ede_cfb64 ,
157.Fn EVP_des_ede_ecb ,
158and
159.Fn EVP_des_ede_ofb
160provide two key triple DES in CBC, CFB with 64-bit shift, ECB, and OFB modes.
161.Fn EVP_des_ede_cfb
162is an alias for
163.Fn EVP_des_ede_cfb64 ,
164implemented as a macro.
165.Fn EVP_des_ede
166is an alias for
167.Fn EVP_des_ede_ecb .
168.Pp
169.Fn EVP_des_ede3_cbc ,
170.Fn EVP_des_ede3_cfb1 ,
171.Fn EVP_des_ede3_cfb8 ,
172.Fn EVP_des_ede3_cfb64 ,
173.Fn EVP_des_ede3_ecb ,
174.Fn EVP_des_ede3_ofb
175provide three key triple DES in CBC, CFB with 1-bit shift, CFB with 8-bit
176shift, CFB with 64-bit shift, ECB, and OFB modes.
177.Fn EVP_des_ede3_cfb
178is an alias for
179.Fn EVP_des_ede3_cfb64 ,
180implemented as a macro.
181.Fn EVP_des_ede3
182is an alias for
183.Fn EVP_des_ede3_ecb .
184.Pp
185.Fn EVP_desx_cbc
186provides the DES-X encryption algorithm in CBC mode.
187It uses a key length of 128 bits and acts on blocks of 128 bits.
188.Sh RETURN VALUES
189These functions return an
190.Vt EVP_CIPHER
191structure that provides the implementation of the symmetric cipher.
192.Sh SEE ALSO
193.Xr evp 3 ,
194.Xr EVP_EncryptInit 3
195.Sh HISTORY
196.Fn EVP_des_cbc ,
197.Fn EVP_des_cfb ,
198.Fn EVP_des_ecb ,
199.Fn EVP_des_ofb ,
200.Fn EVP_des_ede ,
201.Fn EVP_des_ede_cbc ,
202.Fn EVP_des_ede_cfb ,
203.Fn EVP_des_ede_ofb ,
204.Fn EVP_des_ede3 ,
205.Fn EVP_des_ede3_cbc ,
206.Fn EVP_des_ede3_cfb ,
207and
208.Fn EVP_des_ede3_ofb
209first appeared in SSLeay 0.5.1.
210.Fn EVP_desx_cbc
211first appeared in SSLeay 0.6.2.
212These functions have been available since
213.Ox 2.4 .
214.Pp
215.Fn EVP_des_ede_ecb
216and
217.Fn EVP_des_ede3_ecb
218first appeared in OpenSSL 0.9.7 and have been available since
219.Ox 3.2 .
220.Pp
221.Fn EVP_des_cfb1 ,
222.Fn EVP_des_cfb8 ,
223.Fn EVP_des_cfb64 ,
224.Fn EVP_des_ede_cfb64 ,
225.Fn EVP_des_ede3_cfb1 ,
226.Fn EVP_des_ede3_cfb8 ,
227and
228.Fn EVP_des_ede3_cfb64
229first appeared in OpenSSL 0.9.7e and have been available since
230.Ox 3.8 .
diff --git a/src/lib/libcrypto/man/EVP_rc2_cbc.3 b/src/lib/libcrypto/man/EVP_rc2_cbc.3
deleted file mode 100644
index 38c8184260..0000000000
--- a/src/lib/libcrypto/man/EVP_rc2_cbc.3
+++ /dev/null
@@ -1,201 +0,0 @@
1.\" $OpenBSD: EVP_rc2_cbc.3,v 1.1 2024/12/08 17:41:23 schwarze Exp $
2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 8 2024 $
18.Dt EVP_RC2_CBC 3
19.Os
20.Sh NAME
21.Nm EVP_rc2_cbc ,
22.Nm EVP_rc2_ecb ,
23.Nm EVP_rc2_cfb64 ,
24.Nm EVP_rc2_cfb ,
25.Nm EVP_rc2_ofb ,
26.Nm EVP_rc2_40_cbc ,
27.Nm EVP_rc2_64_cbc
28.Nd Rivest Cipher 2 in the EVP framework
29.Sh SYNOPSIS
30.In openssl/evp.h
31.Ft const EVP_CIPHER *
32.Fn EVP_rc2_cbc void
33.Ft const EVP_CIPHER *
34.Fn EVP_rc2_ecb void
35.Ft const EVP_CIPHER *
36.Fn EVP_rc2_cfb64 void
37.Ft const EVP_CIPHER *
38.Fn EVP_rc2_cfb void
39.Ft const EVP_CIPHER *
40.Fn EVP_rc2_ofb void
41.Ft const EVP_CIPHER *
42.Fn EVP_rc2_40_cbc void
43.Ft const EVP_CIPHER *
44.Fn EVP_rc2_64_cbc void
45.In openssl/rc2.h
46.Fd #define RC2_BLOCK 8
47.Fd #define RC2_KEY_LENGTH 16
48.Sh DESCRIPTION
49RC2 is a block cipher operating on blocks of
50.Dv RC2_BLOCK No = 8
51bytes, equivalent to 64 bits, using a variable
52.Fa key
53length with an additional parameter called
54.Dq effective key bits
55or
56.Dq effective key length .
57.Pp
58.Fn EVP_rc2_cbc ,
59.Fn EVP_rc2_ecb ,
60.Fn EVP_rc2_cfb64 ,
61and
62.Fn EVP_rc2_ofb
63provide the RC2 encryption algorithm in CBC, ECB, CFB and OFB mode,
64respectively.
65.Fn EVP_rc2_cfb
66is an alias for
67.Fn EVP_rc2_cfb64 ,
68implemented as a macro.
69.Pp
70By default, these functions set both the key length
71and the effective key length to
72.Dv RC2_KEY_LENGTH No = 16
73bytes, which is not a very useful value because it is quite short.
74.Pp
75Configuring normally requires a multi-step process:
76.Bl -enum -width 2n
77.It
78Create a new, empty
79.Vt EVP_CIPHER_CTX
80object with
81.Xr EVP_CIPHER_CTX_new 3 .
82.It
83Select the operation mode by calling
84.Xr EVP_EncryptInit 3
85with the desired
86.Fa type
87argument, passing
88.Dv NULL
89pointers for the
90.Fa key
91and
92.Fa iv
93arguments.
94.It
95Select the
96.Fa key
97length by passing the desired number of bytes to
98.Xr EVP_CIPHER_CTX_set_key_length 3 .
99Doing so overrides the default key length of
100.Dv RC2_KEY_LENGTH No = 16 .
101Valid values for
102.Fa keylen
103are positive and less than or equal to 128.
104.It
105Select the effective key length by calling
106.Xr EVP_CIPHER_CTX_ctrl 3
107with a
108.Fa type
109argument of
110.Dv EVP_CTRL_SET_RC2_KEY_BITS ,
111passing the desired number of bits in
112.Fa arg .
113Doing so overrides the default effective key length of 128 bits.
114Valid values for
115.Fa arg
116are positive and less than or equal to 1024.
117The
118.Fa ptr
119argument is ignored; passing
120.Dv NULL
121is recommended.
122.It
123Call
124.Xr EVP_EncryptInit 3
125a second time, this time passing
126.Dv NULL
127for the type argument.
128The
129.Fa key
130argument points to an array containing the number of bytes that was passed to
131.Xr EVP_CIPHER_CTX_set_key_length 3 ,
132and the
133.Fa iv
134argument points to an array of eight bytes.
135.It
136Finally,
137.Xr EVP_EncryptUpdate 3
138and
139.Xr EVP_EncryptFinal 3
140can be used in the normal way.
141.El
142.Pp
143Once a
144.Fa ctx
145object is fully configured, calling
146.Xr EVP_CIPHER_CTX_ctrl 3
147with a
148.Fa type
149argument of
150.Dv EVP_CTRL_GET_RC2_KEY_BITS
151interprets
152.Fa ptr
153as a pointer to
154.Vt int
155and stores the effective key length in bits at that location.
156In this case,
157.Fa arg
158is ignored and passing 0 is recommended.
159.Pp
160In the CFB and OFB modes, the minimum required total length in bytes
161of the output buffer is equal to the total number of input bytes to
162be encoded.
163In the CBC and ECB modes, the minimum required total length
164of the output buffer has to be rounded up to the next multiple
165of the block size of eight bytes.
166.Pp
167.Fn EVP_rc2_40_cbc
168and
169.Fn EVP_rc2_64_cbc
170are obsolete functions that provide the RC2 algorithm in CBC mode
171with a key length and an effective key length of 40 and 64 bits,
172respectively.
173.Sh RETURN VALUES
174With the
175.Vt EVP_CIPHER
176objects documented in the present manual page,
177.Fn EVP_CIPHER_CTX_ctrl
178returns 1 for success or 0 if an error occurs.
179.Sh SEE ALSO
180.Xr evp 3 ,
181.Xr EVP_CIPHER_CTX_set_key_length 3 ,
182.Xr EVP_EncryptInit 3 ,
183.Xr RC2_encrypt 3
184.Sh HISTORY
185.Fn EVP_rc2_cbc ,
186.Fn EVP_rc2_ecb ,
187.Fn EVP_rc2_cfb ,
188and
189.Fn EVP_rc2_ofb
190first appeared in SSLeay 0.5.2 and have been available since
191.Ox 2.4 .
192.Pp
193.Fn EVP_rc2_40_cbc
194and
195.Fn EVP_rc2_64_cbc
196first appeared in SSLeay 0.9.1 and have been available since
197.Ox 2.6 .
198.Pp
199.Fn EVP_rc2_cfb64
200first appeared in OpenSSL 0.9.7e and has been available since
201.Ox 3.8 .
diff --git a/src/lib/libcrypto/man/EVP_rc4.3 b/src/lib/libcrypto/man/EVP_rc4.3
deleted file mode 100644
index fda041113c..0000000000
--- a/src/lib/libcrypto/man/EVP_rc4.3
+++ /dev/null
@@ -1,109 +0,0 @@
1.\" $OpenBSD: EVP_rc4.3,v 1.1 2019/03/21 13:37:25 schwarze Exp $
2.\" full merge up to: OpenSSL 8fa4d95e Oct 21 11:59:09 2017 +0900
3.\"
4.\" This file was written by Ronald Tse <ronald.tse@ribose.com>
5.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 21 2019 $
52.Dt EVP_RC4 3
53.Os
54.Sh NAME
55.Nm EVP_rc4 ,
56.Nm EVP_rc4_40 ,
57.Nm EVP_rc4_hmac_md5
58.Nd EVP RC4 stream cipher
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft const EVP_CIPHER *
62.Fn EVP_rc4 void
63.Ft const EVP_CIPHER *
64.Fn EVP_rc4_40 void
65.Ft const EVP_CIPHER *
66.Fn EVP_rc4_hmac_md5 void
67.Sh DESCRIPTION
68These functions provide the RC4 stream cipher in the
69.Xr evp 3
70framework.
71It is a variable key length cipher.
72.Pp
73.Fn EVP_rc4
74uses a default key length of 128 bits.
75.Pp
76.Fn EVP_rc4_40
77uses a key length of 40 bits instead.
78This function is deprecated.
79Use
80.Fn EVP_rc4
81and
82.Xr EVP_CIPHER_CTX_set_key_length 3
83instead.
84.Pp
85.Fn EVP_rc4_hmac_md5
86provides authenticated encryption with the RC4 stream cipher
87with MD5 as HMAC.
88This function is not intended for usage outside of TLS
89and requires calling of some undocumented control functions.
90It does not conform to the EVP AEAD interface.
91.Sh RETURN VALUES
92These functions return an
93.Vt EVP_CIPHER
94structure that provides the implementation of the symmetric cipher.
95.Sh SEE ALSO
96.Xr evp 3 ,
97.Xr EVP_EncryptInit 3
98.Sh HISTORY
99.Fn EVP_rc4
100first appeared in SSLeay 0.5.1
101and
102.Fn EVP_rc4_40
103in OpenSSL 0.9.1.
104These functions have been available since
105.Ox 2.4 .
106.Pp
107.Fn EVP_rc4_hmac_md5
108first appeared in OpenSSL 1.0.1 and has been available since
109.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/EVP_sha1.3 b/src/lib/libcrypto/man/EVP_sha1.3
deleted file mode 100644
index b28c9f54c3..0000000000
--- a/src/lib/libcrypto/man/EVP_sha1.3
+++ /dev/null
@@ -1,120 +0,0 @@
1.\" $OpenBSD: EVP_sha1.3,v 1.2 2024/03/05 17:21:40 tb Exp $
2.\"
3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 5 2024 $
18.Dt EVP_SHA1 3
19.Os
20.Sh NAME
21.Nm EVP_sha1 ,
22.Nm EVP_md5 ,
23.Nm EVP_md5_sha1 ,
24.Nm EVP_md4
25.Nd legacy message digest algorithms
26.Sh SYNOPSIS
27.In openssl/evp.h
28.Ft const EVP_MD *
29.Fn EVP_sha1 void
30.Ft const EVP_MD *
31.Fn EVP_md5 void
32.Ft const EVP_MD *
33.Fn EVP_md5_sha1 void
34.Ft const EVP_MD *
35.Fn EVP_md4 void
36.Sh DESCRIPTION
37The following message digest algorithms are cryptographically broken.
38None of them should be used in new code unless there is no way around it.
39.Pp
40.Fn EVP_sha1
41implements the SHA-1 algorithm and produces 160 bits of output
42from a given input.
43Examples of protocols and software still requiring it
44include OCSP, DNS, and the
45.Sy git
46version control system.
47.Pp
48.Fn EVP_md5
49implements the MD5 algorithm and produces 128 bits of output
50from a given input.
51It is still occasionally used when no security is required
52but a fast hash algorithm is beneficial.
53.Pp
54.Fn EVP_md5_sha1
55produces concatenated MD5 and SHA-1 message digests.
56Do not use this except where it is required for the historic SSLv3 protocol.
57.Pp
58.Fn EVP_md4
59implements the MD4 algorithm and produces 128 bits of output
60from a given input.
61It has been marked as
62.Dq historic
63by the Internet Engineering Task Force since 2011.
64.Sh RETURN VALUES
65These functions return pointers to static
66.Vt EVP_MD
67objects implementing the hash functions.
68.Sh SEE ALSO
69.Xr evp 3 ,
70.Xr EVP_DigestInit 3
71.Sh STANDARDS
72.Rs
73.%A T. Polk
74.%A L. Chen
75.%A S. Turner
76.%A P. Hoffman
77.%T Security Considerations for the SHA-0 and SHA-1 Message-Digest Algorithms
78.%R RFC 6194
79.%D March 2011
80.Re
81.Pp
82.Rs
83.%A S. Turner
84.%A L. Chen
85.%T Updated Security Considerations for the MD5 Message-Digest\
86 and the HMAC-MD5 Algorithms
87.%R RFC 6151
88.%D March 2011
89.Re
90.Pp
91.Rs
92.%A S. Turner
93.%A L. Chen
94.%T MD4 to Historic Status
95.%R RFC 6150
96.%D March 2011
97.Re
98.Pp
99.Rs
100.%A P. Kocher
101.%A P. Karlton
102.%A A. Freier
103.%T The Secure Sockets Layer (SSL) Protocol Version 3.0
104.%R RFC 6101
105.%D August 2011
106.Re
107.Sh HISTORY
108.Fn EVP_sha1
109and
110.Fn EVP_md5
111first appeared in SSLeay 0.5.1 and have been available since
112.Ox 2.4 .
113.Pp
114.Fn EVP_md4
115first appeared in OpenSSL 0.9.6 and has been available since
116.Ox 2.9 .
117.Pp
118.Fn EVP_md5_sha1
119first appeared in OpenSSL 1.1.0 and has been available since
120.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/EVP_sha3_224.3 b/src/lib/libcrypto/man/EVP_sha3_224.3
deleted file mode 100644
index 3c21ae1a09..0000000000
--- a/src/lib/libcrypto/man/EVP_sha3_224.3
+++ /dev/null
@@ -1,91 +0,0 @@
1.\" $OpenBSD: EVP_sha3_224.3,v 1.3 2024/03/05 17:21:40 tb Exp $
2.\" selective merge up to: OpenSSL bbda8ce9 Oct 31 15:43:01 2017 +0800
3.\"
4.\" This file was written by Ronald Tse <ronald.tse@ribose.com>.
5.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 5 2024 $
52.Dt EVP_SHA3_224 3
53.Os
54.Sh NAME
55.Nm EVP_sha3_224 ,
56.Nm EVP_sha3_256 ,
57.Nm EVP_sha3_384 ,
58.Nm EVP_sha3_512
59.Nd Secure Hash Algorithm 3 for EVP
60.Sh SYNOPSIS
61.In openssl/evp.h
62.Ft const EVP_MD *
63.Fn EVP_sha3_224 void
64.Ft const EVP_MD *
65.Fn EVP_sha3_256 void
66.Ft const EVP_MD *
67.Fn EVP_sha3_384 void
68.Ft const EVP_MD *
69.Fn EVP_sha3_512 void
70.Sh DESCRIPTION
71SHA-3 (Secure Hash Algorithm 3) is a family of cryptographic hash
72functions standardized in NIST FIPS 202, first published in 2015.
73It is based on the Keccak algorithm.
74.Pp
75.Fn EVP_sha3_224 ,
76.Fn EVP_sha3_256 ,
77.Fn EVP_sha3_384 ,
78and
79.Fn EVP_sha3_512
80implement the SHA3-224, SHA3-256, SHA3-384, and SHA3-512 algorithms
81and produce 224, 256, 384 and 512 bits of output from a given input,
82respectively.
83.Sh RETURN VALUES
84These functions return pointers to static
85.Vt EVP_MD
86objects implementing the hash functions.
87.Sh SEE ALSO
88.Xr evp 3 ,
89.Xr EVP_DigestInit 3
90.Sh STANDARDS
91NIST FIPS 202
diff --git a/src/lib/libcrypto/man/EVP_sm3.3 b/src/lib/libcrypto/man/EVP_sm3.3
deleted file mode 100644
index aa6789f249..0000000000
--- a/src/lib/libcrypto/man/EVP_sm3.3
+++ /dev/null
@@ -1,82 +0,0 @@
1.\" $OpenBSD: EVP_sm3.3,v 1.1 2019/08/25 17:08:20 schwarze Exp $
2.\" full merge up to: OpenSSL 21ebd2fc Aug 24 20:38:04 2018 +0800
3.\"
4.\" This file was written by Jack Lloyd <jack.lloyd@ribose.com>
5.\" and Ronald Tse <ronald.tse@ribose.com>.
6.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
7.\" Copyright (c) 2017 Ribose Inc. All Rights Reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: August 25 2019 $
54.Dt EVP_SM3 3
55.Os
56.Sh NAME
57.Nm EVP_sm3
58.Nd SM3 hash function for EVP
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft const EVP_MD *
62.Fn EVP_sm3 void
63.Sh DESCRIPTION
64SM3 is a cryptographic hash function with a 256-bit output.
65It is part of the Chinese
66.Dq Commercial Cryptography
67suite of algorithms which is required
68for certain commercial applications in China.
69.Sh RETURN VALUES
70.Fn EVP_sm3
71returns a pointer to a static
72.Vt EVP_MD
73object implementing the SM3 hash function.
74.Sh SEE ALSO
75.Xr evp 3 ,
76.Xr EVP_DigestInit 3
77.Sh STANDARDS
78GB/T 32905-2016 and GM/T 0004-2012
79.Sh HISTORY
80.Fn EVP_sm3
81first appeared in OpenSSL 1.1.1 and has been available since
82.Ox 6.5 .
diff --git a/src/lib/libcrypto/man/EVP_sm4_cbc.3 b/src/lib/libcrypto/man/EVP_sm4_cbc.3
deleted file mode 100644
index 0605a52faa..0000000000
--- a/src/lib/libcrypto/man/EVP_sm4_cbc.3
+++ /dev/null
@@ -1,82 +0,0 @@
1.\" $OpenBSD: EVP_sm4_cbc.3,v 1.2 2023/11/16 20:27:43 schwarze Exp $
2.\" full merge up to: OpenSSL 87103969 Oct 1 14:11:57 2018 -0700
3.\"
4.\" Copyright (c) 2017 Ribose Inc
5.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
6.\" The original version of this file
7.\" was written by Ronald Tse <ronald.tse@ribose.com>.
8.\"
9.\" Permission to use, copy, modify, and/or distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.Dd $Mdocdate: November 16 2023 $
22.Dt EVP_SM4_CBC 3
23.Os
24.Sh NAME
25.Nm EVP_sm4_cbc ,
26.Nm EVP_sm4_ecb ,
27.Nm EVP_sm4_cfb ,
28.Nm EVP_sm4_cfb128 ,
29.Nm EVP_sm4_ofb ,
30.Nm EVP_sm4_ctr
31.Nd EVP SM4 cipher
32.Sh SYNOPSIS
33.In openssl/evp.h
34.Ft const EVP_CIPHER *
35.Fn EVP_sm4_cbc void
36.Ft const EVP_CIPHER *
37.Fn EVP_sm4_ecb void
38.Ft const EVP_CIPHER *
39.Fn EVP_sm4_cfb void
40.Ft const EVP_CIPHER *
41.Fn EVP_sm4_cfb128 void
42.Ft const EVP_CIPHER *
43.Fn EVP_sm4_ofb void
44.Ft const EVP_CIPHER *
45.Fn EVP_sm4_ctr void
46.Sh DESCRIPTION
47These functions provide the SM4 blockcipher in the
48.Xr evp 3
49framework.
50.Pp
51All modes use a key length of 128 bits and act on blocks of 128
52bits.
53.Pp
54.Fn EVP_sm4_cfb
55is an alias for
56.Fn EVP_sm4_cfb128 ,
57implemented as a macro.
58.Pp
59With an argument of
60.Qq sm4
61or
62.Qq SM4 ,
63.Xr EVP_get_cipherbyname 3
64returns
65.Fn EVP_sm4_cbc .
66.Sh RETURN VALUES
67These functions return an
68.Vt EVP_CIPHER
69structure that provides the implementation of the symmetric cipher.
70.Sh SEE ALSO
71.Xr evp 3 ,
72.Xr EVP_EncryptInit 3
73.Sh STANDARDS
74.Rs
75.%T Information security technology - SM4 block cipher algorithm
76.%I National Standards of People's Republic of China
77.%N GB/T 32907-2016
78.%D August 29, 2016
79.Re
80.Sh HISTORY
81These functions appeared in OpenSSL 1.1.1 and have been available since
82.Ox 6.5 .
diff --git a/src/lib/libcrypto/man/EXTENDED_KEY_USAGE_new.3 b/src/lib/libcrypto/man/EXTENDED_KEY_USAGE_new.3
deleted file mode 100644
index 3d1ed17ff3..0000000000
--- a/src/lib/libcrypto/man/EXTENDED_KEY_USAGE_new.3
+++ /dev/null
@@ -1,84 +0,0 @@
1.\" $OpenBSD: EXTENDED_KEY_USAGE_new.3,v 1.6 2021/10/27 11:24:47 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 27 2021 $
18.Dt EXTENDED_KEY_USAGE_NEW 3
19.Os
20.Sh NAME
21.Nm EXTENDED_KEY_USAGE_new ,
22.Nm EXTENDED_KEY_USAGE_free
23.Nd X.509 key usage restrictions
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft EXTENDED_KEY_USAGE
27.Fn EXTENDED_KEY_USAGE_new void
28.Ft void
29.Fn EXTENDED_KEY_USAGE_free "EXTENDED_KEY_USAGE *eku"
30.Sh DESCRIPTION
31By using the key usage extension, the extended key usage extension,
32or both of them,
33.Vt X509
34end entity certificates may indicate that the key contained in them
35is only intended to be used for the specified purposes.
36If both extensions are present, only uses compatible with both
37extensions are intended.
38.Pp
39.Fn EXTENDED_KEY_USAGE_new
40allocates and initializes an empty
41.Vt EXTENDED_KEY_USAGE
42object, which is a
43.Vt STACK_OF(ASN1_OBJECT)
44and represents an ASN.1
45.Vt ExtKeyUsageSyntax
46structure defined in RFC 5280 section 4.2.1.12.
47It can hold key purpose identifiers.
48.Pp
49.Fn EXTENDED_KEY_USAGE_free
50frees
51.Fa eku .
52.Pp
53The key usage extension uses the ASN.1 BIT STRING data type
54and doesn't require any dedicated object.
55.Sh RETURN VALUES
56.Fn EXTENDED_KEY_USAGE_new
57returns the new
58.Vt EXTENDED_KEY_USAGE
59object or
60.Dv NULL
61if an error occurs.
62.Sh SEE ALSO
63.Xr BASIC_CONSTRAINTS_new 3 ,
64.Xr d2i_EXTENDED_KEY_USAGE 3 ,
65.Xr POLICYINFO_new 3 ,
66.Xr X509_check_purpose 3 ,
67.Xr X509_EXTENSION_new 3 ,
68.Xr X509_get_extension_flags 3 ,
69.Xr X509_new 3
70.Sh STANDARDS
71RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
72Certificate Revocation List (CRL) Profile:
73.Bl -dash -compact
74.It
75section 4.2.1.3: Key Usage
76.It
77section 4.2.1.12: Extended Key Usage
78.El
79.Sh HISTORY
80.Fn EXTENDED_KEY_USAGE_new
81and
82.Fn EXTENDED_KEY_USAGE_free
83first appeared in OpenSSL 0.9.7 and have been available since
84.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/GENERAL_NAME_new.3 b/src/lib/libcrypto/man/GENERAL_NAME_new.3
deleted file mode 100644
index a6b7ee56da..0000000000
--- a/src/lib/libcrypto/man/GENERAL_NAME_new.3
+++ /dev/null
@@ -1,165 +0,0 @@
1.\" $OpenBSD: GENERAL_NAME_new.3,v 1.6 2019/06/06 01:06:58 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 6 2019 $
18.Dt GENERAL_NAME_NEW 3
19.Os
20.Sh NAME
21.Nm GENERAL_NAME_new ,
22.Nm GENERAL_NAME_free ,
23.Nm GENERAL_NAMES_new ,
24.Nm GENERAL_NAMES_free ,
25.Nm EDIPARTYNAME_new ,
26.Nm EDIPARTYNAME_free ,
27.Nm OTHERNAME_new ,
28.Nm OTHERNAME_free
29.Nd names for use in X.509 extensions
30.Sh SYNOPSIS
31.In openssl/x509v3.h
32.Ft GENERAL_NAME *
33.Fn GENERAL_NAME_new void
34.Ft void
35.Fn GENERAL_NAME_free "GENERAL_NAME *name"
36.Ft GENERAL_NAMES *
37.Fn GENERAL_NAMES_new void
38.Ft void
39.Fn GENERAL_NAMES_free "GENERAL_NAMES *names"
40.Ft EDIPARTYNAME *
41.Fn EDIPARTYNAME_new void
42.Ft void
43.Fn EDIPARTYNAME_free "EDIPARTYNAME *name"
44.Ft OTHERNAME *
45.Fn OTHERNAME_new void
46.Ft void
47.Fn OTHERNAME_free "OTHERNAME *name"
48.Sh DESCRIPTION
49Even though the X.501
50.Vt Name
51documented in
52.Xr X509_NAME_new 3
53is a complicated multi-layered structure, it is very rigid and not
54flexible enough to represent various entities that many people want
55to use as names in certificates.
56For that reason, X.509 extensions use the X.509
57.Vt GeneralName
58wrapper structure rather than using the X.501
59.Vt Name
60structure directly, at the expense of adding one or two additional
61layers of indirection.
62.Pp
63.Fn GENERAL_NAME_new
64allocates and initializes an empty
65.Vt GENERAL_NAME
66object, representing the ASN.1
67.Vt GeneralName
68structure defined in RFC 5280 section 4.2.1.6.
69It can for example hold an
70.Vt X509_name
71object, an IP address, a DNS host name, a uniform resource identifier,
72an email address, or an
73.Vt EDIPARTYNAME
74or
75.Vt OTHERNAME
76object described below.
77.Fn GENERAL_NAME_free
78frees
79.Fa name .
80.Pp
81.Fn GENERAL_NAMES_new
82allocates and initializes an empty
83.Vt GENERAL_NAMES
84object, which is a
85.Vt STACK_OF(GENERAL_NAME)
86and represents the ASN.1
87.Vt GeneralNames
88structure defined in RFC 5280 section 4.2.1.6.
89It is used by extension structures that can contain multiple names,
90for example key identifier, alternative name, and distribution point
91extensions.
92.Fn GENERAL_NAMES_free
93frees
94.Fa names .
95.Pp
96.Fn EDIPARTYNAME_new
97allocates and initializes an empty
98.Vt EDIPARTYNAME
99object, representing the ASN.1
100.Vt EDIPartyName
101structure defined in RFC 5280 section 4.2.1.6, where
102.Dq EDI
103stands for
104.Dq electronic data identifier .
105It can hold two strings, the name itself and the name of the authority
106that assigned that name.
107.Fn EDIPARTYNAME_free
108frees
109.Fa name .
110.Pp
111.Fn OTHERNAME_new
112allocates and initializes an empty
113.Vt OTHERNAME
114object, representing the ASN.1
115.Vt OtherName
116structure defined in RFC 5280 section 4.2.1.6.
117It can hold data of any
118.Vt ASN1_TYPE
119together with a type identifier.
120.Fn OTHERNAME_free
121frees
122.Fa name .
123.Sh RETURN VALUES
124.Fn GENERAL_NAME_new ,
125.Fn GENERAL_NAMES_new ,
126.Fn EDIPARTYNAME_new ,
127and
128.Fn OTHERNAME_new
129return a new
130.Vt GENERAL_NAME ,
131.Vt GENERAL_NAMES ,
132.Vt EDIPARTYNAME ,
133or
134.Vt OTHERNAME
135object or
136.Dv NULL
137if an error occurs.
138.Sh SEE ALSO
139.Xr d2i_GENERAL_NAME 3 ,
140.Xr X509_EXTENSION_new 3 ,
141.Xr X509_NAME_new 3
142.Sh STANDARDS
143RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
144Certificate Revocation List (CRL) Profile,
145section 4.2: Certificate Extensions
146.Sh HISTORY
147.Fn GENERAL_NAME_new ,
148.Fn GENERAL_NAME_free ,
149.Fn GENERAL_NAMES_new ,
150and
151.Fn GENERAL_NAMES_free
152first appeared in OpenSSL 0.9.2b and have been available since
153.Ox 2.6 .
154.Pp
155.Fn OTHERNAME_new
156and
157.Fn OTHERNAME_free
158first appeared in OpenSSL 0.9.5 and have been available since
159.Ox 2.7 .
160.Pp
161.Fn EDIPARTYNAME_new
162and
163.Fn EDIPARTYNAME_free
164first appeared in OpenSSL 0.9.7 and have been available since
165.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/HMAC.3 b/src/lib/libcrypto/man/HMAC.3
deleted file mode 100644
index a515014fca..0000000000
--- a/src/lib/libcrypto/man/HMAC.3
+++ /dev/null
@@ -1,324 +0,0 @@
1.\" $OpenBSD: HMAC.3,v 1.23 2024/08/29 20:21:53 tb Exp $
2.\" full merge up to: OpenSSL crypto/hmac a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" selective merge up to: OpenSSL man3/HMAC b3696a55 Sep 2 09:35:50 2017 -0400
4.\"
5.\" This file was written by Ulf Moeller <ulf@openssl.org>,
6.\" Richard Levitte <levitte@openssl.org>, and
7.\" Matt Caswell <matt@openssl.org>.
8.\" Copyright (c) 2000-2002, 2006, 2008, 2009, 2013, 2015, 2016
9.\" The OpenSSL Project. All rights reserved.
10.\"
11.\" Redistribution and use in source and binary forms, with or without
12.\" modification, are permitted provided that the following conditions
13.\" are met:
14.\"
15.\" 1. Redistributions of source code must retain the above copyright
16.\" notice, this list of conditions and the following disclaimer.
17.\"
18.\" 2. Redistributions in binary form must reproduce the above copyright
19.\" notice, this list of conditions and the following disclaimer in
20.\" the documentation and/or other materials provided with the
21.\" distribution.
22.\"
23.\" 3. All advertising materials mentioning features or use of this
24.\" software must display the following acknowledgment:
25.\" "This product includes software developed by the OpenSSL Project
26.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
27.\"
28.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
29.\" endorse or promote products derived from this software without
30.\" prior written permission. For written permission, please contact
31.\" openssl-core@openssl.org.
32.\"
33.\" 5. Products derived from this software may not be called "OpenSSL"
34.\" nor may "OpenSSL" appear in their names without prior written
35.\" permission of the OpenSSL Project.
36.\"
37.\" 6. Redistributions of any form whatsoever must retain the following
38.\" acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
41.\"
42.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
43.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
46.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\"
55.Dd $Mdocdate: August 29 2024 $
56.Dt HMAC 3
57.Os
58.Sh NAME
59.Nm HMAC ,
60.Nm HMAC_CTX_new ,
61.Nm HMAC_CTX_reset ,
62.Nm HMAC_CTX_free ,
63.Nm HMAC_Init_ex ,
64.Nm HMAC_Update ,
65.Nm HMAC_Final ,
66.Nm HMAC_CTX_copy ,
67.Nm HMAC_CTX_set_flags ,
68.Nm HMAC_CTX_get_md ,
69.Nm HMAC_size
70.Nd HMAC message authentication code
71.Sh SYNOPSIS
72.In openssl/hmac.h
73.Ft unsigned char *
74.Fo HMAC
75.Fa "const EVP_MD *evp_md"
76.Fa "const void *key"
77.Fa "int key_len"
78.Fa "const unsigned char *d"
79.Fa "size_t n"
80.Fa "unsigned char *md"
81.Fa "unsigned int *md_len"
82.Fc
83.Ft HMAC_CTX *
84.Fn HMAC_CTX_new void
85.Ft int
86.Fo HMAC_CTX_reset
87.Fa "HMAC_CTX *ctx"
88.Fc
89.Ft void
90.Fo HMAC_CTX_free
91.Fa "HMAC_CTX *ctx"
92.Fc
93.Ft int
94.Fo HMAC_Init_ex
95.Fa "HMAC_CTX *ctx"
96.Fa "const void *key"
97.Fa "int key_len"
98.Fa "const EVP_MD *md"
99.Fa "ENGINE *engine"
100.Fc
101.Ft int
102.Fo HMAC_Update
103.Fa "HMAC_CTX *ctx"
104.Fa "const unsigned char *data"
105.Fa "size_t len"
106.Fc
107.Ft int
108.Fo HMAC_Final
109.Fa "HMAC_CTX *ctx"
110.Fa "unsigned char *md"
111.Fa "unsigned int *len"
112.Fc
113.Ft int
114.Fo HMAC_CTX_copy
115.Fa "HMAC_CTX *dctx"
116.Fa "HMAC_CTX *sctx"
117.Fc
118.Ft void
119.Fo HMAC_CTX_set_flags
120.Fa "HMAC_CTX *ctx"
121.Fa "unsigned long flags"
122.Fc
123.Ft const EVP_MD *
124.Fo HMAC_CTX_get_md
125.Fa "const HMAC_CTX *ctx"
126.Fc
127.Ft size_t
128.Fo HMAC_size
129.Fa "const HMAC_CTX *e"
130.Fc
131.Sh DESCRIPTION
132HMAC is a MAC (message authentication code), i.e. a keyed hash
133function used for message authentication, which is based on a hash
134function.
135.Pp
136.Fn HMAC
137computes the message authentication code of the
138.Fa n
139bytes at
140.Fa d
141using the hash function
142.Fa evp_md
143and the key
144.Fa key
145which is
146.Fa key_len
147bytes long.
148.Pp
149It places the result in
150.Fa md ,
151which must have space for the output of the hash function, which is no
152more than
153.Dv EVP_MAX_MD_SIZE
154bytes.
155The size of the output is placed in
156.Fa md_len ,
157unless it is
158.Dv NULL .
159.Pp
160.Fa evp_md
161can be
162.Xr EVP_sha1 3 ,
163.Xr EVP_ripemd160 3 ,
164etc.
165.Pp
166.Fn HMAC_CTX_new
167allocates and initializes a new
168.Vt HMAC_CTX
169object.
170.Pp
171.Fn HMAC_CTX_reset
172zeroes and re-initializes
173.Fa ctx
174and associated resources, making it suitable for new computations
175as if it was deleted with
176.Fn HMAC_CTX_free
177and newly created with
178.Fn HMAC_CTX_new .
179.Pp
180.Fn HMAC_CTX_free
181erases the key and other data from
182.Fa ctx ,
183releases any associated resources, and finally frees
184.Fa ctx
185itself.
186.Pp
187The following functions may be used if the message is not completely
188stored in memory:
189.Pp
190.Fn HMAC_Init_ex
191sets up or reuses
192.Fa ctx
193to use the hash function
194.Fa evp_md
195and the key
196.Fa key .
197Either can be
198.Dv NULL ,
199in which case the existing one is reused.
200The
201.Fa ctx
202must have been created with
203.Fn HMAC_CTX_new
204before the first use in this function.
205If
206.Fn HMAC_Init_ex
207is called with a
208.Dv NULL
209.Fa key
210but
211.Fa evp_md
212is neither
213.Dv NULL
214nor the same as the previous digest used by
215.Fa ctx ,
216then an error is returned because reuse of an existing key with a
217different digest is not supported.
218The
219.Fa ENGINE *engine
220argument is always ignored and passing
221.Dv NULL
222is recommended.
223.Pp
224.Fn HMAC_Update
225can be called repeatedly with chunks of the message to be authenticated
226.Pq Fa len No bytes at Fa data .
227.Pp
228.Fn HMAC_Final
229places the message authentication code in
230.Fa md ,
231which must have space for the hash function output.
232.Pp
233.Fn HMAC_CTX_copy
234copies all of the internal state from
235.Fa sctx
236into
237.Fa dctx .
238.Pp
239.Fn HMAC_CTX_set_flags
240applies the specified flags to the internal
241.Vt EVP_MD_CTX
242objects.
243Possible flag values
244.Dv EVP_MD_CTX_FLAG_*
245are defined in
246.In openssl/evp.h .
247.Pp
248.Fn HMAC_size
249returns the length in bytes of the underlying hash function output.
250It is implemented as a macro.
251.Sh RETURN VALUES
252.Fn HMAC
253returns a pointer to the message authentication code or
254.Dv NULL
255if an error occurred.
256.Pp
257.Fn HMAC_CTX_new
258returns a pointer to the new
259.Vt HMAC_CTX
260object or
261.Dv NULL
262if an error occurred.
263.Pp
264.Fn HMAC_CTX_reset ,
265.Fn HMAC_Init_ex ,
266.Fn HMAC_Update ,
267.Fn HMAC_Final ,
268and
269.Fn HMAC_CTX_copy
270return 1 for success or 0 if an error occurred.
271.Pp
272.Fn HMAC_CTX_get_md
273returns the message digest that was previously set for
274.Fa ctx
275with
276.Fn HMAC_Init_ex ,
277or
278.Dv NULL
279if none was set.
280.Pp
281.Fn HMAC_size
282returns the length in bytes of the underlying hash function output
283or 0 on error.
284.Sh SEE ALSO
285.Xr CMAC_Init 3 ,
286.Xr EVP_DigestInit 3
287.Sh STANDARDS
288RFC 2104
289.Sh HISTORY
290.Fn HMAC ,
291.Fn HMAC_Update ,
292.Fn HMAC_Final ,
293and
294.Fn HMAC_size
295first appeared in SSLeay 0.9.0 and have been available since
296.Ox 2.4 .
297.Pp
298.Fn HMAC_Init_ex
299first appeared in OpenSSL 0.9.7 and have been available since
300.Ox 3.2 .
301.Pp
302.Fn HMAC_CTX_set_flags
303first appeared in OpenSSL 0.9.7f and have been available since
304.Ox 3.8 .
305.Pp
306.Fn HMAC_CTX_copy
307first appeared in OpenSSL 1.0.0 and has been available since
308.Ox 4.9 .
309.Pp
310.Fn HMAC_CTX_new ,
311.Fn HMAC_CTX_reset ,
312.Fn HMAC_CTX_free ,
313and
314.Fn HMAC_CTX_get_md
315first appeared in OpenSSL 1.1.0 and have been available since
316.Ox 6.3 .
317.Sh CAVEATS
318Other implementations allow
319.Fa md
320in
321.Fn HMAC
322to be
323.Dv NULL
324and return a static array, which is not thread safe.
diff --git a/src/lib/libcrypto/man/IPAddressRange_new.3 b/src/lib/libcrypto/man/IPAddressRange_new.3
deleted file mode 100644
index a812107cdf..0000000000
--- a/src/lib/libcrypto/man/IPAddressRange_new.3
+++ /dev/null
@@ -1,525 +0,0 @@
1.\" $OpenBSD: IPAddressRange_new.3,v 1.9 2023/10/03 09:58:06 tb Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 3 2023 $
18.Dt IPADDRESSRANGE_NEW 3
19.Os
20.Sh NAME
21.Nm IPAddressRange_new ,
22.Nm IPAddressRange_free ,
23.Nm d2i_IPAddressRange ,
24.Nm i2d_IPAddressRange ,
25.Nm IPAddressOrRange_new ,
26.Nm IPAddressOrRange_free ,
27.Nm d2i_IPAddressOrRange ,
28.Nm i2d_IPAddressOrRange ,
29.Nm IPAddressChoice_new ,
30.Nm IPAddressChoice_free ,
31.Nm d2i_IPAddressChoice ,
32.Nm i2d_IPAddressChoice ,
33.Nm IPAddressFamily_new ,
34.Nm IPAddressFamily_free ,
35.Nm d2i_IPAddressFamily ,
36.Nm i2d_IPAddressFamily
37.Nd RFC 3779 IP address prefixes and ranges
38.Sh SYNOPSIS
39.In openssl/x509v3.h
40.Ft "IPAddressRange *"
41.Fn IPAddressRange_new void
42.Ft void
43.Fn IPAddressRange_free "IPAddressRange *range"
44.Ft IPAddressRange *
45.Fo d2i_IPAddressRange
46.Fa "IPAddressRange **range"
47.Fa "const unsigned char **der_in"
48.Fa "long length"
49.Fc
50.Ft int
51.Fo i2d_IPAddressRange
52.Fa "IPAddressRange *range"
53.Fa "unsigned char **der_out"
54.Fc
55.Ft "IPAddressOrRange *"
56.Fn IPAddressOrRange_new void
57.Ft void
58.Fn IPAddressOrRange_free "IPAddressOrRange *aor"
59.Ft IPAddressOrRange *
60.Fo d2i_IPAddressOrRange
61.Fa "IPAddressOrRange **aor"
62.Fa "const unsigned char **der_in"
63.Fa "long length"
64.Fc
65.Ft int
66.Fo i2d_IPAddressOrRange
67.Fa "IPAddressOrRange *aor"
68.Fa "unsigned char **der_out"
69.Fc
70.Ft "IPAddressChoice *"
71.Fn IPAddressChoice_new void
72.Ft void
73.Fn IPAddressChoice_free "IPAddressChoice *ac"
74.Ft IPAddressChoice *
75.Fo d2i_IPAddressChoice
76.Fa "IPAddressChoice **ac"
77.Fa "const unsigned char **der_in"
78.Fa "long length"
79.Fc
80.Ft int
81.Fo i2d_IPAddressChoice
82.Fa "IPAddressChoice *ac"
83.Fa "unsigned char **der_out"
84.Fc
85.Ft "IPAddressFamily *"
86.Fn IPAddressFamily_new void
87.Ft void
88.Fn IPAddressFamily_free "IPAddressFamily *af"
89.Ft IPAddressFamily *
90.Fo d2i_IPAddressFamily
91.Fa "IPAddressFamily **af"
92.Fa "const unsigned char **der_in"
93.Fa "long length"
94.Fc
95.Ft int
96.Fo i2d_IPAddressFamily
97.Fa "IPAddressFamily *af"
98.Fa "unsigned char **der_out"
99.Fc
100.Sh DESCRIPTION
101.Vt IPAddressRange ,
102.Vt IPAddressOrRange ,
103.Vt IPAddressChoice ,
104and
105.Vt IPAddressFamily
106are building blocks of the
107.Vt IPAddrBlocks
108type representing the RFC 3779 IP address delegation extension.
109.Pp
110Per RFC 3779, section 2.1.1,
111an IPv4 or an IPv6 address is encoded in network byte order in an
112ASN.1 BIT STRING of bit size 32 or 128 bits, respectively.
113The bit size of a prefix is its prefix length;
114all insignificant zero bits are omitted
115from the encoding.
116Per section 2.1.2,
117an address range is expressed as a pair of BIT STRINGs
118where all the least significant zero bits of the lower bound
119and all the least significant one bits of the upper bound are omitted.
120.Pp
121The library provides no API for directly converting an IP address or
122prefix (in any form) to and from an
123.Vt ASN1_BIT_STRING .
124It also provides no API for directly handling ranges.
125The
126.Vt ASN1_BIT_STRING
127internals are subtle and directly manipulating them in the
128context of the RFC 3779 API is discouraged.
129The bit size of an
130.Vt ASN1_BIT_STRING
131representing an IP address prefix or range is eight times its
132.Fa length
133member minus the lowest three bits of its
134.Fa flags ,
135provided the
136.Dv ASN1_STRING_FLAG_BITS_LEFT
137flag is set.
138.Pp
139The
140.Vt IPAddressRange
141type defined in RFC 3779 section 2.2.3.9 is implemented as
142.Bd -literal -offset indent
143typedef struct IPAddressRange_st {
144 ASN1_BIT_STRING *min;
145 ASN1_BIT_STRING *max;
146} IPAddressRange;
147.Ed
148.Pp
149It represents the closed range [min,max] of IP addresses between
150.Fa min
151and
152.Fa max ,
153where
154.Fa min
155should be strictly smaller than
156.Fa max
157and the range should not be expressible as a prefix.
158.Pp
159.Fn IPAddressRange_new
160allocates a new
161.Vt IPAddressRange
162object with allocated, empty
163.Fa min
164and
165.Fa max ,
166thus representing the entire address space invalidly as a non-prefix.
167.Pp
168.Fn IPAddressRange_free
169frees
170.Fa range
171including any data contained in it.
172If
173.Fa range
174is
175.Dv NULL ,
176no action occurs.
177.Pp
178There is no dedicated type representing the
179.Vt IPAddress
180type defined in RFC 3779 section 2.2.3.8.
181The API uses
182.Vt ASN1_BIT_STRING
183for this.
184.Pp
185The
186.Vt IPAddressOrRange
187type defined in RFC 3779 section 2.2.3.7 is implemented as
188.Bd -literal -offset indent
189typedef struct IPAddressOrRange_st {
190 int type;
191 union {
192 ASN1_BIT_STRING *addressPrefix;
193 IPAddressRange *addressRange;
194 } u;
195} IPAddressOrRange;
196.Ed
197.Pp
198representing an individual address prefix or an address range.
199The
200.Fa type
201member should be set to
202.Dv IPAddressOrRange_addressPrefix
203or
204.Dv IPAddressOrRange_addressRange
205to indicate which member of the union
206.Fa u
207is valid.
208.Pp
209.Fn IPAddressOrRange_new
210returns a new
211.Vt IPAddressOrRange
212object with invalid type and
213.Dv NULL
214members of the union
215.Fa u .
216.Pp
217.Fn IPAddressOrRange_free
218frees
219.Fa aor
220including any data contained in it,
221provided
222.Fa type
223is set correctly.
224If
225.Fa aor
226is
227.Dv NULL ,
228no action occurs.
229.Pp
230In order to express a list of address prefixes and address ranges,
231RFC 3779 section 2.2.3.6
232uses an ASN.1 SEQUENCE,
233which is implemented via a
234.Xr STACK_OF 3
235construction over
236.Vt IPAddressOrRange :
237.Bd -literal -offset indent
238typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;
239.Ed
240.Pp
241Since an
242.Vt IPAddressOrRanges
243object should be sorted in a specific way (see
244.Xr X509v3_addr_canonize 3 ) ,
245a comparison function is needed for a correct instantiation
246with
247.Xr sk_new 3 .
248The
249.Fn v4IPAddressOrRange_cmp
250and
251.Fn v6IPAddressOrRange_cmp
252functions are not directly exposed and not easily accessible
253from outside the library,
254and they are non-trivial to implement.
255It is therefore discouraged to use
256.Vt IPAddressOrRanges
257objects that are not part of an
258.Vt IPAddrBlocks
259object.
260.Pp
261The
262.Dq inherit
263marker from RFC 3779 section 2.2.3.5 is implemented as
264.Vt ASN1_NULL .
265It has no dedicated type or API and can be instantiated with
266.Xr ASN1_NULL_new 3 .
267.Pp
268The
269.Vt IPAddressChoice
270type defined in RFC 3779 section 2.2.3.4 is implemented as
271.Bd -literal -offset indent
272typedef struct IPAddressChoice_st {
273 int type;
274 union {
275 ASN1_NULL *inherit;
276 IPAddressOrRanges *addressesOrRanges;
277 } u;
278} IPAddressChoice;
279.Ed
280.Pp
281where the
282.Fa type
283member should be set to
284.Dv IPAddressChoice_inherit
285or
286.Dv IPAddressChoice_addressesOrRanges
287to indicate whether a given
288.Vt IPAddressChoice
289object represents an inherited list or an explicit list.
290.Pp
291.Fn IPAddressChoice_new
292returns a new
293.Vt IPAddressChoice
294object with invalid type and
295.Dv NULL
296members of the union
297.Fa u .
298.Pp
299.Fn IPAddressChoice_free
300frees
301.Fa ac
302including any data contained in it,
303provided
304.Fa type
305is set correctly.
306.Pp
307The
308.Fa addressFamily
309element defined in RFC 3779 section 2.2.3.3 is implemented as an
310.Vt ASN1_OCTET_STRING
311and it contains two or three octets.
312The first two octets are always present and represent the
313address family identifier (AFI)
314in network byte order.
315The optional subsequent address family identifier (SAFI)
316occupies the third octet.
317For IPv4 and IPv6,
318.Dv IANA_AFI_IPV4
319and
320.Dv IANA_AFI_IPV6
321are predefined.
322Other AFIs are not supported by this implementation.
323.Pp
324The
325.Vt IPAddressFamily
326type defined in RFC 3779 section 2.2.3.2 is implemented as
327.Bd -literal -offset indent
328typedef struct IPAddressFamily_st {
329 ASN1_OCTET_STRING *addressFamily;
330 IPAddressChoice *ipAddressChoice;
331} IPAddressFamily;
332.Ed
333.Pp
334The
335.Fa addressFamily
336member indicates the address family the
337.Fa ipAddressChoice
338represents.
339.Pp
340.Fn IPAddressFamily_new
341returns a new
342.Vt IPAddressFamily
343object with empty
344.Fa addressFamily
345and invalid
346.Fa ipAddressChoice
347members.
348.Pp
349.Fn IPAddressFamily_free
350frees
351.Fa af
352including any data contained in it.
353If
354.Fa af
355is
356.Dv NULL ,
357no action occurs.
358.Pp
359The
360.Vt IPAddrBlocks
361type defined in RFC 3779 section 2.2.3.1
362uses an ASN.1 SEQUENCE,
363which is implemented via a
364.Xr STACK_OF 3
365construction over
366.Vt IPAddressFamily :
367.Bd -literal -offset indent
368typedef STACK_OF(IPAddressFamily) IPAddrBlocks;
369.Ed
370.Pp
371It can be instantiated with
372.Fn sk_IPAddressFamily_new_null
373and the correct sorting function can be installed with
374.Xr X509v3_addr_canonize 3 .
375To populate it, use
376.Xr X509v3_addr_add_prefix 3
377and related functions.
378.Pp
379.Fn d2i_IPAddressRange ,
380.Fn i2d_IPAddressRange ,
381.Fn d2i_IPAddressOrRange ,
382.Fn i2d_IPAddressOrRange ,
383.Fn d2i_IPAddressChoice ,
384.Fn i2d_IPAddressChoice ,
385.Fn d2i_IPAddressFamily ,
386and
387.Fn i2d_IPAddressFamily
388decode and encode ASN.1
389.Vt IPAddressRange ,
390.Vt IPAddressOrRange ,
391.Vt IPAddressChoice ,
392and
393.Vt IPAddressFamily
394objects.
395For details about the semantics, examples, caveats, and bugs, see
396.Xr ASN1_item_d2i 3 .
397There is no easy way of ensuring that the encodings generated by
398these functions are correct, unless they are applied to objects
399that are part of a canonical
400.Vt IPAddrBlocks
401structure, see
402.Xr X509v3_addr_is_canonical 3 .
403.Sh RETURN VALUES
404.Fn IPAddressRange_new
405returns a new
406.Vt IPAddressRange
407object with allocated, empty members, or
408.Dv NULL
409if an error occurs.
410.Pp
411.Fn IPAddressOrRange_new
412returns a new, empty
413.Vt IPAddressOrRange
414object or
415.Dv NULL
416if an error occurs.
417.Pp
418.Fn IPAddressChoice_new
419returns a new, empty
420.Vt IPAddressChoice
421object or
422.Dv NULL
423if an error occurs.
424.Pp
425.Fn IPAddressFamily_new
426returns a new
427.Vt IPAddressFamily
428object with allocated, empty members, or
429.Dv NULL
430if an error occurs.
431.Pp
432The decoding functions
433.Fn d2i_IPAddressRange ,
434.Fn d2i_IPAddressOrRange ,
435.Fn d2i_IPAddressChoice ,
436and
437.Fn d2i_IPAddressFamily
438return an
439.Vt IPAddressRange ,
440an
441.Vt IPAddressOrRange ,
442an
443.Vt IPAddressChoice ,
444or an
445.Vt IPAddressFamily
446object, respectively,
447or
448.Dv NULL
449if an error occurs.
450.Pp
451The encoding functions
452.Fn i2d_IPAddressRange ,
453.Fn i2d_IPAddressOrRange ,
454.Fn i2d_IPAddressChoice ,
455and
456.Fn i2d_IPAddressFamily
457return the number of bytes successfully encoded
458or a value <= 0 if an error occurs.
459.Sh SEE ALSO
460.Xr ASIdentifiers_new 3 ,
461.Xr ASN1_BIT_STRING_new 3 ,
462.Xr ASN1_OCTET_STRING_new 3 ,
463.Xr ASN1_OCTET_STRING_set 3 ,
464.Xr crypto 3 ,
465.Xr X509_new 3 ,
466.Xr X509v3_addr_add_inherit 3 ,
467.Xr X509v3_addr_inherits 3 ,
468.Xr X509v3_addr_subset 3
469.Sh STANDARDS
470RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers:
471.Bl -dash -compact
472.It
473section 2.1.1: Encoding of an IP Address or Prefix
474.It
475section 2.1.2: Encoding of a Range of IP Addresses
476.It
477section 2.2.3: Syntax
478.It
479section 2.2.3.1: Type IPAddrBlocks
480.It
481section 2.2.3.2: Type IPAddressFamily
482.It
483section 2.2.3.3: Element addressFamily
484.It
485section 2.2.3.4: Element ipAddressChoice and Type IPAddressChoice
486.It
487section 2.2.3.5: Element inherit
488.It
489section 2.2.3.6: Element addressesOrRanges
490.It
491section 2.2.3.7: Type IPAddressOrRange
492.It
493section 2.2.3.8: Element addressPrefix and Type IPAddress
494.It
495section 2.2.3.9: Element addressRange and Type IPAddressRange
496.El
497.Pp
498ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
499Information technology - ASN.1 encoding rules:
500Specification of Basic Encoding Rules (BER), Canonical Encoding
501Rules (CER) and Distinguished Encoding Rules (DER),
502section 8.6: Encoding of a bitstring value
503.Sh HISTORY
504These functions first appeared in OpenSSL 0.9.8e
505and have been available since
506.Ox 7.1 .
507.Sh BUGS
508.\" The internals do not seem to consistently apply and check
509.\" .Dv ASN1_STRING_FLAG_BITS_LEFT
510.\" which may lead to incorrect encoding and misinterpretation
511As it stands, the API is barely usable
512due to missing convenience accessors, constructors and destructors
513and due to the complete absence of API that checks that the
514individual building blocks are correct.
515Extracting information from a given object can be done relatively
516safely.
517However, constructing objects is very error prone, be it
518by hand or using the bug-ridden
519.Xr X509v3_addr_add_inherit 3
520API.
521.Pp
522RFC 3779 has element
523.Dq addressesOrRanges .
524Its type in this API is
525.Vt IPAddressOrRanges .
diff --git a/src/lib/libcrypto/man/MD5.3 b/src/lib/libcrypto/man/MD5.3
deleted file mode 100644
index 01e715f406..0000000000
--- a/src/lib/libcrypto/man/MD5.3
+++ /dev/null
@@ -1,201 +0,0 @@
1.\" $OpenBSD: MD5.3,v 1.9 2024/05/26 09:54:16 tb Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
5.\" Richard Levitte <levitte@openssl.org>.
6.\" Copyright (c) 2000, 2006 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: May 26 2024 $
53.Dt MD5 3
54.Os
55.Sh NAME
56.Nm MD4 ,
57.Nm MD5 ,
58.Nm MD4_Init ,
59.Nm MD4_Update ,
60.Nm MD4_Final ,
61.Nm MD5_Init ,
62.Nm MD5_Update ,
63.Nm MD5_Final
64.Nd MD4 and MD5 hash functions
65.Sh SYNOPSIS
66.In openssl/md4.h
67.Ft unsigned char *
68.Fo MD4
69.Fa "const unsigned char *d"
70.Fa "unsigned long n"
71.Fa "unsigned char *md"
72.Fc
73.Ft int
74.Fo MD4_Init
75.Fa "MD4_CTX *c"
76.Fc
77.Ft int
78.Fo MD4_Update
79.Fa "MD4_CTX *c"
80.Fa "const void *data"
81.Fa "unsigned long len"
82.Fc
83.Ft int
84.Fo MD4_Final
85.Fa "unsigned char *md"
86.Fa "MD4_CTX *c"
87.Fc
88.In openssl/md5.h
89.Ft unsigned char *
90.Fo MD5
91.Fa "const unsigned char *d"
92.Fa "unsigned long n"
93.Fa "unsigned char *md"
94.Fc
95.Ft int
96.Fo MD5_Init
97.Fa "MD5_CTX *c"
98.Fc
99.Ft int
100.Fo MD5_Update
101.Fa "MD5_CTX *c"
102.Fa "const void *data"
103.Fa "unsigned long len"
104.Fc
105.Ft int
106.Fo MD5_Final
107.Fa "unsigned char *md"
108.Fa "MD5_CTX *c"
109.Fc
110.Sh DESCRIPTION
111MD4 and MD5 are cryptographic hash functions with a 128-bit
112output.
113.Pp
114.Fn MD4
115and
116.Fn MD5
117compute the MD4 and MD5 message digest of the
118.Fa n
119bytes at
120.Fa d
121and place it in
122.Fa md ,
123which must have space for
124.Dv MD4_DIGEST_LENGTH No == Dv MD5_DIGEST_LENGTH No == 16
125bytes of output.
126.Pp
127The following functions may be used if the message is not completely
128stored in memory:
129.Pp
130.Fn MD5_Init
131initializes a
132.Vt MD5_CTX
133structure.
134.Pp
135.Fn MD5_Update
136can be called repeatedly with chunks of the message to be hashed
137.Pq Fa len No bytes at Fa data .
138.Pp
139.Fn MD5_Final
140places the message digest in
141.Fa md ,
142which must have space for
143.Dv MD5_DIGEST_LENGTH No == 16
144bytes of output, and erases the
145.Vt MD5_CTX .
146.Pp
147.Fn MD4_Init ,
148.Fn MD4_Update ,
149and
150.Fn MD4_Final
151are analogous using an
152.Vt MD4_CTX
153structure.
154.Pp
155Applications should use the higher level functions
156.Xr EVP_DigestInit 3
157etc. instead of calling these hash functions directly.
158.Sh RETURN VALUES
159.Fn MD4
160and
161.Fn MD5
162return pointers to the hash value.
163.Pp
164.Fn MD4_Init ,
165.Fn MD4_Update ,
166.Fn MD4_Final ,
167.Fn MD5_Init ,
168.Fn MD5_Update ,
169and
170.Fn MD5_Final
171return 1 for success or 0 otherwise.
172.Sh SEE ALSO
173.Xr EVP_DigestInit 3
174.Sh STANDARDS
175RFC 1320, RFC 1321
176.Sh HISTORY
177.Fn MD5 ,
178.Fn MD5_Init ,
179.Fn MD5_Update ,
180and
181.Fn MD5_Final
182appeared in SSLeay 0.4 or earlier and have been available since
183.Ox 2.4 .
184.Pp
185.Fn MD4 ,
186.Fn MD4_Init ,
187.Fn MD4_Update ,
188and
189.Fn MD4_Final
190first appeared in OpenSSL 0.9.6 and have been available since
191.Ox 2.9 .
192.Sh CAVEATS
193Other implementations allow
194.Fa md
195in
196.Fn MD4
197and
198.Fn MD5
199to be
200.Dv NULL
201and return a static array, which is not thread safe.
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
deleted file mode 100644
index 9f3d448432..0000000000
--- a/src/lib/libcrypto/man/Makefile
+++ /dev/null
@@ -1,436 +0,0 @@
1# $OpenBSD: Makefile,v 1.307 2025/03/08 17:12:55 tb Exp $
2
3.include <bsd.own.mk>
4
5MAN= \
6 ACCESS_DESCRIPTION_new.3 \
7 AES_encrypt.3 \
8 ASIdentifiers_new.3 \
9 ASN1_BIT_STRING_set.3 \
10 ASN1_INTEGER_get.3 \
11 ASN1_NULL_new.3 \
12 ASN1_OBJECT_new.3 \
13 ASN1_PRINTABLE_type.3 \
14 ASN1_STRING_TABLE_get.3 \
15 ASN1_STRING_length.3 \
16 ASN1_STRING_new.3 \
17 ASN1_STRING_print_ex.3 \
18 ASN1_TIME_set.3 \
19 ASN1_TYPE_get.3 \
20 ASN1_UNIVERSALSTRING_to_string.3 \
21 ASN1_generate_nconf.3 \
22 ASN1_get_object.3 \
23 ASN1_item_d2i.3 \
24 ASN1_item_digest.3 \
25 ASN1_item_new.3 \
26 ASN1_item_pack.3 \
27 ASN1_item_sign.3 \
28 ASN1_item_verify.3 \
29 ASN1_mbstring_copy.3 \
30 ASN1_parse_dump.3 \
31 ASN1_put_object.3 \
32 ASRange_new.3 \
33 AUTHORITY_KEYID_new.3 \
34 BASIC_CONSTRAINTS_new.3 \
35 BF_set_key.3 \
36 BIO_accept.3 \
37 BIO_ctrl.3 \
38 BIO_dump.3 \
39 BIO_dup_chain.3 \
40 BIO_f_base64.3 \
41 BIO_f_buffer.3 \
42 BIO_f_cipher.3 \
43 BIO_f_md.3 \
44 BIO_f_null.3 \
45 BIO_find_type.3 \
46 BIO_get_data.3 \
47 BIO_get_ex_new_index.3 \
48 BIO_meth_new.3 \
49 BIO_new.3 \
50 BIO_new_CMS.3 \
51 BIO_printf.3 \
52 BIO_push.3 \
53 BIO_read.3 \
54 BIO_s_accept.3 \
55 BIO_s_bio.3 \
56 BIO_s_connect.3 \
57 BIO_s_datagram.3 \
58 BIO_s_fd.3 \
59 BIO_s_file.3 \
60 BIO_s_mem.3 \
61 BIO_s_null.3 \
62 BIO_s_socket.3 \
63 BIO_set_callback.3 \
64 BIO_should_retry.3 \
65 BN_CTX_new.3 \
66 BN_CTX_start.3 \
67 BN_add.3 \
68 BN_add_word.3 \
69 BN_bn2bin.3 \
70 BN_cmp.3 \
71 BN_copy.3 \
72 BN_generate_prime.3 \
73 BN_get_rfc3526_prime_8192.3 \
74 BN_kronecker.3 \
75 BN_mod_inverse.3 \
76 BN_mod_mul_montgomery.3 \
77 BN_mod_sqrt.3 \
78 BN_new.3 \
79 BN_num_bytes.3 \
80 BN_rand.3 \
81 BN_set_bit.3 \
82 BN_set_flags.3 \
83 BN_set_negative.3 \
84 BN_swap.3 \
85 BN_zero.3 \
86 BUF_MEM_new.3 \
87 CMAC_Init.3 \
88 CMS_ContentInfo_new.3 \
89 CMS_add0_cert.3 \
90 CMS_add1_recipient_cert.3 \
91 CMS_add1_signer.3 \
92 CMS_compress.3 \
93 CMS_decrypt.3 \
94 CMS_encrypt.3 \
95 CMS_final.3 \
96 CMS_get0_RecipientInfos.3 \
97 CMS_get0_SignerInfos.3 \
98 CMS_get0_type.3 \
99 CMS_get1_ReceiptRequest.3 \
100 CMS_sign.3 \
101 CMS_sign_receipt.3 \
102 CMS_signed_add1_attr.3 \
103 CMS_uncompress.3 \
104 CMS_verify.3 \
105 CMS_verify_receipt.3 \
106 CONF_modules_free.3 \
107 CONF_modules_load_file.3 \
108 CRYPTO_lock.3 \
109 CRYPTO_memcmp.3 \
110 CRYPTO_set_ex_data.3 \
111 CRYPTO_set_mem_functions.3 \
112 ChaCha.3 \
113 DES_set_key.3 \
114 DH_generate_key.3 \
115 DH_generate_parameters.3 \
116 DH_get0_pqg.3 \
117 DH_get_ex_new_index.3 \
118 DH_new.3 \
119 DH_set_method.3 \
120 DH_size.3 \
121 DIST_POINT_new.3 \
122 DSA_SIG_new.3 \
123 DSA_do_sign.3 \
124 DSA_dup_DH.3 \
125 DSA_generate_key.3 \
126 DSA_generate_parameters_ex.3 \
127 DSA_get0_pqg.3 \
128 DSA_get_ex_new_index.3 \
129 DSA_meth_new.3 \
130 DSA_new.3 \
131 DSA_set_method.3 \
132 DSA_sign.3 \
133 DSA_size.3 \
134 ECDH_compute_key.3 \
135 ECDSA_SIG_new.3 \
136 EC_GROUP_copy.3 \
137 EC_GROUP_new.3 \
138 EC_KEY_METHOD_new.3 \
139 EC_KEY_new.3 \
140 EC_POINT_add.3 \
141 EC_POINT_new.3 \
142 ENGINE_new.3 \
143 ERR.3 \
144 ERR_GET_LIB.3 \
145 ERR_asprintf_error_data.3 \
146 ERR_clear_error.3 \
147 ERR_error_string.3 \
148 ERR_get_error.3 \
149 ERR_load_crypto_strings.3 \
150 ERR_load_strings.3 \
151 ERR_print_errors.3 \
152 ERR_put_error.3 \
153 ERR_remove_state.3 \
154 ERR_set_mark.3 \
155 ESS_SIGNING_CERT_new.3 \
156 EVP_AEAD_CTX_init.3 \
157 EVP_BytesToKey.3 \
158 EVP_CIPHER_CTX_ctrl.3 \
159 EVP_CIPHER_CTX_get_cipher_data.3 \
160 EVP_CIPHER_CTX_init.3 \
161 EVP_CIPHER_CTX_set_flags.3 \
162 EVP_CIPHER_do_all.3 \
163 EVP_CIPHER_meth_new.3 \
164 EVP_CIPHER_nid.3 \
165 EVP_DigestInit.3 \
166 EVP_DigestSignInit.3 \
167 EVP_DigestVerifyInit.3 \
168 EVP_EncodeInit.3 \
169 EVP_EncryptInit.3 \
170 EVP_MD_CTX_ctrl.3 \
171 EVP_MD_nid.3 \
172 EVP_OpenInit.3 \
173 EVP_PKCS82PKEY.3 \
174 EVP_PKEY_CTX_ctrl.3 \
175 EVP_PKEY_CTX_get_operation.3 \
176 EVP_PKEY_CTX_new.3 \
177 EVP_PKEY_CTX_set_hkdf_md.3 \
178 EVP_PKEY_CTX_set_tls1_prf_md.3 \
179 EVP_PKEY_asn1_get_count.3 \
180 EVP_PKEY_cmp.3 \
181 EVP_PKEY_decrypt.3 \
182 EVP_PKEY_derive.3 \
183 EVP_PKEY_encrypt.3 \
184 EVP_PKEY_get_default_digest_nid.3 \
185 EVP_PKEY_keygen.3 \
186 EVP_PKEY_new.3 \
187 EVP_PKEY_new_CMAC_key.3 \
188 EVP_PKEY_print_private.3 \
189 EVP_PKEY_set1_RSA.3 \
190 EVP_PKEY_sign.3 \
191 EVP_PKEY_size.3 \
192 EVP_PKEY_verify.3 \
193 EVP_PKEY_verify_recover.3 \
194 EVP_SealInit.3 \
195 EVP_SignInit.3 \
196 EVP_VerifyInit.3 \
197 EVP_aes_128_cbc.3 \
198 EVP_aes_128_ccm.3 \
199 EVP_aes_128_gcm.3 \
200 EVP_camellia_128_cbc.3 \
201 EVP_chacha20.3 \
202 EVP_des_cbc.3 \
203 EVP_rc2_cbc.3 \
204 EVP_rc4.3 \
205 EVP_sha1.3 \
206 EVP_sha3_224.3 \
207 EVP_sm3.3 \
208 EVP_sm4_cbc.3 \
209 EXTENDED_KEY_USAGE_new.3 \
210 GENERAL_NAME_new.3 \
211 HMAC.3 \
212 IPAddressRange_new.3 \
213 MD5.3 \
214 NAME_CONSTRAINTS_new.3 \
215 OBJ_NAME_add.3 \
216 OBJ_create.3 \
217 OBJ_find_sigid_algs.3 \
218 OBJ_nid2obj.3 \
219 OCSP_CRLID_new.3 \
220 OCSP_REQUEST_new.3 \
221 OCSP_SERVICELOC_new.3 \
222 OCSP_cert_to_id.3 \
223 OCSP_request_add1_nonce.3 \
224 OCSP_resp_find_status.3 \
225 OCSP_response_status.3 \
226 OCSP_sendreq_new.3 \
227 OPENSSL_VERSION_NUMBER.3 \
228 OPENSSL_cleanse.3 \
229 OPENSSL_config.3 \
230 OPENSSL_init_crypto.3 \
231 OPENSSL_load_builtin_modules.3 \
232 OPENSSL_malloc.3 \
233 OPENSSL_sk_new.3 \
234 OpenSSL_add_all_algorithms.3 \
235 PEM_ASN1_read.3 \
236 PEM_X509_INFO_read.3 \
237 PEM_bytes_read_bio.3 \
238 PEM_read.3 \
239 PEM_read_bio_PrivateKey.3 \
240 PEM_write_bio_CMS_stream.3 \
241 PEM_write_bio_PKCS7_stream.3 \
242 PKCS12_SAFEBAG_new.3 \
243 PKCS12_create.3 \
244 PKCS12_new.3 \
245 PKCS12_newpass.3 \
246 PKCS12_parse.3 \
247 PKCS5_PBKDF2_HMAC.3 \
248 PKCS7_add_attribute.3 \
249 PKCS7_dataFinal.3 \
250 PKCS7_dataInit.3 \
251 PKCS7_decrypt.3 \
252 PKCS7_encrypt.3 \
253 PKCS7_final.3 \
254 PKCS7_get_signer_info.3 \
255 PKCS7_new.3 \
256 PKCS7_set_content.3 \
257 PKCS7_set_type.3 \
258 PKCS7_sign.3 \
259 PKCS7_sign_add_signer.3 \
260 PKCS7_verify.3 \
261 PKCS8_PRIV_KEY_INFO_new.3 \
262 PKCS8_pkey_set0.3 \
263 PKEY_USAGE_PERIOD_new.3 \
264 POLICYINFO_new.3 \
265 RAND_add.3 \
266 RAND_bytes.3 \
267 RAND_load_file.3 \
268 RAND_set_rand_method.3 \
269 RC2_encrypt.3 \
270 RC4.3 \
271 RIPEMD160.3 \
272 RSA_PSS_PARAMS_new.3 \
273 RSA_blinding_on.3 \
274 RSA_check_key.3 \
275 RSA_generate_key.3 \
276 RSA_get0_key.3 \
277 RSA_get_ex_new_index.3 \
278 RSA_meth_new.3 \
279 RSA_new.3 \
280 RSA_padding_add_PKCS1_type_1.3 \
281 RSA_pkey_ctx_ctrl.3 \
282 RSA_print.3 \
283 RSA_private_encrypt.3 \
284 RSA_public_encrypt.3 \
285 RSA_security_bits.3 \
286 RSA_set_method.3 \
287 RSA_sign.3 \
288 RSA_sign_ASN1_OCTET_STRING.3 \
289 RSA_size.3 \
290 SHA1.3 \
291 SMIME_crlf_copy.3 \
292 SMIME_read_ASN1.3 \
293 SMIME_read_CMS.3 \
294 SMIME_read_PKCS7.3 \
295 SMIME_text.3 \
296 SMIME_write_ASN1.3 \
297 SMIME_write_CMS.3 \
298 SMIME_write_PKCS7.3 \
299 STACK_OF.3 \
300 TS_REQ_new.3 \
301 UI_create_method.3 \
302 UI_get_string_type.3 \
303 UI_new.3 \
304 X25519.3 \
305 X509V3_EXT_get_nid.3 \
306 X509V3_EXT_print.3 \
307 X509V3_extensions_print.3 \
308 X509V3_get_d2i.3 \
309 X509V3_parse_list.3 \
310 X509_ALGOR_dup.3 \
311 X509_ATTRIBUTE_get0_object.3 \
312 X509_ATTRIBUTE_new.3 \
313 X509_ATTRIBUTE_set1_object.3 \
314 X509_CINF_new.3 \
315 X509_CRL_get0_by_serial.3 \
316 X509_CRL_new.3 \
317 X509_CRL_print.3 \
318 X509_EXTENSION_set_object.3 \
319 X509_INFO_new.3 \
320 X509_LOOKUP_hash_dir.3 \
321 X509_LOOKUP_new.3 \
322 X509_NAME_ENTRY_get_object.3 \
323 X509_NAME_add_entry_by_txt.3 \
324 X509_NAME_get_index_by_NID.3 \
325 X509_NAME_hash.3 \
326 X509_NAME_new.3 \
327 X509_NAME_print_ex.3 \
328 X509_OBJECT_get0_X509.3 \
329 X509_PKEY_new.3 \
330 X509_PUBKEY_new.3 \
331 X509_PURPOSE_set.3 \
332 X509_REQ_add1_attr.3 \
333 X509_REQ_add_extensions.3 \
334 X509_REQ_new.3 \
335 X509_REQ_print_ex.3 \
336 X509_REVOKED_new.3 \
337 X509_SIG_get0.3 \
338 X509_SIG_new.3 \
339 X509_STORE_CTX_get_error.3 \
340 X509_STORE_CTX_get_ex_new_index.3 \
341 X509_STORE_CTX_new.3 \
342 X509_STORE_CTX_set_flags.3 \
343 X509_STORE_CTX_set_verify.3 \
344 X509_STORE_CTX_set_verify_cb.3 \
345 X509_STORE_get_by_subject.3 \
346 X509_STORE_load_locations.3 \
347 X509_STORE_new.3 \
348 X509_STORE_set1_param.3 \
349 X509_STORE_set_verify_cb_func.3 \
350 X509_VERIFY_PARAM_new.3 \
351 X509_VERIFY_PARAM_set_flags.3 \
352 X509_add1_trust_object.3 \
353 X509_check_ca.3 \
354 X509_check_host.3 \
355 X509_check_issued.3 \
356 X509_check_private_key.3 \
357 X509_check_purpose.3 \
358 X509_cmp.3 \
359 X509_cmp_time.3 \
360 X509_digest.3 \
361 X509_find_by_subject.3 \
362 X509_get0_notBefore.3 \
363 X509_get0_signature.3 \
364 X509_get1_email.3 \
365 X509_get_extension_flags.3 \
366 X509_get_pubkey.3 \
367 X509_get_pubkey_parameters.3 \
368 X509_get_serialNumber.3 \
369 X509_get_subject_name.3 \
370 X509_get_version.3 \
371 X509_keyid_set1.3 \
372 X509_load_cert_file.3 \
373 X509_new.3 \
374 X509_ocspid_print.3 \
375 X509_print_ex.3 \
376 X509_sign.3 \
377 X509_signature_dump.3 \
378 X509_verify_cert.3 \
379 X509v3_addr_add_inherit.3 \
380 X509v3_addr_get_range.3 \
381 X509v3_addr_inherits.3 \
382 X509v3_addr_subset.3 \
383 X509v3_addr_validate_path.3 \
384 X509v3_asid_add_id_or_range.3 \
385 X509v3_get_ext_by_NID.3 \
386 a2d_ASN1_OBJECT.3 \
387 a2i_ipadd.3 \
388 crypto.3 \
389 d2i_ASN1_NULL.3 \
390 d2i_ASN1_OBJECT.3 \
391 d2i_ASN1_OCTET_STRING.3 \
392 d2i_ASN1_SEQUENCE_ANY.3 \
393 d2i_AUTHORITY_KEYID.3 \
394 d2i_BASIC_CONSTRAINTS.3 \
395 d2i_CMS_ContentInfo.3 \
396 d2i_DHparams.3 \
397 d2i_DIST_POINT.3 \
398 d2i_DSAPublicKey.3 \
399 d2i_ECPKParameters.3 \
400 d2i_ESS_SIGNING_CERT.3 \
401 d2i_GENERAL_NAME.3 \
402 d2i_OCSP_REQUEST.3 \
403 d2i_OCSP_RESPONSE.3 \
404 d2i_PKCS12.3 \
405 d2i_PKCS7.3 \
406 d2i_PKCS8PrivateKey_bio.3 \
407 d2i_PKCS8_PRIV_KEY_INFO.3 \
408 d2i_PKEY_USAGE_PERIOD.3 \
409 d2i_POLICYINFO.3 \
410 d2i_PrivateKey.3 \
411 d2i_RSAPublicKey.3 \
412 d2i_TS_REQ.3 \
413 d2i_X509.3 \
414 d2i_X509_ALGOR.3 \
415 d2i_X509_ATTRIBUTE.3 \
416 d2i_X509_CRL.3 \
417 d2i_X509_EXTENSION.3 \
418 d2i_X509_NAME.3 \
419 d2i_X509_REQ.3 \
420 d2i_X509_SIG.3 \
421 des_read_pw.3 \
422 evp.3 \
423 i2a_ASN1_STRING.3 \
424 i2d_CMS_bio_stream.3 \
425 i2d_PKCS7_bio_stream.3 \
426 lh_new.3 \
427 openssl.cnf.5 \
428 s2i_ASN1_INTEGER.3 \
429 v2i_ASN1_BIT_STRING.3 \
430 x509v3.cnf.5
431
432all clean cleandir depend includes obj tags:
433
434install: maninstall
435
436.include <bsd.man.mk>
diff --git a/src/lib/libcrypto/man/NAME_CONSTRAINTS_new.3 b/src/lib/libcrypto/man/NAME_CONSTRAINTS_new.3
deleted file mode 100644
index fec3aba7f7..0000000000
--- a/src/lib/libcrypto/man/NAME_CONSTRAINTS_new.3
+++ /dev/null
@@ -1,100 +0,0 @@
1.\" $OpenBSD: NAME_CONSTRAINTS_new.3,v 1.4 2020/09/17 08:50:05 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 17 2020 $
18.Dt NAME_CONSTRAINTS_NEW 3
19.Os
20.Sh NAME
21.Nm NAME_CONSTRAINTS_new ,
22.Nm NAME_CONSTRAINTS_free ,
23.Nm GENERAL_SUBTREE_new ,
24.Nm GENERAL_SUBTREE_free
25.\" .Nm NAME_CONSTRAINTS_check is intentionally undocumented.
26.\" beck@ said in the x509/x509_ncons.c rev. 1.4 commit message:
27.\" We probably need to deprecate it thoughtfully.
28.Nd X.509 CA name constraints extension
29.Sh SYNOPSIS
30.In openssl/x509v3.h
31.Ft NAME_CONSTRAINTS *
32.Fn NAME_CONSTRAINTS_new void
33.Ft void
34.Fn NAME_CONSTRAINTS_free "NAME_CONSTRAINTS *names"
35.Ft GENERAL_SUBTREE *
36.Fn GENERAL_SUBTREE_new void
37.Ft void
38.Fn GENERAL_SUBTREE_free "GENERAL_SUBTREE *name"
39.Sh DESCRIPTION
40X.509 CA certificates can use the name constraints extension
41to restrict the subject names of subsequent certificates in a
42certification path.
43.Pp
44.Fn NAME_CONSTRAINTS_new
45allocates and initializes an empty
46.Vt NAME_CONSTRAINTS
47object, representing an ASN.1
48.Vt NameConstraints
49structure defined in RFC 5280 section 4.2.1.10.
50It consists of two
51.Vt STACK_OF(GENERAL_SUBTREE)
52objects, one specifying permitted names, the other excluded names.
53.Fn NAME_CONSTRAINTS_free
54frees
55.Fa names .
56.Pp
57.Fn GENERAL_SUBTREE_new
58allocates and initializes an empty
59.Vt GENERAL_SUBTREE
60object, representing an ASN.1
61.Vt GeneralSubtree
62structure defined in RFC 5280 section 4.2.1.10.
63It is a trivial wrapper around the
64.Vt GENERAL_NAME
65object documented in
66.Xr GENERAL_NAME_new 3 .
67The standard requires the other fields of
68.Vt GENERAL_SUBTREE
69to be ignored.
70.Fn GENERAL_SUBTREE_free
71frees
72.Fa name .
73.Sh RETURN VALUES
74.Fn NAME_CONSTRAINTS_new
75and
76.Fn GENERAL_SUBTREE_new
77return the new
78.Vt NAME_CONSTRAINTS
79or
80.Vt GENERAL_SUBTREE
81object, respectively, or
82.Dv NULL
83if an error occurs.
84.Sh SEE ALSO
85.Xr BASIC_CONSTRAINTS_new 3 ,
86.Xr GENERAL_NAMES_new 3 ,
87.Xr X509_EXTENSION_new 3 ,
88.Xr X509_new 3
89.Sh STANDARDS
90RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
91Certificate Revocation List (CRL) Profile,
92section 4.2.1.10: Name Constraints
93.Sh HISTORY
94.Fn NAME_CONSTRAINTS_new ,
95.Fn NAME_CONSTRAINTS_free ,
96.Fn GENERAL_SUBTREE_new ,
97and
98.Fn GENERAL_SUBTREE_free
99first appeared in OpenSSL 0.9.8 and have been available since
100.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/OBJ_NAME_add.3 b/src/lib/libcrypto/man/OBJ_NAME_add.3
deleted file mode 100644
index 0b46010c49..0000000000
--- a/src/lib/libcrypto/man/OBJ_NAME_add.3
+++ /dev/null
@@ -1,307 +0,0 @@
1.\" $OpenBSD: OBJ_NAME_add.3,v 1.6 2024/01/31 08:02:53 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: January 31 2024 $
18.Dt OBJ_NAME_ADD 3
19.Os
20.Sh NAME
21.Nm OBJ_NAME_add ,
22.Nm OBJ_NAME_remove ,
23.Nm OBJ_NAME_get ,
24.Nm OBJ_NAME_new_index ,
25.Nm OBJ_NAME_init ,
26.Nm OBJ_NAME_cleanup
27.Nd global associative array
28.Sh SYNOPSIS
29.In openssl/objects.h
30.Ft int
31.Fo OBJ_NAME_add
32.Fa "const char *name"
33.Fa "int type"
34.Fa "const char *value"
35.Fc
36.Ft int
37.Fo OBJ_NAME_remove
38.Fa "const char *name"
39.Fa "int type"
40.Fc
41.Ft const char *
42.Fo OBJ_NAME_get
43.Fa "const char *name"
44.Fa "int type"
45.Fc
46.Ft int
47.Fo OBJ_NAME_new_index
48.Fa "unsigned long (*hash_func)(const char *name)"
49.Fa "int (*cmp_func)(const char *name1, const char *name2)"
50.Fa "void (*free_func)(const char *name, int type, const char *value)"
51.Fc
52.Ft int
53.Fn OBJ_NAME_init void
54.Ft void
55.Fn OBJ_NAME_cleanup "int type"
56.Bd -literal
57typedef struct {
58 int type;
59 int alias;
60 const char *name;
61 const char *data;
62} OBJ_NAME;
63.Ed
64.Sh DESCRIPTION
65These functions implement a single, static associative array
66with the following properties:
67.Bl -bullet
68.It
69The keys are ordered pairs consisting of a NUL-terminated string
70.Pq called the Fa name
71and an
72.Vt int
73number
74.Pq called the Fa type .
75Two types are predefined and used internally by the library:
76.Dv OBJ_NAME_TYPE_MD_METH
77and
78.Dv OBJ_NAME_TYPE_CIPHER_METH .
79Two additional types are predefined but not used internally:
80.Dv OBJ_NAME_TYPE_PKEY_METH
81and
82.Dv OBJ_NAME_TYPE_COMP_METH .
83All predefined types are greater than
84.Dv OBJ_NAME_TYPE_UNDEF
85and smaller than
86.Dv OBJ_NAME_TYPE_NUM .
87.It
88The values are pointers.
89Formally, they are of the type
90.Vt const char * ,
91but in practice, pointers of other types, for example
92.Vt EVP_CIPHER *
93or
94.Vt EVP_MD * ,
95are often stored as values
96and cast back to the correct type on retrieval.
97.It
98The array supports type-specific aliases for names.
99.El
100.Pp
101.Fn OBJ_NAME_add
102removes the key-value pair or alias with the key
103.Pq Fa name , type
104in the same way as
105.Fn OBJ_NAME_remove
106and inserts a key-value pair with the specified
107.Fa name ,
108.Fa type ,
109and
110.Fa value .
111If the bit
112.Dv OBJ_NAME_ALIAS
113is set in the
114.Fa type
115argument, that bit is cleared before using the
116.Fa type
117and the key
118.Pq Fa name , type
119becomes an alias for the key
120.Pq Fa value , type
121instead of setting a value.
122It is not checked whether the key
123.Pq Fa value , type
124already exists.
125Consequently, it is possible to define an alias
126before setting the associated value.
127.Pp
128.Fn OBJ_NAME_remove
129removes the key-value pair or alias with the key
130.Pq Fa name , type
131from the array, if it exists.
132Otherwise, it has no effect.
133If the bit
134.Dv OBJ_NAME_ALIAS
135is set in the
136.Fa type
137argument, it is ignored and cleared before using the
138.Fa type .
139If the
140.Fa type
141is an application-defined type added with
142.Fn OBJ_NAME_new_index
143and the
144.Fa free_func
145associated with the
146.Fa type
147is not a
148.Dv NULL
149pointer, it is called with the
150.Fa name ,
151.Fa type ,
152and
153.Fa value
154of the key-value pair being removed or with the
155.Fa name ,
156.Fa type ,
157and alias target name of the alias being removed.
158In typical usage, this function might free the
159.Fa name ,
160and it might free the
161.Fa value
162in a type-specific way.
163.Pp
164.Fn OBJ_NAME_get
165looks up the key
166.Pq Fa name , type ,
167recursively resolving up to ten aliases if needed.
168If the bit
169.Dv OBJ_NAME_ALIAS
170is set in the
171.Fa type
172argument, it is cleared before using the
173.Fa type ,
174processing of aliases is disabled, and if
175.Pq Fa name , type
176is an alias, the target name of the alias is returned instead of a value.
177.Pp
178.Fn OBJ_NAME_new_index
179assigns the smallest unassigned positive integer number
180to represent a new, application-defined
181.Fa type .
182The three function pointers will be used, respectively,
183to hash a name for this type, to compare two names for this type,
184and to free the contents of a key-value pair holding the given
185.Fa name ,
186.Fa type ,
187and
188.Fa value .
189If the
190.Fa hash_func
191argument is a
192.Dv NULL
193pointer,
194.Xr lh_strhash 3
195is used instead.
196If the
197.Fa cmp_func
198argument is a
199.Dv NULL
200pointer,
201.Xr strcmp 3
202is used instead.
203If the
204.Fa free_func
205argument is a
206.Dv NULL
207pointer, the
208.Fa name
209and
210.Fa value
211pointers contained in the key-value pair are not freed,
212only the structure representing the pair itself is.
213This default behaviour is also used for the built-in types.
214.Pp
215.Fn OBJ_NAME_init
216initializes the array.
217After initialization, the array is empty.
218Calling
219.Fn OBJ_NAME_init
220when the array is already initialized has no effect.
221Application programs do not need to call this function because
222.Fn OBJ_NAME_add
223and
224.Fn OBJ_NAME_get
225automatically call it whenever needed.
226.Pp
227.Fn OBJ_NAME_cleanup
228removes all key-value pairs and aliases of the given
229.Fa type
230from the array by calling
231.Fn OBJ_NAME_remove
232on every such pair and alias.
233If the
234.Fa type
235argument is negative, it removes all key-value pairs and aliases
236of any type and also reverses all effects of
237.Fn OBJ_NAME_new_index
238and
239.Fn OBJ_NAME_init ,
240in particular resetting the list of types to the predefined types
241and releasing all memory reserved by these functions.
242.Pp
243The
244.Vt OBJ_NAME
245structure represents one key-value pair or one alias with the key
246.Pq Fa name , type .
247If the
248.Fa alias
249field is 0, the
250.Fa data
251field contains the value; otherwise, it contains the alias target name.
252.Sh RETURN VALUES
253.Fn OBJ_NAME_add
254and
255.Fn OBJ_NAME_init
256return 1 on success or 0 if memory allocation fails.
257.Pp
258.Fn OBJ_NAME_remove
259returns 1 if one key-value pair or alias was removed or 0 otherwise.
260.Pp
261.Fn OBJ_NAME_get
262returns the
263.Fa value
264associated with the key
265.Pq Fa name , type
266or
267.Dv NULL
268if
269.Fa name
270is
271.Dv NULL ,
272if the array does not contain a value for this key,
273or if more than ten aliases are encountered before finding a value.
274.Pp
275.Fn OBJ_NAME_new_index
276returns a positive integer greater than or equal to
277.Dv OBJ_NAME_TYPE_NUM
278representing the new type or 0 if memory allocation fails.
279.Sh SEE ALSO
280.Xr EVP_cleanup 3 ,
281.Xr EVP_get_cipherbyname 3 ,
282.Xr EVP_get_digestbyname 3 ,
283.Xr lh_new 3 ,
284.Xr OBJ_create 3 ,
285.Xr OBJ_nid2obj 3
286.Sh BUGS
287Calling
288.Fn OBJ_NAME_get
289with the bit
290.Dv OBJ_NAME_ALIAS
291is not very useful because there is no way to tell
292whether the returned pointer points to a value or to a name,
293short of calling the function again without setting the bit
294and comparing the two returned pointers.
295.Pp
296The
297.Fa free_func
298has no way to tell whether its
299.Fa value
300argument is indeed of the given
301.Fa type
302or whether it is merely the target name of an alias.
303Consequently, to use values of a type
304that requires more cleanup than merely calling
305.Xr free 3
306on it, instances of the type need to begin with a magic number or string
307that cannot occur at the beginning of a name.
diff --git a/src/lib/libcrypto/man/OBJ_create.3 b/src/lib/libcrypto/man/OBJ_create.3
deleted file mode 100644
index fa5bde3dd3..0000000000
--- a/src/lib/libcrypto/man/OBJ_create.3
+++ /dev/null
@@ -1,249 +0,0 @@
1.\" $OpenBSD: OBJ_create.3,v 1.10 2024/01/31 08:02:53 tb Exp $
2.\" full merge up to:
3.\" OpenSSL OBJ_nid2obj.pod 9b86974e Aug 17 15:21:33 2015 -0400
4.\" selective merge up to:
5.\" OpenSSL OBJ_nid2obj.pod 0c5bc96f Mar 15 13:57:22 2022 +0000
6.\"
7.\" This file is a derived work.
8.\" The changes are covered by the following Copyright and license:
9.\"
10.\" Copyright (c) 2017, 2021, 2023 Ingo Schwarze <schwarze@openbsd.org>
11.\"
12.\" Permission to use, copy, modify, and distribute this software for any
13.\" purpose with or without fee is hereby granted, provided that the above
14.\" copyright notice and this permission notice appear in all copies.
15.\"
16.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
17.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
18.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23.\"
24.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
25.\" Copyright (c) 2002, 2006 The OpenSSL Project.
26.\" All rights reserved.
27.\"
28.\" Redistribution and use in source and binary forms, with or without
29.\" modification, are permitted provided that the following conditions
30.\" are met:
31.\"
32.\" 1. Redistributions of source code must retain the above copyright
33.\" notice, this list of conditions and the following disclaimer.
34.\"
35.\" 2. Redistributions in binary form must reproduce the above copyright
36.\" notice, this list of conditions and the following disclaimer in
37.\" the documentation and/or other materials provided with the
38.\" distribution.
39.\"
40.\" 3. All advertising materials mentioning features or use of this
41.\" software must display the following acknowledgment:
42.\" "This product includes software developed by the OpenSSL Project
43.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
44.\"
45.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
46.\" endorse or promote products derived from this software without
47.\" prior written permission. For written permission, please contact
48.\" openssl-core@openssl.org.
49.\"
50.\" 5. Products derived from this software may not be called "OpenSSL"
51.\" nor may "OpenSSL" appear in their names without prior written
52.\" permission of the OpenSSL Project.
53.\"
54.\" 6. Redistributions of any form whatsoever must retain the following
55.\" acknowledgment:
56.\" "This product includes software developed by the OpenSSL Project
57.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
58.\"
59.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
60.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
62.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
63.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
64.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
65.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
66.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
68.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\"
72.Dd $Mdocdate: January 31 2024 $
73.Dt OBJ_CREATE 3
74.Os
75.Sh NAME
76.Nm OBJ_new_nid ,
77.Nm OBJ_add_object ,
78.Nm OBJ_create ,
79.\" OBJ_create_and_add_object is a deprecated, unused alias for OBJ_create(3).
80.Nm OBJ_create_objects ,
81.Nm OBJ_cleanup
82.Nd modify the table of ASN.1 object identifiers
83.Sh SYNOPSIS
84.In openssl/objects.h
85.Ft int
86.Fn OBJ_new_nid "int increment"
87.Ft int
88.Fn OBJ_add_object "const ASN1_OBJECT *object"
89.Ft int
90.Fo OBJ_create
91.Fa "const char *oid"
92.Fa "const char *sn"
93.Fa "const char *ln"
94.Fc
95.Ft int
96.Fn OBJ_create_objects "BIO *in_bio"
97.Ft void
98.Fn OBJ_cleanup void
99.Sh DESCRIPTION
100.Fn OBJ_new_nid
101returns the smallest currently unassigned ASN.1 numeric
102object identifier (NID) and reserves
103.Fa increment
104consecutive NIDs starting with it.
105Passing an argument of 1 is usually recommended.
106The return value can be assigned to a new object by passing it as the
107.Fa nid
108argument to
109.Xr ASN1_OBJECT_create 3
110and by passing the resulting object to
111.Fn OBJ_add_object .
112.Pp
113.Fn OBJ_add_object
114adds a copy of the
115.Fa object
116to the internal table of ASN.1 object identifiers for use by
117.Xr OBJ_nid2obj 3
118and related functions.
119.Pp
120.Fn OBJ_create
121provides a simpler way to add a new object to the internal table.
122.Fa oid
123is the numerical form of the object,
124.Fa sn
125the short name and
126.Fa ln
127the long name.
128A new NID is automatically assigned using
129.Fn OBJ_new_nid .
130.Pp
131.Fn OBJ_create_objects
132reads text lines of the form
133.Pp
134.D1 Fa oid sn ln
135.Pp
136from
137.Fa in_bio
138and calls
139.Fn OBJ_create oid sn ln
140for every line read.
141The three fields of the input lines
142are separated by one or more whitespace characters.
143.Pp
144For all three functions, the objects added to the internal table and
145all the data contained in them is marked as not dynamically allocated.
146Consequently, retrieving them with
147.Xr OBJ_nid2obj 3
148or a similar function and then calling
149.Xr ASN1_OBJECT_free 3
150on the returned pointer will have no effect.
151.Pp
152.Fn OBJ_cleanup
153resets the internal object table to its default state,
154removing and freeing all objects that were added with
155.Fn OBJ_add_object ,
156.Fn OBJ_create ,
157or
158.Fn OBJ_create_objects .
159.Sh RETURN VALUES
160.Fn OBJ_new_nid
161returns the new NID.
162.Pp
163.Fn OBJ_add_object
164returns the NID of the added
165.Fa object
166or
167.Dv NID_undef
168if no object was added because the
169.Fa object
170argument was
171.Dv NULL ,
172did not contain an NID, or memory allocation failed.
173.Pp
174.Fn OBJ_create
175returns the new NID or
176.Dv NID_undef
177if
178.Fa oid
179is not a valid representation of an object identifier
180or if memory allocation fails.
181.Pp
182.Fn OBJ_create_objects
183returns the number of objects added.
184.Pp
185In some cases of failure of
186.Fn OBJ_add_object ,
187.Fn OBJ_create ,
188and
189.Fn OBJ_create_objects ,
190the reason can be determined with
191.Xr ERR_get_error 3 .
192.Sh EXAMPLES
193Create a new NID and initialize an object from it:
194.Bd -literal -offset indent
195int new_nid;
196ASN1_OBJECT *obj;
197
198new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier");
199obj = OBJ_nid2obj(new_nid);
200.Ed
201.Sh SEE ALSO
202.Xr ASN1_OBJECT_new 3 ,
203.Xr OBJ_nid2obj 3
204.Sh HISTORY
205.Fn OBJ_new_nid ,
206.Fn OBJ_add_object ,
207and
208.Fn OBJ_cleanup
209first appeared in SSLeay 0.8.0 and
210.Fn OBJ_create
211in SSLeay 0.9.0.
212These functions have been available since
213.Ox 2.4 .
214.Sh CAVEATS
215.Fn OBJ_add_object
216indicates success even after adding an incomplete object that was created with
217.Xr ASN1_OBJECT_create 3
218but lacks a short name, a long name, or an OID.
219.Pp
220Even
221.Fn OBJ_create
222tolerates
223.Dv NULL
224pointers being passed for the
225.Fa sn
226and/or
227.Fa ln
228arguments, in which case
229.Xr OBJ_nid2sn 3
230and
231.Xr OBJ_sn2nid 3
232or
233.Xr OBJ_nid2ln 3
234and
235.Xr OBJ_ln2nid 3
236will not work on the added object, respectively.
237.Sh BUGS
238.Fn OBJ_new_nid
239does not reserve any return value to indicate an error.
240Consequently, to avoid conflicting NID assignments and integer overflows,
241care must be taken to not pass negative, zero, or large arguments to
242.Fn OBJ_new_nid .
243.Pp
244.Fn OBJ_create_objects
245does not distinguish between end of file, I/O errors, temporary
246unavailability of data on a non-blocking BIO, invalid input syntax,
247and memory allocation failure.
248In all these cases, reading is aborted and the number of objects
249that were already added is returned.
diff --git a/src/lib/libcrypto/man/OBJ_find_sigid_algs.3 b/src/lib/libcrypto/man/OBJ_find_sigid_algs.3
deleted file mode 100644
index 1d7a2b649b..0000000000
--- a/src/lib/libcrypto/man/OBJ_find_sigid_algs.3
+++ /dev/null
@@ -1,89 +0,0 @@
1.\" $OpenBSD: OBJ_find_sigid_algs.3,v 1.2 2024/01/31 08:02:53 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: January 31 2024 $
18.Dt OBJ_FIND_SIGID_ALGS 3
19.Os
20.Sh NAME
21.Nm OBJ_find_sigid_algs ,
22.Nm OBJ_find_sigid_by_algs
23.Nd signature algorithm mappings
24.Sh SYNOPSIS
25.In openssl/objects.h
26.Ft int
27.Fo OBJ_find_sigid_algs
28.Fa "int signature"
29.Fa "int *pdigest"
30.Fa "int *pencryption"
31.Fc
32.Ft int
33.Fo OBJ_find_sigid_by_algs
34.Fa "int *psignature"
35.Fa "int digest"
36.Fa "int encryption"
37.Fc
38.Sh DESCRIPTION
39.Fn OBJ_find_sigid_algs
40looks up the
41.Fa signature
42algorithm.
43If it is found, the associated digest algorithm is stored in
44.Pf * Fa pdigest
45unless
46.Fa pdigest
47is a
48.Dv NULL
49pointer, and the associated encryption algorithm is stored in
50.Pf * Fa pencryption
51unless
52.Fa pencryption
53is a
54.Dv NULL
55pointer.
56.Pp
57.Fn OBJ_find_sigid_by_algs
58looks up the pair
59.Pq Fa digest , encryption .
60If it is found, the associated signature algorithm is stored in
61.Pf * Fa psignature
62unless
63.Fa psignature
64is a
65.Dv NULL
66pointer.
67.Sh RETURN VALUES
68.Fn OBJ_find_sigid_algs
69returns 1 if a definition of the
70.Fa signature
71algorithm is found or 0 if a definition of the
72.Fa signature
73algorithm is not built into the library.
74.Pp
75.Fn OBJ_find_sigid_by_algs
76returns 1 if a signature algorithm using the specified
77.Fa digest
78and
79.Fa encryption
80algorithms is defined or 0 if the definition of such an algorithm
81is not built into the library.
82.Sh SEE ALSO
83.Xr EVP_cleanup 3 ,
84.Xr OBJ_create 3 ,
85.Xr OBJ_nid2obj 3
86.Sh HISTORY
87These functions first appeared in OpenSSL 1.0.0
88and have been available since
89.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/OBJ_nid2obj.3 b/src/lib/libcrypto/man/OBJ_nid2obj.3
deleted file mode 100644
index ccab1ed30c..0000000000
--- a/src/lib/libcrypto/man/OBJ_nid2obj.3
+++ /dev/null
@@ -1,521 +0,0 @@
1.\" $OpenBSD: OBJ_nid2obj.3,v 1.22 2024/01/31 08:02:53 tb Exp $
2.\" full merge up to: OpenSSL c264592d May 14 11:28:00 2006 +0000
3.\" selective merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2017, 2021, 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2002, 2006, 2016 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: January 31 2024 $
71.Dt OBJ_NID2OBJ 3
72.Os
73.Sh NAME
74.Nm OBJ_nid2obj ,
75.Nm OBJ_nid2ln ,
76.Nm OBJ_nid2sn ,
77.Nm OBJ_obj2nid ,
78.Nm OBJ_ln2nid ,
79.Nm OBJ_sn2nid ,
80.Nm OBJ_txt2nid ,
81.Nm OBJ_txt2obj ,
82.Nm OBJ_obj2txt ,
83.Nm OBJ_cmp ,
84.Nm OBJ_dup ,
85.Nm i2t_ASN1_OBJECT ,
86.Nm i2a_ASN1_OBJECT
87.Nd inspect and create ASN.1 object identifiers
88.Sh SYNOPSIS
89.In openssl/objects.h
90.Ft ASN1_OBJECT *
91.Fo OBJ_nid2obj
92.Fa "int nid"
93.Fc
94.Ft const char *
95.Fo OBJ_nid2ln
96.Fa "int nid"
97.Fc
98.Ft const char *
99.Fo OBJ_nid2sn
100.Fa "int nid"
101.Fc
102.Ft int
103.Fo OBJ_obj2nid
104.Fa "const ASN1_OBJECT *object"
105.Fc
106.Ft int
107.Fo OBJ_ln2nid
108.Fa "const char *ln"
109.Fc
110.Ft int
111.Fo OBJ_sn2nid
112.Fa "const char *sn"
113.Fc
114.Ft int
115.Fo OBJ_txt2nid
116.Fa "const char *s"
117.Fc
118.Ft ASN1_OBJECT *
119.Fo OBJ_txt2obj
120.Fa "const char *s"
121.Fa "int no_name"
122.Fc
123.Ft int
124.Fo OBJ_obj2txt
125.Fa "char *buf"
126.Fa "int buf_len"
127.Fa "const ASN1_OBJECT *object"
128.Fa "int no_name"
129.Fc
130.Ft int
131.Fo OBJ_cmp
132.Fa "const ASN1_OBJECT *a"
133.Fa "const ASN1_OBJECT *b"
134.Fc
135.Ft ASN1_OBJECT *
136.Fo OBJ_dup
137.Fa "const ASN1_OBJECT *object"
138.Fc
139.In openssl/asn1.h
140.Ft int
141.Fo i2t_ASN1_OBJECT
142.Fa "char *buf"
143.Fa "int buf_len"
144.Fa "const ASN1_OBJECT *object"
145.Fc
146.Ft int
147.Fo i2a_ASN1_OBJECT
148.Fa "BIO *out_bio"
149.Fa "const ASN1_OBJECT *object"
150.Fc
151.Sh DESCRIPTION
152The ASN.1 object utility functions process
153.Vt ASN1_OBJECT
154structures, in the following called
155.Dq objects .
156An object represents an ASN.1
157.Vt OBJECT IDENTIFIER
158.Pq OID .
159The library maintains an internal global table of objects.
160Many of these objects are built into the library
161and contained in the global table by default.
162The application program can add additional objects to the global table
163by using functions documented in the
164.Xr OBJ_create 3
165manual page.
166Consequently, there are three classes of objects:
167built-in table objects, user-defined table objects, and non-table objects.
168.Pp
169In addition to the OID, each object can hold
170a long name, a short name, and a numerical identifier (NID).
171Even though the concept of NIDs is specific to the library
172and not standardized, using the NID is often the most convenient way
173for source code to refer to a specific OID.
174The NIDs of the built-in objects are available as defined constants.
175.Pp
176Built-in table objects have certain advantages
177over objects that are not in the global table:
178for example, their NIDs can be used in C language switch statements.
179They are also shared:
180there is only a single static constant structure for each built-on OID.
181.Pp
182Some functions operate on table objects only:
183.Pp
184.Fn OBJ_nid2obj
185retrieves the table object associated with the
186.Fa nid .
187.Fn OBJ_nid2ln
188and
189.Fn OBJ_nid2sn
190retrieve its long and short name, respectively.
191.Pp
192.Fn OBJ_obj2nid
193retrieves the NID associated with the given
194.Fa object ,
195which is either the NID stored in the
196.Fa object
197itself, if any, or otherwise the NID stored in a table object
198containing the same OID.
199.Pp
200.Fn OBJ_ln2nid
201and
202.Fn OBJ_sn2nid
203retrieve the NID from the table object with the long name
204.Fa ln
205or the short name
206.Fa sn ,
207respectively.
208.Pp
209.Fn OBJ_txt2nid
210retrieves the NID from the table object described by the text string
211.Fa s ,
212which can be a long name, a short name,
213or the numerical representation of an OID.
214.Pp
215The remaining functions can be used both on table objects
216and on objects that are not in the global table:
217.Pp
218.Fn OBJ_txt2obj
219retrieves or creates an object matching the text string
220.Fa s .
221If
222.Fa no_name
223is 1, only the numerical representation of an OID is accepted.
224If
225.Fa no_name
226is 0, long names and short names are accepted as well.
227.Pp
228.Fn OBJ_obj2txt
229writes a NUL terminated textual representation
230of the OID contained in the given
231.Fa object
232into
233.Fa buf .
234At most
235.Fa buf_len
236bytes are written, truncating the result if necessary.
237The total amount of space required is returned.
238If
239.Fa no_name
240is 0 and the table object containing the same OID
241contains a long name, the long name is written.
242Otherwise, if
243.Fa no_name
244is 0 and the table object containing the same OID
245contains a short name, the short name is written.
246Otherwise, the numerical representation of the OID is written.
247.Pp
248.Fn i2t_ASN1_OBJECT
249is the same as
250.Fn OBJ_obj2txt
251with
252.Fa no_name
253set to 0.
254.Pp
255.Fn i2a_ASN1_OBJECT
256writes a textual representation of the OID contained in the given
257.Fa object
258to
259.Fa out_bio
260using
261.Xr BIO_write 3 .
262It does not write a terminating NUL byte.
263If the
264.Fa object
265argument is
266.Dv NULL
267or contains no OID, it writes the 4-byte string
268.Qq NULL .
269If
270.Fn i2t_ASN1_OBJECT
271fails,
272.Fn i2a_ASN1_OBJECT
273writes the 9-byte string
274.Qq <INVALID> .
275Otherwise, it writes the string constructed with
276.Fn i2t_ASN1_OBJECT .
277.Pp
278.Fn OBJ_cmp
279tests whether
280.Fa a
281and
282.Fa b
283represent the same ASN.1
284.Vt OBJECT IDENTIFIER .
285Any names and NIDs contained in the two objects are ignored,
286even if they differ between both objects.
287.Pp
288.Fn OBJ_dup
289returns a deep copy of the given
290.Fa object
291if it is marked as dynamically allocated.
292The new object and all data contained in it are marked as dynamically
293allocated.
294If the given
295.Fa object
296is not marked as dynamically allocated,
297.Fn OBJ_dup
298just returns a pointer to the
299.Fa object
300itself.
301.Sh RETURN VALUES
302Application code should treat all returned values \(em
303objects, names, and NIDs \(em as constants.
304.Pp
305.Fn OBJ_nid2obj
306returns a pointer to a table object owned by the library or
307.Dv NULL
308if no matching table object is found.
309.Pp
310.Fn OBJ_nid2ln
311and
312.Fn OBJ_nid2sn
313return a pointer to a string owned by a table object or
314.Dv NULL
315if no matching table object is found.
316For
317.Dv NID_undef ,
318they return the constant static strings
319.Qq undefined
320and
321.Qq UNDEF ,
322respectively.
323.Pp
324.Fn OBJ_obj2nid
325returns an NID on success, or
326.Dv NID_undef
327if
328.Fa object
329is
330.Dv NULL ,
331does not contain an OID,
332if no table object matching the OID is found,
333or if the matching object does not contain an NID.
334.Pp
335.Fn OBJ_ln2nid
336and
337.Fn OBJ_sn2nid
338return an NID on success or
339.Dv NID_undef
340if no matching table object is found
341or if the matching object does not contain an NID.
342.Pp
343.Fn OBJ_txt2nid
344returns an NID on success or
345.Dv NID_undef
346if parsing of
347.Fa s
348or memory allocation fails, if no matching table object is found,
349or if the matching object does not contain an NID.
350.Pp
351.Fn OBJ_txt2obj
352returns a pointer to a table object owned by the library if lookup of
353.Fa s
354as a long or short name succeeds.
355Otherwise, it returns a newly created object,
356transferring ownership to the caller, or
357.Dv NULL
358if parsing of
359.Fa s
360or memory allocation fails.
361.Pp
362.Fn OBJ_obj2txt
363and
364.Fn i2t_ASN1_OBJECT
365return the amount of space required in bytes,
366including the terminating NUL byte,
367or zero if an error occurs before the required space can be calculated,
368in particular if
369.Fa buf_len
370is negative,
371.Fa object
372is
373.Dv NULL
374or does not contain an OID,
375or if memory allocation fails.
376.Pp
377.Fn OBJ_cmp
378returns 0 if both objects refer to the same OID
379or neither of them are associated with any OID,
380or a non-zero value if at least one of them refers to an OID
381but the other one does not refer to the same OID.
382.Pp
383.Fn OBJ_dup
384returns the pointer to the original
385.Fa object
386if it is not marked as dynamically allocated.
387Otherwise, it returns a newly created object,
388transferring ownership to the caller, or
389.Dv NULL
390if
391.Fa object
392is
393.Dv NULL
394or memory allocation fails.
395.Pp
396.Fn i2a_ASN1_OBJECT
397returns the number of bytes written, even if the given
398.Fa object
399is invalid or contains invalid data,
400but a negative value if memory allocation or a write operation fails.
401.Pp
402In some cases of failure of
403.Fn OBJ_nid2obj ,
404.Fn OBJ_nid2ln ,
405.Fn OBJ_nid2sn ,
406.Fn OBJ_txt2nid ,
407.Fn OBJ_txt2obj ,
408.Fn OBJ_obj2txt ,
409.Fn OBJ_dup ,
410.Fn i2t_ASN1_OBJECT ,
411and
412.Fn i2a_ASN1_OBJECT ,
413the reason can be determined with
414.Xr ERR_get_error 3 .
415.Sh EXAMPLES
416Retrieve the object for
417.Sy commonName :
418.Bd -literal -offset indent
419ASN1_OBJECT *object;
420object = OBJ_nid2obj(NID_commonName);
421.Ed
422.Pp
423Check whether an object contains the OID for
424.Sy commonName :
425.Bd -literal -offset indent
426if (OBJ_obj2nid(object) == NID_commonName)
427 /* Do something */
428.Ed
429.Pp
430Create a new object directly:
431.Bd -literal -offset indent
432object = OBJ_txt2obj("1.2.3.4", 1);
433.Ed
434.Sh SEE ALSO
435.Xr ASN1_OBJECT_new 3 ,
436.Xr BIO_new 3 ,
437.Xr d2i_ASN1_OBJECT 3 ,
438.Xr OBJ_create 3
439.Sh HISTORY
440.Fn OBJ_nid2obj ,
441.Fn OBJ_nid2ln ,
442.Fn OBJ_nid2sn ,
443.Fn OBJ_obj2nid ,
444.Fn OBJ_ln2nid ,
445.Fn OBJ_sn2nid ,
446.Fn OBJ_txt2nid ,
447.Fn OBJ_cmp ,
448and
449.Fn OBJ_dup
450first appeared in SSLeay 0.5.1.
451.Fn i2a_ASN1_OBJECT
452first appeared in SSLeay 0.6.0, and
453.Fn i2t_ASN1_OBJECT
454in SSLeay 0.9.0.
455All these functions have been available since
456.Ox 2.4 .
457.Pp
458.Fn OBJ_txt2obj
459first appeared in OpenSSL 0.9.2b.
460.Fn OBJ_obj2txt
461first appeared in OpenSSL 0.9.4.
462Both functions have been available since
463.Ox 2.6 .
464.Sh CAVEATS
465The API contract of
466.Fn OBJ_txt2obj
467when called with a
468.Fa no_name
469argument of 0 and of
470.Fn OBJ_dup
471is scary in so far as the caller cannot find out from the returned
472object whether it is owned by the library or whether ownership was
473transferred to the caller.
474Consequently, it is best practice to assume that ownership of the object
475may have been transferred and call
476.Xr ASN1_OBJECT_free 3
477on the returned object when the caller no longer needs it.
478In case the library retained ownership of the returned object,
479.Xr ASN1_OBJECT_free 3
480has no effect and is harmless.
481.Pp
482Objects returned from
483.Fn OBJ_txt2obj
484with a
485.Fa no_name
486argument of 1 always require
487.Xr ASN1_OBJECT_free 3
488to prevent memory leaks.
489.Pp
490Objects returned from
491.Fn OBJ_nid2obj
492never require
493.Xr ASN1_OBJECT_free 3 ,
494but calling it anyway has no effect and is harmless.
495.Sh BUGS
496Usually, an object is expected to contain an NID other than
497.Dv NID_undef
498if and only if it is a table object.
499However, this is not an invariant guaranteed by the API.
500In particular,
501.Xr ASN1_OBJECT_create 3
502allows the creation of non-table objects containing bogus NIDs.
503.Fn OBJ_obj2nid
504returns such bogus NIDs even though
505.Fn OBJ_nid2obj
506cannot use them for retrieval.
507On top of that, the global table contains one built-in object with an NID of
508.Dv NID_undef .
509.Pp
510.Fn OBJ_obj2txt
511is awkward and messy to use: it doesn't follow the convention of other
512OpenSSL functions where the buffer can be set to
513.Dv NULL
514to determine the amount of data that should be written.
515Instead
516.Fa buf
517must point to a valid buffer and
518.Fa buf_len
519should be set to a positive value.
520A buffer length of 80 should be more than enough to handle any OID
521encountered in practice.
diff --git a/src/lib/libcrypto/man/OCSP_CRLID_new.3 b/src/lib/libcrypto/man/OCSP_CRLID_new.3
deleted file mode 100644
index 6feb608654..0000000000
--- a/src/lib/libcrypto/man/OCSP_CRLID_new.3
+++ /dev/null
@@ -1,113 +0,0 @@
1.\" $OpenBSD: OCSP_CRLID_new.3,v 1.8 2022/01/15 23:38:50 jsg Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: January 15 2022 $
18.Dt OCSP_CRLID_NEW 3
19.Os
20.Sh NAME
21.Nm OCSP_CRLID_new ,
22.Nm OCSP_CRLID_free ,
23.Nm OCSP_crlID_new
24.Nd OCSP CRL extension
25.Sh SYNOPSIS
26.In openssl/ocsp.h
27.Ft OCSP_CRLID *
28.Fn OCSP_CRLID_new void
29.Ft void
30.Fn OCSP_CRLID_free "OCSP_CRLID *crlid"
31.Ft X509_EXTENSION *
32.Fo OCSP_crlID_new
33.Fa "const char *url"
34.Fa "long *number"
35.Fa "char *time"
36.Fc
37.Sh DESCRIPTION
38If a client asks about the validity of a certificate and it turns
39out to be invalid, the responder may optionally communicate which
40certificate revocation list the certificate was found on.
41The required data is stored as an ASN.1
42.Vt CrlID
43structure in the singleExtensions field of the
44.Vt SingleResponse
45structure.
46The
47.Vt CrlID
48is represented by an
49.Vt OCSP_CRLID
50object, which will be stored inside the
51.Vt OCSP_SINGLERESP
52object documented in
53.Xr OCSP_SINGLERESP_new 3 .
54.Pp
55.Fn OCSP_CRLID_new
56allocates and initializes an empty
57.Vt OCSP_CRLID
58object.
59.Fn OCSP_CRLID_free
60frees
61.Fa crlid .
62.Pp
63.Fn OCSP_crlID_new
64accepts the
65.Fa url
66at which the CRL is available, the CRL
67.Fa number ,
68and/or the
69.Fa time
70at which the CRL was created.
71Each argument can be
72.Dv NULL ,
73in which case the respective field is omitted.
74The resulting
75.Vt CrlID
76structure is encoded in ASN.1 using
77.Xr X509V3_EXT_i2d 3
78with criticality 0.
79.Sh RETURN VALUES
80.Fn OCSP_CRLID_new
81returns a new
82.Vt OCSP_CRLID
83object or
84.Dv NULL
85if an error occurred.
86.Pp
87.Fn OCSP_crlID_new
88returns a new
89.Vt X509_EXTENSION
90object or
91.Dv NULL
92if an error occurred.
93.Sh SEE ALSO
94.Xr OCSP_REQUEST_new 3 ,
95.Xr OCSP_resp_find_status 3 ,
96.Xr OCSP_response_status 3 ,
97.Xr X509_EXTENSION_new 3
98.Sh STANDARDS
99RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
100Status Protocol, section 4.4.2: CRL References
101.Sh HISTORY
102.Fn OCSP_CRLID_new ,
103.Fn OCSP_CRLID_free ,
104and
105.Fn OCSP_crlID_new
106first appeared in OpenSSL 0.9.7 and have been available since
107.Ox 3.2 .
108.Sh CAVEATS
109The function names
110.Fn OCSP_CRLID_new
111and
112.Fn OCSP_crlID_new
113only differ in case.
diff --git a/src/lib/libcrypto/man/OCSP_REQUEST_new.3 b/src/lib/libcrypto/man/OCSP_REQUEST_new.3
deleted file mode 100644
index a304f60160..0000000000
--- a/src/lib/libcrypto/man/OCSP_REQUEST_new.3
+++ /dev/null
@@ -1,329 +0,0 @@
1.\" $OpenBSD: OCSP_REQUEST_new.3,v 1.12 2022/02/19 13:09:36 jsg Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2014, 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: February 19 2022 $
69.Dt OCSP_REQUEST_NEW 3
70.Os
71.Sh NAME
72.Nm OCSP_REQUEST_new ,
73.Nm OCSP_REQUEST_free ,
74.Nm OCSP_SIGNATURE_new ,
75.Nm OCSP_SIGNATURE_free ,
76.Nm OCSP_REQINFO_new ,
77.Nm OCSP_REQINFO_free ,
78.Nm OCSP_ONEREQ_new ,
79.Nm OCSP_ONEREQ_free ,
80.Nm OCSP_request_add0_id ,
81.Nm OCSP_request_sign ,
82.Nm OCSP_request_add1_cert ,
83.Nm OCSP_request_onereq_count ,
84.Nm OCSP_request_onereq_get0
85.Nd OCSP request functions
86.Sh SYNOPSIS
87.In openssl/ocsp.h
88.Ft OCSP_REQUEST *
89.Fn OCSP_REQUEST_new void
90.Ft void
91.Fn OCSP_REQUEST_free "OCSP_REQUEST *req"
92.Ft OCSP_SIGNATURE *
93.Fn OCSP_SIGNATURE_new void
94.Ft void
95.Fn OCSP_SIGNATURE_free "OCSP_SIGNATURE *signature"
96.Ft OCSP_REQINFO *
97.Fn OCSP_REQINFO_new void
98.Ft void
99.Fn OCSP_REQINFO_free "OCSP_REQINFO *reqinfo"
100.Ft OCSP_ONEREQ *
101.Fn OCSP_ONEREQ_new void
102.Ft void
103.Fn OCSP_ONEREQ_free "OCSP_ONEREQ *onereq"
104.Ft OCSP_ONEREQ *
105.Fo OCSP_request_add0_id
106.Fa "OCSP_REQUEST *req"
107.Fa "OCSP_CERTID *cid"
108.Fc
109.Ft int
110.Fo OCSP_request_sign
111.Fa "OCSP_REQUEST *req"
112.Fa "X509 *signer"
113.Fa "EVP_PKEY *key"
114.Fa "const EVP_MD *dgst"
115.Fa "STACK_OF(X509) *certs"
116.Fa "unsigned long flags"
117.Fc
118.Ft int
119.Fo OCSP_request_add1_cert
120.Fa "OCSP_REQUEST *req"
121.Fa "X509 *cert"
122.Fc
123.Ft int
124.Fo OCSP_request_onereq_count
125.Fa "OCSP_REQUEST *req"
126.Fc
127.Ft OCSP_ONEREQ *
128.Fo OCSP_request_onereq_get0
129.Fa "OCSP_REQUEST *req"
130.Fa "int i"
131.Fc
132.Sh DESCRIPTION
133.Fn OCSP_REQUEST_new
134allocates and initializes an empty
135.Vt OCSP_REQUEST
136object, representing an ASN.1
137.Vt OCSPRequest
138structure defined in RFC 6960.
139.Fn OCSP_REQUEST_free
140frees
141.Fa req .
142.Pp
143.Fn OCSP_SIGNATURE_new
144allocates and initializes an empty
145.Vt OCSP_SIGNATURE
146object, representing an ASN.1
147.Vt Signature
148structure defined in RFC 6960.
149Such an object is used inside
150.Vt OCSP_REQUEST .
151.Fn OCSP_SIGNATURE_free
152frees
153.Fa signature .
154.Pp
155.Fn OCSP_REQINFO_new
156allocates and initializes an empty
157.Vt OCSP_REQINFO
158object, representing an ASN.1
159.Vt TBSRequest
160structure defined in RFC 6960.
161Such an object is used inside
162.Vt OCSP_REQUEST .
163It asks about the validity of one or more certificates.
164.Fn OCSP_REQINFO_free
165frees
166.Fa reqinfo .
167.Pp
168.Fn OCSP_ONEREQ_new
169allocates and initializes an empty
170.Vt OCSP_ONEREQ
171object, representing an ASN.1
172.Vt Request
173structure defined in RFC 6960.
174Such objects are used inside
175.Vt OCSP_REQINFO .
176Each one asks about the validity of one certificate.
177.Fn OCSP_ONEREQ_free
178frees
179.Fa onereq .
180.Pp
181.Fn OCSP_request_add0_id
182adds certificate ID
183.Fa cid
184to
185.Fa req .
186It returns the
187.Vt OCSP_ONEREQ
188object added so an application can add additional extensions to the
189request.
190The
191.Fa cid
192parameter must not be freed up after the operation.
193.Pp
194.Fn OCSP_request_sign
195signs OCSP request
196.Fa req
197using certificate
198.Fa signer ,
199private key
200.Fa key ,
201digest
202.Fa dgst ,
203and additional certificates
204.Fa certs .
205If the
206.Fa flags
207option
208.Dv OCSP_NOCERTS
209is set, then no certificates will be included in the request.
210.Pp
211.Fn OCSP_request_add1_cert
212adds certificate
213.Fa cert
214to request
215.Fa req .
216The application is responsible for freeing up
217.Fa cert
218after use.
219.Pp
220.Fn OCSP_request_onereq_count
221returns the total number of
222.Vt OCSP_ONEREQ
223objects in
224.Fa req .
225.Pp
226.Fn OCSP_request_onereq_get0
227returns an internal pointer to the
228.Vt OCSP_ONEREQ
229contained in
230.Fa req
231of index
232.Fa i .
233The index value
234.Fa i
235runs from 0 to
236.Fn OCSP_request_onereq_count req No - 1 .
237.Pp
238.Fn OCSP_request_onereq_count
239and
240.Fn OCSP_request_onereq_get0
241are mainly used by OCSP responders.
242.Sh RETURN VALUES
243.Fn OCSP_REQUEST_new ,
244.Fn OCSP_SIGNATURE_new ,
245.Fn OCSP_REQINFO_new ,
246and
247.Fn OCSP_ONEREQ_new
248return an empty
249.Vt OCSP_REQUEST ,
250.Vt OCSP_SIGNATURE ,
251.Vt OCSP_REQINFO ,
252or
253.Vt OCSP_ONEREQ
254object, respectively, or
255.Dv NULL
256if an error occurred.
257.Pp
258.Fn OCSP_request_add0_id
259returns the
260.Vt OCSP_ONEREQ
261object containing
262.Fa cid
263or
264.Dv NULL
265if an error occurred.
266.Pp
267.Fn OCSP_request_sign
268and
269.Fn OCSP_request_add1_cert
270return 1 for success or 0 for failure.
271.Pp
272.Fn OCSP_request_onereq_count
273returns the total number of
274.Vt OCSP_ONEREQ
275objects in
276.Fa req .
277.Pp
278.Fn OCSP_request_onereq_get0
279returns a pointer to an
280.Vt OCSP_ONEREQ
281object or
282.Dv NULL
283if the index value is out of range.
284.Sh EXAMPLES
285Create an
286.Vt OCSP_REQUEST
287object for certificate
288.Fa cert
289with issuer
290.Fa issuer :
291.Bd -literal -offset indent
292OCSP_REQUEST *req;
293OCSP_ID *cid;
294
295req = OCSP_REQUEST_new();
296if (req == NULL)
297 /* error */
298cid = OCSP_cert_to_id(EVP_sha1(), cert, issuer);
299if (cid == NULL)
300 /* error */
301
302if (OCSP_REQUEST_add0_id(req, cid) == NULL)
303 /* error */
304
305 /* Do something with req, e.g. query responder */
306
307OCSP_REQUEST_free(req);
308.Ed
309.Sh SEE ALSO
310.Xr ACCESS_DESCRIPTION_new 3 ,
311.Xr crypto 3 ,
312.Xr d2i_OCSP_REQUEST 3 ,
313.Xr d2i_OCSP_RESPONSE 3 ,
314.Xr EVP_DigestInit 3 ,
315.Xr OCSP_cert_to_id 3 ,
316.Xr OCSP_CRLID_new 3 ,
317.Xr OCSP_request_add1_nonce 3 ,
318.Xr OCSP_resp_find_status 3 ,
319.Xr OCSP_response_status 3 ,
320.Xr OCSP_sendreq_new 3 ,
321.Xr OCSP_SERVICELOC_new 3 ,
322.Xr X509_ocspid_print 3
323.Sh STANDARDS
324RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
325Status Protocol, section 4.1: Request Syntax
326.Sh HISTORY
327These functions first appeared in OpenSSL 0.9.7
328and have been available since
329.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/OCSP_SERVICELOC_new.3 b/src/lib/libcrypto/man/OCSP_SERVICELOC_new.3
deleted file mode 100644
index 62eb8c320f..0000000000
--- a/src/lib/libcrypto/man/OCSP_SERVICELOC_new.3
+++ /dev/null
@@ -1,109 +0,0 @@
1.\" $OpenBSD: OCSP_SERVICELOC_new.3,v 1.8 2019/08/23 12:23:39 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: August 23 2019 $
18.Dt OCSP_SERVICELOC_NEW 3
19.Os
20.Sh NAME
21.Nm OCSP_SERVICELOC_new ,
22.Nm OCSP_SERVICELOC_free ,
23.Nm OCSP_url_svcloc_new
24.Nd OCSP service locator extension
25.Sh SYNOPSIS
26.In openssl/ocsp.h
27.Ft OCSP_SERVICELOC *
28.Fn OCSP_SERVICELOC_new void
29.Ft void
30.Fn OCSP_SERVICELOC_free "OCSP_SERVICELOC *sloc"
31.Ft X509_EXTENSION *
32.Fo OCSP_url_svcloc_new
33.Fa "X509_NAME *issuer"
34.Fa "const char **urls"
35.Fc
36.Sh DESCRIPTION
37Due to restrictions of network routing, a client may be unable to
38directly contact the authoritative OCSP server for a certificate
39that needs to be checked.
40In that case, the request can be sent via a proxy server.
41An ASN.1
42.Vt ServiceLocator
43structure is included in the singleRequestExtensions field of the
44.Vt Request
45structure to indicate where to forward the request.
46The
47.Vt ServiceLocator
48is represented by a
49.Vt OCSP_SERVICELOC
50object, which will be stored inside the
51.Vt OCSP_ONEREQ
52object documented in
53.Xr OCSP_ONEREQ_new 3 .
54.Pp
55.Fn OCSP_SERVICELOC_new
56allocates and initializes an empty
57.Vt OCSP_SERVICELOC
58object.
59.Fn OCSP_SERVICELOC_free
60frees
61.Fa sloc .
62.Pp
63.Fn OCSP_url_svcloc_new
64requires an
65.Fa issuer
66name and optionally accepts an array of
67.Fa urls .
68If
69.Fa urls
70or its first element is
71.Dv NULL ,
72the locator field is omitted from the
73.Vt ServiceLocator
74structure and only the issuer is included.
75The resulting
76.Vt ServiceLocator
77structure is encoded in ASN.1 using
78.Xr X509V3_EXT_i2d 3
79with criticality 0.
80.Sh RETURN VALUES
81.Fn OCSP_SERVICELOC_new
82returns a new
83.Vt OCSP_SERVICELOC
84object or
85.Dv NULL
86if an error occurred.
87.Pp
88.Fn OCSP_url_svcloc_new
89returns a new
90.Vt X509_EXTENSION
91object or
92.Dv NULL
93if an error occurred.
94.Sh SEE ALSO
95.Xr OCSP_REQUEST_new 3 ,
96.Xr X509_EXTENSION_new 3 ,
97.Xr X509_get1_ocsp 3 ,
98.Xr X509_get_issuer_name 3 ,
99.Xr X509_NAME_new 3
100.Sh STANDARDS
101RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
102Status Protocol, section 4.4.6: Service Locator
103.Sh HISTORY
104.Fn OCSP_SERVICELOC_new ,
105.Fn OCSP_SERVICELOC_free ,
106and
107.Fn OCSP_url_svcloc_new
108first appeared in OpenSSL 0.9.7 and have been available since
109.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/OCSP_cert_to_id.3 b/src/lib/libcrypto/man/OCSP_cert_to_id.3
deleted file mode 100644
index e014a1d262..0000000000
--- a/src/lib/libcrypto/man/OCSP_cert_to_id.3
+++ /dev/null
@@ -1,239 +0,0 @@
1.\" $OpenBSD: OCSP_cert_to_id.3,v 1.13 2024/08/24 19:31:09 tb Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2014, 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: August 24 2024 $
69.Dt OCSP_CERT_TO_ID 3
70.Os
71.Sh NAME
72.Nm OCSP_CERTID_new ,
73.Nm OCSP_CERTID_free ,
74.Nm OCSP_cert_to_id ,
75.Nm OCSP_cert_id_new ,
76.Nm OCSP_id_issuer_cmp ,
77.Nm OCSP_id_cmp ,
78.Nm OCSP_id_get0_info
79.Nd OCSP certificate ID utility functions
80.Sh SYNOPSIS
81.In openssl/ocsp.h
82.Ft OCSP_CERTID *
83.Fn OCSP_CERTID_new void
84.Ft void
85.Fn OCSP_CERTID_free "OCSP_CERTID *id"
86.Ft OCSP_CERTID *
87.Fo OCSP_cert_to_id
88.Fa "const EVP_MD *dgst"
89.Fa "const X509 *subject"
90.Fa "const X509 *issuer"
91.Fc
92.Ft OCSP_CERTID *
93.Fo OCSP_cert_id_new
94.Fa "const EVP_MD *dgst"
95.Fa "const X509_NAME *issuerName"
96.Fa "const ASN1_BIT_STRING *issuerKey"
97.Fa "const ASN1_INTEGER *serialNumber"
98.Fc
99.Ft int
100.Fo OCSP_id_issuer_cmp
101.Fa "OCSP_CERTID *a"
102.Fa "OCSP_CERTID *b"
103.Fc
104.Ft int
105.Fo OCSP_id_cmp
106.Fa "OCSP_CERTID *a"
107.Fa "OCSP_CERTID *b"
108.Fc
109.Ft int
110.Fo OCSP_id_get0_info
111.Fa "ASN1_OCTET_STRING **piNameHash"
112.Fa "ASN1_OBJECT **pmd"
113.Fa "ASN1_OCTET_STRING **pikeyHash"
114.Fa "ASN1_INTEGER **pserial"
115.Fa "OCSP_CERTID *cid"
116.Fc
117.Sh DESCRIPTION
118.Fn OCSP_CERTID_new
119allocates and initializes an empty
120.Vt OCSP_CERTID
121object, representing an ASN.1
122.Vt CertID
123structure defined in RFC 6960.
124It can store hashes of an issuer's distinguished name and public
125key together with a serial number of a certificate.
126It is used by the
127.Vt OCSP_ONEREQ
128object described in
129.Xr OCSP_ONEREQ_new 3
130and by the
131.Vt OCSP_SINGLERESP
132object described in
133.Xr OCSP_SINGLERESP_new 3 .
134.Fn OCSP_CERTID_free
135frees
136.Fa id .
137.Pp
138.Fn OCSP_cert_to_id
139creates and returns a new
140.Vt OCSP_CERTID
141object using message digest
142.Fa dgst
143for certificate
144.Fa subject
145with issuer
146.Fa issuer .
147If
148.Fa dgst
149is
150.Dv NULL
151then SHA1 is used.
152.Pp
153.Fn OCSP_cert_id_new
154creates and returns a new
155.Vt OCSP_CERTID
156using
157.Fa dgst
158and issuer name
159.Fa issuerName ,
160issuer key hash
161.Fa issuerKey
162and serial number
163.Fa serialNumber .
164.Pp
165.Fn OCSP_id_issuer_cmp
166compares the hash algorithms,
167the hashed issuer distinguished names and
168the hashed public keys of
169.Vt OCSP_CERTID
170.Fa a
171and
172.Fa b .
173.Pp
174.Fn OCSP_id_cmp
175compares
176.Vt OCSP_CERTID
177.Fa a
178and
179.Fa b
180using
181.Fn OCSP_id_issuer_cmp
182followed by a comparison of the certificate serial numbers with
183.Xr ASN1_INTEGER_cmp 3 .
184.Pp
185.Fn OCSP_id_get0_info
186returns the issuer name hash, hash OID, issuer key hash and serial
187number contained in
188.Fa cid .
189If any of the values are not required, the corresponding parameter can be
190set to
191.Dv NULL .
192The values returned by
193.Fn OCSP_id_get0_info
194are internal pointers and must not be freed up by an application:
195they will be freed when the corresponding
196.Vt OCSP_CERTID
197object is freed.
198.Pp
199OCSP clients will typically only use
200.Fn OCSP_cert_to_id
201or
202.Fn OCSP_cert_id_new :
203the other functions are used by responder applications.
204.Sh RETURN VALUES
205.Fn OCSP_CERTID_new ,
206.Fn OCSP_cert_to_id ,
207and
208.Fn OCSP_cert_id_new
209return either a pointer to a valid
210.Vt OCSP_CERTID
211object or
212.Dv NULL
213if an error occurred.
214.Pp
215.Fn OCSP_id_cmp
216and
217.Fn OCSP_id_issuer_cmp
218return 0 for a match or non-zero otherwise.
219.Pp
220.Fn OCSP_id_get0_info
221returns 1 for success or 0 for failure.
222.Sh SEE ALSO
223.Xr ASN1_INTEGER_cmp 3 ,
224.Xr EVP_DigestInit 3 ,
225.Xr OCSP_request_add1_nonce 3 ,
226.Xr OCSP_REQUEST_new 3 ,
227.Xr OCSP_resp_find_status 3 ,
228.Xr OCSP_response_status 3 ,
229.Xr OCSP_sendreq_new 3 ,
230.Xr X509_get_issuer_name 3 ,
231.Xr X509_NAME_new 3 ,
232.Xr X509_ocspid_print 3
233.Sh STANDARDS
234RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
235Status Protocol, section 4: Details of the Protocol
236.Sh HISTORY
237These functions first appeared in OpenSSL 0.9.7
238and have been available since
239.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/OCSP_request_add1_nonce.3 b/src/lib/libcrypto/man/OCSP_request_add1_nonce.3
deleted file mode 100644
index 036c937c61..0000000000
--- a/src/lib/libcrypto/man/OCSP_request_add1_nonce.3
+++ /dev/null
@@ -1,163 +0,0 @@
1.\" $OpenBSD: OCSP_request_add1_nonce.3,v 1.4 2018/03/22 21:08:22 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2014, 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 22 2018 $
52.Dt OCSP_REQUEST_ADD1_NONCE 3
53.Os
54.Sh NAME
55.Nm OCSP_request_add1_nonce ,
56.Nm OCSP_basic_add1_nonce ,
57.Nm OCSP_check_nonce ,
58.Nm OCSP_copy_nonce
59.Nd OCSP nonce functions
60.Sh SYNOPSIS
61.In openssl/ocsp.h
62.Ft int
63.Fo OCSP_request_add1_nonce
64.Fa "OCSP_REQUEST *req"
65.Fa "unsigned char *val"
66.Fa "int len"
67.Fc
68.Ft int
69.Fo OCSP_basic_add1_nonce
70.Fa "OCSP_BASICRESP *resp"
71.Fa "unsigned char *val"
72.Fa "int len"
73.Fc
74.Ft int
75.Fo OCSP_check_nonce
76.Fa "OCSP_REQUEST *req"
77.Fa "OCSP_BASICRESP *resp"
78.Fc
79.Ft int
80.Fo OCSP_copy_nonce
81.Fa "OCSP_BASICRESP *resp"
82.Fa "OCSP_REQUEST *req"
83.Fc
84.Sh DESCRIPTION
85An OCSP nonce is typically added to an OCSP request to thwart replay
86attacks by checking the same nonce value appears in the response.
87.Pp
88.Fn OCSP_request_add1_nonce
89adds a nonce of value
90.Fa val
91and length
92.Fa len
93to OCSP request
94.Fa req .
95If
96.Fa val
97is
98.Dv NULL ,
99a random nonce is used.
100If
101.Fa len
102is zero or negative, a default length will be used (currently 16 bytes).
103For most purposes the nonce value in a request is set to a random value
104so the
105.Fa val
106parameter in
107.Fn OCSP_request_add1_nonce
108is usually NULL.
109.Pp
110.Fn OCSP_basic_add1_nonce
111is identical to
112.Fn OCSP_request_add1_nonce
113except it adds a nonce to OCSP basic response
114.Fa resp .
115.Pp
116.Fn OCSP_check_nonce
117compares the nonce value in
118.Fa req
119and
120.Fa resp .
121.Pp
122.Fn OCSP_copy_nonce
123copies any nonce value present in
124.Fa req
125to
126.Fa resp .
127.Pp
128Some responders may include a nonce in all responses even if one is not
129supplied.
130.Pp
131Some responders cache OCSP responses and do not sign each response for
132performance reasons.
133As a result they do not support nonces.
134.Sh RETURN VALUES
135.Fn OCSP_request_add1_nonce
136and
137.Fn OCSP_basic_add1_nonce
138return 1 for success or 0 for failure.
139.Pp
140.Fn OCSP_copy_nonce
141returns 1 if a nonce was successfully copied, 2 if no nonce was
142present in
143.Fa req ,
144or 0 if an error occurred.
145.Pp
146.Fn OCSP_check_nonce
147returns positive values for success: 1 if nonces are present and
148equal, 2 if both nonces are absent, or 3 if a nonce is present in
149the response only.
150A zero return value indicates that both nonces are present but
151mismatch: this should be treated as an error condition.
152A return value of -1 indicates that a nonce is present in the request
153only: this will happen if the responder doesn't support nonces.
154.Sh SEE ALSO
155.Xr OCSP_cert_to_id 3 ,
156.Xr OCSP_REQUEST_new 3 ,
157.Xr OCSP_resp_find_status 3 ,
158.Xr OCSP_response_status 3 ,
159.Xr OCSP_sendreq_new 3
160.Sh HISTORY
161These functions first appeared in OpenSSL 0.9.7
162and have been available since
163.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/OCSP_resp_find_status.3 b/src/lib/libcrypto/man/OCSP_resp_find_status.3
deleted file mode 100644
index 06d0354bd6..0000000000
--- a/src/lib/libcrypto/man/OCSP_resp_find_status.3
+++ /dev/null
@@ -1,494 +0,0 @@
1.\" $OpenBSD: OCSP_resp_find_status.3,v 1.11 2022/03/31 17:27:17 naddy Exp $
2.\" full merge up to: OpenSSL c952780c Jun 21 07:03:34 2016 -0400
3.\" selective merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2016, 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
23.\" and David von Oheimb <David.von.Oheimb@siemens.com>.
24.\" Copyright (c) 2014, 2018 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: March 31 2022 $
71.Dt OCSP_RESP_FIND_STATUS 3
72.Os
73.Sh NAME
74.Nm OCSP_SINGLERESP_new ,
75.Nm OCSP_SINGLERESP_free ,
76.Nm OCSP_CERTSTATUS_new ,
77.Nm OCSP_CERTSTATUS_free ,
78.Nm OCSP_REVOKEDINFO_new ,
79.Nm OCSP_REVOKEDINFO_free ,
80.Nm OCSP_resp_find_status ,
81.Nm OCSP_cert_status_str ,
82.Nm OCSP_resp_count ,
83.Nm OCSP_resp_get0 ,
84.Nm OCSP_resp_find ,
85.Nm OCSP_SINGLERESP_get0_id ,
86.Nm OCSP_single_get0_status ,
87.Nm OCSP_check_validity ,
88.Nm OCSP_basic_verify
89.Nd OCSP response utility functions
90.Sh SYNOPSIS
91.In openssl/ocsp.h
92.Ft OCSP_SINGLERESP *
93.Fn OCSP_SINGLERESP_new void
94.Ft void
95.Fn OCSP_SINGLERESP_free "OCSP_SINGLERESP *single"
96.Ft OCSP_CERTSTATUS *
97.Fn OCSP_CERTSTATUS_new void
98.Ft void
99.Fn OCSP_CERTSTATUS_free "OCSP_CERTSTATUS *certstatus"
100.Ft OCSP_REVOKEDINFO *
101.Fn OCSP_REVOKEDINFO_new void
102.Ft void
103.Fn OCSP_REVOKEDINFO_free "OCSP_REVOKEDINFO *revokedinfo"
104.Ft int
105.Fo OCSP_resp_find_status
106.Fa "OCSP_BASICRESP *bs"
107.Fa "OCSP_CERTID *id"
108.Fa "int *status"
109.Fa "int *reason"
110.Fa "ASN1_GENERALIZEDTIME **revtime"
111.Fa "ASN1_GENERALIZEDTIME **thisupd"
112.Fa "ASN1_GENERALIZEDTIME **nextupd"
113.Fc
114.Ft const char *
115.Fo OCSP_cert_status_str
116.Fa "long status"
117.Fc
118.Ft int
119.Fo OCSP_resp_count
120.Fa "OCSP_BASICRESP *bs"
121.Fc
122.Ft OCSP_SINGLERESP *
123.Fo OCSP_resp_get0
124.Fa "OCSP_BASICRESP *bs"
125.Fa "int idx"
126.Fc
127.Ft int
128.Fo OCSP_resp_find
129.Fa "OCSP_BASICRESP *bs"
130.Fa "OCSP_CERTID *id"
131.Fa "int last"
132.Fc
133.Ft const OCSP_CERTID *
134.Fo OCSP_SINGLERESP_get0_id
135.Fa "const OCSP_SINGLERESP *single"
136.Fc
137.Ft int
138.Fo OCSP_single_get0_status
139.Fa "OCSP_SINGLERESP *single"
140.Fa "int *reason"
141.Fa "ASN1_GENERALIZEDTIME **revtime"
142.Fa "ASN1_GENERALIZEDTIME **thisupd"
143.Fa "ASN1_GENERALIZEDTIME **nextupd"
144.Fc
145.Ft int
146.Fo OCSP_check_validity
147.Fa "ASN1_GENERALIZEDTIME *thisupd"
148.Fa "ASN1_GENERALIZEDTIME *nextupd"
149.Fa "long sec"
150.Fa "long maxsec"
151.Fc
152.Ft int
153.Fo OCSP_basic_verify
154.Fa "OCSP_BASICRESP *bs"
155.Fa "STACK_OF(X509) *certs"
156.Fa "X509_STORE *st"
157.Fa "unsigned long flags"
158.Fc
159.Sh DESCRIPTION
160.Fn OCSP_SINGLERESP_new
161allocates and initializes an empty
162.Vt OCSP_SINGLERESP
163object, representing an ASN.1
164.Vt SingleResponse
165structure defined in RFC 6960.
166Each such object can store the server's answer regarding the validity
167of one individual certificate.
168Such objects are used inside the
169.Vt OCSP_RESPDATA
170of
171.Vt OCSP_BASICRESP
172objects, which are described in
173.Xr OCSP_BASICRESP_new 3 .
174.Fn OCSP_SINGLERESP_free
175frees
176.Fa single .
177.Pp
178.Fn OCSP_CERTSTATUS_new
179allocates and initializes an empty
180.Vt OCSP_CERTSTATUS
181object, representing an ASN.1
182.Vt CertStatus
183structure defined in RFC 6960.
184Such an object is used inside
185.Vt OCSP_SINGLERESP .
186.Fn OCSP_CERTSTATUS_free
187frees
188.Fa certstatus .
189.Pp
190.Fn OCSP_REVOKEDINFO_new
191allocates and initializes an empty
192.Vt OCSP_REVOKEDINFO
193object, representing an ASN.1
194.Vt RevokedInfo
195structure defined in RFC 6960.
196Such an object is used inside
197.Vt OCSP_CERTSTATUS .
198.Fn OCSP_REVOKEDINFO_free
199frees
200.Fa revokedinfo .
201.Pp
202.Fn OCSP_resp_find_status
203searches
204.Fa bs
205for an OCSP response for
206.Fa id .
207If it is successful, the fields of the response are returned in
208.Pf * Fa status ,
209.Pf * Fa reason ,
210.Pf * Fa revtime ,
211.Pf * Fa thisupd
212and
213.Pf * Fa nextupd .
214The
215.Pf * Fa status
216value will be one of
217.Dv V_OCSP_CERTSTATUS_GOOD ,
218.Dv V_OCSP_CERTSTATUS_REVOKED ,
219or
220.Dv V_OCSP_CERTSTATUS_UNKNOWN .
221The
222.Pf * Fa reason
223and
224.Pf * Fa revtime
225fields are only set if the status is
226.Dv V_OCSP_CERTSTATUS_REVOKED .
227If set, the
228.Pf * Fa reason
229field will be set to the revocation reason which will be one of
230.Dv OCSP_REVOKED_STATUS_NOSTATUS ,
231.Dv OCSP_REVOKED_STATUS_UNSPECIFIED ,
232.Dv OCSP_REVOKED_STATUS_KEYCOMPROMISE ,
233.Dv OCSP_REVOKED_STATUS_CACOMPROMISE ,
234.Dv OCSP_REVOKED_STATUS_AFFILIATIONCHANGED ,
235.Dv OCSP_REVOKED_STATUS_SUPERSEDED ,
236.Dv OCSP_REVOKED_STATUS_CESSATIONOFOPERATION ,
237.Dv OCSP_REVOKED_STATUS_CERTIFICATEHOLD
238or
239.Dv OCSP_REVOKED_STATUS_REMOVEFROMCRL .
240.Pp
241.Fn OCSP_cert_status_str
242converts one of the
243.Fa status
244codes retrieved by
245.Fn OCSP_resp_find_status
246to a string consisting of one word.
247.Pp
248.Fn OCSP_resp_count
249returns the number of
250.Vt OCSP_SINGLERESP
251structures in
252.Fa bs .
253.Pp
254.Fn OCSP_resp_get0
255returns the
256.Vt OCSP_SINGLERESP
257structure in
258.Fa bs
259corresponding to index
260.Fa idx ,
261where
262.Fa idx
263runs from 0 to
264.Fn OCSP_resp_count bs No - 1 .
265.Pp
266.Fn OCSP_resp_find
267searches
268.Fa bs
269for
270.Fa id
271and returns the index of the first matching entry after
272.Fa last
273or starting from the beginning if
274.Fa last
275is -1.
276.Pp
277.Fn OCSP_single_get0_status
278extracts the fields of
279.Fa single
280in
281.Pf * Fa reason ,
282.Pf * Fa revtime ,
283.Pf * Fa thisupd ,
284and
285.Pf * Fa nextupd .
286.Pp
287.Fn OCSP_check_validity
288checks the validity of
289.Fa thisupd
290and
291.Fa nextupd
292values which will be typically obtained from
293.Fn OCSP_resp_find_status
294or
295.Fn OCSP_single_get0_status .
296If
297.Fa sec
298is non-zero, it indicates how many seconds leeway should be allowed in
299the check.
300If
301.Fa maxsec
302is positive, it indicates the maximum age of
303.Fa thisupd
304in seconds.
305.Pp
306Applications will typically call
307.Fn OCSP_resp_find_status
308using the certificate ID of interest and then check its validity using
309.Fn OCSP_check_validity .
310They can then take appropriate action based on the status of the
311certificate.
312.Pp
313An OCSP response for a certificate contains
314.Sy thisUpdate
315and
316.Sy nextUpdate
317fields.
318Normally the current time should be between these two values.
319To account for clock skew, the
320.Fa maxsec
321field can be set to non-zero in
322.Fn OCSP_check_validity .
323Some responders do not set the
324.Sy nextUpdate
325field.
326This would otherwise mean an ancient response would be considered
327valid: the
328.Fa maxsec
329parameter to
330.Fn OCSP_check_validity
331can be used to limit the permitted age of responses.
332.Pp
333The values written to
334.Pf * Fa revtime ,
335.Pf * Fa thisupd ,
336and
337.Pf * Fa nextupd
338by
339.Fn OCSP_resp_find_status
340and
341.Fn OCSP_single_get0_status
342are internal pointers which must not be freed up by the calling
343application.
344Any or all of these parameters can be set to
345.Dv NULL
346if their value is not required.
347.Pp
348.Fn OCSP_basic_verify
349checks that the basic response message
350.Fa bs
351is correctly signed and that the signer certificate can be validated.
352It takes
353.Fa st
354as the trusted store and
355.Fa certs
356as a set of untrusted intermediate certificates.
357The function first tries to find the signer certificate of the response in
358.Fa certs .
359It also searches the certificates the responder may have included in
360.Fa bs
361unless the
362.Fa flags
363contain
364.Dv OCSP_NOINTERN .
365It fails if the signer certificate cannot be found.
366Next, the function checks the signature of
367.Fa bs
368and fails on error unless the
369.Fa flags
370contain
371.Dv OCSP_NOSIGS .
372Then the function already returns
373success if the
374.Fa flags
375contain
376.Dv OCSP_NOVERIFY
377or if the signer certificate was found in
378.Fa certs
379and the
380.Fa flags
381contain
382.Dv OCSP_TRUSTOTHER .
383Otherwise the function continues by validating the signer certificate.
384To this end, all certificates in
385.Fa certs
386and in
387.Fa bs
388are considered as untrusted certificates for the construction of
389the validation path for the signer certificate unless the
390.Dv OCSP_NOCHAIN
391flag is set.
392After successful path
393validation, the function returns success if the
394.Dv OCSP_NOCHECKS
395flag is set.
396Otherwise it verifies that the signer certificate meets the OCSP issuer
397criteria including potential delegation.
398If this does not succeed and the
399.Fa flags
400do not contain
401.Dv OCSP_NOEXPLICIT ,
402the function checks for explicit trust for OCSP signing
403in the root CA certificate.
404.Sh RETURN VALUES
405.Fn OCSP_SINGLERESP_new ,
406.Fn OCSP_CERTSTATUS_new ,
407and
408.Fn OCSP_REVOKEDINFO_new
409return a pointer to an empty
410.Vt OCSP_SINGLERESP ,
411.Vt OCSP_CERTSTATUS ,
412or
413.Vt OCSP_REVOKEDINFO
414object, respectively, or
415.Dv NULL
416if an error occurred.
417.Pp
418.Fn OCSP_resp_find_status
419returns 1 if
420.Fa id
421is found in
422.Fa bs
423or 0 otherwise.
424.Pp
425.Fn OCSP_cert_status_str
426returns a pointer to a static string.
427.Pp
428.Fn OCSP_resp_count
429returns the total number of
430.Vt OCSP_SINGLERESP
431fields in
432.Fa bs .
433.Pp
434.Fn OCSP_resp_get0
435returns a pointer to an
436.Vt OCSP_SINGLERESP
437structure or
438.Dv NULL
439if
440.Fa idx
441is out of range.
442.Pp
443.Fn OCSP_resp_find
444returns the index of
445.Fa id
446in
447.Fa bs
448(which may be 0) or -1 if
449.Fa id
450was not found.
451.Pp
452.Fn OCSP_SINGLERESP_get0_id
453returns an internal pointer to the certificate ID object used by
454.Fa single ;
455the returned pointer should not be freed by the caller.
456.Pp
457.Fn OCSP_single_get0_status
458returns the status of
459.Fa single
460or -1 if an error occurred.
461.Pp
462.Fn OCSP_basic_verify
463returns 1 on success, 0 on error, or -1 on fatal error such as malloc failure.
464.Sh SEE ALSO
465.Xr OCSP_cert_to_id 3 ,
466.Xr OCSP_CRLID_new 3 ,
467.Xr OCSP_request_add1_nonce 3 ,
468.Xr OCSP_REQUEST_new 3 ,
469.Xr OCSP_response_status 3 ,
470.Xr OCSP_sendreq_new 3
471.Sh STANDARDS
472RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
473Status Protocol, section 4.2: Response Syntax
474.Sh HISTORY
475.Fn OCSP_SINGLERESP_new ,
476.Fn OCSP_SINGLERESP_free ,
477.Fn OCSP_CERTSTATUS_new ,
478.Fn OCSP_CERTSTATUS_free ,
479.Fn OCSP_REVOKEDINFO_new ,
480.Fn OCSP_REVOKEDINFO_free ,
481.Fn OCSP_resp_find_status ,
482.Fn OCSP_cert_status_str ,
483.Fn OCSP_resp_count ,
484.Fn OCSP_resp_get0 ,
485.Fn OCSP_resp_find ,
486.Fn OCSP_single_get0_status ,
487and
488.Fn OCSP_check_validity
489first appeared in OpenSSL 0.9.7 and have been available since
490.Ox 3.2 .
491.Pp
492.Fn OCSP_SINGLERESP_get0_id
493first appeared in OpenSSL 1.1.0 and has been available since
494.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/OCSP_response_status.3 b/src/lib/libcrypto/man/OCSP_response_status.3
deleted file mode 100644
index 4e85384fb0..0000000000
--- a/src/lib/libcrypto/man/OCSP_response_status.3
+++ /dev/null
@@ -1,308 +0,0 @@
1.\" $OpenBSD: OCSP_response_status.3,v 1.8 2019/08/27 09:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\" selective merge up to: OpenSSL 6738bf14 Feb 13 12:51:29 2018 +0000
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2016, 2019 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2014, 2016, 2018 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: August 27 2019 $
70.Dt OCSP_RESPONSE_STATUS 3
71.Os
72.Sh NAME
73.Nm OCSP_RESPONSE_new ,
74.Nm OCSP_RESPONSE_free ,
75.Nm OCSP_RESPBYTES_new ,
76.Nm OCSP_RESPBYTES_free ,
77.Nm OCSP_BASICRESP_new ,
78.Nm OCSP_BASICRESP_free ,
79.Nm OCSP_RESPDATA_new ,
80.Nm OCSP_RESPDATA_free ,
81.Nm OCSP_RESPID_new ,
82.Nm OCSP_RESPID_free ,
83.Nm OCSP_response_create ,
84.Nm OCSP_response_status ,
85.Nm OCSP_response_status_str ,
86.Nm OCSP_response_get1_basic ,
87.Nm OCSP_basic_sign
88.Nd OCSP response functions
89.Sh SYNOPSIS
90.In openssl/ocsp.h
91.Ft OCSP_RESPONSE *
92.Fn OCSP_RESPONSE_new void
93.Ft void
94.Fn OCSP_RESPONSE_free "OCSP_RESPONSE *resp"
95.Ft OCSP_RESPBYTES *
96.Fn OCSP_RESPBYTES_new void
97.Ft void
98.Fn OCSP_RESPBYTES_free "OCSP_RESPBYTES *respbytes"
99.Ft OCSP_BASICRESP *
100.Fn OCSP_BASICRESP_new void
101.Ft void
102.Fn OCSP_BASICRESP_free "OCSP_BASICRESP *bs"
103.Ft OCSP_RESPDATA *
104.Fn OCSP_RESPDATA_new void
105.Ft void
106.Fn OCSP_RESPDATA_free "OCSP_RESPDATA *respdata"
107.Ft OCSP_RESPID *
108.Fn OCSP_RESPID_new void
109.Ft void
110.Fn OCSP_RESPID_free "OCSP_RESPID *respid"
111.Ft OCSP_RESPONSE *
112.Fo OCSP_response_create
113.Fa "int status"
114.Fa "OCSP_BASICRESP *bs"
115.Fc
116.Ft int
117.Fo OCSP_response_status
118.Fa "OCSP_RESPONSE *resp"
119.Fc
120.Ft const char *
121.Fo OCSP_response_status_str
122.Fa "long code"
123.Fc
124.Ft OCSP_BASICRESP *
125.Fo OCSP_response_get1_basic
126.Fa "OCSP_RESPONSE *resp"
127.Fc
128.Ft int
129.Fo OCSP_basic_sign
130.Fa "OCSP_BASICRESP *bs"
131.Fa "X509 *signer"
132.Fa "EVP_PKEY *key"
133.Fa "const EVP_MD *dgst"
134.Fa "STACK_OF(X509) *certs"
135.Fa "unsigned long flags"
136.Fc
137.Sh DESCRIPTION
138.Fn OCSP_RESPONSE_new
139allocates and initializes an empty
140.Vt OCSP_RESPONSE
141object, representing an ASN.1
142.Vt OCSPResponse
143structure defined in RFC 6960.
144.Fn OCSP_RESPONSE_free
145frees
146.Fa resp .
147.Pp
148.Fn OCSP_RESPBYTES_new
149allocates and initializes an empty
150.Vt OCSP_RESPBYTES
151object, representing an ASN.1
152.Vt ResponseBytes
153structure defined in RFC 6960.
154Such an object is used inside
155.Vt OCSP_RESPONSE .
156.Fn OCSP_RESPBYTES_free
157frees
158.Fa respbytes .
159.Pp
160.Fn OCSP_BASICRESP_new
161allocates and initializes an empty
162.Vt OCSP_BASICRESP
163object, representing an ASN.1
164.Vt BasicOCSPResponse
165structure defined in RFC 6960.
166.Vt OCSP_RESPBYTES
167contains the DER-encoded form of an
168.Vt OCSP_BASICRESP
169object.
170.Fn OCSP_BASICRESP_free
171frees
172.Fa bs .
173.Pp
174.Fn OCSP_RESPDATA_new
175allocates and initializes an empty
176.Vt OCSP_RESPDATA
177object, representing an ASN.1
178.Vt ResponseData
179structure defined in RFC 6960.
180Such an object is used inside
181.Vt OCSP_BASICRESP .
182.Fn OCSP_RESPDATA_free
183frees
184.Fa respdata .
185.Pp
186.Fn OCSP_RESPID_new
187allocates and initializes an empty
188.Vt OCSP_RESPID
189object, representing an ASN.1
190.Vt ResponderID
191structure defined in RFC 6960.
192Such an object is used inside
193.Vt OCSP_RESPDATA .
194.Fn OCSP_RESPID_free
195frees
196.Fa respid .
197.Pp
198.Fn OCSP_response_create
199creates an
200.Vt OCSP_RESPONSE
201object for
202.Fa status
203and optionally including the basic response
204.Fa bs .
205.Pp
206.Fn OCSP_response_status
207returns the OCSP response status of
208.Fa resp .
209It returns one of the values
210.Dv OCSP_RESPONSE_STATUS_SUCCESSFUL ,
211.Dv OCSP_RESPONSE_STATUS_MALFORMEDREQUEST ,
212.Dv OCSP_RESPONSE_STATUS_INTERNALERROR ,
213.Dv OCSP_RESPONSE_STATUS_TRYLATER ,
214.Dv OCSP_RESPONSE_STATUS_SIGREQUIRED ,
215or
216.Dv OCSP_RESPONSE_STATUS_UNAUTHORIZED .
217.Pp
218.Fn OCSP_response_status_str
219converts one of the
220.Fa status
221codes returned by
222.Fn OCSP_response_status
223to a string consisting of one word.
224.Pp
225.Fn OCSP_response_get1_basic
226decodes and returns the
227.Vt OCSP_BASICRESP
228object contained in
229.Fa resp .
230It is only called if the status of a response is
231.Dv OCSP_RESPONSE_STATUS_SUCCESSFUL .
232.Pp
233.Fn OCSP_basic_sign
234signs the OCSP response
235.Fa bs
236using the certificate
237.Fa signer ,
238the private key
239.Fa key ,
240the digest
241.Fa dgst ,
242and the additional certificates
243.Fa certs .
244If the
245.Fa flags
246option
247.Dv OCSP_NOCERTS
248is set, then no certificates will be included in the request.
249If the
250.Fa flags
251option
252.Dv OCSP_RESPID_KEY
253is set, then the responder is identified by key ID
254rather than by name.
255.Sh RETURN VALUES
256.Fn OCSP_RESPONSE_new
257and
258.Fn OCSP_response_create
259return a pointer to an
260.Vt OCSP_RESPONSE
261object or
262.Dv NULL
263if an error occurred.
264.Pp
265.Fn OCSP_BASICRESP_new
266and
267.Fn OCSP_response_get1_basic
268return a pointer to an
269.Vt OCSP_BASICRESP
270object or
271.Dv NULL
272if an error occurred.
273.Pp
274.Fn OCSP_RESPBYTES_new ,
275.Fn OCSP_RESPDATA_new ,
276and
277.Fn OCSP_RESPID_new
278return a pointer to an empty
279.Vt OCSP_RESPBYTES ,
280.Vt OCSP_RESPDATA ,
281or
282.Vt OCSP_RESPID
283object, respectively, or
284.Dv NULL
285if an error occurred.
286.Pp
287.Fn OCSP_response_status
288returns a status value.
289.Pp
290.Fn OCSP_response_status_str
291returns a pointer to a static string.
292.Pp
293.Fn OCSP_basic_sign
294return 1 on success or 0 on failure.
295.Sh SEE ALSO
296.Xr EVP_DigestInit 3 ,
297.Xr OCSP_cert_to_id 3 ,
298.Xr OCSP_request_add1_nonce 3 ,
299.Xr OCSP_REQUEST_new 3 ,
300.Xr OCSP_resp_find_status 3 ,
301.Xr OCSP_sendreq_new 3
302.Sh STANDARDS
303RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
304Status Protocol, section 4.2: Response Syntax
305.Sh HISTORY
306These functions first appeared in OpenSSL 0.9.7
307and have been available since
308.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/OCSP_sendreq_new.3 b/src/lib/libcrypto/man/OCSP_sendreq_new.3
deleted file mode 100644
index 300f719525..0000000000
--- a/src/lib/libcrypto/man/OCSP_sendreq_new.3
+++ /dev/null
@@ -1,323 +0,0 @@
1.\" $OpenBSD: OCSP_sendreq_new.3,v 1.10 2022/03/31 17:27:17 naddy Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2014, 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: March 31 2022 $
69.Dt OCSP_SENDREQ_NEW 3
70.Os
71.Sh NAME
72.Nm OCSP_sendreq_new ,
73.Nm OCSP_sendreq_nbio ,
74.Nm OCSP_REQ_CTX_free ,
75.Nm OCSP_REQ_CTX_add1_header ,
76.Nm OCSP_REQ_CTX_set1_req ,
77.Nm OCSP_parse_url ,
78.Nm OCSP_sendreq_bio
79.Nd OCSP responder query functions
80.Sh SYNOPSIS
81.In openssl/ocsp.h
82.Ft OCSP_REQ_CTX *
83.Fo OCSP_sendreq_new
84.Fa "BIO *io"
85.Fa "const char *path"
86.Fa "OCSP_REQUEST *req"
87.Fa "int maxline"
88.Fc
89.Ft int
90.Fo OCSP_sendreq_nbio
91.Fa "OCSP_RESPONSE **presp"
92.Fa "OCSP_REQ_CTX *rctx"
93.Fc
94.Ft void
95.Fo OCSP_REQ_CTX_free
96.Fa "OCSP_REQ_CTX *rctx"
97.Fc
98.Ft int
99.Fo OCSP_REQ_CTX_add1_header
100.Fa "OCSP_REQ_CTX *rctx"
101.Fa "const char *name"
102.Fa "const char *value"
103.Fc
104.Ft int
105.Fo OCSP_REQ_CTX_set1_req
106.Fa "OCSP_REQ_CTX *rctx"
107.Fa "OCSP_REQUEST *req"
108.Fc
109.Ft int
110.Fo OCSP_parse_url
111.Fa "const char *url"
112.Fa "char **phost"
113.Fa "char **pport"
114.Fa "char **ppath"
115.Fa "int *pssl"
116.Fc
117.Ft OCSP_RESPONSE *
118.Fo OCSP_sendreq_bio
119.Fa "BIO *io"
120.Fa "const char *path"
121.Fa "OCSP_REQUEST *req"
122.Fc
123.Sh DESCRIPTION
124The function
125.Fn OCSP_sendreq_new
126returns an
127.Vt OCSP_REQ_CTX
128structure using the responder
129.Fa io ,
130the URI path
131.Fa path ,
132the OCSP request
133.Fa req
134and with a response header maximum line length of
135.Fa maxline .
136If
137.Fa maxline
138is zero, a default value of 4k is used.
139The OCSP request
140.Fa req
141may be set to
142.Dv NULL
143and provided later if required.
144.Pp
145The arguments to
146.Fn OCSP_sendreq_new
147correspond to the components of the URI.
148For example, if the responder URI is
149.Pa http://ocsp.com/ocspreq ,
150the BIO
151.Fa io
152should be connected to host
153.Pa ocsp.com
154on port 80 and
155.Fa path
156should be set to
157.Qq /ocspreq .
158.Pp
159.Fn OCSP_sendreq_nbio
160performs non-blocking I/O on the OCSP request context
161.Fa rctx .
162When the operation is complete, it returns the response in
163.Pf * Fa presp .
164If
165.Fn OCSP_sendreq_nbio
166indicates an operation should be retried, the corresponding BIO can
167be examined to determine which operation (read or write) should be
168retried and appropriate action can be taken, for example a
169.Xr select 2
170call on the underlying socket.
171.Pp
172.Fn OCSP_REQ_CTX_free
173frees up the OCSP context
174.Fa rctx .
175.Pp
176.Fn OCSP_REQ_CTX_add1_header
177adds header
178.Fa name
179with value
180.Fa value
181to the context
182.Fa rctx .
183The added headers are of the form
184.Qq Fa name : value
185or just
186.Qq Fa name
187if
188.Fa value
189is
190.Dv NULL .
191.Fn OCSP_REQ_CTX_add1_header
192can be called more than once to add multiple headers.
193It must be called before any calls to
194.Fn OCSP_sendreq_nbio .
195The
196.Fa req
197parameter in the initial to
198.Fn OCSP_sendreq_new
199call must be set to
200.Dv NULL
201if additional headers are set.
202.Pp
203.Fn OCSP_REQ_CTX_set1_req
204sets the OCSP request in
205.Fa rctx
206to
207.Fa req .
208This function should be called after any calls to
209.Fn OCSP_REQ_CTX_add1_header .
210.Pp
211.Fn OCSP_parse_url
212is a utility function to parse a
213.Fa url
214of the form
215.Sm off
216.Sy http Op Sy s
217.Pf :// Ar host
218.Op : Ar port
219.Op / Ar path
220.Sm on
221and store pointers to newly allocated copies of the strings
222.Ar host ,
223.Ar port ,
224and
225.Ar path
226in
227.Pf * phost ,
228.Pf * pport ,
229and
230.Pf * ppath ,
231respectively.
232By default,
233.Pf * ppath
234is set to
235.Qq /
236and
237.Pf * pport
238to
239.Qq 443
240for
241.Sy https
242or
243.Qq 80
244for
245.Sy http .
246For
247.Sy https ,
248.Pf * Fa pssl
249is set to 1; otherwise, to 0.
250.Pp
251.Fn OCSP_sendreq_bio
252performs an OCSP request using the responder
253.Fa io ,
254the URI path
255.Fa path ,
256the OCSP request
257.Fa req .
258It does not support retries and so cannot handle non-blocking I/O
259efficiently.
260It is retained for compatibility and its use in new applications
261is not recommended.
262.Sh RETURN VALUES
263.Fn OCSP_sendreq_new
264returns a valid
265.Vt OCSP_REQ_CTX
266structure or
267.Dv NULL
268if an error occurred.
269.Pp
270.Fn OCSP_sendreq_nbio
271returns 1 if the operation was completed successfully,
272-1 if the operation should be retried,
273or 0 if an error occurred.
274.Pp
275.Fn OCSP_REQ_CTX_add1_header ,
276.Fn OCSP_REQ_CTX_set1_req ,
277and
278.Fn OCSP_parse_url
279return 1 for success or 0 for failure.
280.Pp
281.Fn OCSP_sendreq_bio
282returns the
283.Vt OCSP_RESPONSE
284structure sent by the responder or
285.Dv NULL
286if an error occurred.
287.Sh EXAMPLES
288Add a Host header for
289.Pa ocsp.com :
290.Pp
291.Dl OCSP_REQ_CTX_add1_header(ctx, "Host", "ocsp.com");
292.Sh SEE ALSO
293.Xr OCSP_cert_to_id 3 ,
294.Xr OCSP_request_add1_nonce 3 ,
295.Xr OCSP_REQUEST_new 3 ,
296.Xr OCSP_resp_find_status 3 ,
297.Xr OCSP_response_status 3 ,
298.Xr X509_get1_ocsp 3
299.Sh HISTORY
300.Fn OCSP_parse_url
301and
302.Fn OCSP_sendreq_bio
303first appeared in OpenSSL 0.9.7 and have been available since
304.Ox 3.2 .
305.Pp
306.Fn OCSP_sendreq_new ,
307.Fn OCSP_sendreq_nbio ,
308and
309.Fn OCSP_REQ_CTX_free
310first appeared in OpenSSL 0.9.8h and have been available since
311.Ox 4.5 .
312.Pp
313.Fn OCSP_REQ_CTX_add1_header
314and
315.Fn OCSP_REQ_CTX_set1_req
316first appeared in OpenSSL 1.0.0 and have been available since
317.Ox 4.9 .
318.Sh CAVEATS
319These functions only perform a minimal HTTP query to a responder.
320If an application wishes to support more advanced features, it
321should use an alternative, more complete, HTTP library.
322.Pp
323Currently only HTTP POST queries to responders are supported.
diff --git a/src/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3 b/src/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3
deleted file mode 100644
index 76427a864b..0000000000
--- a/src/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3
+++ /dev/null
@@ -1,281 +0,0 @@
1.\" $OpenBSD: OPENSSL_VERSION_NUMBER.3,v 1.13 2023/11/16 20:17:04 schwarze Exp $
2.\" full merge up to: OpenSSL 1f13ad31 Dec 25 17:50:39 2017 +0800
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ulf Moeller <ulf@openssl.org>,
22.\" Richard Levitte <levitte@openssl.org>, and
23.\" Bodo Moeller <bodo@openssl.org>.
24.\" Copyright (c) 2000, 2002, 2015, 2016, 2017 The OpenSSL Project.
25.\" All rights reserved.
26.\"
27.\" Redistribution and use in source and binary forms, with or without
28.\" modification, are permitted provided that the following conditions
29.\" are met:
30.\"
31.\" 1. Redistributions of source code must retain the above copyright
32.\" notice, this list of conditions and the following disclaimer.
33.\"
34.\" 2. Redistributions in binary form must reproduce the above copyright
35.\" notice, this list of conditions and the following disclaimer in
36.\" the documentation and/or other materials provided with the
37.\" distribution.
38.\"
39.\" 3. All advertising materials mentioning features or use of this
40.\" software must display the following acknowledgment:
41.\" "This product includes software developed by the OpenSSL Project
42.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
43.\"
44.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
45.\" endorse or promote products derived from this software without
46.\" prior written permission. For written permission, please contact
47.\" openssl-core@openssl.org.
48.\"
49.\" 5. Products derived from this software may not be called "OpenSSL"
50.\" nor may "OpenSSL" appear in their names without prior written
51.\" permission of the OpenSSL Project.
52.\"
53.\" 6. Redistributions of any form whatsoever must retain the following
54.\" acknowledgment:
55.\" "This product includes software developed by the OpenSSL Project
56.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
57.\"
58.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
59.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
62.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
67.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\"
71.Dd $Mdocdate: November 16 2023 $
72.Dt OPENSSL_VERSION_NUMBER 3
73.Os
74.Sh NAME
75.Nm OPENSSL_VERSION_NUMBER ,
76.Nm LIBRESSL_VERSION_NUMBER ,
77.Nm LIBRESSL_VERSION_TEXT ,
78.Nm OPENSSL_VERSION_TEXT ,
79.Nm OpenSSL_version_num ,
80.Nm OpenSSL_version ,
81.Nm SSLeay ,
82.Nm SSLeay_version
83.Nd get OpenSSL version number
84.Sh SYNOPSIS
85.In openssl/opensslv.h
86.Fd #define OPENSSL_VERSION_NUMBER 0x020000000L
87.Fd #define LIBRESSL_VERSION_NUMBER 0x02nnnn00fL
88.Fd #define LIBRESSL_VERSION_TEXT \(dqLibreSSL 2.n.n\(dq
89.Fd #define OPENSSL_VERSION_TEXT LIBRESSL_VERSION_TEXT
90.In openssl/crypto.h
91.Ft unsigned long
92.Fn OpenSSL_version_num void
93.Ft const char *
94.Fo OpenSSL_version
95.Fa "int t"
96.Fc
97.Ft long
98.Fn SSLeay void
99.Ft const char *
100.Fo SSLeay_version
101.Fa "int t"
102.Fc
103.Sh DESCRIPTION
104.Dv OPENSSL_VERSION_NUMBER
105and
106.Dv LIBRESSL_VERSION_NUMBER
107are numeric release version identifiers.
108The first two digits contain the major release number,
109the third and fourth digits the minor release number,
110and the fifth and sixth digits the fix release number.
111For OpenSSL, the seventh and eight digits contain the patch release number
112and the final digit is 0 for development, 1 to e for betas 1 to 14, or f
113for release.
114For LibreSSL,
115.Dv OPENSSL_VERSION_NUMBER
116is always 0x020000000,
117and
118.Dv LIBRESSL_VERSION_NUMBER
119always ends with 00f.
120.Pp
121For example:
122.Bd -literal -offset indent
123OPENSSL_VERSION_NUMBER:
1240x000906000 == 0.9.6 dev
1250x000906023 == 0.9.6b beta 3
1260x00090605f == 0.9.6e release
1270x020000000 == 2.0.0 for any version of LibreSSL
128
129LIBRESSL_VERSION_NUMBER:
1300x02070000f == LibreSSL 2.7.0
131.Ed
132.Pp
133OpenSSL versions prior to 0.9.3 had identifiers < 0x0930.
134For versions between 0.9.3 and 0.9.5,
135the seventh digit was 1 for release and 0 otherwise,
136and the eighth and ninth digits were the patch release number.
137.Pp
138For example:
139.Bd -literal
1400x000904100 == 0.9.4 release
1410x000905000 == 0.9.5 dev
142.Ed
143.Pp
144OpenSSL version 0.9.5a had an interim interpretation that is like the current
145one, except the patch level got the highest bit set, to keep continuity.
146The number was therefore 0x0090581f.
147.Pp
148.Fn OpenSSL_version_num
149returns
150.Dv OPENSSL_VERSION_NUMBER .
151.Pp
152.Fn OpenSSL_version
153returns different strings depending on
154.Fa t :
155.Bl -tag -width Ds
156.It Dv OPENSSL_VERSION
157The text variant of the version number,
158.Dv OPENSSL_VERSION_TEXT .
159For OpenSSL, it includes the release date, for example
160.Qq OpenSSL 0.9.5a 1 Apr 2000 .
161For LibreSSL,
162.Dv LIBRESSL_VERSION_TEXT
163is returned.
164.It Dv OPENSSL_CFLAGS
165The compiler flags set for the compilation process in the form
166.Qq compiler: ...
167if available or
168.Qq compiler: information not available
169otherwise.
170LibreSSL never provides compiler information.
171.It Dv OPENSSL_BUILT_ON
172The date of the build process in the form
173.Qq built on: ...
174if available or
175.Qq built on: date not available
176otherwise.
177LibreSSL never provides information on the build date.
178.It Dv OPENSSL_PLATFORM
179The Configure target of the library build in the form
180.Qq platform: ...
181if available or
182.Qq platform: information not available
183otherwise.
184LibreSSL never provides platform information.
185.It Dv OPENSSL_DIR
186The
187.Dv OPENSSLDIR
188setting of the library build in the form
189.Qq OPENSSLDIR: Qq ...
190if available or
191.Qq OPENSSLDIR: N/A
192otherwise.
193For LibreSSL, the default is
194.Qq OPENSSLDIR: Qq /etc/ssl .
195.It Dv OPENSSL_ENGINES_DIR
196The
197.Dv ENGINESDIR
198setting of the library build in the form
199.Qq ENGINESDIR: Qq ...
200if available or
201.Qq ENGINESDIR: N/A
202otherwise.
203LibreSSL never provides or uses an
204.Dv ENGINESDIR .
205.El
206.Pp
207For an unknown
208.Fa t ,
209the text
210.Qq not available
211is returned.
212.Pp
213For backward compatibility,
214.Dv SSLEAY_VERSION_NUMBER
215is an alias for
216.Dv OPENSSL_VERSION_NUMBER
217and
218.Fn SSLeay
219for
220.Fn OpenSSL_version_num .
221The legacy function
222.Fn SSLeay_version
223is similar to
224.Fn OpenSSL_version
225except that it takes arguments
226.Dv SSLEAY_VERSION ,
227.Dv SSLEAY_CFLAGS ,
228.Dv SSLEAY_BUILT_ON ,
229.Dv SSLEAY_PLATFORM ,
230and
231.Dv SSLEAY_DIR
232which expand to
233.Em other
234numerical values than the corresponding
235.Dv OPENSSL_*
236macros.
237.Sh RETURN VALUES
238.Fn OpenSSL_version_num
239and
240.Fn SSLeay
241return a constant version number.
242.Pp
243.Fn OpenSSL_version
244and
245.Fn SSLeay_version
246return pointers to static strings.
247.Sh SEE ALSO
248.Xr crypto 3 ,
249.Xr OPENSSL_config 3
250.Sh HISTORY
251.Fn SSLeay ,
252.Fn SSLeay_version ,
253and
254.Dv SSLEAY_VERSION_NUMBER
255first appeared in SSLeay 0.6.0 and have been available since
256.Ox 2.4 .
257.Pp
258.Dv OPENSSL_VERSION_NUMBER
259first appeared in the first OpenSSL release, OpenSSL 0.9.1c,
260and has been available since
261.Ox 2.6 .
262.Pp
263.Dv SSLEAY_DIR
264first appeared in OpenSSL 0.9.7 and have been available since
265.Ox 3.2 .
266.Pp
267.Dv LIBRESSL_VERSION_NUMBER
268first appeared in LibreSSL 2.0.0 and
269.Ox 5.6
270and got its final format in LibreSSL 2.3.2 and
271.Ox 5.9 .
272.Dv LIBRESSL_VERSION_TEXT
273first appeared in LibreSSL 2.2.2 and
274.Ox 5.8 .
275.Pp
276.Fn OpenSSL_version_num
277and
278.Fn OpenSSL_version
279first appeared in OpenSSL 1.1.0
280and have been available since LibreSSL 2.7.1 and
281.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/OPENSSL_cleanse.3 b/src/lib/libcrypto/man/OPENSSL_cleanse.3
deleted file mode 100644
index 95fe6b86fd..0000000000
--- a/src/lib/libcrypto/man/OPENSSL_cleanse.3
+++ /dev/null
@@ -1,42 +0,0 @@
1.\" $OpenBSD: OPENSSL_cleanse.3,v 1.4 2019/06/10 09:49:48 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 10 2019 $
18.Dt OPENSSL_CLEANSE 3
19.Os
20.Sh NAME
21.Nm OPENSSL_cleanse
22.Nd OpenSSL memory cleaning operation
23.Sh SYNOPSIS
24.In openssl/crypto.h
25.Ft void
26.Fo OPENSSL_cleanse
27.Fa "void *ptr"
28.Fa "size_t len"
29.Fc
30.Sh DESCRIPTION
31Do not use the interface documented here.
32It is provided purely for compatibility with legacy application code.
33.Pp
34.Fn OPENSSL_cleanse
35has the same semantics as, and is a wrapper around,
36.Xr explicit_bzero 3 .
37.Sh SEE ALSO
38.Xr crypto 3
39.Sh HISTORY
40.Fn OPENSSL_cleanse
41first appeared in OpenSSL 0.9.6h and has been available since
42.Ox 3.4 .
diff --git a/src/lib/libcrypto/man/OPENSSL_config.3 b/src/lib/libcrypto/man/OPENSSL_config.3
deleted file mode 100644
index f5f31571a1..0000000000
--- a/src/lib/libcrypto/man/OPENSSL_config.3
+++ /dev/null
@@ -1,152 +0,0 @@
1.\" $OpenBSD: OPENSSL_config.3,v 1.16 2023/11/19 21:01:27 tb Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2004 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: November 19 2023 $
69.Dt OPENSSL_CONFIG 3
70.Os
71.Sh NAME
72.Nm OPENSSL_config ,
73.Nm OPENSSL_no_config
74.Nd simple crypto and ssl library configuration
75.Sh SYNOPSIS
76.In openssl/conf.h
77.Ft void
78.Fo OPENSSL_config
79.Fa "const char *appname"
80.Fc
81.Ft void
82.Fn OPENSSL_no_config void
83.Sh DESCRIPTION
84.Fn OPENSSL_config
85initializes the crypto library and calls
86.Xr CONF_modules_load_file 3
87with the standard configuration file and the given
88.Fa appname .
89If
90.Fa appname
91is
92.Dv NULL ,
93then the default name
94.Sy openssl_conf
95is used.
96Any errors are ignored.
97Further calls to
98.Fn OPENSSL_config
99have no effect.
100.Pp
101.Fn OPENSSL_no_config
102suppresses the loading of the standard configuration file, so that any
103future calls to
104.Fn OPENSSL_config
105or to
106.Xr OPENSSL_init_crypto 3
107will ensure the library is initialized but no configuration
108file will be loaded.
109.Pp
110Calling these functions is optional.
111All required initialization of the crypto libraries happens
112automatically when needed.
113.Pp
114To use a non-standard configuration file, refer to
115.Xr CONF_modules_load_file 3 .
116.Pp
117Internally,
118.Fn OPENSSL_config
119calls
120.Xr OPENSSL_init_crypto 3
121and
122.Xr OPENSSL_load_builtin_modules 3 .
123.Pp
124If an application is compiled with the preprocessor symbol
125.Dv OPENSSL_LOAD_CONF
126#define'd,
127.Xr OpenSSL_add_all_algorithms 3
128automatically calls
129.Fn OPENSSL_config .
130.Pp
131Applications should free up configuration at application closedown by
132calling
133.Xr CONF_modules_free 3 .
134.Sh FILES
135.Bl -tag -width /etc/ssl/openssl.cnf -compact
136.It Pa /etc/ssl/openssl.cnf
137standard configuration file
138.El
139.Sh SEE ALSO
140.Xr CONF_modules_free 3 ,
141.Xr CONF_modules_load_file 3 ,
142.Xr crypto 3 ,
143.Xr OPENSSL_load_builtin_modules 3 ,
144.Xr OPENSSL_VERSION_NUMBER 3 ,
145.Xr openssl.cnf 5 ,
146.Xr x509v3.cnf 5
147.Sh HISTORY
148.Fn OPENSSL_config
149and
150.Fn OPENSSL_no_config
151first appeared in OpenSSL 0.9.7 and have been available since
152.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/OPENSSL_init_crypto.3 b/src/lib/libcrypto/man/OPENSSL_init_crypto.3
deleted file mode 100644
index 6f38c7bda2..0000000000
--- a/src/lib/libcrypto/man/OPENSSL_init_crypto.3
+++ /dev/null
@@ -1,115 +0,0 @@
1.\" $OpenBSD: OPENSSL_init_crypto.3,v 1.5 2020/05/24 12:21:31 schwarze Exp $
2.\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org>
3.\"
4.\" Permission to use, copy, modify, and distribute this software for any
5.\" purpose with or without fee is hereby granted, provided that the above
6.\" copyright notice and this permission notice appear in all copies.
7.\"
8.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\"
16.Dd $Mdocdate: May 24 2020 $
17.Dt OPENSSL_INIT_CRYPTO 3
18.Os
19.Sh NAME
20.Nm OPENSSL_init_crypto ,
21.Nm OPENSSL_init
22.Nd initialise the crypto library
23.Sh SYNOPSIS
24.In openssl/crypto.h
25.Ft int
26.Fo OPENSSL_init_crypto
27.Fa "uint64_t options"
28.Fa "const void *dummy"
29.Fc
30.Ft void
31.Fn OPENSSL_init void
32.Sh DESCRIPTION
33These functions are deprecated.
34It is never useful for an application program
35to call either of them explicitly.
36.Pp
37The library automatically calls
38.Fn OPENSSL_init_crypto
39internally with an
40.Fa options
41argument of 0 whenever needed.
42It is safest to assume that any function may do so.
43.Pp
44To enable or disable the standard configuration file, instead use
45.Xr OPENSSL_config 3
46or
47.Xr OPENSSL_no_config 3 ,
48respectively.
49To load a non-standard configuration file, refer to
50.Xr CONF_modules_load_file 3 .
51.Pp
52If
53.Fn OPENSSL_init_crypto
54is called before any other crypto or ssl functions, the crypto
55library is initialised by allocating various internal resources,
56in particular calling
57.Xr ERR_load_crypto_strings 3 ,
58.Xr OpenSSL_add_all_ciphers 3 ,
59and
60.Xr OpenSSL_add_all_digests 3 .
61.Pp
62The following
63.Fa options
64are supported:
65.Bl -tag -width Ds
66.It Dv OPENSSL_INIT_LOAD_CONFIG
67At the end of the initialization, call
68.Xr OPENSSL_config 3
69with a
70.Dv NULL
71argument, loading the default configuration file.
72.It Dv OPENSSL_INIT_NO_LOAD_CONFIG
73Ignore any later calls to
74.Xr OPENSSL_config 3 .
75.El
76.Pp
77The other
78.Fa options
79flags defined by OpenSSL are all ignored by LibreSSL.
80The
81.Fa dummy
82argument has no effect.
83.Pp
84If this function is called more than once, none of the calls except
85the first one have any effect.
86.Pp
87.Fn OPENSSL_init
88has no effect at all.
89.Sh RETURN VALUES
90.Fn OPENSSL_init_crypto
91is intended to return 1 on success or 0 on error.
92.Sh SEE ALSO
93.Xr CONF_modules_load_file 3 ,
94.Xr OPENSSL_config 3 ,
95.Xr OPENSSL_load_builtin_modules 3 ,
96.Xr openssl.cnf 5
97.Sh HISTORY
98.Fn OPENSSL_init
99first appeared in OpenSSL 1.0.0e and has been available since
100.Ox 5.3 .
101It stopped having any effect in OpenSSL 1.1.1 and in
102.Ox 5.6 .
103.Pp
104.Fn OPENSSL_init_crypto
105first appeared in OpenSSL 1.1.0 and has been available since
106.Ox 6.3 .
107.Sh BUGS
108.Fn OPENSSL_init_crypto
109silently ignores almost all kinds of errors.
110In particular, if memory allocation fails, initialisation is likely
111to remain incomplete, the library may be in an inconsistent internal
112state, but the return value will usually indicate success anyway.
113There is no way for the application program to find out whether
114library initialisation is actually complete, nor to get back to a
115consistent state if it isn't.
diff --git a/src/lib/libcrypto/man/OPENSSL_load_builtin_modules.3 b/src/lib/libcrypto/man/OPENSSL_load_builtin_modules.3
deleted file mode 100644
index 2b20efaf0e..0000000000
--- a/src/lib/libcrypto/man/OPENSSL_load_builtin_modules.3
+++ /dev/null
@@ -1,101 +0,0 @@
1.\" $OpenBSD: OPENSSL_load_builtin_modules.3,v 1.8 2023/12/05 02:41:13 jsg Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2004, 2013 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 5 2023 $
52.Dt OPENSSL_LOAD_BUILTIN_MODULES 3
53.Os
54.Sh NAME
55.Nm OPENSSL_load_builtin_modules ,
56.Nm ASN1_add_oid_module
57.Nd add standard configuration modules
58.Sh SYNOPSIS
59.In openssl/conf.h
60.Ft void
61.Fn OPENSSL_load_builtin_modules void
62.Ft void
63.Fn ASN1_add_oid_module void
64.Sh DESCRIPTION
65The function
66.Fn OPENSSL_load_builtin_modules
67adds all the standard OpenSSL configuration modules to the internal
68list.
69They can then be used by the OpenSSL configuration code.
70.Pp
71.Fn ASN1_add_oid_module
72adds just the ASN.1 OBJECT module.
73.Pp
74If the simple configuration function
75.Xr OPENSSL_config 3
76is called then
77.Fn OPENSSL_load_builtin_modules
78is called automatically.
79.Pp
80Applications which use configuration functions like
81.Xr CONF_modules_load_file 3
82directly need to call
83.Fn OPENSSL_load_builtin_modules
84themselves
85.Em before
86any other configuration code.
87.Pp
88Applications should call
89.Xr OPENSSL_config 3
90or
91.Fn OPENSSL_load_builtin_modules
92to load all configuration modules instead of adding modules selectively:
93otherwise functionality may be missing from the application when
94new modules are added.
95.Sh SEE ALSO
96.Xr CONF_modules_load_file 3 ,
97.Xr OPENSSL_config 3
98.Sh HISTORY
99These functions first appeared in OpenSSL 0.9.7
100and have been available since
101.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/OPENSSL_malloc.3 b/src/lib/libcrypto/man/OPENSSL_malloc.3
deleted file mode 100644
index a43dc56923..0000000000
--- a/src/lib/libcrypto/man/OPENSSL_malloc.3
+++ /dev/null
@@ -1,101 +0,0 @@
1.\" $OpenBSD: OPENSSL_malloc.3,v 1.13 2024/04/04 09:30:43 tb Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: April 4 2024 $
18.Dt OPENSSL_MALLOC 3
19.Os
20.Sh NAME
21.Nm OPENSSL_malloc ,
22.Nm OPENSSL_free ,
23.Nm OPENSSL_strdup ,
24.Nm CRYPTO_malloc ,
25.Nm CRYPTO_free ,
26.Nm CRYPTO_strdup
27.Nd legacy OpenSSL memory allocation wrappers
28.Sh SYNOPSIS
29.In openssl/crypto.h
30.Ft void *
31.Fo OPENSSL_malloc
32.Fa "size_t num"
33.Fc
34.Ft void
35.Fo OPENSSL_free
36.Fa "void *addr"
37.Fc
38.Ft char *
39.Fo OPENSSL_strdup
40.Fa "const char *str"
41.Fc
42.Ft void *
43.Fo CRYPTO_malloc
44.Fa "size_t num"
45.Fa "const char *file"
46.Fa "int line"
47.Fc
48.Ft void
49.Fo CRYPTO_free
50.Fa "void *str"
51.Fa "const char *"
52.Fa int
53.Fc
54.Ft char *
55.Fo CRYPTO_strdup
56.Fa "const char *p"
57.Fa "const char *file"
58.Fa "int line"
59.Fc
60.Sh DESCRIPTION
61Do not use any of the interfaces documented here in new code.
62They are provided purely for compatibility with legacy application code.
63.Pp
64These functions are wrappers around the corresponding
65standard
66.Xr malloc 3 ,
67.Xr free 3 ,
68and
69.Xr strdup 3
70functions.
71.Pp
72The
73.Fn OPENSSL_*
74functions are implemented as macros.
75.Sh RETURN VALUES
76These functions return the same type and value as the corresponding
77standard functions.
78.Sh SEE ALSO
79.Xr crypto 3
80.Sh HISTORY
81.Fn CRYPTO_malloc
82and
83.Fn CRYPTO_free
84first appeared in SSLeay 0.6.4 and have been available since
85.Ox 2.4 .
86.Pp
87.Fn OPENSSL_malloc
88and
89.Fn OPENSSL_free
90first appeared in OpenSSL 0.9.6 and have been available since
91.Ox 2.9 .
92.Pp
93.Fn CRYPTO_strdup
94and
95.Fn OPENSSL_strdup
96first appeared in OpenSSL 0.9.8j and have been available since
97.Ox 4.5 .
98.Sh CAVEATS
99If interoperability with other implementations is required,
100memory returned by the library as bare pointers must be freed with
101.Fn OPENSSL_free .
diff --git a/src/lib/libcrypto/man/OPENSSL_sk_new.3 b/src/lib/libcrypto/man/OPENSSL_sk_new.3
deleted file mode 100644
index 8f06bb4212..0000000000
--- a/src/lib/libcrypto/man/OPENSSL_sk_new.3
+++ /dev/null
@@ -1,553 +0,0 @@
1.\" $OpenBSD: OPENSSL_sk_new.3,v 1.13 2024/03/04 09:47:34 tb Exp $
2.\"
3.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 4 2024 $
18.Dt OPENSSL_SK_NEW 3
19.Os
20.Sh NAME
21.Nm sk_new_null ,
22.Nm sk_new ,
23.Nm sk_set_cmp_func ,
24.Nm sk_dup ,
25.Nm sk_free ,
26.Nm sk_pop_free ,
27.Nm sk_num ,
28.Nm sk_value ,
29.Nm sk_find ,
30.Nm sk_sort ,
31.Nm sk_is_sorted ,
32.Nm sk_push ,
33.Nm sk_unshift ,
34.Nm sk_insert ,
35.Nm sk_set ,
36.Nm sk_pop ,
37.Nm sk_shift ,
38.Nm sk_delete ,
39.Nm sk_delete_ptr ,
40.Nm sk_zero
41.Nd variable-sized arrays of void pointers, called OpenSSL stacks
42.Sh SYNOPSIS
43.In openssl/stack.h
44.Ft _STACK *
45.Fn sk_new_null void
46.Ft _STACK *
47.Fo sk_new
48.Fa "int (*compfunc)(const void *, const void *)"
49.Fc
50.Ft old_function_pointer
51.Fo sk_set_cmp_func
52.Fa "_STACK *stack"
53.Fa "int (*compfunc)(const void *, const void *)"
54.Fc
55.Ft _STACK *
56.Fo sk_dup
57.Fa "_STACK *stack"
58.Fc
59.Ft void
60.Fo sk_free
61.Fa "_STACK *stack"
62.Fc
63.Ft void
64.Fo sk_pop_free
65.Fa "_STACK *stack"
66.Fa "void (*freefunc)(void *)"
67.Fc
68.Ft int
69.Fo sk_num
70.Fa "const _STACK *stack"
71.Fc
72.Ft void *
73.Fo sk_value
74.Fa "const _STACK *stack"
75.Fa "int index"
76.Fc
77.Ft int
78.Fo sk_find
79.Fa "_STACK *stack"
80.Fa "void *wanted"
81.Fc
82.Ft void
83.Fo sk_sort
84.Fa "_STACK *stack"
85.Fc
86.Ft int
87.Fo sk_is_sorted
88.Fa "const _STACK *stack"
89.Fc
90.Ft int
91.Fo sk_push
92.Fa "_STACK *stack"
93.Fa "void *new_item"
94.Fc
95.Ft int
96.Fo sk_unshift
97.Fa "_STACK *stack"
98.Fa "void *new_item"
99.Fc
100.Ft int
101.Fo sk_insert
102.Fa "_STACK *stack"
103.Fa "void *new_item"
104.Fa "int index"
105.Fc
106.Ft void *
107.Fo sk_set
108.Fa "_STACK *stack"
109.Fa "int index"
110.Fa "void *new_item"
111.Fc
112.Ft void *
113.Fo sk_pop
114.Fa "_STACK *stack"
115.Fc
116.Ft void *
117.Fo sk_shift
118.Fa "_STACK *stack"
119.Fc
120.Ft void *
121.Fo sk_delete
122.Fa "_STACK *stack"
123.Fa "int index"
124.Fc
125.Ft void *
126.Fo sk_delete_ptr
127.Fa "_STACK *stack"
128.Fa "void *wanted"
129.Fc
130.Ft void
131.Fo sk_zero
132.Fa "_STACK *stack"
133.Fc
134.Sh DESCRIPTION
135OpenSSL introduced an idiosyncratic concept of variable sized arrays
136of pointers and somewhat misleadingly called such an array a
137.Dq stack .
138Intrinsically, and as documented in this manual page, OpenSSL stacks
139are not type safe but only handle
140.Vt void *
141function arguments and return values.
142.Pp
143OpenSSL also provides a fragile, unusually complicated system of
144macro-generated wrappers that offers superficial type safety at the
145expense of extensive obfuscation, implemented using large amounts
146of autogenerated code involving exceedingly ugly, nested
147.Xr cpp 1
148macros; see the
149.Xr STACK_OF 3
150manual page for details.
151.Pp
152The fundamental data type is the
153.Vt _STACK
154structure.
155It stores a variable number of void pointers
156and remembers the number of pointers currently stored.
157It can optionally hold a pointer to a comparison function.
158As long as no comparison function is installed, the order of pointers
159is meaningful; as soon as a comparison function is installed, it
160becomes ill-defined.
161.Pp
162.Fn sk_new_null
163allocates and initializes a new, empty stack.
164.Fn sk_new
165is identical except that it also installs
166.Fa compfunc
167as the comparison function for the new stack object.
168.Fn sk_set_cmp_func
169installs
170.Fa compfunc
171for the existing
172.Fa stack .
173The
174.Fa compfunc
175is allowed to be
176.Dv NULL ,
177but the
178.Fa stack
179is not.
180.Pp
181.Fn sk_dup
182creates a shallow copy of the given
183.Fa stack ,
184which must not be a
185.Dv NULL
186pointer.
187It neither copies the objects pointed to from the stack nor
188increases their reference counts, but merely copies the pointers.
189Extreme care must be taken in order to avoid freeing the memory twice,
190for example by calling
191.Fn sk_free
192on one copy and only calling
193.Fn sk_pop_free
194on the other.
195.Pp
196.Fn sk_free
197frees the given
198.Fa stack .
199It does not free any of the pointers stored on the stack.
200Unless these pointers are merely copies of pointers owned by
201other objects, they must be freed before calling
202.Fn sk_free ,
203in order to avoid leaking memory.
204If
205.Fa stack
206is a
207.Dv NULL
208pointer, no action occurs.
209.Pp
210.Fn sk_pop_free
211is severely misnamed.
212It does not at all do what one would expect from a function called
213.Dq pop .
214Instead, it does the same as
215.Fn sk_free ,
216except that it also calls the function
217.Fa freefunc
218on each of the pointers contained in the
219.Fa stack .
220If the calls to
221.Fa freefunc
222are intended to free the memory in use by the objects on the stack,
223ensure that no other pointers to the same objects remain elsewhere.
224.Pp
225.Fn sk_find
226searches the
227.Fa stack
228for the
229.Fa wanted
230pointer.
231If the
232.Fa stack
233contains more than one copy of the
234.Fa wanted
235pointer, only the first match is found.
236If a comparison function is installed for the stack, the stack is
237first sorted with
238.Fn sk_sort ,
239and instead of comparing pointers, two pointers are considered to match
240if the comparison function returns 0.
241.Pp
242.Fn sk_sort
243sorts the
244.Fa stack
245using
246.Xr qsort 3
247and the installed comparison function.
248If
249.Fa stack
250is a
251.Dv NULL
252pointer or already considered sorted, no action occurs.
253This function can only be called if a comparison function is installed.
254.Pp
255.Fn sk_is_sorted
256reports whether the
257.Fa stack
258is considered sorted.
259Calling
260.Fn sk_new_null
261or
262.Fn sk_new ,
263successfully calling
264.Fn sk_push ,
265.Fn sk_unshift ,
266.Fn sk_insert ,
267or
268.Fn sk_set ,
269or changing the comparison function sets the state to unsorted.
270If a comparison function is installed, calling
271.Fn sk_sort ,
272or
273.Fn sk_find
274sets the state to sorted.
275.Pp
276.Fn sk_push
277pushes
278.Fa new_item
279onto the end of the
280.Fa stack ,
281increasing the number of pointers by 1.
282If
283.Fa stack
284is a
285.Dv NULL
286pointer, no action occurs.
287.Pp
288.Fn sk_unshift
289inserts
290.Fa new_item
291at the beginning of the
292.Fa stack ,
293such that it gets the index 0.
294The number of pointers increases by 1.
295If
296.Fa stack
297is a
298.Dv NULL
299pointer, no action occurs.
300.Pp
301.Fn sk_insert
302inserts the
303.Fa new_item
304into the
305.Fa stack
306such that it gets the given
307.Fa index .
308If
309.Fa index
310is less than 0 or greater than or equal to
311.Fn sk_num stack ,
312the effect is the same as for
313.Fn sk_push .
314If
315.Fa stack
316is a
317.Dv NULL
318pointer, no action occurs.
319.Pp
320.Fn sk_set
321replaces the pointer with the given
322.Fa index
323on the
324.Fa stack
325with the
326.Fa new_item .
327The old pointer is not freed,
328which may leak memory if no copy of it exists elsewhere.
329If
330.Fa stack
331is a
332.Dv NULL
333pointer or if
334.Fa index
335is less than 0 or greater than or equal to
336.Fn sk_num stack ,
337no action occurs.
338.Pp
339.Fn sk_pop
340and
341.Fn sk_shift
342remove the pointer with the highest or lowest index from the
343.Fa stack ,
344respectively, reducing the number of pointers by 1.
345If
346.Fa stack
347is a
348.Dv NULL
349pointer or if it is empty, no action occurs.
350.Pp
351.Fn sk_delete
352removes the pointer with the given
353.Fa index
354from the
355.Fa stack ,
356reducing the number of pointers by 1.
357If
358.Fa stack
359is a
360.Dv NULL
361pointer or the
362.Fa index
363is less than 0 or greater than or equal to
364.Fn sk_num stack ,
365no action occurs.
366.Pp
367.Fn sk_delete_ptr
368removes the
369.Fa wanted
370pointer from the
371.Fa stack ,
372reducing the number of pointers by 1 if it is found.
373It never uses a comparison function
374but only compares pointers themselves.
375The
376.Fa stack
377pointer must not be
378.Dv NULL .
379.Pp
380.Fn sk_zero
381removes all pointers from the
382.Fa stack .
383It does not free any of the pointers.
384Unless these pointers are merely copies of pointers owned by other
385objects, they must be freed before calling
386.Fn sk_zero ,
387in order to avoid leaking memory.
388If
389.Fa stack
390is a
391.Dv NULL
392pointer, no action occurs.
393.Sh RETURN VALUES
394.Fn sk_new_null ,
395.Fn sk_new ,
396and
397.Fn sk_dup
398return a pointer to the newly allocated stack object or
399.Dv NULL
400if insufficient memory is available.
401.Pp
402.Fn sk_set_cmp_func
403returns a pointer to the comparison function
404that was previously installed for the
405.Fa stack
406or
407.Dv NULL
408if none was installed.
409.Pp
410.Fn sk_num
411returns the number of pointers currently stored on the
412.Fa stack ,
413or \-1 if
414.Fa stack
415is a
416.Dv NULL
417pointer.
418.Pp
419.Fn sk_value
420returns the pointer with the given
421.Fa index
422from the
423.Fa stack ,
424or
425.Dv NULL
426if
427.Fa stack
428is a
429.Dv NULL
430pointer or if the
431.Fa index
432is less than 0 or greater than or equal to
433.Fn sk_num stack .
434.Pp
435.Fn sk_find
436returns the lowest index considered to match or \-1 if
437.Fa stack
438is a
439.Dv NULL
440pointer or if no match is found.
441.Pp
442.Fn sk_is_sorted
443returns 1 if the
444.Fa stack
445is considered sorted or if it is a
446.Dv NULL
447pointer, or 0 otherwise.
448.Pp
449.Fn sk_push ,
450.Fn sk_unshift ,
451and
452.Fn sk_insert
453return the new number of pointers on the
454.Fa stack
455or 0 if
456.Fa stack
457is a
458.Dv NULL
459pointer or if memory allocation fails.
460.Pp
461.Fn sk_set
462returns
463.Fa new_item
464or
465.Dv NULL
466if
467.Fa stack
468is a
469.Dv NULL
470pointer or if the
471.Fa index
472is less than 0 or greater than or equal to
473.Fn sk_num stack .
474.Pp
475.Fn sk_pop
476and
477.Fn sk_shift
478return the deleted pointer or
479.Dv NULL
480if
481.Fa stack
482is a
483.Dv NULL
484pointer or if it is empty.
485.Pp
486.Fn sk_delete
487returns the deleted pointer or
488.Dv NULL
489if
490.Fa stack
491is a
492.Dv NULL
493pointer or if the
494.Fa index
495is less than 0 or greater than or equal to
496.Fn sk_num stack .
497.Pp
498.Fn sk_delete_ptr
499returns
500.Fa wanted
501or
502.Dv NULL
503if it is not found.
504.Sh SEE ALSO
505.Xr STACK_OF 3
506.Sh HISTORY
507.Fn sk_new_null ,
508.Fn sk_new ,
509.Fn sk_free ,
510.Fn sk_pop_free ,
511.Fn sk_num ,
512.Fn sk_value ,
513.Fn sk_find ,
514.Fn sk_push ,
515.Fn sk_unshift ,
516.Fn sk_insert ,
517.Fn sk_pop ,
518.Fn sk_shift ,
519.Fn sk_delete ,
520and
521.Fn sk_delete_ptr
522first appeared in SSLeay 0.5.1.
523.Fn sk_set_cmp_func ,
524.Fn sk_dup ,
525and
526.Fn sk_zero
527first appeared in SSLeay 0.8.0.
528These functions have been available since
529.Ox 2.4 .
530.Pp
531.Fn sk_set
532first appeared in OpenSSL 0.9.3.
533.Fn sk_sort
534first appeared in OpenSSL 0.9.4.
535Both functions have been available since
536.Ox 2.6 .
537.Pp
538.Fn sk_is_sorted
539first appeared in OpenSSL 0.9.7e and has been available since
540.Ox 3.8 .
541.Sh BUGS
542Even if a comparison function is installed, empty stacks and
543stacks containing a single pointer are sometimes considered
544sorted and sometimes considered unsorted.
545.Pp
546If a comparison function is installed, the concept of
547.Dq first match
548in
549.Fn sk_find
550is ill-defined because
551.Xr qsort 3
552is not a stable sorting function.
553It is probably best to only assume that they return an arbitrary match.
diff --git a/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3 b/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3
deleted file mode 100644
index 88ecef9768..0000000000
--- a/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3
+++ /dev/null
@@ -1,152 +0,0 @@
1.\" $OpenBSD: OpenSSL_add_all_algorithms.3,v 1.16 2024/03/04 19:04:47 tb Exp $
2.\" full merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000, 2003, 2013 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 4 2024 $
52.Dt OPENSSL_ADD_ALL_ALGORITHMS 3
53.Os
54.Sh NAME
55.Nm OpenSSL_add_all_algorithms ,
56.Nm OpenSSL_add_all_ciphers ,
57.Nm OpenSSL_add_all_digests ,
58.Nm EVP_cleanup ,
59.Nm SSLeay_add_all_algorithms
60.\" .Nm OPENSSL_add_all_algorithms_conf ,
61.\" .Nm OPENSSL_add_all_algorithms_noconf ,
62.\" .Nm SSLeay_add_all_ciphers , and
63.\" .Nm SSLeay_add_all_digests are intentionally undocumented
64.\" because they are unused aliases.
65.Nd add algorithms to internal table
66.Sh SYNOPSIS
67.In openssl/evp.h
68.Ft void
69.Fn OpenSSL_add_all_algorithms void
70.Ft void
71.Fn OpenSSL_add_all_ciphers void
72.Ft void
73.Fn OpenSSL_add_all_digests void
74.Ft void
75.Fn EVP_cleanup void
76.Ft void
77.Fn SSLeay_add_all_algorithms void
78.Sh DESCRIPTION
79These functions are deprecated.
80It is never useful for any application program
81to call any of them explicitly.
82The library automatically calls them internally whenever needed.
83.Pp
84OpenSSL keeps an internal table of digest algorithms and ciphers.
85It uses this table to look up ciphers via functions such as
86.Xr EVP_get_cipherbyname 3 .
87.Pp
88.Fn OpenSSL_add_all_algorithms
89adds all algorithms to the table (digests and ciphers).
90If an application is compiled with the preprocessor symbol
91.Dv OPENSSL_LOAD_CONF
92#define'd, it also calls
93.Xr OPENSSL_config 3
94with a
95.Dv NULL
96argument, loading the default configuration file.
97.Pp
98.Fn OpenSSL_add_all_digests
99adds all digest algorithms to the table.
100.Pp
101.Fn OpenSSL_add_all_ciphers
102adds all encryption algorithms to the table including password based
103encryption algorithms.
104.Pp
105If any of the above functions is called more than once,
106only the first call has an effect.
107.Pp
108.Fn EVP_cleanup
109removes all ciphers and digests from the table and also calls
110.Xr OBJ_NAME_cleanup 3
111with an argument of \-1 ,
112thus resetting the global associative array of names
113and all signature algorithm definitions to their default states,
114removing all application-defined types, key-value pairs, and aliases,
115including any that are unrelated to the EVP library.
116.Pp
117.Fn SSLeay_add_all_algorithms
118is a deprecated alias for
119.Fn OpenSSL_add_all_algorithms .
120.Pp
121.Fn OpenSSL_add_all_algorithms
122and
123.Fn SSLeay_add_all_algorithms
124are implemented as macros.
125.Sh SEE ALSO
126.Xr evp 3 ,
127.Xr EVP_DigestInit 3 ,
128.Xr EVP_EncryptInit 3 ,
129.Xr OBJ_cleanup 3 ,
130.Xr OBJ_NAME_add 3 ,
131.Xr OPENSSL_config 3
132.Sh HISTORY
133.Fn EVP_cleanup ,
134.Fn SSLeay_add_all_algorithms ,
135and precursor functions
136.Fn SSLeay_add_all_ciphers
137and
138.Fn SSLeay_add_all_digests
139first appeared in SSLeay 0.8.0 and have been available since
140.Ox 2.4 .
141.Pp
142.Fn OpenSSL_add_all_algorithms ,
143.Fn OpenSSL_add_all_ciphers ,
144and
145.Fn OpenSSL_add_all_digests
146first appeared in OpenSSL 0.9.5 and have been available since
147.Ox 2.7 .
148.Sh BUGS
149Although the functions do not return error codes, it is possible for them
150to fail.
151This will only happen as a result of a memory allocation failure so this
152is not too much of a problem in practice.
diff --git a/src/lib/libcrypto/man/PEM_ASN1_read.3 b/src/lib/libcrypto/man/PEM_ASN1_read.3
deleted file mode 100644
index 53ebe5ada4..0000000000
--- a/src/lib/libcrypto/man/PEM_ASN1_read.3
+++ /dev/null
@@ -1,172 +0,0 @@
1.\" $OpenBSD: PEM_ASN1_read.3,v 1.2 2020/07/23 17:34:53 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 23 2020 $
18.Dt PEM_ASN1_READ 3
19.Os
20.Sh NAME
21.Nm d2i_of_void ,
22.Nm PEM_ASN1_read ,
23.Nm PEM_ASN1_read_bio
24.Nd PEM and DER decode an arbitrary ASN.1 value
25.Sh SYNOPSIS
26.In openssl/pem.h
27.Ft typedef void *
28.Fo d2i_of_void
29.Fa "void **val_out"
30.Fa "const unsigned char **der_in"
31.Fa "long length"
32.Fc
33.Ft void *
34.Fo PEM_ASN1_read
35.Fa "d2i_of_void *d2i"
36.Fa "const char *name"
37.Fa "FILE *in_fp"
38.Fa "void **val_out"
39.Fa "pem_password_cb *cb"
40.Fa "void *u"
41.Fc
42.Ft void *
43.Fo PEM_ASN1_read_bio
44.Fa "d2i_of_void *d2i"
45.Fa "const char *name"
46.Fa "BIO *in_bp"
47.Fa "void **val_out"
48.Fa "pem_password_cb *cb"
49.Fa "void *u"
50.Fc
51.Sh DESCRIPTION
52These functions read one object from
53.Fa in_fp
54or
55.Fa in_bp
56and perform both PEM and DER decoding.
57They are needed when more specific decoding functions
58like those documented in
59.Xr PEM_read_bio_PrivateKey 3
60and
61.Xr PEM_read_SSL_SESSION 3
62are inadequate for the type
63.Fa name .
64.Pp
65For PEM decoding,
66.Xr PEM_bytes_read_bio 3
67is called internally.
68Consequently, the first object of type
69.Fa name
70is returned and preceding objects of other types are discarded.
71If necessary, data is decrypted, using
72.Fa cb
73and/or
74.Fa u
75if they are not
76.Dv NULL ,
77as described in the
78.Xr pem_password_cb 3
79manual page.
80.Pp
81For subsequent DER decoding, pass a
82.Fa d2i
83callback function that is adequate for the type
84.Fa name ,
85typically returning a pointer of a type more specific than
86.Ft void * .
87For example,
88.Xr d2i_ASN1_TYPE 3
89can always be used and its manual page describes the required
90behaviour of the callback function to be passed.
91Normally, passing a more specific function is more useful;
92candidate functions can be found with
93.Ql man -k Nm~^d2i_ .
94.Pp
95For the
96.Fa name
97argument, the
98.Dv PEM_STRING_*
99string constants defined in
100.In openssl/pem.h
101can be used.
102.Pp
103The
104.Fa val_out
105argument is useless and its many dangers are described in detail in the
106.Xr d2i_ASN1_TYPE 3
107manual page.
108To reduce the risk of bugs, always passing
109.Dv NULL
110is recommended.
111.Sh RETURN VALUES
112These functions return a pointer to the decoded object or
113.Dv NULL
114if an error occurs.
115They fail if
116.Xr PEM_bytes_read_bio 3
117fails, for example because of invalid syntax in the input, an unknown
118encryption, or an invalid passphrase entered by the user.
119They also fail if
120.Fa d2i
121returns
122.Dv NULL ,
123for example due to DER decoding errors.
124.Pp
125.Fn PEM_ASN1_read
126may also fail if memory is exhausted.
127.Sh EXAMPLES
128Typical usage of
129.Fn PEM_ASN1_read
130is demonstrated by the implementation of the more specific function
131to PEM and DER decode an X.509 certificate:
132.Bd -literal -offset 2n
133X509 *
134PEM_read_X509(FILE *fp, X509 **val_out, pem_password_cb *cb, void *u)
135{
136 return PEM_ASN1_read((d2i_of_void *)d2i_X509, PEM_STRING_X509,
137 fp, (void **)val_out, cb, u);
138}
139.Ed
140.Sh ERRORS
141Diagnostics that can be retrieved with
142.Xr ERR_get_error 3 ,
143.Xr ERR_GET_REASON 3 ,
144and
145.Xr ERR_reason_error_string 3
146include:
147.Bl -tag -width Ds
148.It Dv ERR_R_BUF_LIB Qq "BUF lib"
149.Fn PEM_ASN1_read
150failed to set up a temporary BIO,
151for example because memory was exhausted.
152.It Dv ERR_R_ASN1_LIB Qq "ASN1 lib"
153.Fa d2i
154returned
155.Dv NULL ,
156for example due to a DER syntax error.
157.El
158.Pp
159Additional types of errors can result from
160.Xr PEM_bytes_read_bio 3 .
161.Sh SEE ALSO
162.Xr BIO_new 3 ,
163.Xr d2i_ASN1_TYPE 3 ,
164.Xr PEM_bytes_read_bio 3 ,
165.Xr PEM_read 3 ,
166.Xr PEM_read_bio_PrivateKey 3 ,
167.Xr PEM_read_SSL_SESSION 3 ,
168.Xr PEM_X509_INFO_read 3
169.Sh HISTORY
170These functions first appeared in SSLeay 0.5.1
171and have been available since
172.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/PEM_X509_INFO_read.3 b/src/lib/libcrypto/man/PEM_X509_INFO_read.3
deleted file mode 100644
index b3216a89b6..0000000000
--- a/src/lib/libcrypto/man/PEM_X509_INFO_read.3
+++ /dev/null
@@ -1,189 +0,0 @@
1.\" $OpenBSD: PEM_X509_INFO_read.3,v 1.4 2021/10/19 10:39:33 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 19 2021 $
18.Dt PEM_X509_INFO_READ 3
19.Os
20.Sh NAME
21.Nm PEM_X509_INFO_read ,
22.Nm PEM_X509_INFO_read_bio
23.Nd PEM and DER decode X.509 certificates, private keys, and revocation lists
24.Sh SYNOPSIS
25.In openssl/pem.h
26.Ft STACK_OF(X509_INFO) *
27.Fo PEM_X509_INFO_read
28.Fa "FILE *in_fp"
29.Fa "STACK_OF(X509_INFO) *sk"
30.Fa "pem_password_cb *cb"
31.Fa "void *u"
32.Fc
33.Ft STACK_OF(X509_INFO) *
34.Fo PEM_X509_INFO_read_bio
35.Fa "BIO *in_bp"
36.Fa "STACK_OF(X509_INFO) *sk"
37.Fa "pem_password_cb *cb"
38.Fa "void *u"
39.Fc
40.Sh DESCRIPTION
41These functions read zero or more objects
42related to X.509 certificates from
43.Fa in_fp
44or
45.Fa in_bp ,
46perform both PEM and DER decoding,
47and wrap the resulting objects in newly allocated
48.Vt X509_INFO
49containers.
50.Pp
51Setting
52.Fa sk
53to
54.Dv NULL
55is recommended, in which case
56a new stack is allocated, populated, and returned.
57If an existing
58.Fa sk
59is passed in, the created
60.Vt X509_INFO
61objects are pushed onto that stack.
62.Pp
63For PEM decoding,
64.Xr PEM_read_bio 3
65is used internally, implying that any non-PEM data
66before, between, and after the objects is silently discarded.
67.Pp
68For subsequent DER decoding,
69the decoding function and the field of the
70.Vt X509_INFO
71structure to store the new object in
72are selected according to the PEM type name:
73.Bl -column "TRUSTED CERTIFICATE" "d2i_PrivateKey()" "revocation list"
74.It PEM type name Ta decoder Ta Vt X509_INFO No field
75.It CERTIFICATE Ta Xr d2i_X509 3 Ta certificate
76.It X509 CERTIFICATE Ta Xr d2i_X509 3 Ta certificate
77.It TRUSTED CERTIFICATE Ta Xr d2i_X509_AUX 3 Ta certificate
78.It X509 CRL Ta Xr d2i_X509_CRL 3 Ta revocation list
79.It RSA PRIVATE KEY Ta Xr d2i_PrivateKey 3 Ta private key
80.It DSA PRIVATE KEY Ta Xr d2i_PrivateKey 3 Ta private key
81.It EC PRIVATE KEY Ta Xr d2i_PrivateKey 3 Ta private key
82.El
83.Pp
84Whenever the selected field is already occupied, another new
85.Vt X509_INFO
86container is allocated and pushed onto the stack.
87Depending on the sequence of objects in the input, this can result
88in several partially populated
89.Vt X509_INFO
90containers being pushed onto the stack.
91.Pp
92PEM objects of types not listed in the above table are silently skipped.
93.Pp
94Encrypted certificates and revocation lists are decrypted by calling
95.Xr PEM_do_header 3
96internally, passing through the optional arguments
97.Fa cb
98and
99.Fa u .
100Encrypted private keys are not decrypted.
101Instead, the encrypted form is stored as read.
102All the same,
103.Xr PEM_get_EVP_CIPHER_INFO 3
104is called internally to check that PEM headers, if there are any,
105are valid and specify an encryption the library is prepared to handle.
106.Pp
107If any error occurs, objects that had already been read
108during the same call are deleted again and
109.Fa sk
110is left unchanged.
111.Sh RETURN VALUES
112These functions return a pointer to the stack
113the objects read were pushed onto or
114.Dv NULL
115if an error occurs.
116They fail if
117.Xr PEM_read_bio 3 ,
118.Xr PEM_get_EVP_CIPHER_INFO 3 ,
119.Xr PEM_do_header 3 ,
120or DER decoding fails or if memory is exhausted.
121.Sh ERRORS
122Diagnostics that can be retrieved with
123.Xr ERR_get_error 3 ,
124.Xr ERR_GET_REASON 3 ,
125and
126.Xr ERR_reason_error_string 3
127include:
128.Bl -tag -width Ds
129.It Dv ERR_R_ASN1_LIB Qq "ASN1 lib"
130DER decoding of a PEM object failed.
131.It Dv ERR_R_BUF_LIB Qq BUF lib
132.Fn PEM_X509_INFO_read
133failed to set up a temporary BIO, for example because memory was exhausted.
134.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
135.Fn PEM_X509_INFO_read_bio
136failed to allocate a new
137.Vt X509_INFO ,
138.Vt STACK_OF(X509_INFO) ,
139or
140.Vt X509_PKEY
141object.
142.El
143.Pp
144Additional types of errors can result from
145.Xr PEM_read_bio 3 ,
146.Xr PEM_get_EVP_CIPHER_INFO 3 ,
147and
148.Xr PEM_do_header 3 .
149.Pp
150After these functions failed due to memory exhaustion,
151.Xr ERR_get_error 3
152may sometimes return 0 anyway.
153.Sh SEE ALSO
154.Xr BIO_new 3 ,
155.Xr d2i_PrivateKey 3 ,
156.Xr d2i_X509 3 ,
157.Xr d2i_X509_CRL 3 ,
158.Xr EVP_PKEY_new 3 ,
159.Xr PEM_read 3 ,
160.Xr PEM_read_bio_PrivateKey 3 ,
161.Xr STACK_OF 3 ,
162.Xr X509_CRL_new 3 ,
163.Xr X509_INFO_new 3 ,
164.Xr X509_LOOKUP_new 3 ,
165.Xr X509_new 3 ,
166.Xr X509_PKEY_new 3
167.Sh HISTORY
168.Fn PEM_X509_INFO_read
169first appeared in SSLeay 0.5.1 and
170.Fn PEM_X509_INFO_read_bio
171in SSLeay 0.6.0.
172Both functions have been available since
173.Ox 2.4 .
174.Sh CAVEATS
175It is not an error
176if the input does not contain any objects of the desired types.
177In that case, nothing is added to
178.Fa sk ,
179or if
180.Fa sk
181is
182.Dv NULL ,
183a newly allocated, empty stack is returned.
184The only way to detect this situation is by comparing
185the number of objects on the stack before and after the call.
186.Sh BUGS
187When reaching the end of the input, these functions call
188.Xr ERR_clear_error 3 ,
189which may hide errors that occurred before calling these functions.
diff --git a/src/lib/libcrypto/man/PEM_bytes_read_bio.3 b/src/lib/libcrypto/man/PEM_bytes_read_bio.3
deleted file mode 100644
index 20ad6b8a4d..0000000000
--- a/src/lib/libcrypto/man/PEM_bytes_read_bio.3
+++ /dev/null
@@ -1,184 +0,0 @@
1.\" $OpenBSD: PEM_bytes_read_bio.3,v 1.6 2020/07/23 17:34:53 schwarze Exp $
2.\" selective merge up to:
3.\" OpenSSL PEM_bytes_read_bio.pod 7671342e Feb 29 15:47:12 2016 -0600
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Benjamin Kaduk <bkaduk at akamai dot com>.
22.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: July 23 2020 $
69.Dt PEM_BYTES_READ_BIO 3
70.Os
71.Sh NAME
72.Nm PEM_bytes_read_bio
73.Nd read a PEM-encoded data structure from a BIO
74.Sh SYNOPSIS
75.In openssl/pem.h
76.Ft int
77.Fo PEM_bytes_read_bio
78.Fa "unsigned char **pdata"
79.Fa "long *plen"
80.Fa "char **pnm"
81.Fa "const char *name"
82.Fa "BIO *in_bp"
83.Fa "pem_password_cb *cb"
84.Fa "void *u"
85.Fc
86.Sh DESCRIPTION
87.Fn PEM_bytes_read_bio
88reads and PEM decodes the first object of type
89.Fa name
90.Pq e.g. RSA PRIVATE KEY, CERTIFICATE, etc.\&
91from
92.Fa in_bp .
93If multiple PEM-encoded data structures are present in the same stream,
94it skips non-matching data types and continues reading.
95Before reading each PEM object, lines not starting with
96.Qq "-----BEGIN "
97are also skipped; see
98.Xr PEM_read_bio 3
99for details of PEM parsing.
100.Pp
101The PEM header may indicate that the following data is encrypted; if so,
102the data is decrypted, optionally using
103.Fa cb
104and
105.Fa u ,
106as described in
107.Xr pem_password_cb 3 .
108.Pp
109Some data types have compatibility aliases, such as a file containing
110X509 CERTIFICATE matching a request for the deprecated type CERTIFICATE.
111The actual type indicated by the file is returned in
112.Em *pnm
113if
114.Fa pnm
115is
116.Pf non- Dv NULL .
117The caller must free the storage pointed to by
118.Em *pnm .
119.Pp
120The returned data is the DER-encoded form of the requested type, in
121.Em *pdata
122with length
123.Em *plen .
124The caller must free the storage pointed to by
125.Em *pdata .
126.Sh RETURN VALUES
127.Fn PEM_bytes_read_bio
128returns 1 for success or 0 for failure.
129.Sh ERRORS
130Diagnostics that can be retrieved with
131.Xr ERR_get_error 3 ,
132.Xr ERR_GET_REASON 3 ,
133and
134.Xr ERR_reason_error_string 3
135include:
136.Bl -tag -width Ds
137.It Dv PEM_R_NO_START_LINE Qq no start line
138No more PEM objects were found in the input.
139This can happen when the input contains no PEM objects at all,
140or only objects that do not match the type
141.Fa name .
142.It Dv PEM_R_NOT_PROC_TYPE Qq not proc type
143The first PEM header does not start with
144.Qq "Proc-Type: " .
145.It Dv PEM_R_NOT_ENCRYPTED Qq not encrypted
146The Proc-Type header differs from
147.Qq 4,ENCRYPTED .
148.It Dv PEM_R_SHORT_HEADER Qq short header
149The Proc-Type header is the last header line.
150.It Dv PEM_R_NOT_DEK_INFO Qq not dek info
151The second PEM header does not start with
152.Qq "DEK-Info: " .
153.It Dv PEM_R_UNSUPPORTED_ENCRYPTION Qq unsupported encryption
154The cipher name given in the DEK-Info header is unknown to
155.Xr EVP_get_cipherbyname 3 .
156.It Dv PEM_R_BAD_IV_CHARS Qq "bad iv chars"
157The word following the cipher name in the DEK-Info header
158contains bytes that are not hexadecimal digits.
159This also happens when the initialization vector is missing or too short.
160.It Dv PEM_R_BAD_PASSWORD_READ Qq bad password read
161.Fa cb
162reported failure.
163This may for example happen when the user mistypes the password.
164.It Dv PEM_R_BAD_DECRYPT Qq bad decrypt
165.Xr EVP_DecryptInit_ex 3 ,
166.Xr EVP_DecryptUpdate 3 ,
167or
168.Xr EVP_DecryptFinal_ex 3
169failed.
170.El
171.Pp
172Additional types of errors can result from
173.Xr PEM_read_bio 3 .
174.Sh SEE ALSO
175.Xr PEM_ASN1_read 3 ,
176.Xr PEM_read 3 ,
177.Xr PEM_read_bio_PrivateKey 3 ,
178.Xr PEM_X509_INFO_read 3
179.Sh STANDARDS
180RFC 1421: Privacy Enhancement for Internet Electronic Mail (PEM), Part I
181.Sh HISTORY
182.Fn PEM_bytes_read_bio
183first appeared in OpenSSL 0.9.7 and has been available since
184.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/PEM_read.3 b/src/lib/libcrypto/man/PEM_read.3
deleted file mode 100644
index 1493d54fc4..0000000000
--- a/src/lib/libcrypto/man/PEM_read.3
+++ /dev/null
@@ -1,416 +0,0 @@
1.\" $OpenBSD: PEM_read.3,v 1.15 2023/09/18 15:26:46 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Viktor Dukhovni
22.\" and by Rich Salz <rsalz@openssl.org>.
23.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: September 18 2023 $
70.Dt PEM_READ 3
71.Os
72.Sh NAME
73.Nm PEM_write ,
74.Nm PEM_write_bio ,
75.Nm PEM_read ,
76.Nm PEM_read_bio ,
77.Nm PEM_get_EVP_CIPHER_INFO ,
78.Nm PEM_do_header ,
79.Nm PEM_def_callback ,
80.Nm pem_password_cb
81.Nd PEM encoding routines
82.Sh SYNOPSIS
83.In openssl/pem.h
84.Ft int
85.Fo PEM_write
86.Fa "FILE *fp"
87.Fa "const char *name"
88.Fa "const char *header"
89.Fa "const unsigned char *data"
90.Fa "long len"
91.Fc
92.Ft int
93.Fo PEM_write_bio
94.Fa "BIO *bp"
95.Fa "const char *name"
96.Fa "const char *header"
97.Fa "const unsigned char *data"
98.Fa "long len"
99.Fc
100.Ft int
101.Fo PEM_read
102.Fa "FILE *fp"
103.Fa "char **name"
104.Fa "char **header"
105.Fa "unsigned char **data"
106.Fa "long *len"
107.Fc
108.Ft int
109.Fo PEM_read_bio
110.Fa "BIO *bp"
111.Fa "char **name"
112.Fa "char **header"
113.Fa "unsigned char **data"
114.Fa "long *len"
115.Fc
116.Ft int
117.Fo PEM_get_EVP_CIPHER_INFO
118.Fa "char *header"
119.Fa "EVP_CIPHER_INFO *cinfo"
120.Fc
121.Ft int
122.Fo PEM_do_header
123.Fa "EVP_CIPHER_INFO *cinfo"
124.Fa "unsigned char *data"
125.Fa "long *len"
126.Fa "pem_password_cb *cb"
127.Fa "void *userdata"
128.Fc
129.Ft int
130.Fo PEM_def_callback
131.Fa "char *password"
132.Fa "int size"
133.Fa "int verify"
134.Fa "void *userdata"
135.Fc
136.Ft typedef int
137.Fo pem_password_cb
138.Fa "char *password"
139.Fa "int size"
140.Fa "int verify"
141.Fa "void *userdata"
142.Fc
143.Sh DESCRIPTION
144These functions read and write PEM-encoded objects, using the PEM type
145.Fa name ,
146any additional
147.Fa header
148information, and the raw
149.Fa data
150of length
151.Fa len .
152.Pp
153PEM is the binary content encoding first defined in IETF RFC 1421.
154The content is a series of base64-encoded lines, surrounded by
155begin/end markers each on their own line.
156For example:
157.Bd -literal -offset indent
158-----BEGIN PRIVATE KEY-----
159MIICdg....
160\&... bhTQ==
161-----END PRIVATE KEY-----
162.Ed
163.Pp
164Optional header line(s) may appear after the begin line, and their
165existence depends on the type of object being written or read.
166.Pp
167.Fn PEM_write
168writes to the file
169.Fa fp ,
170while
171.Fn PEM_write_bio
172writes to the BIO
173.Fa bp .
174The
175.Fa name
176is the name to use in the marker, the
177.Fa header
178is the header value or
179.Dv NULL ,
180and
181.Fa data
182and
183.Fa len
184specify the data and its length.
185.Pp
186The final
187.Fa data
188buffer is typically an ASN.1 object which can be decoded with the
189.Fn d2i_*
190function appropriate to the type
191.Fa name ;
192see
193.Xr d2i_X509 3
194for examples.
195.Pp
196.Fn PEM_read
197reads from the file
198.Fa fp ,
199while
200.Fn PEM_read_bio
201reads from the BIO
202.Fa bp .
203Both skip any non-PEM data that precedes the start of the next PEM
204object.
205When an object is successfully retrieved, the type name from the
206"----BEGIN <type>-----" is returned via the
207.Fa name
208argument, any encapsulation headers are returned in
209.Fa header ,
210and the base64-decoded content and its length are returned via
211.Fa data
212and
213.Fa len ,
214respectively.
215The
216.Fa name ,
217.Fa header ,
218and
219.Fa data
220pointers should be freed by the caller when no longer needed.
221.Pp
222The remaining functions are deprecated because the underlying PEM
223encryption format is obsolete and should be avoided.
224It uses an encryption format with an OpenSSL-specific key-derivation
225function, which employs MD5 with an iteration count of 1.
226Instead, private keys should be stored in PKCS#8 form, with a strong
227PKCS#5 v2.0 PBE; see
228.Xr PEM_write_PrivateKey 3
229and
230.Xr d2i_PKCS8PrivateKey_bio 3 .
231.Pp
232.Fn PEM_get_EVP_CIPHER_INFO
233can be used to determine the
234.Fa data
235returned by
236.Fn PEM_read
237or
238.Fn PEM_read_bio
239is encrypted and to retrieve the associated cipher and IV.
240The caller passes a pointer to a structure of type
241.Vt EVP_CIPHER_INFO
242via the
243.Fa cinfo
244argument and the
245.Fa header
246returned via
247.Fn PEM_read
248or
249.Fn PEM_read_bio .
250If the call is successful, 1 is returned and the cipher and IV are
251stored at the address pointed to by
252.Fa cinfo .
253When the header is malformed or not supported or when the cipher is
254unknown or some internal error happens, 0 is returned.
255.Pp
256.Fn PEM_do_header
257can then be used to decrypt the data if the header indicates encryption.
258The
259.Fa cinfo
260argument is a pointer to the structure initialized by a preceding call
261to
262.Fn PEM_get_EVP_CIPHER_INFO .
263If that structure indicates the absence of encryption,
264.Fn PEM_do_header
265returns successfully without taking any action.
266The
267.Fa data
268and
269.Fa len
270arguments are used both to pass in the encrypted data that was
271returned in the same arguments from the preceding call to
272.Fn PEM_read
273or
274.Fn PEM_read_bio
275and to pass out the decrypted data.
276.Pp
277The callback function
278.Fa cb
279is used to obtain the encryption
280.Fa password ;
281if
282.Fa cb
283is
284.Dv NULL ,
285.Fn PEM_def_callback
286is used instead.
287The
288.Fa password
289buffer needs to be at least
290.Fa size
291bytes long.
292Unless
293.Fa userdata
294is
295.Dv NULL ,
296.Fn PEM_def_callback
297ignores the
298.Fa verify
299argument and copies the NUL-terminated byte string
300.Fa userdata
301to
302.Fa password
303without a terminating NUL byte, silently truncating the copy to at most
304.Fa size
305bytes.
306If
307.Fa userdata
308is
309.Dv NULL ,
310.Fn PEM_def_callback
311instead prompts the user for the password with echoing turned off
312by calling
313.Xr EVP_read_pw_string_min 3
314internally.
315In this case, the
316.Fa size
317is silently reduced to at most
318.Dv BUFSIZ
319and at most
320.Fa size No \- 1
321bytes are accepted from the user and copied into the byte string buffer
322.Fa password .
323A callback function
324.Fa cb
325supplied by the application may use
326.Fa userdata
327for a different purpose than
328.Fn PEM_def_callback
329does, e.g., as auxiliary data to use while acquiring the password.
330For example, a GUI application might pass a window handle.
331If the
332.Fa verify
333flag is non-zero, the user is prompted twice for the password to
334make typos less likely and it is checked that both inputs agree.
335This flag is not set by
336.Fn PEM_do_header
337nor by other read functions, but it is typically set by write functions.
338.Pp
339If the data is a priori known to not be encrypted, then neither
340.Fn PEM_get_EVP_CIPHER_INFO
341nor
342.Fn PEM_do_header
343need to be called.
344.Sh RETURN VALUES
345.Fn PEM_read
346and
347.Fn PEM_read_bio
348return 1 on success or 0 on failure.
349The latter includes the case when no more PEM objects remain in the
350input file.
351To distinguish end of file from more serious errors, the caller
352must peek at the error stack and check for
353.Dv PEM_R_NO_START_LINE ,
354which indicates that no more PEM objects were found.
355See
356.Xr ERR_peek_last_error 3
357and
358.Xr ERR_GET_REASON 3 .
359.Pp
360.Fn PEM_get_EVP_CIPHER_INFO
361and
362.Fn PEM_do_header
363return 1 on success or 0 on failure.
364The
365.Fa data
366is likely meaningless if these functions fail.
367.Pp
368.Fn PEM_def_callback
369returns the number of bytes stored into
370.Fa buf
371or a negative value on failure, and
372.Fa cb
373is expected to behave in the same way.
374If
375.Fa userdata
376is
377.Dv NULL ,
378.Fn PEM_def_callback
379fails if
380.Fa num
381is less than 5
382or if an error occurs trying to prompt the user for the password.
383Otherwise, it fails when
384.Fa num
385is negative.
386The details of the circumstances that cause
387.Fa cb
388to fail may differ.
389.Sh SEE ALSO
390.Xr crypto 3 ,
391.Xr d2i_PKCS8PrivateKey_bio 3 ,
392.Xr PEM_ASN1_read 3 ,
393.Xr PEM_bytes_read_bio 3 ,
394.Xr PEM_read_bio_PrivateKey 3 ,
395.Xr PEM_read_SSL_SESSION 3 ,
396.Xr PEM_write_bio_CMS_stream 3 ,
397.Xr PEM_write_bio_PKCS7_stream 3 ,
398.Xr PEM_X509_INFO_read 3
399.Sh HISTORY
400.Fn PEM_write ,
401.Fn PEM_read ,
402and
403.Fn PEM_do_header
404appeared in SSLeay 0.4 or earlier.
405.Fn PEM_get_EVP_CIPHER_INFO
406first appeared in SSLeay 0.5.1.
407.Fn PEM_write_bio
408and
409.Fn PEM_read_bio
410first appeared in SSLeay 0.6.0.
411These functions have been available since
412.Ox 2.4 .
413.Pp
414.Fn PEM_def_callback
415first appeared in OpenSSL 0.9.7 and has been available since
416.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 b/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
deleted file mode 100644
index 9f45261725..0000000000
--- a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
+++ /dev/null
@@ -1,1335 +0,0 @@
1.\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.23 2024/09/02 08:04:32 tb Exp $
2.\" full merge up to:
3.\" OpenSSL man3/PEM_read_bio_PrivateKey.pod 18bad535 Apr 9 15:13:55 2019 +0100
4.\" OpenSSL man3/PEM_read_CMS.pod 83cf7abf May 29 13:07:08 2018 +0100
5.\"
6.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
7.\" Copyright (c) 2001-2004, 2009, 2013-2016 The OpenSSL Project.
8.\" All rights reserved.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\"
14.\" 1. Redistributions of source code must retain the above copyright
15.\" notice, this list of conditions and the following disclaimer.
16.\"
17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\" notice, this list of conditions and the following disclaimer in
19.\" the documentation and/or other materials provided with the
20.\" distribution.
21.\"
22.\" 3. All advertising materials mentioning features or use of this
23.\" software must display the following acknowledgment:
24.\" "This product includes software developed by the OpenSSL Project
25.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
26.\"
27.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
28.\" endorse or promote products derived from this software without
29.\" prior written permission. For written permission, please contact
30.\" openssl-core@openssl.org.
31.\"
32.\" 5. Products derived from this software may not be called "OpenSSL"
33.\" nor may "OpenSSL" appear in their names without prior written
34.\" permission of the OpenSSL Project.
35.\"
36.\" 6. Redistributions of any form whatsoever must retain the following
37.\" acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
40.\"
41.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
42.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
45.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\"
54.Dd $Mdocdate: September 2 2024 $
55.Dt PEM_READ_BIO_PRIVATEKEY 3
56.Os
57.Sh NAME
58.Nm PEM_read_bio_PrivateKey ,
59.Nm PEM_read_PrivateKey ,
60.Nm PEM_write_bio_PrivateKey ,
61.Nm PEM_write_PrivateKey ,
62.Nm PEM_write_bio_PKCS8PrivateKey ,
63.Nm PEM_write_PKCS8PrivateKey ,
64.Nm PEM_write_bio_PKCS8PrivateKey_nid ,
65.Nm PEM_write_PKCS8PrivateKey_nid ,
66.Nm PEM_read_bio_PKCS8 ,
67.Nm PEM_read_PKCS8 ,
68.Nm PEM_write_bio_PKCS8 ,
69.Nm PEM_write_PKCS8 ,
70.Nm PEM_read_bio_PKCS8_PRIV_KEY_INFO ,
71.Nm PEM_read_PKCS8_PRIV_KEY_INFO ,
72.Nm PEM_write_bio_PKCS8_PRIV_KEY_INFO ,
73.Nm PEM_write_PKCS8_PRIV_KEY_INFO ,
74.Nm PEM_read_bio_PUBKEY ,
75.Nm PEM_read_PUBKEY ,
76.Nm PEM_write_bio_PUBKEY ,
77.Nm PEM_write_PUBKEY ,
78.Nm PEM_read_bio_RSAPrivateKey ,
79.Nm PEM_read_RSAPrivateKey ,
80.Nm PEM_write_bio_RSAPrivateKey ,
81.Nm PEM_write_RSAPrivateKey ,
82.Nm PEM_read_bio_RSAPublicKey ,
83.Nm PEM_read_RSAPublicKey ,
84.Nm PEM_write_bio_RSAPublicKey ,
85.Nm PEM_write_RSAPublicKey ,
86.Nm PEM_read_bio_RSA_PUBKEY ,
87.Nm PEM_read_RSA_PUBKEY ,
88.Nm PEM_write_bio_RSA_PUBKEY ,
89.Nm PEM_write_RSA_PUBKEY ,
90.Nm PEM_read_bio_DSAPrivateKey ,
91.Nm PEM_read_DSAPrivateKey ,
92.Nm PEM_write_bio_DSAPrivateKey ,
93.Nm PEM_write_DSAPrivateKey ,
94.Nm PEM_read_bio_DSA_PUBKEY ,
95.Nm PEM_read_DSA_PUBKEY ,
96.Nm PEM_write_bio_DSA_PUBKEY ,
97.Nm PEM_write_DSA_PUBKEY ,
98.Nm PEM_read_bio_DSAparams ,
99.Nm PEM_read_DSAparams ,
100.Nm PEM_write_bio_DSAparams ,
101.Nm PEM_write_DSAparams ,
102.Nm PEM_read_bio_DHparams ,
103.Nm PEM_read_DHparams ,
104.Nm PEM_write_bio_DHparams ,
105.Nm PEM_write_DHparams ,
106.Nm PEM_read_bio_ECPKParameters ,
107.Nm PEM_read_ECPKParameters ,
108.Nm PEM_write_bio_ECPKParameters ,
109.Nm PEM_write_ECPKParameters ,
110.Nm PEM_read_bio_ECPrivateKey ,
111.Nm PEM_read_ECPrivateKey ,
112.Nm PEM_write_bio_ECPrivateKey ,
113.Nm PEM_write_ECPrivateKey ,
114.Nm PEM_read_bio_EC_PUBKEY ,
115.Nm PEM_read_EC_PUBKEY ,
116.Nm PEM_write_bio_EC_PUBKEY ,
117.Nm PEM_write_EC_PUBKEY ,
118.Nm PEM_read_bio_X509 ,
119.Nm PEM_read_X509 ,
120.Nm PEM_write_bio_X509 ,
121.Nm PEM_write_X509 ,
122.Nm PEM_read_bio_X509_AUX ,
123.Nm PEM_read_X509_AUX ,
124.Nm PEM_write_bio_X509_AUX ,
125.Nm PEM_write_X509_AUX ,
126.Nm PEM_read_bio_X509_REQ ,
127.Nm PEM_read_X509_REQ ,
128.Nm PEM_write_bio_X509_REQ ,
129.Nm PEM_write_X509_REQ ,
130.Nm PEM_write_bio_X509_REQ_NEW ,
131.Nm PEM_write_X509_REQ_NEW ,
132.Nm PEM_read_bio_X509_CRL ,
133.Nm PEM_read_X509_CRL ,
134.Nm PEM_write_bio_X509_CRL ,
135.Nm PEM_write_X509_CRL ,
136.Nm PEM_read_bio_PKCS7 ,
137.Nm PEM_read_PKCS7 ,
138.Nm PEM_write_bio_PKCS7 ,
139.Nm PEM_write_PKCS7 ,
140.Nm PEM_read_CMS ,
141.Nm PEM_read_bio_CMS ,
142.Nm PEM_write_CMS ,
143.Nm PEM_write_bio_CMS
144.Nd PEM routines
145.Sh SYNOPSIS
146.In openssl/pem.h
147.Ft EVP_PKEY *
148.Fo PEM_read_bio_PrivateKey
149.Fa "BIO *bp"
150.Fa "EVP_PKEY **x"
151.Fa "pem_password_cb *cb"
152.Fa "void *u"
153.Fc
154.Ft EVP_PKEY *
155.Fo PEM_read_PrivateKey
156.Fa "FILE *fp"
157.Fa "EVP_PKEY **x"
158.Fa "pem_password_cb *cb"
159.Fa "void *u"
160.Fc
161.Ft int
162.Fo PEM_write_bio_PrivateKey
163.Fa "BIO *bp"
164.Fa "EVP_PKEY *x"
165.Fa "const EVP_CIPHER *enc"
166.Fa "unsigned char *kstr"
167.Fa "int klen"
168.Fa "pem_password_cb *cb"
169.Fa "void *u"
170.Fc
171.Ft int
172.Fo PEM_write_PrivateKey
173.Fa "FILE *fp"
174.Fa "EVP_PKEY *x"
175.Fa "const EVP_CIPHER *enc"
176.Fa "unsigned char *kstr"
177.Fa "int klen"
178.Fa "pem_password_cb *cb"
179.Fa "void *u"
180.Fc
181.Ft int
182.Fo PEM_write_bio_PKCS8PrivateKey
183.Fa "BIO *bp"
184.Fa "EVP_PKEY *x"
185.Fa "const EVP_CIPHER *enc"
186.Fa "char *kstr"
187.Fa "int klen"
188.Fa "pem_password_cb *cb"
189.Fa "void *u"
190.Fc
191.Ft int
192.Fo PEM_write_PKCS8PrivateKey
193.Fa "FILE *fp"
194.Fa "EVP_PKEY *x"
195.Fa "const EVP_CIPHER *enc"
196.Fa "char *kstr"
197.Fa "int klen"
198.Fa "pem_password_cb *cb"
199.Fa "void *u"
200.Fc
201.Ft int
202.Fo PEM_write_bio_PKCS8PrivateKey_nid
203.Fa "BIO *bp"
204.Fa "EVP_PKEY *x"
205.Fa "int nid"
206.Fa "char *kstr"
207.Fa "int klen"
208.Fa "pem_password_cb *cb"
209.Fa "void *u"
210.Fc
211.Ft int
212.Fo PEM_write_PKCS8PrivateKey_nid
213.Fa "FILE *fp"
214.Fa "EVP_PKEY *x"
215.Fa "int nid"
216.Fa "char *kstr"
217.Fa "int klen"
218.Fa "pem_password_cb *cb"
219.Fa "void *u"
220.Fc
221.Ft X509_SIG *
222.Fo PEM_read_bio_PKCS8
223.Fa "BIO *bp"
224.Fa "X509_SIG **x"
225.Fa "pem_password_cb *cb"
226.Fa "void *u"
227.Fc
228.Ft X509_SIG *
229.Fo PEM_read_PKCS8
230.Fa "FILE *fp"
231.Fa "X509_SIG **x"
232.Fa "pem_password_cb *cb"
233.Fa "void *u"
234.Fc
235.Ft int
236.Fo PEM_write_bio_PKCS8
237.Fa "BIO *bp"
238.Fa "X509_SIG *x"
239.Fc
240.Ft int
241.Fo PEM_write_PKCS8
242.Fa "FILE *fp"
243.Fa "X509_SIG *x"
244.Fc
245.Ft PKCS8_PRIV_KEY_INFO *
246.Fo PEM_read_bio_PKCS8_PRIV_KEY_INFO
247.Fa "BIO *bp"
248.Fa "PKCS8_PRIV_KEY_INFO **x"
249.Fa "pem_password_cb *cb"
250.Fa "void *u"
251.Fc
252.Ft PKCS8_PRIV_KEY_INFO *
253.Fo PEM_read_PKCS8_PRIV_KEY_INFO
254.Fa "FILE *fp"
255.Fa "PKCS8_PRIV_KEY_INFO **x"
256.Fa "pem_password_cb *cb"
257.Fa "void *u"
258.Fc
259.Ft int
260.Fo PEM_write_bio_PKCS8_PRIV_KEY_INFO
261.Fa "BIO *bp"
262.Fa "PKCS8_PRIV_KEY_INFO *x"
263.Fc
264.Ft int
265.Fo PEM_write_PKCS8_PRIV_KEY_INFO
266.Fa "FILE *fp"
267.Fa "PKCS8_PRIV_KEY_INFO *x"
268.Fc
269.Ft EVP_PKEY *
270.Fo PEM_read_bio_PUBKEY
271.Fa "BIO *bp"
272.Fa "EVP_PKEY **x"
273.Fa "pem_password_cb *cb"
274.Fa "void *u"
275.Fc
276.Ft EVP_PKEY *
277.Fo PEM_read_PUBKEY
278.Fa "FILE *fp"
279.Fa "EVP_PKEY **x"
280.Fa "pem_password_cb *cb"
281.Fa "void *u"
282.Fc
283.Ft int
284.Fo PEM_write_bio_PUBKEY
285.Fa "BIO *bp"
286.Fa "EVP_PKEY *x"
287.Fc
288.Ft int
289.Fo PEM_write_PUBKEY
290.Fa "FILE *fp"
291.Fa "EVP_PKEY *x"
292.Fc
293.Ft RSA *
294.Fo PEM_read_bio_RSAPrivateKey
295.Fa "BIO *bp"
296.Fa "RSA **x"
297.Fa "pem_password_cb *cb"
298.Fa "void *u"
299.Fc
300.Ft RSA *
301.Fo PEM_read_RSAPrivateKey
302.Fa "FILE *fp"
303.Fa "RSA **x"
304.Fa "pem_password_cb *cb"
305.Fa "void *u"
306.Fc
307.Ft int
308.Fo PEM_write_bio_RSAPrivateKey
309.Fa "BIO *bp"
310.Fa "RSA *x"
311.Fa "const EVP_CIPHER *enc"
312.Fa "unsigned char *kstr"
313.Fa "int klen"
314.Fa "pem_password_cb *cb"
315.Fa "void *u"
316.Fc
317.Ft int
318.Fo PEM_write_RSAPrivateKey
319.Fa "FILE *fp"
320.Fa "RSA *x"
321.Fa "const EVP_CIPHER *enc"
322.Fa "unsigned char *kstr"
323.Fa "int klen"
324.Fa "pem_password_cb *cb"
325.Fa "void *u"
326.Fc
327.Ft RSA *
328.Fo PEM_read_bio_RSAPublicKey
329.Fa "BIO *bp"
330.Fa "RSA **x"
331.Fa "pem_password_cb *cb"
332.Fa "void *u"
333.Fc
334.Ft RSA *
335.Fo PEM_read_RSAPublicKey
336.Fa "FILE *fp"
337.Fa "RSA **x"
338.Fa "pem_password_cb *cb"
339.Fa "void *u"
340.Fc
341.Ft int
342.Fo PEM_write_bio_RSAPublicKey
343.Fa "BIO *bp"
344.Fa "RSA *x"
345.Fc
346.Ft int
347.Fo PEM_write_RSAPublicKey
348.Fa "FILE *fp"
349.Fa "RSA *x"
350.Fc
351.Ft RSA *
352.Fo PEM_read_bio_RSA_PUBKEY
353.Fa "BIO *bp"
354.Fa "RSA **x"
355.Fa "pem_password_cb *cb"
356.Fa "void *u"
357.Fc
358.Ft RSA *
359.Fo PEM_read_RSA_PUBKEY
360.Fa "FILE *fp"
361.Fa "RSA **x"
362.Fa "pem_password_cb *cb"
363.Fa "void *u"
364.Fc
365.Ft int
366.Fo PEM_write_bio_RSA_PUBKEY
367.Fa "BIO *bp"
368.Fa "RSA *x"
369.Fc
370.Ft int
371.Fo PEM_write_RSA_PUBKEY
372.Fa "FILE *fp"
373.Fa "RSA *x"
374.Fc
375.Ft DSA *
376.Fo PEM_read_bio_DSAPrivateKey
377.Fa "BIO *bp"
378.Fa "DSA **x"
379.Fa "pem_password_cb *cb"
380.Fa "void *u"
381.Fc
382.Ft DSA *
383.Fo PEM_read_DSAPrivateKey
384.Fa "FILE *fp"
385.Fa "DSA **x"
386.Fa "pem_password_cb *cb"
387.Fa "void *u"
388.Fc
389.Ft int
390.Fo PEM_write_bio_DSAPrivateKey
391.Fa "BIO *bp"
392.Fa "DSA *x"
393.Fa "const EVP_CIPHER *enc"
394.Fa "unsigned char *kstr"
395.Fa "int klen"
396.Fa "pem_password_cb *cb"
397.Fa "void *u"
398.Fc
399.Ft int
400.Fo PEM_write_DSAPrivateKey
401.Fa "FILE *fp"
402.Fa "DSA *x"
403.Fa "const EVP_CIPHER *enc"
404.Fa "unsigned char *kstr"
405.Fa "int klen"
406.Fa "pem_password_cb *cb"
407.Fa "void *u"
408.Fc
409.Ft DSA *
410.Fo PEM_read_bio_DSA_PUBKEY
411.Fa "BIO *bp"
412.Fa "DSA **x"
413.Fa "pem_password_cb *cb"
414.Fa "void *u"
415.Fc
416.Ft DSA *
417.Fo PEM_read_DSA_PUBKEY
418.Fa "FILE *fp"
419.Fa "DSA **x"
420.Fa "pem_password_cb *cb"
421.Fa "void *u"
422.Fc
423.Ft int
424.Fo PEM_write_bio_DSA_PUBKEY
425.Fa "BIO *bp"
426.Fa "DSA *x"
427.Fc
428.Ft int
429.Fo PEM_write_DSA_PUBKEY
430.Fa "FILE *fp"
431.Fa "DSA *x"
432.Fc
433.Ft DSA *
434.Fo PEM_read_bio_DSAparams
435.Fa "BIO *bp"
436.Fa "DSA **x"
437.Fa "pem_password_cb *cb"
438.Fa "void *u"
439.Fc
440.Ft DSA *
441.Fo PEM_read_DSAparams
442.Fa "FILE *fp"
443.Fa "DSA **x"
444.Fa "pem_password_cb *cb"
445.Fa "void *u"
446.Fc
447.Ft int
448.Fo PEM_write_bio_DSAparams
449.Fa "BIO *bp"
450.Fa "DSA *x"
451.Fc
452.Ft int
453.Fo PEM_write_DSAparams
454.Fa "FILE *fp"
455.Fa "DSA *x"
456.Fc
457.Ft DH *
458.Fo PEM_read_bio_DHparams
459.Fa "BIO *bp"
460.Fa "DH **x"
461.Fa "pem_password_cb *cb"
462.Fa "void *u"
463.Fc
464.Ft DH *
465.Fo PEM_read_DHparams
466.Fa "FILE *fp"
467.Fa "DH **x"
468.Fa "pem_password_cb *cb"
469.Fa "void *u"
470.Fc
471.Ft int
472.Fo PEM_write_bio_DHparams
473.Fa "BIO *bp"
474.Fa "DH *x"
475.Fc
476.Ft int
477.Fo PEM_write_DHparams
478.Fa "FILE *fp"
479.Fa "DH *x"
480.Fc
481.Ft EC_GROUP *
482.Fo PEM_read_bio_ECPKParameters
483.Fa "BIO *bp"
484.Fa "EC_GROUP **x"
485.Fa "pem_password_cb *cb"
486.Fa "void *u"
487.Fc
488.Ft EC_GROUP *
489.Fo PEM_read_ECPKParameters
490.Fa "FILE *fp"
491.Fa "EC_GROUP **x"
492.Fa "pem_password_cb *cb"
493.Fa "void *u"
494.Fc
495.Ft int
496.Fo PEM_write_bio_ECPKParameters
497.Fa "BIO *bp"
498.Fa "const EC_GROUP *x"
499.Fc
500.Ft int
501.Fo PEM_write_ECPKParameters
502.Fa "FILE *fp"
503.Fa "const EC_GROUP *x"
504.Fc
505.Ft EC_KEY *
506.Fo PEM_read_bio_ECPrivateKey
507.Fa "BIO *bp"
508.Fa "EC_KEY **key"
509.Fa "pem_password_cb *cb"
510.Fa "void *u"
511.Fc
512.Ft EC_KEY *
513.Fo PEM_read_ECPrivateKey
514.Fa "FILE *fp"
515.Fa "EC_KEY **eckey"
516.Fa "pem_password_cb *cb"
517.Fa "void *u"
518.Fc
519.Ft int
520.Fo PEM_write_bio_ECPrivateKey
521.Fa "BIO *bp"
522.Fa "EC_KEY *x"
523.Fa "const EVP_CIPHER *enc"
524.Fa "unsigned char *kstr"
525.Fa "int klen"
526.Fa "pem_password_cb *cb"
527.Fa "void *u"
528.Fc
529.Ft int
530.Fo PEM_write_ECPrivateKey
531.Fa "FILE *fp"
532.Fa "EC_KEY *x"
533.Fa "const EVP_CIPHER *enc"
534.Fa "unsigned char *kstr"
535.Fa "int klen"
536.Fa "pem_password_cb *cb"
537.Fa "void *u"
538.Fc
539.Ft EC_KEY *
540.Fo PEM_read_bio_EC_PUBKEY
541.Fa "BIO *bp"
542.Fa "EC_KEY **x"
543.Fa "pem_password_cb *cb"
544.Fa "void *u"
545.Fc
546.Ft EC_KEY *
547.Fo PEM_read_EC_PUBKEY
548.Fa "FILE *fp"
549.Fa "EC_KEY **x"
550.Fa "pem_password_cb *cb"
551.Fa "void *u"
552.Fc
553.Ft int
554.Fo PEM_write_bio_EC_PUBKEY
555.Fa "BIO *bp"
556.Fa "EC_KEY *x"
557.Fc
558.Ft int
559.Fo PEM_write_EC_PUBKEY
560.Fa "FILE *fp"
561.Fa "EC_KEY *x"
562.Fc
563.Ft X509 *
564.Fo PEM_read_bio_X509
565.Fa "BIO *bp"
566.Fa "X509 **x"
567.Fa "pem_password_cb *cb"
568.Fa "void *u"
569.Fc
570.Ft X509 *
571.Fo PEM_read_X509
572.Fa "FILE *fp"
573.Fa "X509 **x"
574.Fa "pem_password_cb *cb"
575.Fa "void *u"
576.Fc
577.Ft int
578.Fo PEM_write_bio_X509
579.Fa "BIO *bp"
580.Fa "X509 *x"
581.Fc
582.Ft int
583.Fo PEM_write_X509
584.Fa "FILE *fp"
585.Fa "X509 *x"
586.Fc
587.Ft X509 *
588.Fo PEM_read_bio_X509_AUX
589.Fa "BIO *bp"
590.Fa "X509 **x"
591.Fa "pem_password_cb *cb"
592.Fa "void *u"
593.Fc
594.Ft X509 *
595.Fo PEM_read_X509_AUX
596.Fa "FILE *fp"
597.Fa "X509 **x"
598.Fa "pem_password_cb *cb"
599.Fa "void *u"
600.Fc
601.Ft int
602.Fo PEM_write_bio_X509_AUX
603.Fa "BIO *bp"
604.Fa "X509 *x"
605.Fc
606.Ft int
607.Fo PEM_write_X509_AUX
608.Fa "FILE *fp"
609.Fa "X509 *x"
610.Fc
611.Ft X509_REQ *
612.Fo PEM_read_bio_X509_REQ
613.Fa "BIO *bp"
614.Fa "X509_REQ **x"
615.Fa "pem_password_cb *cb"
616.Fa "void *u"
617.Fc
618.Ft X509_REQ *
619.Fo PEM_read_X509_REQ
620.Fa "FILE *fp"
621.Fa "X509_REQ **x"
622.Fa "pem_password_cb *cb"
623.Fa "void *u"
624.Fc
625.Ft int
626.Fo PEM_write_bio_X509_REQ
627.Fa "BIO *bp"
628.Fa "X509_REQ *x"
629.Fc
630.Ft int
631.Fo PEM_write_X509_REQ
632.Fa "FILE *fp"
633.Fa "X509_REQ *x"
634.Fc
635.Ft int
636.Fo PEM_write_bio_X509_REQ_NEW
637.Fa "BIO *bp"
638.Fa "X509_REQ *x"
639.Fc
640.Ft int
641.Fo PEM_write_X509_REQ_NEW
642.Fa "FILE *fp"
643.Fa "X509_REQ *x"
644.Fc
645.Ft X509_CRL *
646.Fo PEM_read_bio_X509_CRL
647.Fa "BIO *bp"
648.Fa "X509_CRL **x"
649.Fa "pem_password_cb *cb"
650.Fa "void *u"
651.Fc
652.Ft X509_CRL *
653.Fo PEM_read_X509_CRL
654.Fa "FILE *fp"
655.Fa "X509_CRL **x"
656.Fa "pem_password_cb *cb"
657.Fa "void *u"
658.Fc
659.Ft int
660.Fo PEM_write_bio_X509_CRL
661.Fa "BIO *bp"
662.Fa "X509_CRL *x"
663.Fc
664.Ft int
665.Fo PEM_write_X509_CRL
666.Fa "FILE *fp"
667.Fa "X509_CRL *x"
668.Fc
669.Ft PKCS7 *
670.Fo PEM_read_bio_PKCS7
671.Fa "BIO *bp"
672.Fa "PKCS7 **x"
673.Fa "pem_password_cb *cb"
674.Fa "void *u"
675.Fc
676.Ft PKCS7 *
677.Fo PEM_read_PKCS7
678.Fa "FILE *fp"
679.Fa "PKCS7 **x"
680.Fa "pem_password_cb *cb"
681.Fa "void *u"
682.Fc
683.Ft int
684.Fo PEM_write_bio_PKCS7
685.Fa "BIO *bp"
686.Fa "PKCS7 *x"
687.Fc
688.Ft int
689.Fo PEM_write_PKCS7
690.Fa "FILE *fp"
691.Fa "PKCS7 *x"
692.Fc
693.In openssl/cms.h
694.Ft CMS_ContentInfo *
695.Fo PEM_read_CMS
696.Fa "FILE *fp"
697.Fa "CMS_ContentInfo **x"
698.Fa "pem_password_cb *cb"
699.Fa "void *u"
700.Fc
701.Ft CMS_ContentInfo *
702.Fo PEM_read_bio_CMS
703.Fa "BIO *bp"
704.Fa "CMS_ContentInfo **x"
705.Fa "pem_password_cb *cb"
706.Fa "void *u"
707.Fc
708.Ft int
709.Fo PEM_write_CMS
710.Fa "FILE *fp"
711.Fa "const CMS_ContentInfo *x"
712.Fc
713.Ft int
714.Fo PEM_write_bio_CMS
715.Fa "BIO *bp"
716.Fa "const CMS_ContentInfo *x"
717.Fc
718.Sh DESCRIPTION
719The PEM functions read or write structures in PEM format.
720In this sense PEM format is simply base64-encoded data surrounded by
721header lines; see
722.Xr PEM_read 3
723for more details.
724.Pp
725For more details about the meaning of arguments see the
726.Sx PEM function arguments
727section.
728.Pp
729Each operation has four functions associated with it.
730For brevity the term
731.Dq Ar TYPE No functions
732will be used to collectively refer to the
733.Fn PEM_read_bio_TYPE ,
734.Fn PEM_read_TYPE ,
735.Fn PEM_write_bio_TYPE ,
736and
737.Fn PEM_write_TYPE
738functions.
739If no set of specific functions exists for a given type,
740.Xr PEM_ASN1_read 3
741can be used instead.
742.Pp
743The
744.Sy PrivateKey
745functions read or write a private key in PEM format using an
746.Vt EVP_PKEY
747structure.
748The write routines use "traditional" private key format and can handle
749both RSA and DSA private keys.
750The read functions can additionally transparently handle PKCS#8 format
751encrypted and unencrypted keys too.
752.Pp
753.Fn PEM_write_bio_PKCS8PrivateKey
754and
755.Fn PEM_write_PKCS8PrivateKey
756write a private key in an
757.Vt EVP_PKEY
758structure in PKCS#8
759.Vt EncryptedPrivateKeyInfo
760format using PKCS#5 v2.0 password based encryption algorithms.
761The
762.Fa enc
763argument specifies the encryption algorithm to use: unlike all other PEM
764routines, the encryption is applied at the PKCS#8 level and not in the
765PEM headers.
766If
767.Fa enc
768is
769.Dv NULL ,
770then no encryption is used and a PKCS#8
771.Vt PrivateKeyInfo
772structure is used instead.
773.Pp
774.Fn PEM_write_bio_PKCS8PrivateKey_nid
775and
776.Fn PEM_write_PKCS8PrivateKey_nid
777also write out a private key as a PKCS#8
778.Vt EncryptedPrivateKeyInfo .
779However they use PKCS#5 v1.5 or PKCS#12 encryption algorithms instead.
780The algorithm to use is specified in the
781.Fa nid
782parameter and should be the NID of the corresponding OBJECT IDENTIFIER.
783.Pp
784The
785.Sy PKCS8
786functions process an encrypted private key using an
787.Vt X509_SIG
788structure and the
789.Xr d2i_X509_SIG 3
790function.
791.Pp
792The
793.Sy PKCS8_PRIV_KEY_INFO
794functions process a private key using a
795.Vt PKCS8_PRIV_KEY_INFO
796structure.
797.Pp
798The
799.Sy PUBKEY
800functions process a public key using an
801.Vt EVP_PKEY
802structure.
803The public key is encoded as an ASN.1
804.Vt SubjectPublicKeyInfo
805structure.
806.Pp
807The
808.Sy RSAPrivateKey
809functions process an RSA private key using an
810.Vt RSA
811structure.
812They handle the same formats as the
813.Sy PrivateKey
814functions, but an error occurs if the private key is not RSA.
815.Pp
816The
817.Sy RSAPublicKey
818functions process an RSA public key using an
819.Vt RSA
820structure.
821The public key is encoded using a PKCS#1
822.Vt RSAPublicKey
823structure.
824.Pp
825The
826.Sy RSA_PUBKEY
827functions also process an RSA public key using an
828.Vt RSA
829structure.
830However the public key is encoded using an ASN.1
831.Vt SubjectPublicKeyInfo
832structure and an error occurs if the public key is not RSA.
833.Pp
834The
835.Sy DSAPrivateKey
836functions process a DSA private key using a
837.Vt DSA
838structure.
839They handle the same formats as the
840.Sy PrivateKey
841functions but an error occurs if the private key is not DSA.
842.Pp
843The
844.Sy DSA_PUBKEY
845functions process a DSA public key using a
846.Vt DSA
847structure.
848The public key is encoded using an ASN.1
849.Vt SubjectPublicKeyInfo
850structure and an error occurs if the public key is not DSA.
851.Pp
852The
853.Sy DSAparams
854functions process DSA parameters using a
855.Vt DSA
856structure.
857The parameters are encoded using a Dss-Parms structure as defined in RFC 2459.
858.Pp
859The
860.Sy DHparams
861functions process DH parameters using a
862.Vt DH
863structure.
864The parameters are encoded using a PKCS#3 DHparameter structure.
865.Pp
866The
867.Sy ECPKParameters
868functions process EC parameters using an
869.Vt EC_GROUP
870structure and the
871.Xr d2i_ECPKParameters 3
872function.
873.Pp
874The
875.Sy ECPrivateKey
876functions process an EC private key using an
877.Vt EC_KEY
878structure.
879.Pp
880The
881.Sy EC_PUBKEY
882functions process an EC public key using an
883.Vt EC_KEY
884structure.
885.Pp
886The
887.Sy X509
888functions process an X509 certificate using an
889.Vt X509
890structure.
891They will also process a trusted X509 certificate but any trust settings
892are discarded.
893.Pp
894The
895.Sy X509_AUX
896functions process a trusted X509 certificate using an
897.Vt X509
898structure.
899.Pp
900The
901.Sy X509_REQ
902and
903.Sy X509_REQ_NEW
904functions process a PKCS#10 certificate request using an
905.Vt X509_REQ
906structure.
907The
908.Sy X509_REQ
909write functions use CERTIFICATE REQUEST in the header whereas the
910.Sy X509_REQ_NEW
911functions use NEW CERTIFICATE REQUEST (as required by some CAs).
912The
913.Sy X509_REQ
914read functions will handle either form so there are no
915.Sy X509_REQ_NEW
916read functions.
917.Pp
918The
919.Sy X509_CRL
920functions process an X509 CRL using an
921.Vt X509_CRL
922structure.
923.Pp
924The
925.Sy PKCS7
926functions process a PKCS#7
927.Vt ContentInfo
928using a
929.Vt PKCS7
930structure.
931.Pp
932The
933.Sy CMS
934functions process a
935.Vt CMS_ContentInfo
936structure.
937.Pp
938The old
939.Sy PrivateKey
940write routines are retained for compatibility.
941New applications should write private keys using the
942.Fn PEM_write_bio_PKCS8PrivateKey
943or
944.Fn PEM_write_PKCS8PrivateKey
945routines because they are more secure (they use an iteration count of
9462048 whereas the traditional routines use a count of 1) unless
947compatibility with older versions of OpenSSL is important.
948.Pp
949The
950.Sy PrivateKey
951read routines can be used in all applications because they handle all
952formats transparently.
953.Ss PEM function arguments
954The PEM functions have many common arguments.
955.Pp
956The
957.Fa bp
958parameter specifies the
959.Vt BIO
960to read from or write to.
961.Pp
962The
963.Fa fp
964parameter specifies the
965.Vt FILE
966pointer to read from or write to.
967.Pp
968The PEM read functions all take a pointer to pointer argument
969.Fa x
970and return a pointer of the same type.
971If
972.Fa x
973is
974.Dv NULL ,
975then the parameter is ignored.
976If
977.Fa x
978is not
979.Dv NULL
980but
981.Pf * Fa x
982is
983.Dv NULL ,
984then the structure returned will be written to
985.Pf * Fa x .
986If neither
987.Fa x
988nor
989.Pf * Fa x
990are
991.Dv NULL ,
992then an attempt is made to reuse the structure at
993.Pf * Fa x ,
994but see the
995.Sx BUGS
996and
997.Sx EXAMPLES
998sections.
999Irrespective of the value of
1000.Fa x ,
1001a pointer to the structure is always returned, or
1002.Dv NULL
1003if an error occurred.
1004.Pp
1005The PEM functions which write private keys take an
1006.Fa enc
1007parameter, which specifies the encryption algorithm to use.
1008Encryption is done at the PEM level.
1009If this parameter is set to
1010.Dv NULL ,
1011then the private key is written in unencrypted form.
1012.Pp
1013The optional arguments
1014.Fa u
1015and
1016.Fa cb
1017are a passphrase used for encrypting a PEM structure
1018or a callback to obtain the passphrase; see
1019.Xr pem_password_cb 3
1020for details.
1021.Pp
1022For the PEM write routines, if the
1023.Fa kstr
1024parameter is not
1025.Dv NULL ,
1026then
1027.Fa klen
1028bytes at
1029.Fa kstr
1030are used as the passphrase and
1031.Fa cb
1032is ignored.
1033.Ss PEM encryption format
1034These old
1035.Sy PrivateKey
1036routines use a non-standard technique for encryption.
1037.Pp
1038The private key (or other data) takes the following form:
1039.Bd -literal -offset indent
1040-----BEGIN RSA PRIVATE KEY-----
1041Proc-Type: 4,ENCRYPTED
1042DEK-Info: DES-EDE3-CBC,3F17F5316E2BAC89
1043
1044\&...base64 encoded data...
1045-----END RSA PRIVATE KEY-----
1046.Ed
1047.Pp
1048The line beginning with
1049.Dq DEK-Info
1050contains two comma separated pieces of information:
1051the encryption algorithm name as used by
1052.Xr EVP_get_cipherbyname 3
1053and an 8-byte salt encoded as a set of hexadecimal digits.
1054.Pp
1055After this is the base64-encoded encrypted data.
1056.Pp
1057The encryption key is determined using
1058.Xr EVP_BytesToKey 3 ,
1059using the salt and an iteration count of 1.
1060The IV used is the value of the salt and *not* the IV returned by
1061.Xr EVP_BytesToKey 3 .
1062.Sh RETURN VALUES
1063The read routines return either a pointer to the structure read or
1064.Dv NULL
1065if an error occurred.
1066.Pp
1067The write routines return 1 for success or 0 for failure.
1068.Sh EXAMPLES
1069Although the PEM routines take several arguments, in almost all
1070applications most of them are set to 0 or
1071.Dv NULL .
1072.Pp
1073Read a certificate in PEM format from a
1074.Vt BIO :
1075.Bd -literal -offset indent
1076X509 *x;
1077x = PEM_read_bio_X509(bp, NULL, 0, NULL);
1078if (x == NULL) {
1079 /* Error */
1080}
1081.Ed
1082.Pp
1083Alternative method:
1084.Bd -literal -offset indent
1085X509 *x = NULL;
1086if (!PEM_read_bio_X509(bp, &x, 0, NULL)) {
1087 /* Error */
1088}
1089.Ed
1090.Pp
1091Write a certificate to a
1092.Vt BIO :
1093.Bd -literal -offset indent
1094if (!PEM_write_bio_X509(bp, x)) {
1095 /* Error */
1096}
1097.Ed
1098.Pp
1099Write an unencrypted private key to a
1100.Vt FILE :
1101.Bd -literal -offset indent
1102if (!PEM_write_PrivateKey(fp, key, NULL, NULL, 0, 0, NULL)) {
1103 /* Error */
1104}
1105.Ed
1106.Pp
1107Write a private key (using traditional format) to a
1108.Vt BIO
1109using triple DES encryption; the pass phrase is prompted for:
1110.Bd -literal -offset indent
1111if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(),
1112 NULL, 0, 0, NULL)) {
1113 /* Error */
1114}
1115.Ed
1116.Pp
1117Write a private key (using PKCS#8 format) to a
1118.Vt BIO
1119using triple DES encryption, using the pass phrase "hello":
1120.Bd -literal -offset indent
1121if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(),
1122 NULL, 0, 0, "hello")) {
1123 /* Error */
1124}
1125.Ed
1126.Pp
1127Read a private key from a
1128.Vt BIO
1129using the pass phrase "hello":
1130.Bd -literal -offset indent
1131key = PEM_read_bio_PrivateKey(bp, NULL, 0, "hello");
1132if (key == NULL) {
1133 /* Error */
1134}
1135.Ed
1136.Pp
1137Read a private key from a
1138.Vt BIO
1139using a pass phrase callback:
1140.Bd -literal -offset indent
1141key = PEM_read_bio_PrivateKey(bp, NULL, pass_cb, "My Private Key");
1142if (key == NULL) {
1143 /* Error */
1144}
1145.Ed
1146.Pp
1147Skeleton pass phrase callback:
1148.Bd -literal -offset indent
1149int
1150pass_cb(char *buf, int size, int rwflag, void *u)
1151{
1152 char *tmp;
1153 size_t len;
1154
1155 /* We'd probably do something else if 'rwflag' is 1 */
1156 printf("Enter pass phrase for \e"%s\e"\en", u);
1157
1158 /*
1159 * Instead of the following line, get the passphrase
1160 * from the user in some way.
1161 */
1162 tmp = "hello";
1163 if (tmp == NULL) /* An error occurred. */
1164 return -1;
1165
1166 len = strlen(tmp);
1167 if (len == 0) /* Treat an empty passphrase as an error, too. */
1168 return -1;
1169
1170 /* if too long, truncate */
1171 if (len > size)
1172 len = size;
1173 memcpy(buf, tmp, len);
1174 return len;
1175}
1176.Ed
1177.Sh SEE ALSO
1178.Xr BIO_new 3 ,
1179.Xr DSA_new 3 ,
1180.Xr PEM_ASN1_read 3 ,
1181.Xr PEM_bytes_read_bio 3 ,
1182.Xr PEM_read 3 ,
1183.Xr PEM_read_SSL_SESSION 3 ,
1184.Xr PEM_write_bio_CMS_stream 3 ,
1185.Xr PEM_write_bio_PKCS7_stream 3 ,
1186.Xr PEM_X509_INFO_read 3 ,
1187.Xr RSA_new 3 ,
1188.Xr X509_CRL_new 3 ,
1189.Xr X509_REQ_new 3 ,
1190.Xr X509_SIG_new 3
1191.Sh HISTORY
1192.Fn PEM_read_X509
1193and
1194.Fn PEM_write_X509
1195appeared in SSLeay 0.4 or earlier.
1196.Fn PEM_read_X509_REQ ,
1197.Fn PEM_write_X509_REQ ,
1198.Fn PEM_read_X509_CRL ,
1199and
1200.Fn PEM_write_X509_CRL
1201first appeared in SSLeay 0.4.4.
1202.Fn PEM_read_RSAPrivateKey ,
1203.Fn PEM_write_RSAPrivateKey ,
1204.Fn PEM_read_DHparams ,
1205.Fn PEM_write_DHparams ,
1206.Fn PEM_read_PKCS7 ,
1207and
1208.Fn PEM_write_PKCS7
1209first appeared in SSLeay 0.5.1.
1210.Fn PEM_read_bio_PrivateKey ,
1211.Fn PEM_read_PrivateKey ,
1212.Fn PEM_read_bio_RSAPrivateKey ,
1213.Fn PEM_write_bio_RSAPrivateKey ,
1214.Fn PEM_read_bio_DSAPrivateKey ,
1215.Fn PEM_read_DSAPrivateKey ,
1216.Fn PEM_write_bio_DSAPrivateKey ,
1217.Fn PEM_write_DSAPrivateKey ,
1218.Fn PEM_read_bio_DHparams ,
1219.Fn PEM_write_bio_DHparams ,
1220.Fn PEM_read_bio_X509 ,
1221.Fn PEM_write_bio_X509 ,
1222.Fn PEM_read_bio_X509_REQ ,
1223.Fn PEM_write_bio_X509_REQ ,
1224.Fn PEM_read_bio_X509_CRL ,
1225.Fn PEM_write_bio_X509_CRL ,
1226.Fn PEM_read_bio_PKCS7 ,
1227and
1228.Fn PEM_write_bio_PKCS7
1229first appeared in SSLeay 0.6.0.
1230.Fn PEM_write_bio_PrivateKey ,
1231.Fn PEM_write_PrivateKey ,
1232.Fn PEM_read_bio_DSAparams ,
1233.Fn PEM_read_DSAparams ,
1234.Fn PEM_write_bio_DSAparams ,
1235and
1236.Fn PEM_write_DSAparams
1237first appeared in SSLeay 0.8.0.
1238.Fn PEM_read_bio_RSAPublicKey ,
1239.Fn PEM_read_RSAPublicKey ,
1240.Fn PEM_write_bio_RSAPublicKey ,
1241and
1242.Fn PEM_write_RSAPublicKey
1243first appeared in SSLeay 0.8.1.
1244All these functions have been available since
1245.Ox 2.4 .
1246.Pp
1247.Fn PEM_write_bio_PKCS8PrivateKey ,
1248.Fn PEM_write_PKCS8PrivateKey ,
1249.Fn PEM_read_bio_PKCS8 ,
1250.Fn PEM_read_PKCS8 ,
1251.Fn PEM_write_bio_PKCS8 ,
1252.Fn PEM_write_PKCS8 ,
1253.Fn PEM_read_bio_PKCS8_PRIV_KEY_INFO ,
1254.Fn PEM_read_PKCS8_PRIV_KEY_INFO ,
1255.Fn PEM_write_bio_PKCS8_PRIV_KEY_INFO ,
1256.Fn PEM_write_PKCS8_PRIV_KEY_INFO ,
1257.Pp
1258.Fn PEM_write_bio_PKCS8PrivateKey_nid ,
1259.Fn PEM_write_PKCS8PrivateKey_nid ,
1260.Fn PEM_read_bio_PUBKEY ,
1261.Fn PEM_read_PUBKEY ,
1262.Fn PEM_write_bio_PUBKEY ,
1263.Fn PEM_write_PUBKEY ,
1264.Fn PEM_read_bio_RSA_PUBKEY ,
1265.Fn PEM_read_RSA_PUBKEY ,
1266.Fn PEM_write_bio_RSA_PUBKEY ,
1267.Fn PEM_write_RSA_PUBKEY ,
1268.Fn PEM_read_bio_DSA_PUBKEY ,
1269.Fn PEM_read_DSA_PUBKEY ,
1270.Fn PEM_write_bio_DSA_PUBKEY ,
1271.Fn PEM_write_DSA_PUBKEY ,
1272.Fn PEM_write_bio_X509_REQ_NEW ,
1273.Fn PEM_write_X509_REQ_NEW ,
1274.Fn PEM_read_bio_X509_AUX ,
1275.Fn PEM_read_X509_AUX ,
1276.Fn PEM_write_bio_X509_AUX ,
1277and
1278.Fn PEM_write_X509_AUX
1279first appeared in OpenSSL 0.9.5 and have been available since
1280.Ox 2.7 .
1281.Pp
1282.Fn PEM_read_bio_ECPKParameters ,
1283.Fn PEM_read_ECPKParameters ,
1284.Fn PEM_write_bio_ECPKParameters ,
1285.Fn PEM_write_ECPKParameters ,
1286.Fn PEM_read_bio_ECPrivateKey ,
1287.Fn PEM_read_ECPrivateKey ,
1288.Fn PEM_write_bio_ECPrivateKey ,
1289.Fn PEM_write_ECPrivateKey ,
1290.Fn PEM_read_bio_EC_PUBKEY ,
1291.Fn PEM_read_EC_PUBKEY ,
1292.Fn PEM_write_bio_EC_PUBKEY ,
1293and
1294.Fn PEM_write_EC_PUBKEY
1295first appeared in OpenSSL 0.9.8 and have been available since
1296.Ox 4.5 .
1297.Pp
1298.Fn PEM_read_CMS ,
1299.Fn PEM_read_bio_CMS ,
1300.Fn PEM_write_CMS ,
1301and
1302.Fn PEM_write_bio_CMS
1303first appeared in OpenSSL 0.9.8h and have been available since
1304.Ox 6.7 .
1305.Sh CAVEATS
1306A frequent cause of problems is attempting to use the PEM routines like
1307this:
1308.Bd -literal -offset indent
1309X509 *x;
1310PEM_read_bio_X509(bp, &x, 0, NULL);
1311.Ed
1312.Pp
1313This is a bug because an attempt will be made to reuse the data at
1314.Fa x ,
1315which is an uninitialised pointer.
1316.Pp
1317These functions make no assumption regarding the pass phrase received
1318from the password callback.
1319It will simply be treated as a byte sequence.
1320.Sh BUGS
1321The PEM read routines in some versions of OpenSSL will not correctly
1322reuse an existing structure.
1323Therefore
1324.Pp
1325.Dl PEM_read_bio_X509(bp, &x, 0, NULL);
1326.Pp
1327where
1328.Fa x
1329already contains a valid certificate may not work, whereas
1330.Bd -literal -offset indent
1331X509_free(x);
1332x = PEM_read_bio_X509(bp, NULL, 0, NULL);
1333.Ed
1334.Pp
1335is guaranteed to work.
diff --git a/src/lib/libcrypto/man/PEM_write_bio_CMS_stream.3 b/src/lib/libcrypto/man/PEM_write_bio_CMS_stream.3
deleted file mode 100644
index 88adbba74f..0000000000
--- a/src/lib/libcrypto/man/PEM_write_bio_CMS_stream.3
+++ /dev/null
@@ -1,95 +0,0 @@
1.\" $OpenBSD: PEM_write_bio_CMS_stream.3,v 1.6 2023/05/01 07:28:11 tb Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: May 1 2023 $
52.Dt PEM_WRITE_BIO_CMS_STREAM 3
53.Os
54.Sh NAME
55.Nm PEM_write_bio_CMS_stream
56.Nd output CMS_ContentInfo structure in PEM format
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft int
60.Fo PEM_write_bio_CMS_stream
61.Fa "BIO *out"
62.Fa "CMS_ContentInfo *cms"
63.Fa "BIO *data"
64.Fa "int flags"
65.Fc
66.Sh DESCRIPTION
67.Fn PEM_write_bio_CMS_stream
68outputs a
69.Vt CMS_ContentInfo
70structure in PEM format.
71.Pp
72It is otherwise identical to the function
73.Xr SMIME_write_CMS 3 .
74.Pp
75This function is effectively a version of
76.Xr PEM_write_bio_CMS 3
77supporting streaming.
78.Sh RETURN VALUES
79.Fn PEM_write_bio_CMS_stream
80returns 1 for success or 0 for failure.
81.Sh SEE ALSO
82.Xr CMS_ContentInfo_new 3 ,
83.Xr CMS_decrypt 3 ,
84.Xr CMS_encrypt 3 ,
85.Xr CMS_sign 3 ,
86.Xr CMS_verify 3 ,
87.Xr ERR_get_error 3 ,
88.Xr i2d_CMS_bio_stream 3 ,
89.Xr PEM_write 3 ,
90.Xr SMIME_write_CMS 3
91.Sh HISTORY
92.Fn PEM_write_bio_CMS_stream
93first appeared in OpenSSL 1.0.0
94and has been available since
95.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/PEM_write_bio_PKCS7_stream.3 b/src/lib/libcrypto/man/PEM_write_bio_PKCS7_stream.3
deleted file mode 100644
index 9050b8562f..0000000000
--- a/src/lib/libcrypto/man/PEM_write_bio_PKCS7_stream.3
+++ /dev/null
@@ -1,90 +0,0 @@
1.\" $OpenBSD: PEM_write_bio_PKCS7_stream.3,v 1.12 2023/05/01 07:28:11 tb Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2007, 2009, 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: May 1 2023 $
52.Dt PEM_WRITE_BIO_PKCS7_STREAM 3
53.Os
54.Sh NAME
55.Nm PEM_write_bio_PKCS7_stream
56.Nd output PKCS7 structure in PEM format
57.Sh SYNOPSIS
58.In openssl/pkcs7.h
59.Ft int
60.Fo PEM_write_bio_PKCS7_stream
61.Fa "BIO *out"
62.Fa "PKCS7 *p7"
63.Fa "BIO *data"
64.Fa "int flags"
65.Fc
66.Sh DESCRIPTION
67.Fn PEM_write_bio_PKCS7_stream
68outputs a PKCS7 structure in PEM format.
69.Pp
70It is otherwise identical to the function
71.Xr SMIME_write_PKCS7 3 .
72.Pp
73This function is effectively a version of
74.Xr PEM_write_bio_PKCS7 3
75supporting streaming.
76.Sh RETURN VALUES
77Upon successful completion, 1 is returned;
78otherwise 0 is returned and an error code can be retrieved with
79.Xr ERR_get_error 3 .
80.Sh SEE ALSO
81.Xr BIO_new 3 ,
82.Xr i2d_PKCS7_bio_stream 3 ,
83.Xr PEM_write_PKCS7 3 ,
84.Xr PKCS7_final 3 ,
85.Xr PKCS7_new 3 ,
86.Xr SMIME_write_PKCS7 3
87.Sh HISTORY
88.Fn PEM_write_bio_PKCS7_stream
89first appeared in OpenSSL 1.0.0 and has been available since
90.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/PKCS12_SAFEBAG_new.3 b/src/lib/libcrypto/man/PKCS12_SAFEBAG_new.3
deleted file mode 100644
index e7d20ea7f6..0000000000
--- a/src/lib/libcrypto/man/PKCS12_SAFEBAG_new.3
+++ /dev/null
@@ -1,104 +0,0 @@
1.\" $OpenBSD: PKCS12_SAFEBAG_new.3,v 1.4 2019/06/06 01:06:58 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 6 2019 $
18.Dt PKCS12_SAFEBAG_NEW 3
19.Os
20.Sh NAME
21.Nm PKCS12_SAFEBAG_new ,
22.Nm PKCS12_SAFEBAG_free ,
23.Nm PKCS12_BAGS_new ,
24.Nm PKCS12_BAGS_free
25.Nd PKCS#12 container for one piece of information
26.Sh SYNOPSIS
27.In openssl/pkcs12.h
28.Ft PKCS12_SAFEBAG *
29.Fn PKCS12_SAFEBAG_new void
30.Ft void
31.Fn PKCS12_SAFEBAG_free "PKCS12_SAFEBAG *safebag"
32.Ft PKCS12_BAGS *
33.Fn PKCS12_BAGS_new void
34.Ft void
35.Fn PKCS12_BAGS_free "PKCS12_BAGS *bag"
36.Sh DESCRIPTION
37.Fn PKCS12_SAFEBAG_new
38allocates and initializes an empty
39.Vt PKCS12_SAFEBAG
40object, representing an ASN.1
41.Vt SafeBag
42structure defined in RFC 7292 section 4.2.
43It can hold a pointer to a
44.Vt PKCS12_BAGS
45object together with a type identifier and optional attributes.
46.Fn PKCS12_SAFEBAG_free
47frees
48.Fa safebag .
49.Pp
50.Fn PKCS12_BAGS_new
51allocates and initializes an empty
52.Vt PKCS12_BAGS
53object, representing the bagValue field of an ASN.1
54.Vt SafeBag
55structure.
56It is used in
57.Vt PKCS12_SAFEBAG
58and can hold a DER-encoded X.509 certificate,
59a base64-encoded SDSI certificate,
60a DER-encoded X.509 CRL,
61or other user-defined information.
62.Pp
63If an instance of
64.Vt PKCS12_SAFEBAG
65contains
66.Vt PKCS8_PRIV_KEY_INFO ,
67.Vt X509_SIG ,
68or nested
69.Vt PKCS12_SAFEBAG
70objects, the respective pointers are stored directly in the
71.Vt PKCS12_SAFEBAG
72object rather than in the contained
73.Vt PKCS12_BAGS
74object as required by RFC 7292.
75.Sh RETURN VALUES
76.Fn PKCS12_SAFEBAG_new
77and
78.Fn PKCS12_BAGS_new
79return the new
80.Vt PKCS12_SAFEBAG
81or
82.Vt PKCS12_BAGS
83object, respectively, or
84.Dv NULL
85if an error occurs.
86.Sh SEE ALSO
87.Xr PKCS12_create 3 ,
88.Xr PKCS12_new 3 ,
89.Xr PKCS8_PRIV_KEY_INFO_new 3 ,
90.Xr X509_ATTRIBUTE_new 3 ,
91.Xr X509_CRL_new 3 ,
92.Xr X509_new 3 ,
93.Xr X509_SIG_new 3
94.Sh STANDARDS
95RFC 7292: PKCS #12: Personal Information Exchange Syntax,
96section 4.2: The SafeBag Type
97.Sh HISTORY
98.Fn PKCS12_SAFEBAG_new ,
99.Fn PKCS12_SAFEBAG_free ,
100.Fn PKCS12_BAGS_new ,
101and
102.Fn PKCS12_BAGS_free
103first appeared in OpenSSL 0.9.3 and have been available since
104.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/PKCS12_create.3 b/src/lib/libcrypto/man/PKCS12_create.3
deleted file mode 100644
index 904166da73..0000000000
--- a/src/lib/libcrypto/man/PKCS12_create.3
+++ /dev/null
@@ -1,188 +0,0 @@
1.\" $OpenBSD: PKCS12_create.3,v 1.13 2024/08/22 12:26:01 tb Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2002, 2015 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: August 22 2024 $
53.Dt PKCS12_CREATE 3
54.Os
55.Sh NAME
56.Nm PKCS12_create
57.Nd create a PKCS#12 structure
58.Sh SYNOPSIS
59.In openssl/pkcs12.h
60.Ft PKCS12 *
61.Fo PKCS12_create
62.Fa "const char *pass"
63.Fa "const char *name"
64.Fa "EVP_PKEY *pkey"
65.Fa "X509 *cert"
66.Fa "STACK_OF(X509) *ca"
67.Fa "int nid_key"
68.Fa "int nid_cert"
69.Fa "int iter"
70.Fa "int mac_iter"
71.Fa "int keytype"
72.Fc
73.Sh DESCRIPTION
74.Fn PKCS12_create
75creates a PKCS#12 structure.
76.Pp
77.Fa pass
78is the passphrase to use.
79.Fa name
80is the
81.Sy friendlyName
82to use for the supplied certificate and key.
83.Fa pkey
84is the private key to include in the structure and
85.Fa cert
86its corresponding certificates.
87.Fa ca
88is an optional set of certificates to also include in the structure.
89.Fa pkey ,
90.Fa cert ,
91or both can be
92.Dv NULL
93to indicate that no key or certificate is required.
94.Pp
95.Fa nid_key
96and
97.Fa nid_cert
98are the encryption algorithms that should be used for the key and
99certificate, respectively.
100If either
101.Fa nid_key
102or
103.Fa nid_cert
104is set to -1, no encryption will be used.
105.Pp
106.Fa iter
107is the encryption algorithm iteration count to use and
108.Fa mac_iter
109is the MAC iteration count to use.
110If
111.Fa mac_iter
112is set to -1, the MAC will be omitted entirely.
113.Pp
114.Fa keytype
115is the type of key.
116.Pp
117The parameters
118.Fa nid_key ,
119.Fa nid_cert ,
120.Fa iter ,
121.Fa mac_iter ,
122and
123.Fa keytype
124can all be set to zero and sensible defaults will be used.
125.Pp
126These defaults are: 40-bit RC2 encryption for certificates, triple DES
127encryption for private keys, a key iteration count of
128PKCS12_DEFAULT_ITER (currently 2048) and a MAC iteration count of 1.
129.Pp
130The default MAC iteration count is 1 in order to retain compatibility
131with old software which did not interpret MAC iteration counts.
132If such compatibility is not required then
133.Fa mac_iter
134should be set to PKCS12_DEFAULT_ITER.
135.Pp
136.Fa keytype
137adds a flag to the store private key.
138This is a non-standard extension that is only currently interpreted by
139MSIE.
140If set to zero, the flag is omitted; if set to
141.Dv KEY_SIG ,
142the key can be used for signing only; and if set to
143.Dv KEY_EX ,
144it can be used for signing and encryption.
145This option was useful for old export grade software which could use
146signing only keys of arbitrary size but had restrictions on the
147permissible sizes of keys which could be used for encryption.
148.Pp
149If a certificate contains an
150.Sy alias
151or
152.Sy keyid
153then this will be used for the corresponding
154.Sy friendlyName
155or
156.Sy localKeyID
157in the PKCS12 structure.
158.Sh RETURN VALUES
159.Fn PKCS12_create
160returns a valid
161.Vt PKCS12
162structure or
163.Dv NULL
164if an error occurred.
165.Sh SEE ALSO
166.Xr crypto 3 ,
167.Xr d2i_PKCS12 3 ,
168.Xr PKCS12_new 3 ,
169.Xr PKCS12_newpass 3 ,
170.Xr PKCS12_parse 3 ,
171.Xr PKCS12_SAFEBAG_new 3 ,
172.Xr X509_keyid_set1 3
173.Sh HISTORY
174.Fn PKCS12_create
175first appeared in OpenSSL 0.9.3 and has been available since
176.Ox 2.6 .
177.Pp
178Before OpenSSL 0.9.8, neither
179.Fa pkey
180nor
181.Fa cert
182were allowed to be
183.Dv NULL ,
184and a value of -1 was not allowed for
185.Fa nid_key ,
186.Fa nid_cert ,
187and
188.Fa mac_iter .
diff --git a/src/lib/libcrypto/man/PKCS12_new.3 b/src/lib/libcrypto/man/PKCS12_new.3
deleted file mode 100644
index c7ccdb4911..0000000000
--- a/src/lib/libcrypto/man/PKCS12_new.3
+++ /dev/null
@@ -1,99 +0,0 @@
1.\" $OpenBSD: PKCS12_new.3,v 1.4 2019/06/06 01:06:58 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 6 2019 $
18.Dt PKCS12_NEW 3
19.Os
20.Sh NAME
21.Nm PKCS12_new ,
22.Nm PKCS12_free ,
23.Nm PKCS12_MAC_DATA_new ,
24.Nm PKCS12_MAC_DATA_free
25.Nd PKCS#12 personal information exchange (PFX)
26.Sh SYNOPSIS
27.In openssl/pkcs12.h
28.Ft PKCS12 *
29.Fn PKCS12_new void
30.Ft void
31.Fn PKCS12_free "PKCS12 *pfx"
32.Ft PKCS12_MAC_DATA *
33.Fn PKCS12_MAC_DATA_new void
34.Ft void
35.Fn PKCS12_MAC_DATA_free "PKCS12_MAC_DATA *mac_data"
36.Sh DESCRIPTION
37.Fn PKCS12_new
38allocates and initializes an empty
39.Vt PKCS12
40object, representing an ASN.1
41.Vt PFX
42.Pq personal information exchange
43structure defined in RFC 7292 section 4.
44It can hold a pointer to a
45.Vt PKCS7
46object described in
47.Xr PKCS7_new 3
48and optionally an instance of
49.Vt PKCS12_MAC_DATA
50described below.
51.Fn PKCS12_free
52frees
53.Fa pfx .
54.Pp
55.Fn PKCS12_MAC_DATA_new
56allocates and initializes an empty
57.Vt PKCS12_MAC_DATA
58object, representing an ASN.1
59.Vt MacData
60structure defined in RFC 7292 section 4.
61It is used inside
62.Vt PKCS12
63and can hold a pointer to an
64.Vt X509_SIG
65object described in
66.Xr X509_SIG_new 3
67together with a salt value and an iteration count.
68.Fn PKCS12_MAC_DATA_free
69frees
70.Fa mac_data .
71.Sh RETURN VALUES
72.Fn PKCS12_new
73and
74.Fn PKCS12_MAC_DATA_new
75return the new
76.Vt PKCS12
77or
78.Vt PKCS12_MAC_DATA
79object, respectively, or
80.Dv NULL
81if an error occurs.
82.Sh SEE ALSO
83.Xr d2i_PKCS12 3 ,
84.Xr PKCS12_create 3 ,
85.Xr PKCS12_newpass 3 ,
86.Xr PKCS12_parse 3 ,
87.Xr PKCS12_SAFEBAG_new 3 ,
88.Xr PKCS7_new 3 ,
89.Xr X509_SIG_new 3
90.Sh STANDARDS
91RFC 7292: PKCS #12: Personal Information Exchange Syntax
92.Sh HISTORY
93.Fn PKCS12_new ,
94.Fn PKCS12_free ,
95.Fn PKCS12_MAC_DATA_new ,
96and
97.Fn PKCS12_MAC_DATA_free
98first appeared in OpenSSL 0.9.3 and have been available since
99.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/PKCS12_newpass.3 b/src/lib/libcrypto/man/PKCS12_newpass.3
deleted file mode 100644
index b5642c96ea..0000000000
--- a/src/lib/libcrypto/man/PKCS12_newpass.3
+++ /dev/null
@@ -1,155 +0,0 @@
1.\" $OpenBSD: PKCS12_newpass.3,v 1.4 2019/06/14 13:59:32 schwarze Exp $
2.\" OpenSSL c95a8b4e May 5 14:26:26 2016 +0100
3.\"
4.\" This file was written by Jeffrey Walton <noloader@gmail.com>.
5.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 14 2019 $
52.Dt PKCS12_NEWPASS 3
53.Os
54.Sh NAME
55.Nm PKCS12_newpass
56.Nd change the password of a PKCS#12 structure
57.Sh SYNOPSIS
58.In openssl/pkcs12.h
59.Ft int
60.Fo PKCS12_newpass
61.Fa "PKCS12 *p12"
62.Fa "const char *oldpass"
63.Fa "const char *newpass"
64.Fc
65.Sh DESCRIPTION
66.Fn PKCS12_newpass
67changes the password of a PKCS#12 structure.
68.Pp
69.Fa p12
70is a pointer to a PKCS#12 structure.
71.Fa oldpass
72is the existing password and
73.Fa newpass
74is the new password.
75.Pp
76If the PKCS#12 structure does not have a password, use the empty
77string
78.Qq \&
79for
80.Fa oldpass .
81Passing
82.Dv NULL
83for
84.Fa oldpass
85results in a
86.Fn PKCS12_newpass
87failure.
88.Pp
89If the wrong password is used for
90.Fa oldpass ,
91the function will fail with a MAC verification error.
92In rare cases, the PKCS#12 structure does not contain a MAC:
93in this case it will usually fail with a decryption padding error.
94.Sh RETURN VALUES
95Upon successful completion, 1 is returned;
96otherwise 0 is returned and an error code can be retrieved with
97.Xr ERR_get_error 3 .
98.Sh EXAMPLES
99This example loads a PKCS#12 file, changes its password,
100and writes out the result to a new file.
101.Bd -literal
102#include <stdio.h>
103#include <stdlib.h>
104#include <openssl/pem.h>
105#include <openssl/err.h>
106#include <openssl/pkcs12.h>
107
108int main(int argc, char **argv)
109{
110 FILE *fp;
111 PKCS12 *p12;
112 if (argc != 5) {
113 fprintf(stderr,
114 "Usage: pkread p12file password newpass opfile\en");
115 return 1;
116 }
117 if ((fp = fopen(argv[1], "rb")) == NULL) {
118 fprintf(stderr, "Error opening file %s\en", argv[1]);
119 return 1;
120 }
121 p12 = d2i_PKCS12_fp(fp, NULL);
122 fclose(fp);
123 if (p12 == NULL) {
124 fprintf(stderr, "Error reading PKCS#12 file\en");
125 ERR_print_errors_fp(stderr);
126 return 1;
127 }
128 if (PKCS12_newpass(p12, argv[2], argv[3]) == 0) {
129 fprintf(stderr, "Error changing password\en");
130 ERR_print_errors_fp(stderr);
131 PKCS12_free(p12);
132 return 1;
133 }
134 if ((fp = fopen(argv[4], "wb")) == NULL) {
135 fprintf(stderr, "Error opening file %s\en", argv[4]);
136 PKCS12_free(p12);
137 return 1;
138 }
139 i2d_PKCS12_fp(fp, p12);
140 PKCS12_free(p12);
141 fclose(fp);
142 return 0;
143}
144.Ed
145.Sh SEE ALSO
146.Xr PKCS12_create 3 ,
147.Xr PKCS12_new 3
148.Sh HISTORY
149.Fn PKCS12_newpass
150first appeared in OpenSSL 0.9.5 and has been available since
151.Ox 2.7 .
152.Sh BUGS
153The password format is a NUL terminated ASCII string which is
154converted to Unicode form internally.
155As a result, some passwords cannot be supplied to this function.
diff --git a/src/lib/libcrypto/man/PKCS12_parse.3 b/src/lib/libcrypto/man/PKCS12_parse.3
deleted file mode 100644
index 4e92d303c7..0000000000
--- a/src/lib/libcrypto/man/PKCS12_parse.3
+++ /dev/null
@@ -1,145 +0,0 @@
1.\" $OpenBSD: PKCS12_parse.3,v 1.7 2021/07/09 12:07:27 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2009 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: July 9 2021 $
52.Dt PKCS12_PARSE 3
53.Os
54.Sh NAME
55.Nm PKCS12_parse
56.Nd parse a PKCS#12 structure
57.Sh SYNOPSIS
58.In openssl/pkcs12.h
59.Ft int
60.Fo PKCS12_parse
61.Fa "PKCS12 *p12"
62.Fa "const char *pass"
63.Fa "EVP_PKEY **pkey"
64.Fa "X509 **cert"
65.Fa "STACK_OF(X509) **ca"
66.Fc
67.Sh DESCRIPTION
68.Fn PKCS12_parse
69parses a PKCS12 structure.
70.Pp
71.Fa p12
72is the
73.Vt PKCS12
74structure to parse.
75.Fa pass
76is the passphrase to use.
77If successful, the private key will be written to
78.Pf * Fa pkey ,
79the corresponding certificate to
80.Pf * Fa cert ,
81and any additional certificates to
82.Pf * Fa ca .
83.Pp
84The parameters
85.Fa pkey
86and
87.Fa cert
88cannot be
89.Dv NULL .
90.Fa ca
91can be
92.Dv NULL ,
93in which case additional certificates will be discarded.
94.Pf * Fa ca
95can also be a valid STACK, in which case additional certificates are
96appended to
97.Pf * Fa ca .
98If
99.Pf * Fa ca
100is
101.Dv NULL ,
102a new STACK will be allocated.
103.Pp
104The
105.Sy friendlyName
106and
107.Sy localKeyID
108attributes (if present) of each certificate will be stored in the
109.Fa alias
110and
111.Fa keyid
112attributes of the
113.Vt X509
114structure.
115.Sh RETURN VALUES
116.Fn PKCS12_parse
117returns 1 for success and 0 if an error occurred.
118.Pp
119The error can be obtained from
120.Xr ERR_get_error 3 .
121.Sh SEE ALSO
122.Xr d2i_PKCS12 3 ,
123.Xr PKCS12_create 3 ,
124.Xr PKCS12_new 3 ,
125.Xr X509_keyid_set1 3
126.Sh HISTORY
127.Fn PKCS12_parse
128first appeared in OpenSSL 0.9.3 and has been available since
129.Ox 2.6 .
130.Sh BUGS
131Only a single private key and corresponding certificate is returned by
132this function.
133More complex PKCS#12 files with multiple private keys will only return
134the first match.
135.Pp
136Only
137.Sy friendlyName
138and
139.Sy localKeyID
140attributes are currently stored in certificates.
141Other attributes are discarded.
142.Pp
143Attributes currently cannot be stored in the private key
144.Vt EVP_PKEY
145structure.
diff --git a/src/lib/libcrypto/man/PKCS5_PBKDF2_HMAC.3 b/src/lib/libcrypto/man/PKCS5_PBKDF2_HMAC.3
deleted file mode 100644
index 3a448b92a7..0000000000
--- a/src/lib/libcrypto/man/PKCS5_PBKDF2_HMAC.3
+++ /dev/null
@@ -1,163 +0,0 @@
1.\" $OpenBSD: PKCS5_PBKDF2_HMAC.3,v 1.9 2019/06/07 20:46:25 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Jeffrey Walton <noloader@gmail.com>.
5.\" Copyright (c) 2014, 2015 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 7 2019 $
52.Dt PKCS5_PBKDF2_HMAC 3
53.Os
54.Sh NAME
55.Nm PKCS5_PBKDF2_HMAC ,
56.Nm PKCS5_PBKDF2_HMAC_SHA1
57.Nd password based derivation routines with salt and iteration count
58.Sh SYNOPSIS
59.In openssl/evp.h
60.Ft int
61.Fo PKCS5_PBKDF2_HMAC
62.Fa "const char *pass"
63.Fa "int passlen"
64.Fa "const unsigned char *salt"
65.Fa "int saltlen"
66.Fa "int iter"
67.Fa "const EVP_MD *digest"
68.Fa "int keylen"
69.Fa "unsigned char *out"
70.Fc
71.Ft int
72.Fo PKCS5_PBKDF2_HMAC_SHA1
73.Fa "const char *pass"
74.Fa "int passlen"
75.Fa "const unsigned char *salt"
76.Fa "int saltlen"
77.Fa "int iter"
78.Fa "int keylen"
79.Fa "unsigned char *out"
80.Fc
81.Sh DESCRIPTION
82.Fn PKCS5_PBKDF2_HMAC
83derives a key from a password using a salt and iteration count as
84specified in RFC 2898.
85.Pp
86.Fa pass
87is the password used in the derivation of length
88.Fa passlen .
89.Fa pass
90is an optional parameter and can be
91.Dv NULL .
92If
93.Fa passlen
94is -1, then the function will calculate the length of
95.Fa pass
96using
97.Xr strlen 3 .
98.Pp
99.Fa salt
100is the salt used in the derivation of length
101.Fa saltlen .
102If the
103.Fa salt
104is
105.Dv NULL ,
106then
107.Fa saltlen
108must be 0.
109The function will not attempt to calculate the length of the
110.Fa salt
111because it is not assumed to be NUL terminated.
112.Pp
113.Fa iter
114is the iteration count and its value should be greater than or equal to 1.
115RFC 2898 suggests an iteration count of at least 1000.
116Any
117.Fa iter
118less than 1 is treated as a single iteration.
119.Pp
120.Fa digest
121is the message digest function used in the derivation.
122Values include any of the EVP_* message digests.
123.Fn PKCS5_PBKDF2_HMAC_SHA1
124calls
125.Fn PKCS5_PBKDF2_HMAC
126with
127.Xr EVP_sha1 3 .
128.Pp
129The derived key will be written to
130.Fa out .
131The size of the
132.Fa out
133buffer is specified via
134.Fa keylen .
135.Pp
136A typical application of this function is to derive keying material for
137an encryption algorithm from a password in the
138.Fa pass ,
139a salt in
140.Fa salt ,
141and an iteration count.
142.Pp
143Increasing the
144.Fa iter
145parameter slows down the algorithm which makes it harder for an attacker
146to perform a brute force attack using a large number of candidate
147passwords.
148.Sh RETURN VALUES
149.Fn PKCS5_PBKDF2_HMAC
150and
151.Fn PBKCS5_PBKDF2_HMAC_SHA1
152return 1 on success or 0 on error.
153.Sh SEE ALSO
154.Xr EVP_BytesToKey 3 ,
155.Xr EVP_DigestInit 3
156.Sh HISTORY
157.Fn PKCS5_PBKDF2_HMAC_SHA1
158first appeared in OpenSSL 0.9.4 and has been available since
159.Ox 2.6 .
160.Pp
161.Fn PKCS5_PBKDF2_HMAC
162first appeared in OpenSSL 1.0.0 and has been available since
163.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/PKCS7_add_attribute.3 b/src/lib/libcrypto/man/PKCS7_add_attribute.3
deleted file mode 100644
index 4a1c350f98..0000000000
--- a/src/lib/libcrypto/man/PKCS7_add_attribute.3
+++ /dev/null
@@ -1,365 +0,0 @@
1.\" $OpenBSD: PKCS7_add_attribute.3,v 1.3 2020/06/10 11:39:12 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 10 2020 $
18.Dt PKCS7_ADD_ATTRIBUTE 3
19.Os
20.Sh NAME
21.Nm PKCS7_add_attribute ,
22.Nm PKCS7_set_attributes ,
23.Nm PKCS7_get_attribute ,
24.Nm PKCS7_add_signed_attribute ,
25.Nm PKCS7_set_signed_attributes ,
26.Nm PKCS7_get_signed_attribute ,
27.Nm PKCS7_add_attrib_content_type ,
28.Nm PKCS7_add1_attrib_digest ,
29.Nm PKCS7_add0_attrib_signing_time ,
30.Nm PKCS7_add_attrib_smimecap
31.Nd attributes of SignerInfo objects
32.Sh SYNOPSIS
33.In openssl/pkcs7.h
34.Ft int
35.Fo PKCS7_add_attribute
36.Fa "PKCS7_SIGNER_INFO *si"
37.Fa "int nid"
38.Fa "int attrtype"
39.Fa "void *value"
40.Fc
41.Ft int
42.Fo PKCS7_set_attributes
43.Fa "PKCS7_SIGNER_INFO *si"
44.Fa "STACK_OF(X509_ATTRIBUTE) *sk"
45.Fc
46.Ft ASN1_TYPE *
47.Fo PKCS7_get_attribute
48.Fa "PKCS7_SIGNER_INFO *si"
49.Fa "int nid"
50.Fc
51.Ft int
52.Fo PKCS7_add_signed_attribute
53.Fa "PKCS7_SIGNER_INFO *si"
54.Fa "int nid"
55.Fa "int attrtype"
56.Fa "void *value"
57.Fc
58.Ft int
59.Fo PKCS7_set_signed_attributes
60.Fa "PKCS7_SIGNER_INFO *si"
61.Fa "STACK_OF(X509_ATTRIBUTE) *sk"
62.Fc
63.Ft ASN1_TYPE *
64.Fo PKCS7_get_signed_attribute
65.Fa "PKCS7_SIGNER_INFO *si"
66.Fa "int nid"
67.Fc
68.Ft int
69.Fo PKCS7_add_attrib_content_type
70.Fa "PKCS7_SIGNER_INFO *si"
71.Fa "ASN1_OBJECT *coid"
72.Fc
73.Ft int
74.Fo PKCS7_add1_attrib_digest
75.Fa "PKCS7_SIGNER_INFO *si"
76.Fa "const unsigned char *md"
77.Fa "int mdlen"
78.Fc
79.Ft int
80.Fo PKCS7_add0_attrib_signing_time
81.Fa "PKCS7_SIGNER_INFO *si"
82.Fa "ASN1_TIME *t"
83.Fc
84.Ft int
85.Fo PKCS7_add_attrib_smimecap
86.Fa "PKCS7_SIGNER_INFO *si"
87.Fa "STACK_OF(X509_ALGOR) *cap"
88.Fc
89.Sh DESCRIPTION
90.Fn PKCS7_add_attribute
91appends a new attribute of type
92.Fa nid
93to the
94.Fa unauthenticatedAttributes
95list of
96.Fa si ,
97and it adds a new ASN.1 ANY object of type
98.Fa attrtype
99with the given
100.Fa value
101to the new attribute.
102Ownership of the
103.Fa value
104is transferred into the new attribute object, so the calling code
105must not
106.Xr free 3
107the
108.Fa value .
109If the list already contains an unauthenticated attribute of type
110.Fa nid
111before the call, the new attribute replaces the old one
112instead of being appended to the end of the list.
113.Pp
114.Fn PKCS7_set_attributes
115frees the
116.Fa unauthenticatedAttributes
117list of
118.Fa si
119and all the attributes contained in it and replaces it with a deep copy of
120.Fa sk .
121.Pp
122.Fn PKCS7_get_attribute
123retrieves the first ASN.1 ANY member of the attribute of type
124.Fa nid
125from the
126.Fa unauthenticatedAttributes
127list of
128.Fa si .
129.Pp
130The behaviour of
131.Fn PKCS7_add_signed_attribute ,
132.Fn PKCS7_set_signed_attributes ,
133and
134.Fn PKCS7_get_signed_attribute
135is identical except that they operate on the list of
136.Fa authenticatedAttributes .
137.Pp
138The normal way to use
139.Fn PKCS7_add_signed_attribute
140is to first create a
141.Vt SignedInfo
142object with
143.Xr PKCS7_sign 3
144using the
145.Dv PKCS7_PARTIAL
146or
147.Dv PKCS7_STREAM
148flag, retrieve the
149.Vt PKCS7_SIGNER_INFO
150object with
151.Xr PKCS7_get_signer_info 3
152or add an additional one with
153.Xr PKCS7_sign_add_signer 3 ,
154call
155.Fn PKCS7_add_signed_attribute
156for each desired additional attribute, then do the signing with
157.Xr PKCS7_final 3
158or with another finalizing function.
159.Pp
160The four remaining functions are wrappers around
161.Fn PKCS7_add_signed_attribute .
162.Pp
163.Fn PKCS7_add_attrib_content_type
164sets the
165.Dv NID_pkcs9_contentType
166attribute to
167.Fa coid ,
168which specifies the content type of the
169.Vt ContentInfo
170value to be signed.
171This attribute is mandatory and automatically added by
172.Xr PKCS7_sign 3
173and
174.Xr PKCS7_sign_add_signer 3
175unless the
176.Dv PKCS7_NOATTR
177flag is present.
178Objects suitable as
179.Fa coid
180arguments can for example be obtained with
181.Xr OBJ_nid2obj 3 .
182If
183.Fa coid
184is
185.Dv NULL ,
186the content type defaults to
187.Dv NID_pkcs7_data .
188.Pp
189.Fn PKCS7_add1_attrib_digest
190sets or replaces the
191.Dv NID_pkcs9_messageDigest
192attribute, which is the message digest of the contents octets
193of the DER-encoding of the content field of the
194.Vt ContentInfo
195value being signed, to a copy of
196.Fa md ,
197which is assumed to be
198.Fa mdlen
199bytes long.
200If
201.Fa mdlen
202is -1, then
203.Fn strlen md
204is used instead of
205.Fa mdlen .
206This attribute is mandatory and automatically added by
207.Xr PKCS7_dataFinal 3
208and
209.Xr PKCS7_final 3 .
210.Pp
211.Fn PKCS7_add0_attrib_signing_time
212sets or replaces the optional
213.Dv NID_pkcs9_signingTime
214attribute to
215.Fa t ,
216specifying the time at which the signer performed the signing process.
217Ownership of
218.Fa t
219is transferred into the new attribute object, so the calling code
220must not
221.Xr free 3
222.Fa t .
223If
224.Fa t
225is
226.Dv NULL ,
227a new
228.Vt ASN1_TIME
229structure is allocated.
230This attribute is automatically added by
231.Xr PKCS7_dataFinal 3
232and
233.Xr PKCS7_final 3 .
234.Pp
235.Fn PKCS7_add_attrib_smimecap
236sets or replaces the optional
237.Dv NID_SMIMECapabilities
238attribute, indicating algorithms the sender is prepared to handle.
239The
240.Fa cap
241pointer is not stored in the new attribute object and can be passed to
242.Fn sk_X509_ALGOR_pop_free
243after the call.
244This attribute is automatically added by
245.Xr PKCS7_sign 3
246and
247.Xr PKCS7_sign_add_signer 3
248unless the
249.Dv PKCS7_NOATTR
250or
251.Dv PKCS7_NOSMIMECAP
252flag is present.
253.Sh RETURN VALUES
254.Fn PKCS7_add_attribute ,
255.Fn PKCS7_set_attributes ,
256.Fn PKCS7_add_signed_attribute ,
257.Fn PKCS7_set_signed_attributes ,
258.Fn PKCS7_add_attrib_content_type ,
259.Fn PKCS7_add1_attrib_digest ,
260.Fn PKCS7_add0_attrib_signing_time ,
261and
262.Fn PKCS7_add_attrib_smimecap
263return 1 on success or 0 on failure.
264The most common reason for failure is lack of memory.
265.Fn PKCS7_add_attribute
266and
267.Fn PKCS7_add_signed_attribute
268also fail if
269.Fa nid
270is invalid, and
271.Fn PKCS7_add_attrib_content_type
272if
273.Fa si
274already contains an authenticated attribute of type
275.Dv NID_pkcs9_contentType .
276.Pp
277.Fn PKCS7_get_attribute
278and
279.Fn PKCS7_get_signed_attribute
280return an internal pointer to an ASN.1 ANY object or
281.Dv NULL
282on failure.
283They fail if
284.Fa nid
285is invalid, if the respective list in
286.Fa si
287contains no attribute of the requested type, or if an invalid element
288is found in the list before finding the attribute of the requested type.
289.Sh SEE ALSO
290.Xr ASN1_TIME_new 3 ,
291.Xr ASN1_TYPE_new 3 ,
292.Xr OBJ_nid2obj 3 ,
293.Xr PKCS7_final 3 ,
294.Xr PKCS7_get_signer_info 3 ,
295.Xr PKCS7_new 3 ,
296.Xr PKCS7_sign 3 ,
297.Xr PKCS7_sign_add_signer 3 ,
298.Xr STACK_OF 3 ,
299.Xr X509_ALGOR_new 3 ,
300.Xr X509_ATTRIBUTE_new 3
301.Sh STANDARDS
302RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5,
303section 9.2: SignerInfo type
304.Pp
305RFC 2985: PKCS #9: Selected Object Classes and Attribute Types Version 2.0,
306section 5.3: Attribute types for use in PKCS #7 data
307and section 5.6: Attributes defined in S/MIME
308.Pp
309RFC 8551: Secure/Multipurpose Internet Mail Extensions (S/MIME)
310Version 4.0 Message Specification,
311section 2.5.2: SMIMECapabilities Attribute
312.Sh HISTORY
313.Fn PKCS7_add_attribute ,
314.Fn PKCS7_set_attributes ,
315.Fn PKCS7_get_attribute ,
316.Fn PKCS7_add_signed_attribute ,
317.Fn PKCS7_set_signed_attributes ,
318and
319.Fn PKCS7_get_signed_attribute
320first appeared in OpenSSL 0.9.1 and have been available since
321.Ox 2.6 .
322.Pp
323.Fn PKCS7_add_attrib_smimecap
324first appeared in OpenSSL 0.9.5 and has been available since
325.Ox 2.7 .
326.Pp
327.Fn PKCS7_add_attrib_content_type ,
328.Fn PKCS7_add1_attrib_digest ,
329and
330.Fn PKCS7_add0_attrib_signing_time
331first appeared in OpenSSL 1.0.0 and have been available since
332.Ox 4.9 .
333.Sh CAVEATS
334.Fn PKCS7_set_signed_attributes
335does not validate that
336.Fa sk
337contains the PKCS #9 content type and message digest attributes
338required by RFC 2315.
339It succeeds even when
340.Fa sk
341is empty, leaving
342.Fa si
343in a state that violates the standard.
344.Pp
345.Fn PKCS7_add0_attrib_signing_time
346does not validate
347.Fa t
348in any way.
349In particular, it may set the signing time to the future
350or to the remote past.
351.Sh BUGS
352A function to remove individual attributes from these lists
353does not appear to exist.
354A program desiring to do that might have to manually iterate the fields
355.Fa auth_attr
356and
357.Fa unauth_attr
358of
359.Fa si ,
360which are both of type
361.Vt STACK_OF(X509_ATTRIBUTE) ,
362using the facilities described in
363.Xr STACK_OF 3
364and
365.Xr OPENSSL_sk_new 3 .
diff --git a/src/lib/libcrypto/man/PKCS7_dataFinal.3 b/src/lib/libcrypto/man/PKCS7_dataFinal.3
deleted file mode 100644
index 1a01b2ff61..0000000000
--- a/src/lib/libcrypto/man/PKCS7_dataFinal.3
+++ /dev/null
@@ -1,158 +0,0 @@
1.\" $OpenBSD: PKCS7_dataFinal.3,v 1.3 2022/12/26 07:18:52 jmc Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 26 2022 $
18.Dt PKCS7_DATAFINAL 3
19.Os
20.Sh NAME
21.Nm PKCS7_dataFinal
22.Nd move data from a BIO chain to a ContentInfo object
23.Sh SYNOPSIS
24.In openssl/pkcs7.h
25.Ft int
26.Fo PKCS7_dataFinal
27.Fa "PKCS7 *p7"
28.Fa "BIO *chain"
29.Fc
30.Sh DESCRIPTION
31.Fn PKCS7_dataFinal
32transfers the data from the memory BIO at the end of the given
33.Fa chain
34into the appropriate content field of
35.Fa p7
36itself or of its appropriate substructure.
37It is typically used as the final step of populating
38.Fa p7 ,
39after creating the
40.Fa chain
41with
42.Xr PKCS7_dataInit 3
43and after writing the data into it.
44.Pp
45After calling
46.Fn PKCS7_dataFinal ,
47the program can call
48.Xr BIO_free_all 3
49on the
50.Fa chain
51because such chains are not designed for reuse.
52.Pp
53Depending on the
54.Fa contentType
55of
56.Fa p7 ,
57.Fn PKCS7_dataFinal
58sets the following fields:
59.Bl -tag -width Ds
60.It for Vt SignedData No or Vt DigestedData :
61in substructures of the
62.Fa content
63field of
64.Fa p7 :
65the
66.Fa content
67field in the
68.Vt ContentInfo
69structure (unless
70.Fa p7
71is configured to store a detached signature) and the
72.Fa encryptedDigest
73fields in all the
74.Vt SignerInfo
75structures
76.It for Vt EnvelopedData No or Vt SignedAndEnvelopedData :
77the
78.Fa encryptedContent
79field in the
80.Vt EncryptedContentInfo
81structure contained in the
82.Fa content
83field of
84.Fa p7
85.It for arbitrary data :
86the
87.Fa content
88field of
89.Fa p7
90itself
91.El
92.Sh RETURN VALUES
93.Fn PKCS7_dataFinal
94returns 1 on success or 0 on failure.
95.Pp
96Possible reasons for failure include:
97.Pp
98.Bl -dash -compact -offset 2n -width 1n
99.It
100.Fa p7
101is
102.Dv NULL .
103.It
104The
105.Fa content
106field of
107.Fa p7
108is empty.
109.It
110The
111.Fa contentType
112of
113.Fa p7
114is unsupported.
115.It
116The
117.Fa chain
118does not contain the expected memory BIO.
119.It
120Signing or digesting is requested and
121.Fa p7
122is not configured to store a detached signature,
123but does not contain the required field to store the content either.
124.It
125At least one signer lacks a usable digest algorithm.
126.It
127Signing or digesting fails.
128.It
129Memory allocation fails.
130.El
131.Pp
132Signers lacking private keys do not cause failure
133but are silently skipped.
134.Sh SEE ALSO
135.Xr BIO_new 3 ,
136.Xr PKCS7_dataInit 3 ,
137.Xr PKCS7_final 3 ,
138.Xr PKCS7_new 3 ,
139.Xr PKCS7_sign 3
140.Sh HISTORY
141.Fn PKCS7_dataFinal
142first appeared in SSLeay 0.9.1 and has been available since
143.Ox 2.6 .
144.Sh CAVEATS
145This function does not support
146.Vt EncryptedData .
147.Pp
148Even though this function is typically used after
149.Xr PKCS7_dataInit 3
150and even though
151.Xr PKCS7_dataInit 3
152also supports reading from
153.Vt ContentInfo
154structures that are already fully populated, do not use
155.Fn PKCS7_dataFinal
156on fully populated structures.
157It is only intended for putting data into new structures
158and it is neither needed nor suitable for reading.
diff --git a/src/lib/libcrypto/man/PKCS7_dataInit.3 b/src/lib/libcrypto/man/PKCS7_dataInit.3
deleted file mode 100644
index cb54d3f95c..0000000000
--- a/src/lib/libcrypto/man/PKCS7_dataInit.3
+++ /dev/null
@@ -1,226 +0,0 @@
1.\" $OpenBSD: PKCS7_dataInit.3,v 1.2 2020/06/03 13:41:27 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 3 2020 $
18.Dt PKCS7_DATAINIT 3
19.Os
20.Sh NAME
21.Nm PKCS7_dataInit
22.Nd construct a BIO chain for adding or retrieving content
23.Sh SYNOPSIS
24.In openssl/pkcs7.h
25.Ft BIO *
26.Fo PKCS7_dataInit
27.Fa "PKCS7 *p7"
28.Fa "BIO *indata"
29.Fc
30.Sh DESCRIPTION
31.Fn PKCS7_dataInit
32constructs a BIO chain in preparation for putting data into
33or retrieving data out of
34.Fa p7 .
35Depending on the
36.Fa contentType
37of
38.Fa p7 ,
39the created chain starts with:
40.Bl -tag -width Ds
41.It for Vt SignedData :
42one or more
43.Xr BIO_f_md 3
44message digest filters
45.It for Vt EnvelopedData :
46one
47.Xr BIO_f_cipher 3
48encryption filter
49.It for Vt SignedAndEnvelopedData :
50one or more
51.Xr BIO_f_md 3
52message digest filters followed by one
53.Xr BIO_f_cipher 3
54encryption filter
55.It for Vt DigestedData :
56one
57.Xr BIO_f_md 3
58message digest filter
59.It for arbitrary data :
60no filter BIO
61.El
62.Pp
63One additional BIO is appended to the end of the chain,
64depending on the first condition that holds in the following list:
65.Bl -tag -width Ds
66.It Fa indata
67if the
68.Fa indata
69argument is not
70.Dv NULL .
71This only makes sense while verifying a detached signature, in which case
72.Fa indata
73is expected to supply the content associated with the detached signature.
74.It Xr BIO_s_null 3
75if the
76.Fa contentType
77of
78.Fa p7
79is
80.Vt SignedData
81and it is configured to contain a detached signature.
82This only makes sense while creating the detached signature.
83.It Xr BIO_new_mem_buf 3
84when reading from a
85.Vt SignedData
86or
87.Vt DigestedData
88object.
89.Fn PKCS7_dataInit
90attaches the end of the chain to the nested content of
91.Fa p7 .
92.It Xr BIO_s_mem 3
93otherwise.
94This is the most common case while writing data to
95.Fa p7 .
96.Xr PKCS7_dataFinal 3
97can later be used to transfer the data from the memory BIO into
98.Fa p7 .
99.El
100.Ss Adding content
101Before calling
102.Fn PKCS7_dataInit
103in order to add content,
104.Xr PKCS7_new 3 ,
105.Xr PKCS7_set_type 3 ,
106and
107.Xr PKCS7_content_new 3
108are typically required to create
109.Fa p7 ,
110to choose its desired type, and to allocate the nested
111.Vt ContentInfo
112structure.
113Alternatively, for
114.Vt SignedData ,
115.Xr PKCS7_sign 3
116can be used with the
117.Dv PKCS7_PARTIAL
118or
119.Dv PKCS7_STREAM
120.Fa flags
121or for
122.Vt EnvelopedData ,
123.Xr PKCS7_encrypt 3
124with the
125.Dv PKCS7_STREAM
126flag.
127.Pp
128After calling
129.Fn PKCS7_dataInit ,
130the desired data can be written into the returned
131.Vt BIO ,
132.Xr BIO_flush 3
133can be called on it,
134.Xr PKCS7_dataFinal 3
135can be used to transfer the processed data
136from the returned memory BIO to the
137.Fa p7
138structure, and the chain can finally be destroyed with
139.Xr BIO_free_all 3 .
140.Pp
141While
142.Fn PKCS7_dataInit
143does support the
144.Vt EnvelopedData
145and
146.Vt SignedAndEnvelopedData
147types, using it for these types is awkward and error prone
148except when using
149.Xr PKCS7_encrypt 3
150for the setup because
151.Xr PKCS7_content_new 3
152does not support these two types.
153So in addition to creating
154.Fa p7
155itself and setting its type, the nested
156.Fa ContentInfo
157structure also needs to be constructed with
158.Xr PKCS7_new 3
159and
160.Xr PKCS7_set_type 3
161and manually inserted into the correct field
162of the respective sub-structure of
163.Fa p7 .
164.Ss Retrieving content
165.Fn PKCS7_dataInit
166can also be called on a fully populated object of type
167.Vt SignedData
168or
169.Vt DigestedData .
170After that,
171.Xr BIO_read 3
172can be used to retrieve data from it.
173In this use case, do not call
174.Xr PKCS7_dataFinal 3 ;
175simply proceed directly to
176.Xr BIO_free_all 3
177after reading the data.
178.Sh RETURN VALUES
179.Fn PKCS7_dataInit
180returns a BIO chain on success or
181.Dv NULL
182on failure.
183It fails if
184.Fa p7
185is
186.Dv NULL ,
187if the
188.Fa content
189field of
190.Fa p7
191is empty, if the
192.Fa contentType
193of
194.Fa p7
195is unsupported, if a cipher is required but none is configured, or
196if any required operation fails, for example due to lack of memory
197or for various other reasons.
198.Sh SEE ALSO
199.Xr BIO_new 3 ,
200.Xr BIO_read 3 ,
201.Xr PKCS7_content_new 3 ,
202.Xr PKCS7_dataFinal 3 ,
203.Xr PKCS7_encrypt 3 ,
204.Xr PKCS7_final 3 ,
205.Xr PKCS7_new 3 ,
206.Xr PKCS7_set_type 3 ,
207.Xr PKCS7_sign 3
208.Sh HISTORY
209.Fn PKCS7_dataInit
210first appeared in SSLeay 0.8.1 and has been available since
211.Ox 2.4 .
212.Sh CAVEATS
213This function does not support
214.Vt EncryptedData .
215.Sh BUGS
216If
217.Fa p7
218is a fully populated structure containing
219.Vt EnvelopedData ,
220.Vt SignedAndEnvelopedData ,
221or arbitrary data,
222.Fn PKCS7_dataInit
223returns a BIO chain that ultimately reads from an empty memory BIO,
224so reading from it will instantly return an end-of-file indication
225rather than reading the actual data contained in
226.Fa p7 .
diff --git a/src/lib/libcrypto/man/PKCS7_decrypt.3 b/src/lib/libcrypto/man/PKCS7_decrypt.3
deleted file mode 100644
index 8d00499b57..0000000000
--- a/src/lib/libcrypto/man/PKCS7_decrypt.3
+++ /dev/null
@@ -1,118 +0,0 @@
1.\" $OpenBSD: PKCS7_decrypt.3,v 1.10 2019/06/10 14:58:48 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2006 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 10 2019 $
52.Dt PKCS7_DECRYPT 3
53.Os
54.Sh NAME
55.Nm PKCS7_decrypt
56.Nd decrypt content from a PKCS#7 envelopedData structure
57.Sh SYNOPSIS
58.In openssl/pkcs7.h
59.Ft int
60.Fo PKCS7_decrypt
61.Fa "PKCS7 *p7"
62.Fa "EVP_PKEY *pkey"
63.Fa "X509 *cert"
64.Fa "BIO *data"
65.Fa "int flags"
66.Fc
67.Sh DESCRIPTION
68.Fn PKCS7_decrypt
69extracts and decrypts the content from a PKCS#7 envelopedData structure.
70.Fa pkey
71is the private key of the recipient,
72.Fa cert
73is the recipient's certificate,
74.Fa data
75is a
76.Vt BIO
77to write the content to and
78.Fa flags
79is an optional set of flags.
80.Pp
81Although the recipient's certificate is not needed to decrypt the data,
82it is needed to locate the appropriate recipients
83in the PKCS#7 structure.
84.Pp
85If the
86.Dv PKCS7_TEXT
87.Fa flag
88is set, MIME headers for type
89.Sy text/plain
90are deleted from the content.
91If the content is not of type
92.Sy text/plain ,
93an error is returned.
94.Sh RETURN VALUES
95.Fn PKCS7_decrypt
96returns 1 for success or 0 for failure.
97.Pp
98The error can be obtained from
99.Xr ERR_get_error 3 .
100.Sh SEE ALSO
101.Xr PKCS7_encrypt 3 ,
102.Xr PKCS7_new 3 ,
103.Xr PKCS7_verify 3
104.Sh HISTORY
105.Fn PKCS7_decrypt
106first appeared in OpenSSL 0.9.5 and has been available since
107.Ox 2.7 .
108.Sh BUGS
109.Fn PKCS7_decrypt
110must be passed the correct recipient key and certificate.
111It would be better if it could look up the correct key and certificate
112from a database.
113.Pp
114The lack of single pass processing and need to hold all data in memory
115as mentioned in
116.Xr PKCS7_sign 3
117also applies to
118.Fn PKCS7_decrypt .
diff --git a/src/lib/libcrypto/man/PKCS7_encrypt.3 b/src/lib/libcrypto/man/PKCS7_encrypt.3
deleted file mode 100644
index 700498a1de..0000000000
--- a/src/lib/libcrypto/man/PKCS7_encrypt.3
+++ /dev/null
@@ -1,169 +0,0 @@
1.\" $OpenBSD: PKCS7_encrypt.3,v 1.11 2020/06/03 13:41:27 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2006, 2007, 2008, 2009 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: June 3 2020 $
53.Dt PKCS7_ENCRYPT 3
54.Os
55.Sh NAME
56.Nm PKCS7_encrypt
57.Nd create a PKCS#7 envelopedData structure
58.Sh SYNOPSIS
59.In openssl/pkcs7.h
60.Ft PKCS7 *
61.Fo PKCS7_encrypt
62.Fa "STACK_OF(X509) *certs"
63.Fa "BIO *in"
64.Fa "const EVP_CIPHER *cipher"
65.Fa "int flags"
66.Fc
67.Sh DESCRIPTION
68.Fn PKCS7_encrypt
69creates and returns a PKCS#7 envelopedData structure.
70.Fa certs
71is a list of recipient certificates.
72.Fa in
73is the content to be encrypted.
74.Fa cipher
75is the symmetric cipher to use.
76.Fa flags
77is an optional set of flags.
78.Pp
79Only RSA keys are supported in PKCS#7 and envelopedData so the recipient
80certificates supplied to this function must all contain RSA public keys,
81though they do not have to be signed using the RSA algorithm.
82.Pp
83The algorithm passed in the
84.Fa cipher
85parameter must support ASN.1 encoding of its parameters.
86.Pp
87Many browsers implement a "sign and encrypt" option which is simply an
88S/MIME envelopedData containing an S/MIME signed message.
89This can be readily produced by storing the S/MIME signed message in a
90memory
91.Vt BIO
92and passing it to
93.Fn PKCS7_encrypt .
94.Pp
95The following flags can be passed in the
96.Fa flags
97parameter.
98.Pp
99If the
100.Dv PKCS7_TEXT
101flag is set, MIME headers for type
102.Sy text/plain
103are prepended to the data.
104.Pp
105Normally the supplied content is translated into MIME canonical format
106(as required by the S/MIME specifications).
107If
108.Dv PKCS7_BINARY
109is set, no translation occurs.
110This option should be used if the supplied data is in binary format;
111otherwise, the translation will corrupt it.
112If
113.Dv PKCS7_BINARY
114is set, then
115.Dv PKCS7_TEXT
116is ignored.
117.Pp
118If the
119.Dv PKCS7_STREAM
120flag is set, a partial
121.Vt PKCS7
122structure is output suitable for streaming I/O: no data is read from
123.Fa in .
124.Pp
125If the flag
126.Dv PKCS7_STREAM
127is set, the returned
128.Vt PKCS7
129structure is
130.Sy not
131complete and outputting its contents via a function that does not
132properly finalize the
133.Vt PKCS7
134structure will give unpredictable results.
135.Pp
136Several functions including
137.Xr PKCS7_final 3 ,
138.Xr SMIME_write_PKCS7 3 ,
139.Xr PEM_write_bio_PKCS7_stream 3 ,
140and
141.Xr i2d_PKCS7_bio_stream 3
142finalize the structure.
143Alternatively finalization can be performed by obtaining the streaming
144ASN.1
145.Vt BIO
146directly using
147.Fn BIO_new_PKCS7 .
148.Sh RETURN VALUES
149.Fn PKCS7_encrypt
150returns either a
151.Vt PKCS7
152structure or
153.Dv NULL
154if an error occurred.
155The error can be obtained from
156.Xr ERR_get_error 3 .
157.Sh SEE ALSO
158.Xr PKCS7_decrypt 3 ,
159.Xr PKCS7_final 3 ,
160.Xr PKCS7_new 3 ,
161.Xr PKCS7_sign 3
162.Sh HISTORY
163.Fn PKCS7_encrypt
164first appeared in OpenSSL 0.9.5 and has been available since
165.Ox 2.7 .
166.Pp
167The
168.Dv PKCS7_STREAM
169flag was first supported in OpenSSL 1.0.0.
diff --git a/src/lib/libcrypto/man/PKCS7_final.3 b/src/lib/libcrypto/man/PKCS7_final.3
deleted file mode 100644
index 775b84d984..0000000000
--- a/src/lib/libcrypto/man/PKCS7_final.3
+++ /dev/null
@@ -1,202 +0,0 @@
1.\" $OpenBSD: PKCS7_final.3,v 1.3 2022/12/26 07:18:52 jmc Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 26 2022 $
18.Dt PKCS7_FINAL 3
19.Os
20.Sh NAME
21.Nm PKCS7_final
22.Nd read data from a BIO into a ContentInfo object
23.Sh SYNOPSIS
24.In openssl/pkcs7.h
25.Ft int
26.Fo PKCS7_final
27.Fa "PKCS7 *p7"
28.Fa "BIO *data"
29.Fa "int flags"
30.Fc
31.Sh DESCRIPTION
32.Fn PKCS7_final
33reads
34.Fa data
35and puts it into the appropriate content field of
36.Fa p7
37itself or of its appropriate substructure, which can be of type
38.Vt SignedData ,
39.Vt EnvelopedData ,
40.Vt SignedAndEnvelopedData ,
41.Vt DigestedData ,
42or arbitrary data.
43The
44.Xr PKCS7_dataFinal 3
45manual explains which field exactly the data is put into.
46.Pp
47The following
48.Fa flags
49are recognized:
50.Bl -tag -width PKCS7_BINARY
51.It Dv PKCS7_BINARY
52Copy the data verbatim without changing any bytes.
53By default, line endings are replaced with two-byte
54.Qq \er\en
55sequences (ASCII CR+LF).
56If this flag is set,
57.Dv PKCS7_TEXT
58is ignored.
59.It Dv PKCS7_TEXT
60Prepend
61.Qq Content-Type: text/plain
62followed by a blank line to the data.
63This flag is ignored if
64.Dv PKCS7_BINARY
65is also set.
66.El
67.Pp
68If any other bits are set in
69.Fa flags ,
70for example
71.Dv PKCS7_STREAM
72or
73.Dv PKCS7_PARTIAL ,
74they are ignored, allowing to pass the same
75.Fa flags
76argument that was already passed to
77.Xr PKCS7_sign 3
78or
79.Xr PKCS7_encrypt 3 .
80.Pp
81.Fn PKCS7_final
82is most commonly used to finalize a
83.Fa p7
84object returned from a call to
85.Xr PKCS7_sign 3
86that used
87.Fa flags
88including
89.Dv PKCS7_PARTIAL
90or
91.Dv PKCS7_STREAM .
92With these flags,
93.Xr PKCS7_sign 3
94ignores its
95.Fa data
96argument.
97The partial
98.Fa p7
99object returned can then be customized, for example setting up
100multiple signers or non-default digest algorithms with
101.Xr PKCS7_sign_add_signer 3 ,
102before calling
103.Fn PKCS7_final .
104.Pp
105Similarly,
106.Fn PKCS7_final
107can be used to finalize a
108.Fa p7
109object returned from a call to
110.Xr PKCS7_encrypt 3
111that used
112.Fa flags
113including
114.Dv PKCS7_STREAM .
115.Pp
116Since
117.Fn PKCS7_final
118starts by calling
119.Xr PKCS7_dataInit 3
120internally, using it to finalize a
121.Fa p7
122object containing
123.Vt SignedAndEnvelopedData ,
124.Vt DigestedData ,
125or arbitrary data requires the setup described in the
126.Xr PKCS7_dataInit 3
127manual.
128For
129.Vt SignedData
130and
131.Vt EnvelopedData ,
132such manual setup is also feasible, but it is more easily performed with
133.Xr PKCS7_sign 3
134or
135.Xr PKCS7_encrypt 3 ,
136respectively.
137.Pp
138.Fn PKCS7_final
139is only one among several functions that can be used to finalize
140.Fa p7 ;
141alternatives include
142.Xr SMIME_write_PKCS7 3 ,
143.Xr PEM_write_bio_PKCS7_stream 3 ,
144and
145.Xr i2d_PKCS7_bio_stream 3 .
146.Sh RETURN VALUES
147.Fn PKCS7_final
148returns 1 on success or 0 on failure.
149.Pp
150Possible reasons for failure include:
151.Pp
152.Bl -dash -compact -offset 2n -width 1n
153.It
154.Fa p7
155is
156.Dv NULL .
157.It
158The
159.Fa content
160field of
161.Fa p7
162is empty.
163.It
164The
165.Fa contentType
166of
167.Fa p7
168is unsupported.
169.It
170Signing or digesting is requested and
171.Fa p7
172is not configured to store a detached signature, but does not contain
173the required field to store the content either.
174.It
175At least one signer lacks a usable digest algorithm.
176.It
177A cipher is required but none is configured.
178.It
179Any required operation fails, for example signing or digesting.
180.It
181Memory allocation fails.
182.El
183.Pp
184Signers lacking private keys do not cause failure but are silently skipped.
185.Sh SEE ALSO
186.Xr BIO_new 3 ,
187.Xr i2d_PKCS7_bio_stream 3 ,
188.Xr PEM_write_bio_PKCS7_stream 3 ,
189.Xr PKCS7_add_attribute 3 ,
190.Xr PKCS7_dataFinal 3 ,
191.Xr PKCS7_dataInit 3 ,
192.Xr PKCS7_encrypt 3 ,
193.Xr PKCS7_new 3 ,
194.Xr PKCS7_sign 3 ,
195.Xr SMIME_write_PKCS7 3
196.Sh HISTORY
197.Fn PKCS7_final
198first appeared in OpenSSL 1.0.0 and has been available since
199.Ox 4.9 .
200.Sh CAVEATS
201This function does not support
202.Vt EncryptedData .
diff --git a/src/lib/libcrypto/man/PKCS7_get_signer_info.3 b/src/lib/libcrypto/man/PKCS7_get_signer_info.3
deleted file mode 100644
index 280f373ead..0000000000
--- a/src/lib/libcrypto/man/PKCS7_get_signer_info.3
+++ /dev/null
@@ -1,62 +0,0 @@
1.\" $OpenBSD: PKCS7_get_signer_info.3,v 1.1 2020/06/10 11:43:08 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 10 2020 $
18.Dt PKCS7_GET_SIGNER_INFO 3
19.Os
20.Sh NAME
21.Nm PKCS7_get_signer_info
22.Nd retrieve signerInfos from a SignedData object
23.Sh SYNOPSIS
24.In openssl/pkcs7.h
25.Ft STACK_OF(PKCS7_SIGNER_INFO) *
26.Fn PKCS7_get_signer_info "PKCS7 *p7"
27.Sh DESCRIPTION
28This function retrieves the set of
29.Vt SignerInfo
30structures from the
31.Fa signerInfos
32field of
33.Fa p7 .
34.Pp
35These can subsequently be manipulated with the functions documented in
36.Xr PKCS7_add_attribute 3 .
37.Sh RETURN VALUES
38.Fn PKCS7_get_signer_info
39returns an internal pointer to a
40.Vt STACK_OF(PKCS7_SIGNER_INFO)
41object or
42.Dv NULL
43on failure.
44It fails if
45.Fa p7
46is
47.Dv NULL ,
48if it has no content,
49or if it is of a type other than
50.Vt SignedData
51or
52.Vt SignedAndEnvelopedData .
53.Sh SEE ALSO
54.Xr PKCS7_add_attribute 3 ,
55.Xr PKCS7_final 3 ,
56.Xr PKCS7_new 3 ,
57.Xr PKCS7_sign 3 ,
58.Xr PKCS7_sign_add_signer 3
59.Sh HISTORY
60.Fn PKCS7_get_signer_info
61first appeared in SSLeay 0.8.1 and has been available since
62.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/PKCS7_new.3 b/src/lib/libcrypto/man/PKCS7_new.3
deleted file mode 100644
index 151261a312..0000000000
--- a/src/lib/libcrypto/man/PKCS7_new.3
+++ /dev/null
@@ -1,269 +0,0 @@
1.\" $OpenBSD: PKCS7_new.3,v 1.12 2020/06/10 11:43:08 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 10 2020 $
18.Dt PKCS7_NEW 3
19.Os
20.Sh NAME
21.Nm PKCS7_new ,
22.Nm PKCS7_free ,
23.Nm PKCS7_SIGNED_new ,
24.Nm PKCS7_SIGNED_free ,
25.Nm PKCS7_ENVELOPE_new ,
26.Nm PKCS7_ENVELOPE_free ,
27.Nm PKCS7_SIGN_ENVELOPE_new ,
28.Nm PKCS7_SIGN_ENVELOPE_free ,
29.Nm PKCS7_DIGEST_new ,
30.Nm PKCS7_DIGEST_free ,
31.Nm PKCS7_ENCRYPT_new ,
32.Nm PKCS7_ENCRYPT_free ,
33.Nm PKCS7_ENC_CONTENT_new ,
34.Nm PKCS7_ENC_CONTENT_free ,
35.Nm PKCS7_SIGNER_INFO_new ,
36.Nm PKCS7_SIGNER_INFO_free ,
37.Nm PKCS7_RECIP_INFO_new ,
38.Nm PKCS7_RECIP_INFO_free ,
39.Nm PKCS7_ISSUER_AND_SERIAL_new ,
40.Nm PKCS7_ISSUER_AND_SERIAL_free
41.Nd PKCS#7 data structures
42.Sh SYNOPSIS
43.In openssl/pkcs7.h
44.Ft PKCS7 *
45.Fn PKCS7_new void
46.Ft void
47.Fn PKCS7_free "PKCS7 *p7"
48.Ft PKCS7_SIGNED *
49.Fn PKCS7_SIGNED_new void
50.Ft void
51.Fn PKCS7_SIGNED_free "PKCS7_SIGNED *signed"
52.Ft PKCS7_ENVELOPE *
53.Fn PKCS7_ENVELOPE_new void
54.Ft void
55.Fn PKCS7_ENVELOPE_free "PKCS7_ENVELOPE *envelope"
56.Ft PKCS7_SIGN_ENVELOPE *
57.Fn PKCS7_SIGN_ENVELOPE_new void
58.Ft void
59.Fn PKCS7_SIGN_ENVELOPE_free "PKCS7_SIGN_ENVELOPE *signed_envelope"
60.Ft PKCS7_DIGEST *
61.Fn PKCS7_DIGEST_new void
62.Ft void
63.Fn PKCS7_DIGEST_free "PKCS7_DIGEST *digested"
64.Ft PKCS7_ENCRYPT *
65.Fn PKCS7_ENCRYPT_new void
66.Ft void
67.Fn PKCS7_ENCRYPT_free "PKCS7_ENCRYPT *encrypted"
68.Ft PKCS7_ENC_CONTENT *
69.Fn PKCS7_ENC_CONTENT_new void
70.Ft void
71.Fn PKCS7_ENC_CONTENT_free "PKCS7_ENC_CONTENT *content"
72.Ft PKCS7_SIGNER_INFO *
73.Fn PKCS7_SIGNER_INFO_new void
74.Ft void
75.Fn PKCS7_SIGNER_INFO_free "PKCS7_SIGNER_INFO *signer"
76.Ft PKCS7_RECIP_INFO *
77.Fn PKCS7_RECIP_INFO_new void
78.Ft void
79.Fn PKCS7_RECIP_INFO_free "PKCS7_RECIP_INFO *recip"
80.Ft PKCS7_ISSUER_AND_SERIAL *
81.Fn PKCS7_ISSUER_AND_SERIAL_new void
82.Ft void
83.Fn PKCS7_ISSUER_AND_SERIAL_free "PKCS7_ISSUER_AND_SERIAL *cert"
84.Sh DESCRIPTION
85PKCS#7 is an ASN.1-based format for transmitting data that has
86cryptography applied to it, in particular signed and encrypted data.
87.Pp
88.Fn PKCS7_new
89allocates and initializes an empty
90.Vt PKCS7
91object, representing an ASN.1
92.Vt ContentInfo
93structure defined in RFC 2315 section 7.
94It is the top-level data structure able to hold any kind of content
95that can be transmitted using PKCS#7.
96It can be used recursively in
97.Vt PKCS7_SIGNED
98and
99.Vt PKCS7_DIGEST
100objects.
101.Fn PKCS7_free
102frees
103.Fa p7 .
104.Pp
105.Fn PKCS7_SIGNED_new
106allocates and initializes an empty
107.Vt PKCS7_SIGNED
108object, representing an ASN.1
109.Vt SignedData
110structure defined in RFC 2315 section 9.
111It can be used inside
112.Vt PKCS7
113objects and holds any kind of content together with signatures by
114zero or more signers and information about the signing algorithm
115and certificates used.
116.Fn PKCS7_SIGNED_free
117frees
118.Fa signed .
119.Pp
120.Fn PKCS7_ENVELOPE_new
121allocates and initializes an empty
122.Vt PKCS7_ENVELOPE
123object, representing an ASN.1
124.Vt EnvelopedData
125structure defined in RFC 2315 section 10.
126It can be used inside
127.Vt PKCS7
128objects and holds any kind of encrypted content together with
129content-encryption keys for one or more recipients.
130.Fn PKCS7_ENVELOPE_free
131frees
132.Fa envelope .
133.Pp
134.Fn PKCS7_SIGN_ENVELOPE_new
135allocates and initializes an empty
136.Vt PKCS7_SIGN_ENVELOPE
137object, representing an ASN.1
138.Vt SignedAndEnvelopedData
139structure defined in RFC 2315 section 11.
140It can be used inside
141.Vt PKCS7
142objects and holds any kind of encrypted content together with
143signatures by one or more signers, information about the signing
144algorithm and certificates used, and content-encryption keys for
145one or more recipients.
146.Fn PKCS7_SIGN_ENVELOPE_free
147frees
148.Fa signed_envelope .
149.Pp
150.Fn PKCS7_DIGEST_new
151allocates and initializes an empty
152.Vt PKCS7_DIGEST
153object, representing an ASN.1
154.Vt DigestedData
155structure defined in RFC 2315 section 12.
156It can be used inside
157.Vt PKCS7
158objects and holds any kind of content together with a message digest
159for checking its integrity and information about the algorithm used.
160.Fn PKCS7_DIGEST_free
161frees
162.Fa digested .
163.Pp
164.Fn PKCS7_ENCRYPT_new
165allocates and initializes an empty
166.Vt PKCS7_ENCRYPT
167object, representing an ASN.1
168.Vt EncryptedData
169structure defined in RFC 2315 section 13.
170It can be used inside
171.Vt PKCS7
172objects and holds any kind of encrypted content.
173Keys are not included and need to be communicated separately.
174.Fn PKCS7_ENCRYPT_free
175frees
176.Fa encrypted .
177.Pp
178.Fn PKCS7_ENC_CONTENT_new
179allocates and initializes an empty
180.Vt PKCS7_ENC_CONTENT
181object, representing an ASN.1
182.Vt EncryptedContentInfo
183structure defined in RFC 2315 section 10.1.
184It can be used inside
185.Vt PKCS7_ENVELOPE ,
186.Vt PKCS7_SIGN_ENVELOPE ,
187and
188.Vt PKCS7_ENCRYPT
189objects and holds encrypted content together with information about
190the encryption algorithm used.
191.Fn PKCS7_ENC_CONTENT_free
192frees
193.Fa content .
194.Pp
195.Fn PKCS7_SIGNER_INFO_new
196allocates and initializes an empty
197.Vt PKCS7_SIGNER_INFO
198object, representing an ASN.1
199.Vt SignerInfo
200structure defined in RFC 2315 section 9.2.
201It can be used inside
202.Vt PKCS7_SIGNED
203and
204.Vt PKCS7_SIGN_ENVELOPE
205objects and holds a signature together with information about the
206signer and the algorithms used.
207.Fn PKCS7_SIGNER_INFO_free
208frees
209.Fa signer .
210.Pp
211.Fn PKCS7_RECIP_INFO_new
212allocates and initializes an empty
213.Vt PKCS7_RECIP_INFO
214object, representing an ASN.1
215.Vt RecipientInfo
216structure defined in RFC 2315 section 10.2.
217It can be used inside
218.Vt PKCS7_ENVELOPE
219and
220.Vt PKCS7_SIGN_ENVELOPE
221objects and holds a content-encryption key together with information
222about the intended recipient and the key encryption algorithm used.
223.Fn PKCS7_RECIP_INFO_free
224frees
225.Fa recip .
226.Pp
227.Fn PKCS7_ISSUER_AND_SERIAL_new
228allocates and initializes an empty
229.Vt PKCS7_ISSUER_AND_SERIAL
230object, representing an ASN.1
231.Vt IssuerAndSerialNumber
232structure defined in RFC 2315 section 6.7.
233It can be used inside
234.Vt PKCS7_SIGNER_INFO
235and
236.Vt PKCS7_RECIP_INFO
237objects and identifies a certificate by holding the distinguished
238name of the certificate issuer and an issuer-specific certificate
239serial number.
240.Fn PKCS7_ISSUER_AND_SERIAL_free
241frees
242.Fa cert .
243.Sh SEE ALSO
244.Xr crypto 3 ,
245.Xr d2i_PKCS7 3 ,
246.Xr i2d_PKCS7_bio_stream 3 ,
247.Xr PEM_read_PKCS7 3 ,
248.Xr PEM_write_bio_PKCS7_stream 3 ,
249.Xr PKCS7_add_attribute 3 ,
250.Xr PKCS7_dataFinal 3 ,
251.Xr PKCS7_dataInit 3 ,
252.Xr PKCS7_decrypt 3 ,
253.Xr PKCS7_encrypt 3 ,
254.Xr PKCS7_final 3 ,
255.Xr PKCS7_get_signer_info 3 ,
256.Xr PKCS7_ISSUER_AND_SERIAL_digest 3 ,
257.Xr PKCS7_set_content 3 ,
258.Xr PKCS7_set_type 3 ,
259.Xr PKCS7_sign 3 ,
260.Xr PKCS7_sign_add_signer 3 ,
261.Xr PKCS7_verify 3 ,
262.Xr SMIME_read_PKCS7 3 ,
263.Xr SMIME_write_PKCS7 3
264.Sh STANDARDS
265RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5
266.Sh HISTORY
267These functions first appeared in SSLeay 0.5.1
268and have been available since
269.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/PKCS7_set_content.3 b/src/lib/libcrypto/man/PKCS7_set_content.3
deleted file mode 100644
index fa057341d5..0000000000
--- a/src/lib/libcrypto/man/PKCS7_set_content.3
+++ /dev/null
@@ -1,120 +0,0 @@
1.\" $OpenBSD: PKCS7_set_content.3,v 1.2 2020/05/24 12:37:30 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: May 24 2020 $
18.Dt PKCS7_SET_CONTENT 3
19.Os
20.Sh NAME
21.Nm PKCS7_set_content ,
22.Nm PKCS7_content_new
23.Nd set the nested contentInfo in a PKCS#7 structure
24.Sh SYNOPSIS
25.In openssl/pkcs7.h
26.Ft int
27.Fo PKCS7_set_content
28.Fa "PKCS7 *outer"
29.Fa "PKCS7 *inner"
30.Fc
31.Ft int
32.Fo PKCS7_content_new
33.Fa "PKCS7 *outer"
34.Fa "int inner_type"
35.Fc
36.Sh DESCRIPTION
37If the
38.Fa contentType
39of the
40.Fa outer
41PKCS7 structure is
42.Vt SignedData
43or
44.Vt DigestedData ,
45.Fn PKCS7_set_content
46sets the
47.Fa contentInfo
48field of the
49.Fa content
50field of
51.Fa outer
52to
53.Fa inner ,
54without copying
55.Fa inner .
56If there was previous
57.Fa contentInfo ,
58it is freed rather than overwritten.
59The rest of the internal state of
60.Fa outer
61and of its
62.Fa content
63remains unchanged.
64.Pp
65.Fn PKCS7_content_new
66is similar except that it first allocates and initializes a new, empty
67.Fa inner
68object of the given
69.Fa inner_type
70using
71.Xr PKCS7_new 3
72and
73.Xr PKCS7_set_type 3 .
74The
75.Fa inner_type
76can be any of the NIDs listed in the
77.Xr PKCS7_set_type 3
78manual.
79.Sh RETURN VALUES
80These functions return 1 on success or 0 on failure.
81They fail if the
82.Fa contentType
83of
84.Fa outer
85is unsupported.
86.Fn PKCS7_content_new
87can also fail when memory is exhausted.
88In case of failure,
89.Fa outer
90remains unchanged.
91.Sh SEE ALSO
92.Xr PKCS7_dataInit 3 ,
93.Xr PKCS7_new 3 ,
94.Xr PKCS7_set_type 3 ,
95.Xr PKCS7_sign 3
96.Sh STANDARDS
97RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5
98.Bl -bullet -compact -offset 1n -width 1n
99.It
100Section 7. General syntax
101.It
102Section 9. Signed-data content type
103.It
104Section 12.\& Digested-data content type
105.El
106.Sh HISTORY
107These functions first appeared in SSLeay 0.8.1
108and have been available since
109.Ox 2.4 .
110.Sh CAVEATS
111Despite the function names, these functions do not set the
112.Fa content
113field of
114.Fa outer ,
115but only the
116.Fa contentInfo
117field inside it.
118The rest of the
119.Fa content
120remains unchanged.
diff --git a/src/lib/libcrypto/man/PKCS7_set_type.3 b/src/lib/libcrypto/man/PKCS7_set_type.3
deleted file mode 100644
index f414b128a2..0000000000
--- a/src/lib/libcrypto/man/PKCS7_set_type.3
+++ /dev/null
@@ -1,119 +0,0 @@
1.\" $OpenBSD: PKCS7_set_type.3,v 1.2 2020/05/20 11:40:26 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: May 20 2020 $
18.Dt PKCS7_SET_TYPE 3
19.Os
20.Sh NAME
21.Nm PKCS7_set_type ,
22.Nm PKCS7_set0_type_other
23.Nd initialize type of PKCS#7 ContentInfo
24.Sh SYNOPSIS
25.In openssl/pkcs7.h
26.Ft int
27.Fo PKCS7_set_type
28.Fa "PKCS7 *p7"
29.Fa "int type"
30.Fc
31.Ft int
32.Fo PKCS7_set0_type_other
33.Fa "PKCS7 *p7"
34.Fa "int type"
35.Fa "ASN1_TYPE *content"
36.Fc
37.Sh DESCRIPTION
38These functions set the
39.Fa type
40of an unused
41.Vt ContentInfo
42structure
43.Fa p7 .
44.Pp
45The function
46.Fn PKCS7_set_type
47also allocates and initializes an empty child object in
48.Fa p7 .
49The
50.Fa type
51argument can be any of these NIDs,
52creating a child object of the indicated data type:
53.Pp
54.Bl -column NID_pkcs7_signedAndEnveloped PKCS7_SIGN_ENVELOPE n.a. -compact
55.It Fa type No argument Ta data type of child Ta version
56.It Dv NID_pkcs7_data Ta Vt ASN1_OCTET_STRING Ta n.a.
57.It Dv NID_pkcs7_digest Ta Vt PKCS7_DIGEST Ta 0
58.It Dv NID_pkcs7_encrypted Ta Vt PKCS7_ENCRYPT Ta 0
59.It Dv NID_pkcs7_enveloped Ta Vt PKCS7_ENVELOPE Ta 0
60.It Dv NID_pkcs7_signed Ta Vt PKCS7_SIGNED Ta 1
61.It Dv NID_pkcs7_signedAndEnveloped Ta Vt PKCS7_SIGN_ENVELOPE Ta 1
62.El
63.Pp
64If the provided
65.Fa type
66is invalid,
67.Fa p7
68remains unchanged and
69.Fn PKCS7_set_type
70fails.
71.Pp
72If memory allocation fails,
73.Fn PKCS7_set_type
74fails and
75.Fa p7
76may remain in an inconsistent state.
77.Pp
78The function
79.Fn PKCS7_set0_type_other
80accepts an arbitrary NID as the
81.Fa type
82and also sets the
83.Fa content ,
84neither checking it in any way nor copying it.
85.Pp
86For both functions, the rest of the internal state of
87.Fa p7
88remains unchanged.
89.Sh RETURN VALUES
90The function
91.Fn PKCS7_set_type
92returns 1 on success or 0 on failure.
93.Pp
94The function
95.Fn PKCS7_set0_type_other
96does no error handling at all and always returns 1.
97.Sh SEE ALSO
98.Xr ASN1_OCTET_STRING_new 3 ,
99.Xr ASN1_TYPE_new 3 ,
100.Xr PKCS7_encrypt 3 ,
101.Xr PKCS7_new 3 ,
102.Xr PKCS7_set_content 3 ,
103.Xr PKCS7_sign 3
104.Sh HISTORY
105The function
106.Fn PKCS7_set_type
107first appeared in SSLeay 0.8.1 and
108.Fn PKCS7_set0_type_other
109in OpenSSL 0.9.8.
110Both have been available since
111.Ox 2.4 .
112.Sh CAVEATS
113If
114.Fa p7
115has already been in use before being passed to one of these functions,
116it will report success even though it leaks memory.
117Later on, if other functions try to use
118.Fa p7
119in its former role, they are likely to misbehave.
diff --git a/src/lib/libcrypto/man/PKCS7_sign.3 b/src/lib/libcrypto/man/PKCS7_sign.3
deleted file mode 100644
index 37257e60fd..0000000000
--- a/src/lib/libcrypto/man/PKCS7_sign.3
+++ /dev/null
@@ -1,251 +0,0 @@
1.\" $OpenBSD: PKCS7_sign.3,v 1.13 2020/06/10 11:43:08 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2003, 2006-2009, 2015 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: June 10 2020 $
53.Dt PKCS7_SIGN 3
54.Os
55.Sh NAME
56.Nm PKCS7_sign
57.Nd create a PKCS#7 signedData structure
58.Sh SYNOPSIS
59.In openssl/pkcs7.h
60.Ft PKCS7 *
61.Fo PKCS7_sign
62.Fa "X509 *signcert"
63.Fa "EVP_PKEY *pkey"
64.Fa "STACK_OF(X509) *certs"
65.Fa "BIO *data"
66.Fa "int flags"
67.Fc
68.Sh DESCRIPTION
69.Fn PKCS7_sign
70creates and returns a PKCS#7 signedData structure.
71.Fa signcert
72is the certificate to sign with,
73.Fa pkey
74is the corresponding private key.
75.Fa certs
76is an optional additional set of certificates to include in the PKCS#7
77structure (for example any intermediate CAs in the chain).
78.Pp
79The data to be signed is read from
80.Vt BIO
81.Fa data .
82.Pp
83.Fa flags
84is an optional set of flags.
85.Pp
86Any of the following flags (OR'ed together) can be passed in the
87.Fa flags
88parameter.
89.Pp
90Many S/MIME clients expect the signed content to include valid MIME
91headers.
92If the
93.Dv PKCS7_TEXT
94flag is set, MIME headers for type
95.Sy text/plain
96are prepended to the data.
97.Pp
98If
99.Dv PKCS7_NOCERTS
100is set, the signer's certificate will not be included in the PKCS7
101structure, though the signer's certificate must still be supplied in the
102.Fa signcert
103parameter.
104This can reduce the size of the signature if the signer's certificate can
105be obtained by other means: for example a previously signed message.
106.Pp
107The data being signed is included in the
108.Vt PKCS7
109structure, unless
110.Dv PKCS7_DETACHED
111is set, in which case it is omitted.
112This is used for PKCS7 detached signatures which are used in S/MIME
113plaintext signed messages for example.
114.Pp
115Normally the supplied content is translated into MIME canonical format
116(as required by the S/MIME specifications).
117If
118.Dv PKCS7_BINARY
119is set, no translation occurs.
120This option should be used if the supplied data is in binary format;
121otherwise, the translation will corrupt it.
122.Pp
123The signedData structure includes several PKCS#7 authenticatedAttributes
124including the signing time, the PKCS#7 content type and the supported
125list of ciphers in an SMIMECapabilities attribute.
126If
127.Dv PKCS7_NOATTR
128is set, then no authenticatedAttributes will be used.
129If
130.Dv PKCS7_NOSMIMECAP
131is set, then just the SMIMECapabilities are omitted.
132.Pp
133If present, the SMIMECapabilities attribute indicates support for the
134following algorithms: triple DES, 128-bit RC2, 64-bit RC2, DES
135and 40-bit RC2.
136If any of these algorithms is disabled then it will not be included.
137.Pp
138If the flags
139.Dv PKCS7_STREAM
140is set, then the returned
141.Vt PKCS7
142structure is just initialized ready to perform the signing operation.
143The signing is however
144.Sy not
145performed and the data to be signed is not read from the
146.Fa data
147parameter.
148Signing is deferred until after the data has been written.
149In this way data can be signed in a single pass.
150.Pp
151If the
152.Dv PKCS7_PARTIAL
153flag is set, a partial
154.Vt PKCS7
155structure is output to which additional signers and capabilities can be
156added before finalization.
157.Pp
158If the flag
159.Dv PKCS7_STREAM
160is set, the returned
161.Vt PKCS7
162structure is
163.Sy not
164complete and outputting its contents via a function that does not
165properly finalize the
166.Vt PKCS7
167structure will give unpredictable results.
168.Pp
169Several functions including
170.Xr PKCS7_final 3 ,
171.Xr SMIME_write_PKCS7 3 ,
172.Xr PEM_write_bio_PKCS7_stream 3 ,
173and
174.Xr i2d_PKCS7_bio_stream 3
175finalize the structure.
176Alternatively finalization can be performed by obtaining the streaming
177ASN.1
178.Vt BIO
179directly using
180.Fn BIO_new_PKCS7 .
181.Pp
182If a signer is specified, it will use the default digest for the
183signing algorithm.
184This is
185.Sy SHA1
186for both RSA and DSA keys.
187.Pp
188In OpenSSL 1.0.0, the
189.Fa certs ,
190.Fa signcert ,
191and
192.Fa pkey
193parameters can all be
194.Dv NULL
195if the
196.Dv PKCS7_PARTIAL
197flag is set.
198One or more signers can be added using the function
199.Xr PKCS7_sign_add_signer 3
200and attributes can be added using the functions described in
201.Xr PKCS7_add_attribute 3 .
202.Xr PKCS7_final 3
203must also be called to finalize the structure if streaming is not
204enabled.
205Alternative signing digests can also be specified using this method.
206.Pp
207In OpenSSL 1.0.0, if
208.Fa signcert
209and
210.Fa pkey
211are
212.Dv NULL ,
213then a certificate-only PKCS#7 structure is output.
214.Pp
215In versions of OpenSSL before 1.0.0 the
216.Fa signcert
217and
218.Fa pkey
219parameters must
220.Sy NOT
221be
222.Dv NULL .
223.Sh RETURN VALUES
224.Fn PKCS7_sign
225returns either a valid
226.Vt PKCS7
227structure or
228.Dv NULL
229if an error occurred.
230The error can be obtained from
231.Xr ERR_get_error 3 .
232.Sh SEE ALSO
233.Xr PKCS7_add_attribute 3 ,
234.Xr PKCS7_encrypt 3 ,
235.Xr PKCS7_final 3 ,
236.Xr PKCS7_get_signer_info 3 ,
237.Xr PKCS7_new 3 ,
238.Xr PKCS7_sign_add_signer 3 ,
239.Xr PKCS7_verify 3
240.Sh HISTORY
241.Fn PKCS7_sign
242first appeared in OpenSSL 0.9.5 and have been available since
243.Ox 2.7 .
244.Pp
245The
246.Dv PKCS7_PARTIAL
247and
248.Dv PKCS7_STREAM
249flags were added in OpenSSL 1.0.0.
250.Sh BUGS
251Some advanced attributes such as counter signatures are not supported.
diff --git a/src/lib/libcrypto/man/PKCS7_sign_add_signer.3 b/src/lib/libcrypto/man/PKCS7_sign_add_signer.3
deleted file mode 100644
index 195d6388c9..0000000000
--- a/src/lib/libcrypto/man/PKCS7_sign_add_signer.3
+++ /dev/null
@@ -1,187 +0,0 @@
1.\" $OpenBSD: PKCS7_sign_add_signer.3,v 1.13 2020/06/10 11:43:08 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2007, 2008, 2009, 2015 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: June 10 2020 $
53.Dt PKCS7_SIGN_ADD_SIGNER 3
54.Os
55.Sh NAME
56.Nm PKCS7_sign_add_signer
57.Nd add a signer to a SignedData structure
58.Sh SYNOPSIS
59.In openssl/pkcs7.h
60.Ft PKCS7_SIGNER_INFO *
61.Fo PKCS7_sign_add_signer
62.Fa "PKCS7 *p7"
63.Fa "X509 *signcert"
64.Fa "EVP_PKEY *pkey"
65.Fa "const EVP_MD *md"
66.Fa "int flags"
67.Fc
68.Sh DESCRIPTION
69.Fn PKCS7_sign_add_signer
70adds a signer with certificate
71.Fa signcert
72and private key
73.Fa pkey
74using message digest
75.Fa md
76to a
77.Vt PKCS7
78signed data structure
79.Fa p7 .
80.Pp
81The
82.Vt PKCS7
83structure should be obtained from an initial call to
84.Xr PKCS7_sign 3
85with the flag
86.Dv PKCS7_PARTIAL
87set or, in the case or re-signing, a valid
88.Vt PKCS7
89signed data structure.
90.Pp
91If the
92.Fa md
93parameter is
94.Dv NULL ,
95then the default digest for the public key algorithm will be used.
96.Pp
97Unless the
98.Dv PKCS7_REUSE_DIGEST
99flag is set, the returned
100.Dv PKCS7
101structure is not complete and must be
102finalized either by streaming (if applicable) or by a call to
103.Xr PKCS7_final 3 .
104.Pp
105The main purpose of this function is to provide finer control over a
106PKCS#7 signed data structure where the simpler
107.Xr PKCS7_sign 3
108function defaults are not appropriate, for example if multiple
109signers or non default digest algorithms are needed.
110.Pp
111Any of the following flags (OR'ed together) can be passed in the
112.Fa flags
113parameter.
114.Pp
115If
116.Dv PKCS7_REUSE_DIGEST
117is set, then an attempt is made to copy the content digest value from the
118.Vt PKCS7
119structure: to add a signer to an existing structure.
120An error occurs if a matching digest value cannot be found to copy.
121The returned
122.Vt PKCS7
123structure will be valid and finalized when this flag is set.
124.Pp
125If
126.Dv PKCS7_PARTIAL
127is set in addition to
128.Dv PKCS7_REUSE_DIGEST ,
129then the
130.Dv PKCS7_SIGNER_INO
131structure will not be finalized, so additional attributes can be added.
132In this case an explicit call to
133.Fn PKCS7_SIGNER_INFO_sign
134is needed to finalize it.
135.Pp
136If
137.Dv PKCS7_NOCERTS
138is set, the signer's certificate will not be included in the
139.Vt PKCS7
140structure, though the signer's certificate must still be supplied in the
141.Fa signcert
142parameter.
143This can reduce the size of the signature if the signers certificate can
144be obtained by other means: for example a previously signed message.
145.Pp
146The signedData structure includes several PKCS#7 authenticatedAttributes
147including the signing time, the PKCS#7 content type and the supported
148list of ciphers in an SMIMECapabilities attribute.
149If
150.Dv PKCS7_NOATTR
151is set, then no authenticatedAttributes will be used.
152If
153.Dv PKCS7_NOSMIMECAP
154is set, then just the SMIMECapabilities are omitted.
155.Pp
156If present, the SMIMECapabilities attribute indicates support for the
157following algorithms: triple DES, 128-bit RC2, 64-bit RC2, DES
158and 40-bit RC2.
159If any of these algorithms is disabled, then it will not be included.
160.Pp
161.Fn PKCS7_sign_add_signer
162returns an internal pointer to the
163.Vt PKCS7_SIGNER_INFO
164structure just added, which can be used to set additional attributes
165with the functions described in
166.Xr PKCS7_add_attribute 3
167before it is finalized.
168.Sh RETURN VALUES
169.Fn PKCS7_sign_add_signer
170returns an internal pointer to the
171.Vt PKCS7_SIGNER_INFO
172structure just added or
173.Dv NULL
174if an error occurs.
175In some cases of failure, the reason can be determined with
176.Xr ERR_get_error 3 .
177.Sh SEE ALSO
178.Xr EVP_DigestInit 3 ,
179.Xr PKCS7_add_attribute 3 ,
180.Xr PKCS7_final 3 ,
181.Xr PKCS7_get_signer_info 3 ,
182.Xr PKCS7_new 3 ,
183.Xr PKCS7_sign 3
184.Sh HISTORY
185.Fn PKCS7_sign_add_signer
186first appeared in OpenSSL 1.0.0 and has been available since
187.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/PKCS7_verify.3 b/src/lib/libcrypto/man/PKCS7_verify.3
deleted file mode 100644
index d091c03dfd..0000000000
--- a/src/lib/libcrypto/man/PKCS7_verify.3
+++ /dev/null
@@ -1,252 +0,0 @@
1.\" $OpenBSD: PKCS7_verify.3,v 1.11 2022/03/31 17:27:17 naddy Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2006, 2013, 2014, 2015 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 31 2022 $
52.Dt PKCS7_VERIFY 3
53.Os
54.Sh NAME
55.Nm PKCS7_verify ,
56.Nm PKCS7_get0_signers
57.Nd verify a PKCS#7 signedData structure
58.Sh SYNOPSIS
59.In openssl/pkcs7.h
60.Ft int
61.Fo PKCS7_verify
62.Fa "PKCS7 *p7"
63.Fa "STACK_OF(X509) *certs"
64.Fa "X509_STORE *store"
65.Fa "BIO *indata"
66.Fa "BIO *out"
67.Fa "int flags"
68.Fc
69.Ft STACK_OF(X509) *
70.Fo PKCS7_get0_signers
71.Fa "PKCS7 *p7"
72.Fa "STACK_OF(X509) *certs"
73.Fa "int flags"
74.Fc
75.Sh DESCRIPTION
76.Fn PKCS7_verify
77verifies a PKCS#7 signedData structure.
78.Fa p7
79is the
80.Vt PKCS7
81structure to verify.
82.Fa certs
83is a set of certificates in which to search for the signer's
84certificate.
85.Fa store
86is a trusted certificate store (used for chain verification).
87.Fa indata
88is the signed data if the content is not present in
89.Fa p7 ,
90that is if it is detached.
91The content is written to
92.Fa out
93if it is not
94.Dv NULL .
95.Pp
96.Fa flags
97is an optional set of flags, which can be used to modify the verify
98operation.
99.Pp
100.Fn PKCS7_get0_signers
101retrieves the signer's certificates from
102.Fa p7 .
103The signers must be freed with
104.Fn sk_X509_free .
105It does
106.Sy not
107check their validity or whether any signatures are valid.
108The
109.Fa certs
110and
111.Fa flags
112parameters have the same meanings as in
113.Fn PKCS7_verify .
114.Pp
115Normally the verify process proceeds as follows.
116.Pp
117Initially some sanity checks are performed on
118.Fa p7 .
119The type of
120.Fa p7
121must be signedData.
122There must be at least one signature on the data and if the content
123is detached,
124.Fa indata
125cannot be
126.Dv NULL .
127.Pp
128An attempt is made to locate all the signer's certificates, first
129looking in the
130.Fa certs
131parameter (if it is not
132.Dv NULL )
133and then looking in any certificates contained in the
134.Fa p7
135structure itself.
136If any signer's certificates cannot be located, the operation fails.
137.Pp
138Each signer's certificate is chain verified using the
139.Sy smimesign
140purpose and the supplied trusted certificate store.
141Any internal certificates in the message are used as untrusted CAs.
142If any chain verify fails, an error code is returned.
143.Pp
144Finally, the signed content is read (and written to
145.Fa out
146if it is not
147.Dv NULL )
148and the signature's checked.
149.Pp
150If all signature's verify correctly then the function is successful.
151.Pp
152Any of the following flags (OR'ed together) can be passed in the
153.Fa flags
154parameter to change the default verify behaviour.
155Only the flag
156.Dv PKCS7_NOINTERN
157is meaningful to
158.Fn PKCS7_get0_signers .
159.Pp
160If
161.Dv PKCS7_NOINTERN
162is set, the certificates in the message itself are not searched when
163locating the signer's certificate.
164This means that all the signer's certificates must be in the
165.Fa certs
166parameter.
167.Pp
168If the
169.Dv PKCS7_TEXT
170flag is set, MIME headers for type
171.Sy text/plain
172are deleted from the content.
173If the content is not of type
174.Sy text/plain ,
175then an error is returned.
176.Pp
177If
178.Dv PKCS7_NOVERIFY
179is set, the signer's certificates are not chain verified.
180.Pp
181If
182.Dv PKCS7_NOCHAIN
183is set, then the certificates contained in the message are not used as
184untrusted CAs.
185This means that the whole verify chain (apart from the signer's
186certificate) must be contained in the trusted store.
187.Pp
188If
189.Dv PKCS7_NOSIGS
190is set, then the signatures on the data are not checked.
191.Pp
192One application of
193.Dv PKCS7_NOINTERN
194is to only accept messages signed by a small number of certificates.
195The acceptable certificates would be passed in the
196.Fa certs
197parameter.
198In this case, if the signer is not one of the certificates supplied in
199.Fa certs ,
200then the verify will fail because the signer cannot be found.
201.Pp
202Care should be taken when modifying the default verify behaviour, for
203example setting
204.Dv PKCS7_NOVERIFY | PKCS7_NOSIGS
205will totally disable all verification and any signed message will be
206considered valid.
207This combination is however useful if one merely wishes to write the
208content to
209.Fa out
210and its validity is not considered important.
211.Pp
212Chain verification should arguably be performed using the signing time
213rather than the current time.
214However since the signing time is supplied by the signer, it cannot be
215trusted without additional evidence (such as a trusted timestamp).
216.Sh RETURN VALUES
217.Fn PKCS7_verify
218returns 1 for a successful verification and 0 or a negative value if
219an error occurs.
220.Pp
221.Fn PKCS7_get0_signers
222returns all signers or
223.Dv NULL
224if an error occurred.
225The signers must be freed with
226.Fn sk_X509_free .
227.Pp
228The error can be obtained from
229.Xr ERR_get_error 3 .
230.Sh SEE ALSO
231.Xr PKCS7_decrypt 3 ,
232.Xr PKCS7_new 3 ,
233.Xr PKCS7_sign 3 ,
234.Xr X509_STORE_new 3
235.Sh HISTORY
236.Fn PKCS7_verify
237and
238.Fn PKCS7_get0_signers
239first appeared in OpenSSL 0.9.5 and have been available since
240.Ox 2.7 .
241.Sh BUGS
242The trusted certificate store is not searched for the signer's
243certificate.
244This is primarily due to the inadequacies of the current
245.Vt X509_STORE
246functionality.
247.Pp
248The lack of single pass processing and the need to hold all data
249in memory as mentioned in
250.Xr PKCS7_sign 3
251also applies to
252.Fn PKCS7_verify .
diff --git a/src/lib/libcrypto/man/PKCS8_PRIV_KEY_INFO_new.3 b/src/lib/libcrypto/man/PKCS8_PRIV_KEY_INFO_new.3
deleted file mode 100644
index 822968f58d..0000000000
--- a/src/lib/libcrypto/man/PKCS8_PRIV_KEY_INFO_new.3
+++ /dev/null
@@ -1,65 +0,0 @@
1.\" $OpenBSD: PKCS8_PRIV_KEY_INFO_new.3,v 1.7 2024/12/06 12:51:13 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 6 2024 $
18.Dt PKCS8_PRIV_KEY_INFO_NEW 3
19.Os
20.Sh NAME
21.Nm PKCS8_PRIV_KEY_INFO_new ,
22.Nm PKCS8_PRIV_KEY_INFO_free
23.Nd PKCS#8 private key information
24.Sh SYNOPSIS
25.In openssl/x509.h
26.Ft PKCS8_PRIV_KEY_INFO *
27.Fn PKCS8_PRIV_KEY_INFO_new void
28.Ft void
29.Fn PKCS8_PRIV_KEY_INFO_free "PKCS8_PRIV_KEY_INFO *key"
30.Sh DESCRIPTION
31.Fn PKCS8_PRIV_KEY_INFO_new
32allocates and initializes an empty
33.Vt PKCS8_PRIV_KEY_INFO
34object, representing an ASN.1
35.Vt PrivateKeyInfo
36structure defined in RFC 5208 section 5.
37It can hold a private key together with information about the
38algorithm to be used with it and optional attributes.
39.Pp
40.Fn PKCS8_PRIV_KEY_INFO_free
41frees
42.Fa key .
43.Sh RETURN VALUES
44.Fn PKCS8_PRIV_KEY_INFO_new
45returns the new
46.Vt PKCS8_PRIV_KEY_INFO
47object or
48.Dv NULL
49if an error occurs.
50.Sh SEE ALSO
51.Xr d2i_PKCS8_PRIV_KEY_INFO 3 ,
52.Xr d2i_PKCS8PrivateKey_bio 3 ,
53.Xr EVP_PKCS82PKEY 3 ,
54.Xr PEM_read_PKCS8_PRIV_KEY_INFO 3 ,
55.Xr PKCS12_parse 3 ,
56.Xr PKCS8_pkey_set0 3 ,
57.Xr X509_ATTRIBUTE_new 3
58.Sh STANDARDS
59RFC 5208: PKCS#8: Private-Key Information Syntax Specification
60.Sh HISTORY
61.Fn PKCS8_PRIV_KEY_INFO_new
62and
63.Fn PKCS8_PRIV_KEY_INFO_free
64first appeared in OpenSSL 0.9.3 and have been available since
65.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/PKCS8_pkey_set0.3 b/src/lib/libcrypto/man/PKCS8_pkey_set0.3
deleted file mode 100644
index f3d5a294c3..0000000000
--- a/src/lib/libcrypto/man/PKCS8_pkey_set0.3
+++ /dev/null
@@ -1,159 +0,0 @@
1.\" $OpenBSD: PKCS8_pkey_set0.3,v 1.3 2024/09/02 07:45:09 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 2 2024 $
18.Dt PKCS8_PKEY_SET0 3
19.Os
20.Sh NAME
21.Nm PKCS8_pkey_set0 ,
22.Nm PKCS8_pkey_get0 ,
23.Nm PKCS8_pkey_add1_attr_by_NID ,
24.Nm PKCS8_pkey_get0_attrs
25.Nd change and inspect PKCS#8 PrivateKeyInfo objects
26.Sh SYNOPSIS
27.In openssl/x509.h
28.Ft int
29.Fo PKCS8_pkey_set0
30.Fa "PKCS8_PRIV_KEY_INFO *keyinfo"
31.Fa "ASN1_OBJECT *aobj"
32.Fa "int version"
33.Fa "int ptype"
34.Fa "void *pval"
35.Fa "unsigned char *data"
36.Fa "int len"
37.Fc
38.Ft int
39.Fo PKCS8_pkey_get0
40.Fa "const ASN1_OBJECT **paobj"
41.Fa "const unsigned char **pdata"
42.Fa "int *plen"
43.Fa "const X509_ALGOR **palgor"
44.Fa "const PKCS8_PRIV_KEY_INFO *keyinfo"
45.Fc
46.Ft int
47.Fo PKCS8_pkey_add1_attr_by_NID
48.Fa "PKCS8_PRIV_KEY_INFO *keyinfo"
49.Fa "int nid"
50.Fa "int type"
51.Fa "const unsigned char *data"
52.Fa "int len"
53.Fc
54.Ft const STACK_OF(X509_ATTRIBUTE) *
55.Fo PKCS8_pkey_get0_attrs
56.Fa "const PKCS8_PRIV_KEY_INFO *keyinfo"
57.Fc
58.Sh DESCRIPTION
59.Fn PKCS8_pkey_set0
60initializes the
61.Fa keyinfo
62object.
63The algorithm is set to
64.Fa aobj
65with the associated parameter type
66.Fa ptype
67and parameter value
68.Fa pval
69using
70.Xr X509_ALGOR_set0 3 ,
71replacing any previous information about the algorithm.
72Unless
73.Fa data
74is
75.Dv NULL ,
76the encoded private key is set to the
77.Fa len
78bytes starting at
79.Fa data
80using
81.Xr ASN1_STRING_set0 3 ,
82not performing any validation.
83If
84.Fa data
85is
86.Dv NULL ,
87the key data remains unchanged.
88If the
89.Fa version
90argument is greater than or equal to 0, it replaces any existing version;
91otherwise, the version remains unchanged.
92If
93.Fa keyinfo
94contains any attributes, they remain unchanged.
95.Pp
96.Fn PKCS8_pkey_get0
97retrieves some information from the
98.Fa keyinfo
99object.
100Internal pointers to the algorithm OID, the
101.Vt AlgorithmIdentifier ,
102and the encoded private key are stored in
103.Pf * Fa paobj ,
104.Pf * Fa palgor ,
105and
106.Pf * Fa pdata ,
107respectively.
108.Dv NULL
109pointers can be passed for any of these three arguments if the respective
110information is not needed.
111Unless
112.Fa pdata
113is
114.Dv NULL ,
115.Pf * Fa plen
116is set to the number of bytes in
117.Pf * Fa pdata .
118.Pp
119.Fn PKCS8_pkey_add1_attr_by_NID
120creates a new X.501 Attribute object using
121.Xr X509_ATTRIBUTE_create_by_NID 3
122and appends it to the attributes of
123.Fa keyinfo .
124.Sh RETURN VALUES
125.Fn PKCS8_pkey_set0
126and
127.Fn PKCS8_pkey_add1_attr_by_NID
128return 1 for success or 0 for failure.
129.Pp
130.Fn PKCS8_pkey_get0
131always returns 1.
132.Pp
133.Fn PKCS8_pkey_get0_attrs
134returns an internal pointer to the array of attributes associated with
135.Fa keyinfo
136or
137.Dv NULL
138if no attributes are set.
139.Sh SEE ALSO
140.Xr ASN1_STRING_set0 3 ,
141.Xr EVP_PKCS82PKEY 3 ,
142.Xr OBJ_nid2obj 3 ,
143.Xr PKCS8_PRIV_KEY_INFO_new 3 ,
144.Xr STACK_OF 3 ,
145.Xr X509_ALGOR_new 3 ,
146.Xr X509_ATTRIBUTE_create_by_NID 3 ,
147.Xr X509_ATTRIBUTE_new 3
148.Sh HISTORY
149.Fn PKCS8_pkey_set0
150and
151.Fn PKCS8_pkey_get0
152first appeared in OpenSSL 1.0.0 and have been available since
153.Ox 4.9 .
154.Pp
155.Fn PKCS8_pkey_add1_attr_by_NID
156and
157.Fn PKCS8_pkey_get0_attrs
158first appeared in OpenSSL 1.1.0 and have been available since
159.Ox 6.4 .
diff --git a/src/lib/libcrypto/man/PKEY_USAGE_PERIOD_new.3 b/src/lib/libcrypto/man/PKEY_USAGE_PERIOD_new.3
deleted file mode 100644
index 40735c6f86..0000000000
--- a/src/lib/libcrypto/man/PKEY_USAGE_PERIOD_new.3
+++ /dev/null
@@ -1,74 +0,0 @@
1.\" $OpenBSD: PKEY_USAGE_PERIOD_new.3,v 1.5 2019/06/06 01:06:59 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 6 2019 $
18.Dt PKEY_USAGE_PERIOD_NEW 3
19.Os
20.Sh NAME
21.Nm PKEY_USAGE_PERIOD_new ,
22.Nm PKEY_USAGE_PERIOD_free
23.Nd X.509 certificate private key usage period extension
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft PKEY_USAGE_PERIOD *
27.Fn PKEY_USAGE_PERIOD_new void
28.Ft void
29.Fn PKEY_USAGE_PERIOD_free "PKEY_USAGE_PERIOD *period"
30.Sh DESCRIPTION
31.Fn PKEY_USAGE_PERIOD_new
32allocates and initializes an empty
33.Vt PKEY_USAGE_PERIOD
34object, representing an ASN.1
35.Vt PrivateKeyUsagePeriod
36structure defined in RFC 3280 section 4.2.1.4.
37It could be used in
38.Vt X509
39certificates to specify a validity period for the private key
40that differed from the validity period of the certificate.
41.Pp
42.Fn PKEY_USAGE_PERIOD_free
43frees
44.Fa period .
45.Sh RETURN VALUES
46.Fn PKEY_USAGE_PERIOD_new
47returns the new
48.Vt PKEY_USAGE_PERIOD
49object or
50.Dv NULL
51if an error occurs.
52.Sh SEE ALSO
53.Xr d2i_PKEY_USAGE_PERIOD 3 ,
54.Xr EXTENDED_KEY_USAGE_new 3 ,
55.Xr X509_CINF_new 3 ,
56.Xr X509_EXTENSION_new 3 ,
57.Xr X509_new 3
58.Sh STANDARDS
59RFC 3280: Internet X.509 Public Key Infrastructure Certificate and
60Certificate Revocation List (CRL) Profile,
61section 4.2.1.4: Private Key Usage Period
62.Pp
63RFC 3280 was obsoleted by RFC 5280, which says: "Section 4.2.1.4
64in RFC 3280, which specified the
65.Vt PrivateKeyUsagePeriod
66certificate extension but deprecated its use, was removed.
67Use of this ISO standard extension is neither deprecated
68nor recommended for use in the Internet PKI."
69.Sh HISTORY
70.Fn PKEY_USAGE_PERIOD_new
71and
72.Fn PKEY_USAGE_PERIOD_free
73first appeared in OpenSSL 0.9.2b and have been available since
74.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/POLICYINFO_new.3 b/src/lib/libcrypto/man/POLICYINFO_new.3
deleted file mode 100644
index 52c004414e..0000000000
--- a/src/lib/libcrypto/man/POLICYINFO_new.3
+++ /dev/null
@@ -1,218 +0,0 @@
1.\" $OpenBSD: POLICYINFO_new.3,v 1.11 2023/05/14 08:03:57 tb Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: May 14 2023 $
18.Dt POLICYINFO_NEW 3
19.Os
20.Sh NAME
21.Nm POLICYINFO_new ,
22.Nm POLICYINFO_free ,
23.Nm CERTIFICATEPOLICIES_new ,
24.Nm CERTIFICATEPOLICIES_free ,
25.Nm POLICYQUALINFO_new ,
26.Nm POLICYQUALINFO_free ,
27.Nm USERNOTICE_new ,
28.Nm USERNOTICE_free ,
29.Nm NOTICEREF_new ,
30.Nm NOTICEREF_free ,
31.Nm POLICY_MAPPING_new ,
32.Nm POLICY_MAPPING_free ,
33.Nm POLICY_CONSTRAINTS_new ,
34.Nm POLICY_CONSTRAINTS_free
35.Nd X.509 certificate policies
36.Sh SYNOPSIS
37.In openssl/x509v3.h
38.Ft POLICYINFO *
39.Fn POLICYINFO_new void
40.Ft void
41.Fn POLICYINFO_free "POLICYINFO *pi"
42.Ft CERTIFICATEPOLICIES *
43.Fn CERTIFICATEPOLICIES_new void
44.Ft void
45.Fn CERTIFICATEPOLICIES_free "CERTIFICATEPOLICIES *pis"
46.Ft POLICYQUALINFO *
47.Fn POLICYQUALINFO_new void
48.Ft void
49.Fn POLICYQUALINFO_free "POLICYQUALINFO *pqi"
50.Ft USERNOTICE *
51.Fn USERNOTICE_new void
52.Ft void
53.Fn USERNOTICE_free "USERNOTICE *usernotice"
54.Ft NOTICEREF *
55.Fn NOTICEREF_new void
56.Ft void
57.Fn NOTICEREF_free "NOTICEREF *noticeref"
58.Ft POLICY_MAPPING *
59.Fn POLICY_MAPPING_new void
60.Ft void
61.Fn POLICY_MAPPING_free "POLICY_MAPPING *pm"
62.Ft POLICY_CONSTRAINTS *
63.Fn POLICY_CONSTRAINTS_new void
64.Ft void
65.Fn POLICY_CONSTRAINTS_free "POLICY_CONSTRAINTS *pc"
66.Sh DESCRIPTION
67X.509 CA and end entity certificates can optionally indicate
68restrictions on their intended use.
69.Pp
70.Fn POLICYINFO_new
71allocates and initializes an empty
72.Vt POLICYINFO
73object, representing an ASN.1
74.Vt PolicyInformation
75structure defined in RFC 5280 section 4.2.1.4.
76It can hold a policy identifier and optional advisory qualifiers.
77.Fn POLICYINFO_free
78frees
79.Fa pi .
80.Pp
81.Fn CERTIFICATEPOLICIES_new
82allocates and initializes an empty
83.Vt CERTIFICATEPOLICIES
84object, which is a
85.Vt STACK_OF(POLICYINFO)
86and represents an ASN.1
87.Vt CertificatePolicies
88structure defined in RFC 5280 section 4.2.1.4.
89It can be used by
90.Vt X509
91objects, both by CA certificates and end entity certificates.
92.Fn CERTIFICATEPOLICIES_free
93frees
94.Fa pis .
95.Pp
96.Fn POLICYQUALINFO_new
97allocates and initializes an empty
98.Vt POLICYQUALINFO
99object, representing an ASN.1
100.Vt PolicyQualifierInfo
101structure defined in RFC 5280 section 4.2.1.4.
102It can be used in
103.Vt POLICYINFO
104and it can hold either a uniform resource identifier of a certification
105practice statement published by the CA, or a pointer to a
106.Vt USERNOTICE
107object, or arbitrary other information.
108.Fn POLICYQUALINFO_free
109frees
110.Fa pqi .
111.Pp
112.Fn USERNOTICE_new
113allocates and initializes an empty
114.Vt USERNOTICE
115object, representing an ASN.1
116.Vt UserNotice
117structure defined in RFC 5280 section 4.2.1.4.
118It can be used in
119.Vt POLICYQUALINFO
120and it can hold either an
121.Vt ASN1_STRING
122intended for display to the user or a pointer to a
123.Vt NOTICEREF
124object.
125.Fn NOTICEREF_free
126frees
127.Fa usernotice .
128.Pp
129.Fn NOTICEREF_new
130allocates and initializes an empty
131.Vt NOTICEREF
132object, representing an ASN.1
133.Vt NoticeReference
134structure defined in RFC 5280 section 4.2.1.4.
135It can be used in
136.Vt USERNOTICE
137and can hold an organization name and a stack of notice numbers.
138.Fn NOTICEREF_free
139frees
140.Fa noticeref .
141.Pp
142.Fn POLICY_MAPPING_new
143allocates and initializes an empty
144.Vt POLICY_MAPPING
145object, representing an ASN.1
146.Vt PolicyMappings
147structure defined in RFC 5280 section 4.2.1.5.
148It can be used in
149.Vt X509
150CA certificates and can hold a list of pairs of policy identifiers,
151declaring one of the policies in each pair as equivalent to the
152other.
153.Fn POLICY_MAPPING_free
154frees
155.Fa pm .
156.Pp
157.Fn POLICY_CONSTRAINTS_new
158allocates and initializes an empty
159.Vt POLICY_CONSTRAINTS
160object, representing an ASN.1
161.Vt PolicyConstraints
162structure defined in RFC 5280 section 4.2.1.11.
163It can be used in
164.Vt X509
165CA certificates to restrict policy mapping and/or to require explicit
166certificate policies in subsequent intermediate certificates in the
167certification path.
168.Fn POLICY_CONSTRAINTS_free
169frees
170.Fa pc .
171.Sh RETURN VALUES
172The constructor functions return a new object of the respective
173type or
174.Dv NULL
175if an error occurs.
176.Sh SEE ALSO
177.Xr BASIC_CONSTRAINTS_new 3 ,
178.Xr d2i_POLICYINFO 3 ,
179.Xr NAME_CONSTRAINTS_new 3 ,
180.Xr X509_EXTENSION_new 3 ,
181.Xr X509_get_extension_flags 3 ,
182.Xr X509_new 3
183.Sh STANDARDS
184RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
185Certificate Revocation List (CRL) Profile:
186.Bl -dash -compact
187.It
188section 4.2.1.4: Certificate Policies
189.It
190section 4.2.1.5: Policy Mappings
191.It
192section 4.2.1.11: Policy Constraints
193.El
194.Sh HISTORY
195.Fn POLICYINFO_new ,
196.Fn POLICYINFO_free ,
197.Fn CERTIFICATEPOLICIES_new ,
198.Fn CERTIFICATEPOLICIES_free ,
199.Fn POLICYQUALINFO_new ,
200.Fn POLICYQUALINFO_free ,
201.Fn USERNOTICE_new ,
202.Fn USERNOTICE_free ,
203.Fn NOTICEREF_new ,
204and
205.Fn NOTICEREF_free
206first appeared in OpenSSL 0.9.3 and have been available since
207.Ox 2.6 .
208.Pp
209.Fn POLICY_MAPPING_new ,
210.Fn POLICY_MAPPING_free ,
211.Fn POLICY_CONSTRAINTS_new ,
212and
213.Fn POLICY_CONSTRAINTS_free
214first appeared in OpenSSL 0.9.8 and have been available since
215.Ox 4.5 .
216.Sh BUGS
217This is a lot of nested data structures, but most of them are
218designed to have almost no effect.
diff --git a/src/lib/libcrypto/man/RAND_add.3 b/src/lib/libcrypto/man/RAND_add.3
deleted file mode 100644
index 5404f696a3..0000000000
--- a/src/lib/libcrypto/man/RAND_add.3
+++ /dev/null
@@ -1,73 +0,0 @@
1.\" $OpenBSD: RAND_add.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $
2.\" content checked up to: OpenSSL c16de9d8 Aug 31 23:16:22 2017 +0200
3.\"
4.\" Copyright (c) 2014 Miod Vallat <miod@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: March 27 2018 $
19.Dt RAND_ADD 3
20.Os
21.Sh NAME
22.Nm RAND_add ,
23.Nm RAND_cleanup ,
24.Nm RAND_poll ,
25.Nm RAND_seed ,
26.Nm RAND_status
27.Nd manipulate the PRNG state
28.Sh SYNOPSIS
29.In openssl/rand.h
30.Ft void
31.Fo RAND_add
32.Fa "const void *buf"
33.Fa "int num"
34.Fa "double entropy"
35.Fc
36.Ft void
37.Fn RAND_cleanup void
38.Ft int
39.Fn RAND_poll void
40.Ft void
41.Fo RAND_seed
42.Fa "const void *buf"
43.Fa "int num"
44.Fc
45.Ft int
46.Fn RAND_status void
47.Sh DESCRIPTION
48These functions used to allow for the state of the random number
49generator to be controlled by external sources.
50.Pp
51They are kept for ABI compatibility but are no longer functional, and
52should not be used in new programs.
53.Sh RETURN VALUES
54.Fn RAND_poll
55and
56.Fn RAND_status
57always return 1.
58.Sh HISTORY
59.Fn RAND_cleanup
60and
61.Fn RAND_seed
62first appeared in SSLeay 0.5.1 and have been available since
63.Ox 2.4 .
64.Pp
65.Fn RAND_add
66and
67.Fn RAND_status
68first appeared in OpenSSL 0.9.5 and have been available since
69.Ox 2.7 .
70.Pp
71.Fn RAND_poll
72first appeared in OpenSSL 0.9.6 and has been available since
73.Ox 2.9 .
diff --git a/src/lib/libcrypto/man/RAND_bytes.3 b/src/lib/libcrypto/man/RAND_bytes.3
deleted file mode 100644
index 19427a82df..0000000000
--- a/src/lib/libcrypto/man/RAND_bytes.3
+++ /dev/null
@@ -1,108 +0,0 @@
1.\" $OpenBSD: RAND_bytes.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 27 2018 $
52.Dt RAND_BYTES 3
53.Os
54.Sh NAME
55.Nm RAND_bytes ,
56.Nm RAND_pseudo_bytes
57.Nd generate random data
58.Sh SYNOPSIS
59.In openssl/rand.h
60.Ft int
61.Fo RAND_bytes
62.Fa "unsigned char *buf"
63.Fa "int num"
64.Fc
65.Ft int
66.Fo RAND_pseudo_bytes
67.Fa "unsigned char *buf"
68.Fa "int num"
69.Fc
70.Sh DESCRIPTION
71These functions are deprecated and only retained for compatibility
72with legacy application programs.
73Use
74.Xr arc4random_buf 3
75instead.
76.Pp
77.Fn RAND_bytes
78puts
79.Fa num
80cryptographically strong pseudo-random bytes into
81.Fa buf .
82.Pp
83.Fn RAND_pseudo_bytes
84puts
85.Fa num
86pseudo-random bytes into
87.Fa buf .
88Pseudo-random byte sequences generated by
89.Fn RAND_pseudo_bytes
90will be unique if they are of sufficient length, but are not necessarily
91unpredictable.
92They can be used for non-cryptographic purposes and for certain purposes
93in cryptographic protocols, but usually not for key generation etc.
94.Sh RETURN VALUES
95.Fn RAND_bytes
96returns 1.
97.Fn RAND_pseudo_bytes
98returns 1.
99.Sh HISTORY
100.Fn RAND_bytes
101first appeared in SSLeay 0.5.1 and has been available since
102.Ox 2.4 .
103It has a return value since OpenSSL 0.9.5 and
104.Ox 2.7 .
105.Pp
106.Fn RAND_pseudo_bytes
107first appeared in OpenSSL 0.9.5 and has been available since
108.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/RAND_load_file.3 b/src/lib/libcrypto/man/RAND_load_file.3
deleted file mode 100644
index 9227e2721b..0000000000
--- a/src/lib/libcrypto/man/RAND_load_file.3
+++ /dev/null
@@ -1,119 +0,0 @@
1.\" $OpenBSD: RAND_load_file.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2001 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 27 2018 $
52.Dt RAND_LOAD_FILE 3
53.Os
54.Sh NAME
55.Nm RAND_file_name ,
56.Nm RAND_load_file ,
57.Nm RAND_write_file
58.Nd PRNG seed file
59.Sh SYNOPSIS
60.In openssl/rand.h
61.Ft const char *
62.Fo RAND_file_name
63.Fa "char *buf"
64.Fa "size_t num"
65.Fc
66.Ft int
67.Fo RAND_load_file
68.Fa "const char *filename"
69.Fa "long max_bytes"
70.Fc
71.Ft int
72.Fo RAND_write_file
73.Fa "const char *filename"
74.Fc
75.Sh DESCRIPTION
76.Fn RAND_file_name
77returns a default path for the random seed file.
78.Fa buf
79points to a buffer of size
80.Fa num
81in which to store the filename.
82If
83.Fa num
84is too small for the path name, an error occurs.
85.Pp
86.Fn RAND_load_file
87used to allow for the state of the random number generator to be
88controlled by external sources.
89It is kept for ABI compatibility but is no longer functional, and should
90not be used in new programs.
91.Pp
92.Fn RAND_write_file
93writes a number of random bytes (currently 1024) to file
94.Fa filename .
95.Sh RETURN VALUES
96.Fn RAND_load_file
97returns
98.Fa max_bytes ,
99or a bogus positive value if
100.Fa max_bytes
101is -1.
102.Pp
103.Fn RAND_write_file
104returns the number of bytes written, or a number less than or equal
105to 1 if an error occurs.
106.Pp
107.Fn RAND_file_name
108returns a pointer to
109.Fa buf
110on success or
111.Dv NULL
112on error.
113.Sh HISTORY
114.Fn RAND_load_file ,
115.Fn RAND_write_file ,
116and
117.Fn RAND_file_name
118first appeared in SSLeay 0.5.1 and have been available since
119.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/RAND_set_rand_method.3 b/src/lib/libcrypto/man/RAND_set_rand_method.3
deleted file mode 100644
index d94d794daf..0000000000
--- a/src/lib/libcrypto/man/RAND_set_rand_method.3
+++ /dev/null
@@ -1,55 +0,0 @@
1.\" $OpenBSD: RAND_set_rand_method.3,v 1.4 2018/03/21 09:03:49 schwarze Exp $
2.\"
3.\" Copyright (c) 2014 Miod Vallat <miod@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 21 2018 $
18.Dt RAND_SET_RAND_METHOD 3
19.Os
20.Sh NAME
21.Nm RAND_set_rand_method ,
22.Nm RAND_get_rand_method ,
23.Nm RAND_SSLeay
24.Nd select RAND method
25.Sh SYNOPSIS
26.In openssl/rand.h
27.Ft int
28.Fo RAND_set_rand_method
29.Fa "const RAND_METHOD *meth"
30.Fc
31.Ft const RAND_METHOD *
32.Fn RAND_get_rand_method void
33.Ft RAND_METHOD *
34.Fn RAND_SSLeay void
35.Sh DESCRIPTION
36These functions used to allow for the random number generator functions
37to be replaced by arbitrary code.
38.Pp
39They are kept for ABI compatibility but are no longer functional, and
40should not be used in new programs.
41.Sh RETURN VALUES
42.Fn RAND_set_rand_method
43always returns 1.
44.Fn RAND_get_rand_method
45and
46.Fn RAND_SSLeay
47always return
48.Dv NULL .
49.Sh HISTORY
50.Fn RAND_set_rand_method ,
51.Fn RAND_get_rand_method ,
52and
53.Fn RAND_SSLeay
54first appeared in SSLeay 0.9.1 and have been available since
55.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/RC2_encrypt.3 b/src/lib/libcrypto/man/RC2_encrypt.3
deleted file mode 100644
index a90e0f574b..0000000000
--- a/src/lib/libcrypto/man/RC2_encrypt.3
+++ /dev/null
@@ -1,195 +0,0 @@
1.\" $OpenBSD: RC2_encrypt.3,v 1.2 2024/12/18 04:15:48 jsg Exp $
2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 18 2024 $
18.Dt RC2_ENCRYPT 3
19.Os
20.Sh NAME
21.Nm RC2_set_key ,
22.Nm RC2_encrypt ,
23.Nm RC2_decrypt ,
24.Nm RC2_cbc_encrypt ,
25.Nm RC2_ecb_encrypt ,
26.Nm RC2_cfb64_encrypt ,
27.Nm RC2_ofb64_encrypt
28.Nd low-level functions for Rivest Cipher 2
29.Sh SYNOPSIS
30.In openssl/rc2.h
31.Ft void
32.Fo RC2_set_key
33.Fa "RC2_KEY *expanded_key"
34.Fa "int len"
35.Fa "const unsigned char *user_key"
36.Fa "int effective_bits"
37.Fc
38.Ft void
39.Fo RC2_encrypt
40.Fa "unsigned long *data"
41.Fa "RC2_KEY *expanded_key"
42.Fc
43.Ft void
44.Fo RC2_decrypt
45.Fa "unsigned long *data"
46.Fa "RC2_KEY *expanded_key"
47.Fc
48.Ft void
49.Fo RC2_cbc_encrypt
50.Fa "const unsigned char *in"
51.Fa "unsigned char *out"
52.Fa "long length"
53.Fa "RC2_KEY *expanded_key"
54.Fa "unsigned char *iv"
55.Fa "int encrypt"
56.Fc
57.Ft void
58.Fo RC2_ecb_encrypt
59.Fa "const unsigned char *in"
60.Fa "unsigned char *out"
61.Fa "RC2_KEY *expanded_key"
62.Fa "int encrypt"
63.Fc
64.Ft void
65.Fo RC2_cfb64_encrypt
66.Fa "const unsigned char *in"
67.Fa "unsigned char *out"
68.Fa "long length"
69.Fa "RC2_KEY *expanded_key"
70.Fa "unsigned char *iv"
71.Fa "int *num"
72.Fa "int encrypt"
73.Fc
74.Ft void
75.Fo RC2_ofb64_encrypt
76.Fa "const unsigned char *in"
77.Fa "unsigned char *out"
78.Fa "long length"
79.Fa "RC2_KEY *expanded_key"
80.Fa "unsigned char *iv"
81.Fa "int *num"
82.Fc
83.Sh DESCRIPTION
84RC2 is a block cipher operating on blocks of
85.Dv RC2_BLOCK No = 8
86bytes, equivalent to 64 bits, using a variable key length
87with an additional parameter called
88.Dq effective key bits
89or
90.Dq effective key length .
91The maximum effective key length is 1024 bits.
92.Pp
93If using RC2 cannot be avoided, it is recommended that application
94programs use the
95.Xr EVP_rc2_cbc 3
96family of functions instead of the functions documented in the present
97manual page, to ease later migration to less outdated encryption algorithms.
98.Pp
99.Fn RC2_set_key
100expands the first
101.Fa len
102bytes of
103.Fa user_key
104into the
105.Vt RC2_KEY
106structure
107.Pf * Fa expanded_key .
108The storage for the expanded key has to be provided by the calling code.
109If the
110.Fa len
111argument exceeds 128, only the first 128 bytes are used.
112.Pp
113Optionally, if the
114.Fa effective_bits
115argument is positive and less than 1024, the effective key length of
116.Pf * Fa expanded_key
117is reduced to
118.Fa effective_bits .
119Reducing the effective key length is not cryptographically useful.
120This option was originally designed to conform to US export regulations
121valid at the time, which were designed to allow the US government
122to spy on foreign encrypted communications.
123Unless interoperability requires otherwise, setting
124.Fa effective_bits
125to 1024 is recommended.
126.Pp
127.Fn RC2_encrypt
128and
129.Fn RC2_decrypt
130interpret
131.Fa data
132as an array of two 32 bit integers and encrypt or decrypt
133that single block in place, respectively, using the
134.Fa expanded_key .
135.Pp
136The remaining functions encode or decode
137.Fa length
138bytes starting at
139.Fa in
140to
141.Fa length
142bytes starting at
143.Fa out
144in various modes of operation using the
145.Fa expanded_key .
146Both arrays need to be long enough to hold
147.Fa length
148bytes rounded up to the next multiple of 8.
149The
150.Fa iv
151argument points to an array of 8 bytes used as the initialization vector.
152If the
153.Fa encrypt
154argument is
155.Dv RC2_ENCRYPT
156or another non-zero value, encryption is performed;
157if it is
158.Dv RC2_DECRYPT No = 0 ,
159decryption is performed.
160.Pp
161.Fn RC2_cbc_encrypt
162operates in cipher block chaining mode.
163.Pp
164.Fn RC2_ecb_encrypt
165encodes or decodes eight bytes at
166.Fa in
167to
168eight bytes at
169.Fa out
170in electronic codebook mode.
171.Pp
172.Fn RC2_cfb64_encrypt
173and
174.Fn RC2_ofb64_encrypt
175operate in cipher feedback mode and output feedback mode, respectively,
176with 64 bit blocks.
177The number of bytes used from the last 8 byte block is kept track of in
178.Pf * Fa num .
179.Sh SEE ALSO
180.Xr crypto 3 ,
181.Xr EVP_EncryptInit 3 ,
182.Xr EVP_rc2_cbc 3
183.Sh HISTORY
184.Fn RC2_set_key ,
185.Fn RC2_encrypt ,
186.Fn RC2_cbc_encrypt ,
187.Fn RC2_ecb_encrypt ,
188.Fn RC2_cfb64_encrypt ,
189and
190.Fn RC2_ofb64_encrypt
191first appeared in SSLeay 0.5.2.
192.Fn RC2_decrypt
193first appeared in SSLeay 0.9.0.
194All these functions have been available since
195.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/RC4.3 b/src/lib/libcrypto/man/RC4.3
deleted file mode 100644
index 8b20a434b7..0000000000
--- a/src/lib/libcrypto/man/RC4.3
+++ /dev/null
@@ -1,126 +0,0 @@
1.\" $OpenBSD: RC4.3,v 1.8 2020/03/29 17:05:02 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 29 2020 $
52.Dt RC4 3
53.Os
54.Sh NAME
55.Nm RC4_set_key ,
56.Nm RC4
57.Nd RC4 encryption
58.Sh SYNOPSIS
59.In openssl/rc4.h
60.Ft void
61.Fo RC4_set_key
62.Fa "RC4_KEY *key"
63.Fa "int len"
64.Fa "const unsigned char *data"
65.Fc
66.Ft void
67.Fo RC4
68.Fa "RC4_KEY *key"
69.Fa "unsigned long len"
70.Fa "const unsigned char *indata"
71.Fa "unsigned char *outdata"
72.Fc
73.Sh DESCRIPTION
74This library implements the alleged RC4 cipher, which is described for
75example in
76.Qq Applied Cryptography .
77It is believed to be compatible with RC4[TM], a proprietary cipher of
78RSA Security Inc.
79.Pp
80RC4 is a stream cipher with variable key length.
81Typically, 128-bit (16-byte) keys are used for strong encryption, but
82shorter insecure key sizes have been widely used due to export
83restrictions.
84.Pp
85RC4 consists of a key setup phase and the actual encryption or
86decryption phase.
87.Pp
88.Fn RC4_set_key
89sets up the
90.Vt RC4_KEY
91.Fa key
92using the
93.Fa len
94bytes long key at
95.Fa data .
96.Pp
97.Fn RC4
98encrypts or decrypts the
99.Fa len
100bytes of data at
101.Fa indata
102using
103.Fa key
104and places the result at
105.Fa outdata .
106Repeated
107.Fn RC4
108calls with the same
109.Fa key
110yield a continuous key stream.
111.Pp
112Since RC4 is a stream cipher (the input is XOR'ed with a pseudo-random
113key stream to produce the output), decryption uses the same function
114calls as encryption.
115.Sh SEE ALSO
116.Xr blowfish 3 ,
117.Xr EVP_EncryptInit 3 ,
118.Xr EVP_rc4 3
119.Sh HISTORY
120.Fn RC4_set_key
121and
122.Fn RC4
123appeared in SSLeay 0.4 or earlier and have been available since
124.Ox 2.4 .
125.Sh BUGS
126This cipher is broken and should no longer be used.
diff --git a/src/lib/libcrypto/man/RIPEMD160.3 b/src/lib/libcrypto/man/RIPEMD160.3
deleted file mode 100644
index 43c6694036..0000000000
--- a/src/lib/libcrypto/man/RIPEMD160.3
+++ /dev/null
@@ -1,154 +0,0 @@
1.\" $OpenBSD: RIPEMD160.3,v 1.8 2024/05/26 09:54:16 tb Exp $
2.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2006, 2014 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: May 26 2024 $
52.Dt RIPEMD160 3
53.Os
54.Sh NAME
55.Nm RIPEMD160 ,
56.Nm RIPEMD160_Init ,
57.Nm RIPEMD160_Update ,
58.Nm RIPEMD160_Final
59.Nd RIPEMD-160 hash function
60.Sh SYNOPSIS
61.In openssl/ripemd.h
62.Ft unsigned char *
63.Fo RIPEMD160
64.Fa "const unsigned char *d"
65.Fa "unsigned long n"
66.Fa "unsigned char *md"
67.Fc
68.Ft int
69.Fo RIPEMD160_Init
70.Fa "RIPEMD160_CTX *c"
71.Fc
72.Ft int
73.Fo RIPEMD160_Update
74.Fa "RIPEMD160_CTX *c"
75.Fa "const void *data"
76.Fa "unsigned long len"
77.Fc
78.Ft int
79.Fo RIPEMD160_Final
80.Fa "unsigned char *md"
81.Fa "RIPEMD160_CTX *c"
82.Fc
83.Sh DESCRIPTION
84RIPEMD-160 is a cryptographic hash function with a 160-bit output.
85.Pp
86.Fn RIPEMD160
87computes the RIPEMD-160 message digest of the
88.Fa n
89bytes at
90.Fa d
91and places it in
92.Fa md ,
93which must have space for
94.Dv RIPEMD160_DIGEST_LENGTH
95== 20 bytes of output.
96.Pp
97The following functions may be used if the message is not completely
98stored in memory:
99.Pp
100.Fn RIPEMD160_Init
101initializes a
102.Vt RIPEMD160_CTX
103structure.
104.Pp
105.Fn RIPEMD160_Update
106can be called repeatedly with chunks of the message to be hashed
107.Pq Fa len No bytes at Fa data .
108.Pp
109.Fn RIPEMD160_Final
110places the message digest in
111.Fa md ,
112which must have space for
113.Dv RIPEMD160_DIGEST_LENGTH
114== 20 bytes of output,
115and erases the
116.Vt RIPEMD160_CTX .
117.Pp
118Applications should use the higher level functions
119.Xr EVP_DigestInit 3
120etc. instead of calling the hash functions directly.
121.Sh RETURN VALUES
122.Fn RIPEMD160
123returns a pointer to the hash value.
124.Pp
125.Fn RIPEMD160_Init ,
126.Fn RIPEMD160_Update ,
127and
128.Fn RIPEMD160_Final
129return 1 for success or 0 otherwise.
130.Sh SEE ALSO
131.Xr EVP_DigestInit 3 ,
132.Xr HMAC 3
133.Sh STANDARDS
134.Bd -unfilled
135ISO/IEC 10118-3:2004/Cor 1:2011
136Hash-functions \(em Part 3: Dedicated hash-functions
137Clause 7: RIPEMD-160
138.Ed
139.Sh HISTORY
140.Fn RIPEMD160 ,
141.Fn RIPEMD160_Init ,
142.Fn RIPEMD160_Update ,
143and
144.Fn RIPEMD160_Final
145first appeared in SSLeay 0.9.0 and have been available since
146.Ox 2.4 .
147.Sh CAVEATS
148Other implementations allow
149.Fa md
150in
151.Fn RIPEMD160
152to be
153.Dv NULL
154and return a static array, which is not thread safe.
diff --git a/src/lib/libcrypto/man/RSA_PSS_PARAMS_new.3 b/src/lib/libcrypto/man/RSA_PSS_PARAMS_new.3
deleted file mode 100644
index f69f33dbe5..0000000000
--- a/src/lib/libcrypto/man/RSA_PSS_PARAMS_new.3
+++ /dev/null
@@ -1,60 +0,0 @@
1.\" $OpenBSD: RSA_PSS_PARAMS_new.3,v 1.4 2019/06/06 01:06:59 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 6 2019 $
18.Dt RSA_PSS_PARAMS_NEW 3
19.Os
20.Sh NAME
21.Nm RSA_PSS_PARAMS_new ,
22.Nm RSA_PSS_PARAMS_free
23.Nd probabilistic signature scheme with RSA hashing
24.Sh SYNOPSIS
25.In openssl/rsa.h
26.Ft RSA_PSS_PARAMS *
27.Fn RSA_PSS_PARAMS_new void
28.Ft void
29.Fn RSA_PSS_PARAMS_free "RSA_PSS_PARAMS *params"
30.Sh DESCRIPTION
31.Fn RSA_PSS_PARAMS_new
32allocates and initializes an empty
33.Vt RSA_PSS_PARAMS
34object, representing an ASN.1
35.Vt RSASSA-PSS-params
36structure defined in RFC 8017 appendix A.2.3.
37It references the hash function and the mask generation function
38and stores the length of the salt and the trailer field number.
39.Fn RSA_PSS_PARAMS_free
40frees
41.Fa params .
42.Sh RETURN VALUES
43.Fn RSA_PSS_PARAMS_new
44returns the new
45.Vt RSA_PSS_PARAMS
46object or
47.Dv NULL
48if an error occurs.
49.Sh SEE ALSO
50.Xr RSA_new 3 ,
51.Xr RSA_padding_add_PKCS1_type_1 3 ,
52.Xr X509_sign 3
53.Sh STANDARDS
54RFC 8017: PKCS#1: RSA Cryptography Specifications Version 2.2
55.Sh HISTORY
56.Fn RSA_PSS_PARAMS_new
57and
58.Fn RSA_PSS_PARAMS_free
59first appeared in OpenSSL 1.0.1 and have been available since
60.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/RSA_blinding_on.3 b/src/lib/libcrypto/man/RSA_blinding_on.3
deleted file mode 100644
index bd2a301377..0000000000
--- a/src/lib/libcrypto/man/RSA_blinding_on.3
+++ /dev/null
@@ -1,97 +0,0 @@
1.\" $OpenBSD: RSA_blinding_on.3,v 1.7 2023/07/26 20:08:59 tb Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: July 26 2023 $
52.Dt RSA_BLINDING_ON 3
53.Os
54.Sh NAME
55.Nm RSA_blinding_on ,
56.Nm RSA_blinding_off
57.Nd protect the RSA operation from timing attacks
58.Sh SYNOPSIS
59.In openssl/rsa.h
60.Ft int
61.Fo RSA_blinding_on
62.Fa "RSA *rsa"
63.Fa "BN_CTX *ctx"
64.Fc
65.Ft void
66.Fo RSA_blinding_off
67.Fa "RSA *rsa"
68.Fc
69.Sh DESCRIPTION
70RSA is vulnerable to timing attacks.
71In a setup where attackers can measure the time of RSA decryption or
72signature operations, blinding must be used to protect the RSA operation
73from that attack.
74.Pp
75.Fn RSA_blinding_on
76turns blinding on for key
77.Fa rsa
78and generates a random blinding factor.
79.Fa ctx
80is
81.Dv NULL
82or a pre-allocated and initialized
83.Vt BN_CTX .
84.Pp
85.Fn RSA_blinding_off
86turns blinding off and frees the memory used for the blinding factor.
87.Sh RETURN VALUES
88.Fn RSA_blinding_on
89returns 1 on success, and 0 if an error occurred.
90.Sh SEE ALSO
91.Xr RSA_new 3
92.Sh HISTORY
93.Fn RSA_blinding_on
94and
95.Fn RSA_blinding_off
96first appeared in SSLeay 0.9.0 and have been available since
97.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/RSA_check_key.3 b/src/lib/libcrypto/man/RSA_check_key.3
deleted file mode 100644
index 36b613b3a5..0000000000
--- a/src/lib/libcrypto/man/RSA_check_key.3
+++ /dev/null
@@ -1,130 +0,0 @@
1.\" $OpenBSD: RSA_check_key.3,v 1.10 2023/11/19 21:06:15 tb Exp $
2.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
5.\" Geoff Thorpe <geoff@openssl.org>.
6.\" Copyright (c) 2000, 2002 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: November 19 2023 $
53.Dt RSA_CHECK_KEY 3
54.Os
55.Sh NAME
56.Nm RSA_check_key
57.Nd validate private RSA keys
58.Sh SYNOPSIS
59.In openssl/rsa.h
60.Ft int
61.Fo RSA_check_key
62.Fa "RSA *rsa"
63.Fc
64.Sh DESCRIPTION
65This function validates RSA keys.
66It checks that
67.Fa rsa->p
68and
69.Fa rsa->q
70are in fact prime, and that
71.Fa rsa->n
72satisfies n = p*q.
73.Pp
74It also checks that
75.Fa rsa->d
76and
77.Fa rsa->e
78satisfy d*e = 1 mod ((p-1)*(q-1)),
79and that
80.Fa rsa->dmp1 ,
81.Fa rsa->dmq1 ,
82and
83.Fa resa->iqmp
84are set correctly or are
85.Dv NULL .
86.Pp
87This function does not work on RSA public keys that have only the
88modulus and public exponent elements populated.
89It performs integrity checks on all the RSA key material, so the
90.Vt RSA
91key structure must contain all the private key data too.
92Therefore, it cannot be used with any arbitrary
93.Vt RSA
94key object, even if it is otherwise fit for regular RSA operation.
95.Sh RETURN VALUES
96.Fn RSA_check_key
97returns 1 if
98.Fa rsa
99is a valid RSA key, and 0 otherwise.
100-1 is returned if an error occurs while checking the key.
101.Pp
102If the key is invalid or an error occurred, the reason code can be
103obtained using
104.Xr ERR_get_error 3 .
105.Sh SEE ALSO
106.Xr BN_is_prime_ex 3 ,
107.Xr RSA_get0_key 3 ,
108.Xr RSA_new 3
109.Sh HISTORY
110.Fn RSA_check_key
111first appeared in OpenSSL 0.9.4 and has been available since
112.Ox 2.6 .
113.Sh BUGS
114A method of verifying the RSA key using opaque RSA API functions might
115need to be considered.
116Right now
117.Fn RSA_check_key
118simply uses the
119.Vt RSA
120structure elements directly, bypassing the
121.Vt RSA_METHOD
122table altogether (and completely violating encapsulation and
123object-orientation in the process).
124The best fix will probably be to introduce a
125.Fn check_key
126handler
127to the
128.Vt RSA_METHOD
129function table so that alternative implementations can also provide
130their own verifiers.
diff --git a/src/lib/libcrypto/man/RSA_generate_key.3 b/src/lib/libcrypto/man/RSA_generate_key.3
deleted file mode 100644
index 83703b1eaa..0000000000
--- a/src/lib/libcrypto/man/RSA_generate_key.3
+++ /dev/null
@@ -1,164 +0,0 @@
1.\" $OpenBSD: RSA_generate_key.3,v 1.13 2019/06/10 14:58:48 schwarze Exp $
2.\" OpenSSL RSA_generate_key.pod bb6c5e7f Feb 5 10:29:22 2017 -0500
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2002, 2013 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 10 2019 $
52.Dt RSA_GENERATE_KEY 3
53.Os
54.Sh NAME
55.Nm RSA_generate_key_ex ,
56.Nm RSA_generate_key
57.Nd generate RSA key pair
58.Sh SYNOPSIS
59.In openssl/rsa.h
60.Ft int
61.Fo RSA_generate_key_ex
62.Fa "RSA *rsa"
63.Fa "int bits"
64.Fa "BIGNUM *e"
65.Fa "BN_GENCB *cb"
66.Fc
67.Pp
68Deprecated:
69.Pp
70.Ft RSA *
71.Fo RSA_generate_key
72.Fa "int num"
73.Fa "unsigned long e"
74.Fa "void (*callback)(int, int, void *)"
75.Fa "void *cb_arg"
76.Fc
77.Sh DESCRIPTION
78.Fn RSA_generate_key_ex
79generates a key pair and stores it in
80.Fa rsa .
81.Pp
82The modulus size will be of length
83.Fa bits ,
84and the public exponent will be
85.Fa e .
86Key sizes with
87.Fa num
88< 1024 should be considered insecure.
89The exponent is an odd number, typically 3, 17 or 65537.
90.Pp
91A callback function may be used to provide feedback about the progress
92of the key generation.
93If
94.Fa cb
95is not
96.Dv NULL ,
97it will be called as follows using the
98.Xr BN_GENCB_call 3
99function:
100.Bl -bullet
101.It
102While a random prime number is generated, it is called as described in
103.Xr BN_generate_prime 3 .
104.It
105When the
106.Fa n Ns -th
107randomly generated prime is rejected as not suitable for
108the key,
109.Fn BN_GENCB_call cb 2 n
110is called.
111.It
112When a random p has been found with p-1 relatively prime to
113.Fa e ,
114it is called as
115.Fn BN_GENCB_call cb 3 0 .
116.El
117.Pp
118The process is then repeated for prime q with
119.Fn BN_GENCB_call cb 3 1 .
120.Pp
121.Fn RSA_generate_key
122is deprecated.
123New applications should use
124.Fn RSA_generate_key_ex
125instead.
126.Fn RSA_generate_key
127works in the same way as
128.Fn RSA_generate_key_ex
129except it uses "old style" call backs.
130See
131.Xr BN_generate_prime 3
132for further details.
133.Sh RETURN VALUES
134.Fn RSA_generate_key_ex
135returns 1 on success or 0 on error.
136.Fn RSA_generate_key
137returns the key on success or
138.Dv NULL
139on error.
140.Pp
141The error codes can be obtained by
142.Xr ERR_get_error 3 .
143.Sh SEE ALSO
144.Xr BN_generate_prime 3 ,
145.Xr RSA_get0_key 3 ,
146.Xr RSA_meth_set_keygen 3 ,
147.Xr RSA_new 3
148.Sh HISTORY
149.Fn RSA_generate_key
150appeared in SSLeay 0.4 or earlier and had its
151.Fa cb_arg
152argument added in SSLeay 0.9.0.
153It has been available since
154.Ox 2.4 .
155.Pp
156.Fn RSA_generate_key_ex
157first appeared in OpenSSL 0.9.8 and has been available since
158.Ox 4.5 .
159.Sh BUGS
160.Fn BN_GENCB_call cb 2 x
161is used with two different meanings.
162.Pp
163.Fn RSA_generate_key
164goes into an infinite loop for illegal input values.
diff --git a/src/lib/libcrypto/man/RSA_get0_key.3 b/src/lib/libcrypto/man/RSA_get0_key.3
deleted file mode 100644
index f09fb00d2b..0000000000
--- a/src/lib/libcrypto/man/RSA_get0_key.3
+++ /dev/null
@@ -1,460 +0,0 @@
1.\" $OpenBSD: RSA_get0_key.3,v 1.8 2025/01/05 15:40:42 tb Exp $
2.\" selective merge up to: OpenSSL 665d899f Aug 2 02:19:43 2017 +0800
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Richard Levitte <levitte@openssl.org>
22.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: January 5 2025 $
69.Dt RSA_GET0_KEY 3
70.Os
71.Sh NAME
72.Nm RSA_get0_key ,
73.Nm RSA_get0_n ,
74.Nm RSA_get0_e ,
75.Nm RSA_get0_d ,
76.Nm RSA_set0_key ,
77.Nm RSA_get0_factors ,
78.Nm RSA_get0_p ,
79.Nm RSA_get0_q ,
80.Nm RSA_set0_factors ,
81.Nm RSA_get0_crt_params ,
82.Nm RSA_get0_dmp1 ,
83.Nm RSA_get0_dmq1 ,
84.Nm RSA_get0_iqmp ,
85.Nm RSA_set0_crt_params ,
86.Nm RSA_clear_flags ,
87.Nm RSA_test_flags ,
88.Nm RSA_set_flags
89.Nd get and set data in an RSA object
90.Sh SYNOPSIS
91.In openssl/rsa.h
92.Ft void
93.Fo RSA_get0_key
94.Fa "const RSA *r"
95.Fa "const BIGNUM **n"
96.Fa "const BIGNUM **e"
97.Fa "const BIGNUM **d"
98.Fc
99.Ft "const BIGNUM *"
100.Fo RSA_get0_n
101.Fa "const RSA *r"
102.Fc
103.Ft "const BIGNUM *"
104.Fo RSA_get0_e
105.Fa "const RSA *r"
106.Fc
107.Ft "const BIGNUM *"
108.Fo RSA_get0_d
109.Fa "const RSA *r"
110.Fc
111.Ft int
112.Fo RSA_set0_key
113.Fa "RSA *r"
114.Fa "BIGNUM *n"
115.Fa "BIGNUM *e"
116.Fa "BIGNUM *d"
117.Fc
118.Ft void
119.Fo RSA_get0_factors
120.Fa "const RSA *r"
121.Fa "const BIGNUM **p"
122.Fa "const BIGNUM **q"
123.Fc
124.Ft "const BIGNUM *"
125.Fo RSA_get0_p
126.Fa "const RSA *r"
127.Fc
128.Ft "const BIGNUM *"
129.Fo RSA_get0_q
130.Fa "const RSA *r"
131.Fc
132.Ft int
133.Fo RSA_set0_factors
134.Fa "RSA *r"
135.Fa "BIGNUM *p"
136.Fa "BIGNUM *q"
137.Fc
138.Ft void
139.Fo RSA_get0_crt_params
140.Fa "const RSA *r"
141.Fa "const BIGNUM **dmp1"
142.Fa "const BIGNUM **dmq1"
143.Fa "const BIGNUM **iqmp"
144.Fc
145.Ft "const BIGNUM *"
146.Fo RSA_get0_dmp1
147.Fa "const RSA *r"
148.Fc
149.Ft "const BIGNUM *"
150.Fo RSA_get0_dmq1
151.Fa "const RSA *r"
152.Fc
153.Ft "const BIGNUM *"
154.Fo RSA_get0_iqmp
155.Fa "const RSA *r"
156.Fc
157.Ft int
158.Fo RSA_set0_crt_params
159.Fa "RSA *r"
160.Fa "BIGNUM *dmp1"
161.Fa "BIGNUM *dmq1"
162.Fa "BIGNUM *iqmp"
163.Fc
164.Ft void
165.Fo RSA_clear_flags
166.Fa "RSA *r"
167.Fa "int flags"
168.Fc
169.Ft int
170.Fo RSA_test_flags
171.Fa "const RSA *r"
172.Fa "int flags"
173.Fc
174.Ft void
175.Fo RSA_set_flags
176.Fa "RSA *r"
177.Fa "int flags"
178.Fc
179.Sh DESCRIPTION
180An
181.Vt RSA
182object contains the components for the public and private key.
183.Fa n
184is the modulus common to both public and private key,
185.Fa e
186is the public exponent and
187.Fa d
188is the private exponent.
189.Fa p ,
190.Fa q ,
191.Fa dmp1 ,
192.Fa dmq1 ,
193and
194.Fa iqmp
195are the factors for the second representation of a private key
196(see PKCS#1 section 3 Key Types), where
197.Fa p
198and
199.Fa q
200are the first and second factor of
201.Fa n .
202.Fa dmp1 ,
203.Fa dmq1 ,
204and
205.Fa iqmp
206are the exponents and coefficient
207for Chinese Remainder Theorem (CRT) calculations.
208.Pp
209The
210.Fa n ,
211.Fa e ,
212and
213.Fa d
214parameters can be obtained by calling
215.Fn RSA_get0_key .
216If they have not been set yet, then
217.Pf * Fa n ,
218.Pf * Fa e ,
219and
220.Pf * Fa d
221are set to
222.Dv NULL .
223Otherwise, they are set to pointers to the internal representations
224of the values that should not be freed by the caller.
225.Pp
226The
227.Fa n ,
228.Fa e ,
229and
230.Fa d
231parameter values can be set by calling
232.Fn RSA_set0_key .
233The values
234.Fa n
235and
236.Fa e
237must be
238.Pf non- Dv NULL
239the first time this function is called on a given
240.Vt RSA
241object.
242The value
243.Fa d
244may be
245.Dv NULL .
246On subsequent calls, any of these values may be
247.Dv NULL ,
248which means that the corresponding field is left untouched.
249Calling this function transfers the memory management of the values to
250the RSA object.
251Therefore, the values that have been passed in
252should not be freed by the caller.
253.Pp
254In a similar fashion, the
255.Fa p
256and
257.Fa q
258parameters can be obtained and set with
259.Fn RSA_get0_factors
260and
261.Fn RSA_set0_factors ,
262and the
263.Fa dmp1 ,
264.Fa dmq1 ,
265and
266.Fa iqmp
267parameters can be obtained and set with
268.Fn RSA_get0_crt_params
269and
270.Fn RSA_set0_crt_params .
271.Pp
272For
273.Fn RSA_get0_key ,
274.Fn RSA_get0_factors ,
275and
276.Fn RSA_get0_crt_params ,
277.Dv NULL
278value
279.Vt BIGNUM **
280output arguments are permitted.
281The functions
282ignore
283.Dv NULL
284arguments but return values for other,
285.Pf non- Dv NULL ,
286arguments.
287.Pp
288Values retrieved with
289.Fn RSA_get0_key ,
290.Fn RSA_get0_factors ,
291and
292.Fn RSA_get0_crt_params
293are owned by the
294.Vt RSA
295object used in the call and may therefore
296.Em not
297be passed to
298.Fn RSA_set0_key ,
299.Fn RSA_set0_factors ,
300or
301.Fn RSA_set0_crt_params .
302If needed, duplicate the received value using
303.Xr BN_dup 3
304and pass the duplicate.
305.Pp
306Any of the values
307.Fa n ,
308.Fa e ,
309.Fa d ,
310.Fa p ,
311.Fa q ,
312.Fa dmp1 ,
313.Fa dmq1 ,
314and
315.Fa iqmp
316can also be retrieved separately by the corresponding functions
317.Fn RSA_get0_n ,
318.Fn RSA_get0_e ,
319.Fn RSA_get0_d ,
320.Fn RSA_get0_p ,
321.Fn RSA_get0_q ,
322.Fn RSA_get0_dmp1 ,
323.Fn RSA_get0_dmq1 ,
324and
325.Fn RSA_get0_iqmp ,
326respectively.
327The pointers are owned by the
328.Vt RSA
329object.
330.Pp
331.Fn RSA_clear_flags
332clears the specified
333.Fa flags
334in
335.Fa r .
336.Fn RSA_test_flags
337tests the
338.Fa flags
339in
340.Fa r .
341.Fn RSA_set_flags
342sets the
343.Fa flags
344in
345.Fa r ;
346any flags already set remain set.
347For all three functions, multiple flags can be passed in one call,
348OR'ed together bitwise.
349.Pp
350The following flags are supported:
351.Bl -tag -width Ds
352.It Dv RSA_FLAG_CACHE_PRIVATE No and Dv RSA_FLAG_CACHE_PUBLIC
353Precompute information needed for Montgomery multiplication
354from the private and public key, respectively, and cache it in
355.Fa r
356for repeated use.
357These two flags are set by default for the default RSA implementation,
358.Xr RSA_PKCS1_SSLeay 3 .
359.It Dv RSA_FLAG_EXT_PKEY
360The function set with
361.Xr RSA_meth_set_mod_exp 3
362is used for private key operations even if
363.Fa p ,
364.Fa q ,
365.Fa dmp1 ,
366.Fa dmq1 ,
367and
368.Fa iqmp
369are all
370.Dv NULL .
371This flag may be useful with RSA implementations that do not use the
372private key components stored in the standard fields, for example
373because they store the private key in external hardware.
374If this flag is unset, the function set with
375.Xr RSA_meth_set_bn_mod_exp 3
376is used with
377.Fa n
378and
379.Fa d
380instead.
381.It Dv RSA_FLAG_NO_BLINDING
382Turn off blinding during private key encryption and decryption.
383This flag is set by
384.Xr RSA_blinding_off 3 .
385.It Dv RSA_FLAG_SIGN_VER
386This flag has no effect.
387It is provided only for backward compatibility with legacy applications.
388.El
389.Pp
390The flags
391.Dv RSA_FLAG_BLINDING ,
392.Dv RSA_FLAG_CHECKED ,
393.Dv RSA_FLAG_FIPS_METHOD ,
394.Dv RSA_FLAG_NON_FIPS_ALLOW ,
395and
396.Dv RSA_FLAG_THREAD_SAFE
397are defined for compatibility with existing code but have no effect.
398.Sh RETURN VALUES
399.Fn RSA_get0_n ,
400.Fn RSA_get0_e ,
401.Fn RSA_get0_d ,
402.Fn RSA_get0_p ,
403.Fn RSA_get0_q ,
404.Fn RSA_get0_dmp1 ,
405.Fn RSA_get0_dmq1 ,
406and
407.Fn RSA_get0_iqmp
408return a pointer owned by the
409.Vt RSA
410object if the corresponding value has been set,
411otherwise they return
412.Dv NULL .
413.Pp
414.Fn RSA_set0_key ,
415.Fn RSA_set0_factors ,
416and
417.Fn RSA_set0_crt_params
418return 1 on success or 0 on failure.
419.Pp
420.Fn RSA_test_flags
421returns those of the given
422.Fa flags
423currently set in
424.Fa r
425or 0 if none of the given
426.Fa flags
427are set.
428.Sh SEE ALSO
429.Xr RSA_check_key 3 ,
430.Xr RSA_generate_key 3 ,
431.Xr RSA_new 3 ,
432.Xr RSA_print 3 ,
433.Xr RSA_size 3
434.Sh HISTORY
435.Fn RSA_get0_key ,
436.Fn RSA_set0_key ,
437.Fn RSA_get0_factors ,
438.Fn RSA_set0_factors ,
439.Fn RSA_get0_crt_params ,
440.Fn RSA_set0_crt_params ,
441.Fn RSA_clear_flags ,
442.Fn RSA_test_flags ,
443and
444.Fn RSA_set_flags
445first appeared in OpenSSL 1.1.0
446and have been available since
447.Ox 6.3 .
448.Pp
449.Fn RSA_get0_n ,
450.Fn RSA_get0_e ,
451.Fn RSA_get0_d ,
452.Fn RSA_get0_p ,
453.Fn RSA_get0_q ,
454.Fn RSA_get0_dmp1 ,
455.Fn RSA_get0_dmq1 ,
456and
457.Fn RSA_get0_iqmp
458first appeared in OpenSSL 1.1.1
459and have been available since
460.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/RSA_get_ex_new_index.3 b/src/lib/libcrypto/man/RSA_get_ex_new_index.3
deleted file mode 100644
index 5f1fb4335f..0000000000
--- a/src/lib/libcrypto/man/RSA_get_ex_new_index.3
+++ /dev/null
@@ -1,382 +0,0 @@
1.\" $OpenBSD: RSA_get_ex_new_index.3,v 1.13 2023/11/19 21:08:04 tb Exp $
2.\"
3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 19 2023 $
18.Dt RSA_GET_EX_NEW_INDEX 3
19.Os
20.Sh NAME
21.Nm RSA_get_ex_new_index ,
22.Nm RSA_set_ex_data ,
23.Nm RSA_get_ex_data
24.Nd add application specific data to RSA objects
25.Sh SYNOPSIS
26.In openssl/rsa.h
27.Ft int
28.Fo RSA_get_ex_new_index
29.Fa "long argl"
30.Fa "void *argp"
31.Fa "CRYPTO_EX_new *new_func"
32.Fa "CRYPTO_EX_dup *dup_func"
33.Fa "CRYPTO_EX_free *free_func"
34.Fc
35.Ft int
36.Fo RSA_set_ex_data
37.Fa "RSA *rsa"
38.Fa "int idx"
39.Fa "void *data"
40.Fc
41.Ft void *
42.Fo RSA_get_ex_data
43.Fa "RSA *rsa"
44.Fa "int idx"
45.Fc
46.Sh DESCRIPTION
47The following parent objects can have application specific data called
48.Dq ex_data
49attached to them:
50.Vt BIO , DH , DSA , EC_KEY , RSA ,
51.Vt SSL , SSL_CTX , SSL_SESSION , UI , X509 , X509_STORE ,
52and
53.Vt X509_STORE_CTX .
54.\" CRYPTO_EX_INDEX_APP and CRYPTO_EX_INDEX_UI_METHOD are unused.
55The present manual page documents the related API functions taking the
56.Vt RSA
57object type as an example.
58The functions for the other object types work in exactly the same way:
59just replace the string
60.Qq RSA
61with the name of the respective object type
62throughout the rest of this manual page.
63.Pp
64By default, each individual
65.Vt RSA
66object can store one
67.Vt void *
68pointing to application specific data.
69That specific pointer is identified by an
70.Fa idx
71argument of 0.
72.Pp
73.Fn RSA_get_ex_new_index
74reserves the next consecutive
75.Fa idx
76argument, enabling storage of one additional
77.Vt void *
78per
79.Vt RSA
80object.
81It is typically called at program startup.
82It can be called more than once if some
83.Vt RSA
84objects need to store more than two application specific pointers.
85Reserving an additional index for one parent object type, for example for
86.Vt RSA ,
87does not change the numbers of indices that can be used
88with any other parent object type.
89.Pp
90It is strongly recommended to always pass three
91.Dv NULL
92pointers for the arguments
93.Fa new_func ,
94.Fa dup_func ,
95and
96.Fa free_func .
97When following this recommendation, the arguments
98.Fa argl
99and
100.Fa argp
101are ignored; conventionally, passing 0 and
102.Dv NULL
103is recommended.
104Because using them is discouraged, the three function callback types
105are only documented in the low-level
106.Xr CRYPTO_EX_new 3
107manual page.
108.Pp
109.Fn RSA_set_ex_data
110stores the
111.Fa data
112pointer as application specific data at the given
113.Fa idx
114in the given
115.Fa rsa
116object.
117The meaning of the data pointed to is up to the application.
118The caller retains ownership of the
119.Fa data
120and is responsible for freeing it when neither the caller nor the
121.Fa rsa
122object need it any longer.
123Any other pointer that was previously stored at the same
124.Fa idx
125in the same
126.Fa rsa
127object is silently overwritten.
128Passing a
129.Dv NULL
130pointer for the
131.Fa data
132argument is valid and indicates that no application specific data
133currently needs to be stored at the given
134.Fa idx .
135.Pp
136.Fn RSA_get_ex_data
137retrieves the last pointer that was stored using
138.Fn RSA_set_ex_data
139at the given
140.Fa idx
141in the given
142.Fa rsa
143object.
144.Sh RETURN VALUES
145.Fn RSA_get_ex_new_index
146returns a new index equal to or greater than 1
147or \-1 if memory allocation fails.
148.Pp
149.Fn RSA_set_ex_data
150returns 1 on success or 0 if memory allocation fails.
151.Pp
152.Fn RSA_get_ex_data
153returns the application specific data or
154.Dv NULL
155if
156.Fa rsa
157does not contain application specific data at the given
158.Fa idx .
159.Sh ERRORS
160After failure of
161.Fn RSA_get_ex_new_index
162or
163.Fn RSA_set_ex_data ,
164the following diagnostic can be retrieved with
165.Xr ERR_get_error 3 ,
166.Xr ERR_GET_REASON 3 ,
167and
168.Xr ERR_reason_error_string 3 :
169.Bl -tag -width Ds
170.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
171Memory allocation failed.
172.El
173.Pp
174In a few unusual failure cases,
175.Xr ERR_get_error 3
176may report different errors caused by
177.Xr OPENSSL_init_crypto 3
178or even none at all.
179.Pp
180.Fn RSA_get_ex_data
181does not distinguish success from failure.
182Consequently, after
183.Fn RSA_get_ex_data
184returns
185.Dv NULL ,
186.Xr ERR_get_error 3
187returns 0 unless there is still an earlier error in the queue.
188.Sh SEE ALSO
189.Xr BIO_set_ex_data 3 ,
190.Xr CRYPTO_set_ex_data 3 ,
191.Xr DH_set_ex_data 3 ,
192.Xr DSA_set_ex_data 3 ,
193.Xr RSA_new 3 ,
194.Xr SSL_CTX_set_ex_data 3 ,
195.Xr SSL_SESSION_set_ex_data 3 ,
196.Xr SSL_set_ex_data 3 ,
197.Xr X509_STORE_CTX_set_ex_data 3 ,
198.Xr X509_STORE_set_ex_data 3
199.Sh HISTORY
200These functions first appeared in SSLeay 0.9.0
201and have been available since
202.Ox 2.4 .
203.Sh CAVEATS
204A relatively small minority of application programs
205attempt to change the API contract such that
206.Fn RSA_set_ex_data
207transfers ownership of the
208.Fa data
209to the
210.Fa rsa
211object.
212They do this by providing a
213.Fa free_func
214that calls
215.Xr free 3
216or higher-level
217.Fn *_free
218functions on the
219.Fa data
220and sometimes also attempt additional cleanup work as a side effect.
221.Pp
222This practice is discouraged for several reasons:
223.Bl -enum
224.It
225Due to a massive design mistake in the low-level API function
226.Xr CRYPTO_free_ex_data 3 ,
227this practice creates a possibility that
228.Xr RSA_free 3
229may fail due to memory allocation failure, consequently leaking the
230memory containing the application specific data and silently skipping
231any additional cleanup work the
232.Fa free_func
233was supposed to do, leaving the application in an undetectably
234inconsistent state.
235Arguably, leaking additional memory while trying to free some
236is most unfortunate especially when the program
237is already starved for memory.
238.It
239This practice introduces a risk of use-after-free and double-free
240bugs in case the
241.Fa rsa
242object gets destructed while a caller of
243.Fn RSA_set_ex_data
244or
245.Fn RSA_get_ex_data
246still holds a
247.Fa data
248pointer.
249No such risk exists when no
250.Fa free_func
251is installed.
252.It
253Attempting additional cleanup work in
254.Fa free_func
255is an even worse idea because
256.Fa free_func
257is unable to report any issues it might detect while doing that work.
258Instead, if any additional cleanup work is needed, it is recommended
259that the calling code takes care of that before calling
260.Xr RSA_free 3 .
261.El
262.Pp
263Even fewer application programs install a
264.Fa new_func
265that allocates memory and stores a pointer to it in the
266.Fa rsa
267object by calling
268.Xr CRYPTO_set_ex_data 3 .
269That is useless because
270.Fa new_func
271does not have access to any useful information it could store in such memory
272and because the default return value of
273.Dv NULL
274from
275.Fn RSA_get_ex_data
276is sufficient to indicate
277that no application specific data has been stored yet.
278In addition, allocating memory in
279.Fa new_func
280is also inadvisable because it introduces an additional responsibility
281for callers of
282.Fn RSA_set_ex_data
283to always call
284.Fn RSA_get_ex_data
285first, even when it is the first time the application wants to set
286application specific data in a particular
287.Fa rsa
288object, and to either modify whatever
289.Fn RSA_get_ex_data
290returns or to free it before calling
291.Fn RSA_set_ex_data .
292If that is forgotten, a memory leak results.
293.Pp
294Consequently, allocating any required memory
295is better left to the application code that calls
296.Fn RSA_set_ex_data .
297.Pp
298Installing a
299.Fa dup_func
300is often seen in combination with installing a
301.Fa free_func ,
302for obvious reasons.
303It is rarely useful because for most parent object types
304that support ex_data, including for
305.Vt RSA ,
306the library does not provide a copying API function in the first place, and
307even where copying functions exist, they tend to be fragile and error-prone.
308When a new object is needed, it is usually advisable to construct it from
309scratch whenever possible, rather than attempting a copy operation.
310.Pp
311On top of that, if
312.Fa dup_func
313fails, for example because of a memory allocation failure, the
314failure is neither reported nor detectable in any way, leaving the
315new parent object with incomplete data and potentially in an
316inconsistent state.
317.Sh BUGS
318If
319.Fn RSA_set_ex_data
320fails, recovery is very difficult.
321In particular, calling
322.Xr RSA_free 3
323on the parent
324.Fa rsa
325object right afterwards is likely to also hit a memory allocation
326failure, leaking all memory internally allocated by all earlier calls of
327.Fn RSA_set_ex_data
328on
329.Fa rsa
330rather than freeing that memory.
331In order to recover, the application program
332would have to free a sufficient amount of
333.Em other
334memory before calling
335.Xr RSA_free 3 ,
336which will rarely be feasible.
337Consequently, after a failure of
338.Fn RSA_set_ex_data ,
339terminating the program is likely the only reasonable option.
340.Pp
341If
342.Fn RSA_set_ex_data
343is called with an
344.Fa idx
345argument greater than the last one previously returned from
346.Fn RSA_get_ex_new_index ,
347it may still succeed, and though that is not guaranteed by the API,
348retrieving the
349.Fa data
350from such a bogus
351.Fa idx
352may even be possible with
353.Fn RSA_get_ex_data ,
354hiding the bug in the application program that caused passing the bogus
355.Fa idx
356to
357.Fn RSA_set_ex_data
358in the first place.
359.Pp
360If the bogus
361.Fa idx
362argument is large,
363.Fn RSA_set_ex_data
364may uselessly allocate a large amount of memory.
365Calling
366.Xr RSA_free 3
367on the parent
368.Fa rsa
369object is the only way to recover that memory.
370.Pp
371If the bogus
372.Fa idx
373argument is very large,
374.Fn RSA_set_ex_data
375is likely to cause a significant delay before eventually failing
376due to memory exhaustion.
377It is likely to return without releasing the memory already
378allocated, causing any subsequent attempt to allocate memory
379for other purposes to fail, too.
380In this situation, what was said above about failure of
381.Fn RSA_set_ex_data
382applies, so terminating the program is likely the only reasonable option.
diff --git a/src/lib/libcrypto/man/RSA_meth_new.3 b/src/lib/libcrypto/man/RSA_meth_new.3
deleted file mode 100644
index a3a5c549e5..0000000000
--- a/src/lib/libcrypto/man/RSA_meth_new.3
+++ /dev/null
@@ -1,606 +0,0 @@
1.\" $OpenBSD: RSA_meth_new.3,v 1.6 2025/01/05 15:40:42 tb Exp $
2.\" full merge up to: OpenSSL a970b14f Jul 31 18:58:40 2017 -0400
3.\" selective merge up to: OpenSSL 24907560 Sep 17 07:47:42 2018 +1000
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Richard Levitte <levitte@openssl.org>.
23.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: January 5 2025 $
70.Dt RSA_METH_NEW 3
71.Os
72.Sh NAME
73.Nm RSA_meth_new ,
74.Nm RSA_meth_dup ,
75.Nm RSA_meth_free ,
76.Nm RSA_meth_get0_name ,
77.Nm RSA_meth_set1_name ,
78.Nm RSA_meth_get_flags ,
79.Nm RSA_meth_set_flags ,
80.Nm RSA_meth_get0_app_data ,
81.Nm RSA_meth_set0_app_data ,
82.Nm RSA_meth_get_init ,
83.Nm RSA_meth_set_init ,
84.Nm RSA_meth_get_finish ,
85.Nm RSA_meth_set_finish ,
86.Nm RSA_meth_get_pub_enc ,
87.Nm RSA_meth_set_pub_enc ,
88.Nm RSA_meth_get_pub_dec ,
89.Nm RSA_meth_set_pub_dec ,
90.Nm RSA_meth_get_priv_enc ,
91.Nm RSA_meth_set_priv_enc ,
92.Nm RSA_meth_get_priv_dec ,
93.Nm RSA_meth_set_priv_dec ,
94.Nm RSA_meth_get_sign ,
95.Nm RSA_meth_set_sign ,
96.Nm RSA_meth_get_verify ,
97.Nm RSA_meth_set_verify ,
98.Nm RSA_meth_get_mod_exp ,
99.Nm RSA_meth_set_mod_exp ,
100.Nm RSA_meth_get_bn_mod_exp ,
101.Nm RSA_meth_set_bn_mod_exp ,
102.Nm RSA_meth_get_keygen ,
103.Nm RSA_meth_set_keygen
104.Nd build up RSA methods
105.Sh SYNOPSIS
106.In openssl/rsa.h
107.Ft RSA_METHOD *
108.Fo RSA_meth_new
109.Fa "const char *name"
110.Fa "int flags"
111.Fc
112.Ft RSA_METHOD *
113.Fo RSA_meth_dup
114.Fa "const RSA_METHOD *meth"
115.Fc
116.Ft void
117.Fo RSA_meth_free
118.Fa "RSA_METHOD *meth"
119.Fc
120.Ft const char *
121.Fo RSA_meth_get0_name
122.Fa "const RSA_METHOD *meth"
123.Fc
124.Ft int
125.Fo RSA_meth_set1_name
126.Fa "RSA_METHOD *meth"
127.Fa "const char *name"
128.Fc
129.Ft int
130.Fo RSA_meth_get_flags
131.Fa "const RSA_METHOD *meth"
132.Fc
133.Ft int
134.Fo RSA_meth_set_flags
135.Fa "RSA_METHOD *meth"
136.Fa "int flags"
137.Fc
138.Ft void *
139.Fo RSA_meth_get0_app_data
140.Fa "const RSA_METHOD *meth"
141.Fc
142.Ft int
143.Fo RSA_meth_set0_app_data
144.Fa "RSA_METHOD *meth"
145.Fa "void *app_data"
146.Fc
147.Ft int
148.Fo "(*RSA_meth_get_init(const RSA_METHOD *meth))"
149.Fa "RSA *rsa"
150.Fc
151.Ft int
152.Fo "RSA_meth_set_init"
153.Fa "RSA_METHOD *meth"
154.Fa "int (*init)(RSA *rsa)"
155.Fc
156.Ft int
157.Fo "(*RSA_meth_get_finish(const RSA_METHOD *meth))"
158.Fa "RSA *rsa"
159.Fc
160.Ft int
161.Fo RSA_meth_set_finish
162.Fa "RSA_METHOD *meth"
163.Fa "int (*finish)(RSA *rsa)"
164.Fc
165.Ft int
166.Fo "(*RSA_meth_get_pub_enc(const RSA_METHOD *meth))"
167.Fa "int flen"
168.Fa "const unsigned char *from"
169.Fa "unsigned char *to"
170.Fa "RSA *rsa"
171.Fa "int padding"
172.Fc
173.Ft int
174.Fo RSA_meth_set_pub_enc
175.Fa "RSA_METHOD *meth"
176.Fa "int (*pub_enc)(int flen, const unsigned char *from,\
177 unsigned char *to, RSA *rsa, int padding)"
178.Fc
179.Ft int
180.Fo "(*RSA_meth_get_pub_dec(const RSA_METHOD *meth))"
181.Fa "int flen"
182.Fa "const unsigned char *from"
183.Fa "unsigned char *to"
184.Fa "RSA *rsa"
185.Fa "int padding"
186.Fc
187.Ft int
188.Fo RSA_meth_set_pub_dec
189.Fa "RSA_METHOD *meth"
190.Fa "int (*pub_dec)(int flen, const unsigned char *from,\
191 unsigned char *to, RSA *rsa, int padding)"
192.Fc
193.Ft int
194.Fo "(*RSA_meth_get_priv_enc(const RSA_METHOD *meth))"
195.Fa "int flen"
196.Fa "const unsigned char *from"
197.Fa "unsigned char *to"
198.Fa "RSA *rsa"
199.Fa "int padding"
200.Fc
201.Ft int
202.Fo RSA_meth_set_priv_enc
203.Fa "RSA_METHOD *meth"
204.Fa "int (*priv_enc)(int flen, const unsigned char *from,\
205 unsigned char *to, RSA *rsa, int padding)"
206.Fc
207.Ft int
208.Fo "(*RSA_meth_get_priv_dec(const RSA_METHOD *meth))"
209.Fa "int flen"
210.Fa "const unsigned char *from"
211.Fa "unsigned char *to"
212.Fa "RSA *rsa"
213.Fa "int padding"
214.Fc
215.Ft int
216.Fo RSA_meth_set_priv_dec
217.Fa "RSA_METHOD *meth"
218.Fa "int (*priv_dec)(int flen, const unsigned char *from,\
219 unsigned char *to, RSA *rsa, int padding)"
220.Fc
221.Ft int
222.Fo "(*RSA_meth_get_sign(const RSA_METHOD *meth))"
223.Fa "int type"
224.Fa "const unsigned char *m"
225.Fa "unsigned int m_length"
226.Fa "unsigned char *sigret"
227.Fa "unsigned int *siglen"
228.Fa "const RSA *rsa"
229.Fc
230.Ft int
231.Fo RSA_meth_set_sign
232.Fa "RSA_METHOD *rsa"
233.Fa "int (*sign)(int type, const unsigned char *m, unsigned int m_length,\
234 unsigned char *sigret, unsigned int *siglen, const RSA *rsa)"
235.Fc
236.Ft int
237.Fo "(*RSA_meth_get_verify(const RSA_METHOD *meth))"
238.Fa "int dtype"
239.Fa "const unsigned char *m"
240.Fa "unsigned int m_length"
241.Fa "const unsigned char *sigbuf"
242.Fa "unsigned int siglen"
243.Fa "const RSA *rsa"
244.Fc
245.Ft int
246.Fo RSA_meth_set_verify
247.Fa "RSA_METHOD *rsa"
248.Fa "int (*verify)(int dtype, const unsigned char *m,\
249 unsigned int m_length, const unsigned char *sigbuf,\
250 unsigned int siglen, const RSA *rsa)"
251.Fc
252.Ft int
253.Fo "(*RSA_meth_get_mod_exp(const RSA_METHOD *meth))"
254.Fa "BIGNUM *r0"
255.Fa "const BIGNUM *i"
256.Fa "RSA *rsa"
257.Fa "BN_CTX *ctx"
258.Fc
259.Ft int
260.Fo RSA_meth_set_mod_exp
261.Fa "RSA_METHOD *meth"
262.Fa "int (*mod_exp)(BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx)"
263.Fc
264.Ft int
265.Fo "(*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))"
266.Fa "BIGNUM *r"
267.Fa "const BIGNUM *a"
268.Fa "const BIGNUM *p"
269.Fa "const BIGNUM *m"
270.Fa "BN_CTX *ctx"
271.Fa "BN_MONT_CTX *m_ctx"
272.Fc
273.Ft int
274.Fo RSA_meth_set_bn_mod_exp
275.Fa "RSA_METHOD *meth"
276.Fa "int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\
277 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)"
278.Fc
279.Ft int
280.Fo "(*RSA_meth_get_keygen(const RSA_METHOD *meth))"
281.Fa "RSA *rsa"
282.Fa "int bits"
283.Fa "BIGNUM *e"
284.Fa "BN_GENCB *cb"
285.Fc
286.Ft int
287.Fo RSA_meth_set_keygen
288.Fa "RSA_METHOD *meth"
289.Fa "int (*keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)"
290.Fc
291.Sh DESCRIPTION
292The
293.Vt RSA_METHOD
294structure holds function pointers for custom RSA implementations.
295.Pp
296.Fn RSA_meth_new
297creates a new
298.Vt RSA_METHOD
299structure.
300A copy of the NUL-terminated
301.Fa name
302is stored in the new
303.Vt RSA_METHOD
304object.
305Any new
306.Vt RSA
307object constructed from this
308.Vt RSA_METHOD
309will have the given
310.Fa flags
311set by default, as if they were set with
312.Xr RSA_set_flags 3 .
313.Pp
314.Fn RSA_meth_dup
315creates a deep copy of
316.Fa meth ,
317except that a pointer stored into it with
318.Fn RSA_meth_set0_app_data
319is copied as a pointer without creating a copy of its content.
320This might be useful for creating a new
321.Vt RSA_METHOD
322based on an existing one, but with some differences.
323.Pp
324.Fn RSA_meth_free
325destroys
326.Fa meth
327and frees any memory associated with it,
328except that memory pointed to by a pointer set with
329.Fn RSA_meth_set0_app_data
330is not freed.
331If
332.Fa meth
333is
334.Dv NULL ,
335no action occurs.
336.Pp
337.Fn RSA_meth_get0_name
338returns an internal pointer to the name of
339.Fa meth .
340.Fn RSA_meth_set1_name
341stores a copy of the NUL-terminated
342.Fa name
343in the
344.Vt RSA_METHOD
345object after freeing the previously stored name.
346Method names are ignored by the default RSA implementation
347but can be used by alternative implementations
348and by the application program.
349.Pp
350.Fn RSA_meth_get_flags
351retrieves the flags from
352.Fa meth .
353Flags are documented in
354.Xr RSA_test_flags 3 .
355.Fn RSA_meth_set_flags
356overwrites all flags in
357.Fa meth .
358Unlike
359.Xr RSA_set_flags 3 ,
360it does not preserve any flags that were set before the call.
361.Pp
362.Fn RSA_meth_get0_app_data
363and
364.Fn RSA_meth_set0_app_data
365get and set a pointer to implementation-specific data.
366The function
367.Fn RSA_meth_free
368does not
369.Xr free 3
370the memory pointed to by
371.Fa app_data .
372The default RSA implementation does not use
373.Fa app_data .
374.Pp
375.Fn RSA_meth_get_init
376and
377.Fn RSA_meth_set_init
378get and set an optional function used when creating a new
379.Vt RSA
380object.
381Unless
382.Fa init
383is
384.Dv NULL ,
385it will be called at the end of
386.Xr RSA_new 3 ,
387.Xr RSA_new_method 3 ,
388and
389.Xr RSA_set_method 3 ,
390passing a pointer to the newly allocated or reset
391.Vt RSA
392object as an argument.
393The default RSA implementation,
394.Xr RSA_PKCS1_SSLeay 3 ,
395contains an
396.Fa init
397function equivalent to calling
398.Xr RSA_set_flags 3
399with an argument of
400.Dv RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE .
401.Pp
402.Fn RSA_meth_get_finish
403and
404.Fn RSA_meth_set_finish
405get and set an optional function for destroying an
406.Vt RSA
407object.
408Unless
409.Fa finish
410is
411.Dv NULL ,
412it will be called from
413.Xr RSA_set_method 3
414and from
415.Xr RSA_free 3 .
416It takes the same argument as
417.Xr RSA_free 3
418and is intended to do RSA implementation specific cleanup.
419The memory used by the
420.Vt RSA
421object itself should not be freed by the
422.Fa finish
423function.
424The default RSA implementation contains a
425.Fa finish
426function freeing the memory used by the
427.Dv RSA_FLAG_CACHE_PUBLIC
428and
429.Dv RSA_FLAG_CACHE_PRIVATE
430caches.
431.Pp
432.Fn RSA_meth_get_pub_enc ,
433.Fn RSA_meth_set_pub_enc ,
434.Fn RSA_meth_get_pub_dec ,
435.Fn RSA_meth_set_pub_dec ,
436.Fn RSA_meth_get_priv_enc ,
437.Fn RSA_meth_set_priv_enc ,
438.Fn RSA_meth_get_priv_dec ,
439and
440.Fn RSA_meth_set_priv_dec
441get and set the mandatory functions
442used for public and private key encryption and decryption.
443These functions will be called from
444.Xr RSA_public_encrypt 3 ,
445.Xr RSA_public_decrypt 3 ,
446.Xr RSA_private_encrypt 3 ,
447and
448.Xr RSA_private_decrypt 3 ,
449respectively, and take the same parameters as those.
450.Pp
451.Fn RSA_meth_get_sign ,
452.Fn RSA_meth_set_sign ,
453.Fn RSA_meth_get_verify ,
454and
455.Fn RSA_meth_set_verify
456get and set the optional functions
457used for creating and verifying an RSA signature.
458.Pp
459.Fn RSA_meth_get_mod_exp
460and
461.Fn RSA_meth_set_mod_exp
462get and set the function
463used for Chinese Remainder Theorem (CRT) computations involving the
464.Fa p ,
465.Fa q ,
466.Fa dmp1 ,
467.Fa dmq1 ,
468and
469.Fa iqmp
470fields of an
471.Vt RSA
472object.
473It is used by the default RSA implementation during
474.Xr RSA_private_encrypt 3
475and
476.Xr RSA_private_decrypt 3
477when the required components of the private key are available
478or when the
479.Dv RSA_FLAG_EXT_PKEY
480flag is set.
481.Pp
482.Fn RSA_meth_get_bn_mod_exp
483and
484.Fn RSA_meth_set_bn_mod_exp
485get and set the function used for CRT computations,
486specifically the value r =
487.Fa a
488\(ha
489.Fa p
490mod
491.Fa m .
492It is used by the default RSA implementation during
493.Xr RSA_public_encrypt 3
494and
495.Xr RSA_public_decrypt 3
496and as a fallback during
497.Xr RSA_private_encrypt 3
498and
499.Xr RSA_private_decrypt 3 .
500.Pp
501.Fn RSA_meth_get_keygen
502and
503.Fn RSA_meth_set_keygen
504get and set the optional function used for generating a new RSA key pair.
505Unless
506.Fa keygen
507is
508.Dv NULL ,
509it will be called from
510.Xr RSA_generate_key_ex 3
511and takes the same parameters.
512Otherwise, a builtin default implementation is used.
513.Sh RETURN VALUES
514.Fn RSA_meth_new
515and
516.Fn RSA_meth_dup
517return the newly allocated
518.Vt RSA_METHOD
519object or
520.Dv NULL
521on failure.
522.Pp
523.Fn RSA_meth_get0_name
524returns an internal pointer which must not be freed by the caller.
525.Pp
526.Fn RSA_meth_get_flags
527returns zero or more
528.Dv RSA_FLAG_*
529constants OR'ed together, or 0 if no flags are set in
530.Fa meth .
531.Pp
532.Fn RSA_meth_get0_app_data
533returns the pointer that was earlier passed to
534.Fn RSA_meth_set0_app_data
535or
536.Dv NULL
537otherwise.
538.Pp
539All other
540.Fn RSA_meth_get_*
541functions return the appropriate function pointer that has been set
542with the corresponding
543.Fn RSA_meth_set_*
544function, or
545.Dv NULL
546if no such pointer has been set in
547.Fa meth .
548.Pp
549All
550.Fn RSA_meth_set*
551functions return 1 on success or 0 on failure.
552In the current implementation, only
553.Fn RSA_meth_set1_name
554can actually fail.
555.Sh SEE ALSO
556.Xr RSA_generate_key_ex 3 ,
557.Xr RSA_new 3 ,
558.Xr RSA_private_encrypt 3 ,
559.Xr RSA_public_encrypt 3 ,
560.Xr RSA_set_flags 3 ,
561.Xr RSA_set_method 3 ,
562.Xr RSA_sign 3
563.Sh HISTORY
564These functions first appeared in OpenSSL 1.1.0.
565.Fn RSA_meth_new ,
566.Fn RSA_meth_dup ,
567.Fn RSA_meth_free ,
568.Fn RSA_meth_set_finish ,
569.Fn RSA_meth_set_priv_enc ,
570and
571.Fn RSA_meth_set_priv_dec
572have been available since
573.Ox 6.3 ,
574.Fn RSA_meth_set1_name
575and
576.Fn RSA_meth_get_finish
577since
578.Ox 6.4 ,
579and
580.Fn RSA_meth_get0_name ,
581.Fn RSA_meth_get_flags ,
582.Fn RSA_meth_set_flags ,
583.Fn RSA_meth_get0_app_data ,
584.Fn RSA_meth_set0_app_data ,
585.Fn RSA_meth_get_init ,
586.Fn RSA_meth_set_init ,
587.Fn RSA_meth_set_finish ,
588.Fn RSA_meth_get_pub_enc ,
589.Fn RSA_meth_set_pub_enc ,
590.Fn RSA_meth_get_pub_dec ,
591.Fn RSA_meth_set_pub_dec ,
592.Fn RSA_meth_get_priv_enc ,
593.Fn RSA_meth_get_priv_dec ,
594.Fn RSA_meth_get_sign ,
595.Fn RSA_meth_set_sign ,
596.Fn RSA_meth_get_verify ,
597.Fn RSA_meth_set_verify ,
598.Fn RSA_meth_get_mod_exp ,
599.Fn RSA_meth_set_mod_exp ,
600.Fn RSA_meth_get_bn_mod_exp ,
601.Fn RSA_meth_set_bn_mod_exp ,
602.Fn RSA_meth_get_keygen ,
603and
604.Fn RSA_meth_set_keygen
605since
606.Ox 6.6 .
diff --git a/src/lib/libcrypto/man/RSA_new.3 b/src/lib/libcrypto/man/RSA_new.3
deleted file mode 100644
index f5c7929e77..0000000000
--- a/src/lib/libcrypto/man/RSA_new.3
+++ /dev/null
@@ -1,248 +0,0 @@
1.\" $OpenBSD: RSA_new.3,v 1.18 2023/11/19 21:03:22 tb Exp $
2.\" full merge up to:
3.\" OpenSSL doc/man3/RSA_new.pod e9b77246 Jan 20 19:58:49 2017 +0100
4.\" OpenSSL doc/crypto/rsa.pod 35d2e327 Jun 3 16:19:49 2016 -0400 (final)
5.\"
6.\" This file is a derived work.
7.\" The changes are covered by the following Copyright and license:
8.\"
9.\" Copyright (c) 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
10.\"
11.\" Permission to use, copy, modify, and distribute this software for any
12.\" purpose with or without fee is hereby granted, provided that the above
13.\" copyright notice and this permission notice appear in all copies.
14.\"
15.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22.\"
23.\" The original file was written by Ulf Moeller <ulf@openssl.org>.
24.\" Copyright (c) 2000, 2002, 2016 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: November 19 2023 $
71.Dt RSA_NEW 3
72.Os
73.Sh NAME
74.Nm RSA_new ,
75.Nm RSAPrivateKey_dup ,
76.Nm RSAPublicKey_dup ,
77.Nm RSA_up_ref ,
78.Nm RSA_free
79.Nd allocate and free RSA objects
80.Sh SYNOPSIS
81.In openssl/rsa.h
82.Ft RSA *
83.Fn RSA_new void
84.Ft RSA *
85.Fo RSAPrivateKey_dup
86.Fa "RSA *rsa"
87.Fc
88.Ft RSA *
89.Fo RSAPublicKey_dup
90.Fa "RSA *rsa"
91.Fc
92.Ft int
93.Fo RSA_up_ref
94.Fa "RSA *rsa"
95.Fc
96.Ft void
97.Fo RSA_free
98.Fa "RSA *rsa"
99.Fc
100.Sh DESCRIPTION
101The RSA functions implement RSA public key encryption and signatures
102as defined in PKCS #1 v2.0 (RFC 2437).
103.Pp
104.Fn RSA_new
105allocates and initializes an
106.Vt RSA
107structure, setting the reference count to 1.
108It is equivalent to calling
109.Xr RSA_new_method 3
110with a
111.Dv NULL
112argument.
113.Pp
114.Fn RSAPrivateKey_dup
115calls
116.Fn RSA_new
117and copies the public and private key components from
118.Fa rsa
119into the new structure.
120.Fn RSAPublicKey_dup
121does the same except that it copies the public key components only.
122.Pp
123.Fn RSA_up_ref
124increments the reference count by 1.
125.Pp
126.Fn RSA_free
127decrements the reference count by 1.
128If it reaches 0, it calls the optional
129.Fa finish
130function set up with
131.Xr RSA_meth_set_finish 3
132and frees the
133.Vt RSA
134structure and its components.
135The key is erased before the memory is returned to the system.
136If
137.Fa rsa
138is a
139.Dv NULL
140pointer, no action occurs.
141.Pp
142The
143.Vt RSA
144structure consists of several
145.Vt BIGNUM
146components.
147It can contain public as well as private RSA keys:
148.Bd -literal
149typedef struct {
150 BIGNUM *n; // public modulus
151 BIGNUM *e; // public exponent
152 BIGNUM *d; // private exponent
153 BIGNUM *p; // secret prime factor
154 BIGNUM *q; // secret prime factor
155 BIGNUM *dmp1; // d mod (p-1)
156 BIGNUM *dmq1; // d mod (q-1)
157 BIGNUM *iqmp; // q^-1 mod p
158 // ...
159} RSA;
160.Ed
161.Pp
162In public keys, the private exponent
163.Fa d
164and the related secret values
165.Fa p , q , dmp1 , dmp2 ,
166and
167.Fa iqmp
168are
169.Dv NULL .
170.Pp
171.Fa p ,
172.Fa q ,
173.Fa dmp1 ,
174.Fa dmq1 ,
175and
176.Fa iqmp
177may be
178.Dv NULL
179in private keys, but the RSA operations are much faster when these
180values are available.
181.Pp
182Note that RSA keys may use non-standard
183.Vt RSA_METHOD
184implementations.
185In some cases, these
186.Vt BIGNUM
187values will not be used by the implementation or may be used for
188alternative data storage.
189For this reason, applications should generally avoid using
190.Vt RSA
191structure elements directly and instead use API functions to query
192or modify keys.
193.Sh RETURN VALUES
194.Fn RSA_new ,
195.Fn RSAPrivateKey_dup ,
196and
197.Fn RSAPublicKey_dup
198return a pointer to the newly allocated structure, or
199.Dv NULL
200if an error occurs.
201An error code can be obtained by
202.Xr ERR_get_error 3 .
203.Pp
204.Fn RSA_up_ref
205returns 1 for success or 0 for failure.
206.Sh SEE ALSO
207.Xr BN_new 3 ,
208.Xr crypto 3 ,
209.Xr d2i_RSAPublicKey 3 ,
210.Xr DH_new 3 ,
211.Xr DSA_new 3 ,
212.Xr EVP_PKEY_set1_RSA 3 ,
213.Xr RSA_blinding_on 3 ,
214.Xr RSA_check_key 3 ,
215.Xr RSA_generate_key 3 ,
216.Xr RSA_get0_key 3 ,
217.Xr RSA_get_ex_new_index 3 ,
218.Xr RSA_meth_new 3 ,
219.Xr RSA_padding_add_PKCS1_type_1 3 ,
220.Xr RSA_pkey_ctx_ctrl 3 ,
221.Xr RSA_print 3 ,
222.Xr RSA_private_encrypt 3 ,
223.Xr RSA_PSS_PARAMS_new 3 ,
224.Xr RSA_public_encrypt 3 ,
225.Xr RSA_security_bits 3 ,
226.Xr RSA_set_method 3 ,
227.Xr RSA_sign 3 ,
228.Xr RSA_sign_ASN1_OCTET_STRING 3 ,
229.Xr RSA_size 3
230.Sh STANDARDS
231SSL, PKCS #1 v2.0
232.Pp
233RSA was covered by a US patent which expired in September 2000.
234.Sh HISTORY
235.Fn RSA_new
236and
237.Fn RSA_free
238appeared in SSLeay 0.4 or earlier.
239.Fn RSAPrivateKey_dup
240first appeared in SSLeay 0.5.1 and
241.Fn RSAPublicKey_dup
242in SSLeay 0.5.2.
243These functions have been available since
244.Ox 2.4 .
245.Pp
246.Fn RSA_up_ref
247first appeared in OpenSSL 0.9.7 and has been available since
248.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/RSA_padding_add_PKCS1_type_1.3 b/src/lib/libcrypto/man/RSA_padding_add_PKCS1_type_1.3
deleted file mode 100644
index e7c3a2a624..0000000000
--- a/src/lib/libcrypto/man/RSA_padding_add_PKCS1_type_1.3
+++ /dev/null
@@ -1,236 +0,0 @@
1.\" $OpenBSD: RSA_padding_add_PKCS1_type_1.3,v 1.8 2018/03/21 16:09:51 schwarze Exp $
2.\" OpenSSL 1e3f62a3 Jul 17 16:47:13 2017 +0200
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 21 2018 $
52.Dt RSA_PADDING_ADD_PKCS1_TYPE_1 3
53.Os
54.Sh NAME
55.Nm RSA_padding_add_PKCS1_type_1 ,
56.Nm RSA_padding_check_PKCS1_type_1 ,
57.Nm RSA_padding_add_PKCS1_type_2 ,
58.Nm RSA_padding_check_PKCS1_type_2 ,
59.Nm RSA_padding_add_PKCS1_OAEP ,
60.Nm RSA_padding_check_PKCS1_OAEP ,
61.Nm RSA_padding_add_none ,
62.Nm RSA_padding_check_none
63.Nd asymmetric encryption padding
64.Sh SYNOPSIS
65.In openssl/rsa.h
66.Ft int
67.Fo RSA_padding_add_PKCS1_type_1
68.Fa "unsigned char *to"
69.Fa "int tlen"
70.Fa "unsigned char *f"
71.Fa "int fl"
72.Fc
73.Ft int
74.Fo RSA_padding_check_PKCS1_type_1
75.Fa "unsigned char *to"
76.Fa "int tlen"
77.Fa "unsigned char *f"
78.Fa "int fl"
79.Fa "int rsa_len"
80.Fc
81.Ft int
82.Fo RSA_padding_add_PKCS1_type_2
83.Fa "unsigned char *to"
84.Fa "int tlen"
85.Fa "unsigned char *f"
86.Fa "int fl"
87.Fc
88.Ft int
89.Fo RSA_padding_check_PKCS1_type_2
90.Fa "unsigned char *to"
91.Fa "int tlen"
92.Fa "unsigned char *f"
93.Fa "int fl"
94.Fa "int rsa_len"
95.Fc
96.Ft int
97.Fo RSA_padding_add_PKCS1_OAEP
98.Fa "unsigned char *to"
99.Fa "int tlen"
100.Fa "unsigned char *f"
101.Fa "int fl"
102.Fa "unsigned char *p"
103.Fa "int pl"
104.Fc
105.Ft int
106.Fo RSA_padding_check_PKCS1_OAEP
107.Fa "unsigned char *to"
108.Fa "int tlen"
109.Fa "unsigned char *f"
110.Fa "int fl"
111.Fa "int rsa_len"
112.Fa "unsigned char *p"
113.Fa "int pl"
114.Fc
115.Ft int
116.Fo RSA_padding_add_none
117.Fa "unsigned char *to"
118.Fa "int tlen"
119.Fa "unsigned char *f"
120.Fa "int fl"
121.Fc
122.Ft int
123.Fo RSA_padding_check_none
124.Fa "unsigned char *to"
125.Fa "int tlen"
126.Fa "unsigned char *f"
127.Fa "int fl"
128.Fa "int rsa_len"
129.Fc
130.Sh DESCRIPTION
131These functions are called from the RSA encrypt, decrypt, sign, and
132verify functions.
133Normally they should not be called from application programs.
134.Pp
135However, they can also be called directly to implement padding for other
136asymmetric ciphers.
137.Fn RSA_padding_add_PKCS1_OAEP
138and
139.Fn RSA_padding_check_PKCS1_OAEP
140may be used in an application combined with
141.Dv RSA_NO_PADDING
142in order to implement OAEP with an encoding parameter.
143.Pp
144.Fn RSA_padding_add_*
145encodes
146.Fa fl
147bytes from
148.Fa f
149so as to fit into
150.Fa tlen
151bytes and stores the result at
152.Fa to .
153An error occurs if
154.Fa fl
155does not meet the size requirements of the encoding method.
156.Pp
157The following encoding methods are implemented:
158.Pp
159.Bl -tag -width PKCS1_type_2 -compact
160.It PKCS1_type_1
161PKCS #1 v2.0 EMSA-PKCS1-v1_5 (PKCS #1 v1.5 block type 1);
162used for signatures
163.It PKCS1_type_2
164PKCS #1 v2.0 EME-PKCS1-v1_5 (PKCS #1 v1.5 block type 2)
165.It PKCS1_OAEP
166PKCS #1 v2.0 EME-OAEP
167.It none
168simply copy the data
169.El
170.Pp
171.Fn RSA_padding_check_*
172verifies that the
173.Fa fl
174bytes at
175.Fa f
176contain a valid encoding for a
177.Fa rsa_len
178byte RSA key in the respective encoding method and stores the recovered
179data of at most
180.Fa tlen
181bytes (for
182.Dv RSA_NO_PADDING :
183of size
184.Fa tlen )
185at
186.Fa to .
187.Pp
188For
189.Fn RSA_padding_*_OAEP ,
190.Fa p
191points to the encoding parameter of length
192.Fa pl .
193.Fa p
194may be
195.Dv NULL
196if
197.Fa pl
198is 0.
199.Sh RETURN VALUES
200The
201.Fn RSA_padding_add_*
202functions return 1 on success or 0 on error.
203The
204.Fn RSA_padding_check_*
205functions return the length of the recovered data or -1 on error.
206Error codes can be obtained by calling
207.Xr ERR_get_error 3 .
208.Sh SEE ALSO
209.Xr RSA_new 3 ,
210.Xr RSA_private_decrypt 3 ,
211.Xr RSA_public_encrypt 3 ,
212.Xr RSA_sign 3 ,
213.Xr RSA_verify 3
214.Sh HISTORY
215.Fn RSA_padding_add_PKCS1_type_1 ,
216.Fn RSA_padding_check_PKCS1_type_1 ,
217.Fn RSA_padding_add_PKCS1_type_2 ,
218.Fn RSA_padding_check_PKCS1_type_2 ,
219.Fn RSA_padding_add_none ,
220and
221.Fn RSA_padding_check_none
222first appeared in SSLeay 0.9.0 and have been available since
223.Ox 2.4 .
224.Pp
225.Fn RSA_padding_add_PKCS1_OAEP
226and
227.Fn RSA_padding_check_PKCS1_OAEP
228first appeared in OpenSSL 0.9.2b and have been available since
229.Ox 2.6 .
230.Sh BUGS
231The
232.Fn RSA_padding_check_PKCS1_type_2
233padding check leaks timing information which can potentially be
234used to mount a Bleichenbacher padding oracle attack.
235This is an inherent weakness in the PKCS #1 v1.5 padding design.
236Prefer PKCS1_OAEP padding.
diff --git a/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3 b/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3
deleted file mode 100644
index 3d4e79cc47..0000000000
--- a/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3
+++ /dev/null
@@ -1,402 +0,0 @@
1.\" $OpenBSD: RSA_pkey_ctx_ctrl.3,v 1.8 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL man3/EVP_PKEY_CTX_ctrl.pod 99d63d46 Oct 26 13:56:48 2016 -0400
4.\" OpenSSL man3/EVP_PKEY_CTX_set_rsa_pss_keygen_md.pod
5.\" 87103969 Oct 1 14:11:57 2018 -0700
6.\" selective merge up to:
7.\" OpenSSL man3/EVP_PKEY_CTX_ctrl.pod df75c2b f Dec 9 01:02:36 2018 +0100
8.\"
9.\" This file was written by Dr. Stephen Henson <steve@openssl.org>
10.\" and Antoine Salon <asalon@vmware.com>.
11.\" Copyright (c) 2006, 2009, 2013, 2014, 2015, 2017, 2018 The OpenSSL Project.
12.\" All rights reserved.
13.\"
14.\" Redistribution and use in source and binary forms, with or without
15.\" modification, are permitted provided that the following conditions
16.\" are met:
17.\"
18.\" 1. Redistributions of source code must retain the above copyright
19.\" notice, this list of conditions and the following disclaimer.
20.\"
21.\" 2. Redistributions in binary form must reproduce the above copyright
22.\" notice, this list of conditions and the following disclaimer in
23.\" the documentation and/or other materials provided with the
24.\" distribution.
25.\"
26.\" 3. All advertising materials mentioning features or use of this
27.\" software must display the following acknowledgment:
28.\" "This product includes software developed by the OpenSSL Project
29.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
30.\"
31.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
32.\" endorse or promote products derived from this software without
33.\" prior written permission. For written permission, please contact
34.\" openssl-core@openssl.org.
35.\"
36.\" 5. Products derived from this software may not be called "OpenSSL"
37.\" nor may "OpenSSL" appear in their names without prior written
38.\" permission of the OpenSSL Project.
39.\"
40.\" 6. Redistributions of any form whatsoever must retain the following
41.\" acknowledgment:
42.\" "This product includes software developed by the OpenSSL Project
43.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
44.\"
45.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
46.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
48.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
49.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
51.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
52.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
54.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
56.\" OF THE POSSIBILITY OF SUCH DAMAGE.
57.\"
58.Dd $Mdocdate: December 6 2024 $
59.Dt RSA_PKEY_CTX_CTRL 3
60.Os
61.Sh NAME
62.Nm RSA_pkey_ctx_ctrl ,
63.Nm EVP_PKEY_CTX_set_rsa_padding ,
64.Nm EVP_PKEY_CTX_get_rsa_padding ,
65.Nm EVP_PKEY_CTX_set_rsa_keygen_bits ,
66.Nm EVP_PKEY_CTX_set_rsa_keygen_pubexp ,
67.Nm EVP_PKEY_CTX_set_rsa_mgf1_md ,
68.Nm EVP_PKEY_CTX_get_rsa_mgf1_md ,
69.Nm EVP_PKEY_CTX_set_rsa_oaep_md ,
70.Nm EVP_PKEY_CTX_get_rsa_oaep_md ,
71.Nm EVP_PKEY_CTX_set0_rsa_oaep_label ,
72.Nm EVP_PKEY_CTX_get0_rsa_oaep_label ,
73.Nm EVP_PKEY_CTX_set_rsa_pss_saltlen ,
74.Nm EVP_PKEY_CTX_get_rsa_pss_saltlen ,
75.Nm EVP_PKEY_CTX_set_rsa_pss_keygen_md ,
76.Nm EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md ,
77.Nm EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen
78.Nd RSA private key control operations
79.Sh SYNOPSIS
80.In openssl/rsa.h
81.Ft int
82.Fo RSA_pkey_ctx_ctrl
83.Fa "EVP_PKEY_CTX *ctx"
84.Fa "int optype"
85.Fa "int cmd"
86.Fa "int p1"
87.Fa "void *p2"
88.Fc
89.Ft int
90.Fo EVP_PKEY_CTX_set_rsa_padding
91.Fa "EVP_PKEY_CTX *ctx"
92.Fa "int pad"
93.Fc
94.Ft int
95.Fo EVP_PKEY_CTX_get_rsa_padding
96.Fa "EVP_PKEY_CTX *ctx"
97.Fa "int *ppad"
98.Fc
99.Ft int
100.Fo EVP_PKEY_CTX_set_rsa_keygen_bits
101.Fa "EVP_PKEY_CTX *ctx"
102.Fa "int mbits"
103.Fc
104.Ft int
105.Fo EVP_PKEY_CTX_set_rsa_keygen_pubexp
106.Fa "EVP_PKEY_CTX *ctx"
107.Fa "BIGNUM *pubexp"
108.Fc
109.Ft int
110.Fo EVP_PKEY_CTX_set_rsa_mgf1_md
111.Fa "EVP_PKEY_CTX *ctx"
112.Fa "const EVP_MD *md"
113.Fc
114.Ft int
115.Fo EVP_PKEY_CTX_get_rsa_mgf1_md
116.Fa "EVP_PKEY_CTX *ctx"
117.Fa "const EVP_MD **pmd"
118.Fc
119.Ft int
120.Fo EVP_PKEY_CTX_set_rsa_oaep_md
121.Fa "EVP_PKEY_CTX *ctx"
122.Fa "const EVP_MD *md"
123.Fc
124.Ft int
125.Fo EVP_PKEY_CTX_get_rsa_oaep_md
126.Fa "EVP_PKEY_CTX *ctx"
127.Fa "const EVP_MD **pmd"
128.Fc
129.Ft int
130.Fo EVP_PKEY_CTX_set0_rsa_oaep_label
131.Fa "EVP_PKEY_CTX *ctx"
132.Fa "unsigned char *label"
133.Fa "int len"
134.Fc
135.Ft int
136.Fo EVP_PKEY_CTX_get0_rsa_oaep_label
137.Fa "EVP_PKEY_CTX *ctx"
138.Fa "unsigned char **plabel"
139.Fc
140.Ft int
141.Fo EVP_PKEY_CTX_set_rsa_pss_saltlen
142.Fa "EVP_PKEY_CTX *ctx"
143.Fa "int len"
144.Fc
145.Ft int
146.Fo EVP_PKEY_CTX_get_rsa_pss_saltlen
147.Fa "EVP_PKEY_CTX *ctx"
148.Fa "int *plen"
149.Fc
150.Ft int
151.Fo EVP_PKEY_CTX_set_rsa_pss_keygen_md
152.Fa "EVP_PKEY_CTX *pctx"
153.Fa "const EVP_MD *md"
154.Fc
155.Ft int
156.Fo EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md
157.Fa "EVP_PKEY_CTX *pctx"
158.Fa "const EVP_MD *md"
159.Fc
160.Ft int
161.Fo EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen
162.Fa "EVP_PKEY_CTX *pctx"
163.Fa "int saltlen"
164.Fc
165.Sh DESCRIPTION
166The function
167.Fn RSA_pkey_ctx_ctrl
168is a shallow wrapper around
169.Xr EVP_PKEY_CTX_ctrl 3
170which only succeeds if
171.Fa ctx
172matches either
173.Dv EVP_PKEY_RSA
174or
175.Dv EVP_PKEY_RSA_PSS .
176.Pp
177All the remaining "functions" are implemented as macros.
178.Pp
179The
180.Fn EVP_PKEY_CTX_set_rsa_padding
181macro sets the RSA padding mode for
182.Fa ctx .
183The
184.Fa pad
185parameter can take the value
186.Dv RSA_PKCS1_PADDING
187for PKCS#1 padding,
188.Dv RSA_NO_PADDING
189for no padding,
190.Dv RSA_PKCS1_OAEP_PADDING
191for OAEP padding (encrypt and decrypt only),
192.Dv RSA_X931_PADDING
193for X9.31 padding (signature operations only) and
194.Dv RSA_PKCS1_PSS_PADDING
195(sign and verify only).
196Only the last one can be used with keys of the type
197.Dv EVP_PKEY_RSA_PSS .
198.Pp
199Two RSA padding modes behave differently if
200.Xr EVP_PKEY_CTX_set_signature_md 3
201is used.
202If this macro is called for PKCS#1 padding, the plaintext buffer is an
203actual digest value and is encapsulated in a
204.Vt DigestInfo
205structure according to PKCS#1 when signing and this structure is
206expected (and stripped off) when verifying.
207If this control is not used with RSA and PKCS#1 padding then the
208supplied data is used directly and not encapsulated.
209In the case of X9.31 padding for RSA the algorithm identifier byte is
210added or checked and removed if this control is called.
211If it is not called then the first byte of the plaintext buffer is
212expected to be the algorithm identifier byte.
213.Pp
214The
215.Fn EVP_PKEY_CTX_get_rsa_padding
216macro retrieves the RSA padding mode for
217.Fa ctx .
218.Pp
219The
220.Fn EVP_PKEY_CTX_set_rsa_keygen_bits
221macro sets the RSA key length for RSA or RSA-PSS key generation to
222.Fa mbits .
223The smallest supported value is 512 bits.
224If not specified, 1024 bits is used.
225.Pp
226The
227.Fn EVP_PKEY_CTX_set_rsa_keygen_pubexp
228macro sets the public exponent value for RSA or RSA-PSS key generation to
229.Fa pubexp .
230Currently, it should be an odd integer.
231The
232.Fa pubexp
233pointer is used internally by this function, so it should not be modified
234or freed after the call.
235If this macro is not called, then 65537 is used.
236.Pp
237The
238.Fn EVP_PKEY_CTX_set_rsa_mgf1_md
239macro sets the MGF1 digest for RSA padding schemes to
240.Fa md .
241Unless explicitly specified, the signing digest is used.
242The padding mode must have been set to
243.Dv RSA_PKCS1_OAEP_PADDING
244or
245.Dv RSA_PKCS1_PSS_PADDING .
246If the key is of the type
247.Dv EVP_PKEY_RSA_PSS
248and has usage restrictions, an error occurs if an attempt is made
249to set the digest to anything other than the restricted value.
250.Pp
251The
252.Fn EVP_PKEY_CTX_get_rsa_mgf1_md
253macro retrieves the MGF1 digest for
254.Fa ctx .
255Unless explicitly specified, the signing digest is used.
256The padding mode must have been set to
257.Dv RSA_PKCS1_OAEP_PADDING
258or
259.Dv RSA_PKCS1_PSS_PADDING .
260.Ss Optimal asymmetric encryption padding
261The following macros require that the padding mode was set to
262.Dv RSA_PKCS1_OAEP_PADDING .
263.Pp
264The
265.Fn EVP_PKEY_CTX_set_rsa_oaep_md
266macro sets the message digest type used in RSA OAEP to
267.Fa md .
268.Pp
269The
270.Fn EVP_PKEY_CTX_get_rsa_oaep_md
271macro gets the message digest type used in RSA OAEP to
272.Pf * Fa pmd .
273.Pp
274The
275.Fn EVP_PKEY_CTX_set0_rsa_oaep_label
276macro sets the RSA OAEP label to
277.Fa label
278and its length to
279.Fa len .
280If
281.Fa label
282is
283.Dv NULL
284or
285.Fa len
286is 0, the label is cleared.
287The library takes ownership of the label so the caller should not
288free the original memory pointed to by
289.Fa label .
290.Pp
291The
292.Fn EVP_PKEY_CTX_get0_rsa_oaep_label
293macro gets the RSA OAEP label to
294.Pf * Fa plabel .
295The return value is the label length.
296The resulting pointer is owned by the library and should not be
297freed by the caller.
298.Ss Probabilistic signature scheme
299The following macros require that the padding mode was set to
300.Dv RSA_PKCS1_PSS_PADDING .
301.Pp
302The
303.Fn EVP_PKEY_CTX_set_rsa_pss_saltlen
304macro sets the RSA PSS salt length to
305.Fa len .
306Three special values are supported:
307.Dv RSA_PSS_SALTLEN_DIGEST
308sets the salt length to the digest length.
309.Dv RSA_PSS_SALTLEN_MAX
310sets the salt length to the maximum permissible value.
311When signing,
312.Dv RSA_PSS_SALTLEN_AUTO
313sets the salt length to the maximum permissible value.
314When verifying,
315.Dv RSA_PSS_SALTLEN_AUTO
316causes the salt length to be automatically determined based on the
317PSS block structure.
318If this macro is not called, a salt length value of
319.Dv RSA_PSS_SALTLEN_AUTO
320is used by default.
321.Pp
322If the key has usage restrictions and an attempt is made to set the
323salt length below the minimum value, an error occurs.
324Also, if the key has usage restrictions,
325.Dv RSA_PSS_SALTLEN_AUTO
326is not supported for verification.
327.Pp
328The
329.Fn EVP_PKEY_CTX_get_rsa_pss_saltlen
330macro retrieves the RSA PSS salt length for
331.Fa ctx .
332.Pp
333Optional parameter restrictions can be specified when generating a PSS
334key.
335If any restrictions are set using the macros described below,
336then all parameters are restricted.
337For example, setting a minimum salt length also restricts the digest and
338MGF1 algorithms.
339If any restrictions are in place, then they are reflected in the
340corresponding parameters of the public key when (for example) a
341certificate request is signed.
342.Pp
343.Fn EVP_PKEY_CTX_set_rsa_pss_keygen_md
344restricts the digest algorithm the generated key can use to
345.Fa md .
346.Pp
347.Fn EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md
348restricts the MGF1 algorithm the generated key can use to
349.Fa md .
350.Pp
351.Fn EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen
352restricts the minimum salt length to
353.Fa saltlen .
354.Sh RETURN VALUES
355These functions return a positive value for success or 0 or a negative
356value for failure.
357In particular, a return value of -2 indicates the operation is not
358supported by the public key algorithm.
359.Sh SEE ALSO
360.Xr EVP_DigestInit 3 ,
361.Xr EVP_PKEY_CTX_ctrl 3 ,
362.Xr EVP_PKEY_CTX_new 3 ,
363.Xr EVP_PKEY_decrypt 3 ,
364.Xr EVP_PKEY_derive 3 ,
365.Xr EVP_PKEY_encrypt 3 ,
366.Xr EVP_PKEY_get_default_digest_nid 3 ,
367.Xr EVP_PKEY_keygen 3 ,
368.Xr EVP_PKEY_sign 3 ,
369.Xr EVP_PKEY_verify 3 ,
370.Xr EVP_PKEY_verify_recover 3
371.Sh HISTORY
372The functions
373.Fn EVP_PKEY_CTX_set_rsa_padding ,
374.Fn EVP_PKEY_CTX_set_rsa_keygen_bits ,
375.Fn EVP_PKEY_CTX_set_rsa_keygen_pubexp ,
376and
377.Fn EVP_PKEY_CTX_set_rsa_pss_saltlen
378first appeared in OpenSSL 1.0.0 and have been available since
379.Ox 4.9 .
380.Pp
381The functions
382.Fn EVP_PKEY_CTX_get_rsa_padding ,
383.Fn EVP_PKEY_CTX_set_rsa_mgf1_md ,
384.Fn EVP_PKEY_CTX_get_rsa_mgf1_md ,
385and
386.Fn EVP_PKEY_CTX_get_rsa_pss_saltlen
387first appeared in OpenSSL 1.0.1 and have been available since
388.Ox 5.3 .
389.Pp
390The functions
391.Fn EVP_PKEY_CTX_set_rsa_oaep_md ,
392.Fn EVP_PKEY_CTX_get_rsa_oaep_md ,
393.Fn EVP_PKEY_CTX_set0_rsa_oaep_label ,
394and
395.Fn EVP_PKEY_CTX_get0_rsa_oaep_label
396first appeared in OpenSSL 1.0.2 and have been available since
397.Ox 6.7 .
398.Pp
399The function
400.Fn RSA_pkey_ctx_ctrl
401first appeared in OpenSSL 1.1.1 and has been available since
402.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/RSA_print.3 b/src/lib/libcrypto/man/RSA_print.3
deleted file mode 100644
index 767241ce1c..0000000000
--- a/src/lib/libcrypto/man/RSA_print.3
+++ /dev/null
@@ -1,144 +0,0 @@
1.\" $OpenBSD: RSA_print.3,v 1.9 2019/06/06 01:06:59 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2002, 2003 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 6 2019 $
52.Dt RSA_PRINT 3
53.Os
54.Sh NAME
55.Nm RSA_print ,
56.Nm RSA_print_fp ,
57.Nm DSAparams_print ,
58.Nm DSAparams_print_fp ,
59.Nm DSA_print ,
60.Nm DSA_print_fp ,
61.Nm DHparams_print ,
62.Nm DHparams_print_fp
63.Nd print cryptographic parameters
64.Sh SYNOPSIS
65.In openssl/rsa.h
66.Ft int
67.Fo RSA_print
68.Fa "BIO *bp"
69.Fa "RSA *x"
70.Fa "int offset"
71.Fc
72.Ft int
73.Fo RSA_print_fp
74.Fa "FILE *fp"
75.Fa "RSA *x"
76.Fa "int offset"
77.Fc
78.In openssl/dsa.h
79.Ft int
80.Fo DSAparams_print
81.Fa "BIO *bp"
82.Fa "DSA *x"
83.Fc
84.Ft int
85.Fo DSAparams_print_fp
86.Fa "FILE *fp"
87.Fa "DSA *x"
88.Fc
89.Ft int
90.Fo DSA_print
91.Fa "BIO *bp"
92.Fa "DSA *x"
93.Fa "int offset"
94.Fc
95.Ft int
96.Fo DSA_print_fp
97.Fa "FILE *fp"
98.Fa "DSA *x"
99.Fa "int offset"
100.Fc
101.In openssl/dh.h
102.Ft int
103.Fo DHparams_print
104.Fa "BIO *bp"
105.Fa "DH *x"
106.Fc
107.Ft int
108.Fo DHparams_print_fp
109.Fa "FILE *fp"
110.Fa "DH *x"
111.Fc
112.Sh DESCRIPTION
113A human-readable hexadecimal output of the components of the RSA key,
114DSA parameters or key or DH parameters is printed to
115.Fa bp
116or
117.Fa fp .
118.Pp
119The output lines are indented by
120.Fa offset
121spaces.
122.Sh RETURN VALUES
123These functions return 1 on success or 0 on error.
124.Sh SEE ALSO
125.Xr BN_bn2bin 3 ,
126.Xr DH_get0_pqg 3 ,
127.Xr DH_new 3 ,
128.Xr DSA_get0_pqg 3 ,
129.Xr RSA_get0_key 3 ,
130.Xr RSA_new 3
131.Sh HISTORY
132.Fn RSA_print
133and
134.Fn DHparams_print
135first appeared in SSLeay 0.5.1.
136.Fn RSA_print_fp ,
137.Fn DSA_print ,
138and
139.Fn DHparams_print_fp
140first appeared in SSLeay 0.6.0.
141.Fn DSA_print_fp
142first appeared in SSLeay 0.8.0.
143All these functions have been available since
144.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/RSA_private_encrypt.3 b/src/lib/libcrypto/man/RSA_private_encrypt.3
deleted file mode 100644
index 2bf6c57dba..0000000000
--- a/src/lib/libcrypto/man/RSA_private_encrypt.3
+++ /dev/null
@@ -1,150 +0,0 @@
1.\" $OpenBSD: RSA_private_encrypt.3,v 1.10 2019/06/10 14:58:48 schwarze Exp $
2.\" OpenSSL RSA_private_encrypt.pod b41f6b64 Mar 10 15:49:04 2017 +0000
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 10 2019 $
52.Dt RSA_PRIVATE_ENCRYPT 3
53.Os
54.Sh NAME
55.Nm RSA_private_encrypt ,
56.Nm RSA_public_decrypt
57.Nd low level signature operations
58.Sh SYNOPSIS
59.In openssl/rsa.h
60.Ft int
61.Fo RSA_private_encrypt
62.Fa "int flen"
63.Fa "const unsigned char *from"
64.Fa "unsigned char *to"
65.Fa "RSA *rsa"
66.Fa "int padding"
67.Fc
68.Ft int
69.Fo RSA_public_decrypt
70.Fa "int flen"
71.Fa "const unsigned char *from"
72.Fa "unsigned char *to"
73.Fa "RSA *rsa"
74.Fa "int padding"
75.Fc
76.Sh DESCRIPTION
77These functions handle RSA signatures at a low level.
78.Pp
79.Fn RSA_private_encrypt
80signs the
81.Fa flen
82bytes at
83.Fa from
84(usually a message digest with an algorithm identifier) using the
85private key
86.Fa rsa
87and stores the signature in
88.Fa to .
89.Fa to
90must point to
91.Fn RSA_size rsa
92bytes of memory.
93.Pp
94.Fa padding
95denotes one of the following modes:
96.Bl -tag -width Ds
97.It Dv RSA_PKCS1_PADDING
98PKCS #1 v1.5 padding.
99This function does not handle the
100.Sy algorithmIdentifier
101specified in PKCS #1.
102When generating or verifying PKCS #1 signatures,
103.Xr RSA_sign 3
104and
105.Xr RSA_verify 3
106should be used.
107.It Dv RSA_NO_PADDING
108Raw RSA signature.
109This mode should only be used to implement cryptographically sound
110padding modes in the application code.
111Signing user data directly with RSA is insecure.
112.El
113.Pp
114.Fn RSA_public_decrypt
115recovers the message digest from the
116.Fa flen
117bytes long signature at
118.Fa from
119using the signer's public key
120.Fa rsa .
121.Fa to
122must point to a memory section large enough to hold the message digest
123(which is smaller than
124.Fn RSA_size rsa
125- 11).
126.Fa padding
127is the padding mode that was used to sign the data.
128.Sh RETURN VALUES
129.Fn RSA_private_encrypt
130returns the size of the signature (i.e.\&
131.Fn RSA_size rsa ) .
132.Fn RSA_public_decrypt
133returns the size of the recovered message digest.
134.Pp
135On error, -1 is returned; the error codes can be obtained by
136.Xr ERR_get_error 3 .
137.Sh SEE ALSO
138.Xr RSA_meth_set_priv_enc 3 ,
139.Xr RSA_new 3 ,
140.Xr RSA_sign 3 ,
141.Xr RSA_verify 3
142.Sh HISTORY
143.Fn RSA_private_encrypt
144and
145.Fn RSA_public_decrypt
146appeared in SSLeay 0.4 or earlier and have been available since
147.Ox 2.4 .
148.Pp
149.Dv RSA_NO_PADDING
150is available since SSLeay 0.9.0.
diff --git a/src/lib/libcrypto/man/RSA_public_encrypt.3 b/src/lib/libcrypto/man/RSA_public_encrypt.3
deleted file mode 100644
index be3afdf402..0000000000
--- a/src/lib/libcrypto/man/RSA_public_encrypt.3
+++ /dev/null
@@ -1,247 +0,0 @@
1.\" $OpenBSD: RSA_public_encrypt.3,v 1.13 2023/09/10 16:04:15 schwarze Exp $
2.\" OpenSSL RSA_public_encrypt.pod 1e3f62a3 Jul 17 16:47:13 2017 +0200
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ulf Moeller <ulf@openssl.org>.
22.\" Copyright (c) 2000, 2004 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: September 10 2023 $
69.Dt RSA_PUBLIC_ENCRYPT 3
70.Os
71.Sh NAME
72.Nm RSA_public_encrypt ,
73.Nm RSA_private_decrypt ,
74.Nm EVP_PKEY_encrypt_old ,
75.Nm EVP_PKEY_decrypt_old
76.Nd RSA public key cryptography
77.Sh SYNOPSIS
78.In openssl/rsa.h
79.Ft int
80.Fo RSA_public_encrypt
81.Fa "int flen"
82.Fa "const unsigned char *from"
83.Fa "unsigned char *to"
84.Fa "RSA *rsa"
85.Fa "int padding"
86.Fc
87.Ft int
88.Fo RSA_private_decrypt
89.Fa "int flen"
90.Fa "const unsigned char *from"
91.Fa "unsigned char *to"
92.Fa "RSA *rsa"
93.Fa "int padding"
94.Fc
95.In openssl/evp.h
96.Ft int
97.Fo EVP_PKEY_encrypt_old
98.Fa "unsigned char *to"
99.Fa "const unsigned char *from"
100.Fa "int flen"
101.Fa "EVP_PKEY *pkey"
102.Fc
103.Ft int
104.Fo EVP_PKEY_decrypt_old
105.Fa "unsigned char *to"
106.Fa "const unsigned char *from"
107.Fa "int flen"
108.Fa "EVP_PKEY *pkey"
109.Fc
110.Sh DESCRIPTION
111.Fn RSA_public_encrypt
112encrypts the
113.Fa flen
114bytes at
115.Fa from
116(usually a session key) using the public key
117.Fa rsa
118and stores the ciphertext in
119.Fa to .
120.Fa to
121must point to
122.Fn RSA_size rsa
123bytes of memory.
124.Pp
125.Fa padding
126denotes one of the following modes:
127.Bl -tag -width Ds
128.It Dv RSA_PKCS1_PADDING
129PKCS #1 v1.5 padding.
130This currently is the most widely used mode.
131.It Dv RSA_PKCS1_OAEP_PADDING
132EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an empty
133encoding parameter.
134This mode is recommended for all new applications.
135.It Dv RSA_NO_PADDING
136Raw RSA encryption.
137This mode should only be used to implement cryptographically sound
138padding modes in the application code.
139Encrypting user data directly with RSA is insecure.
140.El
141.Pp
142.Fa flen
143must be less than
144.Fn RSA_size rsa
145- 11 for the PKCS #1 v1.5 based padding modes, less than
146.Fn RSA_size rsa
147- 41 for
148.Dv RSA_PKCS1_OAEP_PADDING
149and exactly
150.Fn RSA_size rsa
151for
152.Dv RSA_NO_PADDING .
153.Pp
154.Fn RSA_private_decrypt
155decrypts the
156.Fa flen
157bytes at
158.Fa from
159using the private key
160.Fa rsa
161and stores the plaintext in
162.Fa to .
163.Fa to
164must point to a memory section large enough to hold the decrypted data
165(which is smaller than
166.Fn RSA_size rsa ) .
167.Fa padding
168is the padding mode that was used to encrypt the data.
169.Pp
170.Fn EVP_PKEY_encrypt_old
171is a deprecated wrapper around
172.Fn RSA_public_encrypt
173that uses the
174.Vt RSA
175public key stored in
176.Fa pkey
177and
178.Dv RSA_PKCS1_PADDING .
179.Pp
180.Fn EVP_PKEY_decrypt_old
181is a deprecated wrapper around
182.Fn RSA_private_decrypt
183that uses the
184.Vt RSA
185private key stored in
186.Fa pkey
187and
188.Dv RSA_PKCS1_PADDING .
189.Sh RETURN VALUES
190.Fn RSA_public_encrypt
191and
192.Fn EVP_PKEY_encrypt_old
193return the size of the encrypted data (i.e.\&
194.Fn RSA_size rsa ) .
195.Fn RSA_private_decrypt
196and
197.Fn EVP_PKEY_decrypt_old
198returns the size of the recovered plaintext.
199On error, \-1 is returned; the error codes can be obtained by
200.Xr ERR_get_error 3 .
201.Pp
202In addition to the return values documented above,
203.Fn EVP_PKEY_encrypt_old
204may return 0 if the
205.Xr EVP_PKEY_id 3
206of
207.Fa pkey
208is not
209.Dv EVP_PKEY_RSA .
210.Sh SEE ALSO
211.Xr EVP_PKEY_decrypt 3 ,
212.Xr EVP_PKEY_encrypt 3 ,
213.Xr RSA_meth_set_priv_dec 3 ,
214.Xr RSA_new 3 ,
215.Xr RSA_size 3
216.Sh STANDARDS
217SSL, PKCS #1 v2.0
218.Sh HISTORY
219.Fn RSA_public_encrypt
220and
221.Fn RSA_private_decrypt
222appeared in SSLeay 0.4 or earlier and have been available since
223.Ox 2.4 .
224.Pp
225.Fn EVP_PKEY_encrypt
226and
227.Fn EVP_PKEY_decrypt
228first appeared in SSLeay 0.9.0 and have been available since
229.Ox 2.4 .
230There were renamed to
231.Fn EVP_PKEY_encrypt_old
232and
233.Fn EVP_PKEY_decrypt_old
234in OpenSSL 1.0.0 and
235.Ox 4.9 .
236.Pp
237.Dv RSA_NO_PADDING
238is available since SSLeay 0.9.0.
239OAEP was added in OpenSSL 0.9.2b.
240.Sh BUGS
241Decryption failures in the
242.Dv RSA_PKCS1_PADDING
243mode leak information which can potentially be used to mount a
244Bleichenbacher padding oracle attack.
245This is an inherent weakness in the PKCS #1 v1.5 padding design.
246Prefer
247.Dv RSA_PKCS1_OAEP_PADDING .
diff --git a/src/lib/libcrypto/man/RSA_security_bits.3 b/src/lib/libcrypto/man/RSA_security_bits.3
deleted file mode 100644
index f7024a7956..0000000000
--- a/src/lib/libcrypto/man/RSA_security_bits.3
+++ /dev/null
@@ -1,137 +0,0 @@
1.\" $OpenBSD: RSA_security_bits.3,v 1.1 2022/07/13 17:32:16 schwarze Exp $
2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 13 2022 $
18.Dt RSA_SECURITY_BITS 3
19.Os
20.Sh NAME
21.Nm RSA_security_bits ,
22.Nm DSA_security_bits ,
23.Nm DH_security_bits ,
24.Nm BN_security_bits
25.Nd get security strength
26.Sh SYNOPSIS
27.In openssl/rsa.h
28.Ft int
29.Fn RSA_security_bits "const RSA *rsa"
30.In openssl/dsa.h
31.Ft int
32.Fn DSA_security_bits "const DSA *dsa"
33.In openssl/dh.h
34.Ft int
35.Fn DH_security_bits "const DH *dh"
36.In openssl/bn.h
37.Ft int
38.Fo BN_security_bits
39.Fa "int pubbits"
40.Fa "int privbits"
41.Fc
42.Sh DESCRIPTION
43These functions return the security strength of some specific types of
44cryptographic keys, measured in bits.
45It is approximately the binary logarithm of the number of operations
46an attacker has to perform in order to break the key.
47.Pp
48.Fn RSA_security_bits
49uses only the number of significant bits in the public modulus of
50.Fa rsa
51as returned by
52.Xr RSA_bits 3 .
53It returns
54.Bl -column 256 for 15360 last_column -offset indent
55.It 256 Ta for Ta 15360 Ta or more significant bits
56.It 192 Ta Ta 7680 Ta
57.It 128 Ta Ta 3072 Ta
58.It 112 Ta Ta 2048 Ta
59.It 80 Ta Ta 1024 Ta
60.El
61.Pp
62or 0 otherwise.
63.Pp
64.Fn DSA_security_bits
65uses the number of significant bits in the public domain parameter
66.Fa p
67contained in the
68.Fa dsa
69object, which is equal to the size of the public key, in the same way as
70.Fn RSA_security_bits .
71In addition, the public domain parameter
72.Fa q
73contained in the
74.Fa dsa
75object, which is equal to the size of the private key, is inspected.
76The return value is either the security strength according to the above table
77or half the size of the private key, whichever is smaller.
78If the return value would be smaller than 80, 0 is returned instead.
79.Pp
80.Fn DH_security_bits
81uses the number of significant bits in the shared secret contained in the
82.Fa dh
83object as returned by
84.Xr DH_bits 3
85in the same way as
86.Fn RSA_security_bits .
87If
88.Fa dh
89contains the domain parameter
90.Fa q ,
91its number of significant bits is used in the same way as for
92.Fn DSA_security_bits
93to limit the return value.
94Otherwise, if
95.Fa dh
96contains the length of the secret exponent in bits,
97that number is used.
98If neither is available, only the above table is used
99without calculating a minimum.
100.Pp
101.Fn BN_security_bits
102is a combined function.
103If \-1 is passed for the
104.Fa privbits
105argument, it behaves like
106.Fn RSA_security_bits .
107Otherwise, it behaves like
108.Fn DSA_security_bits .
109.Sh RETURN VALUES
110All these functions return numbers in the range from 0 to 256 inclusive.
111.Pp
112.Fn DSA_security_bits
113fails and returns \-1 unless both of the
114.Fa p
115and
116.Fa q
117domain parameters are present.
118.Sh SEE ALSO
119.Xr BN_num_bits 3 ,
120.Xr DH_bits 3 ,
121.Xr DH_get0_pqg 3 ,
122.Xr DSA_get0_pqg 3 ,
123.Xr RSA_bits 3 ,
124.Xr SSL_CTX_set_security_level 3
125.Rs
126.%A Elaine Barker
127.%T Recommendation for Key Management
128.%I U.S. National Institute of Standards and Technology
129.%R NIST Special Publication 800-57 Part 1 Revision 5
130.%U https://doi.org/10.6028/NIST.SP.800-57pt1r5
131.%C Gaithersburg, MD
132.%D May 2020
133.Re
134.Sh HISTORY
135These functions first appeared in OpenSSL 1.1.0
136and have been available since
137.Ox 7.2 .
diff --git a/src/lib/libcrypto/man/RSA_set_method.3 b/src/lib/libcrypto/man/RSA_set_method.3
deleted file mode 100644
index ffe22c116f..0000000000
--- a/src/lib/libcrypto/man/RSA_set_method.3
+++ /dev/null
@@ -1,252 +0,0 @@
1.\" $OpenBSD: RSA_set_method.3,v 1.18 2023/11/19 10:34:26 tb Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>
5.\" and Geoff Thorpe <geoff@openssl.org>.
6.\" Copyright (c) 2000, 2002, 2007, 2014 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: November 19 2023 $
54.Dt RSA_SET_METHOD 3
55.Os
56.Sh NAME
57.Nm RSA_set_default_method ,
58.Nm RSA_get_default_method ,
59.Nm RSA_set_method ,
60.Nm RSA_get_method ,
61.Nm RSA_PKCS1_SSLeay ,
62.Nm RSA_flags ,
63.Nm RSA_new_method
64.Nd select RSA method
65.Sh SYNOPSIS
66.In openssl/rsa.h
67.Ft void
68.Fo RSA_set_default_method
69.Fa "const RSA_METHOD *meth"
70.Fc
71.Ft const RSA_METHOD *
72.Fn RSA_get_default_method void
73.Ft int
74.Fo RSA_set_method
75.Fa "RSA *rsa"
76.Fa "const RSA_METHOD *meth"
77.Fc
78.Ft const RSA_METHOD *
79.Fo RSA_get_method
80.Fa "const RSA *rsa"
81.Fc
82.Ft const RSA_METHOD *
83.Fn RSA_PKCS1_SSLeay void
84.Ft int
85.Fo RSA_flags
86.Fa "const RSA *rsa"
87.Fc
88.Ft RSA *
89.Fo RSA_new_method
90.Fa "ENGINE *engine"
91.Fc
92.Sh DESCRIPTION
93An
94.Vt RSA_METHOD
95object contains pointers to the functions used for RSA operations.
96By default, the internal implementation returned by
97.Fn RSA_PKCS1_SSLeay
98is used.
99By selecting another method, alternative implementations
100such as hardware accelerators may be used.
101.Pp
102.Fn RSA_set_default_method
103selects
104.Fa meth
105as the default method for all
106.Vt RSA
107structures created later.
108.Pp
109.Fn RSA_get_default_method
110returns a pointer to the current default method.
111.Pp
112.Fn RSA_set_method
113selects
114.Fa meth
115to perform all operations using the key
116.Fa rsa .
117This replaces the previous
118.Vt RSA_METHOD
119used by the RSA key, calling the
120.Fa finish
121function set up with
122.Xr RSA_meth_set_finish 3
123if any.
124If
125.Fa meth
126contains an
127.Fa init
128function set up with
129.Xr RSA_meth_set_init 3 ,
130that function is called just before returning from
131.Fn RSA_set_method .
132.Pp
133It is possible to have RSA keys that only work with certain
134.Vt RSA_METHOD
135implementations,
136and in such cases attempting to change the
137.Vt RSA_METHOD
138for the key can have unexpected results.
139.Pp
140.Fn RSA_get_method
141returns a pointer to the
142.Vt RSA_METHOD
143being used by
144.Fa rsa .
145.Pp
146The misleadingly named function
147.Fn RSA_flags
148returns the flags that are set for the current
149.Vt RSA_METHOD
150of
151.Fa rsa .
152The flags used by
153.Fa rsa
154itself can instead be tested with
155.Xr RSA_test_flags 3 .
156See the
157.Sx BUGS
158section for more details.
159.Pp
160.Fn RSA_new_method
161allocates and initializes an
162.Vt RSA
163structure.
164The
165.Fa engine
166argument is ignored and
167the default method controlled by
168.Fn RSA_set_default_method
169is used.
170.Pp
171The initial
172.Fa flags
173are copied from the
174.Vt RSA_METHOD
175object used and will not be affected by later changes to that object,
176but may be modified by the optional
177.Fa init
178function which may have been set up with
179.Xr RSA_meth_set_init 3
180and which is called just before returning from
181.Fn RSA_new_method .
182.Sh RETURN VALUES
183.Fn RSA_PKCS1_SSLeay ,
184.Fn RSA_get_default_method ,
185and
186.Fn RSA_get_method
187return pointers to the respective
188.Vt RSA_METHOD .
189.Pp
190.Fn RSA_set_method
191returns 1 on success or 0 on failure.
192Currently, it cannot fail.
193.Pp
194.Fn RSA_new_method
195returns
196.Dv NULL
197and sets an error code that can be obtained by
198.Xr ERR_get_error 3
199if the allocation fails.
200Otherwise it returns a pointer to the newly allocated structure.
201.Sh SEE ALSO
202.Xr RSA_meth_new 3 ,
203.Xr RSA_new 3
204.Sh HISTORY
205.Fn RSA_set_default_method ,
206.Fn RSA_PKCS1_SSLeay ,
207and
208.Fn RSA_new_method
209first appeared in SSLeay 0.8.0.
210.Fn RSA_flags
211first appeared in SSLeay 0.9.0.
212These functions have been available since
213.Ox 2.4 .
214.Pp
215.Fn RSA_get_default_method ,
216.Fn RSA_set_method ,
217and
218.Fn RSA_get_method
219as well as the
220.Fa rsa_sign
221and
222.Fa rsa_verify
223components of
224.Vt RSA_METHOD
225first appeared in OpenSSL 0.9.4 and have been available since
226.Ox 2.6 .
227.Sh BUGS
228The behaviour of
229.Fn RSA_flags
230is a misfeature that is left as-is for now to avoid creating
231compatibility problems.
232RSA functionality, such as the encryption functions, are controlled by
233the
234.Fa flags
235value in the
236.Vt RSA
237key itself, not by the
238.Fa flags
239value in the
240.Vt RSA_METHOD
241attached to the RSA key (which is what this function returns).
242If the flags element of an
243.Vt RSA
244key is changed, the changes will be honoured by RSA functionality
245but will not be reflected in the return value of the
246.Fn RSA_flags
247function - in effect
248.Fn RSA_flags
249behaves more like an
250.Fn RSA_default_flags
251function, which does not
252currently exist.
diff --git a/src/lib/libcrypto/man/RSA_sign.3 b/src/lib/libcrypto/man/RSA_sign.3
deleted file mode 100644
index 65e9dc99b8..0000000000
--- a/src/lib/libcrypto/man/RSA_sign.3
+++ /dev/null
@@ -1,147 +0,0 @@
1.\" $OpenBSD: RSA_sign.3,v 1.8 2019/06/10 14:58:48 schwarze Exp $
2.\" OpenSSL aa90ca11 Aug 20 15:48:56 2016 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2005, 2014, 2015, 2016 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: June 10 2019 $
53.Dt RSA_SIGN 3
54.Os
55.Sh NAME
56.Nm RSA_sign ,
57.Nm RSA_verify
58.Nd RSA signatures
59.Sh SYNOPSIS
60.In openssl/rsa.h
61.Ft int
62.Fo RSA_sign
63.Fa "int type"
64.Fa "const unsigned char *m"
65.Fa "unsigned int m_len"
66.Fa "unsigned char *sigret"
67.Fa "unsigned int *siglen"
68.Fa "RSA *rsa"
69.Fc
70.Ft int
71.Fo RSA_verify
72.Fa "int type"
73.Fa "const unsigned char *m"
74.Fa "unsigned int m_len"
75.Fa "unsigned char *sigbuf"
76.Fa "unsigned int siglen"
77.Fa "RSA *rsa"
78.Fc
79.Sh DESCRIPTION
80.Fn RSA_sign
81signs the message digest
82.Fa m
83of size
84.Fa m_len
85using the private key
86.Fa rsa
87using RSASSA-PKCS1-v1_5 as specified in RFC 3447.
88It stores the signature in
89.Fa sigret
90and the signature size in
91.Fa siglen .
92.Fa sigret
93must point to
94.Fn RSA_size rsa
95bytes of memory.
96Note that PKCS #1 adds meta-data, placing limits on the size of the key
97that can be used.
98See
99.Xr RSA_private_encrypt 3
100for lower-level operations.
101.Pp
102.Fa type
103denotes the message digest algorithm that was used to generate
104.Fa m .
105If
106.Fa type
107is
108.Sy NID_md5_sha1 ,
109an SSL signature (MD5 and SHA1 message digests with PKCS #1 padding and
110no algorithm identifier) is created.
111.Pp
112.Fn RSA_verify
113verifies that the signature
114.Fa sigbuf
115of size
116.Fa siglen
117matches a given message digest
118.Fa m
119of size
120.Fa m_len .
121.Fa type
122denotes the message digest algorithm that was used to generate the
123signature.
124.Fa rsa
125is the signer's public key.
126.Sh RETURN VALUES
127.Fn RSA_sign
128returns 1 on success.
129.Fn RSA_verify
130returns 1 on successful verification.
131.Pp
132The error codes can be obtained by
133.Xr ERR_get_error 3 .
134.Sh SEE ALSO
135.Xr RSA_meth_set_sign 3 ,
136.Xr RSA_new 3 ,
137.Xr RSA_private_encrypt 3 ,
138.Xr RSA_public_decrypt 3
139.Sh STANDARDS
140SSL, PKCS #1 v2.0
141.Sh HISTORY
142.Fn RSA_sign
143first appeared in SSLeay 0.4.4.
144.Fn RSA_verify
145first appeared in SSLeay 0.6.0.
146Both functions have been available since
147.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3 b/src/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3
deleted file mode 100644
index 34aef42c48..0000000000
--- a/src/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3
+++ /dev/null
@@ -1,131 +0,0 @@
1.\" $OpenBSD: RSA_sign_ASN1_OCTET_STRING.3,v 1.7 2019/06/10 14:58:48 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 10 2019 $
52.Dt RSA_SIGN_ASN1_OCTET_STRING 3
53.Os
54.Sh NAME
55.Nm RSA_sign_ASN1_OCTET_STRING ,
56.Nm RSA_verify_ASN1_OCTET_STRING
57.Nd RSA signatures
58.Sh SYNOPSIS
59.In openssl/rsa.h
60.Ft int
61.Fo RSA_sign_ASN1_OCTET_STRING
62.Fa "int dummy"
63.Fa "unsigned char *m"
64.Fa "unsigned int m_len"
65.Fa "unsigned char *sigret"
66.Fa "unsigned int *siglen"
67.Fa "RSA *rsa"
68.Fc
69.Ft int
70.Fo RSA_verify_ASN1_OCTET_STRING
71.Fa "int dummy"
72.Fa "unsigned char *m"
73.Fa "unsigned int m_len"
74.Fa "unsigned char *sigbuf"
75.Fa "unsigned int siglen"
76.Fa "RSA *rsa"
77.Fc
78.Sh DESCRIPTION
79.Fn RSA_sign_ASN1_OCTET_STRING
80signs the octet string
81.Fa m
82of size
83.Fa m_len
84using the private key
85.Fa rsa
86represented in DER using PKCS #1 padding.
87It stores the signature in
88.Fa sigret
89and the signature size in
90.Fa siglen .
91.Fa sigret
92must point to
93.Fn RSA_size rsa
94bytes of memory.
95.Pp
96.Fa dummy
97is ignored.
98.Pp
99.Fn RSA_verify_ASN1_OCTET_STRING
100verifies that the signature
101.Fa sigbuf
102of size
103.Fa siglen
104is the DER representation of a given octet string
105.Fa m
106of size
107.Fa m_len .
108.Fa dummy
109is ignored.
110.Fa rsa
111is the signer's public key.
112.Sh RETURN VALUES
113.Fn RSA_sign_ASN1_OCTET_STRING
114returns 1 on success or 0 otherwise.
115.Fn RSA_verify_ASN1_OCTET_STRING
116returns 1 on successful verification or 0 otherwise.
117.Pp
118The error codes can be obtained by
119.Xr ERR_get_error 3 .
120.Sh SEE ALSO
121.Xr RSA_new 3 ,
122.Xr RSA_sign 3 ,
123.Xr RSA_verify 3
124.Sh HISTORY
125.Fn RSA_sign_ASN1_OCTET_STRING
126and
127.Fn RSA_verify_ASN1_OCTET_STRING
128first appeared in SSLeay 0.8.0 and have been available since
129.Ox 2.4 .
130.Sh BUGS
131These functions serve no recognizable purpose.
diff --git a/src/lib/libcrypto/man/RSA_size.3 b/src/lib/libcrypto/man/RSA_size.3
deleted file mode 100644
index 8a552b4e67..0000000000
--- a/src/lib/libcrypto/man/RSA_size.3
+++ /dev/null
@@ -1,97 +0,0 @@
1.\" $OpenBSD: RSA_size.3,v 1.10 2022/07/13 21:51:35 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
5.\" Kurt Roeckx <kurt@roeckx.be>.
6.\" Copyright (c) 2000, 2002, 2015 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: July 13 2022 $
53.Dt RSA_SIZE 3
54.Os
55.Sh NAME
56.Nm RSA_size ,
57.Nm RSA_bits
58.Nd get the RSA modulus size
59.Sh SYNOPSIS
60.In openssl/rsa.h
61.Ft int
62.Fo RSA_size
63.Fa "const RSA *rsa"
64.Fc
65.Ft int
66.Fo RSA_bits
67.Fa "const RSA *rsa"
68.Fc
69.Sh DESCRIPTION
70.Fn RSA_size
71returns the RSA modulus size in bytes.
72It can be used to determine how much memory must be allocated for
73an RSA encrypted value.
74.Pp
75.Fn RSA_bits
76returns the number of significant bits.
77.Pp
78.Fa rsa
79and
80.Fa rsa->n
81must not be
82.Dv NULL .
83.Sh RETURN VALUES
84The size.
85.Sh SEE ALSO
86.Xr BN_num_bits 3 ,
87.Xr RSA_get0_key 3 ,
88.Xr RSA_new 3 ,
89.Xr RSA_security_bits 3
90.Sh HISTORY
91.Fn RSA_size
92first appeared in SSLeay 0.4.4 and has been available since
93.Ox 2.4 .
94.Pp
95.Fn RSA_bits
96first appeared in OpenSSL 1.1.0 and has been available since
97.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/SHA1.3 b/src/lib/libcrypto/man/SHA1.3
deleted file mode 100644
index 4ccb08157c..0000000000
--- a/src/lib/libcrypto/man/SHA1.3
+++ /dev/null
@@ -1,285 +0,0 @@
1.\" $OpenBSD: SHA1.3,v 1.9 2024/06/01 12:35:23 tb Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
5.\" Matt Caswell <matt@openssl.org>.
6.\" Copyright (c) 2000, 2006, 2015 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: June 1 2024 $
53.Dt SHA1 3
54.Os
55.Sh NAME
56.Nm SHA1 ,
57.Nm SHA1_Init ,
58.Nm SHA1_Update ,
59.Nm SHA1_Final ,
60.Nm SHA224 ,
61.Nm SHA224_Init ,
62.Nm SHA224_Update ,
63.Nm SHA224_Final ,
64.Nm SHA256 ,
65.Nm SHA256_Init ,
66.Nm SHA256_Update ,
67.Nm SHA256_Final ,
68.Nm SHA384 ,
69.Nm SHA384_Init ,
70.Nm SHA384_Update ,
71.Nm SHA384_Final ,
72.Nm SHA512 ,
73.Nm SHA512_Init ,
74.Nm SHA512_Update ,
75.Nm SHA512_Final
76.Nd Secure Hash Algorithm
77.Sh SYNOPSIS
78.In openssl/sha.h
79.Ft unsigned char *
80.Fo SHA1
81.Fa "const unsigned char *d"
82.Fa "size_t n"
83.Fa "unsigned char *md"
84.Fc
85.Ft int
86.Fo SHA1_Init
87.Fa "SHA_CTX *c"
88.Fc
89.Ft int
90.Fo SHA1_Update
91.Fa "SHA_CTX *c"
92.Fa "const void *data"
93.Fa "size_t len"
94.Fc
95.Ft int
96.Fo SHA1_Final
97.Fa "unsigned char *md"
98.Fa "SHA_CTX *c"
99.Fc
100.Ft unsigned char *
101.Fo SHA224
102.Fa "const unsigned char *d"
103.Fa "size_t n"
104.Fa "unsigned char *md"
105.Fc
106.Ft int
107.Fo SHA224_Init
108.Fa "SHA256_CTX *c"
109.Fc
110.Ft int
111.Fo SHA224_Update
112.Fa "SHA256_CTX *c"
113.Fa "const void *data"
114.Fa "size_t len"
115.Fc
116.Ft int
117.Fo SHA224_Final
118.Fa "unsigned char *md"
119.Fa "SHA256_CTX *c"
120.Fc
121.Ft unsigned char *
122.Fo SHA256
123.Fa "const unsigned char *d"
124.Fa "size_t n"
125.Fa "unsigned char *md"
126.Fc
127.Ft int
128.Fo SHA256_Init
129.Fa "SHA256_CTX *c"
130.Fc
131.Ft int
132.Fo SHA256_Update
133.Fa "SHA256_CTX *c"
134.Fa "const void *data"
135.Fa "size_t len"
136.Fc
137.Ft int
138.Fo SHA256_Final
139.Fa "unsigned char *md"
140.Fa "SHA256_CTX *c"
141.Fc
142.Ft unsigned char *
143.Fo SHA384
144.Fa "const unsigned char *d"
145.Fa "size_t n"
146.Fa "unsigned char *md"
147.Fc
148.Ft int
149.Fo SHA384_Init
150.Fa "SHA512_CTX *c"
151.Fc
152.Ft int
153.Fo SHA384_Update
154.Fa "SHA512_CTX *c"
155.Fa "const void *data"
156.Fa "size_t len"
157.Fc
158.Ft int
159.Fo SHA384_Final
160.Fa "unsigned char *md"
161.Fa "SHA512_CTX *c"
162.Fc
163.Ft unsigned char *
164.Fo SHA512
165.Fa "const unsigned char *d"
166.Fa "size_t n"
167.Fa "unsigned char *md"
168.Fc
169.Ft int
170.Fo SHA512_Init
171.Fa "SHA512_CTX *c"
172.Fc
173.Ft int
174.Fo SHA512_Update
175.Fa "SHA512_CTX *c"
176.Fa "const void *data"
177.Fa "size_t len"
178.Fc
179.Ft int
180.Fo SHA512_Final
181.Fa "unsigned char *md"
182.Fa "SHA512_CTX *c"
183.Fc
184.Sh DESCRIPTION
185SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a
186160-bit output.
187.Pp
188.Fn SHA1
189computes the SHA-1 message digest of the
190.Fa n
191bytes at
192.Fa d
193and places it in
194.Fa md ,
195which must have space for
196.Dv SHA_DIGEST_LENGTH
197== 20 bytes of output.
198.Pp
199The following functions may be used if the message is not completely
200stored in memory:
201.Pp
202.Fn SHA1_Init
203initializes a
204.Vt SHA_CTX
205structure.
206.Pp
207.Fn SHA1_Update
208can be called repeatedly with chunks of the message to be hashed
209.Pq Fa len No bytes at Fa data .
210.Pp
211.Fn SHA1_Final
212places the message digest in
213.Fa md ,
214which must have space for
215.Dv SHA_DIGEST_LENGTH
216== 20 bytes of output, and erases the
217.Vt SHA_CTX .
218.Pp
219The SHA224, SHA256, SHA384, and SHA512 families of functions operate
220in the same way as the SHA1 functions.
221Note that SHA224 and SHA256 use a
222.Vt SHA256_CTX
223object instead of
224.Vt SHA_CTX ,
225and SHA384 and SHA512 use
226.Vt SHA512_CTX .
227The buffer
228.Fa md
229must have space for the output from the SHA variant being used:
230.Dv SHA224_DIGEST_LENGTH ,
231.Dv SHA256_DIGEST_LENGTH ,
232.Dv SHA384_DIGEST_LENGTH ,
233or
234.Dv SHA512_DIGEST_LENGTH
235bytes.
236.Pp
237Applications should use the higher level functions
238.Xr EVP_DigestInit 3
239etc. instead of calling the hash functions directly.
240.Sh RETURN VALUES
241.Fn SHA1 ,
242.Fn SHA224 ,
243.Fn SHA256 ,
244.Fn SHA384 ,
245and
246.Fn SHA512
247return a pointer to the hash value.
248The other functions return 1 for success or 0 otherwise.
249.Sh SEE ALSO
250.Xr EVP_DigestInit 3 ,
251.Xr HMAC 3 ,
252.Xr RIPEMD160 3
253.Sh STANDARDS
254.Rs
255.%T Secure Hash Standard (SHS)
256.%R NIST FIPS Publication
257.%N 180-4
258.%U https://doi.org/10.6028/NIST.FIPS.180-4
259.%D 2015
260.Re
261.Sh HISTORY
262.Fn SHA1 ,
263.Fn SHA1_Init ,
264.Fn SHA1_Update ,
265and
266.Fn SHA1_Final
267first appeared in SSLeay 0.5.1 and have been available since
268.Ox 2.4 .
269.Pp
270The other functions first appeared in OpenSSL 0.9.8
271and have been available since
272.Ox 4.5 .
273.Sh CAVEATS
274Other implementations allow
275.Fa md
276in
277.Fn SHA1 ,
278.Fn SHA224 ,
279.Fn SHA256 ,
280.Fn SHA384 ,
281and
282.Fn SHA512
283to be
284.Dv NULL
285and return a static array, which is not thread safe.
diff --git a/src/lib/libcrypto/man/SMIME_crlf_copy.3 b/src/lib/libcrypto/man/SMIME_crlf_copy.3
deleted file mode 100644
index 3b46138473..0000000000
--- a/src/lib/libcrypto/man/SMIME_crlf_copy.3
+++ /dev/null
@@ -1,96 +0,0 @@
1.\" $OpenBSD: SMIME_crlf_copy.3,v 1.3 2023/05/01 07:28:11 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: May 1 2023 $
18.Dt SMIME_CRLF_COPY 3
19.Os
20.Sh NAME
21.Nm SMIME_crlf_copy
22.Nd buffered copy between BIOs
23.Sh SYNOPSIS
24.Ft int
25.Fo SMIME_crlf_copy
26.Fa "BIO *in_bio"
27.Fa "BIO *out_bio"
28.Fa "int flags"
29.Fc
30.Sh DESCRIPTION
31.Fn SMIME_crlf_copy
32copies data from
33.Fa in_bio
34to
35.Fa out_bio .
36To avoid many small write operations on
37.Fa out_bio ,
38a buffering BIO created with
39.Xr BIO_f_buffer 3
40is temporarily prepended to it.
41.Pp
42If the bit
43.Dv SMIME_BINARY
44is set in the
45.Fa flags
46argument, all the data is copied verbatim using
47.Xr BIO_read 3
48and
49.Xr BIO_write 3 .
50.Pp
51Otherwise, the data is read as text.
52All trailing carriage return and newline characters are discarded
53from every input line and a single pair of carriage return and
54newline characters is appended to mark the end of every output line,
55except that the last output line will end without such a pair if
56the last input line does not have a newline character at the end.
57.Pp
58If the bit
59.Dv SMIME_TEXT
60is set in the
61.Fa flags
62argument and the bit
63.Dv SMIME_BINARY
64is not set, the line
65.Qq Content-Type: text/plain
66is prepended to the output
67with two pairs of carriage return and newline characters after it.
68.Pp
69In any case,
70.Xr BIO_flush 3
71is called on the output at the end of the function.
72.Sh RETURN VALUES
73.Fn SMIME_crlf_copy
74is intended to return 1 on success or 0 on failure.
75.Sh SEE ALSO
76.Xr BIO_f_buffer 3 ,
77.Xr BIO_flush 3 ,
78.Xr BIO_new 3 ,
79.Xr BIO_push 3 ,
80.Xr BIO_read 3 ,
81.Xr SMIME_text 3 ,
82.Xr SMIME_write_ASN1 3
83.Sh HISTORY
84.Fn SMIME_crlf_copy
85first appeared in OpenSSL 1.0.0 and has been available since
86.Ox 4.9 .
87.Sh BUGS
88.Fn SMIME_crlf_copy
89silently ignores most errors and may return 1
90even if it lost part or all of the data in transit.
91.Pp
92Only blocking BIOs are supported.
93If any of the
94.Vt BIO
95arguments is non-blocking, part or all of the data is likely
96to be silently lost in transit.
diff --git a/src/lib/libcrypto/man/SMIME_read_ASN1.3 b/src/lib/libcrypto/man/SMIME_read_ASN1.3
deleted file mode 100644
index 320064567c..0000000000
--- a/src/lib/libcrypto/man/SMIME_read_ASN1.3
+++ /dev/null
@@ -1,124 +0,0 @@
1.\" $OpenBSD: SMIME_read_ASN1.3,v 1.2 2021/12/14 15:22:49 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL SMIME_read_PKCS7.pod 83cf7abf May 29 13:07:08 2018 +0100
4.\" OpenSSL SMIME_read_CMS.pod b97fdb57 Nov 11 09:33:09 2016 +0100
5.\"
6.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
7.\" Copyright (c) 2002, 2006, 2008 The OpenSSL Project. All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: December 14 2021 $
54.Dt SMIME_READ_ASN1 3
55.Os
56.Sh NAME
57.Nm SMIME_read_ASN1
58.Nd generic S/MIME message parser
59.Sh SYNOPSIS
60.In openssl/asn1.h
61.Ft ASN1_VALUE *
62.Fo SMIME_read_ASN1
63.Fa "BIO *in_bio"
64.Fa "BIO **out_bio"
65.Fa "const ASN1_ITEM *it"
66.Fc
67.Sh DESCRIPTION
68.Fn SMIME_read_ASN1
69reads a message in S/MIME format from
70.Fa in_bio .
71.Pp
72If the message uses cleartext signing, the content is saved in a memory
73.Vt BIO
74which is written to
75.Pf * Fa out_bio .
76Otherwise,
77.Pf * Fa out_bio
78is set to
79.Dv NULL .
80.Pp
81To support future functionality, if
82.Fa out_bio
83is not
84.Dv NULL ,
85.Pf * Fa out_bio
86should be initialized to
87.Dv NULL
88before calling
89.Fn SMIME_read_ASN1 .
90.Sh RETURN VALUES
91.Fn SMIME_read_ASN1
92returns a newly allocated object of type
93.Fa it
94or
95.Dv NULL
96if an error occurred.
97The error can be obtained from
98.Xr ERR_get_error 3 .
99.Sh SEE ALSO
100.Xr ASN1_item_d2i_bio 3 ,
101.Xr BIO_f_base64 3 ,
102.Xr BIO_new 3 ,
103.Xr SMIME_read_CMS 3 ,
104.Xr SMIME_read_PKCS7 3 ,
105.Xr SMIME_text 3
106.Sh HISTORY
107.Fn SMIME_read_ASN1
108first appeared in OpenSSL 0.9.8h and has been available since
109.Ox 4.5 .
110.Sh BUGS
111The MIME parser used by
112.Fn SMIME_read_ASN1
113is somewhat primitive.
114While it will handle most S/MIME messages, more complex compound
115formats may not work.
116.Pp
117The parser assumes that the
118structure is always base64 encoded, and it will not handle the case
119where it is in binary format or uses quoted printable format.
120.Pp
121The use of a memory
122to hold the signed content limits the size of the message which can
123be processed due to memory restraints: a streaming single pass
124option should be available.
diff --git a/src/lib/libcrypto/man/SMIME_read_CMS.3 b/src/lib/libcrypto/man/SMIME_read_CMS.3
deleted file mode 100644
index e1b1d07499..0000000000
--- a/src/lib/libcrypto/man/SMIME_read_CMS.3
+++ /dev/null
@@ -1,132 +0,0 @@
1.\" $OpenBSD: SMIME_read_CMS.3,v 1.7 2021/12/14 14:30:50 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 14 2021 $
52.Dt SMIME_READ_CMS 3
53.Os
54.Sh NAME
55.Nm SMIME_read_CMS
56.Nd extract CMS ContentInfo from an S/MIME message
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft CMS_ContentInfo *
60.Fo SMIME_read_CMS
61.Fa "BIO *in"
62.Fa "BIO **bcont"
63.Fc
64.Sh DESCRIPTION
65.Fn SMIME_read_CMS
66parses a message in S/MIME format from
67.Fa in .
68.Pp
69If the message uses cleartext signing, the content is saved in a memory BIO
70which is written to
71.Pf * Fa bcont
72and which can then be passed to
73.Xr CMS_verify 3
74with the
75.Dv CMS_DETACHED
76flag set.
77Otherwise,
78.Pf * Fa bcont
79is set to
80.Dv NULL
81and the type of the returned structure can be determined using
82.Xr CMS_get0_type 3 .
83.Pp
84To support future functionality if
85.Fa bcont
86is not
87.Dv NULL ,
88.Pf * Fa bcont
89should be initialized to
90.Dv NULL ,
91for example:
92.Bd -literal -offset indent
93BIO *cont = NULL;
94CMS_ContentInfo *cms = SMIME_read_CMS(in, &cont);
95.Ed
96.Sh RETURN VALUES
97.Fn SMIME_read_CMS
98returns a valid
99.Vt CMS_ContentInfo
100structure or
101.Dv NULL
102if an error occurred.
103The error can be obtained from
104.Xr ERR_get_error 3 .
105.Sh SEE ALSO
106.Xr CMS_ContentInfo_new 3 ,
107.Xr CMS_decrypt 3 ,
108.Xr CMS_get0_type 3 ,
109.Xr CMS_verify 3 ,
110.Xr d2i_CMS_ContentInfo 3 ,
111.Xr SMIME_read_ASN1 3 ,
112.Xr SMIME_write_CMS 3
113.Sh HISTORY
114.Fn SMIME_read_CMS
115first appeared in OpenSSL 0.9.8h
116and has been available since
117.Ox 6.7 .
118.Sh BUGS
119The MIME parser used by
120.Fn SMIME_read_CMS
121is somewhat primitive.
122While it will handle most S/MIME messages, more complex compound formats
123may not work.
124.Pp
125The parser assumes that the
126.Vt CMS_ContentInfo
127structure is always base64 encoded and will not handle the case
128where it is in binary format or uses quoted printable format.
129.Pp
130The use of a memory BIO to hold the signed content limits the size of
131the message which can be processed due to memory restraints: a streaming
132single pass option should be available.
diff --git a/src/lib/libcrypto/man/SMIME_read_PKCS7.3 b/src/lib/libcrypto/man/SMIME_read_PKCS7.3
deleted file mode 100644
index dbe2765b8b..0000000000
--- a/src/lib/libcrypto/man/SMIME_read_PKCS7.3
+++ /dev/null
@@ -1,150 +0,0 @@
1.\" $OpenBSD: SMIME_read_PKCS7.3,v 1.8 2021/12/14 14:30:50 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2006 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 14 2021 $
52.Dt SMIME_READ_PKCS7 3
53.Os
54.Sh NAME
55.Nm SMIME_read_PKCS7
56.Nd extract a PKCS#7 object from an S/MIME message
57.Sh SYNOPSIS
58.In openssl/pkcs7.h
59.Ft PKCS7 *
60.Fo SMIME_read_PKCS7
61.Fa "BIO *in"
62.Fa "BIO **bcont"
63.Fc
64.Sh DESCRIPTION
65.Fn SMIME_read_PKCS7
66parses a message in S/MIME format.
67.Pp
68.Fa in
69is a
70.Vt BIO
71to read the message from.
72.Pp
73If cleartext signing is used, then the content is saved in a memory
74.Vt BIO
75which is written to
76.Pf * Fa bcont ,
77otherwise
78.Pf * Fa bcont
79is set to
80.Dv NULL .
81.Pp
82The parsed PKCS#7 structure is returned, or
83.Dv NULL
84if an error occurred.
85.Pp
86If
87.Pf * Fa bcont
88is not
89.Dv NULL ,
90then the message is clear text signed.
91.Pf * Fa bcont
92can then be passed to
93.Xr PKCS7_verify 3
94with the
95.Dv PKCS7_DETACHED
96flag set.
97.Pp
98Otherwise the type of the returned structure can be determined using the
99.Fn PKCS7_type_is_*
100macros defined in
101.In openssl/pkcs7.h .
102.Pp
103To support future functionality, if
104.Fa bcont
105is not
106.Dv NULL ,
107.Pf * Fa bcont
108should be initialized to
109.Dv NULL .
110For example:
111.Bd -literal -offset indent
112BIO *cont = NULL;
113PKCS7 *p7;
114
115p7 = SMIME_read_PKCS7(in, &cont);
116.Ed
117.Sh RETURN VALUES
118.Fn SMIME_read_PKCS7
119returns a valid
120.Vt PKCS7
121structure or
122.Dv NULL
123if an error occurred.
124The error can be obtained from
125.Xr ERR_get_error 3 .
126.Sh SEE ALSO
127.Xr PKCS7_new 3 ,
128.Xr SMIME_read_ASN1 3 ,
129.Xr SMIME_write_PKCS7 3
130.Sh HISTORY
131.Fn SMIME_read_PKCS7
132first appeared in OpenSSL 0.9.5 and has been available since
133.Ox 2.7 .
134.Sh BUGS
135The MIME parser used by
136.Fn SMIME_read_PKCS7
137is somewhat primitive.
138While it will handle most S/MIME messages, more complex compound
139formats may not work.
140.Pp
141The parser assumes that the
142.Vt PKCS7
143structure is always base64 encoded, and it will not handle the case
144where it is in binary format or uses quoted printable format.
145.Pp
146The use of a memory
147.Vt BIO
148to hold the signed content limits the size of the message which can
149be processed due to memory restraints: a streaming single pass
150option should be available.
diff --git a/src/lib/libcrypto/man/SMIME_text.3 b/src/lib/libcrypto/man/SMIME_text.3
deleted file mode 100644
index a4c9689925..0000000000
--- a/src/lib/libcrypto/man/SMIME_text.3
+++ /dev/null
@@ -1,57 +0,0 @@
1.\" $OpenBSD: SMIME_text.3,v 1.1 2021/12/14 15:22:49 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 14 2021 $
18.Dt SMIME_TEXT 3
19.Os
20.Sh NAME
21.Nm SMIME_text
22.Nd remove text/plain MIME headers
23.Sh SYNOPSIS
24.In openssl/asn1.h
25.Ft int
26.Fo SMIME_text
27.Fa "BIO *in_bio"
28.Fa "BIO *out_bio"
29.Fc
30.Sh DESCRIPTION
31.Fn SMIME_text
32reads MIME headers from
33.Fa in_bio ,
34checks that the content type is
35.Dq text/plain ,
36discards the MIME headers,
37and copies the text that follows the headers from
38.Fa in_bio
39to
40.Fa out_bio .
41.Sh RETURN VALUES
42.Fn SMIME_text
43returns 1 on success or 0 if memory allocation, reading the input,
44or parsing the MIME headers fails, if there is no
45.Dq content-type
46header, or if the content type is not
47.Dq text/plain .
48.Sh SEE ALSO
49.Xr SMIME_crlf_copy 3 ,
50.Xr SMIME_read_ASN1 3
51.Sh HISTORY
52.Fn SMIME_text
53first appeared in OpenSSL 1.0.0 and has been available since
54.Ox 4.9 .
55.Sh CAVEATS
56.Fn SMIME_text
57does not support non-blocking BIOs.
diff --git a/src/lib/libcrypto/man/SMIME_write_ASN1.3 b/src/lib/libcrypto/man/SMIME_write_ASN1.3
deleted file mode 100644
index a02fa58570..0000000000
--- a/src/lib/libcrypto/man/SMIME_write_ASN1.3
+++ /dev/null
@@ -1,163 +0,0 @@
1.\" $OpenBSD: SMIME_write_ASN1.3,v 1.2 2023/05/01 07:28:11 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: May 1 2023 $
18.Dt SMIME_WRITE_ASN1 3
19.Os
20.Sh NAME
21.Nm SMIME_write_ASN1
22.Nd generate an S/MIME message
23.Sh SYNOPSIS
24.In openssl/asn1.h
25.Ft int
26.Fo SMIME_write_ASN1
27.Fa "BIO *out_bio"
28.Fa "ASN1_VALUE *val_in"
29.Fa "BIO *in_bio"
30.Fa "int flags"
31.Fa "int ctype_nid"
32.Fa "int econt_nid"
33.Fa "STACK_OF(X509_ALGOR) *micalg"
34.Fa "const ASN1_ITEM *it"
35.Fc
36.Sh DESCRIPTION
37.Fn SMIME_write_ASN1
38generates an S/MIME message on
39.Fa out_bio
40by writing MIME 1.0 headers
41followed by a BER- and base64-encoded serialization of
42.Fa val_in ,
43which can be of the type
44.Vt CMS_ContentInfo
45or
46.Vt PKCS7
47and has to match the
48.Fa it
49argument.
50.Pp
51The
52.Fa flags
53can be the logical OR of zero or more of the following bits:
54.Bl -tag -width Ds
55.It Dv PKCS7_REUSE_DIGEST
56Skip the calls to
57.Xr PKCS7_dataInit 3
58and
59.Xr PKCS7_dataFinal 3 .
60This flag has no effect unless
61.Dv SMIME_DETACHED
62is also set.
63It is normally used if
64.Fa out_bio
65is already set up to calculate and finalize the digest when written through.
66.It Dv SMIME_BINARY
67If specified, this flag is passed through to
68.Xr SMIME_crlf_copy 3 .
69.It Dv SMIME_CRLFEOL
70End MIME header lines with pairs of carriage return and newline characters.
71By default, no carriage return characters are written
72and header lines are ended with newline characters only.
73.It Dv SMIME_DETACHED
74Use cleartext signing.
75Generate a
76.Qq multipart/signed
77S/MIME message using the
78.Fa micalg
79argument and ignoring the
80.Fa ctype_nid
81and
82.Fa econt_nid
83arguments.
84The content is read from
85.Fa in_bio .
86If
87.Fa in_bio
88is a
89.Dv NULL
90pointer, this flag is ignored.
91.Pp
92If this flag is ignored or not specified,
93the smime-type is chosen according to
94.Fa ctype_nid
95instead:
96.Bl -tag -width Ds
97.It Dv NID_pkcs7_enveloped
98.Qq enveloped-data
99.It Dv NID_pkcs7_signed
100.Qq signed-receipt
101if
102.Fa econt_nid
103is
104.Dv NID_id_smime_ct_receipt
105.br
106.Qq signed-data
107if
108.Fa micalg
109is not empty
110.br
111.Qq certs-only
112if
113.Fa micalg
114is empty
115.It Dv NID_id_smime_ct_compressedData
116.Qq compressed-data
117.El
118.It Dv SMIME_OLDMIME
119In Content-Type headers, use
120.Qq application/x-pkcs7-mime
121or
122.Qq application/x-pkcs7-signature .
123By default,
124.Qq application/pkcs7-mime
125or
126.Qq application/pkcs7-signature
127are used instead.
128.It Dv SMIME_STREAM
129Perform streaming by reading the content from
130.Fa in_bio .
131This only works if
132.Dv SMIME_DETACHED
133is not specified.
134.It SMIME_TEXT
135Prepend the line
136.Qq Content-Type: text/plain
137to the content.
138This only makes sense if
139.Dv SMIME_DETACHED
140is also set.
141It is ignored if the flag
142.Dv SMIME_BINARY
143is also set.
144.El
145.Sh RETURN VALUES
146.Fn SMIME_write_ASN1
147is intended to return 1 on success or 0 on failure.
148.Sh SEE ALSO
149.Xr ASN1_item_i2d_bio 3 ,
150.Xr BIO_f_base64 3 ,
151.Xr BIO_new 3 ,
152.Xr SMIME_crlf_copy 3 ,
153.Xr SMIME_write_CMS 3 ,
154.Xr SMIME_write_PKCS7 3 ,
155.Xr X509_ALGOR_new 3
156.Sh HISTORY
157.Fn SMIME_write_ASN1
158first appeared in OpenSSL 1.0.0 and has been available since
159.Ox 4.9 .
160.Sh BUGS
161.Fn SMIME_write_ASN1
162ignores most errors and is likely to return 1
163even after producing corrupt or incomplete output.
diff --git a/src/lib/libcrypto/man/SMIME_write_CMS.3 b/src/lib/libcrypto/man/SMIME_write_CMS.3
deleted file mode 100644
index c2c6b77e53..0000000000
--- a/src/lib/libcrypto/man/SMIME_write_CMS.3
+++ /dev/null
@@ -1,133 +0,0 @@
1.\" $OpenBSD: SMIME_write_CMS.3,v 1.6 2021/12/13 17:24:39 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 13 2021 $
52.Dt SMIME_WRITE_CMS 3
53.Os
54.Sh NAME
55.Nm SMIME_write_CMS
56.Nd convert CMS structure to S/MIME format
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft int
60.Fo SMIME_write_CMS
61.Fa "BIO *out"
62.Fa "CMS_ContentInfo *cms"
63.Fa "BIO *data"
64.Fa "int flags"
65.Fc
66.Sh DESCRIPTION
67.Fn SMIME_write_CMS
68adds the appropriate MIME headers to the
69.Fa cms
70structure to produce an S/MIME message and writes it to
71.Fa out .
72If streaming is enabled, the content must be supplied in the
73.Fa data
74argument.
75.Pp
76The following
77.Fa flags
78can be passed:
79.Bl -tag -width Ds
80.It Dv CMS_DETACHED
81Use cleartext signing.
82This option only makes sense if
83.Fa cms
84is of the type
85.Vt SignedData
86and
87.Dv CMS_DETACHED
88was also set when it was created with
89.Xr CMS_sign 3 .
90.Pp
91If
92.Dv CMS_STREAM
93is not set, the data must be read twice:
94once to compute the signature in
95.Xr CMS_sign 3
96and once to output the S/MIME message.
97.It Dv CMS_TEXT
98Add MIME headers for type text/plain to the content.
99This only makes sense if
100.Dv CMS_DETACHED
101is also set.
102.It Dv CMS_STREAM
103Perform streaming.
104This flag should only be set if
105.Dv CMS_STREAM
106was also passed to the function that created
107.Fa cms .
108.Pp
109The content is output in BER format using indefinite length
110constructed encoding except in the case of
111.Vt SignedData
112with detached content where the content is absent and DER format is
113used.
114.El
115.Sh RETURN VALUES
116.Fn SMIME_write_CMS
117returns 1 for success or 0 for failure.
118.Sh SEE ALSO
119.Xr CMS_ContentInfo_new 3 ,
120.Xr CMS_encrypt 3 ,
121.Xr CMS_sign 3 ,
122.Xr d2i_CMS_ContentInfo 3 ,
123.Xr ERR_get_error 3 ,
124.Xr SMIME_write_ASN1 3
125.Sh HISTORY
126.Fn SMIME_write_CMS
127first appeared in OpenSSL 0.9.8h
128and has been available since
129.Ox 6.7 .
130.Sh BUGS
131.Fn SMIME_write_CMS
132always base64 encodes CMS structures.
133There should be an option to disable this.
diff --git a/src/lib/libcrypto/man/SMIME_write_PKCS7.3 b/src/lib/libcrypto/man/SMIME_write_PKCS7.3
deleted file mode 100644
index c1a9f051d0..0000000000
--- a/src/lib/libcrypto/man/SMIME_write_PKCS7.3
+++ /dev/null
@@ -1,184 +0,0 @@
1.\" $OpenBSD: SMIME_write_PKCS7.3,v 1.9 2021/12/14 15:46:48 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2002, 2003, 2006, 2007, 2015 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: December 14 2021 $
70.Dt SMIME_WRITE_PKCS7 3
71.Os
72.Sh NAME
73.Nm SMIME_write_PKCS7
74.Nd convert PKCS#7 structure to S/MIME format
75.Sh SYNOPSIS
76.In openssl/pkcs7.h
77.Ft int
78.Fo SMIME_write_PKCS7
79.Fa "BIO *out"
80.Fa "PKCS7 *p7"
81.Fa "BIO *data"
82.Fa "int flags"
83.Fc
84.Sh DESCRIPTION
85.Fn SMIME_write_PKCS7
86adds the appropriate MIME headers to a PKCS#7 structure to produce an
87S/MIME message.
88.Pp
89.Fa out
90is the
91.Vt BIO
92to write the data to.
93.Fa p7
94is the appropriate
95.Vt PKCS7
96structure.
97If streaming is enabled, then the content must be supplied in the
98.Fa data
99argument.
100.Fa flags
101is an optional set of flags.
102.Pp
103The following flags can be passed in the
104.Fa flags
105parameter.
106.Pp
107If
108.Dv PKCS7_DETACHED
109is set, then cleartext signing will be used.
110This option only makes sense for signedData where
111.Dv PKCS7_DETACHED
112is also set when
113.Xr PKCS7_sign 3
114is also called.
115.Pp
116If the
117.Dv PKCS7_TEXT
118flag is set, MIME headers for type
119.Sy text/plain
120are added to the content.
121This only makes sense if
122.Dv PKCS7_DETACHED
123is also set.
124.Pp
125If the
126.Dv PKCS7_STREAM
127flag is set, streaming is performed.
128This flag should only be set if
129.Dv PKCS7_STREAM
130was also set in the previous call to
131.Xr PKCS7_sign 3
132or
133.Xr PKCS7_encrypt 3 .
134.Pp
135The bit
136.Dv SMIME_OLDMIME
137is inverted before passing on the
138.Fa flags
139to
140.Xr SMIME_write_ASN1 3 .
141Consequently, if this bit is set in the
142.Fa flags
143argument,
144.Qq application/pkcs7-mime
145or
146.Qq application/pkcs7-signature
147is used in Content-Type headers.
148Otherwise,
149.Qq application/x-pkcs7-mime
150or
151.Qq application/x-pkcs7-signature
152is used.
153.Pp
154If cleartext signing is being used and
155.Dv PKCS7_STREAM
156is not set, then the data must be read twice: once to compute the
157signature in
158.Xr PKCS7_sign 3
159and once to output the S/MIME message.
160.Pp
161If streaming is performed, the content is output in BER format using
162indefinite length constructed encoding except in the case of signed
163data with detached content where the content is absent and DER
164format is used.
165.Sh RETURN VALUES
166Upon successful completion, 1 is returned;
167otherwise 0 is returned and an error code can be retrieved with
168.Xr ERR_get_error 3 .
169.Sh SEE ALSO
170.Xr i2d_PKCS7_bio_stream 3 ,
171.Xr PEM_write_bio_PKCS7_stream 3 ,
172.Xr PEM_write_PKCS7 3 ,
173.Xr PKCS7_final 3 ,
174.Xr PKCS7_new 3 ,
175.Xr SMIME_read_PKCS7 3 ,
176.Xr SMIME_write_ASN1 3
177.Sh HISTORY
178.Fn SMIME_write_PKCS7
179first appeared in OpenSSL 0.9.5 and has been available since
180.Ox 2.7 .
181.Sh BUGS
182.Fn SMIME_write_PKCS7
183always base64 encodes PKCS#7 structures.
184There should be an option to disable this.
diff --git a/src/lib/libcrypto/man/STACK_OF.3 b/src/lib/libcrypto/man/STACK_OF.3
deleted file mode 100644
index 4c627eed9b..0000000000
--- a/src/lib/libcrypto/man/STACK_OF.3
+++ /dev/null
@@ -1,207 +0,0 @@
1.\" $OpenBSD: STACK_OF.3,v 1.5 2021/10/24 13:10:46 schwarze Exp $
2.\"
3.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 24 2021 $
18.Dt STACK_OF 3
19.Os
20.Sh NAME
21.Nm STACK_OF
22.Nd variable-sized arrays of pointers, called OpenSSL stacks
23.Sh SYNOPSIS
24.In openssl/safestack.h
25.Fn STACK_OF type
26.Sh DESCRIPTION
27The
28.In openssl/safestack.h
29header provides a fragile, unusually complicated system of
30macro-generated wrappers around the functions described in the
31.Xr OPENSSL_sk_new 3
32manual page.
33It is intended to implement superficially type-safe variable-sized
34arrays of pointers, somewhat misleadingly called
35.Dq stacks
36by OpenSSL.
37Due to the excessive number of API functions, it is impossible to
38properly document this system.
39In particular, calling
40.Xr man 1
41for any of the functions operating on stacks cannot yield any result.
42.Pp
43Unfortunately, application programs can hardly avoid using the concept
44because several important OpenSSL APIs rely on it; see the
45.Sx SEE ALSO
46section for examples.
47Even though both pages are more complicated than any manual page
48ought to be, using the concept safely requires a complete understanding
49of all the details in both this manual page and in
50.Xr OPENSSL_sk_new 3 .
51.Pp
52The
53.Fn STACK_OF
54macro takes a
55.Fa type
56name as its argument, typically the name of a type
57that has been defined as an alias for a specific
58.Vt struct
59type using a
60.Sy typedef
61declaration.
62It expands to an incomplete
63.Vt struct
64type which is intended to represent a
65.Dq stack
66of objects of the given
67.Fa type .
68That type does not actually exist, so it is not possible to define,
69for example, an automatic variable
70.Ql STACK_OF(X509) my_certificates ;
71it is only possible to define pointers to stacks, for example
72.Ql STACK_OF(X509) *my_certificates .
73The only way such pointers can ever be used is by wrapper functions
74casting them to the type
75.Vt _STACK *
76described in
77.Xr OPENSSL_sk_new 3 .
78.Pp
79For a considerable number of types, OpenSSL provides one wrapper
80function for each function described in
81.Xr OPENSSL_sk_new 3 .
82The names of these wrapper functions are usually constructed by
83inserting the name of the type and an underscore after the
84.Sq sk_
85prefix of the function name.
86Usually, where the real functions take
87.Vt void *
88arguments, the wrappers take pointers to the
89.Fa type
90in questions, and where the real functions take
91.Vt _STACK *
92arguments, the wrappers take pointers to
93.Fn STACK_OF type .
94The same applies to return values.
95Various exceptions to all this exist, but the above applies to
96all the types listed below.
97.Pp
98Using the above may make sense for the following types because
99public API functions exist that take stacks of these types as
100arguments or return them:
101.Vt ASN1_INTEGER ,
102.Vt ASN1_OBJECT ,
103.Vt ASN1_UTF8STRING ,
104.Vt CMS_RecipientInfo ,
105.Vt CMS_SignerInfo ,
106.Vt CONF_VALUE ,
107.Vt GENERAL_NAMES ,
108.Vt GENERAL_SUBTREE ,
109.Vt OPENSSL_STRING Pq which is just Vt char * ,
110.Vt PKCS12_SAFEBAG ,
111.Vt PKCS7 ,
112.Vt PKCS7_RECIP_INFO ,
113.Vt PKCS7_SIGNER_INFO ,
114.Vt POLICYQUALINFO ,
115.Vt SRTP_PROTECTION_PROFILE ,
116.Vt SSL_CIPHER ,
117.Vt SSL_COMP ,
118.Vt X509 ,
119.Vt X509_ALGOR ,
120.Vt X509_ATTRIBUTE ,
121.Vt X509_CRL ,
122.Vt X509_EXTENSION ,
123.Vt X509_INFO ,
124.Vt X509_NAME ,
125.Vt X509_OBJECT ,
126.Vt X509_POLICY_NODE ,
127.Vt X509_REVOKED .
128.Pp
129Additionally, some public API functions use the following types
130which are declared with
131.Sy typedef :
132.Bl -column STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS
133.It Vt STACK_OF(ACCESS_DESCRIPTION) Ta Vt AUTHORITY_INFO_ACCESS
134.It Vt STACK_OF(ASN1_OBJECT) Ta Vt EXTENDED_KEY_USAGE
135.It Vt STACK_OF(ASN1_TYPE) Ta Vt ASN1_SEQUENCE_ANY
136.It Vt STACK_OF(DIST_POINT) Ta Vt CRL_DIST_POINTS
137.It Vt STACK_OF(GENERAL_NAME) Ta Vt GENERAL_NAMES
138.It Vt STACK_OF(IPAddressFamily) Ta Vt IPAddrBlocks
139.It Vt STACK_OF(POLICY_MAPPING) Ta Vt POLICY_MAPPINGS
140.It Vt STACK_OF(POLICYINFO) Ta Vt CERTIFICATEPOLICIES
141.It Vt STACK_OF(X509_ALGOR) Ta Vt X509_ALGORS
142.It Vt STACK_OF(X509_EXTENSION) Ta Vt X509_EXTENSIONS
143.El
144.Pp
145Even though the OpenSSL headers declare wrapper functions for many
146more types and even though the OpenSSL documentation says that users
147can declare their own stack types, using
148.Fn STACK_OF
149with any type not listed here is strongly discouraged.
150For other types, there may be subtle, undocumented differences
151in syntax and semantics, and attempting to declare custom stack
152types is very error prone; using plain C arrays of pointers to
153the desired type is much simpler and less dangerous.
154.Sh EXAMPLES
155The following program creates a certificate object, puts two
156pointers to it on a stack, and uses
157.Xr X509_free 3
158to clean up properly:
159.Bd -literal
160#include <err.h>
161#include <stdio.h>
162#include <openssl/x509.h>
163
164int
165main(void)
166{
167 STACK_OF(X509) *stack;
168 X509 *x;
169
170 if ((stack = sk_X509_new_null()) == NULL)
171 err(1, NULL);
172 if ((x = X509_new()) == NULL)
173 err(1, NULL);
174 if (sk_X509_push(stack, x) == 0)
175 err(1, NULL);
176 if (X509_up_ref(x) == 0)
177 errx(1, "X509_up_ref failed");
178 if (sk_X509_push(stack, x) == 0)
179 err(1, NULL);
180 printf("%d pointers: %p, %p\en", sk_X509_num(stack),
181 sk_X509_value(stack, 0), sk_X509_value(stack, 1));
182 sk_X509_pop_free(stack, X509_free);
183
184 return 0;
185}
186.Ed
187.Pp
188The output looks similar to:
189.Pp
190.Dl 2 pointers: 0x4693ff24c00, 0x4693ff24c00
191.Sh SEE ALSO
192.Xr crypto 3 ,
193.Xr OCSP_request_sign 3 ,
194.Xr OPENSSL_sk_new 3 ,
195.Xr PKCS12_parse 3 ,
196.Xr PKCS7_encrypt 3 ,
197.Xr SSL_CTX_set_client_CA_list 3 ,
198.Xr SSL_get_ciphers 3 ,
199.Xr SSL_get_peer_cert_chain 3 ,
200.Xr SSL_load_client_CA_file 3 ,
201.Xr X509_CRL_get_REVOKED 3 ,
202.Xr X509_STORE_CTX_get0_chain 3
203.Sh HISTORY
204The
205.Fn STACK_OF
206macro first appeared in OpenSSL 0.9.3 and has been available since
207.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/TS_REQ_new.3 b/src/lib/libcrypto/man/TS_REQ_new.3
deleted file mode 100644
index 8dbd15ea7e..0000000000
--- a/src/lib/libcrypto/man/TS_REQ_new.3
+++ /dev/null
@@ -1,182 +0,0 @@
1.\" $OpenBSD: TS_REQ_new.3,v 1.6 2019/06/06 01:06:59 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 6 2019 $
18.Dt TS_REQ_NEW 3
19.Os
20.Sh NAME
21.Nm TS_REQ_new ,
22.Nm TS_REQ_free ,
23.Nm TS_RESP_new ,
24.Nm TS_RESP_free ,
25.Nm TS_STATUS_INFO_new ,
26.Nm TS_STATUS_INFO_free ,
27.Nm TS_TST_INFO_new ,
28.Nm TS_TST_INFO_free ,
29.Nm TS_ACCURACY_new ,
30.Nm TS_ACCURACY_free ,
31.Nm TS_MSG_IMPRINT_new ,
32.Nm TS_MSG_IMPRINT_free
33.Nd X.509 time-stamp protocol
34.Sh SYNOPSIS
35.In openssl/ts.h
36.Ft TS_REQ *
37.Fn TS_REQ_new void
38.Ft void
39.Fn TS_REQ_free "TS_REQ *req"
40.Ft TS_RESP *
41.Fn TS_RESP_new void
42.Ft void
43.Fn TS_RESP_free "TS_RESP *resp"
44.Ft TS_STATUS_INFO *
45.Fn TS_STATUS_INFO_new void
46.Ft void
47.Fn TS_STATUS_INFO_free "TS_STATUS_INFO *status"
48.Ft TS_TST_INFO *
49.Fn TS_TST_INFO_new void
50.Ft void
51.Fn TS_TST_INFO_free "TS_TST_INFO *token"
52.Ft TS_ACCURACY *
53.Fn TS_ACCURACY_new void
54.Ft void
55.Fn TS_ACCURACY_free "TS_ACCURACY *accuracy"
56.Ft TS_MSG_IMPRINT *
57.Fn TS_MSG_IMPRINT_new void
58.Ft void
59.Fn TS_MSG_IMPRINT_free "TS_MSG_IMPRINT *imprint"
60.Sh DESCRIPTION
61A time-stamping authority is a trusted third party which allows its
62clients to prove that specific data existed at a particular point
63in time.
64Clients send time-stamping requests to the time-stamping server,
65which returns time-stamp tokens to the clients.
66.Pp
67.Fn TS_REQ_new
68allocates and initializes an empty
69.Vt TS_REQ
70object, representing an ASN.1
71.Vt TimeStampReq
72structure defined in RFC 3161 section 2.4.1.
73It can hold a hash of the datum to be time-stamped and some
74auxiliary, optional information.
75.Fn TS_REQ_free
76frees
77.Fa req .
78.Pp
79.Fn TS_RESP_new
80allocates and initializes an empty
81.Vt TS_RESP
82object, representing an ASN.1
83.Vt TimeStampResp
84structure defined in RFC 3161 section 2.4.2.
85It can hold status information and a time-stamp token.
86.Fn TS_RESP_free
87frees
88.Fa resp .
89.Pp
90.Fn TS_STATUS_INFO_new
91allocates and initializes an empty
92.Vt TS_STATUS_INFO
93object, representing an ASN.1
94.Vt PKIStatusInfo
95structure defined in RFC 3161 section 2.4.2.
96It is used inside
97.Vt TS_RESP
98and describes the outcome of one time-stamp request.
99.Fn TS_STATUS_INFO_free
100frees
101.Fa status .
102.Pp
103.Fn TS_TST_INFO_new
104allocates and initializes an empty
105.Vt TS_TST_INFO
106object, representing an ASN.1
107.Vt TSTInfo
108structure defined in RFC 3161 section 2.4.2.
109It is the time-stamp token included in a
110.Vt TS_RESP
111object in case of success, and it can hold the hash of the datum
112copied from a request, the time of generation, and some auxiliary
113information.
114.Fn TS_TST_INFO_free
115frees
116.Fa token .
117.Pp
118.Fn TS_ACCURACY_new
119allocates and initializes an empty
120.Vt TS_ACCURACY
121object, representing an ASN.1
122.Vt Accuracy
123structure defined in RFC 3161 section 2.4.2.
124It can be used inside a
125.Vt TS_TST_INFO
126object and indicates the maximum error of the time stated in the token.
127.Fn TS_ACCURACY_free
128frees
129.Fa accuracy .
130.Pp
131.Fn TS_MSG_IMPRINT_new
132allocates and initializes an empty
133.Vt TS_MSG_IMPRINT
134object, representing an ASN.1
135.Vt MessageImprint
136structure defined in RFC 3161 section 2.4.1.
137It is used inside
138.Vt TS_REQ
139and
140.Vt TS_RESP
141objects.
142It specifies a hash algorithm and stores the hash value of the datum.
143.Fn TS_MSG_IMPRINT_free
144frees
145.Fa imprint .
146.Sh RETURN VALUES
147.Fn TS_REQ_new ,
148.Fn TS_RESP_new ,
149.Fn TS_STATUS_INFO_new ,
150.Fn TS_TST_INFO_new ,
151.Fn TS_ACCURACY_new ,
152and
153.Fn TS_MSG_IMPRINT_new
154return the new
155.Vt TS_REQ ,
156.Vt TS_RESP ,
157.Vt TS_STATUS_INFO ,
158.Vt TS_TST_INFO ,
159.Vt TS_ACCURACY ,
160or
161.Vt TS_MSG_IMPRINT
162object, respectively, or
163.Dv NULL
164if an error occurred.
165.Sh SEE ALSO
166.Xr ACCESS_DESCRIPTION_new 3 ,
167.Xr ESS_SIGNING_CERT_new 3 ,
168.Xr X509_EXTENSION_new 3
169.Sh STANDARDS
170RFC 3161: Internet X.509 Public Key Infrastructure Time-Stamp Protocol
171.Pp
172Note that RFC 3161 has been updated
173by RFC 5816: ESSCertIDv2 Update for RFC 3161.
174That update allows using the Signing Certificate Attribute Definition
175Version 2 according to RFC 5035, but the current implementation
176only supports the Signing Certificate Attribute Definition Version
1771 according to RFC 2634, and hence only supports RFC 3161, but not
178RFC 5816 functionality.
179.Sh HISTORY
180These functions first appeared in OpenSSL 1.0.0
181and have been available since
182.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/UI_create_method.3 b/src/lib/libcrypto/man/UI_create_method.3
deleted file mode 100644
index ffd6b98157..0000000000
--- a/src/lib/libcrypto/man/UI_create_method.3
+++ /dev/null
@@ -1,284 +0,0 @@
1.\" $OpenBSD: UI_create_method.3,v 1.6 2023/05/22 19:38:04 tb Exp $
2.\" OpenSSL UI_create_method.pod 8e3d46e5 Mar 11 10:51:04 2017 +0100
3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org>.
5.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: May 22 2023 $
52.Dt UI_CREATE_METHOD 3
53.Os
54.Sh NAME
55.Nm UI_create_method ,
56.Nm UI_destroy_method ,
57.Nm UI_method_set_opener ,
58.Nm UI_method_set_writer ,
59.Nm UI_method_set_flusher ,
60.Nm UI_method_set_reader ,
61.Nm UI_method_set_closer ,
62.Nm UI_method_set_prompt_constructor ,
63.Nm UI_method_get_opener ,
64.Nm UI_method_get_writer ,
65.Nm UI_method_get_flusher ,
66.Nm UI_method_get_reader ,
67.Nm UI_method_get_closer ,
68.Nm UI_method_get_prompt_constructor
69.Nd user interface method creation and destruction
70.Sh SYNOPSIS
71.In openssl/ui.h
72.Ft UI_METHOD *
73.Fo UI_create_method
74.Fa "const char *name"
75.Fc
76.Ft void
77.Fo UI_destroy_method
78.Fa "UI_METHOD *ui_method"
79.Fc
80.Ft int
81.Fo UI_method_set_opener
82.Fa "UI_METHOD *method"
83.Fa "int (*opener)(UI *ui)"
84.Fc
85.Ft int
86.Fo UI_method_set_writer
87.Fa "UI_METHOD *method"
88.Fa "int (*writer)(UI *ui, UI_STRING *uis)"
89.Fc
90.Ft int
91.Fo UI_method_set_flusher
92.Fa "UI_METHOD *method"
93.Fa "int (*flusher)(UI *ui)"
94.Fc
95.Ft int
96.Fo UI_method_set_reader
97.Fa "UI_METHOD *method"
98.Fa "int (*reader)(UI *ui, UI_STRING *uis)"
99.Fc
100.Ft int
101.Fo UI_method_set_closer
102.Fa "UI_METHOD *method"
103.Fa "int (*closer)(UI *ui)"
104.Fc
105.Ft int
106.Fo UI_method_set_prompt_constructor
107.Fa "UI_METHOD *method"
108.Fa "char *(*prompt_constructor)(UI *ui, const char *object_desc,\
109 const char *object_name)"
110.Fc
111.Ft int
112.Fo "(*UI_method_get_opener(const UI_METHOD *method))"
113.Fa "UI *"
114.Fc
115.Ft int
116.Fo "(*UI_method_get_writer(const UI_METHOD *method))"
117.Fa "UI *"
118.Fa "UI_STRING *"
119.Fc
120.Ft int
121.Fo "(*UI_method_get_flusher(const UI_METHOD *method))"
122.Fa "UI *"
123.Fc
124.Ft int
125.Fo "(*UI_method_get_reader(const UI_METHOD *method))"
126.Fa "UI *"
127.Fa "UI_STRING *"
128.Fc
129.Ft int
130.Fo "(*UI_method_get_closer(const UI_METHOD *method))"
131.Fa "UI *"
132.Fc
133.Ft char *
134.Fo "(*UI_method_get_prompt_constructor(UI_METHOD *method))"
135.Fa "UI *"
136.Fa "const char *"
137.Fa "const char *"
138.Fc
139.Sh DESCRIPTION
140A method contains a few functions that implement the low level of the
141User Interface.
142These functions are:
143.Bl -tag -width Ds
144.It an opener
145This function takes a reference to a UI and starts a session, for
146example by opening a channel to a tty, or by creating a dialog box.
147.It a writer
148This function takes a reference to a UI and a UI String, and writes the
149string where appropriate, maybe to the tty, maybe added as a field label
150in a dialog box.
151Note that this gets fed all strings associated with a UI, one after the
152other, so care must be taken which ones it actually uses.
153.It a flusher
154This function takes a reference to a UI, and flushes everything that has
155been output so far.
156For example, if the method builds up a dialog box, this can be used to
157actually display it and accepting input ended with a pressed button.
158.It a reader
159This function takes a reference to a UI and a UI string and reads off
160the given prompt, maybe from the tty, maybe from a field in a dialog
161box.
162Note that this gets fed all strings associated with a UI, one after the
163other, so care must be taken which ones it actually uses.
164.It a closer
165This function takes a reference to a UI, and closes the session, maybe
166by closing the channel to the tty, maybe by destroying a dialog box.
167.El
168.Pp
169All of these functions are expected to return 0 on error, 1 on success,
170or -1 on out-off-band events, for example if some prompting has been
171cancelled (by pressing Ctrl-C, for example).
172Only the flusher or the reader are expected to return -1.
173If returned by another of the functions, it's treated as if 0 was returned.
174.Pp
175Regarding the writer and the reader, don't assume the former should only
176write and don't assume the latter should only read.
177This depends on the needs of the method.
178.Pp
179For example, a typical tty reader wouldn't write the prompts in the
180write, but would rather do so in the reader, because of the sequential
181nature of prompting on a tty.
182This is how the
183.Xr UI_OpenSSL 3
184method does it.
185.Pp
186In contrast, a method that builds up a dialog box would add all prompt
187text in the writer, have all input read in the flusher and store the
188results in some temporary buffer, and finally have the reader just fetch
189those results.
190.Pp
191The central function that uses these method functions is
192.Xr UI_process 3 ,
193and it does it in five steps:
194.Bl -enum
195.It
196Open the session using the opener function if that one is defined.
197If an error occurs, jump to 5.
198.It
199For every UI String associated with the UI, call the writer function if
200that one is defined.
201If an error occurs, jump to 5.
202.It
203Flush everything using the flusher function if that one is defined.
204If an error occurs, jump to 5.
205.It
206For every UI String associated with the UI, call the reader function if
207that one is defined.
208If an error occurs, jump to 5.
209.It
210Close the session using the closer function if that one is defined.
211.El
212.Pp
213.Fn UI_create_method
214creates a new UI method with a given
215.Fa name .
216.Pp
217.Fn UI_destroy_method
218destroys the given
219.Fa ui_method .
220.Pp
221.Fn UI_method_set_opener ,
222.Fn UI_method_set_writer ,
223.Fn UI_method_set_flusher ,
224.Fn UI_method_set_reader
225and
226.Fn UI_method_set_closer
227set one of the five main methods to the given function pointer.
228.Pp
229.Fn UI_method_set_prompt_constructor
230sets the prompt constructor, see
231.Xr UI_construct_prompt 3 .
232.Sh RETURN VALUES
233.Fn UI_create_method
234returns a
235.Vt UI_METHOD
236pointer on success or
237.Dv NULL
238on error.
239.Pp
240.Fn UI_method_set_opener ,
241.Fn UI_method_set_writer ,
242.Fn UI_method_set_flusher ,
243.Fn UI_method_set_reader ,
244.Fn UI_method_set_closer ,
245and
246.Fn UI_method_set_prompt_constructor
247return 0 on success or -1 if the given method is
248.Dv NULL .
249.Pp
250.Fn UI_method_get_opener ,
251.Fn UI_method_get_writer ,
252.Fn UI_method_get_flusher ,
253.Fn UI_method_get_reader ,
254.Fn UI_method_get_closer ,
255and
256.Fn UI_method_get_prompt_constructor
257return the requested function pointer if it is set in the method,
258or otherwise
259.Dv NULL .
260.Sh SEE ALSO
261.Xr UI_get_string_type 3 ,
262.Xr UI_new 3
263.Sh HISTORY
264.Fn UI_create_method ,
265.Fn UI_destroy_method ,
266.Fn UI_method_set_opener ,
267.Fn UI_method_set_writer ,
268.Fn UI_method_set_flusher ,
269.Fn UI_method_set_reader ,
270.Fn UI_method_set_closer ,
271.Fn UI_method_get_opener ,
272.Fn UI_method_get_writer ,
273.Fn UI_method_get_flusher ,
274.Fn UI_method_get_reader ,
275and
276.Fn UI_method_get_closer
277first appeared in OpenSSL 0.9.7 and have been available since
278.Ox 3.2 .
279.Pp
280.Fn UI_method_set_prompt_constructor
281and
282.Fn UI_method_get_prompt_constructor
283first appeared in OpenSSL 1.0.0 and have been available since
284.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/UI_get_string_type.3 b/src/lib/libcrypto/man/UI_get_string_type.3
deleted file mode 100644
index bc0449a90e..0000000000
--- a/src/lib/libcrypto/man/UI_get_string_type.3
+++ /dev/null
@@ -1,281 +0,0 @@
1.\" $OpenBSD: UI_get_string_type.3,v 1.4 2018/03/22 21:08:22 schwarze Exp $
2.\" OpenSSL UI_STRING.pod e9c9971b Jul 1 18:28:50 2017 +0200
3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org>
5.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 22 2018 $
52.Dt UI_GET_STRING_TYPE 3
53.Os
54.Sh NAME
55.Nm UI_get_string_type ,
56.Nm UI_get_input_flags ,
57.Nm UI_get0_output_string ,
58.Nm UI_get0_action_string ,
59.Nm UI_get0_result_string ,
60.Nm UI_get0_test_string ,
61.Nm UI_get_result_minsize ,
62.Nm UI_get_result_maxsize ,
63.Nm UI_set_result
64.Nd OpenSSL user interface string parsing
65.Sh SYNOPSIS
66.In openssl/ui.h
67.Bd -literal
68enum UI_string_types {
69 UIT_NONE = 0,
70 UIT_PROMPT, /* Prompt for a string */
71 UIT_VERIFY, /* Prompt for a string and verify */
72 UIT_BOOLEAN, /* Prompt for a yes/no response */
73 UIT_INFO, /* Send info to the user */
74 UIT_ERROR /* Send an error message to the user */
75};
76.Ed
77.Pp
78.Ft enum UI_string_types
79.Fo UI_get_string_type
80.Fa "UI_STRING *uis"
81.Fc
82.Ft int
83.Fo UI_get_input_flags
84.Fa "UI_STRING *uis"
85.Fc
86.Ft const char *
87.Fo UI_get0_output_string
88.Fa "UI_STRING *uis"
89.Fc
90.Ft const char *
91.Fo UI_get0_action_string
92.Fa "UI_STRING *uis"
93.Fc
94.Ft const char *
95.Fo UI_get0_result_string
96.Fa "UI_STRING *uis"
97.Fc
98.Ft const char *
99.Fo UI_get0_test_string
100.Fa "UI_STRING *uis"
101.Fc
102.Ft int
103.Fo UI_get_result_minsize
104.Fa "UI_STRING *uis"
105.Fc
106.Ft int
107.Fo UI_get_result_maxsize
108.Fa "UI_STRING *uis"
109.Fc
110.Ft int
111.Fo UI_set_result
112.Fa "UI *ui"
113.Fa "UI_STRING *uis"
114.Fa "const char *result"
115.Fc
116.Sh DESCRIPTION
117A
118.Vt UI_STRING
119gets created internally and added to a
120.Vt UI
121object whenever one of the functions
122.Xr UI_add_input_string 3 ,
123.Xr UI_dup_input_string 3 ,
124.Xr UI_add_verify_string 3 ,
125.Xr UI_dup_verify_string 3 ,
126.Xr UI_add_input_boolean 3 ,
127.Xr UI_dup_input_boolean 3 ,
128.Xr UI_add_info_string 3 ,
129.Xr UI_dup_info_string 3 ,
130.Xr UI_add_error_string 3
131or
132.Xr UI_dup_error_string 3
133is called.
134For a
135.Vt UI_METHOD
136user, there's no need to know more.
137For a
138.Vt UI_METHOD
139creator, it is of interest to fetch text from these
140.Vt UI_STRING
141objects as well as adding results to some of them.
142.Pp
143.Fn UI_get_string_type
144is used to retrieve the type of the given
145.Vt UI_STRING .
146.Pp
147.Fn UI_get_input_flags
148is used to retrieve the flags associated with the given
149.Vt UI_STRING .
150.Pp
151.Fn UI_get0_output_string
152is used to retrieve the actual string to output (prompt, info, error, ...).
153.Pp
154.Fn UI_get0_action_string
155is used to retrieve the action description associated with a
156.Dv UIT_BOOLEAN
157type
158.Vt UI_STRING .
159See
160.Xr UI_add_input_boolean 3 .
161.Pp
162.Fn UI_get0_result_string
163is used to retrieve the result of a prompt.
164This is only useful for
165.Dv UIT_PROMPT
166and
167.Dv UIT_VERIFY
168type strings.
169.Pp
170.Fn UI_get0_test_string
171is used to retrieve the string to compare the prompt result with.
172This is only useful for
173.Dv UIT_VERIFY
174type strings.
175.Pp
176.Fn UI_get_result_minsize
177and
178.Fn UI_get_result_maxsize
179are used to retrieve the minimum and maximum required size of the
180result.
181This is only useful for
182.Dv UIT_PROMPT
183and
184.Dv UIT_VERIFY
185type strings.
186.Pp
187.Fn UI_set_result
188is used to set the result value of a prompt.
189For
190.Sy UIT_PROMPT
191and
192.Sy UIT_VERIFY
193type UI strings, this sets the result retrievable with
194.Fn UI_get0_result_string
195by copying the contents of
196.Fa result
197if its length fits the minimum and maximum size requirements.
198For
199.Dv UIT_BOOLEAN
200type UI strings, this sets the first character of the result retrievable
201with
202.Fn UI_get0_result_string
203to the first of the
204.Fa ok_chars
205given with
206.Xr UI_add_input_boolean 3
207or
208.Xr UI_dup_input_boolean 3
209if the
210.Fa result
211matched any of them, or the first of the
212.Fa cancel_chars
213if the
214.Fa result
215matched any of them, otherwise it's set to the NUL char.
216See
217.Xr UI_add_input_boolean 3
218for more information on
219.Fa ok_chars
220and
221.Fa cancel_chars .
222.Sh RETURN VALUES
223.Fn UI_get_string_type
224returns the UI string type.
225.Pp
226.Fn UI_get_input_flags
227returns the UI string flags.
228.Pp
229.Fn UI_get0_output_string
230returns the UI string output string.
231.Pp
232.Fn UI_get0_action_string
233returns the UI string action description string for
234.Dv UIT_BOOLEAN
235type UI strings, or
236.Dv NULL
237for any other type.
238.Pp
239.Fn UI_get0_result_string
240returns the UI string result buffer for
241.Dv UIT_PROMPT
242and
243.Dv UIT_VERIFY
244type UI strings, or
245.Dv NULL
246for any other type.
247.Pp
248.Fn UI_get0_test_string
249returns the UI string action description string for
250.Dv UIT_VERIFY
251type UI strings, or
252.Dv NULL
253for any other type.
254.Pp
255.Fn UI_get_result_minsize
256returns the minimum allowed result size for the UI string for
257.Dv UIT_PROMPT
258and
259.Dv UIT_VERIFY
260type strings, or -1 for any other type.
261.Pp
262.Fn UI_get_result_maxsize
263returns the minimum allowed result size for the UI string for
264.Dv UIT_PROMPT
265and
266.Dv UIT_VERIFY
267type strings, or -1 for any other type.
268.Pp
269.Fn UI_set_result
270returns 0 on success or when the UI string is of any type other than
271.Dv UIT_PROMPT ,
272.Dv UIT_VERIFY ,
273or
274.Dv UIT_BOOLEAN ,
275or -1 on error.
276.Sh SEE ALSO
277.Xr UI_new 3
278.Sh HISTORY
279These functions first appeared in OpenSSL 0.9.7
280and have been available since
281.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/UI_new.3 b/src/lib/libcrypto/man/UI_new.3
deleted file mode 100644
index e55477f31e..0000000000
--- a/src/lib/libcrypto/man/UI_new.3
+++ /dev/null
@@ -1,529 +0,0 @@
1.\" $OpenBSD: UI_new.3,v 1.13 2025/03/09 15:25:14 tb Exp $
2.\" full merge up to: OpenSSL 78b19e90 Jan 11 00:12:01 2017 +0100
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\"
5.\" This file was written by Richard Levitte <levitte@openssl.org>.
6.\" Copyright (c) 2001, 2016, 2017 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: March 9 2025 $
53.Dt UI_NEW 3
54.Os
55.Sh NAME
56.Nm UI_new ,
57.Nm UI_new_method ,
58.Nm UI_free ,
59.Nm UI_add_input_string ,
60.Nm UI_dup_input_string ,
61.Nm UI_add_verify_string ,
62.Nm UI_dup_verify_string ,
63.Nm UI_add_input_boolean ,
64.Nm UI_dup_input_boolean ,
65.Nm UI_add_info_string ,
66.Nm UI_dup_info_string ,
67.Nm UI_add_error_string ,
68.Nm UI_dup_error_string ,
69.Nm UI_construct_prompt ,
70.Nm UI_add_user_data ,
71.Nm UI_get0_user_data ,
72.Nm UI_get0_result ,
73.Nm UI_process ,
74.Nm UI_ctrl ,
75.Nm UI_set_default_method ,
76.Nm UI_get_default_method ,
77.Nm UI_get_method ,
78.Nm UI_set_method ,
79.Nm UI_OpenSSL ,
80.Nm UI_null
81.Nd New User Interface
82.Sh SYNOPSIS
83.In openssl/ui.h
84.Ft UI *
85.Fn UI_new void
86.Ft UI *
87.Fo UI_new_method
88.Fa "const UI_METHOD *method"
89.Fc
90.Ft void
91.Fo UI_free
92.Fa "UI *ui"
93.Fc
94.Ft int
95.Fo UI_add_input_string
96.Fa "UI *ui"
97.Fa "const char *prompt"
98.Fa "int flags"
99.Fa "char *result_buf"
100.Fa "int minsize"
101.Fa "int maxsize"
102.Fc
103.Ft int
104.Fo UI_dup_input_string
105.Fa "UI *ui"
106.Fa "const char *prompt"
107.Fa "int flags"
108.Fa "char *result_buf"
109.Fa "int minsize"
110.Fa "int maxsize"
111.Fc
112.Ft int
113.Fo UI_add_verify_string
114.Fa "UI *ui"
115.Fa "const char *prompt"
116.Fa "int flags"
117.Fa "char *result_buf"
118.Fa "int minsize"
119.Fa "int maxsize"
120.Fa "const char *test_buf"
121.Fc
122.Ft int
123.Fo UI_dup_verify_string
124.Fa "UI *ui"
125.Fa "const char *prompt"
126.Fa "int flags"
127.Fa "char *result_buf"
128.Fa "int minsize"
129.Fa "int maxsize"
130.Fa "const char *test_buf"
131.Fc
132.Ft int
133.Fo UI_add_input_boolean
134.Fa "UI *ui"
135.Fa "const char *prompt"
136.Fa "const char *action_desc"
137.Fa "const char *ok_chars"
138.Fa "const char *cancel_chars"
139.Fa "int flags"
140.Fa "char *result_buf"
141.Fc
142.Ft int
143.Fo UI_dup_input_boolean
144.Fa "UI *ui"
145.Fa "const char *prompt"
146.Fa "const char *action_desc"
147.Fa "const char *ok_chars"
148.Fa "const char *cancel_chars"
149.Fa "int flags"
150.Fa "char *result_buf"
151.Fc
152.Ft int
153.Fo UI_add_info_string
154.Fa "UI *ui"
155.Fa "const char *text"
156.Fc
157.Ft int
158.Fo UI_dup_info_string
159.Fa "UI *ui"
160.Fa "const char *text"
161.Fc
162.Ft int
163.Fo UI_add_error_string
164.Fa "UI *ui"
165.Fa "const char *text"
166.Fc
167.Ft int
168.Fo UI_dup_error_string
169.Fa "UI *ui"
170.Fa "const char *text"
171.Fc
172.Fd /* These are the possible flags. They can be OR'ed together. */
173.Fd #define UI_INPUT_FLAG_ECHO 0x01
174.Fd #define UI_INPUT_FLAG_DEFAULT_PWD 0x02
175.Ft char *
176.Fo UI_construct_prompt
177.Fa "UI *ui_method"
178.Fa "const char *object_desc"
179.Fa "const char *object_name"
180.Fc
181.Ft void *
182.Fo UI_add_user_data
183.Fa "UI *ui"
184.Fa "void *user_data"
185.Fc
186.Ft void *
187.Fo UI_get0_user_data
188.Fa "UI *ui"
189.Fc
190.Ft const char *
191.Fo UI_get0_result
192.Fa "UI *ui"
193.Fa "int i"
194.Fc
195.Ft int
196.Fo UI_process
197.Fa "UI *ui"
198.Fc
199.Ft int
200.Fo UI_ctrl
201.Fa "UI *ui"
202.Fa "int cmd"
203.Fa "long i"
204.Fa "void *p"
205.Fa "void (*f)()"
206.Fc
207.Fd #define UI_CTRL_PRINT_ERRORS 1
208.Fd #define UI_CTRL_IS_REDOABLE 2
209.Ft void
210.Fo UI_set_default_method
211.Fa "const UI_METHOD *meth"
212.Fc
213.Ft const UI_METHOD *
214.Fo UI_get_default_method
215.Fa void
216.Fc
217.Ft const UI_METHOD *
218.Fo UI_get_method
219.Fa "UI *ui"
220.Fc
221.Ft const UI_METHOD *
222.Fo UI_set_method
223.Fa "UI *ui"
224.Fa "const UI_METHOD *meth"
225.Fc
226.Ft const UI_METHOD *
227.Fo UI_OpenSSL
228.Fa void
229.Fc
230.Ft const UI_METHOD *
231.Fo UI_null
232.Fa void
233.Fc
234.Sh DESCRIPTION
235UI stands for User Interface, and is a general purpose set of routines
236to prompt the user for text-based information.
237Through user-written methods (see
238.Xr UI_create_method 3 ) ,
239prompting can be done in any way imaginable, be it plain text prompting,
240through dialog boxes or from a cell phone.
241.Pp
242All the functions work through a context of the type
243.Vt UI .
244This context contains all the information needed to prompt correctly
245as well as a reference to a
246.Vt UI_METHOD ,
247which is an ordered vector of functions that carry out the actual
248prompting.
249.Pp
250The first thing to do is to create a
251.Vt UI
252with
253.Fn UI_new
254or
255.Fn UI_new_method ,
256then add information to it with the
257.Fn UI_add_*
258or
259.Fn UI_dup_*
260functions.
261Also, user-defined random data can be passed down to the underlying
262method through calls to
263.Fn UI_add_user_data .
264The default UI method doesn't care about these data, but other methods
265might.
266Finally, use
267.Fn UI_process
268to actually perform the prompting and
269.Fn UI_get0_result
270to find the result to the prompt.
271.Pp
272A
273.Vt UI
274can contain more than one prompt, which are performed in the given
275sequence.
276Each prompt gets an index number which is returned by the
277.Fn UI_add_*
278and
279.Fn UI_dup_*
280functions, and has to be used to get the corresponding result with
281.Fn UI_get0_result .
282.Pp
283The functions are as follows:
284.Pp
285.Fn UI_new
286creates a new
287.Vt UI
288using the default UI method.
289When done with this UI, it should be freed using
290.Fn UI_free .
291.Pp
292.Fn UI_new_method
293creates a new
294.Vt UI
295using the given UI method.
296When done with this UI, it should be freed using
297.Fn UI_free .
298.Pp
299.Fn UI_OpenSSL
300returns the built-in UI method (note: not necessarily the default one,
301since the default can be changed.
302See further on).
303This method is the most machine/OS dependent part of OpenSSL and
304normally generates the most problems when porting.
305.Pp
306.Fn UI_null
307returns a UI method that does nothing.
308Its use is to avoid getting internal defaults for passed
309.Vt UI_METHOD
310pointers.
311.Pp
312.Fn UI_free
313removes
314.Fa ui
315from memory, along with all other pieces of memory that are connected
316to it, like duplicated input strings, results and others.
317If
318.Fa ui
319is a
320.Dv NULL
321pointer, no action occurs.
322.Pp
323.Fn UI_add_input_string
324and
325.Fn UI_add_verify_string
326add a prompt to
327.Fa ui ,
328as well as flags and a result buffer and the desired minimum and
329maximum sizes of the result, not counting the final NUL character.
330The given information is used to prompt for information, for example
331a password, and to verify a password (i.e. having the user enter
332it twice and check that the same string was entered twice).
333.Fn UI_add_verify_string
334takes an extra argument that should be a pointer to the result buffer
335of the input string that it's supposed to verify, or verification will
336fail.
337.Pp
338.Fn UI_add_input_boolean
339adds a prompt to
340.Fa ui
341that's supposed to be answered in a boolean way, with a single
342character for yes and a different character for no.
343A set of characters that can be used to cancel the prompt is given as
344well.
345The prompt itself is really divided in two, one part being the
346descriptive text (given through the
347.Fa prompt
348argument) and one describing the possible answers (given through the
349.Fa action_desc
350argument).
351.Pp
352.Fn UI_add_info_string
353and
354.Fn UI_add_error_string
355add strings that are shown at the same time as the prompt for extra
356information or to show an error string.
357The difference between the two is only conceptual.
358With the builtin method, there's no technical difference between them.
359Other methods may make a difference between them, however.
360.Pp
361The flags currently supported are
362.Dv UI_INPUT_FLAG_ECHO ,
363which is relevant for
364.Fn UI_add_input_string
365and will have the users response be echoed (when prompting for a
366password, this flag should obviously not be used), and
367.Dv UI_INPUT_FLAG_DEFAULT_PWD ,
368which means that a default password of some sort will be used
369(completely depending on the application and the UI method).
370.Pp
371.Fn UI_dup_input_string ,
372.Fn UI_dup_verify_string ,
373.Fn UI_dup_input_boolean ,
374.Fn UI_dup_info_string ,
375and
376.Fn UI_dup_error_string
377are basically the same as their
378.Fn UI_add_*
379counterparts, except that they make their own copies of all strings.
380.Pp
381.Fn UI_construct_prompt
382is a helper function that can be used to create a prompt from two pieces
383of information: a description and a name.
384The default constructor (if there is none provided by the method used)
385creates a string "Enter
386.Em description
387for
388.Em name Ns :".
389With the description "pass phrase" and the file name "foo.key", that
390becomes "Enter pass phrase for foo.key:". Other methods may create
391whatever string and may include encodings that will be processed by the
392other method functions.
393.Pp
394.Fn UI_add_user_data
395adds a user data pointer for the method to use at any time.
396The builtin UI method doesn't care about this info.
397Note that several calls to this function doesn't add data -
398the previous blob is replaced with the one given as argument.
399.Pp
400.Fn UI_get0_user_data
401retrieves the data that has last been given to the
402.Fa ui
403with
404.Fn UI_add_user_data .
405.Pp
406.Fn UI_get0_result
407returns a pointer to the result buffer associated with the information
408indexed by
409.Fa i .
410.Pp
411.Fn UI_process
412goes through the information given so far, does all the printing and
413prompting and returns the final status, which is -2 on out-of-band
414events (Interrupt, Cancel, ...), -1 on error, or 0 on success.
415.Pp
416.Fn UI_ctrl
417adds extra control for the application author.
418For now, it understands two commands:
419.Dv UI_CTRL_PRINT_ERRORS ,
420which makes
421.Fn UI_process
422print the OpenSSL error stack as part of processing the
423.Fa ui ,
424and
425.Dv UI_CTRL_IS_REDOABLE ,
426which returns a flag saying if the used
427.Fa ui
428can be used again or not.
429.Pp
430.Fn UI_set_default_method
431changes the default UI method to the one given.
432This function is not thread-safe and should not be called at the
433same time as other OpenSSL functions.
434.Pp
435.Fn UI_get_default_method
436returns a pointer to the current default UI method.
437.Pp
438.Fn UI_get_method
439returns the UI method associated with a given
440.Fa ui .
441.Pp
442.Fn UI_set_method
443changes the UI method associated with a given
444.Fa ui .
445.Sh RETURN VALUES
446.Fn UI_new
447and
448.Fn UI_new_method
449return a valid
450.Vt UI
451structure or
452.Dv NULL
453if an error occurred.
454.Pp
455.Fn UI_add_input_string ,
456.Fn UI_dup_input_string ,
457.Fn UI_add_verify_string ,
458.Fn UI_dup_verify_string ,
459.Fn UI_add_input_boolean ,
460.Fn UI_dup_input_boolean ,
461.Fn UI_add_info_string ,
462.Fn UI_dup_info_string ,
463.Fn UI_add_error_string ,
464and
465.Fn UI_dup_error_string
466return a positive number on success or a number
467less than or equal to zero otherwise.
468.Pp
469.Fn UI_construct_prompt
470and
471.Fn UI_get0_result
472return a string or
473.Dv NULL
474if an error occurred.
475.Pp
476.Fn UI_add_user_data
477and
478.Fn UI_get0_user_data
479return a pointer to the user data that was contained in
480.Fa ui
481before the call.
482In particular,
483.Dv NULL
484is a valid return value.
485.Pp
486.Fn UI_process
487returns 0 on success or a negative value on error.
488.Pp
489.Fn UI_ctrl
490returns a mask on success or \-1 on error.
491.Pp
492.Fn UI_get_default_method ,
493.Fn UI_OpenSSL
494and
495.Fn UI_null
496always return a pointer to a valid
497.Vt UI_METHOD
498structure.
499.Pp
500.Fn UI_get_method
501and
502.Fn UI_set_method
503return a pointer to the
504.Vt UI_METHOD
505structure that is installed in
506.Fa ui
507after the call.
508The OpenSSL documentation says that they can fail and return
509.Dv NULL ,
510but currently, this can only happen when and after
511.Fn UI_set_method
512is called with an explicit
513.Dv NULL
514argument.
515.Sh SEE ALSO
516.Xr crypto 3 ,
517.Xr UI_create_method 3 ,
518.Xr UI_get_string_type 3
519.Sh HISTORY
520These functions first appeared in OpenSSL 0.9.7
521and have been available since
522.Ox 3.2 .
523.Pp
524.Fn UI_null
525first appeared in OpenSSL 1.1.1 and has been available since
526.Ox 7.3 .
527.Sh AUTHORS
528.An Richard Levitte Aq Mt richard@levitte.org
529for the OpenSSL project.
diff --git a/src/lib/libcrypto/man/X25519.3 b/src/lib/libcrypto/man/X25519.3
deleted file mode 100644
index a327f8c7b2..0000000000
--- a/src/lib/libcrypto/man/X25519.3
+++ /dev/null
@@ -1,211 +0,0 @@
1.\" $OpenBSD: X25519.3,v 1.7 2022/12/15 17:20:48 schwarze Exp $
2.\" contains some text from: BoringSSL curve25519.h, curve25519.c
3.\" content also checked up to: OpenSSL f929439f Mar 15 12:19:16 2018 +0000
4.\"
5.\" Copyright (c) 2015 Google Inc.
6.\" Copyright (c) 2018, 2022 Ingo Schwarze <schwarze@openbsd.org>
7.\"
8.\" Permission to use, copy, modify, and/or distribute this software for any
9.\" purpose with or without fee is hereby granted, provided that the above
10.\" copyright notice and this permission notice appear in all copies.
11.\"
12.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
13.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
15.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\"
20.\" According to the BoringSSL git history, those parts of the text in
21.\" the present manual page that are Copyrighted by Google were probably
22.\" written by Adam Langley <agl@google.com> in 2015.
23.\" I fail to see any such text in the public domain files written
24.\" by Daniel J. Bernstein and others that are included in SUPERCOP
25.\" and that Adam Langley's BoringSSL implementation is based on.
26.\"
27.Dd $Mdocdate: December 15 2022 $
28.Dt X25519 3
29.Os
30.Sh NAME
31.Nm X25519 ,
32.Nm X25519_keypair ,
33.Nm ED25519_keypair ,
34.Nm ED25519_sign ,
35.Nm ED25519_verify
36.Nd Elliptic Curve Diffie-Hellman and signature primitives based on Curve25519
37.Sh SYNOPSIS
38.In openssl/curve25519.h
39.Ft int
40.Fo X25519
41.Fa "uint8_t out_shared_key[X25519_KEY_LENGTH]"
42.Fa "const uint8_t private_key[X25519_KEY_LENGTH]"
43.Fa "const uint8_t peer_public_value[X25519_KEY_LENGTH]"
44.Fc
45.Ft void
46.Fo X25519_keypair
47.Fa "uint8_t out_public_value[X25519_KEY_LENGTH]"
48.Fa "uint8_t out_private_key[X25519_KEY_LENGTH]"
49.Fc
50.Ft void
51.Fo ED25519_keypair
52.Fa "uint8_t out_public_key[ED25519_PUBLIC_KEY_LENGTH]"
53.Fa "uint8_t out_private_key[ED25519_PRIVATE_KEY_LENGTH]"
54.Fc
55.Ft int
56.Fo ED25519_sign
57.Fa "uint8_t *out_sig"
58.Fa "const uint8_t *message"
59.Fa "size_t message_len"
60.Fa "const uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH]"
61.Fa "const uint8_t private_key_seed[ED25519_PRIVATE_KEY_LENGTH]"
62.Fc
63.Ft int
64.Fo ED25519_verify
65.Fa "const uint8_t *message"
66.Fa "size_t message_len"
67.Fa "const uint8_t signature[ED25519_SIGNATURE_LENGTH]"
68.Fa "const uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH]"
69.Fc
70.Sh DESCRIPTION
71Curve25519 is an elliptic curve over a prime field
72specified in RFC 7748 section 4.1.
73The prime field is defined by the prime number 2^255 - 19.
74.Pp
75X25519
76is the Diffie-Hellman primitive built from Curve25519 as described
77in RFC 7748 section 5.
78Section 6.1 describes the intended use in an Elliptic Curve Diffie-Hellman
79(ECDH) protocol.
80.Pp
81.Fn X25519
82writes a shared key to
83.Fa out_shared_key
84that is calculated from the given
85.Fa private_key
86and the
87.Fa peer_public_value
88by scalar multiplication.
89Do not use the shared key directly, rather use a key derivation
90function and also include the two public values as inputs.
91.Pp
92.Fn X25519_keypair
93sets
94.Fa out_public_value
95and
96.Fa out_private_key
97to a freshly generated public/private key pair.
98First, the
99.Fa out_private_key
100is generated with
101.Xr arc4random_buf 3 .
102Then, the opposite of the masking described in RFC 7748 section 5
103is applied to it to make sure that the generated private key is never
104correctly masked.
105The purpose is to cause incorrect implementations on the peer side
106to consistently fail.
107Correct implementations will decode the key correctly even when it is
108not correctly masked.
109Finally, the
110.Fa out_public_value
111is calculated from the
112.Fa out_private_key
113by multiplying it with the Montgomery base point
114.Vt uint8_t u[32] No = Brq 9 .
115.Pp
116The size of a public and private key is
117.Dv X25519_KEY_LENGTH No = 32
118bytes each.
119.Pp
120Ed25519 is a signature scheme using a twisted Edwards curve
121that is birationally equivalent to Curve25519.
122.Pp
123.Fn ED25519_keypair
124sets
125.Fa out_public_key
126and
127.Fa out_private_key
128to a freshly generated public/private key pair.
129First, the
130.Fa out_private_key
131is generated with
132.Xr arc4random_buf 3 .
133Then, the
134.Fa out_public_key
135is calculated from the private key.
136.Pp
137.Fn ED25519_sign
138signs the
139.Fa message
140of
141.Fa message_len
142bytes using the
143.Fa public_key
144and the
145.Fa private_key
146and writes the signature to
147.Fa out_sig .
148.Pp
149.Fn ED25519_verify
150checks that signing the
151.Fa message
152of
153.Fa message_len
154bytes using the
155.Fa public_key
156would indeed result in the given
157.Fa signature .
158.Pp
159The sizes of a public and private keys are
160.Dv ED25519_PUBLIC_KEY_LENGTH
161and
162.Dv ED25519_PRIVATE_KEY_LENGTH ,
163which are both 32 bytes, and the size of a signature is
164.Dv ED25519_SIGNATURE_LENGTH No = 64
165bytes.
166.Sh RETURN VALUES
167.Fn X25519
168and
169.Fn ED25519_sign
170return 1 on success or 0 on error.
171.Fn X25519
172can fail if the input is a point of small order.
173.Fn ED25519_sign
174always succeeds in LibreSSL, but the API reserves the return value 0
175for memory allocation failure.
176.Pp
177.Fn ED25519_verify
178returns 1 if the
179.Fa signature
180is valid or 0 otherwise.
181.Sh SEE ALSO
182.Xr ECDH_compute_key 3 ,
183.Xr EVP_DigestSign 3 ,
184.Xr EVP_DigestVerify 3 ,
185.Xr EVP_PKEY_derive 3 ,
186.Xr EVP_PKEY_keygen 3
187.Rs
188.%A Daniel J. Bernstein
189.%R A state-of-the-art Diffie-Hellman function:\
190 How do I use Curve25519 in my own software?
191.%U https://cr.yp.to/ecdh.html
192.Re
193.Rs
194.%A Daniel J. Bernstein
195.%A Niels Duif
196.%A Tanja Lange
197.%A Peter Schwabe
198.%A Bo-Yin Yang
199.%T High-Speed High-Security Signatures
200.%B Cryptographic Hardware and Embedded Systems \(em CHES 2011
201.%I Springer
202.%J Lecture Notes in Computer Science
203.%V vol 6917
204.%U https://doi.org/10.1007/978-3-642-23951-9_9
205.%C Nara, Japan
206.%D September 29, 2011
207.Re
208.Sh STANDARDS
209RFC 7748: Elliptic Curves for Security
210.Pp
211RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA)
diff --git a/src/lib/libcrypto/man/X509V3_EXT_get_nid.3 b/src/lib/libcrypto/man/X509V3_EXT_get_nid.3
deleted file mode 100644
index ad153c36d0..0000000000
--- a/src/lib/libcrypto/man/X509V3_EXT_get_nid.3
+++ /dev/null
@@ -1,94 +0,0 @@
1.\" $OpenBSD: X509V3_EXT_get_nid.3,v 1.8 2024/12/24 09:48:56 schwarze Exp $
2.\"
3.\" Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 24 2024 $
18.Dt X509V3_EXT_GET_NID 3
19.Os
20.Sh NAME
21.Nm X509V3_EXT_get_nid ,
22.Nm X509V3_EXT_get
23.Nd retrieve X.509v3 certificate extension methods
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft const X509V3_EXT_METHOD *
27.Fo X509V3_EXT_get_nid
28.Fa "int nid"
29.Fc
30.Ft const X509V3_EXT_METHOD *
31.Fo X509V3_EXT_get
32.Fa "X509_EXTENSION *ext"
33.Fc
34.Sh DESCRIPTION
35An X.509v3 certificate extension contains an Object Identifier (OID),
36a boolean criticality indicator, and an opaque extension value
37.Po
38an
39.Vt ASN1_OCTET_STRING
40.Pc
41whose meaning is determined by the OID.
42The library's
43.Vt X509V3_EXT_METHOD
44type,
45which is not yet documented in detail,
46contains a numeric identifier (NID) to represent the OID and various
47handlers for encoding, decoding, printing, and configuring the
48extension's value.
49Criticality is handled separately, for example as an argument to
50.Xr X509V3_add1_i2d 3 .
51.Sh RETURN VALUES
52.Fn X509V3_EXT_get_nid
53returns the
54.Vt X509V3_EXT_METHOD
55corresponding to the numeric identifier
56.Fa nid ,
57or
58.Dv NULL
59if there is none.
60.Pp
61.Fn X509V3_EXT_get
62returns the
63.Vt X509V3_EXT_METHOD
64associated with the extension type of
65.Fa ext ,
66or
67.Dv NULL
68if there is none.
69.Sh SEE ALSO
70.Xr i2s_ASN1_ENUMERATED_TABLE 3 ,
71.Xr OBJ_create 3 ,
72.Xr v2i_ASN1_BIT_STRING 3 ,
73.Xr X509_EXTENSION_get_object 3 ,
74.Xr X509V3_get_d2i 3
75.Sh STANDARDS
76RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
77Certificate Revocation List (CRL) Profile
78.Bl -dash -compact
79.It
80section 4.2: Certificate Extensions
81.El
82.Sh HISTORY
83These functions first appeared in OpenSSL 0.9.2b and
84have been available since
85.Ox 2.6 .
86.Sh CAVEATS
87In LibreSSL, these functions only support built-in
88.Fa nid
89values corresponding to static built-in objects.
90Other implementations have incomplete support for custom extension methods,
91whose API is not threadsafe, does not affect the behavior of
92.Xr X509_verify_cert 3 ,
93and has various other surprising quirks.
94Both functions prefer built-in methods over custom methods with the same OID.
diff --git a/src/lib/libcrypto/man/X509V3_EXT_print.3 b/src/lib/libcrypto/man/X509V3_EXT_print.3
deleted file mode 100644
index edb97d3a36..0000000000
--- a/src/lib/libcrypto/man/X509V3_EXT_print.3
+++ /dev/null
@@ -1,195 +0,0 @@
1.\" $OpenBSD: X509V3_EXT_print.3,v 1.3 2024/12/28 10:19:45 schwarze Exp $
2.\"
3.\" Copyright (c) 2021, 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 28 2024 $
18.Dt X509V3_EXT_PRINT 3
19.Os
20.Sh NAME
21.Nm X509V3_EXT_print ,
22.Nm X509V3_EXT_print_fp
23.Nd pretty-print an X.509 extension
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft int
27.Fo X509V3_EXT_print
28.Fa "BIO *bio"
29.Fa "X509_EXTENSION *ext"
30.Fa "unsigned long flags"
31.Fa "int indent"
32.Fc
33.Ft int
34.Fo X509V3_EXT_print_fp
35.Fa "FILE *file"
36.Fa "X509_EXTENSION *ext"
37.Fa "int flags"
38.Fa "int indent"
39.Fc
40.Sh DESCRIPTION
41.Fn X509V3_EXT_print
42and
43.Fn X509V3_EXT_print_fp
44decode
45.Fa ext
46and print the data contained in it to the
47.Fa bio
48or
49.Fa file ,
50respectively, in a human-readable format with a left margin of
51.Fa indent
52space characters.
53The details of both the decoding and the printing depend on the type of
54.Fa ext .
55.Pp
56For most extension types, the decoding is done in the same way
57as it would be done by the appropriate public API function, for example:
58.Pp
59.Bl -tag -width NID_authority_key_identifier -compact
60.It Sy extension type
61.Sy decoding function
62.It Dv NID_authority_key_identifier
63.Xr d2i_AUTHORITY_KEYID 3
64.It Dv NID_certificate_policies
65.Xr d2i_CERTIFICATEPOLICIES 3
66.It Dv NID_crl_number
67.Xr d2i_ASN1_INTEGER 3
68.It Dv NID_crl_reason
69.Xr d2i_ASN1_ENUMERATED 3
70.It Dv NID_hold_instruction_code
71.Xr d2i_ASN1_OBJECT 3
72.It Dv NID_id_pkix_OCSP_CrlID
73.Xr d2i_OCSP_CRLID 3
74.It Dv NID_id_pkix_OCSP_noCheck
75.Xr d2i_ASN1_NULL 3
76.It Dv NID_id_pkix_OCSP_Nonce
77non-public function built into the library
78.It Dv NID_invalidity_date
79.Xr d2i_ASN1_GENERALIZEDTIME 3
80.It Dv NID_key_usage
81.Xr d2i_ASN1_BIT_STRING 3
82.It Dv NID_subject_alt_name
83.Xr d2i_GENERAL_NAMES 3
84.It Dv NID_subject_key_identifier
85.Xr d2i_ASN1_OCTET_STRING 3
86.El
87.Pp
88For some types, the printing is performed
89by a dedicated non-public function built into the library.
90For some other types, the printing function is a public API function,
91for example:
92.Pp
93.Bl -tag -width NID_id_pkix_OCSP_archiveCutoff -compact
94.It Sy extension type
95.Sy printing function
96.It Dv NID_crl_number
97.Xr i2s_ASN1_INTEGER 3
98.It Dv NID_crl_reason
99.Xr i2s_ASN1_ENUMERATED_TABLE 3
100.It Dv NID_delta_crl
101.Xr i2s_ASN1_INTEGER 3
102.It Dv NID_hold_instruction_code
103.Xr i2a_ASN1_OBJECT 3
104.It Dv NID_id_pkix_OCSP_archiveCutoff
105.Xr ASN1_GENERALIZEDTIME_print 3
106.It Dv NID_id_pkix_OCSP_Nonce
107.Xr i2a_ASN1_STRING 3
108.It Dv NID_inhibit_any_policy
109.Xr i2s_ASN1_INTEGER 3
110.It Dv NID_invalidity_date
111.Xr ASN1_GENERALIZEDTIME_print 3
112.It Dv NID_key_usage
113.Xr i2v_ASN1_BIT_STRING 3
114.It Dv NID_subject_key_identifier
115.Xr i2s_ASN1_OCTET_STRING 3
116.El
117.Pp
118Some of the public printing functions are not documented yet.
119.Pp
120If
121.Fa ext
122is of an unknown extension type or if decoding fails
123while using the decoding function for the relevant type,
124the action taken depends on the
125.Fa flags
126argument:
127.Bl -bullet
128.It
129If the bit
130.Dv X509V3_EXT_PARSE_UNKNOWN
131is set,
132.Xr ASN1_parse_dump 3
133is called on the BER-encoded data of the extension, passing \-1 for the
134.Fa dump
135argument.
136Thus, some information about the encoding of the extension gets printed
137and some about its decoded content, falling back to
138.Xr BIO_dump_indent 3
139for the decoded content unless a dedicated printing method is known
140for the respective data type(s).
141Note that even if an extension type is unknown, the data type used
142by the unknown extension, or, if that data type is constructed, of
143the values contained in it, may still be known, which may allow
144printing the content of even an unknown extension in a structured
145or partially structured form.
146.It
147If the bit
148.Dv X509V3_EXT_DUMP_UNKNOWN
149is set,
150.Xr BIO_dump_indent 3
151is called on the BER-encoded data of the extension without decoding
152it first, which is usually less readable than the above but poses
153a smaller risk of omitting or misrepresenting parts of the information.
154.It
155If the bit
156.Dv X509V3_EXT_ERROR_UNKNOWN
157is set, only the fixed string
158.Qq "<Not Supported>"
159is printed for an unknown type or only the fixed string
160.Qq "<Parse Error>"
161if the parsing functions fails,
162but printing is considered as successful anyway.
163.It
164If more than one of these three bits is set, or if a bit in
165.Dv X509V3_EXT_UNKNOWN_MASK
166is set that is not listed above, nothing is printed, but printing
167is considered as successful anyway.
168.It
169If none of the bits in
170.Dv X509V3_EXT_UNKNOWN_MASK
171are set, nothing is printed and printing is considered as failed.
172.El
173.Sh RETURN VALUES
174.Fn X509V3_EXT_print
175and
176.Fn X509V3_EXT_print_fp
177return 0 if failure was both detected and considered relevant.
178Otherwise, 1 is returned, and in general the user cannot tell whether
179failure simply went undetected, whether the function detected failure
180but regarded it as irrelevant, or whether printing did indeed
181succeed.
182.Sh SEE ALSO
183.Xr BIO_new 3 ,
184.Xr X509_EXTENSION_new 3 ,
185.Xr X509_get0_extensions 3 ,
186.Xr X509_get_ext 3 ,
187.Xr X509V3_extensions_print 3
188.Sh HISTORY
189These functions first appeared in OpenSSL 0.9.2 and have been available since
190.Ox 2.6 .
191.Sh BUGS
192These functions lack error handling throughout.
193When a write operation fails, they will usually ignore the fact that
194information was omitted from the output and report success to the
195caller anyway.
diff --git a/src/lib/libcrypto/man/X509V3_extensions_print.3 b/src/lib/libcrypto/man/X509V3_extensions_print.3
deleted file mode 100644
index 8c43fe9b01..0000000000
--- a/src/lib/libcrypto/man/X509V3_extensions_print.3
+++ /dev/null
@@ -1,100 +0,0 @@
1.\" $OpenBSD: X509V3_extensions_print.3,v 1.2 2021/11/26 13:48:21 jsg Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 26 2021 $
18.Dt X509V3_EXTENSIONS_PRINT 3
19.Os
20.Sh NAME
21.Nm X509V3_extensions_print
22.Nd pretty-print an array of X.509 extensions
23.Sh SYNOPSIS
24.In openssl/x509v3.h
25.Ft int
26.Fo X509V3_extensions_print
27.Fa "BIO *bio"
28.Fa "char *title"
29.Fa "const STACK_OF(X509_EXTENSION) *sk"
30.Fa "unsigned long flags"
31.Fa "int indent"
32.Fc
33.Sh DESCRIPTION
34For each member of the variable sized array
35.Fa sk ,
36.Fn X509V3_extensions_print
37prints the following information to
38.Fa bio
39in the following order:
40.Bl -bullet
41.It
42The extension type as printed by
43.Xr i2a_ASN1_OBJECT 3 .
44.It
45If the extension is critical, the fixed string
46.Qq "critical" .
47.It
48A human-readable representation of the data contained in the extension
49as printed by
50.Xr X509V3_EXT_print 3 ,
51passing through the
52.Fa flags .
53If that function indicates failure,
54the BER-encoded data of the extension is dumped with
55.Xr ASN1_STRING_print 3
56without decoding it first.
57In both cases, an
58.Fa indent
59incremented by 4 space characters is used.
60.El
61.Pp
62If
63.Fa sk
64is a
65.Dv NULL
66pointer or empty,
67.Fn X509V3_extensions_print
68prints nothing and indicates success.
69.Pp
70Unless
71.Fa title
72is
73.Dv NULL ,
74it is printed on its own output line before the rest of the output, and
75.Fa indent
76is increased by 4 space characters.
77This additional global indentation is cumulative
78to the one applied to individual extensions mentioned above.
79.Sh RETURN VALUES
80.Fn X509V3_extensions_print
81is intended to return 1 on success or 0 if an error occurs.
82.Sh SEE ALSO
83.Xr BIO_new 3 ,
84.Xr STACK_OF 3 ,
85.Xr X509_EXTENSION_get_critical 3 ,
86.Xr X509_get0_extensions 3 ,
87.Xr X509_get_ext 3 ,
88.Xr X509V3_EXT_print 3
89.Sh HISTORY
90.Fn X509V3_extensions_print
91first appeared in OpenSSL 0.9.7 and has been available since
92.Ox 3.2 .
93.Sh BUGS
94Many parsing and printing errors are silently ignored,
95and the function may return indicating success even though
96.Fa sk
97contains invalid data.
98Even if all the data is valid, success may be indicated even when the
99information printed is incomplete for various reasons, for example
100due to memory allocation failures or I/O errors.
diff --git a/src/lib/libcrypto/man/X509V3_get_d2i.3 b/src/lib/libcrypto/man/X509V3_get_d2i.3
deleted file mode 100644
index bf442dc846..0000000000
--- a/src/lib/libcrypto/man/X509V3_get_d2i.3
+++ /dev/null
@@ -1,507 +0,0 @@
1.\" $OpenBSD: X509V3_get_d2i.3,v 1.25 2024/12/31 20:17:00 tb Exp $
2.\" full merge up to: OpenSSL ff7fbfd5 Nov 2 11:52:01 2015 +0000
3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2023, 2024 Theo Buehler <tb@openbsd.org>
9.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
10.\"
11.\" Permission to use, copy, modify, and distribute this software for any
12.\" purpose with or without fee is hereby granted, provided that the above
13.\" copyright notice and this permission notice appear in all copies.
14.\"
15.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22.\"
23.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
24.\" Copyright (c) 2014, 2015, 2016 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: December 31 2024 $
71.Dt X509V3_GET_D2I 3
72.Os
73.Sh NAME
74.Nm X509V3_get_d2i ,
75.Nm X509V3_add1_i2d ,
76.Nm X509V3_EXT_d2i ,
77.Nm X509V3_EXT_i2d ,
78.Nm X509_get_ext_d2i ,
79.Nm X509_add1_ext_i2d ,
80.Nm X509_CRL_get_ext_d2i ,
81.Nm X509_CRL_add1_ext_i2d ,
82.Nm X509_REVOKED_get_ext_d2i ,
83.Nm X509_REVOKED_add1_ext_i2d ,
84.Nm X509_get0_extensions ,
85.Nm X509_CRL_get0_extensions ,
86.Nm X509_REVOKED_get0_extensions ,
87.Nm X509_get0_uids
88.Nd X509 extension decode and encode functions
89.Sh SYNOPSIS
90.In openssl/x509v3.h
91.Ft void *
92.Fo X509V3_get_d2i
93.Fa "const STACK_OF(X509_EXTENSION) *x"
94.Fa "int nid"
95.Fa "int *crit"
96.Fa "int *idx"
97.Fc
98.Ft int
99.Fo X509V3_add1_i2d
100.Fa "STACK_OF(X509_EXTENSION) **x"
101.Fa "int nid"
102.Fa "void *value"
103.Fa "int crit"
104.Fa "unsigned long flags"
105.Fc
106.Ft void *
107.Fo X509V3_EXT_d2i
108.Fa "X509_EXTENSION *ext"
109.Fc
110.Ft X509_EXTENSION *
111.Fo X509V3_EXT_i2d
112.Fa "int ext_nid"
113.Fa "int crit"
114.Fa "void *ext"
115.Fc
116.Ft void *
117.Fo X509_get_ext_d2i
118.Fa "const X509 *x"
119.Fa "int nid"
120.Fa "int *crit"
121.Fa "int *idx"
122.Fc
123.Ft int
124.Fo X509_add1_ext_i2d
125.Fa "X509 *x"
126.Fa "int nid"
127.Fa "void *value"
128.Fa "int crit"
129.Fa "unsigned long flags"
130.Fc
131.Ft void *
132.Fo X509_CRL_get_ext_d2i
133.Fa "const X509_CRL *crl"
134.Fa "int nid"
135.Fa "int *crit"
136.Fa "int *idx"
137.Fc
138.Ft int
139.Fo X509_CRL_add1_ext_i2d
140.Fa "X509_CRL *crl"
141.Fa "int nid"
142.Fa "void *value"
143.Fa "int crit"
144.Fa "unsigned long flags"
145.Fc
146.Ft void *
147.Fo X509_REVOKED_get_ext_d2i
148.Fa "const X509_REVOKED *r"
149.Fa "int nid"
150.Fa "int *crit"
151.Fa "int *idx"
152.Fc
153.Ft int
154.Fo X509_REVOKED_add1_ext_i2d
155.Fa "X509_REVOKED *r"
156.Fa "int nid"
157.Fa "void *value"
158.Fa "int crit"
159.Fa "unsigned long flags"
160.Fc
161.Ft const STACK_OF(X509_EXTENSION) *
162.Fo X509_get0_extensions
163.Fa "const X509 *x"
164.Fc
165.Ft const STACK_OF(X509_EXTENSION) *
166.Fo X509_CRL_get0_extensions
167.Fa "const X509_CRL *crl"
168.Fc
169.Ft const STACK_OF(X509_EXTENSION) *
170.Fo X509_REVOKED_get0_extensions
171.Fa "const X509_REVOKED *r"
172.Fc
173.Ft void
174.Fo X509_get0_uids
175.Fa "const X509 *x"
176.Fa "const ASN1_BIT_STRING **issuerUID"
177.Fa "const ASN1_BIT_STRING **subjectUID"
178.Fc
179.Sh DESCRIPTION
180.Fn X509V3_get_d2i
181looks for an extension with OID
182.Fa nid
183in the extensions
184.Fa x
185and, if found, decodes it.
186If
187.Fa idx
188is
189.Dv NULL ,
190then only one occurrence of an extension is permissible.
191Otherwise the first extension after index
192.Pf * Fa idx
193is returned and
194.Pf * Fa idx
195is updated to the location of the extension.
196If
197.Fa crit
198is not
199.Dv NULL ,
200then
201.Pf * Fa crit
202is set to a status value: -2 if the extension occurs multiple times
203(this is only returned if
204.Fa idx
205is
206.Dv NULL ) ,
207-1 if the extension could not be found, 0 if the extension is found
208and is not critical, and 1 if it is critical.
209A pointer to an extension specific structure or
210.Dv NULL
211is returned.
212.Pp
213.Fn X509V3_add1_i2d
214adds extension
215.Fa value
216to STACK
217.Pf * Fa x
218(allocating a new STACK if necessary) using OID
219.Fa nid
220and criticality
221.Fa crit
222according to
223.Fa flags .
224.Pp
225.Fn X509V3_EXT_d2i
226attempts to decode the ASN.1 data contained in extension
227.Fa ext
228and returns a pointer to an extension specific structure or
229.Dv NULL
230if the extension could not be decoded (invalid syntax or not supported).
231.Pp
232.Fn X509V3_EXT_i2d
233encodes the extension specific structure
234.Fa ext
235with OID
236.Fa ext_nid
237and criticality
238.Fa crit .
239.Pp
240.Fn X509_get_ext_d2i
241and
242.Fn X509_add1_ext_i2d
243operate on the extensions of certificate
244.Fa x ,
245and are otherwise identical to
246.Fn X509V3_get_d2i
247and
248.Fn X509V3_add1_i2d .
249.Pp
250.Fn X509_CRL_get_ext_d2i
251and
252.Fn X509_CRL_add1_ext_i2d
253operate on the extensions of CRL
254.Fa crl ,
255and are otherwise identical to
256.Fn X509V3_get_d2i
257and
258.Fn X509V3_add1_i2d .
259.Pp
260.Fn X509_REVOKED_get_ext_d2i
261and
262.Fn X509_REVOKED_add1_ext_i2d
263operate on the extensions of the
264.Vt X509_REVOKED
265structure
266.Fa r
267(i.e. for CRL entry extensions), and are otherwise identical to
268.Fn X509V3_get_d2i
269and
270.Fn X509V3_add1_i2d .
271.Pp
272.Fn X509_get0_extensions ,
273.Fn X509_CRL_get0_extensions ,
274and
275.Fn X509_REVOKED_get0_extensions
276return a stack of all the extensions of a certificate, a CRL,
277or a CRL entry, respectively.
278.Pp
279In almost all cases an extension can occur at most once and multiple
280occurrences is an error.
281Therefore the
282.Fa idx
283parameter is usually
284.Dv NULL .
285.Pp
286The
287.Fa flags
288argument consists of two parts OR'ed together:
289the operation mode and the optional silent flag.
290The operation mode is the bitwise OR of the
291.Fa flags
292and the bitmask
293.Dv X509V3_ADD_OP_MASK .
294The following operation modes are recognized:
295.Pp
296.Dv X509V3_ADD_DEFAULT
297appends a new extension only if the extension does not already exist.
298An error is returned if the extension does already exist.
299.Pp
300.Dv X509V3_ADD_APPEND
301appends a new extension, ignoring whether the extension already exists.
302This is a misfeature and should not be used because certificates must
303not include the same extension more than once.
304.Pp
305.Dv X509V3_ADD_REPLACE
306replaces an extension if it exists otherwise appends a new extension.
307.Pp
308.Dv X509V3_ADD_REPLACE_EXISTING
309replaces an existing extension if it exists otherwise returns an error.
310.Pp
311.Dv X509V3_ADD_KEEP_EXISTING
312appends a new extension only if the extension does not already exist.
313An error
314.Sy is not
315returned if the extension does already exist.
316.Pp
317.Dv X509V3_ADD_DELETE
318deletes extension
319.Fa nid
320if it exists and errors otherwise.
321No new extension is added.
322.Pp
323Any other operation mode results in an error.
324.Pp
325If
326.Dv X509V3_ADD_SILENT
327is OR'd into the
328.Fa flags ,
329any error returned will not be added to the error queue.
330.Pp
331The function
332.Fn X509V3_get_d2i
333will return
334.Dv NULL
335if the extension is not found, occurs multiple times or cannot be
336decoded.
337It is possible to determine the precise reason by checking the value of
338.Pf * Fa crit .
339.Pp
340.Fn X509_get0_uids
341returns the issuer and subject unique identifiers of the certificate
342.Fa x
343in
344.Pf * Fa issuerUID
345and
346.Pf * Fa subjectUID .
347If a unique identifier field is not present in
348.Fa x ,
349.Dv NULL
350is returned.
351Either one of
352.Fa issuerUID
353and
354.Fa subjectUID
355can be
356.Dv NULL .
357.Sh SUPPORTED EXTENSIONS
358The following sections contain a list of all supported extensions
359including their name and NID.
360.Ss PKIX Certificate Extensions
361The following certificate extensions are defined in PKIX standards such
362as RFC 5280.
363.Bl -column 30n 30n
364.It Basic Constraints Ta Dv NID_basic_constraints
365.It Key Usage Ta Dv NID_key_usage
366.It Extended Key Usage Ta Dv NID_ext_key_usage
367.It Subject Key Identifier Ta Dv NID_subject_key_identifier
368.It Authority Key Identifier Ta Dv NID_authority_key_identifier
369.It Private Key Usage Period Ta Dv NID_private_key_usage_period
370.It Subject Alternative Name Ta Dv NID_subject_alt_name
371.It Issuer Alternative Name Ta Dv NID_issuer_alt_name
372.It Authority Information Access Ta Dv NID_info_access
373.It Subject Information Access Ta Dv NID_sinfo_access
374.It Name Constraints Ta Dv NID_name_constraints
375.It Certificate Policies Ta Dv NID_certificate_policies
376.It Policy Mappings Ta Dv NID_policy_mappings
377.It Policy Constraints Ta Dv NID_policy_constraints
378.It Inhibit Any Policy Ta Dv NID_inhibit_any_policy
379.It IP Address Delegation Ta Dv NID_sbgp_ipAddrBlock
380.It Autonomous System Identifier Delegation\
381 Ta Dv NID_sbgp_autonomousSysNum
382.El
383.Ss Netscape Certificate Extensions
384The following are (largely obsolete) Netscape certificate extensions.
385.Bl -column 30n 30n
386.It Netscape Cert Type Ta Dv NID_netscape_cert_type
387.It Netscape Base Url Ta Dv NID_netscape_base_url
388.It Netscape Revocation Url Ta Dv NID_netscape_revocation_url
389.It Netscape CA Revocation Url Ta Dv NID_netscape_ca_revocation_url
390.It Netscape Renewal Url Ta Dv NID_netscape_renewal_url
391.It Netscape CA Policy Url Ta Dv NID_netscape_ca_policy_url
392.It Netscape SSL Server Name Ta Dv NID_netscape_ssl_server_name
393.It Netscape Comment Ta Dv NID_netscape_comment
394.El
395.Ss PKIX CRL Extensions
396The following are CRL extensions from PKIX standards such as RFC 5280.
397.Bl -column 30n 30n
398.It CRL Number Ta Dv NID_crl_number
399.It CRL Distribution Points Ta Dv NID_crl_distribution_points
400.It Delta CRL Indicator Ta Dv NID_delta_crl
401.It Freshest CRL Ta Dv NID_freshest_crl
402.It Invalidity Date Ta Dv NID_invalidity_date
403.It Issuing Distribution Point Ta Dv NID_issuing_distribution_point
404.El
405.Pp
406The following are CRL entry extensions from PKIX standards such as
407RFC 5280.
408.Bl -column 30n 30n
409.It CRL Reason Code Ta Dv NID_crl_reason
410.It Certificate Issuer Ta Dv NID_certificate_issuer
411.El
412.Ss OCSP Extensions
413.Bl -column 30n 30n
414.It OCSP Nonce Ta Dv NID_id_pkix_OCSP_Nonce
415.It OCSP CRL ID Ta Dv NID_id_pkix_OCSP_CrlID
416.It Acceptable OCSP Responses Ta Dv NID_id_pkix_OCSP_acceptableResponses
417.It OCSP No Check Ta Dv NID_id_pkix_OCSP_noCheck
418.It OCSP Archive Cutoff Ta Dv NID_id_pkix_OCSP_archiveCutoff
419.It OCSP Service Locator Ta Dv NID_id_pkix_OCSP_serviceLocator
420.It Hold Instruction Code Ta Dv NID_hold_instruction_code
421.El
422.Sh RETURN VALUES
423.Fn X509V3_get_d2i ,
424.Fn X509V3_EXT_d2i ,
425.Fn X509_get_ext_d2i ,
426.Fn X509_CRL_get_ext_d2i ,
427and
428.Fn X509_REVOKED_get_ext_d2i
429return a pointer to an extension specific structure or
430.Dv NULL
431if an error occurs.
432.Pp
433.Fn X509V3_add1_i2d ,
434.Fn X509_add1_ext_i2d ,
435.Fn X509_CRL_add1_ext_i2d ,
436and
437.Fn X509_REVOKED_add1_ext_i2d
438return 1 if the operation is successful, 0 if it fails due to a
439non-fatal error (extension not found, already exists, cannot be encoded),
440or -1 due to a fatal error such as a memory allocation failure.
441In some cases of failure, the reason can be determined with
442.Xr ERR_get_error 3 .
443.Pp
444The
445.Fn X509V3_EXT_i2d
446function returns a pointer to an
447.Vt X509_EXTENSION
448structure if successful; otherwise
449.Dv NULL
450is returned and an error code can be retrieved with
451.Xr ERR_get_error 3 .
452.Pp
453.Fn X509_get0_extensions ,
454.Fn X509_CRL_get0_extensions ,
455and
456.Fn X509_REVOKED_get0_extensions
457return a stack of extensions, or
458.Dv NULL
459if no extensions are present.
460.Sh SEE ALSO
461.Xr d2i_X509 3 ,
462.Xr d2i_X509_EXTENSION 3 ,
463.Xr X509_check_purpose 3 ,
464.Xr X509_CRL_get0_by_serial 3 ,
465.Xr X509_CRL_new 3 ,
466.Xr X509_EXTENSION_new 3 ,
467.Xr X509_get_pubkey 3 ,
468.Xr X509_get_subject_name 3 ,
469.Xr X509_get_version 3 ,
470.Xr X509_new 3 ,
471.Xr X509_REVOKED_new 3 ,
472.Xr X509V3_EXT_print 3 ,
473.Xr X509V3_extensions_print 3
474.Sh HISTORY
475.Fn X509V3_EXT_d2i
476first appeared in OpenSSL 0.9.2b.
477.Fn X509V3_EXT_i2d
478first appeared in OpenSSL 0.9.3.
479Both functions have been available since
480.Ox 2.6 .
481.Pp
482.Fn X509V3_get_d2i ,
483.Fn X509_get_ext_d2i ,
484.Fn X509_CRL_get_ext_d2i ,
485and
486.Fn X509_REVOKED_get_ext_d2i
487first appeared in OpenSSL 0.9.5 and have been available since
488.Ox 2.7 .
489.Pp
490.Fn X509V3_add1_i2d ,
491.Fn X509_add1_ext_i2d ,
492.Fn X509_CRL_add1_ext_i2d ,
493and
494.Fn X509_REVOKED_add1_ext_i2d
495first appeared in OpenSSL 0.9.7 and have been available since
496.Ox 3.2 .
497.Pp
498.Fn X509_get0_extensions ,
499.Fn X509_CRL_get0_extensions ,
500and
501.Fn X509_REVOKED_get0_extensions
502first appeared in OpenSSL 1.1.0 and have been available since
503.Ox 6.3 .
504.Pp
505.Fn X509_get0_uids
506first appeared in OpenSSL 1.1.0 and has been available since
507.Ox 7.3 .
diff --git a/src/lib/libcrypto/man/X509V3_parse_list.3 b/src/lib/libcrypto/man/X509V3_parse_list.3
deleted file mode 100644
index 447f1a5e94..0000000000
--- a/src/lib/libcrypto/man/X509V3_parse_list.3
+++ /dev/null
@@ -1,101 +0,0 @@
1.\" $OpenBSD: X509V3_parse_list.3,v 1.2 2024/12/24 09:48:56 schwarze Exp $
2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 24 2024 $
18.Dt X509V3_PARSE_LIST 3
19.Os
20.Sh NAME
21.Nm X509V3_parse_list ,
22.Nm X509V3_conf_free
23.Nd create and destroy CONF_VALUE objects
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft STACK_OF(CONF_VALUE) *
27.Fn X509V3_parse_list "const char *string"
28.Ft void
29.Fn X509V3_conf_free "CONF_VALUE *conf"
30.Sh DESCRIPTION
31.Fn X509V3_parse_list
32parses the
33.Fa string
34and allocates an array of
35.Vt CONF_VALUE
36objects according to the following rules.
37.Bl -enum -width 2n
38.It
39The string is split into fields at comma
40.Pq Sq \&,
41characters.
42.It
43If a field contains a colon
44.Pq Sq \&:
45character, the part before the colon is regarded as a name
46and the part after the first colon as the associated value.
47Otherwise, the whole field is regarded as the name and
48.Dv NULL
49is used as the associated value.
50.It
51For each name and each value, leading and trailing whitespace as defined by
52.Xr isspace 3
53is ignored.
54.It
55Parsing ends when a NUL, carriage return, or newline character
56is encountered.
57.El
58.Pp
59A new, empty
60.Vt STACK_OF(CONF_VALUE)
61is allocated and for each parsed name, one
62.Vt CONF_VALUE
63structure containing the optional value is pushed onto it.
64.Pp
65.Fn X509V3_conf_free
66releases all memory used by
67.Fa conf .
68If
69.Fa conf
70is
71.Dv NULL ,
72no action occurs.
73.Pp
74The typical way to release the memory returned from
75.Fn X509V3_parse_list
76is by calling
77.Fn sk_CONF_VALUE_pop_free
78on it, passing a pointer to the function
79.Fn X509V3_conf_free
80as the second argument.
81.Sh RETURN VALUES
82.Fn X509V3_parse_list
83returns the new
84.Vt STACK_OF(CONF_VALUE)
85object or
86.Dv NULL
87if an error occurs, in particular if there isn't any name,
88if the name before a colon or after a comma is empty,
89if the value after a colon is empty,
90or if memory allocation fails.
91.Sh SEE ALSO
92.Xr isspace 3 ,
93.Xr sk_pop_free 3 ,
94.Xr STACK_OF 3 ,
95.Xr v2i_ASN1_BIT_STRING 3
96.Sh HISTORY
97.Fn X509V3_parse_list
98and
99.Fn X509V3_conf_free
100first appeared in OpenSSL 0.9.2 and have been available since
101.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/X509_ALGOR_dup.3 b/src/lib/libcrypto/man/X509_ALGOR_dup.3
deleted file mode 100644
index ef7ca75863..0000000000
--- a/src/lib/libcrypto/man/X509_ALGOR_dup.3
+++ /dev/null
@@ -1,297 +0,0 @@
1.\" $OpenBSD: X509_ALGOR_dup.3,v 1.23 2024/03/19 17:34:05 tb Exp $
2.\" OpenSSL 4692340e Jun 7 15:49:08 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
8.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2002, 2015 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: March 19 2024 $
70.Dt X509_ALGOR_DUP 3
71.Os
72.Sh NAME
73.Nm X509_ALGOR_new ,
74.Nm X509_ALGOR_free ,
75.Nm X509_ALGOR_dup ,
76.Nm X509_ALGOR_set0 ,
77.Nm X509_ALGOR_get0 ,
78.Nm X509_ALGOR_cmp
79.Nd create, change, and inspect algorithm identifiers
80.Sh SYNOPSIS
81.In openssl/x509.h
82.Ft X509_ALGOR *
83.Fn X509_ALGOR_new void
84.Ft void
85.Fn X509_ALGOR_free "X509_ALGOR *alg"
86.Ft X509_ALGOR *
87.Fo X509_ALGOR_dup
88.Fa "X509_ALGOR *alg"
89.Fc
90.Ft int
91.Fo X509_ALGOR_set0
92.Fa "X509_ALGOR *alg"
93.Fa "ASN1_OBJECT *aobj"
94.Fa "int ptype"
95.Fa "void *pval"
96.Fc
97.Ft void
98.Fo X509_ALGOR_get0
99.Fa "const ASN1_OBJECT **paobj"
100.Fa "int *pptype"
101.Fa "const void **ppval"
102.Fa "const X509_ALGOR *alg"
103.Fc
104.Ft int
105.Fo X509_ALGOR_cmp
106.Fa "const X509_ALGOR *a"
107.Fa "const X509_ALGOR *b"
108.Fc
109.Sh DESCRIPTION
110An
111.Vt X509_ALGOR
112object represents an ASN.1
113.Vt AlgorithmIdentifier
114structure defined in RFC 5280 section 4.1.1.2.
115It specifies a cryptographic
116.Fa algorithm
117by an ASN.1 object identifier (OID) that can be obtained from
118.Xr OBJ_nid2obj 3 ,
119together with optional algorithm-specific
120.Fa parameters
121of the type
122.Vt ASN1_TYPE ,
123see
124.Xr ASN1_TYPE_set 3 .
125.Vt X509_ALGOR
126objects are used by many other objects, for example certificates,
127certificate revocation lists, and certificate requests.
128.Pp
129.Fn X509_ALGOR_new
130allocates a new
131.Vt X509_ALGOR
132object containing the object that
133.Xr OBJ_nid2obj 3
134returns for
135.Dv NID_undef
136as the
137.Fa algorithm
138and a
139.Dv NULL
140pointer as the
141.Fa parameters .
142.Pp
143.Fn X509_ALGOR_free
144frees
145.Fa alg
146and any data contained in it.
147If
148.Fa alg
149is
150.Dv NULL ,
151no action occurs.
152.Pp
153.Fn X509_ALGOR_dup
154creates a deep copy of
155.Fa alg .
156It is implemented by calling
157.Xr ASN1_item_dup 3
158with arguments of
159.Dv X509_ALGOR_it
160and
161.Fa alg ,
162which is equivalent to calling
163.Xr i2d_X509_ALGOR 3
164and
165.Xr d2i_X509_ALGOR 3 .
166.Pp
167.Fn X509_ALGOR_set0
168sets the algorithm OID of
169.Fa alg
170to
171.Fa aobj
172and the associated parameter type to
173.Fa ptype
174with value
175.Fa pval .
176If
177.Fa ptype
178is
179.Dv V_ASN1_UNDEF ,
180the parameter is omitted and
181.Fa pval
182is ignored.
183If
184.Fa ptype
185is zero,
186.Fa pval
187is ignored and the existing parameter is left unchanged, or if
188.Fa alg
189does not contain a parameter, a new, empty parameter of type
190.Dv V_ASN1_UNDEF
191is added.
192Otherwise
193.Fa ptype
194and
195.Fa pval
196have the same meaning as the
197.Fa type
198and
199.Fa value
200parameters to
201.Xr ASN1_TYPE_set 3 .
202Ownership of
203.Fa aobj
204and, unless it is ignored, of
205.Fa pval
206is transferred to
207.Fa alg
208on success.
209.Pp
210.Fn X509_ALGOR_get0
211returns
212.Fa alg Ns 's
213algorithm OID in
214.Pf * Fa paobj ,
215its parameter type in
216.Pf * Fa pptype ,
217and its parameter value in
218.Pf * Fa ppval .
219Any of
220.Fa paobj ,
221.Fa pptype ,
222and
223.Fa ppval
224can be
225.Dv NULL .
226If
227.Fa pptype is
228.Dv NULL
229or if
230.Pf * Fa pptype
231is
232.Dv V_ASN1_UNDEF
233then
234.Pf * Fa ppval Ns 's
235value is undefined.
236.Pp
237.Fn X509_ALGOR_cmp
238compares
239.Fa a
240and
241.Fa b .
242.Sh RETURN VALUES
243.Fn X509_ALGOR_new
244and
245.Fn X509_ALGOR_dup
246return a new
247.Vt X509_ALGOR
248object or
249.Dv NULL
250if an error occurs.
251.Pp
252.Fn X509_ALGOR_set0
253returns 1 for success or 0 if
254.Fa alg
255is
256.Dv NULL
257or memory allocation fails.
258.Pp
259.Fn X509_ALGOR_cmp
260returns 0 if
261.Fa a
262and
263.Fa b
264have identical encodings or non-zero otherwise.
265.Sh SEE ALSO
266.Xr ASN1_TYPE_set 3 ,
267.Xr d2i_X509_ALGOR 3 ,
268.Xr EVP_DigestInit 3 ,
269.Xr OBJ_nid2obj 3 ,
270.Xr X509_get0_signature 3 ,
271.Xr X509_new 3 ,
272.Xr X509_PUBKEY_get0_param 3 ,
273.Xr X509_signature_dump 3
274.Sh STANDARDS
275RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
276Certificate Revocation List (CRL) Profile
277.Sh HISTORY
278.Fn X509_ALGOR_new
279and
280.Fn X509_ALGOR_free
281appeared in SSLeay 0.4 or earlier and have been available since
282.Ox 2.4 .
283.Pp
284.Fn X509_ALGOR_dup
285first appeared in SSLeay 0.9.1 and has been available since
286.Ox 2.6 .
287.Pp
288.Fn X509_ALGOR_set0
289and
290.Fn X509_ALGOR_get0
291first appeared in OpenSSL 0.9.8h and have been available since
292.Ox 4.5 .
293.Pp
294.Fn X509_ALGOR_cmp
295first appeared in OpenSSL 0.9.8zd, 1.0.0p, and 1.0.1k
296and has been available since
297.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3 b/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3
deleted file mode 100644
index 4212e27d7e..0000000000
--- a/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3
+++ /dev/null
@@ -1,136 +0,0 @@
1.\" $OpenBSD: X509_ATTRIBUTE_get0_object.3,v 1.2 2021/10/21 16:26:34 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 21 2021 $
18.Dt X509_ATTRIBUTE_GET0_OBJECT 3
19.Os
20.Sh NAME
21.Nm X509_ATTRIBUTE_get0_object ,
22.Nm X509_ATTRIBUTE_count ,
23.Nm X509_ATTRIBUTE_get0_type ,
24.Nm X509_ATTRIBUTE_get0_data
25.\" In the following line, "X.501" and "Attribute" are not typos.
26.\" The "Attribute" type is defined in X.501, not in X.509.
27.\" The type is called "Attribute" with capital "A", not "attribute".
28.Nd X.501 Attribute read accessors
29.Sh SYNOPSIS
30.In openssl/x509.h
31.Ft ASN1_OBJECT *
32.Fo X509_ATTRIBUTE_get0_object
33.Fa "X509_ATTRIBUTE *attr"
34.Fc
35.Ft int
36.Fo X509_ATTRIBUTE_count
37.Fa "const X509_ATTRIBUTE *attr"
38.Fc
39.Ft ASN1_TYPE *
40.Fo X509_ATTRIBUTE_get0_type
41.Fa "X509_ATTRIBUTE *attr"
42.Fa "int index"
43.Fc
44.Ft void *
45.Fo X509_ATTRIBUTE_get0_data
46.Fa "X509_ATTRIBUTE *attr"
47.Fa "int index"
48.Fa "int type"
49.Fa "void *data"
50.Fc
51.Sh DESCRIPTION
52These functions provide read access to the X.501 Attribute object
53.Fa attr .
54.Pp
55For
56.Fn X509_ATTRIBUTE_get0_data ,
57the
58.Fa type
59argument usually is one of the
60.Dv V_ASN1_*
61constants defined in
62.In openssl/asn1.h .
63For example, if a return value of the type
64.Vt ASN1_OCTET_STRING
65is expected, pass
66.Dv V_ASN1_OCTET_STRING
67as the
68.Fa type
69argument.
70The
71.Fa data
72argument is ignored; passing
73.Dv NULL
74is recommended.
75.Sh RETURN VALUES
76.Fn X509_ATTRIBUTE_get0_object
77returns an internal pointer to the type of
78.Fa attr
79or
80.Dv NULL
81if
82.Fa attr
83is
84.Dv NULL
85or if its type is not set.
86.Pp
87.Fn X509_ATTRIBUTE_count
88returns the number of values stored in
89.Fa attr
90or 0 if no value or values are set.
91.Pp
92.Fn X509_ATTRIBUTE_get0_type
93returns an internal pointer to the ASN.1 ANY object
94representing the value with the given zero-based
95.Fa index
96or
97.Dv NULL
98if
99.Fa attr
100is
101.Dv NULL ,
102if the
103.Fa index
104is larger than or equal to the number of values stored in
105.Fa attr ,
106or if no value or values are set.
107.Pp
108.Fn X509_ATTRIBUTE_get0_data
109returns an internal pointer to the data
110contained in the value with the given zero-based
111.Fa index
112or
113.Dv NULL
114if
115.Fa attr
116is
117.Dv NULL ,
118if the
119.Fa index
120is larger than or equal to the number of values stored in
121.Fa attr ,
122if no value or values are set,
123or if the ASN.1 ANY object representing the value with the given
124.Fa index
125is not of the requested
126.Fa type .
127.Sh SEE ALSO
128.Xr ASN1_OBJECT_new 3 ,
129.Xr ASN1_TYPE_new 3 ,
130.Xr OPENSSL_sk_new 3 ,
131.Xr X509_ATTRIBUTE_new 3 ,
132.Xr X509_ATTRIBUTE_set1_object 3
133.Sh HISTORY
134These functions first appeared in OpenSSL 0.9.5
135and have been available since
136.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3 b/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3
deleted file mode 100644
index cc2b27d4c0..0000000000
--- a/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3
+++ /dev/null
@@ -1,180 +0,0 @@
1.\" $OpenBSD: X509_ATTRIBUTE_new.3,v 1.18 2024/09/02 07:57:27 tb Exp $
2.\"
3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 2 2024 $
18.Dt X509_ATTRIBUTE_NEW 3
19.Os
20.Sh NAME
21.Nm X509_ATTRIBUTE_new ,
22.Nm X509_ATTRIBUTE_create ,
23.Nm X509_ATTRIBUTE_dup ,
24.Nm X509_ATTRIBUTE_free
25.\" In the following line, "X.501" and "Attribute" are not typos.
26.\" The "Attribute" type is defined in X.501, not in X.509.
27.\" The type is called "Attribute" with capital "A", not "attribute".
28.Nd generic X.501 Attribute
29.Sh SYNOPSIS
30.In openssl/x509.h
31.Ft X509_ATTRIBUTE *
32.Fn X509_ATTRIBUTE_new void
33.Ft X509_ATTRIBUTE *
34.Fn X509_ATTRIBUTE_create "int nid" "int type" "void *value"
35.Ft X509_ATTRIBUTE *
36.Fn X509_ATTRIBUTE_dup "X509_ATTRIBUTE *attr"
37.Ft void
38.Fn X509_ATTRIBUTE_free "X509_ATTRIBUTE *attr"
39.Sh DESCRIPTION
40In the X.501 standard, an
41.Vt Attribute
42is the fundamental ASN.1 data type used to represent any kind of
43property of any kind of directory entry.
44In OpenSSL, very few objects use it directly, most notably the
45.Vt X509_REQ_INFO
46object used for PKCS#10 certification requests described in
47.Xr X509_REQ_new 3 ,
48the
49.Vt PKCS8_PRIV_KEY_INFO
50object used for PKCS#8 private key information described in
51.Xr PKCS8_PRIV_KEY_INFO_new 3 ,
52and the
53.Vt PKCS12_SAFEBAG
54container object described in
55.Xr PKCS12_SAFEBAG_new 3 .
56.Pp
57.Fn X509_ATTRIBUTE_new
58allocates and initializes an empty
59.Vt X509_ATTRIBUTE
60object.
61.Pp
62.Fn X509_ATTRIBUTE_create
63allocates a new multi-valued
64.Vt X509_ATTRIBUTE
65object of the type
66.Fa nid
67and initializes its set of values
68to contain one new ASN.1 ANY object with the given
69.Fa value
70and
71.Fa type .
72The
73.Fa type
74usually is one of the
75.Dv V_ASN1_*
76constants defined in
77.In openssl/asn1.h ;
78it is stored without validating it.
79If the function succeeds, ownership of the
80.Fa value
81is transferred to the new
82.Vt X509_ATTRIBUTE
83object.
84.Pp
85Be careful to not confuse the type of the attribute
86and the type of the value.
87.Pp
88.Fn X509_ATTRIBUTE_dup
89creates a deep copy of
90.Fa attr .
91.Pp
92.Fn X509_ATTRIBUTE_free
93frees
94.Fa attr .
95.Sh RETURN VALUES
96.Fn X509_ATTRIBUTE_new ,
97.Fn X509_ATTRIBUTE_create ,
98and
99.Fn X509_ATTRIBUTE_dup
100return the new
101.Vt X509_ATTRIBUTE
102object or
103.Dv NULL
104if an error occurs.
105.Pp
106In particular, these functions fail if memory allocation fails.
107.Fn X509_ATTRIBUTE_create
108also fails if
109.Xr OBJ_nid2obj 3
110fails on
111.Fa nid .
112.Sh SEE ALSO
113.Xr d2i_X509_ATTRIBUTE 3 ,
114.Xr OBJ_nid2obj 3 ,
115.Xr PKCS12_SAFEBAG_new 3 ,
116.Xr PKCS7_add_attribute 3 ,
117.Xr PKCS8_pkey_get0_attrs 3 ,
118.Xr PKCS8_PRIV_KEY_INFO_new 3 ,
119.Xr X509_ATTRIBUTE_get0_object 3 ,
120.Xr X509_ATTRIBUTE_set1_object 3 ,
121.Xr X509_EXTENSION_new 3 ,
122.Xr X509_new 3 ,
123.Xr X509_REQ_add1_attr 3 ,
124.Xr X509_REQ_new 3
125.Sh STANDARDS
126.Bl -ohang
127.It Xo
128For the general definition of the
129.Vt Attribute
130data type:
131.Xc
132ITU-T Recommendation X.501, also known as ISO/IEC 9594-2:
133Information Technology \(en Open Systems Interconnection \(en
134The Directory: Models, section 8.2: Overall structure
135.It For the specific definition in the context of certification requests:
136RFC 2986: PKCS #10: Certification Request Syntax Specification,
137section 4.1: CertificationRequestInfo
138.It For the specific use in the context of private key information:
139RFC 5208: Public-Key Cryptography Standards (PKCS) #8:
140Private-Key Information Syntax Specification
141.It For the specific definition in the context of PFX:
142RFC 7292: PKCS #12: Personal Information Exchange Syntax,
143section 4.2: The SafeBag Type
144.El
145.Sh HISTORY
146.Fn X509_ATTRIBUTE_new
147and
148.Fn X509_ATTRIBUTE_free
149first appeared in SSLeay 0.5.1 and have been available since
150.Ox 2.4 .
151.Pp
152.Fn X509_ATTRIBUTE_create
153and
154.Fn X509_ATTRIBUTE_dup
155first appeared in SSLeay 0.9.1 and have been available since
156.Ox 2.6 .
157.Sh BUGS
158A data type designed to hold arbitrary data is an oxymoron.
159.Pp
160While it may occasionally be useful for abstract syntax specification
161or for generic container objects, using it for the representation
162of specific data in a specific data structure feels like dubious
163design.
164.Pp
165Having two distinct data types to hold arbitrary data \(en
166in this case,
167.Vt X509_ATTRIBUTE
168on the X.501 language level and
169.Vt X509_EXTENSION
170as described in
171.Xr X509_EXTENSION_new 3
172on the X.509 language level \(en feels even more questionable,
173in particular considering that Attributes in certification requests
174can be used to ask for Extensions in certificates.
175.Pp
176At the very least, the direct use of the low-level generic
177.Vt X509_ATTRIBUTE
178type in specific data types like certification requests or private
179key information looks like a layering violation and appears to put
180type safety into jeopardy.
diff --git a/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3 b/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3
deleted file mode 100644
index 3555d4b169..0000000000
--- a/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3
+++ /dev/null
@@ -1,267 +0,0 @@
1.\" $OpenBSD: X509_ATTRIBUTE_set1_object.3,v 1.3 2021/11/26 13:48:21 jsg Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 26 2021 $
18.Dt X509_ATTRIBUTE_SET1_OBJECT 3
19.Os
20.Sh NAME
21.Nm X509_ATTRIBUTE_set1_object ,
22.Nm X509_ATTRIBUTE_set1_data ,
23.Nm X509_ATTRIBUTE_create_by_OBJ ,
24.Nm X509_ATTRIBUTE_create_by_NID ,
25.Nm X509_ATTRIBUTE_create_by_txt
26.\" In the following line, "X.501" and "Attribute" are not typos.
27.\" The "Attribute" type is defined in X.501, not in X.509.
28.\" The type is called "Attribute" with capital "A", not "attribute".
29.Nd modify an X.501 Attribute
30.Sh SYNOPSIS
31.In openssl/x509.h
32.Ft int
33.Fo X509_ATTRIBUTE_set1_object
34.Fa "X509_ATTRIBUTE *attr"
35.Fa "const ASN1_OBJECT *obj"
36.Fc
37.Ft int
38.Fo X509_ATTRIBUTE_set1_data
39.Fa "X509_ATTRIBUTE *attr"
40.Fa "int type"
41.Fa "const void *data"
42.Fa "int len"
43.Fc
44.Ft X509_ATTRIBUTE *
45.Fo X509_ATTRIBUTE_create_by_OBJ
46.Fa "X509_ATTRIBUTE **pattr"
47.Fa "const ASN1_OBJECT *obj"
48.Fa "int type"
49.Fa "const void *data"
50.Fa "int len"
51.Fc
52.Ft X509_ATTRIBUTE *
53.Fo X509_ATTRIBUTE_create_by_NID
54.Fa "X509_ATTRIBUTE **pattr"
55.Fa "int nid"
56.Fa "int type"
57.Fa "const void *data"
58.Fa "int len"
59.Fc
60.Ft X509_ATTRIBUTE *
61.Fo X509_ATTRIBUTE_create_by_txt
62.Fa "X509_ATTRIBUTE **pattr"
63.Fa "const char *name"
64.Fa "int type"
65.Fa "const unsigned char *data"
66.Fa "int len"
67.Fc
68.Sh DESCRIPTION
69.Fn X509_ATTRIBUTE_set1_object
70sets the type of
71.Fa attr
72to
73.Fa obj .
74If
75.Fa obj
76is dynamically allocated, a deep copy is created.
77If the type of
78.Fa attr
79was already set, the old type is freed
80as far as it was dynamically allocated.
81After calling this function,
82.Fa attr
83may be in an inconsistent state
84because its values may not agree with the new attribute type.
85.Pp
86.Fn X509_ATTRIBUTE_set1_data
87sets
88.Fa attr
89to be multi-valued and initializes its set of values
90to contain a single new ASN.1 ANY object representing the
91.Fa data .
92.Pp
93The interpretation of the
94.Fa data
95depends on the values of the
96.Fa type
97and
98.Fa len
99arguments; there are four different cases.
100.Pp
101If the
102.Fa type
103argument has the bit
104.Dv MBSTRING_FLAG
105set,
106.Fa data
107is expected to point to a multibyte character string that is
108.Fa len
109bytes long and uses the encoding specified by the
110.Fa type
111argument, and it is expected that an attribute type was already assigned to
112.Fa attr ,
113for example by calling
114.Fn X509_ATTRIBUTE_set1_object
115before calling
116.Fn X509_ATTRIBUTE_set1_data .
117In this case, an appropriate ASN.1 multibyte string type is chosen and
118a new object of that type is allocated and populated to represent the
119.Fa data
120by calling
121.Xr ASN1_STRING_set_by_NID 3 .
122The type of that new ASN.1 string object is subsequently used instead of the
123.Fa type
124argument.
125.Pp
126If the
127.Fa type
128argument does not have the bit
129.Dv MBSTRING_FLAG
130set and the
131.Fa len argument
132is not \-1, the
133.Fa type
134argument is expected to be one of the types documented in
135.Xr ASN1_STRING_new 3
136and
137.Fa data
138is expected to point to a buffer of
139.Fa len
140bytes.
141In this case, a new object is allocated with
142.Xr ASN1_STRING_type_new 3
143and populated with
144.Xr ASN1_STRING_set 3 .
145.Pp
146If the
147.Fa type
148argument does not have the bit
149.Dv MBSTRING_FLAG
150set and the
151.Fa len argument
152is \-1,
153.Fa data
154is expected to point to an object of the given
155.Fa type
156rather than to a buffer.
157In this case, a deep copy of the existing object
158into the new ASN.1 ANY object is performed with
159.Xr ASN1_TYPE_set1 3 .
160.Pp
161If the
162.Fa type
163argument is 0, the
164.Fa data
165and
166.Fa len
167arguments are ignored and the set of values is left empty
168instead of adding a single ASN.1 ANY object to it.
169This violates section 8.2 of the X.501 standard, which requires
170every attribute to contain at least one value, but some attribute
171types used by the library use empty sets of values anyway.
172.Pp
173.Fn X509_ATTRIBUTE_create_by_OBJ
174sets the type of
175.Pf ** Fa attr
176to
177.Fa obj
178using
179.Fn X509_ATTRIBUTE_set1_object
180and copies the
181.Fa data
182into it using
183.Fn X509_ATTRIBUTE_set1_data .
184If
185.Fa attr
186or
187.Pf * Fa attr
188is
189.Dv NULL ,
190a new
191.Vt X509_ATTRIBUTE
192object is allocated, populated, and returned.
193.Pp
194.Fn X509_ATTRIBUTE_create_by_NID
195is a wrapper around
196.Fn X509_ATTRIBUTE_create_by_OBJ
197that obtains the required
198.Fa obj
199argument by calling
200.Xr OBJ_nid2obj 3
201on the
202.Fa nid
203argument.
204.Pp
205.Fn X509_ATTRIBUTE_create_by_txt
206is a similar wrapper that obtains
207.Fa obj
208by calling
209.Xr OBJ_txt2obj 3
210with the arguments
211.Fa name
212and 0, which means that long names, short names, and numerical OID
213strings are all acceptable.
214.Sh RETURN VALUES
215.Fn X509_ATTRIBUTE_set1_object
216returns 1 if successful or 0 if
217.Fa attr
218or
219.Fa obj
220is
221.Dv NULL
222or if memory allocation fails.
223.Pp
224.Fn X509_ATTRIBUTE_set1_data
225returns 1 if successful or 0 if
226.Fa attr
227is
228.Dv NULL
229or if
230.Xr ASN1_STRING_set_by_NID 3 ,
231.Xr ASN1_STRING_set 3 ,
232.Xr ASN1_TYPE_set1 3 ,
233or memory allocation fails.
234.Pp
235.Fn X509_ATTRIBUTE_create_by_OBJ ,
236.Fn X509_ATTRIBUTE_create_by_NID ,
237and
238.Fn X509_ATTRIBUTE_create_by_txt
239return a pointer to the changed or new object or
240.Dv NULL
241if obtaining
242.Fa obj ,
243allocating memory, or copying fails.
244.Sh SEE ALSO
245.Xr ASN1_OBJECT_new 3 ,
246.Xr ASN1_STRING_new 3 ,
247.Xr ASN1_STRING_set 3 ,
248.Xr ASN1_STRING_set_by_NID 3 ,
249.Xr ASN1_TYPE_new 3 ,
250.Xr OBJ_nid2obj 3 ,
251.Xr X509_ATTRIBUTE_get0_object 3 ,
252.Xr X509_ATTRIBUTE_new 3
253.Sh HISTORY
254These functions first appeared in OpenSSL 0.9.5
255and have been available since
256.Ox 2.7 .
257.Sh BUGS
258If
259.Fa attr
260already contains one or more values,
261.Fn X509_ATTRIBUTE_set1_data ,
262.Fn X509_ATTRIBUTE_create_by_OBJ ,
263.Fn X509_ATTRIBUTE_create_by_NID ,
264and
265.Fn X509_ATTRIBUTE_create_by_txt
266silently overwrite the pointers to the old values
267and leak the memory used for them.
diff --git a/src/lib/libcrypto/man/X509_CINF_new.3 b/src/lib/libcrypto/man/X509_CINF_new.3
deleted file mode 100644
index 6c09c58545..0000000000
--- a/src/lib/libcrypto/man/X509_CINF_new.3
+++ /dev/null
@@ -1,117 +0,0 @@
1.\" $OpenBSD: X509_CINF_new.3,v 1.11 2024/09/02 08:04:32 tb Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 2 2024 $
18.Dt X509_CINF_NEW 3
19.Os
20.Sh NAME
21.Nm X509_CINF_new ,
22.Nm X509_CINF_free ,
23.Nm X509_VAL_new ,
24.Nm X509_VAL_free ,
25.Nm X509_CERT_AUX_new ,
26.Nm X509_CERT_AUX_free
27.Nd X.509 certificate information objects
28.Sh SYNOPSIS
29.In openssl/x509.h
30.Ft X509_CINF *
31.Fn X509_CINF_new void
32.Ft void
33.Fn X509_CINF_free "X509_CINF *inf"
34.Ft X509_VAL *
35.Fn X509_VAL_new void
36.Ft void
37.Fn X509_VAL_free "X509_VAL *val"
38.Ft X509_CERT_AUX *
39.Fn X509_CERT_AUX_new void
40.Ft void
41.Fn X509_CERT_AUX_free "X509_CERT_AUX *aux"
42.Sh DESCRIPTION
43.Fn X509_CINF_new
44allocates and initializes an empty
45.Vt X509_CINF
46object, representing an ASN.1
47.Vt TBSCertificate
48structure defined in RFC 5280 section 4.1.
49It is used inside the
50.Vt X509
51object and holds the main information contained in the X.509
52certificate including subject, public key, issuer, serial number,
53validity period, and extensions.
54.Fn X509_CINF_free
55frees
56.Fa inf .
57.Pp
58.Fn X509_VAL_new
59allocates and initializes an empty
60.Vt X509_VAL
61object, representing an ASN.1
62.Vt Validity
63structure defined in RFC 5280 section 4.1.
64It is used inside the
65.Vt X509_CINF
66object and holds the validity period of the certificate.
67.Fn X509_VAL_free
68frees
69.Fa val .
70.Pp
71.Fn X509_CERT_AUX_new
72allocates and initializes an empty
73.Vt X509_CERT_AUX
74structure.
75It can be used inside an
76.Vt X509
77object to hold optional non-standard auxiliary data appended to a
78certificate, for example friendly alias names and trust data.
79.Fn X509_CERT_AUX_free
80frees
81.Fa aux .
82.Sh RETURN VALUES
83.Fn X509_CINF_new ,
84.Fn X509_VAL_new ,
85and
86.Fn X509_CERT_AUX_new
87return the new
88.Vt X509_CINF ,
89.Vt X509_VAL ,
90or
91.Vt X509_CERT_AUX
92object, respectively, or
93.Dv NULL
94if an error occurs.
95.Sh SEE ALSO
96.Xr d2i_X509_CINF 3 ,
97.Xr X509_add1_trust_object 3 ,
98.Xr X509_CERT_AUX_print 3 ,
99.Xr X509_keyid_set1 3 ,
100.Xr X509_new 3
101.Sh STANDARDS
102RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
103Certificate Revocation List (CRL) Profile
104.Sh HISTORY
105.Fn X509_CINF_new ,
106.Fn X509_CINF_free ,
107.Fn X509_VAL_new ,
108and
109.Fn X509_VAL_free
110appeared in SSLeay 0.4 or earlier and have been available since
111.Ox 2.4 .
112.Pp
113.Fn X509_CERT_AUX_new
114and
115.Fn X509_CERT_AUX_free
116first appeared in OpenSSL 0.9.5 and have been available since
117.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/X509_CRL_get0_by_serial.3 b/src/lib/libcrypto/man/X509_CRL_get0_by_serial.3
deleted file mode 100644
index f5edee6085..0000000000
--- a/src/lib/libcrypto/man/X509_CRL_get0_by_serial.3
+++ /dev/null
@@ -1,179 +0,0 @@
1.\" $OpenBSD: X509_CRL_get0_by_serial.3,v 1.13 2024/03/06 02:34:14 tb Exp $
2.\" full merge up to: OpenSSL cdd6c8c5 Mar 20 12:29:37 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2015, 2017 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 6 2024 $
52.Dt X509_CRL_GET0_BY_SERIAL 3
53.Os
54.Sh NAME
55.Nm X509_CRL_get0_by_serial ,
56.Nm X509_CRL_get0_by_cert ,
57.Nm X509_CRL_get_REVOKED ,
58.Nm X509_CRL_add0_revoked ,
59.Nm X509_CRL_sort
60.Nd add, sort, and retrieve CRL entries
61.Sh SYNOPSIS
62.In openssl/x509.h
63.Ft int
64.Fo X509_CRL_get0_by_serial
65.Fa "X509_CRL *crl"
66.Fa "X509_REVOKED **ret"
67.Fa "ASN1_INTEGER *serial"
68.Fc
69.Ft int
70.Fo X509_CRL_get0_by_cert
71.Fa "X509_CRL *crl"
72.Fa "X509_REVOKED **ret"
73.Fa "X509 *x"
74.Fc
75.Ft STACK_OF(X509_REVOKED) *
76.Fo X509_CRL_get_REVOKED
77.Fa "X509_CRL *crl"
78.Fc
79.Ft int
80.Fo X509_CRL_add0_revoked
81.Fa "X509_CRL *crl"
82.Fa "X509_REVOKED *rev"
83.Fc
84.Ft int
85.Fo X509_CRL_sort
86.Fa "X509_CRL *crl"
87.Fc
88.Sh DESCRIPTION
89.Fn X509_CRL_get0_by_serial
90attempts to find a revoked entry in
91.Fa crl
92for serial number
93.Fa serial .
94If it is successful, it sets
95.Pf * Fa ret
96to the internal pointer of the matching entry.
97Consequently,
98.Pf * Fa ret
99must not be freed up after the call.
100.Pp
101.Fn X509_CRL_get0_by_cert
102is similar to
103.Fn X509_CRL_get0_by_serial
104except that it looks for a revoked entry using the serial number
105of certificate
106.Fa x .
107.Pp
108.Fn X509_CRL_get_REVOKED
109returns an internal pointer to a stack of all revoked entries for
110.Fa crl .
111.Pp
112.Fn X509_CRL_add0_revoked
113appends revoked entry
114.Fa rev
115to CRL
116.Fa crl .
117The pointer
118.Fa rev
119is used internally so it must not be freed up after the call: it is
120freed when the parent CRL is freed.
121.Pp
122.Fn X509_CRL_sort
123sorts the revoked entries of
124.Fa crl
125into ascending serial number order.
126.Pp
127Applications can determine the number of revoked entries returned by
128.Fn X509_CRL_get_revoked
129using
130.Fn sk_X509_REVOKED_num
131and examine each one in turn using
132.Fn sk_X509_REVOKED_value ,
133both defined in
134.In openssl/safestack.h .
135.Sh RETURN VALUES
136.Fn X509_CRL_get0_by_serial
137and
138.Fn X509_CRL_get0_by_cert
139return 0 for failure or 1 for success, except if the revoked entry
140has the reason
141.Qq removeFromCRL ,
142in which case 2 is returned.
143.Pp
144The
145.Fn X509_CRL_add0_revoked
146function returns 1 if successful;
147otherwise 0 is returned and an error code can be retrieved with
148.Xr ERR_get_error 3 .
149.Pp
150.Fn X509_CRL_sort
151returns 1 for success or 0 for failure.
152The current implementation cannot fail.
153.Pp
154.Fn X509_CRL_get_REVOKED
155returns a STACK of revoked entries.
156.Sh SEE ALSO
157.Xr d2i_X509_CRL 3 ,
158.Xr X509_CRL_get_ext 3 ,
159.Xr X509_CRL_get_issuer 3 ,
160.Xr X509_CRL_get_version 3 ,
161.Xr X509_CRL_new 3 ,
162.Xr X509_REVOKED_new 3 ,
163.Xr X509V3_get_d2i 3
164.Sh HISTORY
165.Fn X509_CRL_get_REVOKED
166first appeared in OpenSSL 0.9.2b and has been available since
167.Ox 2.6 .
168.Pp
169.Fn X509_CRL_add0_revoked
170and
171.Fn X509_CRL_sort
172first appeared in OpenSSL 0.9.7 and have been available since
173.Ox 3.2 .
174.Pp
175.Fn X509_CRL_get0_by_serial
176and
177.Fn X509_CRL_get0_by_cert
178first appeared in OpenSSL 1.0.0 and have been available since
179.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/X509_CRL_new.3 b/src/lib/libcrypto/man/X509_CRL_new.3
deleted file mode 100644
index f9355fcfd3..0000000000
--- a/src/lib/libcrypto/man/X509_CRL_new.3
+++ /dev/null
@@ -1,143 +0,0 @@
1.\" $OpenBSD: X509_CRL_new.3,v 1.14 2024/03/06 02:34:14 tb Exp $
2.\"
3.\" Copyright (c) 2016, 2018, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 6 2024 $
18.Dt X509_CRL_NEW 3
19.Os
20.Sh NAME
21.Nm X509_CRL_new ,
22.Nm X509_CRL_dup ,
23.Nm X509_CRL_up_ref ,
24.Nm X509_CRL_free ,
25.Nm X509_CRL_INFO_new ,
26.Nm X509_CRL_INFO_free
27.Nd X.509 certificate revocation lists
28.Sh SYNOPSIS
29.In openssl/x509.h
30.Ft X509_CRL *
31.Fn X509_CRL_new void
32.Ft X509_CRL *
33.Fn X509_CRL_dup "X509_CRL *crl"
34.Ft int
35.Fn X509_CRL_up_ref "X509_CRL *crl"
36.Ft void
37.Fn X509_CRL_free "X509_CRL *crl"
38.Ft X509_CRL_INFO *
39.Fn X509_CRL_INFO_new void
40.Ft void
41.Fn X509_CRL_INFO_free "X509_CRL_INFO *crl_info"
42.Sh DESCRIPTION
43.Fn X509_CRL_new
44allocates and initializes an empty
45.Vt X509_CRL
46object, representing an ASN.1
47.Vt CertificateList
48structure defined in RFC 5280 section 5.1.
49It can hold a pointer to an
50.Vt X509_CRL_INFO
51object discussed below together with a cryptographic signature
52and information about the signature algorithm used.
53The reference count is set to 1.
54.Pp
55.Fn X509_CRL_dup
56creates a deep copy of
57.Fa crl .
58.Pp
59.Fn X509_CRL_up_ref
60increments the reference count of
61.Fa crl
62by 1.
63.Pp
64.Fn X509_CRL_free
65decrements the reference count of
66.Fa crl
67by 1.
68If the reference count reaches 0, it frees
69.Fa crl .
70.Pp
71.Fn X509_CRL_INFO_new
72allocates and initializes an empty
73.Vt X509_CRL_INFO
74object, representing an ASN.1
75.Vt TBSCertList
76structure defined in RFC 5280 section 5.1.
77It is used inside the
78.Vt X509_CRL
79object and can hold a list of revoked certificates, an issuer name,
80the time the list was issued, the time when the next update of the
81list is due, and optional extensions.
82.Fn X509_CRL_INFO_free
83frees
84.Fa crl_info .
85.Sh RETURN VALUES
86.Fn X509_CRL_new ,
87.Fn X509_CRL_dup ,
88and
89.Fn X509_CRL_INFO_new
90return the new
91.Vt X509_CRL
92or
93.Vt X509_CRL_INFO
94object, respectively, or
95.Dv NULL
96if an error occurs.
97.Pp
98.Fn X509_CRL_up_ref
99returns 1 on success or 0 on error.
100.Sh SEE ALSO
101.Xr ACCESS_DESCRIPTION_new 3 ,
102.Xr AUTHORITY_KEYID_new 3 ,
103.Xr d2i_X509_CRL 3 ,
104.Xr DIST_POINT_new 3 ,
105.Xr PEM_read_X509_CRL 3 ,
106.Xr X509_CRL_digest 3 ,
107.Xr X509_CRL_get0_by_serial 3 ,
108.Xr X509_CRL_get0_lastUpdate 3 ,
109.Xr X509_CRL_get0_signature 3 ,
110.Xr X509_CRL_get_ext 3 ,
111.Xr X509_CRL_get_ext_d2i 3 ,
112.Xr X509_CRL_get_issuer 3 ,
113.Xr X509_CRL_get_version 3 ,
114.Xr X509_CRL_match 3 ,
115.Xr X509_CRL_print 3 ,
116.Xr X509_CRL_sign 3 ,
117.Xr X509_EXTENSION_new 3 ,
118.Xr X509_INFO_new 3 ,
119.Xr X509_load_crl_file 3 ,
120.Xr X509_new 3 ,
121.Xr X509_OBJECT_get0_X509_CRL 3 ,
122.Xr X509_REVOKED_new 3 ,
123.Xr X509_STORE_CTX_set0_crls 3 ,
124.Xr X509_STORE_get1_crls 3
125.Sh STANDARDS
126RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
127Certificate Revocation List (CRL) Profile, section 5: CRL and CRL
128Extensions Profile
129.Sh HISTORY
130.Fn X509_CRL_new ,
131.Fn X509_CRL_free ,
132.Fn X509_CRL_INFO_new ,
133and
134.Fn X509_CRL_INFO_free
135first appeared in SSLeay 0.4.4.
136.Fn X509_CRL_dup
137first appeared in SSLeay 0.5.1.
138These functions have been available since
139.Ox 2.4 .
140.Pp
141.Fn X509_CRL_up_ref
142first appeared in OpenSSL 1.1.0 and has been available since
143.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/X509_CRL_print.3 b/src/lib/libcrypto/man/X509_CRL_print.3
deleted file mode 100644
index 2f4832f0e7..0000000000
--- a/src/lib/libcrypto/man/X509_CRL_print.3
+++ /dev/null
@@ -1,113 +0,0 @@
1.\" $OpenBSD: X509_CRL_print.3,v 1.1 2021/07/19 13:16:43 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 19 2021 $
18.Dt X509_CRL_PRINT 3
19.Os
20.Sh NAME
21.Nm X509_CRL_print ,
22.Nm X509_CRL_print_fp
23.Nd pretty-print a certificate revocation list
24.Sh SYNOPSIS
25.In openssl/x509.h
26.Ft int
27.Fo X509_CRL_print
28.Fa "BIO *bio"
29.Fa "X509_CRL *crl"
30.Fc
31.Ft int
32.Fo X509_CRL_print_fp
33.Fa "FILE *fp"
34.Fa "X509_CRL *crl"
35.Fc
36.Sh DESCRIPTION
37.Fn X509_CRL_print
38prints information contained in
39.Fa crl
40to
41.Fa bio
42in human-readable form, in the following order:
43.Bl -bullet
44.It
45The certificate revocation list version number as defined by
46the standard, followed in parentheses by the value contained
47in the version field in hexadecimal notation.
48See
49.Xr X509_CRL_get_version 3
50for details.
51.It
52The name of the signature algorithm is printed with
53.Xr X509_signature_print 3 .
54.It
55The issuer name as returned by
56.Xr X509_CRL_get_issuer 3 .
57.It
58The times of the last and next updates as returned by
59.Xr X509_CRL_get0_lastUpdate 3
60and
61.Xr X509_CRL_get0_nextUpdate 3
62are printed with
63.Xr ASN1_TIME_print 3 .
64.It
65All X.509 extensions directly contained
66in the certificate revocation list object
67.Fa crl
68are printed with
69.Xr X509V3_extensions_print 3 .
70.It
71Information about revoked certificates is retrieved with
72.Xr X509_CRL_get_REVOKED 3 ,
73and for each revoked certificate, the following is printed:
74.Bl -bullet
75.It
76The serial number of the certificate is printed with
77.Xr i2a_ASN1_INTEGER 3 .
78.It
79The revocation date is printed with
80.Xr ASN1_TIME_print 3 .
81.It
82All X.509 extensions contained in the revocation entry are printed with
83.Xr X509V3_extensions_print 3 .
84.El
85.It
86The signature of
87.Fa crl
88is printed with
89.Xr X509_signature_print 3 .
90.El
91.Pp
92.Fn X509_CRL_print_fp
93is similar to
94.Fn X509_CRL_print
95except that it prints to
96.Fa fp .
97.Sh RETURN VALUES
98These functions are intended to return 1 for success and 0 for error.
99.Sh SEE ALSO
100.Xr BIO_new 3 ,
101.Xr X509_CRL_new 3 ,
102.Xr X509_print_ex 3 ,
103.Xr X509_REVOKED_new 3
104.Sh HISTORY
105These functions first appeared in OpenSSL 0.9.2 and have been available since
106.Ox 2.6 .
107.Sh BUGS
108Most I/O errors are silently ignored.
109Even if the information printed is incomplete, these functions may
110return 1 anyway.
111.Pp
112If the version number is invalid, no information from the CRL is printed
113and the functions fail.
diff --git a/src/lib/libcrypto/man/X509_EXTENSION_set_object.3 b/src/lib/libcrypto/man/X509_EXTENSION_set_object.3
deleted file mode 100644
index 45cf0dbaa5..0000000000
--- a/src/lib/libcrypto/man/X509_EXTENSION_set_object.3
+++ /dev/null
@@ -1,348 +0,0 @@
1.\" $OpenBSD: X509_EXTENSION_set_object.3,v 1.19 2024/12/28 11:04:09 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2016, 2021, 2024 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 28 2024 $
69.Dt X509_EXTENSION_SET_OBJECT 3
70.Os
71.Sh NAME
72.Nm X509_EXTENSION_new ,
73.Nm X509_EXTENSION_dup ,
74.Nm X509_EXTENSION_free ,
75.Nm X509_EXTENSION_create_by_NID ,
76.Nm X509_EXTENSION_create_by_OBJ ,
77.Nm X509_EXTENSION_set_object ,
78.Nm X509_EXTENSION_set_critical ,
79.Nm X509_EXTENSION_set_data ,
80.Nm X509_EXTENSION_get_object ,
81.Nm X509_EXTENSION_get_critical ,
82.Nm X509_EXTENSION_get_data ,
83.Nm X509_supported_extension
84.\" In the next line, the capital "E" is not a typo.
85.\" The ASN.1 structure is called "Extension", not "extension".
86.Nd create, change, and inspect X.509 Extension objects
87.Sh SYNOPSIS
88.In openssl/x509.h
89.Ft X509_EXTENSION *
90.Fn X509_EXTENSION_new void
91.Ft X509_EXTENSION *
92.Fn X509_EXTENSION_dup "X509_EXTENSION *ex"
93.Ft void
94.Fn X509_EXTENSION_free "X509_EXTENSION *ex"
95.Ft X509_EXTENSION *
96.Fo X509_EXTENSION_create_by_NID
97.Fa "X509_EXTENSION **ex"
98.Fa "int nid"
99.Fa "int crit"
100.Fa "ASN1_OCTET_STRING *data"
101.Fc
102.Ft X509_EXTENSION *
103.Fo X509_EXTENSION_create_by_OBJ
104.Fa "X509_EXTENSION **ex"
105.Fa "const ASN1_OBJECT *obj"
106.Fa "int crit"
107.Fa "ASN1_OCTET_STRING *data"
108.Fc
109.Ft int
110.Fo X509_EXTENSION_set_object
111.Fa "X509_EXTENSION *ex"
112.Fa "const ASN1_OBJECT *obj"
113.Fc
114.Ft int
115.Fo X509_EXTENSION_set_critical
116.Fa "X509_EXTENSION *ex"
117.Fa "int crit"
118.Fc
119.Ft int
120.Fo X509_EXTENSION_set_data
121.Fa "X509_EXTENSION *ex"
122.Fa "ASN1_OCTET_STRING *data"
123.Fc
124.Ft ASN1_OBJECT *
125.Fo X509_EXTENSION_get_object
126.Fa "X509_EXTENSION *ex"
127.Fc
128.Ft int
129.Fo X509_EXTENSION_get_critical
130.Fa "const X509_EXTENSION *ex"
131.Fc
132.Ft ASN1_OCTET_STRING *
133.Fo X509_EXTENSION_get_data
134.Fa "X509_EXTENSION *ex"
135.Fc
136.Ft int
137.Fo X509_supported_extension
138.Fa "X509_EXTENSION *ex"
139.Fc
140.Sh DESCRIPTION
141.Fn X509_EXTENSION_new
142allocates and initializes an empty
143.Vt X509_EXTENSION
144object, representing an ASN.1
145.Vt Extension
146structure defined in RFC 5280 section 4.1.
147It is a wrapper object around specific extension objects of different
148types and stores an extension type identifier and a criticality
149flag in addition to the DER-encoded form of the wrapped object.
150.Vt X509_EXTENSION
151objects can be used for X.509 v3 certificates inside
152.Vt X509_CINF
153objects and for X.509 v2 certificate revocation lists inside
154.Vt X509_CRL_INFO
155and
156.Vt X509_REVOKED
157objects.
158.Pp
159.Fn X509_EXTENSION_dup
160creates a deep copy of
161.Fa ex
162using
163.Xr ASN1_item_dup 3 .
164.Pp
165.Fn X509_EXTENSION_free
166frees
167.Fa ex
168and all objects it is using.
169.Pp
170.Fn X509_EXTENSION_create_by_NID
171creates an extension of type
172.Fa nid
173and criticality
174.Fa crit
175using data
176.Fa data .
177The created extension is returned and written to
178.Pf * Fa ex
179reusing or allocating a new extension if necessary, so
180.Pf * Fa ex
181should either be
182.Dv NULL
183or a valid
184.Vt X509_EXTENSION
185structure.
186It must not be an uninitialised pointer.
187.Pp
188.Fn X509_EXTENSION_create_by_OBJ
189is identical to
190.Fn X509_EXTENSION_create_by_NID
191except that it creates an extension using
192.Fa obj
193instead of a NID.
194.Pp
195.Fn X509_EXTENSION_set_object
196sets the extension type of
197.Fa ex
198to
199.Fa obj .
200The
201.Fa obj
202pointer is duplicated internally so
203.Fa obj
204should be freed up after use.
205.Pp
206.Fn X509_EXTENSION_set_critical
207sets the criticality of
208.Fa ex
209to
210.Fa crit .
211If
212.Fa crit
213is zero, the extension in non-critical, otherwise it is critical.
214.Pp
215.Fn X509_EXTENSION_set_data
216sets the data in extension
217.Fa ex
218to
219.Fa data .
220The
221.Fa data
222pointer is duplicated internally.
223.Pp
224.Fn X509_EXTENSION_get_object
225returns the extension type of
226.Fa ex
227as an
228.Vt ASN1_OBJECT
229pointer.
230The returned pointer is an internal value which must not be freed up.
231.Pp
232.Fn X509_EXTENSION_get_critical
233tests whether
234.Fa ex
235is critical.
236.Pp
237.Fn X509_EXTENSION_get_data
238returns the data of extension
239.Fa ex .
240The returned pointer is an internal value which must not be freed up.
241.Pp
242.Fn X509_supported_extension
243checks whether
244.Fa ex
245is of a type supported by the verifier.
246The list of supported extension types is hardcoded into the library.
247If an extension is critical but unsupported,
248the certificate will normally be rejected.
249.Pp
250These functions manipulate the contents of an extension directly.
251Most applications will want to parse or encode and add an extension:
252they should use the extension encode and decode functions instead
253such as
254.Xr X509_add1_ext_i2d 3
255and
256.Xr X509_get_ext_d2i 3 .
257.Pp
258The
259.Fa data
260associated with an extension is the extension encoding in an
261.Vt ASN1_OCTET_STRING
262structure.
263.Sh RETURN VALUES
264.Fn X509_EXTENSION_new ,
265.Fn X509_EXTENSION_dup ,
266.Fn X509_EXTENSION_create_by_NID ,
267and
268.Fn X509_EXTENSION_create_by_OBJ
269return an
270.Vt X509_EXTENSION
271pointer or
272.Dv NULL
273if an error occurs.
274.Pp
275.Fn X509_EXTENSION_set_object ,
276.Fn X509_EXTENSION_set_critical ,
277and
278.Fn X509_EXTENSION_set_data
279return 1 for success or 0 for failure.
280.Pp
281.Fn X509_EXTENSION_get_object
282returns an
283.Vt ASN1_OBJECT
284pointer.
285.Pp
286.Fn X509_EXTENSION_get_critical
287returns 0 for non-critical or 1 for critical.
288.Pp
289.Fn X509_EXTENSION_get_data
290returns an
291.Vt ASN1_OCTET_STRING
292pointer.
293.Pp
294.Fn X509_supported_extension
295returns 1 if the type of
296.Fa ex
297is supported by the verifier or 0 otherwise.
298.Sh SEE ALSO
299.Xr ACCESS_DESCRIPTION_new 3 ,
300.Xr AUTHORITY_KEYID_new 3 ,
301.Xr BASIC_CONSTRAINTS_new 3 ,
302.Xr d2i_X509_EXTENSION 3 ,
303.Xr DIST_POINT_new 3 ,
304.Xr ESS_SIGNING_CERT_new 3 ,
305.Xr EXTENDED_KEY_USAGE_new 3 ,
306.Xr GENERAL_NAME_new 3 ,
307.Xr NAME_CONSTRAINTS_new 3 ,
308.Xr OCSP_CRLID_new 3 ,
309.Xr OCSP_SERVICELOC_new 3 ,
310.Xr PKEY_USAGE_PERIOD_new 3 ,
311.Xr POLICYINFO_new 3 ,
312.Xr TS_REQ_new 3 ,
313.Xr X509_check_ca 3 ,
314.Xr X509_check_host 3 ,
315.Xr X509_check_issued 3 ,
316.Xr X509_get_extension_flags 3 ,
317.Xr X509_REQ_add_extensions 3 ,
318.Xr X509V3_EXT_get_nid 3 ,
319.Xr X509V3_EXT_print 3 ,
320.Xr X509V3_extensions_print 3 ,
321.Xr X509V3_get_d2i 3 ,
322.Xr X509v3_get_ext_by_NID 3
323.Sh STANDARDS
324RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
325Certificate Revocation List (CRL) Profile
326.Sh HISTORY
327.Fn X509_EXTENSION_new
328and
329.Fn X509_EXTENSION_free
330first appeared in SSLeay 0.6.2,
331.Fn X509_EXTENSION_dup
332in SSLeay 0.6.5, and
333.Fn X509_EXTENSION_create_by_NID ,
334.Fn X509_EXTENSION_create_by_OBJ ,
335.Fn X509_EXTENSION_set_object ,
336.Fn X509_EXTENSION_set_critical ,
337.Fn X509_EXTENSION_set_data ,
338.Fn X509_EXTENSION_get_object ,
339.Fn X509_EXTENSION_get_critical ,
340and
341.Fn X509_EXTENSION_get_data
342in SSLeay 0.8.0.
343These functions have been available since
344.Ox 2.4 .
345.Pp
346.Fn X509_supported_extension
347first appeared in OpenSSL 0.9.7 and has been available since
348.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/X509_INFO_new.3 b/src/lib/libcrypto/man/X509_INFO_new.3
deleted file mode 100644
index 1e9bb832f3..0000000000
--- a/src/lib/libcrypto/man/X509_INFO_new.3
+++ /dev/null
@@ -1,72 +0,0 @@
1.\" $OpenBSD: X509_INFO_new.3,v 1.3 2021/10/19 10:39:33 schwarze Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\"
4.\" Permission to use, copy, modify, and distribute this software for any
5.\" purpose with or without fee is hereby granted, provided that the above
6.\" copyright notice and this permission notice appear in all copies.
7.\"
8.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\"
16.Dd $Mdocdate: October 19 2021 $
17.Dt X509_INFO_NEW 3
18.Os
19.Sh NAME
20.Nm X509_INFO_new ,
21.Nm X509_INFO_free
22.Nd X.509 certificate wrapper object
23.Sh SYNOPSIS
24.In openssl/x509.h
25.Ft X509_INFO *
26.Fn X509_INFO_new void
27.Ft void
28.Fn X509_INFO_free "X509_INFO *info"
29.Sh DESCRIPTION
30.Vt X509_INFO
31is a reference-counted wrapper object storing a pointer to an X.509
32certificate together with pointers to the associated private key
33and to an associated certificate revocation list.
34It is for example used internally by
35.Xr X509_load_cert_crl_file 3 .
36.Pp
37.Fn X509_INFO_new
38allocates and initializes an empty
39.Vt X509_INFO
40object and sets its reference count to 1.
41.Pp
42.Fn X509_INFO_free
43decrements the reference count of
44.Fa info
45by 1.
46If the reference count reaches 0, it frees all referenced objects
47as well as the storage needed for
48.Fa info
49itself.
50If
51.Fa info
52is a
53.Dv NULL
54pointer, no action occurs.
55.Sh RETURN VALUES
56.Fn X509_INFO_new
57returns the newly allocated
58.Vt X509_INFO
59object or
60.Dv NULL
61if an error occurs.
62.Sh SEE ALSO
63.Xr PEM_X509_INFO_read 3 ,
64.Xr X509_CRL_new 3 ,
65.Xr X509_new 3 ,
66.Xr X509_PKEY_new 3
67.Sh HISTORY
68.Fn X509_INFO_new
69and
70.Fn X509_INFO_free
71first appeared in SSLeay 0.5.1 and have been available since
72.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/X509_LOOKUP_hash_dir.3 b/src/lib/libcrypto/man/X509_LOOKUP_hash_dir.3
deleted file mode 100644
index 5980f8f80d..0000000000
--- a/src/lib/libcrypto/man/X509_LOOKUP_hash_dir.3
+++ /dev/null
@@ -1,188 +0,0 @@
1.\" $OpenBSD: X509_LOOKUP_hash_dir.3,v 1.13 2024/09/02 07:20:21 tb Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Victor B. Wagner <vitus@cryptocom.ru>
23.\" and Claus Assmann.
24.\" Copyright (c) 2015, 2016 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: September 2 2024 $
71.Dt X509_LOOKUP_HASH_DIR 3
72.Os
73.Sh NAME
74.Nm X509_LOOKUP_hash_dir ,
75.Nm X509_LOOKUP_file ,
76.Nm X509_LOOKUP_mem
77.Nd certificate lookup methods
78.Sh SYNOPSIS
79.In openssl/x509_vfy.h
80.Ft const X509_LOOKUP_METHOD *
81.Fn X509_LOOKUP_hash_dir void
82.Ft const X509_LOOKUP_METHOD *
83.Fn X509_LOOKUP_file void
84.Ft const X509_LOOKUP_METHOD *
85.Fn X509_LOOKUP_mem void
86.Sh DESCRIPTION
87.Fn X509_LOOKUP_hash_dir ,
88.Fn X509_LOOKUP_file ,
89and
90.Fn X509_LOOKUP_mem
91return pointers to static certificate lookup method objects
92built into the library, for use with
93.Vt X509_STORE .
94.Pp
95Users of the library typically do not need
96to retrieve pointers to these method objects manually.
97They are automatically used by the
98.Xr X509_STORE_load_locations 3
99or
100.Xr SSL_CTX_load_verify_locations 3
101functions.
102.Ss File Method
103The
104.Fn X509_LOOKUP_file
105method loads all the certificates or CRLs present in a file into memory
106at the time the file is added as a lookup source.
107.Pp
108The file format is ASCII text which contains concatenated PEM
109certificates and CRLs.
110.Pp
111This method should be used by applications which work with a small set
112of CAs.
113.Ss Hashed Directory Method
114.Fa X509_LOOKUP_hash_dir
115is a more advanced method which loads certificates and CRLs on demand,
116and caches them in memory once they are loaded.
117As of OpenSSL 1.0.0, it also checks for newer CRLs upon each lookup, so
118that newer CRLs are used as soon as they appear in the directory.
119.Pp
120The directory should contain one certificate or CRL per file in PEM
121format, with a filename of the form
122.Ar hash . Ns Ar N
123for a certificate, or
124.Ar hash . Ns Sy r Ns Ar N
125for a CRL.
126The
127.Ar hash
128is the value returned by the
129.Xr X509_NAME_hash 3
130function applied to the subject name for certificates or issuer
131name for CRLs.
132The hash can also be obtained via the
133.Fl hash
134option of the
135.Xr openssl 1
136.Cm x509
137or
138.Cm crl
139commands.
140.Pp
141The
142.Ar N
143suffix is a sequence number that starts at zero and is incremented
144consecutively for each certificate or CRL with the same
145.Ar hash
146value.
147Gaps in the sequence numbers are not supported.
148It is assumed that there are no more objects with the same hash
149beyond the first missing number in the sequence.
150.Pp
151Sequence numbers make it possible for the directory to contain multiple
152certificates with the same subject name hash value.
153For example, it is possible to have in the store several certificates
154with the same subject or several CRLs with the same issuer (and, for
155example, a different validity period).
156.Pp
157When checking for new CRLs, once one CRL for a given hash value is
158loaded, hash_dir lookup method checks only for certificates with
159sequence number greater than that of the already cached CRL.
160.Pp
161Note that the hash algorithm used for subject name hashing changed in
162OpenSSL 1.0.0, and all certificate stores have to be rehashed when
163moving from OpenSSL 0.9.8 to 1.0.0.
164.Ss Memory Method
165The
166.Fn X509_LOOKUP_mem
167method supports loading PEM-encoded certificates and revocation lists
168that are already stored in memory, using the function
169.Xr X509_LOOKUP_add_mem 3 .
170This is particularly useful in processes using
171.Xr chroot 2 .
172.Sh RETURN VALUES
173These functions always return a pointer to a static object.
174.Sh SEE ALSO
175.Xr SSL_CTX_load_verify_locations 3 ,
176.Xr X509_LOOKUP_new 3 ,
177.Xr X509_STORE_load_locations 3 ,
178.Xr X509_STORE_new 3
179.Sh HISTORY
180.Fn X509_LOOKUP_hash_dir
181and
182.Fn X509_LOOKUP_file
183first appeared in SSLeay 0.8.0 and have been available since
184.Ox 2.4 .
185.Pp
186.Fn X509_LOOKUP_mem
187first appeared in
188.Ox 5.7 .
diff --git a/src/lib/libcrypto/man/X509_LOOKUP_new.3 b/src/lib/libcrypto/man/X509_LOOKUP_new.3
deleted file mode 100644
index 559dbbb594..0000000000
--- a/src/lib/libcrypto/man/X509_LOOKUP_new.3
+++ /dev/null
@@ -1,460 +0,0 @@
1.\" $OpenBSD: X509_LOOKUP_new.3,v 1.12 2024/09/06 07:48:20 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 6 2024 $
18.Dt X509_LOOKUP_NEW 3
19.Os
20.Sh NAME
21.Nm X509_LOOKUP_free ,
22.Nm X509_LOOKUP_ctrl ,
23.Nm X509_LOOKUP_add_dir ,
24.Nm X509_LOOKUP_load_file ,
25.Nm X509_LOOKUP_add_mem ,
26.Nm X509_get_default_cert_dir ,
27.Nm X509_get_default_cert_file ,
28.Nm X509_get_default_cert_dir_env ,
29.Nm X509_get_default_cert_file_env
30.\" X509_get_default_private_dir is intentionally undocumented
31.\" because it appears to be unused by any real-world software
32.\" and because it doesn't do much in the first place.
33.Nd certificate lookup object
34.Sh SYNOPSIS
35.In openssl/x509_vfy.h
36.Ft void
37.Fn X509_LOOKUP_free "X509_LOOKUP *lookup"
38.Ft int
39.Fo X509_LOOKUP_ctrl
40.Fa "X509_LOOKUP *lookup"
41.Fa "int command"
42.Fa "const char *source"
43.Fa "long type"
44.Fa "char **ret"
45.Fc
46.Ft int
47.Fo X509_LOOKUP_add_dir
48.Fa "X509_LOOKUP *lookup"
49.Fa "const char *source"
50.Fa "long type"
51.Fc
52.Ft int
53.Fo X509_LOOKUP_load_file
54.Fa "X509_LOOKUP *lookup"
55.Fa "const char *source"
56.Fa "long type"
57.Fc
58.Ft int
59.Fo X509_LOOKUP_add_mem
60.Fa "X509_LOOKUP *lookup"
61.Fa "const struct iovec *source"
62.Fa "long type"
63.Fc
64.In openssl/x509.h
65.Ft const char *
66.Fn X509_get_default_cert_dir void
67.Ft const char *
68.Fn X509_get_default_cert_file void
69.Ft const char *
70.Fn X509_get_default_cert_dir_env void
71.Ft const char *
72.Fn X509_get_default_cert_file_env void
73.Sh DESCRIPTION
74.Fn X509_LOOKUP_free
75is a deprecated function that
76releases the memory used by
77.Fa lookup .
78It is provided for compatibility only.
79If
80.Fa lookup
81is a
82.Dv NULL
83pointer, no action occurs.
84.Pp
85The operation of
86.Fn X509_LOOKUP_ctrl
87depends on the
88.Vt X509_LOOKUP_METHOD
89used by
90.Fa lookup :
91.Bl -tag -width 4n
92.It Xr X509_LOOKUP_hash_dir 3
93The
94.Fa command
95is required to be
96.Dv X509_L_ADD_DIR
97and the
98.Fa source
99argument is interpreted
100as a colon-separated, NUL-terminated list of directory names.
101These directories are added to an internal list of directories to search
102for certificate files of the given
103.Fa type .
104.Pp
105If
106.Fa type
107is
108.Dv X509_FILETYPE_DEFAULT ,
109the
110.Fa source
111argument is ignored and
112.Pa /etc/ssl/certs
113and a type of
114.Dv X509_FILETYPE_PEM
115are used instead.
116.Pp
117.Fn X509_LOOKUP_add_dir
118is a macro that calls
119.Fn X509_LOOKUP_ctrl
120with a
121.Fa command
122of
123.Dv X509_L_ADD_DIR
124and
125.Fa ret
126set to
127.Dv NULL .
128.Pp
129This lookup method is peculiar in so far as calling
130.Fn X509_LOOKUP_ctrl
131on a lookup object using it does not yet add any certificates to the associated
132.Vt X509_STORE
133object.
134.It Xr X509_LOOKUP_file 3
135The
136.Fa command
137is required to be
138.Dv X509_L_FILE_LOAD
139and the
140.Fa source
141argument is interpreted as a NUL-terminated file name.
142If the
143.Fa type
144is
145.Dv X509_FILETYPE_PEM ,
146the file is read with
147.Xr BIO_new_file 3
148and
149.Xr PEM_X509_INFO_read_bio 3
150and the certificates and revocation lists found are added to the
151.Vt X509_STORE
152object associated with
153.Fa lookup
154using
155.Xr X509_STORE_add_cert 3
156and
157.Xr X509_STORE_add_crl 3 .
158If
159.Fa type
160is
161.Dv X509_FILETYPE_DEFAULT ,
162the
163.Fa source
164argument is ignored and
165.Pa /etc/ssl/certs.pem
166and a type of
167.Dv X509_FILETYPE_PEM
168are used instead.
169If
170.Fa type
171is
172.Dv X509_FILETYPE_ASN1 ,
173the file is read with
174.Xr d2i_X509_bio 3
175and the single certificate is added to the
176.Vt X509_STORE
177object associated with
178.Fa lookup
179using
180.Xr X509_STORE_add_cert 3 .
181.Pp
182.Fn X509_LOOKUP_load_file
183is a macro calling
184.Fn X509_LOOKUP_ctrl
185with a
186.Fa command
187of
188.Dv X509_L_FILE_LOAD
189and
190.Fa ret
191set to
192.Dv NULL .
193.It Xr X509_LOOKUP_mem 3
194The
195.Fa command
196and
197.Fa type
198are required to be
199.Dv X509_L_MEM
200and
201.Dv X509_FILETYPE_PEM ,
202respectively.
203The
204.Fa source
205argument is interpreted as a pointer to an
206.Vt iovec
207structure defined in
208.In sys/uio.h .
209The memory area described by that structure is read with
210.Xr BIO_new_mem_buf 3
211and
212.Xr PEM_X509_INFO_read_bio 3
213and the certificates and revocation lists found are added to the
214.Vt X509_STORE
215object associated with
216.Fa lookup
217using
218.Xr X509_STORE_add_cert 3
219and
220.Xr X509_STORE_add_crl 3 .
221.Pp
222.Fn X509_LOOKUP_add_mem
223is a macro calling
224.Fn X509_LOOKUP_ctrl
225with a command of
226.Dv X509_L_MEM
227and
228.Fa ret
229set to
230.Dv NULL .
231.El
232.Pp
233With LibreSSL,
234.Fn X509_LOOKUP_ctrl
235always ignores the
236.Fa ret
237argument.
238.Pp
239If the
240.Fa type
241is
242.Dv X509_LU_X509 ,
243it searches the configured directories for files having that name,
244with a file name extension that is a small, non-negative decimal integer
245starting at
246.Qq ".0" .
247These files are read with
248.Xr X509_load_cert_file 3 .
249In each directory, the search is ended once a file with the expected name
250and extension does not exists.
251.Pp
252If the
253.Fa type
254is
255.Dv X509_LU_CRL ,
256the file name extensions are expected to have a prefix of
257.Qq "r" ,
258i.e. they start with
259.Qq ".r0" ,
260and the files are read with
261.Xr X509_load_crl_file 3 .
262.Pp
263In case of success, the first match is returned in the
264.Pf * Fa object
265provided by the caller, overwriting any previous content.
266.Sh RETURN VALUES
267.Fn X509_LOOKUP_ctrl
268returns 1 for success or 0 for failure.
269With library implementations other than LibreSSL,
270it might also return \-1 for internal errors.
271.Pp
272.Fn X509_get_default_cert_dir
273returns a pointer to the constant string
274.Qq /etc/ssl/certs ,
275.Fn X509_get_default_cert_file
276to
277.Qq /etc/ssl/certs.pem ,
278.Fn X509_get_default_cert_dir_env
279to
280.Qq SSL_CERT_DIR ,
281and
282.Fn X509_get_default_cert_file_env
283to
284.Qq SSL_CERT_FILE .
285.Sh ENVIRONMENT
286For reasons of security and simplicity,
287LibreSSL ignores the environment variables
288.Ev SSL_CERT_DIR
289and
290.Ev SSL_CERT_FILE ,
291but other library implementations may use their contents instead
292of the standard locations for trusted certificates, and a few
293third-party application programs also inspect these variables
294directly and may pass their values to
295.Fn X509_LOOKUP_add_dir
296and
297.Fn X509_LOOKUP_load_file .
298.Sh FILES
299.Bl -tag -width /etc/ssl/certs.pem -compact
300.It Pa /etc/ssl/certs/
301default directory for storing trusted certificates
302.It Pa /etc/ssl/certs.pem
303default file for storing trusted certificates
304.El
305.Sh ERRORS
306The following diagnostics can be retrieved with
307.Xr ERR_get_error 3 ,
308.Xr ERR_GET_REASON 3 ,
309and
310.Xr ERR_reason_error_string 3 :
311.Bl -tag -width Ds
312.It Dv ERR_R_ASN1_LIB Qq "ASN1 lib"
313.Xr d2i_X509_bio 3
314failed in
315.Fn X509_LOOKUP_ctrl .
316.It Dv X509_R_BAD_X509_FILETYPE Qq "bad x509 filetype"
317.Fn X509_LOOKUP_ctrl
318was called with an invalid
319.Fa type .
320.It Dv ERR_R_BUF_LIB Qq "BUF lib"
321Memory allocation failed.
322.It Dv X509_R_INVALID_DIRECTORY Qq "invalid directory"
323The
324.Fa source
325argument of
326.Fn X509_LOOKUP_ctrl
327with
328.Dv X509_L_ADD_DIR
329or
330.Fn X509_LOOKUP_add_dir
331was
332.Dv NULL
333or an empty string.
334.It Dv X509_R_LOADING_CERT_DIR Qq "loading cert dir"
335.Fn X509_LOOKUP_ctrl
336with
337.Dv X509_L_ADD_DIR
338or
339.Fn X509_LOOKUP_add_dir
340was called with
341.Dv X509_FILETYPE_DEFAULT
342and adding the default directories failed.
343This error is added after and in addition to a more specific diagnostic.
344.It Dv X509_R_LOADING_DEFAULTS Qq "loading defaults"
345.Fn X509_LOOKUP_ctrl
346with
347.Dv X509_L_FILE_LOAD
348or
349.Fn X509_LOOKUP_load_file
350was called with
351.Dv X509_FILETYPE_DEFAULT
352and adding the certificates and revocation lists failed.
353This error is added after and in addition to a more specific diagnostic.
354.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
355Memory allocation failed.
356.It Dv ERR_R_PEM_LIB Qq "PEM lib"
357.Xr PEM_X509_INFO_read_bio 3 ,
358.Xr PEM_read_bio_X509_AUX 3 ,
359or
360.Xr PEM_read_bio_X509_CRL 3
361failed in
362.Fn X509_LOOKUP_ctrl .
363.It Dv ERR_R_SYS_LIB Qq "system lib"
364.Xr BIO_new 3 ,
365.Xr BIO_new_file 3 ,
366or
367.Xr BIO_read_filename 3
368failed in
369.Fn X509_LOOKUP_ctrl .
370.It Dv X509_R_WRONG_LOOKUP_TYPE Qq "wrong lookup type"
371.Xr X509_STORE_CTX_get_by_subject 3
372was called with an invalid
373.Fa type .
374.El
375.Pp
376Passing an invalid
377.Fa command
378to
379.Fn X509_LOOKUP_ctrl
380causes failure but provides no diagnostics.
381.Sh SEE ALSO
382.Xr d2i_X509_bio 3 ,
383.Xr PEM_read_bio_X509_AUX 3 ,
384.Xr PEM_X509_INFO_read_bio 3 ,
385.Xr X509_load_cert_file 3 ,
386.Xr X509_LOOKUP_hash_dir 3 ,
387.Xr X509_NAME_hash 3 ,
388.Xr X509_NAME_new 3 ,
389.Xr X509_new 3 ,
390.Xr X509_OBJECT_get_type 3 ,
391.Xr X509_STORE_add_cert 3 ,
392.Xr X509_STORE_get_by_subject 3
393.Sh HISTORY
394.Fn X509_get_default_cert_dir ,
395.Fn X509_get_default_cert_file ,
396.Fn X509_get_default_cert_dir_env ,
397and
398.Fn X509_get_default_cert_file_env
399first appeared in SSLeay 0.4.1 and have been available since
400.Ox 2.4 .
401.Pp
402.Fn X509_LOOKUP_add_mem
403first appeared in
404.Ox 5.7 .
405.Pp
406The other functions first appeared in SSLeay 0.8.0
407and have been available since
408.Ox 2.4 .
409.Sh BUGS
410If the
411.Fa type
412is
413.Dv X509_FILETYPE_DEFAULT
414or
415.Dv X509_FILETYPE_PEM ,
416.Fn X509_LOOKUP_ctrl
417with
418.Dv X509_L_FILE_LOAD
419and
420.Fn X509_LOOKUP_load_file
421silently ignore failure of
422.Xr X509_STORE_add_cert 3
423and
424.Xr X509_STORE_add_crl 3
425and indicate success anyway.
426.Pp
427Handling of a
428.Dv NULL
429.Fa source
430is inconsistent for
431.Fn X509_LOOKUP_ctrl
432with
433.Dv X509_L_FILE_LOAD
434and for
435.Fn X509_LOOKUP_load_file .
436With
437.Dv X509_FILETYPE_PEM ,
438it causes failure, but with
439.Dv X509_FILETYPE_ASN1 ,
440no action occurs and success is indicated.
441.Pp
442When called on a
443.Fa lookup
444object using
445.Xr X509_LOOKUP_mem 3 ,
446.Fn X509_LOOKUP_ctrl
447raises
448.Dv ERR_R_PEM_LIB
449when called with an invalid
450.Fa command
451or
452.Fa type ,
453when
454.Xr BIO_new_mem_buf 3
455fails, when
456.Fa source
457contains zero objects, or when
458.Xr X509_STORE_add_cert 3
459fails on the first object encountered, which is all inconsistent
460with the behaviour of the other lookup methods.
diff --git a/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3 b/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3
deleted file mode 100644
index 2eadec7b4d..0000000000
--- a/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3
+++ /dev/null
@@ -1,391 +0,0 @@
1.\" $OpenBSD: X509_NAME_ENTRY_get_object.3,v 1.16 2021/12/10 16:58:20 schwarze Exp $
2.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\" selective merge up to: OpenSSL ca34e08d Dec 12 07:38:07 2018 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2016, 2018, 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2002, 2005, 2006, 2017 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: December 10 2021 $
71.Dt X509_NAME_ENTRY_GET_OBJECT 3
72.Os
73.Sh NAME
74.Nm X509_NAME_ENTRY_new ,
75.Nm X509_NAME_ENTRY_free ,
76.Nm X509_NAME_ENTRY_get_object ,
77.Nm X509_NAME_ENTRY_get_data ,
78.Nm X509_NAME_ENTRY_set ,
79.Nm X509_NAME_ENTRY_set_object ,
80.Nm X509_NAME_ENTRY_set_data ,
81.Nm X509_NAME_ENTRY_create_by_txt ,
82.Nm X509_NAME_ENTRY_create_by_NID ,
83.Nm X509_NAME_ENTRY_create_by_OBJ
84.\" In the following line, "X.501" is not a typo.
85.\" This object defined in X.501, not in X.509.
86.Nd X.501 relative distinguished name
87.Sh SYNOPSIS
88.In openssl/x509.h
89.Ft X509_NAME_ENTRY *
90.Fn X509_NAME_ENTRY_new void
91.Ft void
92.Fo X509_NAME_ENTRY_free
93.Fa "X509_NAME_ENTRY* ne"
94.Fc
95.Ft ASN1_OBJECT *
96.Fo X509_NAME_ENTRY_get_object
97.Fa "const X509_NAME_ENTRY *ne"
98.Fc
99.Ft ASN1_STRING *
100.Fo X509_NAME_ENTRY_get_data
101.Fa "const X509_NAME_ENTRY *ne"
102.Fc
103.Ft int
104.Fo X509_NAME_ENTRY_set
105.Fa "const X509_NAME_ENTRY *ne"
106.Fc
107.Ft int
108.Fo X509_NAME_ENTRY_set_object
109.Fa "X509_NAME_ENTRY *ne"
110.Fa "const ASN1_OBJECT *obj"
111.Fc
112.Ft int
113.Fo X509_NAME_ENTRY_set_data
114.Fa "X509_NAME_ENTRY *ne"
115.Fa "int type"
116.Fa "const unsigned char *bytes"
117.Fa "int len"
118.Fc
119.Ft X509_NAME_ENTRY *
120.Fo X509_NAME_ENTRY_create_by_txt
121.Fa "X509_NAME_ENTRY **ne"
122.Fa "const char *field"
123.Fa "int type"
124.Fa "const unsigned char *bytes"
125.Fa "int len"
126.Fc
127.Ft X509_NAME_ENTRY *
128.Fo X509_NAME_ENTRY_create_by_NID
129.Fa "X509_NAME_ENTRY **ne"
130.Fa "int nid"
131.Fa "int type"
132.Fa "const unsigned char *bytes"
133.Fa "int len"
134.Fc
135.Ft X509_NAME_ENTRY *
136.Fo X509_NAME_ENTRY_create_by_OBJ
137.Fa "X509_NAME_ENTRY **ne"
138.Fa "const ASN1_OBJECT *obj"
139.Fa "int type"
140.Fa "const unsigned char *bytes"
141.Fa "int len"
142.Fc
143.Sh DESCRIPTION
144An X.501
145.Vt RelativeDistinguishedName
146is an ordered set of field type and value pairs.
147It is the building block for constructing X.501
148.Vt Name
149objects.
150The
151.Vt X509_NAME_ENTRY
152object stores one such pair, containing one field type and one value.
153.Pp
154.Vt X509_NAME_ENTRY
155objects are intended for use by the
156.Vt X509_NAME
157objects documented in
158.Xr X509_NAME_new 3 .
159Since part of the information about how several
160.Vt X509_NAME_ENTRY
161objects combine to form an X.501
162.Vt Name
163is stored in the individual
164.Vt X509_NAME_ENTRY
165objects rather than in the
166.Vt X509_NAME
167object, any given
168.Vt X509_NAME_ENTRY
169object can only be used by one
170.Vt X509_NAME
171object at a time.
172.Pp
173.Fn X509_NAME_ENTRY_new
174allocates and initializes an empty
175.Vt X509_NAME_ENTRY
176object, representing an ASN.1
177.Vt RelativeDistinguishedName
178structure defined in RFC 5280 section 4.1.2.4, but containing not more
179than one type-value-pair.
180.Pp
181.Fn X509_NAME_ENTRY_free
182frees
183.Fa ne
184and the type and value contained in it.
185.Pp
186.Fn X509_NAME_ENTRY_get_object
187retrieves the field type of
188.Fa ne
189in an
190.Vt ASN1_OBJECT
191structure.
192.Fn X509_NAME_ENTRY_get_data
193retrieves the field value of
194.Fa ne
195in an
196.Vt ASN1_STRING
197structure.
198These two functions can be used to examine an
199.Vt X509_NAME_ENTRY
200object as returned by
201.Xr X509_NAME_get_entry 3 .
202.Pp
203.Fn X509_NAME_ENTRY_set
204retrieves the index of the X.501
205.Vt RelativeDistinguishedName Pq RDN
206that
207.Fa ne
208is part of in the X.501
209.Vt Name
210object using it.
211The first RDN has index 0.
212If an RDN consists of more than one
213.Vt X509_NAME_ENTRY
214object, they all share the same index.
215In practice, RDNs containing more than one type-value-pair are rarely
216used, so if an
217.Va X509_NAME *name
218object uses
219.Fa ne ,
220then
221.Fn X509_NAME_ENTRY_set ne
222usually agrees with
223.Fn sk_X509_NAME_ENTRY_find name->entries ne ,
224but when multi-pair RDNs are used, it may be smaller.
225.Pp
226.Fn X509_NAME_ENTRY_set_object
227sets the field type of
228.Fa ne
229to
230.Fa obj .
231.Pp
232.Fn X509_NAME_ENTRY_set_data
233sets the field value of
234.Fa ne
235to the given string
236.Fa type
237and the value determined by
238.Fa bytes
239and
240.Fa len .
241If the
242.Fa type
243argument is positive and includes the
244.Fa MBSTRING_FLAG
245bit,
246.Xr ASN1_STRING_set_by_NID 3
247is used for setting the value, passing the
248.Fa type
249as the
250.Fa inform
251argument and using the
252.Fa nid
253corresponding to
254.Fa ne .
255Otherwise, if the
256.Fa type
257argument is
258.Dv V_ASN1_APP_CHOOSE ,
259the type of
260.Fa ne
261is set to the return value of
262.Xr ASN1_PRINTABLE_type 3 .
263.Pp
264.Fn X509_NAME_ENTRY_create_by_txt ,
265.Fn X509_NAME_ENTRY_create_by_NID ,
266and
267.Fn X509_NAME_ENTRY_create_by_OBJ
268create and return an
269.Vt X509_NAME_ENTRY
270structure.
271.Pp
272Except for
273.Fn X509_NAME_ENTRY_get_object
274and
275.Fn X509_NAME_ENTRY_get_data ,
276these functions are rarely used because
277.Vt X509_NAME_ENTRY
278structures are almost always part of
279.Vt X509_NAME
280structures and the functions described in
281.Xr X509_NAME_add_entry_by_txt 3
282are typically used to create and add new entries in a single operation.
283.Pp
284The arguments of these functions support similar options to the
285similarly named ones described in
286.Xr X509_NAME_add_entry_by_txt 3 .
287So for example
288.Fa type
289can be set to
290.Dv MBSTRING_ASC ,
291but in the case of
292.Fn X509_NAME_ENTRY_set_data
293the field type must be set first so the relevant field information
294can be looked up internally.
295.Sh RETURN VALUES
296The
297.Fn X509_NAME_ENTRY_new
298function returns a valid
299.Vt X509_NAME_ENTRY
300structure if successful; otherwise
301.Dv NULL
302is returned and an error code can be retrieved with
303.Xr ERR_get_error 3 .
304.Pp
305.Fn X509_NAME_ENTRY_get_object
306returns a valid
307.Vt ASN1_OBJECT
308structure if it is set or
309.Dv NULL
310if an error occurred.
311.Pp
312.Fn X509_NAME_ENTRY_get_data
313returns a valid
314.Vt ASN1_STRING
315structure if it is set or
316.Dv NULL
317if an error occurred.
318.Pp
319.Fn X509_NAME_ENTRY_set
320returns the zero-based index of the RDN
321.Fa ne
322is used in, or 0 if
323.Fa ne
324is not yet used by any
325.Vt X509_NAME
326object.
327.Pp
328The
329.Fn X509_NAME_ENTRY_set_object
330function returns 1 if successful;
331otherwise 0 is returned and an error code can be retrieved with
332.Xr ERR_get_error 3 .
333.Pp
334.Fn X509_NAME_ENTRY_set_data
335returns 1 on success or 0 on error.
336In some cases of failure, the reason can be determined with
337.Xr ERR_get_error 3 .
338.Pp
339.Fn X509_NAME_ENTRY_create_by_txt ,
340.Fn X509_NAME_ENTRY_create_by_NID ,
341and
342.Fn X509_NAME_ENTRY_create_by_OBJ
343return a valid
344.Vt X509_NAME_ENTRY
345structure on success or
346.Dv NULL
347if an error occurred.
348In some cases of failure, the reason can be determined with
349.Xr ERR_get_error 3 .
350.Sh SEE ALSO
351.Xr OBJ_nid2obj 3 ,
352.Xr X509_NAME_add_entry 3 ,
353.Xr X509_NAME_get_entry 3 ,
354.Xr X509_NAME_new 3
355.Sh STANDARDS
356RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
357Certificate Revocation List (CRL) Profile
358.Pp
359ITU-T Recommendation X.501, also known as ISO/IEC 9594-2: Information
360Technology Open Systems Interconnection The Directory: Models,
361section 9.3: Relative distinguished name
362.Sh HISTORY
363.Fn X509_NAME_ENTRY_new
364and
365.Fn X509_NAME_ENTRY_free
366first appeared in SSLeay 0.5.1.
367.Fn X509_NAME_ENTRY_get_object ,
368.Fn X509_NAME_ENTRY_get_data ,
369.Fn X509_NAME_ENTRY_set_object ,
370.Fn X509_NAME_ENTRY_set_data ,
371.Fn X509_NAME_ENTRY_create_by_NID ,
372and
373.Fn X509_NAME_ENTRY_create_by_OBJ
374first appeared in SSLeay 0.8.0.
375These functions have been available since
376.Ox 2.4 .
377.Pp
378.Fn X509_NAME_ENTRY_create_by_txt
379first appeared in OpenSSL 0.9.5 and has been available since
380.Ox 2.7 .
381.Pp
382.Fn X509_NAME_ENTRY_set
383first appeared in OpenSSL 1.1.0 and has been available since
384.Ox 6.3 .
385.Sh CAVEATS
386Despite its name,
387.Fn X509_NAME_ENTRY_set
388does not set anything.
389Something like
390.Dq X509_NAME_ENTRY_get_set
391would have been a better name.
diff --git a/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3 b/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3
deleted file mode 100644
index 3c1237d20e..0000000000
--- a/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3
+++ /dev/null
@@ -1,283 +0,0 @@
1.\" $OpenBSD: X509_NAME_add_entry_by_txt.3,v 1.16 2022/03/31 17:27:17 naddy Exp $
2.\" OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2005, 2006, 2013, 2014 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: March 31 2022 $
53.Dt X509_NAME_ADD_ENTRY_BY_TXT 3
54.Os
55.Sh NAME
56.Nm X509_NAME_add_entry_by_txt ,
57.Nm X509_NAME_add_entry_by_OBJ ,
58.Nm X509_NAME_add_entry_by_NID ,
59.Nm X509_NAME_add_entry ,
60.Nm X509_NAME_delete_entry
61.Nd X509_NAME modification functions
62.Sh SYNOPSIS
63.In openssl/x509.h
64.Ft int
65.Fo X509_NAME_add_entry_by_txt
66.Fa "X509_NAME *name"
67.Fa "const char *field"
68.Fa "int type"
69.Fa "const unsigned char *bytes"
70.Fa "int len"
71.Fa "int loc"
72.Fa "int set"
73.Fc
74.Ft int
75.Fo X509_NAME_add_entry_by_OBJ
76.Fa "X509_NAME *name"
77.Fa "const ASN1_OBJECT *obj"
78.Fa "int type"
79.Fa "const unsigned char *bytes"
80.Fa "int len"
81.Fa "int loc"
82.Fa "int set"
83.Fc
84.Ft int
85.Fo X509_NAME_add_entry_by_NID
86.Fa "X509_NAME *name"
87.Fa "int nid"
88.Fa "int type"
89.Fa "const unsigned char *bytes"
90.Fa "int len"
91.Fa "int loc"
92.Fa "int set"
93.Fc
94.Ft int
95.Fo X509_NAME_add_entry
96.Fa "X509_NAME *name"
97.Fa "const X509_NAME_ENTRY *ne"
98.Fa "int loc"
99.Fa "int set"
100.Fc
101.Ft X509_NAME_ENTRY *
102.Fo X509_NAME_delete_entry
103.Fa "X509_NAME *name"
104.Fa "int loc"
105.Fc
106.Sh DESCRIPTION
107.Fn X509_NAME_add_entry_by_txt ,
108.Fn X509_NAME_add_entry_by_OBJ ,
109and
110.Fn X509_NAME_add_entry_by_NID
111add a field whose name is defined by a string
112.Fa field ,
113an object
114.Fa obj
115or a NID
116.Fa nid ,
117respectively.
118The field value to be added is in
119.Fa bytes
120of length
121.Fa len .
122If
123.Fa len
124is -1 then the field length is calculated internally using
125.Fn strlen bytes .
126.Pp
127The type of field is determined by
128.Fa type
129which can either be a definition of the type of
130.Fa bytes
131(such as
132.Dv MBSTRING_ASC )
133or a standard ASN.1 type (such as
134.Dv V_ASN1_IA5STRING ) .
135The new entry is added to a position determined by
136.Fa loc
137and
138.Fa set .
139.Pp
140.Fn X509_NAME_add_entry
141adds a copy of an
142.Vt X509_NAME_ENTRY
143structure
144.Fa ne
145to
146.Fa name .
147The new entry is added to a position determined by
148.Fa loc
149and
150.Fa set .
151Since a copy of
152.Fa ne
153is added,
154.Fa ne
155must be freed up after the call.
156.Pp
157.Fn X509_NAME_delete_entry
158deletes an entry from
159.Fa name
160at position
161.Fa loc .
162The deleted entry is returned and must be freed up.
163.Pp
164The use of string types such as
165.Dv MBSTRING_ASC
166or
167.Dv MBSTRING_UTF8
168is strongly recommended for the
169.Fa type
170parameter.
171This allows the internal code to correctly determine the type of the
172field and to apply length checks according to the relevant standards.
173.Pp
174If instead an ASN.1 type is used, no checks are performed and the supplied
175data in
176.Fa bytes
177is used directly.
178.Pp
179In
180.Fn X509_NAME_add_entry_by_txt
181the
182.Fa field
183string represents the field name using
184.Fn OBJ_txt2obj field 0 .
185.Pp
186The
187.Fa loc
188and
189.Fa set
190parameters determine where a new entry should be added.
191For almost all applications,
192.Fa loc
193can be set to -1 and
194.Fa set
195to 0.
196This adds a new entry to the end of
197.Fa name
198as a single valued
199.Vt RelativeDistinguishedName
200(RDN).
201.Pp
202.Fa loc
203actually determines the index where the new entry is inserted:
204if it is -1 it is appended.
205.Pp
206.Fa set
207determines how the new type is added.
208If it is zero, a new RDN is created.
209.Pp
210If
211.Fa set
212is -1 or 1, it is added to the previous or next RDN structure
213respectively.
214This will then be a multivalued RDN: since multivalue RDNs are very
215seldom used,
216.Fa set
217is almost always set to zero.
218.Sh RETURN VALUES
219.Fn X509_NAME_add_entry_by_txt ,
220.Fn X509_NAME_add_entry_by_OBJ ,
221.Fn X509_NAME_add_entry_by_NID ,
222and
223.Fn X509_NAME_add_entry
224return 1 for success or 0 if an error occurred.
225.Pp
226.Fn X509_NAME_delete_entry
227returns either the deleted
228.Vt X509_NAME_ENTRY
229structure or
230.Dv NULL
231if an error occurred.
232.Pp
233In some cases of failure, the reason can be determined with
234.Xr ERR_get_error 3 .
235.Sh EXAMPLES
236Create an
237.Vt X509_NAME
238structure:
239.Bd -literal -offset indent
240C=UK, O=Disorganized Organization, CN=Joe Bloggs
241
242X509_NAME *nm;
243nm = X509_NAME_new();
244if (nm == NULL)
245 /* Some error */
246if (!X509_NAME_add_entry_by_txt(nm, "C", MBSTRING_ASC,
247 "UK", -1, -1, 0))
248 /* Error */
249if (!X509_NAME_add_entry_by_txt(nm, "O", MBSTRING_ASC,
250 "Disorganized Organization", -1, -1, 0))
251 /* Error */
252if (!X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC,
253 "Joe Bloggs", -1, -1, 0))
254 /* Error */
255.Ed
256.Sh SEE ALSO
257.Xr d2i_X509_NAME 3 ,
258.Xr X509_NAME_ENTRY_get_object 3 ,
259.Xr X509_NAME_get_index_by_NID 3 ,
260.Xr X509_NAME_new 3
261.Sh HISTORY
262.Fn X509_NAME_add_entry
263and
264.Fn X509_NAME_delete_entry
265first appeared in SSLeay 0.8.0 and have been available since
266.Ox 2.4 .
267.Pp
268.Fn X509_NAME_add_entry_by_txt ,
269.Fn X509_NAME_add_entry_by_OBJ ,
270and
271.Fn X509_NAME_add_entry_by_NID
272first appeared in OpenSSL 0.9.5 and have been available since
273.Ox 2.7 .
274.Sh BUGS
275.Fa type
276can still be set to
277.Dv V_ASN1_APP_CHOOSE
278to use
279.Xr ASN1_PRINTABLE_type 3
280to determine field types.
281Since this form does not understand multicharacter types, performs
282no length checks, and can result in invalid field types, its use
283is strongly discouraged.
diff --git a/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3 b/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3
deleted file mode 100644
index a2ceb10eb5..0000000000
--- a/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3
+++ /dev/null
@@ -1,265 +0,0 @@
1.\" $OpenBSD: X509_NAME_get_index_by_NID.3,v 1.16 2023/05/29 11:54:50 beck Exp $
2.\" OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2006, 2014, 2015, 2016 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: May 29 2023 $
53.Dt X509_NAME_GET_INDEX_BY_NID 3
54.Os
55.Sh NAME
56.Nm X509_NAME_get_index_by_NID ,
57.Nm X509_NAME_get_index_by_OBJ ,
58.Nm X509_NAME_entry_count ,
59.Nm X509_NAME_get_entry ,
60.Nm X509_NAME_get_text_by_NID ,
61.Nm X509_NAME_get_text_by_OBJ
62.Nd X509_NAME lookup and enumeration functions
63.Sh SYNOPSIS
64.In openssl/x509.h
65.Ft int
66.Fo X509_NAME_get_index_by_NID
67.Fa "const X509_NAME *name"
68.Fa "int nid"
69.Fa "int lastpos"
70.Fc
71.Ft int
72.Fo X509_NAME_get_index_by_OBJ
73.Fa "const X509_NAME *name"
74.Fa "const ASN1_OBJECT *obj"
75.Fa "int lastpos"
76.Fc
77.Ft int
78.Fo X509_NAME_entry_count
79.Fa "const X509_NAME *name"
80.Fc
81.Ft X509_NAME_ENTRY *
82.Fo X509_NAME_get_entry
83.Fa "const X509_NAME *name"
84.Fa "int loc"
85.Fc
86.Ft int
87.Fo X509_NAME_get_text_by_NID
88.Fa "X509_NAME *name"
89.Fa "int nid"
90.Fa "char *buf"
91.Fa "int len"
92.Fc
93.Ft int
94.Fo X509_NAME_get_text_by_OBJ
95.Fa "X509_NAME *name"
96.Fa "const ASN1_OBJECT *obj"
97.Fa "char *buf"
98.Fa "int len"
99.Fc
100.Sh DESCRIPTION
101These functions allow an
102.Vt X509_NAME
103structure to be examined.
104The
105.Vt X509_NAME
106structure is the same as the ASN.1
107.Vt Name
108type defined in RFC 2459 (and elsewhere) and used, for example,
109in certificate subject and issuer names.
110.Pp
111.Fn X509_NAME_get_index_by_NID
112and
113.Fn X509_NAME_get_index_by_OBJ
114retrieve the next index matching
115.Fa nid
116or
117.Fa obj
118after
119.Fa lastpos .
120.Fa lastpos
121should initially be set to -1.
122.Pp
123.Fn X509_NAME_get_entry
124retrieves the
125.Vt X509_NAME_ENTRY
126from
127.Fa name
128corresponding to index
129.Fa loc .
130Acceptable values for
131.Fa loc
132run from 0 to
133.Fn X509_NAME_entry_count name
134- 1.
135.Pp
136.Fn X509_NAME_get_text_by_NID
137and
138.Fn X509_NAME_get_text_by_OBJ
139retrieve the bytes encoded as UTF-8 from the first entry in
140.Fa name
141which matches
142.Fa nid
143or
144.Fa obj .
145If
146.Fa buf
147is
148.Dv NULL ,
149nothing is written, but the return value is calculated as usual.
150If
151.Fa buf
152is not
153.Dv NULL ,
154no more than
155.Fa len
156bytes will be written and the text written to
157.Fa buf
158will be NUL terminated.
159.Pp
160If
161.Fa len
162is not large enough to hold the NUL byte terminated UTF-8 encoding of
163the text, or if the UTF-8 encoding of the text would contains a NUL
164byte, no data will be written and the call will return failure.
165.Pp
166All relevant
167.Dv NID_*
168and
169.Dv OBJ_*
170codes can be found in the
171.In openssl/objects.h
172header file.
173.Pp
174Applications which could pass invalid NIDs to
175.Fn X509_NAME_get_index_by_NID
176should check for the return value of -2.
177Alternatively the NID validity can be determined first by checking that
178.Fn OBJ_nid2obj nid
179is not
180.Dv NULL .
181.Sh RETURN VALUES
182.Fn X509_NAME_get_index_by_NID
183returns the index of the next matching entry, -1 if not found, or -2 if the
184.Fa nid
185does not correspond to a valid OID.
186.Pp
187.Fn X509_NAME_get_index_by_OBJ
188returns the index of the next matching entry or -1 if not found.
189.Pp
190.Fn X509_NAME_entry_count
191returns the total number of entries in
192.Fa name .
193.Pp
194.Fn X509_NAME_get_entry
195returns an internal pointer which must not be freed by the caller or
196.Dv NULL
197if the index is invalid.
198.Pp
199.Fn X509_NAME_get_text_by_NID
200and
201.Fn X509_NAME_get_text_by_OBJ
202return the length of the output UTF-8 string written, not counting the
203terminating NUL, or -1 in the case of an error or no match being found.
204.Pp
205In some cases of failure of
206.Fn X509_NAME_get_index_by_NID
207and
208.Fn X509_NAME_get_text_by_NID ,
209the reason can be determined with
210.Xr ERR_get_error 3 .
211.Sh EXAMPLES
212Process all entries:
213.Bd -literal
214int i;
215X509_NAME_ENTRY *e;
216
217for (i = 0; i < X509_NAME_entry_count(nm); i++) {
218 e = X509_NAME_get_entry(nm, i);
219 /* Do something with e */
220}
221.Ed
222.Pp
223Process all commonName entries:
224.Bd -literal
225int lastpos = -1;
226X509_NAME_ENTRY *e;
227
228for (;;) {
229 lastpos = X509_NAME_get_index_by_NID(nm, NID_commonName, lastpos);
230 if (lastpos == -1)
231 break;
232 e = X509_NAME_get_entry(nm, lastpos);
233 /* Do something with e */
234}
235.Ed
236.Sh SEE ALSO
237.Xr d2i_X509_NAME 3 ,
238.Xr X509_NAME_ENTRY_get_object 3 ,
239.Xr X509_NAME_new 3
240.Sh HISTORY
241These functions first appeared in SSLeay 0.8.0
242and have been available since
243.Ox 2.4 .
244.Sh CAVEATS
245.Fn X509_NAME_get_text_by_NID
246and
247.Fn X509_NAME_get_text_by_OBJ
248are legacy functions which have various limitations which make them of
249minimal use in practice.
250They can only find the first matching entry and will copy the contents
251of the field verbatim: this can be highly confusing if the target is a
252multicharacter string type like a
253.Vt BMPString
254or a
255.Vt UTF8String .
256.Pp
257For a more general solution,
258.Fn X509_NAME_get_index_by_NID
259or
260.Fn X509_NAME_get_index_by_OBJ
261should be used, followed by
262.Fn X509_NAME_get_entry
263on any matching indices and then the various
264.Vt X509_NAME_ENTRY
265utility functions on the result.
diff --git a/src/lib/libcrypto/man/X509_NAME_hash.3 b/src/lib/libcrypto/man/X509_NAME_hash.3
deleted file mode 100644
index 8766109525..0000000000
--- a/src/lib/libcrypto/man/X509_NAME_hash.3
+++ /dev/null
@@ -1,97 +0,0 @@
1.\" $OpenBSD: X509_NAME_hash.3,v 1.3 2021/07/31 14:54:33 schwarze Exp $
2.\"
3.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 31 2021 $
18.Dt X509_NAME_HASH 3
19.Os
20.Sh NAME
21.Nm X509_NAME_hash ,
22.Nm X509_issuer_name_hash ,
23.Nm X509_subject_name_hash ,
24.\" X509_issuer_and_serial_hash() is intentionally undocumented
25.\" because it uses MD5 only and is unused in real-world code.
26.Nm X509_NAME_hash_old ,
27.Nm X509_issuer_name_hash_old ,
28.Nm X509_subject_name_hash_old
29.\" In the following line, "X.501" and "Name" are not typos.
30.\" The "Name" type is defined in X.501, not in X.509.
31.\" The type is called "Name" with capital "N", not "name".
32.Nd calculate SHA-1 or MD5 hashes of X.501 Name objects
33.Sh SYNOPSIS
34.In openssl/x509.h
35.Ft unsigned long
36.Fn X509_NAME_hash "X509_NAME *name"
37.Ft unsigned long
38.Fn X509_issuer_name_hash "X509 *x"
39.Ft unsigned long
40.Fn X509_subject_name_hash "X509 *x"
41.Ft unsigned long
42.Fn X509_NAME_hash_old "X509_NAME *name"
43.Ft unsigned long
44.Fn X509_issuer_name_hash_old "X509 *x"
45.Ft unsigned long
46.Fn X509_subject_name_hash_old "X509 *x"
47.Sh DESCRIPTION
48.Fn X509_NAME_hash
49calculates an
50.Xr SHA1 3
51hash of the DER-encoded form of
52.Fa name .
53It is for example used by
54.Xr X509_LOOKUP_hash_dir 3
55to locate certificate files in the file system.
56.Pp
57.Fn X509_issuer_name_hash
58and
59.Fn X509_subject_name_hash
60are wrappers to calculate this hash of the issuer or subject name of
61.Fa x ,
62respectively.
63.Pp
64.Fn X509_NAME_hash_old ,
65.Fn X509_issuer_name_hash_old ,
66and
67.Fn X509_subject_name_hash_old
68are variants that use MD5 instead of SHA-1.
69.Sh RETURN VALUES
70These functions return the hash value or 0 if an error occurs.
71.Sh SEE ALSO
72.Xr i2d_X509_NAME 3 ,
73.Xr X509_get_subject_name 3 ,
74.Xr X509_LOOKUP_new 3 ,
75.Xr X509_NAME_digest 3 ,
76.Xr X509_NAME_new 3
77.Sh HISTORY
78.Fn X509_subject_name_hash
79first appeared in SSLeay 0.4.0,
80.Fn X509_issuer_name_hash
81in SSLeay 0.5.1, and
82.Fn X509_NAME_hash
83in SSLeay 0.8.0.
84They were switched to hashing the DER representation of the name
85rather than an ASCII rendering in SSLeay 0.9.0 and have all been
86available since
87.Ox 2.4 .
88.Pp
89They were switched to using SHA1 instead of MD5 in OpenSSL 1.0.0 and in
90.Ox 4.9 .
91.Pp
92.Fn X509_NAME_hash_old ,
93.Fn X509_issuer_name_hash_old ,
94and
95.Fn X509_subject_name_hash_old
96first appeared in OpenSSL 1.0.0 and have been available since
97.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/X509_NAME_new.3 b/src/lib/libcrypto/man/X509_NAME_new.3
deleted file mode 100644
index 3a4786a9ae..0000000000
--- a/src/lib/libcrypto/man/X509_NAME_new.3
+++ /dev/null
@@ -1,103 +0,0 @@
1.\" $OpenBSD: X509_NAME_new.3,v 1.9 2021/07/20 17:31:32 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 20 2021 $
18.Dt X509_NAME_NEW 3
19.Os
20.Sh NAME
21.Nm X509_NAME_new ,
22.Nm X509_NAME_free
23.\" In the following line, "X.501" and "Name" are not typos.
24.\" The "Name" type is defined in X.501, not in X.509.
25.\" The type in called "Name" with capital "N", not "name".
26.Nd X.501 Name object
27.Sh SYNOPSIS
28.In openssl/x509.h
29.Ft X509_NAME *
30.Fn X509_NAME_new void
31.Ft void
32.Fn X509_NAME_free "X509_NAME *name"
33.Sh DESCRIPTION
34An X.501
35.Vt Name
36is an ordered sequence of relative distinguished names.
37A relative distinguished name is a set of key-value pairs; see
38.Xr X509_NAME_ENTRY_new 3
39for details.
40.Pp
41Various X.509 structures contain X.501
42.Vt Name
43substructures.
44They are for example used for the issuers of certificates and
45certificate revocation lists and for the subjects of certificates
46and certificate requests.
47.Pp
48.Fn X509_NAME_new
49allocates and initializes an empty
50.Vt X509_NAME
51object, representing an ASN.1
52.Vt Name
53structure defined in RFC 5280 section 4.1.2.4.
54Data can be added to such objects with the functions described in
55.Xr X509_NAME_add_entry_by_txt 3 ,
56and they can be inspected with the functions described in
57.Xr X509_NAME_get_index_by_NID 3 .
58.Pp
59.Fn X509_NAME_free
60frees
61.Fa name
62and all the
63.Vt X509_NAME_ENTRY
64objects contained in it.
65If
66.Fa name
67is a
68.Dv NULL
69pointer, no action occurs.
70.Sh RETURN VALUES
71.Fn X509_NAME_new
72returns a new
73.Vt X509_NAME
74object or
75.Dv NULL
76if an error occurred.
77.Sh SEE ALSO
78.Xr d2i_X509_NAME 3 ,
79.Xr GENERAL_NAME_new 3 ,
80.Xr NAME_CONSTRAINTS_new 3 ,
81.Xr SSL_load_client_CA_file 3 ,
82.Xr X509_get_subject_name 3 ,
83.Xr X509_NAME_add_entry_by_txt 3 ,
84.Xr X509_NAME_cmp 3 ,
85.Xr X509_NAME_digest 3 ,
86.Xr X509_NAME_ENTRY_new 3 ,
87.Xr X509_NAME_get_index_by_NID 3 ,
88.Xr X509_NAME_hash 3 ,
89.Xr X509_NAME_print_ex 3 ,
90.Xr X509_new 3
91.Sh STANDARDS
92RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
93Certificate Revocation List (CRL) Profile
94.Pp
95ITU-T Recommendation X.501, also known as ISO/IEC 9594-2:
96Information Technology \(en Open Systems Interconnection \(en
97The Directory: Models, section 9: Names
98.Sh HISTORY
99.Fn X509_NAME_new
100and
101.Fn X509_NAME_free
102appeared in SSLeay 0.4 or earlier and have been available since
103.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/X509_NAME_print_ex.3 b/src/lib/libcrypto/man/X509_NAME_print_ex.3
deleted file mode 100644
index fc06a717cc..0000000000
--- a/src/lib/libcrypto/man/X509_NAME_print_ex.3
+++ /dev/null
@@ -1,260 +0,0 @@
1.\" $OpenBSD: X509_NAME_print_ex.3,v 1.17 2025/03/09 16:45:31 tb Exp $
2.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2002, 2004, 2007, 2016, 2017 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: March 9 2025 $
54.Dt X509_NAME_PRINT_EX 3
55.Os
56.Sh NAME
57.Nm X509_NAME_print_ex ,
58.Nm X509_NAME_print_ex_fp ,
59.Nm X509_NAME_oneline
60.Nd X509_NAME printing routines
61.Sh SYNOPSIS
62.In openssl/x509.h
63.Ft int
64.Fo X509_NAME_print_ex
65.Fa "BIO *out"
66.Fa "const X509_NAME *nm"
67.Fa "int indent"
68.Fa "unsigned long flags"
69.Fc
70.Ft int
71.Fo X509_NAME_print_ex_fp
72.Fa "FILE *fp"
73.Fa "const X509_NAME *nm"
74.Fa "int indent"
75.Fa "unsigned long flags"
76.Fc
77.Ft char *
78.Fo X509_NAME_oneline
79.Fa "const X509_NAME *a"
80.Fa "char *buf"
81.Fa "int size"
82.Fc
83.Sh DESCRIPTION
84.Fn X509_NAME_print_ex
85prints a human readable version of
86.Fa nm
87to
88.Vt BIO
89.Fa out .
90Each line (for multiline formats) is indented by
91.Fa indent
92spaces.
93The output format can be extensively customised by use of the
94.Fa flags
95parameter.
96.Pp
97.Fn X509_NAME_print_ex_fp
98is identical to
99.Fn X509_NAME_print_ex
100except the output is written to the
101.Vt FILE
102pointer
103.Fa fp .
104.Pp
105.Fn X509_NAME_oneline
106prints an ASCII version of
107.Fa a
108to
109.Fa buf .
110If
111.Fa buf
112is
113.Dv NULL ,
114then a buffer is dynamically allocated and returned, and
115.Fa size
116is ignored.
117Otherwise, at most
118.Fa size
119bytes will be written, including the ending NUL, and
120.Fa buf
121is returned.
122.Pp
123.Fn X509_NAME_oneline
124is a legacy function which produces a non-standard output form.
125It doesn't handle multi-character fields and has various quirks
126and inconsistencies.
127Its use is strongly discouraged in new applications.
128.Pp
129Although there are a large number of possible flags, for most purposes
130.Dv XN_FLAG_ONELINE ,
131.Dv XN_FLAG_MULTILINE ,
132or
133.Dv XN_FLAG_RFC2253
134will suffice.
135As noted on the
136.Xr ASN1_STRING_print_ex 3
137manual page, for UTF-8 terminals the
138.Dv ASN1_STRFLGS_ESC_MSB
139should be unset: so for example
140.Dv XN_FLAG_ONELINE No & Pf ~ Dv ASN1_STRFLGS_ESC_MSB
141would be used.
142.Pp
143The complete set of the flags supported by
144.Dv X509_NAME_print_ex
145is listed below.
146.Pp
147Several options can be OR'ed together.
148.Pp
149The options
150.Dv XN_FLAG_SEP_COMMA_PLUS ,
151.Dv XN_FLAG_SEP_CPLUS_SPC ,
152.Dv XN_FLAG_SEP_SPLUS_SPC ,
153and
154.Dv XN_FLAG_SEP_MULTILINE
155determine the field separators to use.
156Two distinct separators are used between distinct
157.Vt RelativeDistinguishedName
158components and separate values in the same RDN for a multi-valued RDN.
159Multi-valued RDNs are currently very rare so the second separator
160will hardly ever be used.
161.Pp
162.Dv XN_FLAG_SEP_COMMA_PLUS
163uses comma and plus as separators.
164.Dv XN_FLAG_SEP_CPLUS_SPC
165uses comma and plus with spaces:
166this is more readable that plain comma and plus.
167.Dv XN_FLAG_SEP_SPLUS_SPC
168uses spaced semicolon and plus.
169.Dv XN_FLAG_SEP_MULTILINE
170uses spaced newline and plus respectively.
171.Dv XN_FLAG_SEP_MASK
172contains the bits used to represent these four options.
173.Pp
174If
175.Dv XN_FLAG_DN_REV
176is set, the whole DN is printed in reversed order.
177.Pp
178The fields
179.Dv XN_FLAG_FN_SN ,
180.Dv XN_FLAG_FN_LN ,
181.Dv XN_FLAG_FN_OID ,
182and
183.Dv XN_FLAG_FN_NONE
184determine how a field name is displayed.
185It will use the short name (e.g. CN), the long name (e.g. commonName),
186always use OID numerical form (normally OIDs are only used if the
187field name is not recognised) and no field name, respectively.
188.Dv XN_FLAG_FN_MASK
189contains the bits used to represent these four options.
190.Pp
191If
192.Dv XN_FLAG_SPC_EQ
193is set, then spaces will be placed around the
194.Ql =
195character separating field names and values.
196.Pp
197If
198.Dv XN_FLAG_DUMP_UNKNOWN_FIELDS
199is set, then the encoding of unknown fields is printed instead of the
200values.
201.Pp
202If
203.Dv XN_FLAG_FN_ALIGN
204is set, then field names are padded to 20 characters:
205this is only of use for multiline format.
206.Pp
207Additionally, all the options supported by
208.Xr ASN1_STRING_print_ex 3
209can be used to control how each field value is displayed.
210.Pp
211In addition a number of options can be set for commonly used formats.
212.Pp
213.Dv XN_FLAG_RFC2253
214sets options which produce an output compatible with RFC 2253.
215It is equivalent to
216.Dv ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS | XN_FLAG_DN_REV |
217.Dv XN_FLAG_FN_SN | XN_FLAG_DUMP_UNKNOWN_FIELDS .
218.Pp
219.Dv XN_FLAG_ONELINE
220is a more readable one line format which is the same as:
221.Dv ASN1_STRFLGS_RFC2253 | ASN1_STRFLGS_ESC_QUOTE | XN_FLAG_SEP_CPLUS_SPC |
222.Dv XN_FLAG_SPC_EQ | XN_FLAG_FN_SN .
223.Pp
224.Dv XN_FLAG_MULTILINE
225is a multiline format which is the same as:
226.Dv ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | XN_FLAG_SEP_MULTILINE |
227.Dv XN_FLAG_SPC_EQ | XN_FLAG_FN_LN | XN_FLAG_FN_ALIGN .
228.Pp
229.Dv XN_FLAG_COMPAT
230uses the traditional non-standard SSLeay format.
231.Sh RETURN VALUES
232.Fn X509_NAME_print_ex
233and
234.Fn X509_NAME_print_ex_fp
235return 1 on success or 0 on error if
236.Dv XN_FLAG_COMPAT
237is set in
238.Fa flags .
239Otherwise, they return the number of printed bytes including the
240indentation or \-1 on error.
241.Pp
242.Fn X509_NAME_oneline
243returns a valid string on success or
244.Dv NULL
245on error.
246.Sh SEE ALSO
247.Xr ASN1_STRING_print_ex 3 ,
248.Xr d2i_X509_NAME 3 ,
249.Xr X509_NAME_get_index_by_NID 3 ,
250.Xr X509_NAME_new 3
251.Sh HISTORY
252.Fn X509_NAME_oneline
253first appeared in SSLeay 0.5.1 and has been available since
254.Ox 2.4 .
255.Pp
256.Fn X509_NAME_print_ex
257and
258.Fn X509_NAME_print_ex_fp
259first appeared in OpenSSL 0.9.6 and have been available since
260.Ox 2.9 .
diff --git a/src/lib/libcrypto/man/X509_OBJECT_get0_X509.3 b/src/lib/libcrypto/man/X509_OBJECT_get0_X509.3
deleted file mode 100644
index 56b3926a8b..0000000000
--- a/src/lib/libcrypto/man/X509_OBJECT_get0_X509.3
+++ /dev/null
@@ -1,252 +0,0 @@
1.\" $OpenBSD: X509_OBJECT_get0_X509.3,v 1.16 2025/03/08 17:02:59 tb Exp $
2.\"
3.\" Copyright (c) 2018, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 8 2025 $
18.Dt X509_OBJECT_GET0_X509 3
19.Os
20.Sh NAME
21.Nm X509_OBJECT_get_type ,
22.Nm X509_OBJECT_new ,
23.Nm X509_OBJECT_free ,
24.Nm X509_OBJECT_get0_X509 ,
25.Nm X509_OBJECT_get0_X509_CRL ,
26.Nm X509_OBJECT_idx_by_subject ,
27.Nm X509_OBJECT_retrieve_by_subject ,
28.Nm X509_OBJECT_retrieve_match
29.Nd certificate, CRL, private key, and string wrapper for certificate stores
30.Sh SYNOPSIS
31.In openssl/x509_vfy.h
32.Ft X509_LOOKUP_TYPE
33.Fo X509_OBJECT_get_type
34.Fa "const X509_OBJECT *obj"
35.Fc
36.Ft X509_OBJECT *
37.Fo X509_OBJECT_new
38.Fa void
39.Fc
40.Ft void
41.Fo X509_OBJECT_free
42.Fa "X509_OBJECT *obj"
43.Fc
44.Ft X509 *
45.Fo X509_OBJECT_get0_X509
46.Fa "const X509_OBJECT *obj"
47.Fc
48.Ft X509_CRL *
49.Fo X509_OBJECT_get0_X509_CRL
50.Fa "X509_OBJECT *obj"
51.Fc
52.Ft int
53.Fo X509_OBJECT_idx_by_subject
54.Fa "STACK_OF(X509_OBJECT) *stack"
55.Fa "X509_LOOKUP_TYPE type"
56.Fa "X509_NAME *name"
57.Fc
58.Ft X509_OBJECT *
59.Fo X509_OBJECT_retrieve_by_subject
60.Fa "STACK_OF(X509_OBJECT) *stack"
61.Fa "X509_LOOKUP_TYPE type"
62.Fa "X509_NAME *name"
63.Fc
64.Ft X509_OBJECT *
65.Fo X509_OBJECT_retrieve_match
66.Fa "STACK_OF(X509_OBJECT) *stack"
67.Fa "X509_OBJECT *obj"
68.Fc
69.Sh DESCRIPTION
70The
71.Vt X509_OBJECT
72structure is a shallow wrapper around one
73.Vt X509
74certificate object or one
75.Vt X509_CRL
76certificate revocation list object.
77The type of object stored at any given time can be inspected with
78.Fn X509_OBJECT_get_type .
79.Pp
80Each
81.Vt X509_STORE
82object uses one stack of
83.Vt X509_OBJECT
84structures as its main storage area.
85.Pp
86.Fn X509_OBJECT_new
87allocates a new
88.Vt X509_OBJECT
89structure.
90It sets the object type to
91.Dv X509_LU_NONE
92and the pointer to the certificate or CRL to
93.Dv NULL .
94.Pp
95If
96.Fa obj
97contains an
98.Vt X509
99certificate,
100.Fn X509_OBJECT_free
101calls
102.Xr X509_free 3
103on that inner object.
104If
105.Fa obj
106contains an
107.Vt X509_CRL
108certificate revocation list, it calls
109.Xr X509_CRL_free 3
110on that inner list.
111.Fn X509_OBJECT_free
112then frees the storage used for the
113.Fa obj
114itself.
115.Pp
116If
117.Fa type
118is
119.Dv X509_LU_X509 ,
120.Fn X509_OBJECT_idx_by_subject
121and
122.Fn X509_OBJECT_retrieve_by_subject
123search the given
124.Fa stack
125for a certificate with the subject
126.Fa name .
127If
128.Fa type
129is
130.Dv X509_LU_CRL ,
131they search for a certificate revocation list with the issuer
132.Fa name
133instead.
134.Pp
135If
136.Fa obj
137contains a certificate,
138.Fn X509_OBJECT_retrieve_match
139searches the given
140.Fa stack
141for a certificate with a matching subject name;
142if it contains a certificate revocation list, it searches for a
143certificate revocation list with a matching issuer name instead;
144otherwise, it searches for an
145.Vt X509_OBJECT
146with a matching type.
147.Sh RETURN VALUES
148.Fn X509_OBJECT_get_type
149returns
150.Dv X509_LU_X509
151if
152.Fa obj
153contains a certificate,
154.Dv X509_LU_CRL
155if it contains a certificate revocation list, or
156.Dv X509_LU_NONE
157if it contains neither.
158.Pp
159.Fn X509_OBJECT_new
160returns the new object or
161.Dv NULL
162if memory allocation fails.
163.Pp
164.Fn X509_OBJECT_get0_X509
165returns an internal pointer to the certificate contained in
166.Fa obj
167or
168.Dv NULL
169if
170.Fa obj
171is
172.Dv NULL
173or contains no certificate.
174.Pp
175.Fn X509_OBJECT_get0_X509_CRL
176returns an internal pointer to the certificate revocation list contained in
177.Fa obj
178or
179.Dv NULL
180if
181.Fa obj
182is
183.Dv NULL
184or contains no certificate revocation list.
185.Pp
186.Fn X509_OBJECT_idx_by_subject
187returns the zero-based index of the first matching certificate
188or revocation list in the
189.Fa stack
190or \-1 if
191.Fa type
192is neither
193.Dv X509_LU_X509
194nor
195.Dv X509_LU_CRL
196or if no match is found.
197.Pp
198.Fn X509_OBJECT_retrieve_by_subject
199returns the first matching certificate or revocation list in the
200.Fa stack
201or
202.Dv NULL
203if
204.Fa type
205is neither
206.Dv X509_LU_X509
207nor
208.Dv X509_LU_CRL
209or if no match is found.
210.Pp
211.Fn X509_OBJECT_retrieve_match
212returns the first matching
213.Vt X509_OBJECT
214or
215.Dv NULL
216if
217.Fa stack
218or
219.Fa obj
220is
221.Dv NULL
222or no match is found.
223.Sh SEE ALSO
224.Xr STACK_OF 3 ,
225.Xr X509_CRL_new 3 ,
226.Xr X509_LOOKUP_new 3 ,
227.Xr X509_NAME_new 3 ,
228.Xr X509_new 3 ,
229.Xr X509_STORE_get0_objects 3 ,
230.Xr X509_STORE_get_by_subject 3 ,
231.Xr X509_STORE_load_locations 3 ,
232.Xr X509_STORE_new 3
233.Sh HISTORY
234.Fn X509_OBJECT_idx_by_subject ,
235.Fn X509_OBJECT_retrieve_by_subject ,
236and
237.Fn X509_OBJECT_retrieve_match
238first appeared in OpenSSL 0.9.6 and have been available since
239.Ox 2.9 .
240.Pp
241.Fn X509_OBJECT_get_type ,
242.Fn X509_OBJECT_get0_X509 ,
243and
244.Fn X509_OBJECT_get0_X509_CRL
245first appeared in OpenSSL 1.1.0 and have been available since
246.Ox 6.3 .
247.Pp
248.Fn X509_OBJECT_new
249and
250.Fn X509_OBJECT_free
251first appeared in OpenSSL 1.1.0 and have been available since
252.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/X509_PKEY_new.3 b/src/lib/libcrypto/man/X509_PKEY_new.3
deleted file mode 100644
index 253b0f6db5..0000000000
--- a/src/lib/libcrypto/man/X509_PKEY_new.3
+++ /dev/null
@@ -1,92 +0,0 @@
1.\" $OpenBSD: X509_PKEY_new.3,v 1.1 2021/10/19 10:39:33 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 19 2021 $
18.Dt X509_PKEY_NEW 3
19.Os
20.Sh NAME
21.Nm X509_PKEY_new ,
22.Nm X509_PKEY_free
23.Nd X.509 private key wrapper object
24.Sh SYNOPSIS
25.In openssl/x509.h
26.Ft X509_PKEY *
27.Fn X509_PKEY_new void
28.Ft void
29.Fn X509_PKEY_free "X509_PKEY *wrapper"
30.Sh DESCRIPTION
31.Vt X509_PKEY
32is a reference-counted wrapper object that can store
33.Bl -bullet -width 1n
34.It
35a pointer to an encrypted and ASN.1-encoded private key
36.It
37a pointer to an
38.Vt EVP_PKEY
39object representing the same key in decrypted form
40.It
41a pointer to an
42.Vt X509_ALGOR
43object identifying the algorithm used by the key
44.El
45.Pp
46The object may contain only the encrypted key or only the decrypted
47key or both.
48.Pp
49.Vt X509_PKEY
50is used as a sub-object of the
51.Vt X509_INFO
52object created by
53.Xr PEM_X509_INFO_read_bio 3
54if the PEM file contains any RSA, DSA, or EC PRIVATE KEY object.
55.Pp
56.Fn X509_PKEY_new
57allocates and initializes an empty
58.Vt X509_PKEY
59object and sets its reference count to 1.
60.Pp
61.Fn X509_PKEY_free
62decrements the reference count of the
63.Fa wrapper
64object by 1.
65If the reference count reaches 0,
66it frees all internal objects allocated by the
67.Fa wrapper
68as well as the storage needed for the
69.Fa wrapper
70object itself.
71If
72.Fa wrapper
73is a
74.Dv NULL
75pointer, no action occurs.
76.Sh RETURN VALUES
77.Fn X509_PKEY_new
78returns a pointer to the new
79.Vt X509_PKEY
80object or
81.Dv NULL
82if memory allocation fails.
83.Sh SEE ALSO
84.Xr EVP_PKEY_new 3 ,
85.Xr PEM_X509_INFO_read 3 ,
86.Xr X509_INFO_new 3
87.Sh HISTORY
88.Fn X509_PKEY_new
89and
90.Fn X509_PKEY_free
91first appeared in SSLeay 0.6.0 and have been available since
92.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/X509_PUBKEY_new.3 b/src/lib/libcrypto/man/X509_PUBKEY_new.3
deleted file mode 100644
index df1c50bda2..0000000000
--- a/src/lib/libcrypto/man/X509_PUBKEY_new.3
+++ /dev/null
@@ -1,401 +0,0 @@
1.\" $OpenBSD: X509_PUBKEY_new.3,v 1.18 2024/12/06 12:51:13 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2020, 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 6 2024 $
69.Dt X509_PUBKEY_NEW 3
70.Os
71.Sh NAME
72.Nm X509_PUBKEY_new ,
73.Nm X509_PUBKEY_free ,
74.Nm X509_PUBKEY_set ,
75.Nm X509_PUBKEY_get0 ,
76.Nm X509_PUBKEY_get ,
77.Nm d2i_X509_PUBKEY ,
78.Nm i2d_X509_PUBKEY ,
79.Nm d2i_PUBKEY ,
80.Nm i2d_PUBKEY ,
81.Nm d2i_PUBKEY_bio ,
82.Nm d2i_PUBKEY_fp ,
83.Nm i2d_PUBKEY_fp ,
84.Nm i2d_PUBKEY_bio ,
85.Nm X509_PUBKEY_set0_param ,
86.Nm X509_PUBKEY_get0_param
87.Nd X.509 SubjectPublicKeyInfo structure
88.Sh SYNOPSIS
89.In openssl/x509.h
90.Ft X509_PUBKEY *
91.Fn X509_PUBKEY_new void
92.Ft void
93.Fo X509_PUBKEY_free
94.Fa "X509_PUBKEY *a"
95.Fc
96.Ft int
97.Fo X509_PUBKEY_set
98.Fa "X509_PUBKEY **x"
99.Fa "EVP_PKEY *pkey"
100.Fc
101.Ft EVP_PKEY *
102.Fo X509_PUBKEY_get0
103.Fa "X509_PUBKEY *key"
104.Fc
105.Ft EVP_PKEY *
106.Fo X509_PUBKEY_get
107.Fa "X509_PUBKEY *key"
108.Fc
109.Ft X509_PUBKEY *
110.Fo d2i_X509_PUBKEY
111.Fa "X509_PUBKEY **val_out"
112.Fa "const unsigned char **der_in"
113.Fa "long length"
114.Fc
115.Ft int
116.Fo i2d_X509_PUBKEY
117.Fa "X509_PUBKEY *val_in"
118.Fa "unsigned char **der_out"
119.Fc
120.Ft EVP_PKEY *
121.Fo d2i_PUBKEY
122.Fa "EVP_PKEY **val_out"
123.Fa "const unsigned char **der_in"
124.Fa "long length"
125.Fc
126.Ft int
127.Fo i2d_PUBKEY
128.Fa "EVP_PKEY *val_in"
129.Fa "unsigned char **der_out"
130.Fc
131.Ft EVP_PKEY *
132.Fo d2i_PUBKEY_bio
133.Fa "BIO *bp"
134.Fa "EVP_PKEY **val_out"
135.Fc
136.Ft EVP_PKEY *
137.Fo d2i_PUBKEY_fp
138.Fa "FILE *fp"
139.Fa "EVP_PKEY **val_out"
140.Fc
141.Ft int
142.Fo i2d_PUBKEY_fp
143.Fa "FILE *fp"
144.Fa "EVP_PKEY *val_in"
145.Fc
146.Ft int
147.Fo i2d_PUBKEY_bio
148.Fa "BIO *bp"
149.Fa "EVP_PKEY *val_in"
150.Fc
151.Ft int
152.Fo X509_PUBKEY_set0_param
153.Fa "X509_PUBKEY *pub"
154.Fa "ASN1_OBJECT *aobj"
155.Fa "int ptype"
156.Fa "void *pval"
157.Fa "unsigned char *penc"
158.Fa "int penclen"
159.Fc
160.Ft int
161.Fo X509_PUBKEY_get0_param
162.Fa "ASN1_OBJECT **ppkalg"
163.Fa "const unsigned char **pk"
164.Fa "int *ppklen"
165.Fa "X509_ALGOR **pa"
166.Fa "X509_PUBKEY *pub"
167.Fc
168.Sh DESCRIPTION
169The
170.Vt X509_PUBKEY
171structure represents the ASN.1
172.Vt SubjectPublicKeyInfo
173structure defined in RFC 5280 section 4.1 and used in certificates
174and certificate requests.
175.Pp
176.Fn X509_PUBKEY_new
177allocates and initializes an
178.Vt X509_PUBKEY
179structure.
180.Pp
181.Fn X509_PUBKEY_free
182frees up the
183.Vt X509_PUBKEY
184structure
185.Fa a .
186If
187.Fa a
188is a
189.Dv NULL
190pointer, no action occurs.
191.Pp
192.Fn X509_PUBKEY_set
193sets the public key in
194.Pf * Fa x
195to the public key contained in the
196.Vt EVP_PKEY
197structure
198.Fa pkey .
199If
200.Pf * Fa x
201is not
202.Dv NULL ,
203any existing public key structure will be freed.
204.Pp
205.Fn X509_PUBKEY_get0
206returns the public key contained in
207.Fa key .
208The returned value is an internal pointer which must not be freed after use.
209.Pp
210.Fn X509_PUBKEY_get
211is similar to
212.Fn X509_PUBKEY_get0
213except that the reference
214count on the returned key is incremented so it must be freed using
215.Xr EVP_PKEY_free 3
216after use.
217.Pp
218.Fn d2i_X509_PUBKEY ,
219.Fn i2d_X509_PUBKEY ,
220.Fn d2i_PUBKEY ,
221and
222.Fn i2d_PUBKEY
223decode and encode an ASN.1
224.Vt SubjectPublicKeyInfo
225structure using either the
226.Vt X509_PUBKEY
227or the
228.Vt EVP_PKEY
229object type, respectively.
230For details about the semantics, examples, caveats, and bugs, see
231.Xr ASN1_item_d2i 3 .
232.Fn d2i_PUBKEY_bio ,
233.Fn d2i_PUBKEY_fp ,
234.Fn i2d_PUBKEY_bio
235and
236.Fn i2d_PUBKEY_fp
237are similar to
238.Fn d2i_PUBKEY
239and
240.Fn i2d_PUBKEY
241except they decode or encode using a
242.Vt BIO
243or
244.Vt FILE
245pointer.
246.Pp
247.Fn X509_PUBKEY_set0_param
248sets the public key parameters of
249.Fa pub .
250The OID associated with the algorithm is set to
251.Fa aobj .
252The type of the algorithm parameters is set to
253.Fa ptype
254using the structure
255.Fa pval .
256The encoding of the public key itself is set to the
257.Fa penclen
258bytes contained in buffer
259.Fa penc .
260On success ownership of all the supplied parameters is passed to
261.Fa pub
262so they must not be freed after the call.
263.Pp
264.Fn X509_PUBKEY_get0_param
265retrieves the public key parameters from
266.Fa pub ,
267.Pf * Fa ppkalg
268is set to the associated OID and the encoding consists of
269.Pf * Fa ppklen
270bytes at
271.Pf * Fa pk ,
272and
273.Pf * Fa pa
274is set to the associated
275.Vt AlgorithmIdentifier
276for the public key.
277If the value of any of these parameters is not required,
278it can be set to
279.Dv NULL .
280All of the retrieved pointers are internal and must not be freed after
281the call.
282.Sh RETURN VALUES
283If the allocation fails,
284.Fn X509_PUBKEY_new
285returns
286.Dv NULL
287and sets an error code that can be obtained by
288.Xr ERR_get_error 3 .
289Otherwise it returns a pointer to the newly allocated structure.
290.Pp
291.Fn X509_PUBKEY_get0
292returns an internal pointer or
293.Dv NULL
294if an error occurs.
295.Pp
296.Fn X509_PUBKEY_get
297returns a pointer to an object that had its reference count incremented or
298.Dv NULL
299if an error occurs.
300.Pp
301.Fn d2i_X509_PUBKEY ,
302.Fn d2i_PUBKEY ,
303.Fn d2i_PUBKEY_bio ,
304and
305.Fn d2i_PUBKEY_fp
306return a pointer to a valid object or
307.Dv NULL
308if an error occurs.
309.Pp
310.Fn i2d_X509_PUBKEY
311and
312.Fn i2d_PUBKEY
313return the number of bytes successfully encoded or a negative value
314if an error occurs.
315.Pp
316.Fn X509_PUBKEY_set ,
317.Fn X509_PUBKEY_set0_param ,
318.Fn X509_PUBKEY_get0_param ,
319.Fn i2d_PUBKEY_fp ,
320and
321.Fn i2d_PUBKEY_bio
322return 1 for success and 0 if an error occurred.
323.Sh ERRORS
324After failure of
325.Fn X509_PUBKEY_get0
326or
327.Fn X509_PUBKEY_get ,
328one of the following diagnostics can be retrieved with
329.Xr ERR_get_error 3 ,
330.Xr ERR_GET_REASON 3 ,
331and
332.Xr ERR_reason_error_string 3 :
333.Bl -tag -width Ds
334.It Dv X509_R_UNSUPPORTED_ALGORITHM Qq "unsupported algorithm"
335The public key uses an algorithm unsupported by
336.Xr EVP_PKEY_set_type 3 .
337.It X509_R_METHOD_NOT_SUPPORTED Qq "method not supported"
338While the algorithm is known to
339.Xr EVP_PKEY_set_type 3 ,
340using it for decoding is not supported.
341.It X509_R_PUBLIC_KEY_DECODE_ERROR Qq "public key decode error"
342Decoding the public key failed.
343.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
344Memory was exhausted when trying to allocate the new
345.Vt EVP_PKEY
346object.
347.El
348.Pp
349If
350.Fa key
351is
352.Dv NULL
353or does not contain a public key,
354these functions fail but no error is pushed onto the stack.
355.Sh SEE ALSO
356.Xr d2i_X509 3 ,
357.Xr X509_ALGOR_new 3 ,
358.Xr X509_get_pubkey 3 ,
359.Xr X509_new 3
360.Sh STANDARDS
361RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
362Certificate Revocation List (CRL) Profile
363.Sh HISTORY
364.Fn X509_PUBKEY_new
365and
366.Fn X509_PUBKEY_free
367appeared in SSLeay 0.4 or earlier.
368.Fn d2i_X509_PUBKEY
369and
370.Fn i2d_X509_PUBKEY
371first appeared in SSLeay 0.5.1.
372.Fn X509_PUBKEY_set
373and
374.Fn X509_PUBKEY_get
375first appeared in SSLeay 0.8.0.
376These functions have been available since
377.Ox 2.4 .
378.Pp
379.Fn d2i_PUBKEY
380and
381.Fn i2d_PUBKEY
382first appeared in OpenSSL 0.9.5 and have been available since
383.Ox 2.7 .
384.Pp
385.Fn d2i_PUBKEY_bio ,
386.Fn d2i_PUBKEY_fp ,
387.Fn i2d_PUBKEY_fp ,
388and
389.Fn i2d_PUBKEY_bio
390first appeared in OpenSSL 0.9.6 and have been available since
391.Ox 2.9 .
392.Pp
393.Fn X509_PUBKEY_set0_param
394and
395.Fn X509_PUBKEY_get0_param
396first appeared in OpenSSL 1.0.0 and have been available since
397.Ox 4.9 .
398.Pp
399.Fn X509_PUBKEY_get0
400first appeared in OpenSSL 1.1.0 and has been available since
401.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/X509_PURPOSE_set.3 b/src/lib/libcrypto/man/X509_PURPOSE_set.3
deleted file mode 100644
index 1f723e9b9f..0000000000
--- a/src/lib/libcrypto/man/X509_PURPOSE_set.3
+++ /dev/null
@@ -1,295 +0,0 @@
1.\" $OpenBSD: X509_PURPOSE_set.3,v 1.1 2021/07/23 14:27:32 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 23 2021 $
18.Dt X509_PURPOSE_SET 3
19.Os
20.Sh NAME
21.Nm X509_PURPOSE_set ,
22.Nm X509_PURPOSE_get_by_id ,
23.Nm X509_PURPOSE_add ,
24.Nm X509_PURPOSE_get_count ,
25.Nm X509_PURPOSE_cleanup ,
26.Nm X509_PURPOSE_get0 ,
27.Nm X509_PURPOSE_get_by_sname ,
28.Nm X509_PURPOSE_get_id ,
29.Nm X509_PURPOSE_get0_name ,
30.Nm X509_PURPOSE_get0_sname ,
31.Nm X509_PURPOSE_get_trust
32.Nd purpose objects, indices, and identifiers
33.Sh SYNOPSIS
34.In openssl/x509v3.h
35.Ft int
36.Fo X509_PURPOSE_set
37.Fa "int *id_out"
38.Fa "int id_in"
39.Fc
40.Ft int
41.Fn X509_PURPOSE_get_by_id "int identifier"
42.Ft int
43.Fo X509_PURPOSE_add
44.Fa "int identifier"
45.Fa "int trust"
46.Fa "int flags"
47.Fa "int (*check_purpose)(const X509_PURPOSE *, const X509 *, int)"
48.Fa "const char *name"
49.Fa "const char *sname"
50.Fa "void *usr_data"
51.Fc
52.Ft int
53.Fn X509_PURPOSE_get_count void
54.Ft void
55.Fn X509_PURPOSE_cleanup void
56.Ft X509_PURPOSE *
57.Fn X509_PURPOSE_get0 "int index"
58.Ft int
59.Fn X509_PURPOSE_get_by_sname "const char *sname"
60.Ft int
61.Fn X509_PURPOSE_get_id "const X509_PURPOSE *object"
62.Ft char *
63.Fn X509_PURPOSE_get0_name "const X509_PURPOSE *object"
64.Ft char *
65.Fn X509_PURPOSE_get0_sname "const X509_PURPOSE *object"
66.Ft int
67.Fn X509_PURPOSE_get_trust "const X509_PURPOSE *object"
68.Sh DESCRIPTION
69The purposes that an X.509 certificate is intended to be used for
70can be identified in three equivalent ways:
71.Bl -enum
72.It
73By purpose identifiers, which are positive integer constants.
74Standard purpose identifiers lie in the range from
75.Dv X509_PURPOSE_MIN
76to
77.Dv X509_PURPOSE_MAX ,
78inclusive, and are listed in the
79.Xr X509_check_purpose 3
80manual page.
81User defined purpose identifiers are larger than
82.Dv X509_PURPOSE_MAX .
83.It
84By purpose indices, which are non-negative integer constants
85but differ from the purpose identifiers for the same purpose.
86Standard purpose indices are smaller than
87.Dv X509_PURPOSE_MAX .
88User defined purpose indices are larger than or equal to
89.Dv X509_PURPOSE_MAX .
90.It
91By purpose objects of the type
92.Vt X509_PURPOSE .
93Standard purpose objects are available in static storage.
94User defined purpose objects can be created with
95.Fn X509_PURPOSE_add .
96.El
97.Pp
98Application programmers cannot choose the way to identify purposes
99that they like best; depending on the circumstances, all three ways
100are needed.
101Be warned that the naming of most functions is misleading.
102.Pp
103Most API functions documented outside the present manual page
104use purpose identifiers rather than purpose indices.
105.Ss Using purpose identifiers
106.Fn X509_PURPOSE_set
107validates the purpose identifier
108.Fa id_in .
109If it is valid, it is copied to
110.Pf * Fa id_out .
111Otherwise,
112.Pf * Fa id_out
113remains unchanged.
114.Pp
115.Fn X509_PURPOSE_get_by_id
116converts the purpose
117.Fa identifier
118to the corresponding purpose index.
119To find the corresponding purpose object, pass the result to
120.Fn X509_PURPOSE_get0 .
121.Pp
122.Fn X509_PURPOSE_add
123defines a purpose with the given
124.Fa identifier
125or modifies its properties if it already exists.
126The purpose
127.Fa identifier ,
128the
129.Fa trust
130identifier, the
131.Fa flags ,
132the
133.Fa check_purpose
134function, the
135.Fa name ,
136the short name
137.Fa sname ,
138and the
139.Fa usr_data
140pointer are copied into the
141.Vt X509_PURPOSE
142object.
143When modifying an existing purpose object, previous values of fields are
144overwritten and previous
145.Fa name
146and
147.Fa sname
148strings are freed if they were dynamically allocated.
149When creating a new purpose object,
150it is added to the global array of user-defined purpose objects.
151.Pp
152.Dv X509_PURPOSE_DYNAMIC
153and
154.Dv X509_PURPOSE_DYNAMIC_NAME
155are always ignored in the
156.Fa flags
157argument.
158.Dv X509_PURPOSE_DYNAMIC
159is automatically set if the object was created by the user.
160It is never set for standard objects, not even if they were
161modified by the user.
162.Dv X509_PURPOSE_DYNAMIC_NAME
163is automatically set if the object was created or modified by the user.
164It is only unset for unmodified standard objects.
165The library does not appear to define any other flags, so the
166.Fa flags
167argument is probably useless unless users define their own flags
168and use them in the
169.Fa check_purpose
170function.
171.Pp
172The third and final argument of the
173.Fa check_purpose
174function is the
175.Fa ca
176argument documented in
177.Xr X509_check_purpose 3 .
178.Pp
179.Fn X509_PURPOSE_get_count
180returns the total number of purposes currently defined,
181including both standard and user-defined purposes.
182If no user-defined purposes exist, the returned value is
183.Dv X509_PURPOSE_MAX .
184.Pp
185.Fn X509_PURPOSE_cleanup
186deletes all user-defined purpose objects
187and invalidates their purpose identifiers and purpose indices.
188If any of the standard purpose objects were modified by the user,
189those changes are
190.Em not
191reverted.
192.Ss Using purpose indices
193.Fn X509_PURPOSE_get0
194converts the purpose
195.Fa index
196to a pointer to the corresponding purpose object.
197To find the corresponding purpose identifier, pass the result to
198.Fn X509_PURPOSE_get_id .
199.Pp
200.Fn X509_PURPOSE_get_by_sname
201returns the lowest index of a purpose with the given short name.
202.Ss Using purpose objects
203.Fn X509_PURPOSE_get_id
204converts a pointer to a purpose
205.Fa object
206to the corresponding purpose identifier.
207To find the corresponding purpose index, pass the result to
208.Fn X509_PURPOSE_get_by_id .
209.Pp
210.Fn X509_PURPOSE_get0_name ,
211.Fn X509_PURPOSE_get0_sname ,
212and
213.Fn X509_PURPOSE_get_trust
214retrieve the name, short name, and trust identifier from the
215.Fa object ,
216respectively.
217.Sh RETURN VALUES
218.Fn X509_PURPOSE_set
219returns 1 if
220.Fa id_in
221is valid or 0 otherwise.
222.Pp
223.Fn X509_PURPOSE_get_by_id
224and
225.Fn X509_PURPOSE_get_by_sname
226return the corresponding purpose index
227or \-1 if no matching purpose is found.
228.Pp
229.Fn X509_PURPOSE_add
230returns 1 for success or 0 for failure.
231.Pp
232.Fn X509_PURPOSE_get_count
233returns the total number of purposes currently defined.
234.Pp
235.Fn X509_PURPOSE_get0
236returns a standard or user-defined purpose object or
237.Dv NULL
238if the
239.Fa index
240is invalid.
241.Pp
242.Fn X509_PURPOSE_get_id
243always returns a valid purpose identifier.
244.Pp
245.Fn X509_PURPOSE_get0_name
246and
247.Fn X509_PURPOSE_get0_sname
248return pointers to storage owned by the
249.Fa object .
250.Pp
251.Fn X509_PURPOSE_get_trust
252returns the trust identifier associated with the
253.Fa object .
254.Sh ERRORS
255The following diagnostics can be retrieved with
256.Xr ERR_get_error 3 ,
257.Xr ERR_GET_REASON 3 ,
258and
259.Xr ERR_reason_error_string 3 :
260.Bl -tag -width Ds
261.It Dv X509V3_R_INVALID_PURPOSE Qq "invalid purpose"
262.Fn X509_PURPOSE_set
263was called with an invalid
264.Fa id_in
265argument.
266.It Dv X509V3_R_INVALID_NULL_ARGUMENT Qq "invalid null argument"
267.Fn X509_PURPOSE_add
268was called with a
269.Fa name
270or
271.Fa sname
272argument of
273.Dv NULL .
274.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
275.Fn X509_PURPOSE_add
276failed to allocate memory.
277.El
278.Pp
279The other functions provide no diagnostics.
280.Sh SEE ALSO
281.Xr X509_check_purpose 3 ,
282.Xr X509_new 3 ,
283.Xr X509_STORE_set_purpose 3 ,
284.Xr X509_VERIFY_PARAM_set_purpose 3
285.Sh HISTORY
286.Fn X509_PURPOSE_set
287first appeared in OpenSSL 0.9.7 and has been available since
288.Ox 3.2 .
289.Pp
290The other functions first appeared in OpenSSL 0.9.5
291and have been available since
292.Ox 2.7 .
293.Sh CAVEATS
294The difference between purpose identifiers and purpose indices provides
295an ideal breeding ground for off-by-one bugs.
diff --git a/src/lib/libcrypto/man/X509_REQ_add1_attr.3 b/src/lib/libcrypto/man/X509_REQ_add1_attr.3
deleted file mode 100644
index f9b602dbef..0000000000
--- a/src/lib/libcrypto/man/X509_REQ_add1_attr.3
+++ /dev/null
@@ -1,172 +0,0 @@
1.\" $OpenBSD: X509_REQ_add1_attr.3,v 1.4 2024/09/02 07:56:28 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 2 2024 $
18.Dt X509_REQ_ADD1_ATTR 3
19.Os
20.Sh NAME
21.Nm X509_REQ_add1_attr ,
22.Nm X509_REQ_add1_attr_by_OBJ ,
23.Nm X509_REQ_add1_attr_by_NID ,
24.Nm X509_REQ_add1_attr_by_txt ,
25.Nm X509_REQ_delete_attr ,
26.Nm X509_REQ_get_attr ,
27.Nm X509_REQ_get_attr_count ,
28.Nm X509_REQ_get_attr_by_OBJ ,
29.Nm X509_REQ_get_attr_by_NID
30.Nd X.501 Attributes of PKCS#10 certification requests
31.Sh SYNOPSIS
32.In openssl/x509.h
33.Ft int
34.Fo X509_REQ_add1_attr
35.Fa "X509_REQ *req"
36.Fa "X509_ATTRIBUTE *attr"
37.Fc
38.Ft int
39.Fo X509_REQ_add1_attr_by_OBJ
40.Fa "X509_REQ *req"
41.Fa "const ASN1_OBJECT *obj"
42.Fa "int type"
43.Fa "const unsigned char *data"
44.Fa "int len"
45.Fc
46.Ft int
47.Fo X509_REQ_add1_attr_by_NID
48.Fa "X509_REQ *req"
49.Fa "int nid"
50.Fa "int type"
51.Fa "const unsigned char *data"
52.Fa "int len"
53.Fc
54.Ft int
55.Fo X509_REQ_add1_attr_by_txt
56.Fa "X509_REQ *req"
57.Fa "const char *name"
58.Fa "int type"
59.Fa "const unsigned char *data"
60.Fa "int len"
61.Fc
62.Ft X509_ATTRIBUTE *
63.Fo X509_REQ_delete_attr
64.Fa "X509_REQ *req"
65.Fa "int index"
66.Fc
67.Ft X509_ATTRIBUTE *
68.Fo X509_REQ_get_attr
69.Fa "const X509_REQ *req"
70.Fa "int index"
71.Fc
72.Ft int
73.Fo X509_REQ_get_attr_count
74.Fa "const X509_REQ *req"
75.Fc
76.Ft int
77.Fo X509_REQ_get_attr_by_OBJ
78.Fa "const X509_REQ *req"
79.Fa "const ASN1_OBJECT *obj"
80.Fa "int start_after"
81.Fc
82.Ft int
83.Fo X509_REQ_get_attr_by_NID
84.Fa "const X509_REQ *req"
85.Fa "int nid"
86.Fa "int start_after"
87.Fc
88.Sh DESCRIPTION
89These functions support associating an array of X.501 Attributes
90with a PKCS#10 certification request.
91.Pp
92.Fn X509_REQ_add1_attr
93appends a deep copy of the
94.Fa attr ,
95allocating a new array if necessary.
96.Pp
97.Fn X509_REQ_add1_attr_by_OBJ ,
98.Fn X509_REQ_add1_attr_by_NID ,
99and
100.Fn X509_REQ_add1_attr_by_txt
101create a new X.501 Attribute object using
102.Xr X509_ATTRIBUTE_create_by_OBJ 3 ,
103.Xr X509_ATTRIBUTE_create_by_NID 3 ,
104or
105.Xr X509_ATTRIBUTE_create_by_txt 3 ,
106respectively,
107allocating a new array if necessary.
108.Pp
109.Fn X509_REQ_delete_attr
110deletes the attribute with the zero-based
111.Fa index .
112.Pp
113.Fn X509_REQ_get_attr
114returns the attribute with the zero-based
115.Fa index .
116.Pp
117.Fn X509_REQ_get_attr_count
118returns the number of attributes currently associated with
119.Fa req .
120.Pp
121.Fn X509_REQ_get_attr_by_OBJ
122and
123.Fn X509_REQ_get_attr_by_NID
124search for an attribute of the type
125.Fa obj
126or
127.Fa nid .
128.Sh RETURN VALUES
129.Fn X509_REQ_add1_attr ,
130.Fn X509_REQ_add1_attr_by_OBJ ,
131.Fn X509_REQ_add1_attr_by_NID ,
132and
133.Fn X509_REQ_add1_attr_by_txt
134return 1 for success or 0 for failure.
135.Pp
136.Fn X509_REQ_delete_attr
137and
138.Fn X509_REQ_get_attr
139return the deleted or requested attribute or
140.Dv NULL
141if the requested index is negative or greater than or equal to
142the current number of attributes associated with
143.Fa req .
144.Pp
145.Fn X509_REQ_get_attr_count
146returns the current number of attributes.
147.Pp
148.Fn X509_REQ_get_attr_by_OBJ
149and
150.Fn X509_REQ_get_attr_by_NID
151return the index of the first attribute that has an index greater than
152.Fa start_after
153and a type matching
154.Fa obj
155or
156.Fa nid ,
157respectively, or \-1 on failure.
158In addition,
159.Fn X509_REQ_get_attr_by_NID
160returns \-2 if
161.Xr OBJ_nid2obj 3
162fails on the requested
163.Fa nid .
164.Sh SEE ALSO
165.Xr OBJ_nid2obj 3 ,
166.Xr X509_ATTRIBUTE_create_by_OBJ 3 ,
167.Xr X509_ATTRIBUTE_new 3 ,
168.Xr X509_REQ_new 3
169.Sh HISTORY
170These functions first appeared in OpenSSL 0.9.5
171and have been available since
172.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/X509_REQ_add_extensions.3 b/src/lib/libcrypto/man/X509_REQ_add_extensions.3
deleted file mode 100644
index ff33edf474..0000000000
--- a/src/lib/libcrypto/man/X509_REQ_add_extensions.3
+++ /dev/null
@@ -1,113 +0,0 @@
1.\" $OpenBSD: X509_REQ_add_extensions.3,v 1.2 2024/08/18 11:04:55 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: August 18 2024 $
18.Dt X509_REQ_ADD_EXTENSIONS 3
19.Os
20.Sh NAME
21.Nm X509_REQ_add_extensions ,
22.Nm X509_REQ_add_extensions_nid ,
23.Nm X509_REQ_get_extensions ,
24.Nm X509_REQ_extension_nid
25.Nd extensions in certification requests
26.Sh SYNOPSIS
27.In openssl/x509.h
28.Ft int
29.Fo X509_REQ_add_extensions
30.Fa "X509_REQ *req"
31.Fa "STACK_OF(X509_EXTENSION) *extensions"
32.Fc
33.Ft int
34.Fo X509_REQ_add_extensions_nid
35.Fa "X509_REQ *req"
36.Fa "STACK_OF(X509_EXTENSION) *extensions"
37.Fa "int nid"
38.Fc
39.Ft STACK_OF(X509_EXTENSION) *
40.Fn X509_REQ_get_extensions "X509_REQ *req"
41.Ft int
42.Fn X509_REQ_extension_nid "int nid"
43.Sh DESCRIPTION
44.Fn X509_REQ_add_extensions
45encodes the array of
46.Fa extensions
47using
48.Xr i2d_X509_EXTENSIONS 3
49and adds a new X.501 Attribute object of the type
50.Dv NID_ext_req
51to
52.Fa req
53using the equivalent of
54.Xr X509_ATTRIBUTE_create_by_NID 3
55with a
56.Fa type
57of
58.Dv V_ASN1_SEQUENCE .
59.Pp
60.Fn X509_REQ_add_extensions_nid
61is identical except that the specified
62.Fa nid
63is used as the X.501 Attribute type instead of
64.Dv NID_ext_req .
65.Pp
66.Fn X509_REQ_get_extensions
67retrieves the first value of the first X.501 Attribute of appropriate type.
68By default, the attribute types
69.Dv NID_ext_req
70and
71.Dv NID_ms_ext_req
72are considered appropriate.
73.Pp
74.Fn X509_REQ_extension_nid
75checks whether
76.Fn X509_REQ_get_extensions
77regards the
78.Fa nid
79argument as a type appropriate for storing extensions.
80.Sh RETURN VALUES
81.Fn X509_REQ_add_extensions
82and
83.Fn X509_REQ_add_extensions_nid
84returns 1 for success or 0 for failure.
85.Pp
86.Fn X509_REQ_get_extensions
87returns a newly allocated array of ASN.1
88.Vt Extension
89objects or
90.Dv NULL
91if
92.Fa req
93is
94.Dv NULL ,
95does not contain
96.Vt CertificationRequestInfo ,
97contains no attribute of an appropriate type,
98or if decoding or memory allocation fails.
99.Pp
100.Fn X509_REQ_extension_nid
101returns 1 if
102.Fa nid
103is considered appropriate or 0 otherwise.
104.Sh SEE ALSO
105.Xr d2i_X509_EXTENSION 3 ,
106.Xr STACK_OF 3 ,
107.Xr X509_EXTENSION_new 3 ,
108.Xr X509_REQ_new 3 ,
109.Xr X509V3_extensions_print 3
110.Sh HISTORY
111These functions first appeared in OpenSSL 0.9.5
112and have been available since
113.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/X509_REQ_new.3 b/src/lib/libcrypto/man/X509_REQ_new.3
deleted file mode 100644
index 0a5828d5d4..0000000000
--- a/src/lib/libcrypto/man/X509_REQ_new.3
+++ /dev/null
@@ -1,145 +0,0 @@
1.\" $OpenBSD: X509_REQ_new.3,v 1.11 2021/10/29 09:42:07 schwarze Exp $
2.\"
3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 29 2021 $
18.Dt X509_REQ_NEW 3
19.Os
20.Sh NAME
21.Nm X509_REQ_new ,
22.Nm X509_REQ_dup ,
23.Nm X509_to_X509_REQ ,
24.Nm X509_REQ_free ,
25.Nm X509_REQ_INFO_new ,
26.Nm X509_REQ_INFO_free
27.Nd PKCS#10 certification requests
28.Sh SYNOPSIS
29.In openssl/x509.h
30.Ft X509_REQ *
31.Fn X509_REQ_new void
32.Ft X509_REQ *
33.Fn X509_REQ_dup "X509_REQ *req"
34.Ft X509_REQ *
35.Fn X509_to_X509_REQ "X509 *x" "EVP_PKEY *pkey" "const EVP_MD *md"
36.Ft void
37.Fn X509_REQ_free "X509_REQ *req"
38.Ft X509_REQ_INFO *
39.Fn X509_REQ_INFO_new void
40.Ft void
41.Fn X509_REQ_INFO_free "X509_REQ_INFO *req_info"
42.Sh DESCRIPTION
43.Fn X509_REQ_new
44allocates and initializes an empty
45.Vt X509_REQ
46object, representing an ASN.1
47.Vt CertificationRequest
48structure defined in RFC 2986 section 4.2.
49It can hold a pointer to an
50.Vt X509_REQ_INFO
51object discussed below together with a cryptographic signature and
52information about the signature algorithm used.
53.Pp
54.Fn X509_REQ_dup
55creates a deep copy of
56.Fa req
57using
58.Xr ASN1_item_dup 3 ,
59setting the reference count of the copy to 1.
60.Pp
61.Fn X509_to_X509_REQ
62allocates a new certification request object, copies
63the subject name and the public key into it from the certificate
64.Fa x ,
65and sets the version to zero.
66Unless
67.Fa pkey
68is
69.Dv NULL ,
70it also signs the request with
71.Xr X509_REQ_sign 3
72using
73.Fa pkey
74and
75.Fa md .
76.Pp
77.Fn X509_REQ_free
78frees
79.Fa req .
80If
81.Fa req
82is a
83.Dv NULL
84pointer, no action occurs.
85.Pp
86.Fn X509_REQ_INFO_new
87allocates and initializes an empty
88.Vt X509_REQ_INFO
89object, representing an ASN.1
90.Vt CertificationRequestInfo
91structure defined in RFC 2986 section 4.1.
92It is used inside the
93.Vt X509_REQ
94object and can hold the subject and the public key of the requested
95certificate and additional attributes.
96.Fn X509_REQ_INFO_free
97frees
98.Fa req_info .
99If
100.Fa req_info
101is a
102.Dv NULL
103pointer, no action occurs.
104.Sh RETURN VALUES
105.Fn X509_REQ_new ,
106.Fn X509_REQ_dup ,
107.Fn X509_to_X509_REQ ,
108and
109.Fn X509_REQ_INFO_new
110return the new
111.Vt X509_REQ
112or
113.Vt X509_REQ_INFO
114object, respectively, or
115.Dv NULL
116if an error occurs.
117.Sh SEE ALSO
118.Xr d2i_X509_REQ 3 ,
119.Xr PEM_read_X509_REQ 3 ,
120.Xr X509_new 3 ,
121.Xr X509_REQ_add1_attr 3 ,
122.Xr X509_REQ_add_extensions 3 ,
123.Xr X509_REQ_check_private_key 3 ,
124.Xr X509_REQ_digest 3 ,
125.Xr X509_REQ_get0_signature 3 ,
126.Xr X509_REQ_get_pubkey 3 ,
127.Xr X509_REQ_get_subject_name 3 ,
128.Xr X509_REQ_get_version 3 ,
129.Xr X509_REQ_print_ex 3 ,
130.Xr X509_REQ_sign 3
131.Sh STANDARDS
132RFC 2986: PKCS #10: Certification Request Syntax Specification
133.Sh HISTORY
134.Fn X509_REQ_new ,
135.Fn X509_REQ_free ,
136.Fn X509_REQ_INFO_new ,
137and
138.Fn X509_REQ_INFO_free
139first appeared in SSLeay 0.4.4,
140.Fn X509_REQ_dup
141in SSLeay 0.5.1, and
142.Fn X509_to_X509_REQ
143in SSLeay 0.6.0.
144These functions have been available since
145.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/X509_REQ_print_ex.3 b/src/lib/libcrypto/man/X509_REQ_print_ex.3
deleted file mode 100644
index eee06abb21..0000000000
--- a/src/lib/libcrypto/man/X509_REQ_print_ex.3
+++ /dev/null
@@ -1,173 +0,0 @@
1.\" $OpenBSD: X509_REQ_print_ex.3,v 1.3 2025/03/09 14:02:46 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 9 2025 $
18.Dt X509_REQ_PRINT_EX 3
19.Os
20.Sh NAME
21.Nm X509_REQ_print_ex ,
22.Nm X509_REQ_print ,
23.Nm X509_REQ_print_fp
24.Nd pretty-print a PKCS#10 certification request
25.Sh SYNOPSIS
26.Ft int
27.Fo X509_REQ_print_ex
28.Fa "BIO *bio"
29.Fa "X509_REQ *req"
30.Fa "unsigned long nameflags"
31.Fa "unsigned long skipflags"
32.Fc
33.Ft int
34.Fo X509_REQ_print
35.Fa "BIO *bio"
36.Fa "X509_REQ *req"
37.Fc
38.Ft int
39.Fo X509_REQ_print_fp
40.Fa "FILE *fp"
41.Fa "X509_REQ *req"
42.Fc
43.Sh DESCRIPTION
44.Fn X509_REQ_print_ex
45prints information contained in
46.Fa req
47to
48.Fa bio
49in human-readable form.
50Printing is aborted as soon as any operation fails, with the exception
51that failures while attempting to decode or print the public key
52are not considered as errors.
53.Pp
54By default, the following blocks of information
55are printed in the following order.
56Each block can be skipped by setting the corresponding bit in
57.Fa skipflags ,
58provided in parentheses after each block description.
59.Bl -bullet
60.It
61A pair of lines reading
62.Qq Certificate Request:\&
63and
64.Qq Data:\&
65containing no information.
66.Pq Dv X509_FLAG_NO_HEADER
67.It
68The value contained in the version field
69in decimal and hexadecimal notation.
70.Pq Dv X509_FLAG_NO_VERSION
71.It
72The subject name is printed with
73.Xr X509_NAME_print_ex 3 .
74.Pq Dv X509_FLAG_NO_SUBJECT
75.It
76The public key algorithm is printed with
77.Xr i2a_ASN1_OBJECT 3 ,
78and the public key returned from
79.Xr X509_REQ_get_pubkey 3
80with
81.Xr EVP_PKEY_print_public 3 .
82.Pq Dv X509_FLAG_NO_PUBKEY
83.It
84For each X.501 attribute that is not a requested extension according to
85.Xr X509_REQ_extension_nid 3 ,
86the object identifier is printed with
87.Xr i2a_ASN1_OBJECT 3 ,
88and all values of the types
89.Dv V_ASN1_PRINTABLESTRING ,
90.Dv V_ASN1_T61STRING ,
91and
92.Dv V_ASN1_IA5STRING
93are printed with
94.Xr BIO_write 3 .
95.Pq Dv X509_FLAG_NO_ATTRIBUTES
96.It
97The requested extensions are retrieved with
98.Xr X509_REQ_get_extensions 3
99and their types and values are printed with
100.Xr i2a_ASN1_OBJECT 3
101and
102.Xr X509V3_EXT_print 3 ,
103or, if the latter fails, with
104.Xr ASN1_STRING_print 3 .
105.Pq Dv X509_FLAG_NO_EXTENSIONS
106.It
107The signature is printed with
108.Xr X509_signature_print 3 .
109.Pq Dv X509_FLAG_NO_SIGDUMP
110.El
111.Pp
112The
113.Fa nameflags
114argument modifies the format for printing X.501
115.Vt Name
116objects contained in
117.Fa req .
118It is passed through to
119.Xr X509_NAME_print_ex 3 .
120If
121.Fa nameflags
122is
123.Dv X509_FLAG_COMPAT ,
124the
125.Fa indent
126argument of
127.Xr X509_NAME_print_ex 3
128is set to 16 spaces and the traditional SSLeay format is used.
129Otherwise, if the only bit set in
130.Dv XN_FLAG_SEP_MASK
131is
132.Dv XN_FLAG_SEP_MULTILINE ,
133.Fa indent
134is set to 12 spaces.
135Otherwise, indent is set to zero.
136.Pp
137.Fn X509_REQ_print
138is a wrapper function setting the
139.Fa nameflags
140to
141.Dv XN_FLAG_COMPAT
142and the
143.Fa skipflags
144to
145.Dv X509_FLAG_COMPAT .
146.Pp
147.Fn X509_REQ_print_fp
148is similar to
149.Fn X509_REQ_print
150except that it prints to
151.Fa fp .
152.Sh RETURN VALUES
153These functions return 1 if all requested information was successfully
154printed, even if failures occurred while attempting to decode or
155print the public key, or 0 if any operation fails.
156.Sh SEE ALSO
157.Xr BIO_new 3 ,
158.Xr X509_print_ex 3 ,
159.Xr X509_REQ_new 3
160.Sh HISTORY
161.Fn X509_REQ_print
162first appeared in SSLeay 0.4.4 and
163.Fn X509_REQ_print_fp
164in SSLeay 0.6.0.
165These functions have been available since
166.Ox 2.4 .
167.Pp
168.Fn X509_REQ_print_ex
169first appeared in OpenSSL 0.9.7 and has been available since
170.Ox 3.2 .
171.Sh BUGS
172Some printing failures are silently ignored while printing extensions,
173which may result in incomplete data being printed.
diff --git a/src/lib/libcrypto/man/X509_REVOKED_new.3 b/src/lib/libcrypto/man/X509_REVOKED_new.3
deleted file mode 100644
index c1a50d1c9a..0000000000
--- a/src/lib/libcrypto/man/X509_REVOKED_new.3
+++ /dev/null
@@ -1,213 +0,0 @@
1.\" $OpenBSD: X509_REVOKED_new.3,v 1.12 2021/07/19 13:16:43 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL man3/X509_CRL_get0_by_serial cdd6c8c5 Mar 20 12:29:37 2017 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: July 19 2021 $
70.Dt X509_REVOKED_NEW 3
71.Os
72.Sh NAME
73.Nm X509_REVOKED_new ,
74.Nm X509_REVOKED_dup ,
75.Nm X509_REVOKED_free ,
76.Nm X509_REVOKED_get0_serialNumber ,
77.Nm X509_REVOKED_get0_revocationDate ,
78.Nm X509_REVOKED_set_serialNumber ,
79.Nm X509_REVOKED_set_revocationDate
80.Nd create, change, and inspect an X.509 CRL revoked entry
81.Sh SYNOPSIS
82.In openssl/x509.h
83.Ft X509_REVOKED *
84.Fn X509_REVOKED_new void
85.Ft X509_REVOKED *
86.Fo X509_REVOKED_dup
87.Fa "X509_REVOKED *r"
88.Fc
89.Ft void
90.Fn X509_REVOKED_free "X509_REVOKED *r"
91.Ft const ASN1_INTEGER *
92.Fo X509_REVOKED_get0_serialNumber
93.Fa "const X509_REVOKED *r"
94.Fc
95.Ft const ASN1_TIME *
96.Fo X509_REVOKED_get0_revocationDate
97.Fa "const X509_REVOKED *r"
98.Fc
99.Ft int
100.Fo X509_REVOKED_set_serialNumber
101.Fa "X509_REVOKED *r"
102.Fa "ASN1_INTEGER *serial"
103.Fc
104.Ft int
105.Fo X509_REVOKED_set_revocationDate
106.Fa "X509_REVOKED *r"
107.Fa "ASN1_TIME *tm"
108.Fc
109.Sh DESCRIPTION
110.Fn X509_REVOKED_new
111allocates and initializes an empty
112.Vt X509_REVOKED
113object, representing one of the elements of
114the revokedCertificates field of the ASN.1
115.Vt TBSCertList
116structure defined in RFC 5280 section 5.1.
117It is used by
118.Vt X509_CRL
119objects and can hold information about one revoked certificate
120including issuer names, serial number, revocation date, and revocation
121reason.
122.Pp
123.Fn X509_REVOKED_dup
124creates a deep copy of
125.Fa r .
126.Pp
127.Fn X509_REVOKED_free
128frees
129.Fa r .
130.Pp
131.Fn X509_REVOKED_set_serialNumber
132sets the serial number of
133.Fa r
134to
135.Fa serial .
136The supplied
137.Fa serial
138pointer is not used internally so it should be freed up after use.
139.Pp
140.Fn X509_REVOKED_set_revocationDate
141sets the revocation date of
142.Fa r
143to
144.Fa tm .
145The supplied
146.Fa tm
147pointer is not used internally so it should be freed up after use.
148.Sh RETURN VALUES
149The
150.Fn X509_REVOKED_new
151function returns the new
152.Vt X509_REVOKED
153object if successful; otherwise
154.Dv NULL
155is returned and an error code can be retrieved with
156.Xr ERR_get_error 3 .
157.Pp
158.Fn X509_REVOKED_dup
159return the new
160.Vt X509_REVOKED
161object or
162.Dv NULL
163if an error occurs.
164In some cases of failure, the reason can be determined with
165.Xr ERR_get_error 3 .
166.Pp
167.Fn X509_REVOKED_get0_serialNumber
168returns an internal pointer to the serial number of
169.Fa r .
170.Pp
171.Fn X509_REVOKED_get0_revocationDate
172returns an internal pointer to the revocation date of
173.Fa r .
174.Pp
175.Fn X509_REVOKED_set_serialNumber
176and
177.Fn X509_REVOKED_set_revocationDate
178return 1 for success or 0 for failure.
179In some cases of failure, the reason can be determined with
180.Xr ERR_get_error 3 .
181.Sh SEE ALSO
182.Xr d2i_X509_CRL 3 ,
183.Xr PEM_read_X509_CRL 3 ,
184.Xr X509_CRL_get0_by_serial 3 ,
185.Xr X509_CRL_new 3 ,
186.Xr X509_CRL_print 3 ,
187.Xr X509_EXTENSION_new 3 ,
188.Xr X509_REVOKED_get_ext 3 ,
189.Xr X509_REVOKED_get_ext_d2i 3
190.Sh STANDARDS
191RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
192Certificate Revocation List (CRL) Profile, section 5.1: CRL Fields
193.Sh HISTORY
194.Fn X509_REVOKED_new
195and
196.Fn X509_REVOKED_free
197first appeared in SSLeay 0.4.4 and have been available since
198.Ox 2.4 .
199.Pp
200.Fn X509_REVOKED_set_serialNumber
201and
202.Fn X509_REVOKED_set_revocationDate
203first appeared in OpenSSL 0.9.7 and have been available since
204.Ox 3.2 .
205.Pp
206.Fn X509_REVOKED_dup
207first appeared in OpenSSL 1.0.2.
208.Fn X509_REVOKED_get0_serialNumber
209and
210.Fn X509_REVOKED_get0_revocationDate
211first appeared in OpenSSL 1.1.0.
212These functions have been available since
213.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/X509_SIG_get0.3 b/src/lib/libcrypto/man/X509_SIG_get0.3
deleted file mode 100644
index 456261ca3f..0000000000
--- a/src/lib/libcrypto/man/X509_SIG_get0.3
+++ /dev/null
@@ -1,90 +0,0 @@
1.\" $OpenBSD: X509_SIG_get0.3,v 1.1 2021/10/23 15:39:06 tb Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2016 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: October 23 2021 $
53.Dt X509_SIG_GET0 3
54.Os
55.Sh NAME
56.Nm X509_SIG_get0 ,
57.Nm X509_SIG_getm
58.Nd DigestInfo functions
59.Sh SYNOPSIS
60.In openssl/x509.h
61.Ft void
62.Fo X509_SIG_get0
63.Fa "const X509_SIG *sig"
64.Fa "const X509_ALGOR **palg"
65.Fa "const ASN1_OCTET_STRING **pdigest"
66.Fc
67.Ft void
68.Fo X509_SIG_getm
69.Fa "X509_SIG *sig"
70.Fa "X509_ALGOR **palg"
71.Fa "ASN1_OCTET_STRING **pdigest"
72.Fc
73.Sh DESCRIPTION
74.Fn X509_SIG_get0
75returns pointers to the algorithm identifier and digest value in
76.Fa sig .
77.Fn X509_SIG_getm
78is identical to
79.Fn X509_SIG_get0 ,
80except the pointers returned are not constant and can be modified,
81for example to initialise them.
82.Sh SEE ALSO
83.Xr d2i_X509 3 ,
84.Xr X509_SIG_new 3
85.Sh HISTORY
86.Fn X509_SIG_get0
87and
88.Fn X509_SIG_getm
89first appeared in OpenSSL 1.1.0 and have been available since
90.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/X509_SIG_new.3 b/src/lib/libcrypto/man/X509_SIG_new.3
deleted file mode 100644
index 8e6b29dea5..0000000000
--- a/src/lib/libcrypto/man/X509_SIG_new.3
+++ /dev/null
@@ -1,68 +0,0 @@
1.\" $OpenBSD: X509_SIG_new.3,v 1.5 2021/10/27 11:24:47 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 27 2021 $
18.Dt X509_SIG_NEW 3
19.Os
20.Sh NAME
21.Nm X509_SIG_new ,
22.Nm X509_SIG_free
23.Nd PKCS#7 digest information
24.Sh SYNOPSIS
25.In openssl/x509.h
26.Ft X509_SIG *
27.Fn X509_SIG_new void
28.Ft void
29.Fn X509_SIG_free "X509_SIG *sig"
30.Sh DESCRIPTION
31.Fn X509_SIG_new
32allocates and initializes an empty
33.Vt X509_SIG
34object, representing an ASN.1
35.Vt DigestInfo
36structure defined in RFC 2315 section 9.4
37and equivalently in RFC 8017 section 9.2.
38It can hold a message digest together with information about
39the algorithm used.
40.Pp
41.Fn X509_SIG_free
42frees
43.Fa sig .
44.Sh RETURN VALUES
45.Fn X509_SIG_new
46returns the new
47.Vt X509_SIG
48object or
49.Dv NULL
50if an error occurs.
51.Sh SEE ALSO
52.Xr d2i_X509_SIG 3 ,
53.Xr PEM_read_PKCS8 3 ,
54.Xr RSA_sign 3 ,
55.Xr X509_new 3 ,
56.Xr X509_SIG_get0 3
57.Sh STANDARDS
58RFC 2315: PKCS #7: Cryptographic Message Syntax,
59section 9: Signed-data content type
60.Pp
61RFC 8017: PKCS #1: RSA Cryptography Specifications,
62section 9: Encoding Methods for Signatures
63.Sh HISTORY
64.Fn X509_SIG_new
65and
66.Fn X509_SIG_free
67appeared in SSLeay 0.4 or earlier and have been available since
68.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3 b/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3
deleted file mode 100644
index 1f221563cb..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3
+++ /dev/null
@@ -1,591 +0,0 @@
1.\" $OpenBSD: X509_STORE_CTX_get_error.3,v 1.28 2023/06/06 16:20:13 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL man3/X509_STORE_CTX_get_error 24a535ea Sep 22 13:14:20 2020 +0100
4.\" OpenSSL man3/X509_STORE_CTX_new 24a535ea Sep 22 13:14:20 2020 +0100
5.\"
6.\" This file is a derived work.
7.\" The changes are covered by the following Copyright and license:
8.\"
9.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
10.\"
11.\" Permission to use, copy, modify, and distribute this software for any
12.\" purpose with or without fee is hereby granted, provided that the above
13.\" copyright notice and this permission notice appear in all copies.
14.\"
15.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22.\"
23.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
24.\" and Rich Salz <rsalz@openssl.org>.
25.\" Copyright (c) 2009, 2016 The OpenSSL Project. All rights reserved.
26.\"
27.\" Redistribution and use in source and binary forms, with or without
28.\" modification, are permitted provided that the following conditions
29.\" are met:
30.\"
31.\" 1. Redistributions of source code must retain the above copyright
32.\" notice, this list of conditions and the following disclaimer.
33.\"
34.\" 2. Redistributions in binary form must reproduce the above copyright
35.\" notice, this list of conditions and the following disclaimer in
36.\" the documentation and/or other materials provided with the
37.\" distribution.
38.\"
39.\" 3. All advertising materials mentioning features or use of this
40.\" software must display the following acknowledgment:
41.\" "This product includes software developed by the OpenSSL Project
42.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
43.\"
44.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
45.\" endorse or promote products derived from this software without
46.\" prior written permission. For written permission, please contact
47.\" openssl-core@openssl.org.
48.\"
49.\" 5. Products derived from this software may not be called "OpenSSL"
50.\" nor may "OpenSSL" appear in their names without prior written
51.\" permission of the OpenSSL Project.
52.\"
53.\" 6. Redistributions of any form whatsoever must retain the following
54.\" acknowledgment:
55.\" "This product includes software developed by the OpenSSL Project
56.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
57.\"
58.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
59.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
62.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
67.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\"
71.Dd $Mdocdate: June 6 2023 $
72.Dt X509_STORE_CTX_GET_ERROR 3
73.Os
74.Sh NAME
75.Nm X509_STORE_CTX_get_error ,
76.Nm X509_STORE_CTX_set_error ,
77.Nm X509_STORE_CTX_get_error_depth ,
78.Nm X509_STORE_CTX_set_error_depth ,
79.Nm X509_STORE_CTX_get_current_cert ,
80.Nm X509_STORE_CTX_set_current_cert ,
81.Nm X509_STORE_CTX_get0_current_issuer ,
82.Nm X509_STORE_CTX_get0_current_crl ,
83.Nm X509_STORE_CTX_get0_parent_ctx ,
84.Nm X509_STORE_CTX_get_num_untrusted ,
85.Nm X509_STORE_CTX_get0_chain ,
86.Nm X509_STORE_CTX_get_chain ,
87.Nm X509_STORE_CTX_get1_chain ,
88.Nm X509_STORE_CTX_set0_verified_chain ,
89.Nm X509_verify_cert_error_string
90.Nd get or set certificate verification status information
91.Sh SYNOPSIS
92.In openssl/x509_vfy.h
93.Ft int
94.Fo X509_STORE_CTX_get_error
95.Fa "X509_STORE_CTX *ctx"
96.Fc
97.Ft void
98.Fo X509_STORE_CTX_set_error
99.Fa "X509_STORE_CTX *ctx"
100.Fa "int s"
101.Fc
102.Ft int
103.Fo X509_STORE_CTX_get_error_depth
104.Fa "X509_STORE_CTX *ctx"
105.Fc
106.Ft void
107.Fo X509_STORE_CTX_set_error_depth
108.Fa "X509_STORE_CTX *ctx"
109.Fa "int depth"
110.Fc
111.Ft X509 *
112.Fo X509_STORE_CTX_get_current_cert
113.Fa "X509_STORE_CTX *ctx"
114.Fc
115.Ft void
116.Fo X509_STORE_CTX_set_current_cert
117.Fa "X509_STORE_CTX *ctx"
118.Fa "X509 *cert"
119.Fc
120.Ft X509 *
121.Fo X509_STORE_CTX_get0_current_issuer
122.Fa "X509_STORE_CTX *ctx"
123.Fc
124.Ft X509_CRL *
125.Fo X509_STORE_CTX_get0_current_crl
126.Fa "X509_STORE_CTX *ctx"
127.Fc
128.Ft X509_STORE_CTX *
129.Fo X509_STORE_CTX_get0_parent_ctx
130.Fa "X509_STORE_CTX *ctx"
131.Fc
132.Ft int
133.Fo X509_STORE_CTX_get_num_untrusted
134.Fa "X509_STORE_CTX *ctx"
135.Fc
136.Ft STACK_OF(X509) *
137.Fo X509_STORE_CTX_get0_chain
138.Fa "X509_STORE_CTX *ctx"
139.Fc
140.Ft STACK_OF(X509) *
141.Fo X509_STORE_CTX_get_chain
142.Fa "X509_STORE_CTX *ctx"
143.Fc
144.Ft STACK_OF(X509) *
145.Fo X509_STORE_CTX_get1_chain
146.Fa "X509_STORE_CTX *ctx"
147.Fc
148.Ft void
149.Fo X509_STORE_CTX_set0_verified_chain
150.Fa "X509_STORE_CTX *ctx"
151.Fa "STACK_OF(X509) *chain"
152.Fc
153.In openssl/x509.h
154.Ft const char *
155.Fo X509_verify_cert_error_string
156.Fa "long n"
157.Fc
158.Sh DESCRIPTION
159Most of these functions are typically called after
160.Xr X509_verify_cert 3
161to inspect status information related to certificate verification.
162Some may also be called in a verification callback to determine the
163nature of an error.
164.Pp
165.Fn X509_STORE_CTX_get_error
166returns the error code of
167.Fa ctx .
168See the
169.Sy ERROR CODES
170section for a full description of all error codes.
171.Pp
172.Fn X509_STORE_CTX_set_error
173sets the error code of
174.Fa ctx
175to
176.Fa s .
177For example it might be used in a verification callback to set an error
178based on additional checks.
179.Pp
180.Fn X509_STORE_CTX_get_error_depth
181returns the depth of the error.
182This is a non-negative integer representing where in the certificate
183chain the error occurred.
184If it is zero, it occurred in the end entity certificate, one if it is
185the certificate which signed the end entity certificate, and so on.
186.Pp
187.Fn X509_STORE_CTX_set_error_depth
188sets the error depth.
189This can be used in combination with
190.Fn X509_STORE_CTX_set_error
191to set the depth at which an error condition was detected.
192.Pp
193.Fn X509_STORE_CTX_get_current_cert
194returns the certificate in
195.Fa ctx
196which caused the error or
197.Dv NULL
198if no certificate is relevant.
199.Pp
200.Fn X509_STORE_CTX_set_current_cert
201sets the certificate which caused the error in
202.Fa ctx
203to the given
204.Fa cert .
205This value is not intended to remain valid for very long,
206and remains owned by the caller.
207It may be examined by a verification callback invoked to handle
208each error encountered during chain verification and is no longer
209required after such a callback.
210If a callback wishes the save the certificate for use after it returns,
211it needs to increment its reference count via
212.Xr X509_up_ref 3 .
213Once such a saved certificate is no longer needed, it can be freed with
214.Xr X509_free 3 .
215.Pp
216.Fn X509_STORE_CTX_get0_current_issuer
217returns the certificate that caused issuer validation to fail or
218.Dv NULL
219if no CA certificate is relevant.
220.Pp
221.Fn X509_STORE_CTX_get0_current_crl
222returns the certificate revocation list that caused CRL checking to fail or
223.Dv NULL
224if no CRL is relevant.
225.Pp
226When, during certification path validation, the need arises to check
227the validity of the certification path of a CRL issuer certificate,
228the library creates a new, temporary
229.Vt X509_STORE_CTX
230object.
231If
232.Fn X509_STORE_CTX_get0_parent_ctx
233is called on that temporary object, a pointer to the original
234certification path validation context is returned.
235This may be useful in callback functions called from
236.Xr X509_verify_cert 3
237or from its subroutines to find out whether the callback is called
238from the path validation of the target certificate or from the path
239validation of a related CRL issuer certificate, and if the latter,
240what the target certificate is.
241.Pp
242.Fn X509_STORE_CTX_get0_chain
243returns an internal pointer to a complete validate chain
244if a previous call to
245.Xr X509_verify_cert 3
246was successful.
247If the call to
248.Xr X509_verify_cert 3
249was not successful, the returned chain may be incomplete or invalid.
250.Fn X509_STORE_CTX_get_chain
251is a deprecated alias of
252.Fn X509_STORE_CTX_get0_chain .
253.Fn X509_STORE_CTX_get1_chain
254returns a deep copy of the same chain which persists even after the
255.Fa ctx
256structure is freed.
257When it is no longer needed, it should be freed using
258.Fn sk_X509_pop_free chain X509_free .
259.Pp
260.Fn X509_STORE_CTX_set0_verified_chain
261frees the validate chain generated by if a previous call to
262.Xr X509_verify_cert 3 ,
263if any, and replaces it with the given
264.Fa chain .
265Ownership of the
266.Fa chain
267is transferred to the
268.Fa ctx ,
269so it should not be freed by the caller.
270.Pp
271.Fn X509_verify_cert_error_string
272returns a human readable error string for verification error
273.Fa n .
274.Pp
275The above functions should be used instead of directly referencing the
276fields in the
277.Sy X509_VERIFY_CTX
278structure.
279.Pp
280In versions of OpenSSL before 1.0, the current certificate returned by
281.Fn X509_STORE_CTX_get_current_cert
282was never
283.Dv NULL .
284Applications should check the return value before printing out any
285debugging information relating to the current certificate.
286.Pp
287If an unrecognised error code is passed to
288.Fn X509_verify_cert_error_string ,
289"Unknown certificate verification error"
290is returned.
291This should never happen unless an invalid code is passed.
292.Sh RETURN VALUES
293.Fn X509_STORE_CTX_get_error
294returns
295.Dv X509_V_OK
296or an error code.
297.Pp
298.Fn X509_STORE_CTX_get_error_depth
299returns a non-negative error depth.
300.Pp
301.Fn X509_STORE_CTX_get_current_cert ,
302.Fn X509_STORE_CTX_get0_current_issuer ,
303and
304.Fn X509_STORE_CTX_get0_current_crl
305return the object which caused the error or
306.Dv NULL
307if no object of the requested kind is relevant to the error.
308.Pp
309.Fn X509_STORE_CTX_get0_parent_ctx
310returns the parent context or
311.Dv NULL
312if
313.Fa ctx
314is not a temporary child context
315used for path validation of a CRL issuer certificate.
316.Pp
317.Fn X509_STORE_CTX_get_num_untrusted
318returns the number of untrusted certificates
319that were used in building the chain during a call to
320.Xr X509_verify_cert 3 .
321.Pp
322.Fn X509_STORE_CTX_get0_chain ,
323.Fn X509_STORE_CTX_get_chain ,
324and
325.Fn X509_STORE_CTX_get1_chain
326return a pointer to a stack of certificates or
327.Dv NULL
328if an error occurs.
329.Pp
330.Fn X509_verify_cert_error_string
331returns a human readable error string for verification error
332.Fa n .
333.Sh ERROR CODES
334A list of error codes and messages is shown below.
335Some of the error codes are defined but currently never returned:
336these are described as "unused".
337.Bl -tag -width Ds
338.It Dv X509_V_OK : No ok
339The operation was successful.
340.It Dv X509_V_ERR_UNSPECIFIED : \
341 No Unspecified certificate verification error
342An error was encountered during certificate verification and
343the internal routines failed to set a more specific error.
344.It Dv X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT : \
345 No unable to get issuer certificate
346The issuer certificate of a locally looked up certificate could not be found.
347This normally means the list of trusted certificates is not complete.
348.It Dv X509_V_ERR_UNABLE_TO_GET_CRL : No unable to get certificate CRL
349The CRL of a certificate could not be found.
350.It Dv X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE : \
351 No unable to decrypt certificate's signature
352The certificate signature could not be decrypted.
353This means that the actual signature value could not be determined
354rather than it not matching the expected value.
355This is only meaningful for RSA keys.
356.It Dv X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE : \
357 No unable to decrypt CRL's signature
358The CRL signature could not be decrypted: this means that the actual
359signature value could not be determined rather than it not matching the
360expected value.
361Unused.
362.It Dv X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY : \
363 No unable to decode issuer public key
364The public key in the certificate
365.Vt SubjectPublicKeyInfo
366could not be read.
367.It Dv X509_V_ERR_CERT_SIGNATURE_FAILURE : No certificate signature failure
368The signature of the certificate is invalid.
369.It Dv X509_V_ERR_CRL_SIGNATURE_FAILURE : No CRL signature failure
370The signature of the CRL is invalid.
371.It Dv X509_V_ERR_CERT_NOT_YET_VALID : No certificate is not yet valid
372The certificate is not yet valid: the notBefore date is after the
373current time.
374.It Dv X509_V_ERR_CERT_HAS_EXPIRED : No certificate has expired
375The certificate has expired: that is the notAfter date is before the
376current time.
377.It Dv X509_V_ERR_CRL_NOT_YET_VALID : No CRL is not yet valid
378The CRL is not yet valid.
379.It Dv X509_V_ERR_CRL_HAS_EXPIRED : No CRL has expired
380The CRL has expired.
381.It Dv X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD : \
382 No format error in certificate's notBefore field
383The certificate notBefore field contains an invalid time.
384.It Dv X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD : \
385 No format error in certificate's notAfter field
386The certificate notAfter field contains an invalid time.
387.It Dv X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD : \
388 No format error in CRL's lastUpdate field
389The CRL thisUpdate field (sic!) contains an invalid time.
390Both the name of the error constant and the text of the error message
391give a wrong name for the field that contains the problem.
392.It Dv X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD : \
393 No format error in CRL's nextUpdate field
394The CRL nextUpdate field contains an invalid time.
395.It Dv X509_V_ERR_OUT_OF_MEM : No out of memory
396An error occurred trying to allocate memory.
397This should never happen.
398.It Dv X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT : No self signed certificate
399The passed certificate is self signed and the same certificate cannot be
400found in the list of trusted certificates.
401.It Dv X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN : \
402 No self signed certificate in certificate chain
403The certificate chain could be built up using the untrusted certificates
404but the root could not be found locally.
405.It Dv X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY : \
406 No unable to get local issuer certificate
407The issuer certificate could not be found: this occurs if the issuer
408certificate of an untrusted certificate cannot be found.
409.It Dv X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE : \
410 No unable to verify the first certificate
411No signatures could be verified because the chain contains only one
412certificate and it is not self signed.
413.It Dv X509_V_ERR_CERT_CHAIN_TOO_LONG : No certificate chain too long
414The certificate chain length is greater than the supplied maximum depth.
415.It Dv X509_V_ERR_CERT_REVOKED : No certificate revoked
416The certificate has been revoked.
417.It Dv X509_V_ERR_INVALID_CA : No invalid CA certificate
418A CA certificate is invalid.
419Either it is not a CA or its extensions are not consistent with the
420supplied purpose.
421.It Dv X509_V_ERR_PATH_LENGTH_EXCEEDED : No path length constraint exceeded
422The basicConstraints path-length parameter has been exceeded.
423.It Dv X509_V_ERR_INVALID_PURPOSE : No unsupported certificate purpose
424The supplied certificate cannot be used for the specified purpose.
425.It Dv X509_V_ERR_CERT_UNTRUSTED : No certificate not trusted
426The root CA is not marked as trusted for the specified purpose.
427.It Dv X509_V_ERR_CERT_REJECTED : No certificate rejected
428The root CA is marked to reject the specified purpose.
429.It Dv X509_V_ERR_SUBJECT_ISSUER_MISMATCH : No subject issuer mismatch
430The current candidate issuer certificate was rejected because its
431subject name did not match the issuer name of the current certificate.
432This is only set if issuer check debugging is enabled; it is used for
433status notification and is
434.Sy not
435in itself an error.
436.It Dv X509_V_ERR_AKID_SKID_MISMATCH : \
437 No authority and subject key identifier mismatch
438The current candidate issuer certificate was rejected because its
439subject key identifier was present and did not match the authority key
440identifier current certificate.
441This is only set if issuer check debugging is enabled; it is used for
442status notification and is
443.Sy not
444in itself an error.
445.It Dv X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH : \
446 No authority and issuer serial number mismatch
447The current candidate issuer certificate was rejected because its issuer
448name and serial number was present and did not match the authority key
449identifier of the current certificate.
450This is only set if issuer check debugging is enabled; it is used for
451status notification and is
452.Sy not
453in itself an error.
454.It Dv X509_V_ERR_KEYUSAGE_NO_CERTSIGN : \
455 No key usage does not include certificate signing
456The current candidate issuer certificate was rejected because its
457keyUsage extension does not permit certificate signing.
458This is only set if issuer check debugging is enabled it is used for
459status notification and is
460.Sy not
461in itself an error.
462.It Dv X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER : \
463 No unable to get CRL issuer certificate
464The CRL's issuer could not be found:
465there is no alternative CRL issuer set on
466.Ar ctx
467and the last certificate in the chain is not self signed.
468.It Dv X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION : \
469 No unhandled critical extension
470The certificate contains a critical extension that is unsupported
471by the library.
472.It Dv X509_V_ERR_KEYUSAGE_NO_CRL_SIGN : \
473 No key usage does not include CRL signing
474The CRL issuer has a key usage extension with unset cRLSign bit.
475.It Dv X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION : \
476 No unhandled critical CRL extension
477The CRL contains a critical extension that is unsupported
478by the library.
479.\" XXX - The following are unreachable (X509_V_ERR_INVALID_NON_CA) or unused.
480.\" .It Dv X509_V_ERR_INVALID_NON_CA : \
481.\" No invalid non-CA certificate (has CA markings)
482.\" .It Dv X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED : \
483.\" No proxy path length constraint exceeded
484.\" .It Dv X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE : \
485.\" No key usage does not include digital signature
486.\" .It Dv X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED : \
487.\" No proxy certificates not allowed, please set the appropriate flag
488.It Dv X509_V_ERR_INVALID_EXTENSION : \
489 No invalid or inconsistent certificate extension
490A certificate extension had an invalid value (for example an incorrect
491encoding) or some value inconsistent with other extensions.
492.It Dv X509_V_ERR_INVALID_POLICY_EXTENSION : \
493 No invalid or inconsistent certificate policy extension
494A certificate policies extension had an invalid value (for example an
495incorrect encoding) or some value inconsistent with other extensions.
496This error only occurs if policy processing is enabled.
497.It Dv X509_V_ERR_NO_EXPLICIT_POLICY : No no explicit policy
498The verification flags were set to require an explicit policy but none
499was present.
500.It Dv X509_V_ERR_DIFFERENT_CRL_SCOPE : No different CRL scope
501The only CRLs that could be found did not match the scope of the
502certificate.
503.It Dv X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE : \
504 No unsupported extension feature
505Some feature of a certificate extension is not supported.
506Unused.
507.It Dv X509_V_ERR_UNNESTED_RESOURCE : \
508 No RFC 3779 resource not subset of parent's resources
509When walking up a certificate chain, all resources specified in
510RFC 3779 extensions must be contained in the resources delegated in
511the issuer's RFC 3779 extensions.
512The error indicates that this is not the case or that the trust anchor
513has inheritance.
514.It Dv X509_V_ERR_PERMITTED_VIOLATION : No permitted subtree violation
515A name constraint violation occurred in the permitted subtrees.
516.It Dv X509_V_ERR_EXCLUDED_VIOLATION : No excluded subtree violation
517A name constraint violation occurred in the excluded subtrees.
518.It Dv X509_V_ERR_SUBTREE_MINMAX : \
519 No name constraints minimum and maximum not supported
520A certificate name constraints extension included a minimum or maximum
521field: this is not supported.
522.It Dv X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE : \
523 No unsupported name constraint type
524An unsupported name constraint type was encountered.
525OpenSSL currently only supports directory name, DNS name, email and URI
526types.
527.It Dv X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX : \
528 No unsupported or invalid name constraint syntax
529The format of the name constraint is not recognised: for example an
530email address format of a form not mentioned in RFC 3280.
531This could be caused by a garbage extension or some new feature not
532currently supported.
533.\" X509_V_ERR_UNSUPPORTED_NAME_SYNTAX : No unsupported or invalid name syntax
534.It Dv X509_V_ERR_CRL_PATH_VALIDATION_ERROR : No CRL path validation error
535An error occurred when attempting to verify the CRL path.
536This error can only happen if extended CRL checking is enabled.
537.It Dv X509_V_ERR_APPLICATION_VERIFICATION : \
538 No application verification failure
539An application specific error.
540This will never be returned unless explicitly set by an application.
541.\" .It Dv X509_V_ERR_HOSTNAME_MISMATCH : No Hostname mismatch
542.\" .It Dv X509_V_ERR_EMAIL_MISMATCH : No Email address mismatch
543.\" .It Dv X509_V_ERR_IP_ADDRESS_MISMATCH : No IP address mismatch
544.\" .It Dv X509_V_ERR_INVALID_CALL : \
545.\" No Invalid certificate verification context
546.\" .It Dv X509_V_ERR_STORE_LOOKUP : No Issuer certificate lookup error
547.\" .It Dv X509_V_ERR_EE_KEY_TOO_SMALL : No EE certificate key too weak
548.\" .It Dv X509_V_ERR_CA_KEY_TOO_SMALL : No CA certificate key too weak
549.\" .It Dv X509_V_ERR_CA_MD_TOO_WEAK : \
550.\" No CA signature digest algorithm too weak
551.El
552.Sh SEE ALSO
553.Xr X509_STORE_CTX_new 3 ,
554.Xr X509_STORE_CTX_set_verify 3 ,
555.Xr X509_STORE_CTX_set_verify_cb 3 ,
556.Xr X509_STORE_set_verify_cb 3 ,
557.Xr X509_up_ref 3 ,
558.Xr X509_verify_cert 3
559.Sh HISTORY
560.Fn X509_STORE_CTX_get_error ,
561.Fn X509_STORE_CTX_set_error ,
562.Fn X509_STORE_CTX_get_error_depth ,
563.Fn X509_STORE_CTX_get_current_cert ,
564.Fn X509_STORE_CTX_get_chain ,
565and
566.Fn X509_verify_cert_error_string
567first appeared in SSLeay 0.8.0 and have been available since
568.Ox 2.4 .
569.Pp
570.Fn X509_STORE_CTX_get1_chain
571first appeared in OpenSSL 0.9.5 and has been available since
572.Ox 2.7 .
573.Pp
574.Fn X509_STORE_CTX_get0_current_issuer ,
575.Fn X509_STORE_CTX_get0_current_crl ,
576and
577.Fn X509_STORE_CTX_get0_parent_ctx
578first appeared in OpenSSL 1.0.0 and have been available since
579.Ox 4.9 .
580.Pp
581.Fn X509_STORE_CTX_get0_chain
582first appeared in OpenSSL 1.1.0 and has been available since
583.Ox 6.3 .
584.Pp
585.Fn X509_STORE_CTX_set_error_depth ,
586.Fn X509_STORE_CTX_set_current_cert ,
587.Fn X509_STORE_CTX_get_num_untrusted ,
588and
589.Fn X509_STORE_CTX_set0_verified_chain
590first appeared in OpenSSL 1.1.0 and have been available since
591.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3 b/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3
deleted file mode 100644
index bfec65a123..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3
+++ /dev/null
@@ -1,153 +0,0 @@
1.\" $OpenBSD: X509_STORE_CTX_get_ex_new_index.3,v 1.6 2021/07/29 08:32:13 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2009, 2014 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: July 29 2021 $
52.Dt X509_STORE_CTX_GET_EX_NEW_INDEX 3
53.Os
54.Sh NAME
55.Nm X509_STORE_CTX_get_ex_new_index ,
56.Nm X509_STORE_CTX_set_ex_data ,
57.Nm X509_STORE_CTX_get_ex_data ,
58.Nm X509_STORE_CTX_set_app_data ,
59.Nm X509_STORE_CTX_get_app_data
60.Nd add application specific data to X509_STORE_CTX structures
61.Sh SYNOPSIS
62.In openssl/x509_vfy.h
63.Ft int
64.Fo X509_STORE_CTX_get_ex_new_index
65.Fa "long argl"
66.Fa "void *argp"
67.Fa "CRYPTO_EX_new *new_func"
68.Fa "CRYPTO_EX_dup *dup_func"
69.Fa "CRYPTO_EX_free *free_func"
70.Fc
71.Ft int
72.Fo X509_STORE_CTX_set_ex_data
73.Fa "X509_STORE_CTX *d"
74.Fa "int idx"
75.Fa "void *arg"
76.Fc
77.Ft void *
78.Fo X509_STORE_CTX_get_ex_data
79.Fa "X509_STORE_CTX *d"
80.Fa "int idx"
81.Fc
82.Ft int
83.Fo X509_STORE_CTX_set_app_data
84.Fa "X509_STORE_CTX *d"
85.Fa "void *arg"
86.Fc
87.Ft void *
88.Fo X509_STORE_CTX_get_app_data
89.Fa "X509_STORE_CTX *d"
90.Fc
91.Sh DESCRIPTION
92These functions handle application specific data in
93.Vt X509_STORE_CTX
94structures.
95Their usage is identical to that of
96.Xr RSA_get_ex_new_index 3 ,
97.Xr RSA_set_ex_data 3 ,
98and
99.Xr RSA_get_ex_data 3 .
100.Pp
101This mechanism is used internally by the
102.Xr ssl 3
103library to store the
104.Vt SSL
105structure associated with a verification operation in an
106.Vt X509_STORE_CTX
107structure.
108.Pp
109.Fn X509_STORE_CTX_set_app_data
110and
111.Fn X509_STORE_CTX_get_app_data
112are macros calling
113.Fn X509_STORE_CTX_set_ex_data
114and
115.Fn X509_STORE_CTX_get_ex_data ,
116respectively, with an
117.Fa idx
118of 0.
119.Sh RETURN VALUES
120.Fn X509_STORE_CTX_get_ex_new_index
121returns a new index or \-1 on failure.
122.Pp
123.Fn X509_STORE_CTX_set_ex_data
124and
125.Fn X509_STORE_CTX_set_app_data
126return 1 on success or 0 on failure.
127.Pp
128.Fn X509_STORE_CTX_get_ex_data
129and
130.Fn X509_STORE_CTX_get_app_data
131return the application data or
132.Dv NULL
133on failure.
134.Dv NULL
135may also be valid application data, but currently these functions
136can only fail if given an invalid
137.Fa idx
138argument.
139.Sh SEE ALSO
140.Xr RSA_get_ex_new_index 3 ,
141.Xr X509_STORE_CTX_new 3
142.Sh HISTORY
143.Fn X509_STORE_CTX_set_app_data
144and
145.Fn X509_STORE_CTX_get_app_data
146first appeared in SSLeay 0.8.0 and
147.Fn X509_STORE_CTX_get_ex_new_index ,
148.Fn X509_STORE_CTX_set_ex_data ,
149and
150.Fn X509_STORE_CTX_get_ex_data
151in SSLeay 0.9.0.
152All these functions have been available since
153.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_new.3 b/src/lib/libcrypto/man/X509_STORE_CTX_new.3
deleted file mode 100644
index 96af7a8afb..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_CTX_new.3
+++ /dev/null
@@ -1,365 +0,0 @@
1.\" $OpenBSD: X509_STORE_CTX_new.3,v 1.27 2022/11/16 14:55:40 schwarze Exp $
2.\" full merge up to: OpenSSL aae41f8c Jun 25 09:47:15 2015 +0100
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
23.\" and Rich Salz <rsalz@openssl.org>.
24.\" Copyright (c) 2009, 2016 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: November 16 2022 $
71.Dt X509_STORE_CTX_NEW 3
72.Os
73.Sh NAME
74.Nm X509_STORE_CTX_new ,
75.Nm X509_STORE_CTX_init ,
76.Nm X509_STORE_CTX_cleanup ,
77.Nm X509_STORE_CTX_free ,
78.Nm X509_STORE_CTX_get0_store ,
79.Nm X509_STORE_CTX_set0_trusted_stack ,
80.Nm X509_STORE_CTX_trusted_stack ,
81.Nm X509_STORE_CTX_set_cert ,
82.Nm X509_STORE_CTX_get0_cert ,
83.\" X509_STORE_CTX_get0_chain moved to X509_STORE_CTX_get_error(3)
84.Nm X509_STORE_CTX_set_chain ,
85.Nm X509_STORE_CTX_set0_untrusted ,
86.Nm X509_STORE_CTX_get0_untrusted ,
87.Nm X509_STORE_CTX_set0_crls
88.\" X509_STORE_CTX_verify_fn moved to X509_STORE_CTX_set_verify(3)
89.\" X509_STORE_CTX_set_verify moved to X509_STORE_CTX_set_verify(3)
90.Nd X509_STORE_CTX initialisation
91.Sh SYNOPSIS
92.In openssl/x509_vfy.h
93.Ft X509_STORE_CTX *
94.Fn X509_STORE_CTX_new void
95.Ft int
96.Fo X509_STORE_CTX_init
97.Fa "X509_STORE_CTX *ctx"
98.Fa "X509_STORE *store"
99.Fa "X509 *x"
100.Fa "STACK_OF(X509) *untrusted"
101.Fc
102.Ft void
103.Fo X509_STORE_CTX_cleanup
104.Fa "X509_STORE_CTX *ctx"
105.Fc
106.Ft void
107.Fo X509_STORE_CTX_free
108.Fa "X509_STORE_CTX *ctx"
109.Fc
110.Ft X509_STORE *
111.Fo X509_STORE_CTX_get0_store
112.Fa "X509_STORE_CTX *ctx"
113.Fc
114.Ft void
115.Fo X509_STORE_CTX_set0_trusted_stack
116.Fa "X509_STORE_CTX *ctx"
117.Fa "STACK_OF(X509) *trusted"
118.Fc
119.Ft void
120.Fo X509_STORE_CTX_trusted_stack
121.Fa "X509_STORE_CTX *ctx"
122.Fa "STACK_OF(X509) *trusted"
123.Fc
124.Ft void
125.Fo X509_STORE_CTX_set_cert
126.Fa "X509_STORE_CTX *ctx"
127.Fa "X509 *x"
128.Fc
129.Ft X509 *
130.Fo X509_STORE_CTX_get0_cert
131.Fa "X509_STORE_CTX *ctx"
132.Fc
133.Ft void
134.Fo X509_STORE_CTX_set_chain
135.Fa "X509_STORE_CTX *ctx"
136.Fa "STACK_OF(X509) *untrusted"
137.Fc
138.Ft void
139.Fo X509_STORE_CTX_set0_untrusted
140.Fa "X509_STORE_CTX *ctx"
141.Fa "STACK_OF(X509) *untrusted"
142.Fc
143.Ft STACK_OF(X509) *
144.Fo X509_STORE_CTX_get0_untrusted
145.Fa "X509_STORE_CTX *ctx"
146.Fc
147.Ft void
148.Fo X509_STORE_CTX_set0_crls
149.Fa "X509_STORE_CTX *ctx"
150.Fa "STACK_OF(X509_CRL) *crls"
151.Fc
152.Sh DESCRIPTION
153These functions set up an
154.Vt X509_STORE_CTX
155object for subsequent use by
156.Xr X509_verify_cert 3 .
157.Pp
158.Fn X509_STORE_CTX_new
159allocates an empty
160.Vt X509_STORE_CTX
161object not yet containing the subobjects required for normal operation.
162.Pp
163.Fn X509_STORE_CTX_init
164needs to be called on each new
165.Fa ctx
166before any of the other functions become useful.
167It prepares
168.Fa ctx
169for one single verification operation using
170.Xr X509_verify_cert 3 .
171The trusted certificate
172.Fa store
173to be used, the end entity certificate
174.Fa x
175to be verified, and a set of additional
176.Fa untrusted
177certificates, to be used for building the chain,
178can be supplied, or any or all of them can be set to
179.Dv NULL .
180The three pointers passed in are stored internally, the three objects
181pointed to are not copied, their reference count is not incremented,
182and the caller remains responsible for managing their storage and for
183not freeing them before
184.Fn X509_STORE_CTX_free
185is called on
186.Fa ctx .
187If a
188.Fa store
189is provided, the verification parameters contained in it are copied using
190.Xr X509_VERIFY_PARAM_inherit 3 .
191.Pp
192.Fn X509_STORE_CTX_cleanup
193internally cleans up
194.Fa ctx ,
195returning it to an empty state similar to the one after
196.Fn X509_STORE_CTX_new .
197It can then be reused with a new call to
198.Fn X509_STORE_CTX_init .
199.Pp
200.Fn X509_STORE_CTX_free
201calls
202.Fn X509_STORE_CTX_cleanup
203and frees the storage pointed to by
204.Fa ctx .
205If
206.Fa ctx
207is a
208.Dv NULL
209pointer, no action occurs.
210.Pp
211.Fn X509_STORE_CTX_get0_store
212returns the internal pointer to the trusted certificate
213.Fa store
214that was set with
215.Fn X509_STORE_CTX_init .
216.Pp
217.Fn X509_STORE_CTX_set0_trusted_stack
218sets the set of
219.Fa trusted
220certificates used by
221.Fa ctx .
222This is an alternative way of specifying trusted certificates instead of
223using the
224.Fa store .
225.Fn X509_STORE_CTX_trusted_stack
226is a deprecated alias for
227.Fn X509_STORE_CTX_set0_trusted_stack .
228.Pp
229.Fn X509_STORE_CTX_set_cert
230sets the certificate to be verified in
231.Fa ctx
232to
233.Fa x ,
234overriding the certificate that was set with
235.Fn X509_STORE_CTX_init .
236Again, the certificate is not copied
237and its reference count is not incremented.
238.Pp
239.Fn X509_STORE_CTX_get0_cert
240retrieves the internal pointer to the certificate being verified by
241.Fa ctx ,
242i.e. the last one set using either
243.Fn X509_STORE_CTX_init
244or
245.Fn X509_STORE_CTX_set_cert .
246.Pp
247.Fn X509_STORE_CTX_set_chain
248and
249.Fn X509_STORE_CTX_set0_untrusted
250are identical and set the additional,
251.Fa untrusted
252certificates used by
253.Fa ctx ,
254overriding the set of additional, untrusted certificates that was set with
255.Fn X509_STORE_CTX_init .
256Again, the set and the certificates contained in it are not copied
257and their reference counts are not incremented.
258.Pp
259.Fn X509_STORE_CTX_get0_untrusted
260retrieves the internal pointer
261to the set of additional, untrusted certificates associated with
262.Fa ctx ,
263i.e. the last one set using either
264.Fn X509_STORE_CTX_init ,
265.Fn X509_STORE_CTX_set_chain ,
266or
267.Fn X509_STORE_CTX_set0_untrusted .
268.Pp
269.Fn X509_STORE_CTX_set0_crls
270sets a set of
271.Fa crls
272to use during certificate verification.
273These CRLs will only be used if CRL verification is enabled in the
274associated
275.Vt X509_VERIFY_PARAM
276structure.
277This might be used where additional "useful" CRLs are supplied as part
278of a protocol, for example in a PKCS#7 structure.
279.Pp
280Legacy applications might implicitly use an
281.Vt X509_STORE_CTX
282like this:
283.Bd -literal -offset indent
284X509_STORE_CTX ctx;
285X509_STORE_CTX_init(&ctx, store, cert, chain);
286.Ed
287.Pp
288This is
289.Sy not
290recommended in new applications.
291They should instead do:
292.Bd -literal -offset indent
293X509_STORE_CTX *ctx;
294ctx = X509_STORE_CTX_new();
295if (ctx == NULL)
296 /* Bad error */
297X509_STORE_CTX_init(ctx, store, cert, chain);
298.Ed
299.Sh RETURN VALUES
300.Fn X509_STORE_CTX_new
301returns a newly allocated context or
302.Dv NULL
303if an error occurred.
304.Pp
305.Fn X509_STORE_CTX_init
306returns 1 for success or 0 if an error occurred.
307.Pp
308.Fn X509_STORE_CTX_get0_store
309returns the internal pointer to the trusted certificate store or
310.Dv NULL
311if none was set.
312.Pp
313.Fn X509_STORE_CTX_get0_cert
314returns the internal pointer to the certificate to be verified or
315.Dv NULL
316if no such certificate was set.
317.Pp
318.Fn X509_STORE_CTX_get0_untrusted
319returns the internal pointer
320to the set of additional, untrusted certificates or
321.Dv NULL
322if no set of additional certificates was provided.
323.Sh SEE ALSO
324.Xr X509_CRL_new 3 ,
325.Xr X509_STORE_CTX_get_error 3 ,
326.Xr X509_STORE_CTX_get_ex_new_index 3 ,
327.Xr X509_STORE_CTX_set_flags 3 ,
328.Xr X509_STORE_CTX_set_verify 3 ,
329.Xr X509_STORE_CTX_set_verify_cb 3 ,
330.Xr X509_STORE_get_by_subject 3 ,
331.Xr X509_STORE_new 3 ,
332.Xr X509_STORE_set1_param 3 ,
333.Xr X509_STORE_set_verify_cb 3 ,
334.Xr X509_verify_cert 3 ,
335.Xr X509_VERIFY_PARAM_inherit 3 ,
336.Xr X509_VERIFY_PARAM_set_flags 3
337.Sh HISTORY
338.Fn X509_STORE_CTX_init ,
339.Fn X509_STORE_CTX_cleanup ,
340.Fn X509_STORE_CTX_set_cert ,
341and
342.Fn X509_STORE_CTX_set_chain
343first appeared in SSLeay 0.8.0 and have been available since
344.Ox 2.4 .
345.Pp
346.Fn X509_STORE_CTX_new
347and
348.Fn X509_STORE_CTX_free
349first appeared in OpenSSL 0.9.5 and have been available since
350.Ox 2.7 .
351.Pp
352.Fn X509_STORE_CTX_trusted_stack
353first appeared in OpenSSL 0.9.6 and has been available since
354.Ox 2.9 .
355.Pp
356.Fn X509_STORE_CTX_get0_store
357first appeared in OpenSSL 1.0.2.
358.Fn X509_STORE_CTX_set0_trusted_stack ,
359.Fn X509_STORE_CTX_get0_cert ,
360.Fn X509_STORE_CTX_set0_untrusted ,
361and
362.Fn X509_STORE_CTX_get0_untrusted
363first appeared in OpenSSL 1.1.0.
364These functions have been available since
365.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3 b/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3
deleted file mode 100644
index 04bb202bac..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3
+++ /dev/null
@@ -1,326 +0,0 @@
1.\" $OpenBSD: X509_STORE_CTX_set_flags.3,v 1.8 2024/08/29 20:21:10 tb Exp $
2.\" full merge up to: OpenSSL aae41f8c Jun 25 09:47:15 2015 +0100
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
9.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
10.\"
11.\" Permission to use, copy, modify, and distribute this software for any
12.\" purpose with or without fee is hereby granted, provided that the above
13.\" copyright notice and this permission notice appear in all copies.
14.\"
15.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
16.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
18.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22.\"
23.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
24.\" Copyright (c) 2009 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: August 29 2024 $
71.Dt X509_STORE_CTX_SET_FLAGS 3
72.Os
73.Sh NAME
74.Nm X509_STORE_CTX_set_flags ,
75.Nm X509_STORE_CTX_set_time ,
76.Nm X509_STORE_CTX_set_depth ,
77.Nm X509_STORE_CTX_set_trust ,
78.Nm X509_STORE_CTX_set_purpose ,
79.\" .Nm X509_STORE_CTX_purpose_inherit is intentionally undocumented
80.\" because it will be removed in the next major bump.
81.Nm X509_STORE_CTX_get0_param ,
82.Nm X509_STORE_CTX_set0_param ,
83.Nm X509_STORE_CTX_set_default
84.Nd X509_STORE_CTX parameter initialisation
85.Sh SYNOPSIS
86.In openssl/x509_vfy.h
87.Ft void
88.Fo X509_STORE_CTX_set_flags
89.Fa "X509_STORE_CTX *ctx"
90.Fa "unsigned long flags"
91.Fc
92.Ft void
93.Fo X509_STORE_CTX_set_time
94.Fa "X509_STORE_CTX *ctx"
95.Fa "unsigned long dummy"
96.Fa "time_t time"
97.Fc
98.Ft void
99.Fo X509_STORE_CTX_set_depth
100.Fa "X509_STORE_CTX *ctx"
101.Fa "int depth"
102.Fc
103.Ft int
104.Fo X509_STORE_CTX_set_trust
105.Fa "X509_STORE_CTX *ctx"
106.Fa "int trust"
107.Fc
108.Ft int
109.Fo X509_STORE_CTX_set_purpose
110.Fa "X509_STORE_CTX *ctx"
111.Fa "int purpose"
112.Fc
113.Ft X509_VERIFY_PARAM *
114.Fo X509_STORE_CTX_get0_param
115.Fa "X509_STORE_CTX *ctx"
116.Fc
117.Ft void
118.Fo X509_STORE_CTX_set0_param
119.Fa "X509_STORE_CTX *ctx"
120.Fa "X509_VERIFY_PARAM *param"
121.Fc
122.Ft int
123.Fo X509_STORE_CTX_set_default
124.Fa "X509_STORE_CTX *ctx"
125.Fa "const char *name"
126.Fc
127.Sh DESCRIPTION
128These functions operate on the
129.Vt X509_VERIFY_PARAM
130object used by
131.Fa ctx .
132Usually,
133.Xr X509_STORE_CTX_init 3
134is called on
135.Fa ctx
136before these functions, and
137.Xr X509_verify_cert 3
138afterwards.
139.Pp
140.Fn X509_STORE_CTX_set_flags
141sets the internal verification parameter flags to
142.Fa flags .
143See
144.Xr X509_VERIFY_PARAM_set_flags 3
145for a description of the verification flags.
146.Pp
147.Fn X509_STORE_CTX_set_time
148sets the verification
149.Fa time
150using
151.Xr X509_VERIFY_PARAM_set_time 3 .
152The
153.Fa dummy
154argument is ignored.
155.Pp
156.Fn X509_STORE_CTX_set_depth
157sets the maximum verification
158.Fa depth
159using
160.Xr X509_VERIFY_PARAM_set_depth 3 .
161That is the maximum number of untrusted CA certificates
162that can appear in a chain.
163.Pp
164.Fn X509_STORE_CTX_set_trust
165sets the
166.Fa trust
167identifier that can also be set using
168.Xr X509_VERIFY_PARAM_set_trust 3 .
169If the
170.Fa trust
171argument is 0 or invalid
172or the trust identifier is already set to a non-zero value in the
173.Vt X509_VERIFY_PARAM
174object, no action occurs.
175.Pp
176.Fn X509_STORE_CTX_set_purpose
177sets the
178.Fa purpose
179identifier that can also be set using
180.Xr X509_VERIFY_PARAM_set_purpose 3 .
181If the
182.Fa purpose
183argument is 0 or any failure occurs, nothing is changed.
184.Pp
185In the following, the trust identifier contained in the
186.Vt X509_PURPOSE
187object associated with
188.Fa purpose
189is called the
190.Dq associated trust .
191.Pp
192The function fails if the
193.Fa purpose
194argument or the associated trust is invalid but not 0; otherwise,
195.Fn X509_STORE_CTX_set_purpose
196also does the equivalent of calling
197.Fn X509_STORE_CTX_set_trust
198with the associated trust.
199.Pp
200If the purpose identifier is already set to a non-zero value in the
201.Vt X509_VERIFY_PARAM
202object, it is not changed, even if the
203.Fa purpose
204argument is valid, too.
205.Pp
206.Fn X509_STORE_CTX_get0_param
207retrieves an internal pointer to the verification parameters associated
208with
209.Fa ctx .
210.Pp
211.Fn X509_STORE_CTX_set0_param
212sets the internal verification parameter pointer to
213.Fa param .
214After this call
215.Fa param
216should not be used.
217.Pp
218.Fn X509_STORE_CTX_set_default
219looks up and sets the default verification method to
220.Fa name .
221This uses the function
222.Xr X509_VERIFY_PARAM_lookup 3
223to find an appropriate set of parameters from
224.Fa name
225and copies them using
226.Xr X509_VERIFY_PARAM_inherit 3 .
227.Sh RETURN VALUES
228.Fn X509_STORE_CTX_set_trust
229returns 1 if the
230.Fa trust
231argument is 0 or valid or 0 if it is invalid but not 0.
232A return value of 1 does
233.Em not
234imply that the trust identifier stored in the
235.Vt X509_VERIFY_PARAM
236object was changed.
237.Pp
238.Fn X509_STORE_CTX_set_purpose
239returns 1 if both the
240.Fa purpose
241argument and the associated trust are 0 or valid.
242It returns 0 if either the
243.Fa purpose
244argument or the associated trust is invalid but not 0.
245A return value of 1 does not imply that any data was changed.
246.Pp
247.Fn X509_STORE_CTX_get0_param
248returns a pointer to an
249.Vt X509_VERIFY_PARAM
250structure or
251.Dv NULL
252if an error occurred.
253.Pp
254.Fn X509_STORE_CTX_set_default
255returns 1 for success or 0 if an error occurred.
256.Sh ERRORS
257The following diagnostics can be retrieved with
258.Xr ERR_get_error 3 ,
259.Xr ERR_GET_REASON 3 ,
260and
261.Xr ERR_reason_error_string 3 :
262.Bl -tag -width Ds
263.It Dv X509_R_UNKNOWN_TRUST_ID Qq "unknown trust id"
264.Fn X509_STORE_CTX_set_trust
265was called with a
266.Fa trust
267argument that is invalid but not 0.
268Other implementations may also return this when
269.Fn X509_STORE_CTX_set_purpose
270is called with a
271.Fa purpose
272argument with invalid associated trust.
273.It Dv X509_R_UNKNOWN_PURPOSE_ID Qq "unknown purpose id"
274The
275.Fa purpose
276argument is invalid but not 0.
277.El
278.Pp
279The other functions provide no diagnostics.
280.Sh SEE ALSO
281.Xr X509_STORE_CTX_get_error 3 ,
282.Xr X509_STORE_CTX_new 3 ,
283.Xr X509_STORE_CTX_set_verify 3 ,
284.Xr X509_STORE_CTX_set_verify_cb 3 ,
285.Xr X509_STORE_new 3 ,
286.Xr X509_STORE_set1_param 3 ,
287.Xr X509_STORE_set_verify_cb 3 ,
288.Xr X509_verify_cert 3 ,
289.Xr X509_VERIFY_PARAM_new 3 ,
290.Xr X509_VERIFY_PARAM_set_flags 3
291.Sh HISTORY
292.Fn X509_STORE_CTX_set_depth
293first appeared in OpenSSL 0.9.3 and has been available since
294.Ox 2.4 .
295.Pp
296.Fn X509_STORE_CTX_set_trust
297and
298.Fn X509_STORE_CTX_set_purpose
299first appeared in OpenSSL 0.9.5 and have been available since
300.Ox 2.7 .
301.Pp
302.Fn X509_STORE_CTX_set_flags
303and
304.Fn X509_STORE_CTX_set_time
305first appeared in OpenSSL 0.9.6 and have been available since
306.Ox 2.9 .
307.Pp
308.Fn X509_STORE_CTX_get0_param ,
309.Fn X509_STORE_CTX_set0_param ,
310and
311.Fn X509_STORE_CTX_set_default
312first appeared in OpenSSL 0.9.8 and have been available since
313.Ox 4.5 .
314.Sh CAVEATS
315The precise effect of a successful call to
316.Fn X509_STORE_CTX_set_trust
317and
318.Fn X509_STORE_CTX_set_purpose
319is unclear unless only one of these functions is used immediately after
320.Xr X509_STORE_CTX_init 3 .
321It is therefore recommended to use
322.Fn X509_STORE_CTX_get0_param ,
323.Xr X509_VERIFY_PARAM_set_trust 3 ,
324and
325.Xr X509_VERIFY_PARAM_set_purpose 3
326instead.
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_set_verify.3 b/src/lib/libcrypto/man/X509_STORE_CTX_set_verify.3
deleted file mode 100644
index 8c27deea5d..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_CTX_set_verify.3
+++ /dev/null
@@ -1,256 +0,0 @@
1.\" $OpenBSD: X509_STORE_CTX_set_verify.3,v 1.8 2024/06/07 05:51:39 tb Exp $
2.\"
3.\" Copyright (c) 2021, 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\" Copyright (c) 2023 Job Snijders <job@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: June 7 2024 $
19.Dt X509_STORE_CTX_SET_VERIFY 3
20.Os
21.Sh NAME
22.Nm X509_STORE_CTX_verify_fn ,
23.Nm X509_STORE_CTX_set_verify ,
24.Nm X509_STORE_CTX_get_verify ,
25.Nm X509_STORE_set_verify ,
26.Nm X509_STORE_set_verify_func ,
27.Nm X509_STORE_get_verify ,
28.Nm X509_STORE_CTX_check_issued_fn ,
29.Nm X509_STORE_set_check_issued ,
30.Nm X509_STORE_get_check_issued ,
31.Nm X509_STORE_CTX_get_check_issued
32.Nd user-defined certificate chain verification function
33.Sh SYNOPSIS
34.In openssl/x509_vfy.h
35.Ft typedef int
36.Fo (*X509_STORE_CTX_verify_fn)
37.Fa "X509_STORE_CTX *ctx"
38.Fc
39.Ft void
40.Fo X509_STORE_CTX_set_verify
41.Fa "X509_STORE_CTX *ctx"
42.Fa "X509_STORE_CTX_verify_fn verify"
43.Fc
44.Ft X509_STORE_CTX_verify_fn
45.Fo X509_STORE_CTX_get_verify
46.Fa "X509_STORE_CTX *ctx"
47.Fc
48.Ft void
49.Fo X509_STORE_set_verify
50.Fa "X509_STORE *store"
51.Fa "X509_STORE_CTX_verify_fn verify"
52.Fc
53.Ft void
54.Fo X509_STORE_set_verify_func
55.Fa "X509_STORE *store"
56.Fa "X509_STORE_CTX_verify_fn verify"
57.Fc
58.Ft X509_STORE_CTX_verify_fn
59.Fo X509_STORE_get_verify
60.Fa "X509_STORE_CTX *ctx"
61.Fc
62.Ft typedef int
63.Fo (*X509_STORE_CTX_check_issued_fn)
64.Fa "X509_STORE_CTX *ctx"
65.Fa "X509 *subject"
66.Fa "X509 *issuer"
67.Fc
68.Ft void
69.Fo X509_STORE_set_check_issued
70.Fa "X509_STORE *store"
71.Fa "X509_STORE_CTX_check_issued_fn check_issued"
72.Fc
73.Ft X509_STORE_CTX_check_issued_fn
74.Fo X509_STORE_get_check_issued
75.Fa "X509_STORE *store"
76.Fc
77.Ft X509_STORE_CTX_check_issued_fn
78.Fo X509_STORE_CTX_get_check_issued
79.Fa "X509_STORE_CTX *ctx"
80.Fc
81.Sh DESCRIPTION
82.Fn X509_STORE_CTX_set_verify
83configures
84.Fa ctx
85to use the
86.Fa verify
87argument as the X.509 certificate chain verification function instead
88of the default verification function built into the library when
89.Xr X509_verify_cert 3
90is called.
91.Pp
92The
93.Fa verify
94function provided by the user is only called if the
95.Dv X509_V_FLAG_LEGACY_VERIFY
96or
97.Dv X509_V_FLAG_NO_ALT_CHAINS
98flag was set on
99.Fa ctx
100using
101.Xr X509_STORE_CTX_set_flags 3
102or
103.Xr X509_VERIFY_PARAM_set_flags 3 .
104Otherwise, it is ignored and a different algorithm is used that does
105not support replacing the verification function.
106.Pp
107.Fn X509_STORE_set_verify
108saves the function pointer
109.Fa verify
110in the given
111.Fa store
112object.
113That pointer will be copied to an
114.Vt X509_STORE_CTX
115object when
116.Fa store
117is later passed as an argument to
118.Xr X509_STORE_CTX_init 3 .
119.Pp
120.Fn X509_STORE_set_verify_func
121is an alias for
122.Fn X509_STORE_set_verify
123implemented as a macro.
124.Pp
125.Fn X509_STORE_set_check_issued
126saves the function pointer
127.Fa check_issued
128in the given
129.Fa store
130object.
131That pointer will be copied to an
132.Vt X509_STORE_CTX
133object when
134.Fa store
135is later passed as an argument to
136.Fn X509_STORE_CTX_init 3 .
137.Pp
138The
139.Fa check_issued
140function provided by the user should check whether a given certificate
141.Fa subject
142was issued using the CA certificate
143.Fa issuer ,
144and must return 0 on failure and 1 on success.
145The default implementation ignores the
146.Fa ctx
147argument and returns success if and only if
148.Xr X509_check_issued 3
149returns
150.Dv X509_V_OK .
151It is important to pay close attention to the order of the
152.Fa issuer
153and
154.Fa subject
155arguments.
156In
157.Xr X509_check_issued 3
158the
159.Fa issuer
160precedes the
161.Fa subject
162while in
163.Fn check_issued
164the
165.Fa subject
166comes first.
167.Sh RETURN VALUES
168.Fn X509_STORE_CTX_verify_fn
169is supposed to return 1 to indicate that the chain is valid
170or 0 if it is not or if an error occurred.
171.Pp
172.Fn X509_STORE_CTX_get_verify
173returns a function pointer previously set with
174.Fn X509_STORE_CTX_set_verify
175or
176.Xr X509_STORE_CTX_init 3 ,
177or
178.Dv NULL
179if
180.Fa ctx
181is uninitialized.
182.Pp
183.Fn X509_STORE_get_verify
184returns the function pointer previously set with
185.Fn X509_STORE_set_verify ,
186or
187.Dv NULL
188if that function was not called on the
189.Fa store .
190.Pp
191.Fn X509_STORE_get_check_issued
192returns the function pointer previously set with
193.Fn X509_STORE_set_check_issued ,
194or
195.Dv NULL
196if that function was not called on the
197.Fa store .
198.Pp
199.Fn X509_STORE_CTX_get_check_issued
200returns the
201.Fn check_issued
202function pointer set on the
203.Vt X509_STORE_CTX .
204This is either the
205.Fn check_issued
206function inherited from the
207.Fa store
208used in
209.Xr X509_STORE_CTX_init 3
210or the library's default implementation.
211.Sh SEE ALSO
212.Xr X509_check_issued 3 ,
213.Xr X509_STORE_CTX_init 3 ,
214.Xr X509_STORE_CTX_set_error 3 ,
215.Xr X509_STORE_CTX_set_flags 3 ,
216.Xr X509_STORE_CTX_set_verify_cb 3 ,
217.Xr X509_STORE_new 3 ,
218.Xr X509_STORE_set_flags 3 ,
219.Xr X509_STORE_set_verify_cb 3 ,
220.Xr X509_verify_cert 3 ,
221.Xr X509_VERIFY_PARAM_set_flags 3
222.Sh HISTORY
223.Fn X509_STORE_set_verify_func
224first appeared in SSLeay 0.8.0 and has been available since
225.Ox 2.4 .
226.Pp
227.Fn X509_STORE_CTX_set_verify
228and
229.Fn X509_STORE_CTX_get_verify
230first appeared in OpenSSL 1.1.0 and have been available since
231.Ox 7.1 .
232.Pp
233.Fn X509_STORE_CTX_verify_fn ,
234.Fn X509_STORE_set_verify ,
235and
236.Fn X509_STORE_get_verify
237first appeared in OpenSSL 1.1.0 and have been available since
238.Ox 7.2 .
239.Pp
240.Fn X509_STORE_set_check_issued ,
241.Fn X509_STORE_get_check_issued ,
242and
243.Fn X509_STORE_CTX_get_check_issued
244first appeared in OpenSSL 1.1.0 and have been available since
245.Ox 7.3 .
246.Sh BUGS
247The reversal of order of
248.Fa subject
249and
250.Fa issuer
251between
252.Fn check_issued
253and
254.Xr X509_check_issued 3
255is very confusing.
256It has led to bugs and will cause many more.
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3 b/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3
deleted file mode 100644
index 0fe086b721..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3
+++ /dev/null
@@ -1,309 +0,0 @@
1.\" $OpenBSD: X509_STORE_CTX_set_verify_cb.3,v 1.12 2023/05/30 07:37:34 op Exp $
2.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2009 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: May 30 2023 $
70.Dt X509_STORE_CTX_SET_VERIFY_CB 3
71.Os
72.Sh NAME
73.Nm X509_STORE_CTX_verify_cb ,
74.Nm X509_STORE_CTX_set_verify_cb ,
75.Nm X509_STORE_CTX_get_verify_cb
76.Nd set and retrieve verification callback
77.Sh SYNOPSIS
78.In openssl/x509_vfy.h
79.Ft typedef int
80.Fo (*X509_STORE_CTX_verify_cb)
81.Fa "int ok"
82.Fa "X509_STORE_CTX *ctx"
83.Fc
84.Ft void
85.Fo X509_STORE_CTX_set_verify_cb
86.Fa "X509_STORE_CTX *ctx"
87.Fa "X509_STORE_CTX_verify_cb verify_cb"
88.Fc
89.Ft X509_STORE_CTX_verify_cb
90.Fo X509_STORE_CTX_get_verify_cb
91.Fa "X509_STORE_CTX *ctx"
92.Fc
93.Sh DESCRIPTION
94.Fn X509_STORE_CTX_set_verify_cb
95sets the verification callback of
96.Fa ctx
97to
98.Fa verify_cb
99overwriting any existing callback.
100.Pp
101The verification callback can be used to modify the operation of
102certificate verification, either by overriding error conditions or
103logging errors for debugging purposes.
104The use of a verification callback is not essential, and should not
105be used in security sensitive programs.
106.Pp
107Do not use this function.
108It is extremely fragile and unpredictable.
109This callback exposes implementation details of certificate verification,
110which change as the library evolves.
111Attempting to use it for security checks can introduce vulnerabilities if
112making incorrect assumptions about when the callback is called.
113Additionally, overriding
114.Fa ok
115may leave
116.Fa ctx
117in an inconsistent state and break invariants.
118.Pp
119Instead, customize certificate verification by configuring options on the
120.Vt X509_STORE_CTX
121before verification, or applying additional checks after
122.Xr X509_verify_cert 3
123completes successfully.
124.Pp
125The
126.Fa ok
127parameter to the callback indicates the value the callback should return
128to retain the default behaviour.
129If it is zero then an error condition is indicated.
130If it is 1 then no error occurred.
131As the default behaviour is internal to the verifier, and possibly unknown
132to the caller, changing this parameter is inherently dangerous and should not
133normally be done except for debugging purposes, and should not be expected to
134be consistent if the verifier changes.
135If the flag
136.Dv X509_V_FLAG_NOTIFY_POLICY
137is set, then
138.Fa ok
139is set to 2 to indicate the policy checking is complete.
140.Pp
141The
142.Fa ctx
143parameter to the callback is the
144.Vt X509_STORE_CTX
145structure that is performing the verification operation.
146A callback can examine this structure and receive additional information
147about the error, for example by calling
148.Xr X509_STORE_CTX_get_current_cert 3 .
149Additional application data can be passed to the callback via the
150.Sy ex_data
151mechanism.
152.Pp
153The verification callback can be set and inherited from the parent
154structure performing the operation.
155In some cases (such as S/MIME verification) the
156.Vt X509_STORE_CTX
157structure is created and destroyed internally and the only way to set a
158custom verification callback is by inheriting it from the associated
159.Vt X509_STORE .
160.Sh RETURN VALUES
161.Fn X509_STORE_CTX_get_verify_cb
162returns a pointer to the current callback function
163used by the specified
164.Fa ctx .
165If no callback was set using
166.Fn X509_STORE_CTX_set_verify_cb ,
167that is a pointer to a built-in static function
168which does nothing except returning the
169.Fa ok
170argument passed to it.
171.Sh EXAMPLES
172Default callback operation:
173.Bd -literal
174int
175verify_callback(int ok, X509_STORE_CTX *ctx)
176{
177 return ok;
178}
179.Ed
180.Pp
181This is likely the only safe callback to use.
182.Pp
183Simple and terrible example that should not be used.
184Suppose a certificate in the chain is expired and we
185wish to continue after this error:
186.Bd -literal
187int
188verify_callback(int ok, X509_STORE_CTX *ctx)
189{
190 /* Tolerate certificate expiration */
191 if (X509_STORE_CTX_get_error(ctx) == X509_V_ERR_CERT_HAS_EXPIRED)
192 return 1;
193 /* Otherwise don't override */
194 return ok;
195}
196.Ed
197.Pp
198While this example is presented for historical purposes,
199this is not the correct way to accomplish this.
200The verification flag
201.Dv X509_V_FLAG_NO_CHECK_TIME
202should be set on the
203.Vt STORE_CTX
204using
205.Xr X509_VERIFY_PARAM_set_flags 3
206instead.
207.Pp
208Full featured debugging logging callback - note that the output and
209order that things happen from this can change over time and should not
210be parsed or expected to be consistent.
211In this case the
212.Fa bio_err
213is assumed to be a global logging
214.Vt BIO ,
215an alternative would to store a
216.Vt BIO
217in
218.Fa ctx
219using
220.Sy ex_data .
221.Bd -literal
222int
223verify_callback(int ok, X509_STORE_CTX *ctx)
224{
225 X509 *err_cert;
226 int err,depth;
227
228 err_cert = X509_STORE_CTX_get_current_cert(ctx);
229 err = X509_STORE_CTX_get_error(ctx);
230 depth = X509_STORE_CTX_get_error_depth(ctx);
231
232 BIO_printf(bio_err,"depth=%d ",depth);
233 if (err_cert) {
234 X509_NAME_print_ex(bio_err,
235 X509_get_subject_name(err_cert), 0,
236 XN_FLAG_ONELINE);
237 BIO_puts(bio_err, "\en");
238 } else
239 BIO_puts(bio_err, "<no cert>\en");
240 if (!ok)
241 BIO_printf(bio_err, "verify error:num=%d:%s\en",
242 err, X509_verify_cert_error_string(err));
243 switch (err) {
244 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
245 BIO_puts(bio_err, "issuer= ");
246 X509_NAME_print_ex(bio_err,
247 X509_get_issuer_name(err_cert), 0,
248 XN_FLAG_ONELINE);
249 BIO_puts(bio_err, "\en");
250 break;
251 case X509_V_ERR_CERT_NOT_YET_VALID:
252 case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
253 BIO_printf(bio_err, "notBefore=");
254 ASN1_TIME_print(bio_err,
255 X509_get_notBefore(err_cert));
256 BIO_printf(bio_err, "\en");
257 break;
258 case X509_V_ERR_CERT_HAS_EXPIRED:
259 case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
260 BIO_printf(bio_err, "notAfter=");
261 ASN1_TIME_print(bio_err, X509_get_notAfter(err_cert));
262 BIO_printf(bio_err, "\en");
263 break;
264 case X509_V_ERR_NO_EXPLICIT_POLICY:
265 policies_print(bio_err, ctx);
266 break;
267 }
268 if (err == X509_V_OK && ok == 2)
269 /* print out policies */
270
271 BIO_printf(bio_err,"verify return:%d\en",ok);
272 return(ok);
273}
274.Ed
275.Sh SEE ALSO
276.Xr X509_STORE_CTX_get_error 3 ,
277.Xr X509_STORE_CTX_get_ex_new_index 3 ,
278.Xr X509_STORE_CTX_new 3 ,
279.Xr X509_STORE_CTX_set_error 3 ,
280.Xr X509_STORE_CTX_set_flags 3 ,
281.Xr X509_STORE_CTX_set_verify 3 ,
282.Xr X509_STORE_set_verify_cb 3 ,
283.Xr X509_verify_cert 3 ,
284.Xr X509_VERIFY_PARAM_set_flags 3
285.Sh HISTORY
286.Fn X509_STORE_CTX_set_verify_cb
287first appeared in OpenSSL 0.9.6c and has been available since
288.Ox 3.2 .
289.Pp
290.Fn X509_STORE_CTX_get_verify_cb
291first appeared in OpenSSL 1.1.0 and has been available since
292.Ox 7.1 .
293.Pp
294.Fn X509_STORE_CTX_verify_cb
295first appeared in OpenSSL 1.1.0 and has been available since
296.Ox 7.2 .
297.Sh CAVEATS
298In general a verification callback should
299.Sy NOT
300return a changed value of
301.Fa ok
302because this can allow the verification to appear to succeed
303in an unpredictable way.
304This can effectively remove all security from the application because
305untrusted or invalid certificates may be accepted.
306Doing this can possibly make
307.Xr X509_verify_cert 3
308return what appears to be a validated chain of certificates that has not
309been validated or even had the signatures checked.
diff --git a/src/lib/libcrypto/man/X509_STORE_get_by_subject.3 b/src/lib/libcrypto/man/X509_STORE_get_by_subject.3
deleted file mode 100644
index 0f6fbd8410..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_get_by_subject.3
+++ /dev/null
@@ -1,246 +0,0 @@
1.\" $OpenBSD: X509_STORE_get_by_subject.3,v 1.6 2024/05/12 05:08:59 tb Exp $
2.\"
3.\" Copyright (c) 2021, 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: May 12 2024 $
18.Dt X509_STORE_GET_BY_SUBJECT 3
19.Os
20.Sh NAME
21.Nm X509_STORE_CTX_get_by_subject ,
22.Nm X509_STORE_CTX_get_obj_by_subject ,
23.Nm X509_STORE_CTX_get1_certs ,
24.Nm X509_STORE_CTX_get1_crls ,
25.Nm X509_STORE_CTX_get1_issuer ,
26.Nm X509_STORE_get_by_subject ,
27.Nm X509_STORE_get1_certs ,
28.Nm X509_STORE_get1_crls
29.Nd retrieve objects from a certificate store
30.Sh SYNOPSIS
31.In openssl/x509_vfy.h
32.Ft int
33.Fo X509_STORE_CTX_get_by_subject
34.Fa "X509_STORE_CTX *ctx"
35.Fa "X509_LOOKUP_TYPE type"
36.Fa "X509_NAME *name"
37.Fa "X509_OBJECT *object"
38.Fc
39.Ft X509_OBJECT *
40.Fo X509_STORE_CTX_get_obj_by_subject
41.Fa "X509_STORE_CTX *ctx"
42.Fa "X509_LOOKUP_TYPE type"
43.Fa "X509_NAME *name"
44.Fc
45.Ft STACK_OF(X509) *
46.Fo X509_STORE_CTX_get1_certs
47.Fa "X509_STORE_CTX *ctx"
48.Fa "X509_NAME *name"
49.Fc
50.Ft STACK_OF(X509_CRL) *
51.Fo X509_STORE_CTX_get1_crls
52.Fa "X509_STORE_CTX *ctx"
53.Fa "X509_NAME *name"
54.Fc
55.Ft int
56.Fo X509_STORE_CTX_get1_issuer
57.Fa "X509 **issuer"
58.Fa "X509_STORE_CTX *ctx"
59.Fa "X509 *certificate"
60.Fc
61.Ft int
62.Fo X509_STORE_get_by_subject
63.Fa "X509_STORE_CTX *ctx"
64.Fa "X509_LOOKUP_TYPE type"
65.Fa "X509_NAME *name"
66.Fa "X509_OBJECT *object"
67.Fc
68.Ft STACK_OF(X509) *
69.Fo X509_STORE_get1_certs
70.Fa "X509_STORE_CTX *ctx"
71.Fa "X509_NAME *name"
72.Fc
73.Ft STACK_OF(X509_CRL) *
74.Fo X509_STORE_get1_crls
75.Fa "X509_STORE_CTX *ctx"
76.Fa "X509_NAME *name"
77.Fc
78.Sh DESCRIPTION
79.Fn X509_STORE_CTX_get_by_subject
80retrieves the first object having a matching
81.Fa type
82and
83.Fa name
84from the
85.Vt X509_STORE
86associated with the
87.Fa ctx .
88The
89.Fa type
90can be
91.Dv X509_LU_X509
92to retrieve a certificate or
93.Dv X509_LU_CRL
94to retrieve a revocation list.
95.Pp
96If the store does not yet contain a matching object or if the type is
97.Dv X509_LU_CRL ,
98a lookup by subject is performed on
99.Vt X509_LOOKUP
100objects associated with the store until a match is found,
101which may add zero or more objects to the store.
102.Pp
103In case of success, the content of the
104.Fa object
105provided by the caller is overwritten with a pointer to the first
106match, and the reference count of that certificate or revocation
107list is incremented by 1.
108Avoiding a memory leak by making sure the provided
109.Fa object
110is empty is the responsibility of the caller.
111.Pp
112.Fn X509_STORE_CTX_get_obj_by_subject
113is similar except that a new object is allocated and returned.
114.Pp
115.Fn X509_STORE_CTX_get1_certs
116retrieves all certificates matching the subject
117.Vt name
118from the
119.Vt X509_STORE
120associated with
121.Fa ctx .
122If there are none yet,
123.Fn X509_STORE_CTX_get_by_subject
124is called to try and add some.
125In case of success, the reference counts of all certificates
126added to the returned array are incremented by 1.
127.Pp
128.Fn X509_STORE_CTX_get1_crls
129is similar except that it operates on certificate revocation lists
130rather than on certificates and that it always calls
131.Fn X509_STORE_CTX_get_by_subject ,
132even if the
133.Vt X509_STORE
134already contains a matching revocation list.
135.Pp
136.Fn X509_STORE_CTX_get1_issuer
137retrieves the
138.Fa issuer
139CA certificate for the given
140.Fa certificate
141from the
142.Vt X509_STORE
143associated with
144.Fa ctx .
145Internally, the issuer name is retrieved with
146.Xr X509_get_issuer_name 3
147and the candidate issuer CA certificate with
148.Fn X509_STORE_X509_get_by_subject
149using that issuer name.
150.Xr X509_check_issued 3
151or a user-supplied replacement function is used to check whether the
152.Fa certificate
153was indeed issued using the
154.Fa issuer
155CA certificate before returning it.
156If verification parameters associated with
157.Fa ctx
158encourage checking of validity times, CAs with a valid time are
159preferred, but if no matching CA has a valid time, one with an
160invalid time is accepted anyway.
161.Pp
162The following are deprecated aliases implemented as macros:
163.Bl -column X509_STORE_get_by_subject F X509_STORE_CTX_get_by_subject
164.It Fn X509_STORE_get_by_subject Ta for Ta Fn X509_STORE_CTX_get_by_subject
165.It Fn X509_STORE_get1_certs Ta for Ta Fn X509_STORE_CTX_get1_certs
166.It Fn X509_STORE_get1_crls Ta for Ta Fn X509_STORE_CTX_get1_crls
167.El
168.Sh RETURN VALUES
169.Fn X509_STORE_CTX_get_by_subject
170and
171.Fn X509_STORE_get_by_subject
172return 1 if a match is found or 0 on failure.
173In addition to simply not finding a match,
174they may also fail due to memory allocation failure.
175With library implementations other than LibreSSL,
176they might also return negative values for internal errors.
177.Pp
178.Fn X509_STORE_CTX_get_obj_by_subject
179returns the new object or
180.Dv NULL
181on failure, in particular if no match is found or memory allocation fails.
182.Pp
183.Fn X509_STORE_CTX_get1_certs
184and
185.Fn X509_STORE_get1_certs
186return a newly allocated and populated array of certificates or
187.Dv NULL
188on failure.
189They fail if no match is found, if
190.Fn X509_STORE_CTX_get_by_subject
191fails, or if memory allocation fails.
192.Pp
193.Fn X509_STORE_CTX_get1_crls
194and
195.Fn X509_STORE_get1_crls
196return a newly allocated and populated array of CRLs or
197.Dv NULL
198on failure.
199They fail if
200.Fn X509_STORE_CTX_get_by_subject
201finds no new match, even if the associated
202.Vt X509_STORE
203already contains matching CRLs, or if memory allocation fails.
204.Pp
205.Fn X509_STORE_CTX_get1_issuer
206returns 1 if a matching
207.Fa issuer
208CA certificate is found or 0 otherwise.
209With library implementations other than LibreSSL,
210it might also return negative values for internal errors.
211.Sh SEE ALSO
212.Xr STACK_OF 3 ,
213.Xr X509_check_issued 3 ,
214.Xr X509_CRL_new 3 ,
215.Xr X509_get_issuer_name 3 ,
216.Xr X509_NAME_new 3 ,
217.Xr X509_new 3 ,
218.Xr X509_OBJECT_retrieve_by_subject 3 ,
219.Xr X509_STORE_CTX_new 3 ,
220.Xr X509_VERIFY_PARAM_set_flags 3
221.Sh HISTORY
222.Fn X509_STORE_get_by_subject
223first appeared in SSLeay 0.8.0 and has been available since
224.Ox 2.4 .
225.Pp
226.Fn X509_STORE_CTX_get1_issuer
227first appeared in OpenSSL 0.9.6 and has been available since
228.Ox 2.9 .
229.Pp
230.Fn X509_STORE_get1_certs
231and
232.Fn X509_STORE_get1_crls
233first appeared in OpenSSL 1.0.0 and have been available since
234.Ox 4.9 .
235.Pp
236.Fn X509_STORE_CTX_get_by_subject
237and
238.Fn X509_STORE_CTX_get_obj_by_subject
239first appeared in OpenSSL 1.1.0 and have been available since
240.Ox 7.1 .
241.Pp
242.Fn X509_STORE_CTX_get1_certs
243and
244.Fn X509_STORE_CTX_get1_crls
245first appeared in OpenSSL 1.1.0 and have been available since
246.Ox 7.4 .
diff --git a/src/lib/libcrypto/man/X509_STORE_load_locations.3 b/src/lib/libcrypto/man/X509_STORE_load_locations.3
deleted file mode 100644
index a8177b0fd4..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_load_locations.3
+++ /dev/null
@@ -1,188 +0,0 @@
1.\" $OpenBSD: X509_STORE_load_locations.3,v 1.12 2024/09/02 07:20:21 tb Exp $
2.\" full merge up to:
3.\" OpenSSL X509_STORE_add_cert b0edda11 Mar 20 13:00:17 2018 +0000
4.\"
5.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org>
6.\"
7.\" Permission to use, copy, modify, and distribute this software for any
8.\" purpose with or without fee is hereby granted, provided that the above
9.\" copyright notice and this permission notice appear in all copies.
10.\"
11.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\"
19.Dd $Mdocdate: September 2 2024 $
20.Dt X509_STORE_LOAD_LOCATIONS 3
21.Os
22.Sh NAME
23.Nm X509_STORE_load_locations ,
24.Nm X509_STORE_set_default_paths ,
25.Nm X509_STORE_load_mem ,
26.Nm X509_STORE_add_lookup
27.Nd configure files and directories used by a certificate store
28.Sh SYNOPSIS
29.In openssl/x509_vfy.h
30.Ft int
31.Fo X509_STORE_load_locations
32.Fa "X509_STORE *store"
33.Fa "const char *file"
34.Fa "const char *dirs"
35.Fc
36.Ft int
37.Fo X509_STORE_set_default_paths
38.Fa "X509_STORE *store"
39.Fc
40.Ft int
41.Fo X509_STORE_load_mem
42.Fa "X509_STORE *store"
43.Fa "void *buffer"
44.Fa "int length"
45.Fc
46.Ft X509_LOOKUP *
47.Fo X509_STORE_add_lookup
48.Fa "X509_STORE *store"
49.Fa "const X509_LOOKUP_METHOD *method"
50.Fc
51.Sh DESCRIPTION
52.Fn X509_STORE_load_locations
53instructs the
54.Fa store
55to use the PEM
56.Fa file
57and all the PEM files in the directories
58contained in the colon-separated list
59.Fa dirs
60for looking up certificates, in addition to files and directories
61that are already configured.
62The certificates in the directories must be in hashed form, as documented in
63.Xr X509_LOOKUP_hash_dir 3 .
64Directories already in use are not added again.
65If
66.Dv NULL
67is passed for
68.Fa file
69or
70.Fa dirs ,
71no new file or no new directories are added, respectively.
72.Pp
73.Fn X509_STORE_load_locations
74is identical to
75.Xr SSL_CTX_load_verify_locations 3
76except that it operates directly on an
77.Vt X509_STORE
78object, rather than on the store used by an SSL context.
79See that manual page for more information.
80.Pp
81.Fn X509_STORE_set_default_paths
82is similar except that it instructs the
83.Fa store
84to use the default PEM file and directory
85(as documented in
86.Sx FILES )
87in addition to what is already configured.
88It ignores errors that occur while trying to load the file or to
89add the directory, but it may still fail for other reasons, for
90example when out of memory while trying to allocate the required
91.Vt X509_LOOKUP
92objects.
93.Pp
94.Fn X509_STORE_set_default_paths
95is identical to
96.Xr SSL_CTX_set_default_verify_paths 3
97except that it operates directly on an
98.Vt X509_STORE
99object, rather than on the store used by an SSL context.
100See that manual page for more information.
101.Pp
102The above functions are wrappers around
103.Xr X509_LOOKUP_load_file 3
104and
105.Xr X509_LOOKUP_add_dir 3 .
106.Pp
107.Fn X509_STORE_load_mem
108instructs the
109.Fa store
110to use the certificates contained in the memory
111.Fa buffer
112of the given
113.Fa length
114for certificate lookup.
115It is a wrapper around
116.Xr X509_LOOKUP_add_mem 3 .
117.Pp
118.Fn X509_STORE_add_lookup
119checks whether the
120.Fa store
121already contains an
122.Vt X509_LOOKUP
123object using the given
124.Fa method ;
125if it does, the existing object is returned and no other action occurs.
126Otherwise, a new
127.Vt X509_LOOKUP
128object is allocated, added, and returned.
129This function is used internally by all the functions listed above.
130.Sh RETURN VALUES
131.Fn X509_STORE_load_locations
132returns 1 if all files and directories specified were successfully
133added.
134It returns 0 for failure.
135That can happen if adding the file failed, if adding any of the
136directories failed, or if both arguments were
137.Dv NULL .
138.Pp
139.Fn X509_STORE_set_default_paths
140returns 0 for some error conditions and 1 otherwise, not just for
141success, but also for various cases of failure.
142.Pp
143.Fn X509_STORE_load_mem
144returns 1 for success or 0 for failure.
145In particular, parse errors or lack of memory can cause failure.
146.Pp
147.Fn X509_STORE_add_lookup
148returns the existing or new lookup object or
149.Dv NULL
150on failure.
151This is an internal pointer that must not be freed.
152With LibreSSL, the only reason for failure is lack of memory.
153.Sh FILES
154.Bl -tag -width Ds
155.It Pa /etc/ssl/cert.pem
156default PEM file for
157.Fn X509_STORE_set_default_paths
158.It Pa /etc/ssl/certs/
159default directory for
160.Fn X509_STORE_set_default_paths
161.El
162.Sh SEE ALSO
163.Xr SSL_CTX_load_verify_locations 3 ,
164.Xr X509_load_cert_file 3 ,
165.Xr X509_LOOKUP_hash_dir 3 ,
166.Xr X509_LOOKUP_new 3 ,
167.Xr X509_STORE_new 3 ,
168.Xr X509_STORE_set1_param 3 ,
169.Xr X509_STORE_set_verify_cb 3
170.Sh HISTORY
171.Fn X509_STORE_load_locations ,
172.Fn X509_STORE_set_default_paths ,
173and
174.Fn X509_STORE_add_lookup
175first appeared in SSLeay 0.8.0 and have been available since
176.Ox 2.4 .
177.Pp
178.Fn X509_STORE_load_mem
179first appeared in
180.Ox 5.7 .
181.Sh BUGS
182By the time that adding a directory is found to have failed,
183the file and some other directories may already have been successfully loaded,
184so these functions may change the state of the store even when they fail.
185.Pp
186.Fn X509_STORE_set_default_paths
187clears the error queue, deleting even error information that was
188already present when it was called.
diff --git a/src/lib/libcrypto/man/X509_STORE_new.3 b/src/lib/libcrypto/man/X509_STORE_new.3
deleted file mode 100644
index a17da03a41..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_new.3
+++ /dev/null
@@ -1,145 +0,0 @@
1.\" $OpenBSD: X509_STORE_new.3,v 1.7 2021/11/17 16:08:32 schwarze Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by
23.\" Alessandro Ghedini <alessandro@ghedini.me>.
24.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: November 17 2021 $
71.Dt X509_STORE_NEW 3
72.Os
73.Sh NAME
74.Nm X509_STORE_new ,
75.Nm X509_STORE_up_ref ,
76.Nm X509_STORE_free
77.Nd allocate and free X.509 certificate stores
78.Sh SYNOPSIS
79.In openssl/x509_vfy.h
80.Ft X509_STORE *
81.Fn X509_STORE_new void
82.Ft int
83.Fo X509_STORE_up_ref
84.Fa "X509_STORE *store"
85.Fc
86.Ft void
87.Fo X509_STORE_free
88.Fa "X509_STORE *store"
89.Fc
90.Sh DESCRIPTION
91.Fn X509_STORE_new
92allocates and initializes an empty X.509 certificate store
93and sets its reference count to 1.
94.Pp
95.Fn X509_STORE_up_ref
96increments the reference count of
97.Fa store
98by 1.
99.Pp
100.Fn X509_STORE_free
101decrements the reference count of
102.Fa store
103by 1.
104If the reference count reaches 0,
105all resources used by the store, including all certificates
106contained in it, are released and
107.Fa store
108itself is freed.
109If
110.Fa store
111is a
112.Dv NULL
113pointer, no action occurs.
114.Sh RETURN VALUES
115.Fn X509_STORE_new
116returns a newly created
117.Vt X509_STORE
118object or
119.Dv NULL
120if an error occurs.
121.Pp
122.Fn X509_STORE_up_ref
123returns 1 for success and 0 for failure.
124.Sh SEE ALSO
125.Xr PKCS7_verify 3 ,
126.Xr SSL_CTX_set_cert_store 3 ,
127.Xr X509_load_cert_file 3 ,
128.Xr X509_LOOKUP_hash_dir 3 ,
129.Xr X509_OBJECT_get0_X509 3 ,
130.Xr X509_STORE_CTX_new 3 ,
131.Xr X509_STORE_get_ex_new_index 3 ,
132.Xr X509_STORE_load_locations 3 ,
133.Xr X509_STORE_set1_param 3 ,
134.Xr X509_STORE_set_verify_cb 3 ,
135.Xr X509_verify_cert 3
136.Sh HISTORY
137.Fn X509_STORE_new
138and
139.Fn X509_STORE_free
140first appeared in SSLeay 0.8.0 and have been available since
141.Ox 2.4 .
142.Pp
143.Fn X509_STORE_up_ref
144first appeared in OpenSSL 1.1.0 and has been available since
145.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/X509_STORE_set1_param.3 b/src/lib/libcrypto/man/X509_STORE_set1_param.3
deleted file mode 100644
index 527fe652e5..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_set1_param.3
+++ /dev/null
@@ -1,268 +0,0 @@
1.\" $OpenBSD: X509_STORE_set1_param.3,v 1.22 2024/03/14 22:19:12 tb Exp $
2.\" content checked up to:
3.\" OpenSSL man3/X509_STORE_add_cert b0edda11 Mar 20 13:00:17 2018 +0000
4.\" OpenSSL man3/X509_STORE_get0_param e90fc053 Jul 15 09:39:45 2017 -0400
5.\"
6.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
7.\"
8.\" Permission to use, copy, modify, and distribute this software for any
9.\" purpose with or without fee is hereby granted, provided that the above
10.\" copyright notice and this permission notice appear in all copies.
11.\"
12.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\"
20.Dd $Mdocdate: March 14 2024 $
21.Dt X509_STORE_SET1_PARAM 3
22.Os
23.Sh NAME
24.Nm X509_STORE_set1_param ,
25.Nm X509_STORE_set_flags ,
26.Nm X509_STORE_set_purpose ,
27.Nm X509_STORE_set_trust ,
28.Nm X509_STORE_set_depth ,
29.Nm X509_STORE_add_cert ,
30.Nm X509_STORE_add_crl ,
31.Nm X509_STORE_get0_param ,
32.Nm X509_STORE_get1_objects ,
33.Nm X509_STORE_get0_objects ,
34.Nm X509_STORE_get_ex_new_index ,
35.Nm X509_STORE_set_ex_data ,
36.Nm X509_STORE_get_ex_data
37.Nd get and set X509_STORE data
38.Sh SYNOPSIS
39.In openssl/x509_vfy.h
40.Ft int
41.Fo X509_STORE_set1_param
42.Fa "X509_STORE *store"
43.Fa "X509_VERIFY_PARAM *pm"
44.Fc
45.Ft int
46.Fo X509_STORE_set_flags
47.Fa "X509_STORE *store"
48.Fa "unsigned long flags"
49.Fc
50.Ft int
51.Fo X509_STORE_set_purpose
52.Fa "X509_STORE *store"
53.Fa "int purpose"
54.Fc
55.Ft int
56.Fo X509_STORE_set_trust
57.Fa "X509_STORE *store"
58.Fa "int trust"
59.Fc
60.Ft int
61.Fo X509_STORE_set_depth
62.Fa "X509_STORE *store"
63.Fa "int depth"
64.Fc
65.Ft int
66.Fo X509_STORE_add_cert
67.Fa "X509_STORE *store"
68.Fa "X509 *x"
69.Fc
70.Ft int
71.Fo X509_STORE_add_crl
72.Fa "X509_STORE *store"
73.Fa "X509_CRL *crl"
74.Fc
75.Ft X509_VERIFY_PARAM *
76.Fo X509_STORE_get0_param
77.Fa "X509_STORE *store"
78.Fc
79.Ft STACK_OF(X509_OBJECT) *
80.Fo X509_STORE_get1_objects
81.Fa "X509_STORE *store"
82.Fc
83.Ft STACK_OF(X509_OBJECT) *
84.Fo X509_STORE_get0_objects
85.Fa "X509_STORE *store"
86.Fc
87.Ft int
88.Fo X509_STORE_get_ex_new_index
89.Fa "long argl"
90.Fa "void *argp"
91.Fa "CRYPTO_EX_new *new_func"
92.Fa "CRYPTO_EX_dup *dup_func"
93.Fa "CRYPTO_EX_free *free_func"
94.Fc
95.Ft int
96.Fo X509_STORE_set_ex_data
97.Fa "X509_STORE *store"
98.Fa "int idx"
99.Fa "void *arg"
100.Fc
101.Ft void *
102.Fo X509_STORE_get_ex_data
103.Fa "X509_STORE *store"
104.Fa "int idx"
105.Fc
106.Sh DESCRIPTION
107.Fn X509_STORE_set1_param
108copies the verification parameters from
109.Fa pm
110using
111.Xr X509_VERIFY_PARAM_set1 3
112into the verification parameter object contained in the
113.Fa store .
114.Pp
115.Fn X509_VERIFY_PARAM_set_flags ,
116.Fn X509_STORE_set_purpose ,
117.Fn X509_STORE_set_trust ,
118and
119.Fn X509_STORE_set_depth
120call
121.Fn X509_VERIFY_PARAM_set_flags ,
122.Fn X509_VERIFY_PARAM_set_purpose ,
123.Fn X509_VERIFY_PARAM_set_trust ,
124and
125.Fn X509_VERIFY_PARAM_set_depth
126on the verification parameter object contained in the
127.Fa store .
128.Pp
129.Fn X509_STORE_add_cert
130and
131.Fn X509_STORE_add_crl
132add the certificate
133.Fa x
134or the certificate revocation list
135.Fa crl
136to the
137.Fa store ,
138increasing its reference count by 1 in case of success.
139Untrusted objects should not be added in this way.
140.Pp
141.Fn X509_STORE_get_ex_new_index ,
142.Fn X509_STORE_set_ex_data ,
143and
144.Fn X509_STORE_get_ex_data
145handle application specific data in
146.Vt X509_STORE
147objects.
148Their usage is identical to that of
149.Xr RSA_get_ex_new_index 3 ,
150.Xr RSA_set_ex_data 3 ,
151and
152.Xr RSA_get_ex_data 3 .
153.Fn X509_STORE_get_ex_new_index
154is implemented as a macro.
155.Sh RETURN VALUES
156.Fn X509_STORE_set1_param ,
157.Fn X509_STORE_set_purpose ,
158.Fn X509_STORE_set_trust ,
159and
160.Fn X509_STORE_set_ex_data
161return 1 for success or 0 for failure.
162.Pp
163.Fn X509_STORE_set_flags
164and
165.Fn X509_STORE_set_depth
166always return 1, indicating success.
167.Pp
168.Fn X509_STORE_add_cert
169and
170.Fn X509_STORE_add_crl
171return 1 for success or 0 for failure.
172For example, they fail if
173.Fa x
174or
175.Fa crl
176is a
177.Dv NULL
178pointer, if a certificate with the same subject name as
179.Fa x
180or a revocation list with the same issuer name as
181.Fa crl
182are already contained in the
183.Fa store ,
184or if memory allocation fails.
185.Pp
186.Fn X509_STORE_get0_param
187returns an internal pointer to the verification parameter object
188contained in the
189.Fa store .
190The returned pointer must not be freed by the calling application.
191.Pp
192.Fn X509_STORE_get1_objects
193returns a newly allocated stack containing
194the certificates, revocation lists, and private keys in
195.Fa store ,
196as well as cached objects added by
197.Xr X509_LOOKUP_hash_dir 3 .
198The caller must release the result with
199.Xr sk_pop_free 3
200and
201.Xr X509_OBJECT_free 3
202when done.
203.Pp
204.Fn X509_STORE_get0_objects
205is a deprecated function returning an internal pointer to
206the stack of certificates, revocation lists, and private keys contained in
207.Fa store .
208The returned pointer must not be modified or freed by the calling application.
209This function is not thread-safe.
210If
211.Fa store
212is shared across multiple threads, callers cannot safely inspect the result of
213this function, because another thread may have concurrently added to it.
214In particular,
215.Xr X509_LOOKUP_hash_dir 3
216treats this list as a cache and may add to it in the course of certificate
217verification.
218.Pp
219.Fn X509_STORE_get_ex_new_index
220returns a new index or \-1 on failure.
221.Pp
222.Fn X509_STORE_get_ex_data
223returns the application data or
224.Dv NULL
225on failure.
226.Sh SEE ALSO
227.Xr RSA_get_ex_new_index 3 ,
228.Xr SSL_set1_param 3 ,
229.Xr X509_LOOKUP_new 3 ,
230.Xr X509_OBJECT_get0_X509 3 ,
231.Xr X509_STORE_CTX_set0_param 3 ,
232.Xr X509_STORE_load_locations 3 ,
233.Xr X509_STORE_new 3 ,
234.Xr X509_VERIFY_PARAM_new 3 ,
235.Xr X509_VERIFY_PARAM_set_flags 3
236.Sh HISTORY
237.Fn X509_STORE_add_cert
238first appeared in SSLeay 0.8.0.
239.Fn X509_STORE_add_crl
240first appeared in SSLeay 0.9.0.
241These functions have been available since
242.Ox 2.4 .
243.Pp
244.Fn X509_STORE_set_flags ,
245.Fn X509_STORE_set_purpose ,
246and
247.Fn X509_STORE_set_trust
248first appeared in OpenSSL 0.9.7 and have been available since
249.Ox 3.2 .
250.Pp
251.Fn X509_STORE_set1_param
252and
253.Fn X509_STORE_set_depth
254first appeared in OpenSSL 0.9.8 and have been available since
255.Ox 4.5 .
256.Pp
257.Fn X509_STORE_get0_param ,
258.Fn X509_STORE_get0_objects ,
259.Fn X509_STORE_get_ex_new_index ,
260.Fn X509_STORE_set_ex_data ,
261and
262.Fn X509_STORE_get_ex_data
263first appeared in OpenSSL 1.1.0 and have been available since
264.Ox 6.3 .
265.Pp
266.Fn X509_STORE_get1_objects
267first appeared in BoringSSL and has been available since
268.Ox 7.5 .
diff --git a/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3 b/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3
deleted file mode 100644
index bdd5ea5044..0000000000
--- a/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3
+++ /dev/null
@@ -1,121 +0,0 @@
1.\" $OpenBSD: X509_STORE_set_verify_cb_func.3,v 1.12 2022/11/16 14:51:08 schwarze Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL 315c47e0 Dec 1 14:22:16 2020 +0100
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2009 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: November 16 2022 $
53.Dt X509_STORE_SET_VERIFY_CB_FUNC 3
54.Os
55.Sh NAME
56.Nm X509_STORE_set_verify_cb ,
57.Nm X509_STORE_set_verify_cb_func ,
58.Nm X509_STORE_get_verify_cb
59.Nd set verification callback
60.Sh SYNOPSIS
61.In openssl/x509_vfy.h
62.Ft void
63.Fo X509_STORE_set_verify_cb
64.Fa "X509_STORE *st"
65.Fa "X509_STORE_CTX_verify_cb verify_cb"
66.Fc
67.Ft void
68.Fo X509_STORE_set_verify_cb_func
69.Fa "X509_STORE *st"
70.Fa "X509_STORE_CTX_verify_cb verify_cb"
71.Fc
72.Ft X509_STORE_CTX_verify_cb
73.Fo X509_STORE_get_verify_cb
74.Fa "X509_STORE *st"
75.Fc
76.Sh DESCRIPTION
77.Fn X509_STORE_set_verify_cb
78sets the verification callback of
79.Sy ctx
80to
81.Sy verify_cb ,
82overwriting any existing callback.
83.Pp
84.Fn X509_STORE_set_verify_cb_func
85also sets the verification callback but it is implemented as a macro.
86.Pp
87The verification callback from an
88.Vt X509_STORE
89is inherited by the corresponding
90.Vt X509_STORE_CTX
91structure when it is initialized.
92This can be used to set the verification callback when the
93.Vt X509_STORE_CTX
94is otherwise inaccessible (for example during S/MIME verification).
95.Sh RETURN VALUES
96.Fn X509_STORE_get_verify_cb
97returns the function pointer set with
98.Fn X509_STORE_set_verify_cb ,
99or
100.Dv NULL
101if that function was not called on
102.Fa st .
103.Sh SEE ALSO
104.Xr X509_STORE_CTX_new 3 ,
105.Xr X509_STORE_CTX_set_verify 3 ,
106.Xr X509_STORE_CTX_set_verify_cb 3 ,
107.Xr X509_STORE_new 3 ,
108.Xr X509_STORE_set_flags 3 ,
109.Xr X509_verify_cert 3
110.Sh HISTORY
111.Fn X509_STORE_set_verify_cb_func
112first appeared in SSLeay 0.8.0 and has been available since
113.Ox 2.4 .
114.Pp
115.Fn X509_STORE_set_verify_cb
116first appeared in OpenSSL 1.0.0 and has been available since
117.Ox 4.9 .
118.Pp
119.Fn X509_STORE_get_verify_cb
120first appeared in OpenSSL 1.1.0 and has been available since
121.Ox 7.2 .
diff --git a/src/lib/libcrypto/man/X509_VERIFY_PARAM_new.3 b/src/lib/libcrypto/man/X509_VERIFY_PARAM_new.3
deleted file mode 100644
index a22d2b1b4b..0000000000
--- a/src/lib/libcrypto/man/X509_VERIFY_PARAM_new.3
+++ /dev/null
@@ -1,306 +0,0 @@
1.\" $OpenBSD: X509_VERIFY_PARAM_new.3,v 1.5 2023/05/24 09:57:50 tb Exp $
2.\"
3.\" Copyright (c) 2018, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: May 24 2023 $
18.Dt X509_VERIFY_PARAM_NEW 3
19.Os
20.Sh NAME
21.Nm X509_VERIFY_PARAM_new ,
22.Nm X509_VERIFY_PARAM_inherit ,
23.Nm X509_VERIFY_PARAM_set1 ,
24.Nm X509_VERIFY_PARAM_free ,
25.Nm X509_VERIFY_PARAM_add0_table ,
26.Nm X509_VERIFY_PARAM_lookup ,
27.Nm X509_VERIFY_PARAM_get_count ,
28.Nm X509_VERIFY_PARAM_get0 ,
29.Nm X509_VERIFY_PARAM_table_cleanup
30.\" The following constants defined in the public header <openssl/x509_vfy.h>
31.\" are intentionally undocumented because X509_VERIFY_PARAM is an opaque
32.\" struct and LibreSSL provides neither X509_VERIFY_PARAM_set_inh_flags(3)
33.\" nor X509_VERIFY_PARAM_get_inh_flags(3):
34.\" X509_VP_FLAG_DEFAULT
35.\" X509_VP_FLAG_OVERWRITE
36.\" X509_VP_FLAG_RESET_FLAGS
37.\" X509_VP_FLAG_LOCKED
38.\" X509_VP_FLAG_ONCE
39.Nd X509 verification parameter objects
40.Sh SYNOPSIS
41.In openssl/x509_vfy.h
42.Ft X509_VERIFY_PARAM *
43.Fo X509_VERIFY_PARAM_new
44.Fa void
45.Fc
46.Ft int
47.Fo X509_VERIFY_PARAM_inherit
48.Fa "X509_VERIFY_PARAM *destination"
49.Fa "const X509_VERIFY_PARAM *source"
50.Fc
51.Ft int
52.Fo X509_VERIFY_PARAM_set1
53.Fa "X509_VERIFY_PARAM *destination"
54.Fa "const X509_VERIFY_PARAM *source"
55.Fc
56.Ft void
57.Fo X509_VERIFY_PARAM_free
58.Fa "X509_VERIFY_PARAM *param"
59.Fc
60.Ft int
61.Fo X509_VERIFY_PARAM_add0_table
62.Fa "X509_VERIFY_PARAM *param"
63.Fc
64.Ft const X509_VERIFY_PARAM *
65.Fo X509_VERIFY_PARAM_lookup
66.Fa "const char *name"
67.Fc
68.Ft int
69.Fo X509_VERIFY_PARAM_get_count
70.Fa void
71.Fc
72.Ft const X509_VERIFY_PARAM *
73.Fo X509_VERIFY_PARAM_get0
74.Fa "int id"
75.Fc
76.Ft void
77.Fo X509_VERIFY_PARAM_table_cleanup
78.Fa void
79.Fc
80.Sh DESCRIPTION
81.Fn X509_VERIFY_PARAM_new
82allocates and initializes an empty
83.Vt X509_VERIFY_PARAM
84object.
85.Pp
86.Fn X509_VERIFY_PARAM_inherit
87copies some data from the
88.Fa source
89object to the
90.Fa destination
91object.
92.Pp
93The verification flags set with
94.Xr X509_VERIFY_PARAM_set_flags 3
95in the
96.Fa source
97object are always OR'ed into the verification flags of the
98.Fa destination
99object.
100.Pp
101Fields having their default value in the
102.Fa source
103object are not copied.
104.Pp
105By default, fields in the
106.Fa destination
107object already having a non-default value are not overwritten.
108However, if at least one of the
109.Fa source
110or
111.Fa destination
112objects was created during a call to
113.Xr X509_STORE_CTX_init 3
114that did not have a
115.Fa store
116argument, and if that object was not previously used as the
117.Fa destination
118in an earlier call to
119.Fn X509_VERIFY_PARAM_inherit ,
120this restriction is waived and even non-default fields in the
121.Fa destination
122object get overwritten.
123If fields overwritten in this way contain pointers to allocated memory,
124that memory is freed.
125.Pp
126As far as permitted by the above rules, the following fields are copied:
127.Bl -bullet -width 1n
128.It
129the verification purpose identifier set with
130.Xr X509_VERIFY_PARAM_set_purpose 3
131.It
132the trust setting set with
133.Xr X509_VERIFY_PARAM_set_trust 3
134.It
135the verification time set with
136.Xr X509_VERIFY_PARAM_set_time 3 ;
137in this case, the only condition is that
138.Dv X509_V_FLAG_USE_CHECK_TIME
139is not set in the
140.Fa destination
141object, whereas the time value in the
142.Fa destination
143object is not inspected before overwriting it
144.It
145the acceptable policy set with
146.Xr X509_VERIFY_PARAM_set1_policies 3
147.It
148the maximum verification depth set with
149.Xr X509_VERIFY_PARAM_set_depth 3
150.It
151flags that were set with
152.Xr X509_VERIFY_PARAM_set_hostflags 3
153.It
154the list of expected DNS hostnames built with
155.Xr X509_VERIFY_PARAM_set1_host 3
156and
157.Xr X509_VERIFY_PARAM_add1_host 3
158.It
159the expected RFC 822 email address set with
160.Xr X509_VERIFY_PARAM_set1_email 3
161.It
162the expected IP address set with
163.Xr X509_VERIFY_PARAM_set1_ip 3
164or
165.Xr X509_VERIFY_PARAM_set1_ip_asc 3
166.El
167.Pp
168Some data that may be contained in the
169.Fa source
170object is never copied, for example the subject name of the peer
171certificate that can be retrieved with
172.Xr X509_VERIFY_PARAM_get0_peername 3 .
173.Pp
174If
175.Fa source
176is a
177.Dv NULL
178pointer, the function has no effect but returns successfully.
179.Pp
180.Fn X509_VERIFY_PARAM_set1
181is identical to
182.Fn X509_VERIFY_PARAM_inherit
183except that fields in the
184.Fa destination
185object are overwritten even if they do not match their default values.
186Still, fields having their default value in the
187.Fa source
188object are not copied.
189.Pp
190If
191.Fn X509_VERIFY_PARAM_inherit
192or
193.Fn X509_VERIFY_PARAM_set1
194fail, partial copying may have occurred, so all data in the
195.Fa destination
196object should be regarded as invalid.
197.Pp
198.Fn X509_VERIFY_PARAM_inherit
199is used internally by
200.Xr X509_STORE_CTX_init 3
201and by
202.Xr X509_STORE_CTX_set_default 3 ,
203and
204.Fn X509_VERIFY_PARAM_set1
205is used internally by
206.Xr X509_STORE_set1_param 3 .
207.Pp
208.Fn X509_VERIFY_PARAM_free
209clears all data contained in
210.Fa param
211and releases all memory used by it.
212If
213.Fa param
214is a
215.Dv NULL
216pointer, no action occurs.
217.Pp
218.Fn X509_VERIFY_PARAM_add0_table
219adds
220.Fa param
221to a static list of
222.Vt X509_VERIFY_PARAM
223objects maintained by the library.
224This function is extremely dangerous because contrary to the name
225of the function, if the list already contains an object that happens
226to have the same name, that old object is not only silently removed
227from the list, but also silently freed, which may silently invalidate
228various pointers existing elsewhere in the program.
229.Pp
230.Fn X509_VERIFY_PARAM_lookup
231searches this list for an object of the given
232.Fa name .
233If no match is found, the predefined objects built-in to the library
234are also inspected.
235.Pp
236.Fn X509_VERIFY_PARAM_get_count
237returns the sum of the number of objects on this list and the number
238of predefined objects built-in to the library.
239Note that this is not necessarily the total number of
240.Vt X509_VERIFY_PARAM
241objects existing in the program because there may be additional such
242objects that were never added to the list.
243.Pp
244.Fn X509_VERIFY_PARAM_get0
245accesses predefined and user-defined objects using
246.Fa id
247as an index, useful for looping over objects without knowing their names.
248An argument less than the number of predefined objects selects
249one of the predefined objects; a higher argument selects an object
250from the list.
251.Pp
252.Fn X509_VERIFY_PARAM_table_cleanup
253deletes all objects from this list.
254It is extremely dangerous because it also invalidates all data that
255was contained in all objects that were on the list and because it
256frees all these objects, which may invalidate various pointers
257existing elsewhere in the program.
258.Sh RETURN VALUES
259.Fn X509_VERIFY_PARAM_new
260returns a pointer to the new object, or
261.Dv NULL
262on allocation failure.
263.Pp
264.Fn X509_VERIFY_PARAM_inherit ,
265.Fn X509_VERIFY_PARAM_set1 ,
266and
267.Fn X509_VERIFY_PARAM_add0_table
268return 1 for success or 0 for failure.
269.Pp
270.Fn X509_VERIFY_PARAM_lookup
271and
272.Fn X509_VERIFY_PARAM_get0
273return a pointer to an existing built-in or user-defined object, or
274.Dv NULL
275if no object with the given
276.Fa name
277is found, or if
278.Fa id
279is at least
280.Fn X509_VERIFY_PARAM_get_count .
281.Pp
282.Fn X509_VERIFY_PARAM_get_count
283returns a number of objects.
284.Sh SEE ALSO
285.Xr SSL_set1_param 3 ,
286.Xr X509_STORE_CTX_set0_param 3 ,
287.Xr X509_STORE_set1_param 3 ,
288.Xr X509_verify_cert 3 ,
289.Xr X509_VERIFY_PARAM_set_flags 3
290.Sh HISTORY
291.Fn X509_VERIFY_PARAM_new ,
292.Fn X509_VERIFY_PARAM_inherit ,
293.Fn X509_VERIFY_PARAM_set1 ,
294.Fn X509_VERIFY_PARAM_free ,
295.Fn X509_VERIFY_PARAM_add0_table ,
296.Fn X509_VERIFY_PARAM_lookup ,
297and
298.Fn X509_VERIFY_PARAM_table_cleanup
299first appeared in OpenSSL 0.9.8 and have been available since
300.Ox 4.5 .
301.Pp
302.Fn X509_VERIFY_PARAM_get_count
303and
304.Fn X509_VERIFY_PARAM_get0
305first appeared in OpenSSL 1.0.2 and have been available since
306.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3 b/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3
deleted file mode 100644
index a0ae839f9a..0000000000
--- a/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3
+++ /dev/null
@@ -1,736 +0,0 @@
1.\" $OpenBSD: X509_VERIFY_PARAM_set_flags.3,v 1.29 2023/04/30 19:40:23 tb Exp $
2.\" full merge up to: OpenSSL d33def66 Feb 9 14:17:13 2016 -0500
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2018, 2021, 2022 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
23.\" and Viktor Dukhovni <viktor@dukhovni.org>.
24.\" Copyright (c) 2009, 2013, 2014, 2015, 2016, 2017 The OpenSSL Project.
25.\" All rights reserved.
26.\"
27.\" Redistribution and use in source and binary forms, with or without
28.\" modification, are permitted provided that the following conditions
29.\" are met:
30.\"
31.\" 1. Redistributions of source code must retain the above copyright
32.\" notice, this list of conditions and the following disclaimer.
33.\"
34.\" 2. Redistributions in binary form must reproduce the above copyright
35.\" notice, this list of conditions and the following disclaimer in
36.\" the documentation and/or other materials provided with the
37.\" distribution.
38.\"
39.\" 3. All advertising materials mentioning features or use of this
40.\" software must display the following acknowledgment:
41.\" "This product includes software developed by the OpenSSL Project
42.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
43.\"
44.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
45.\" endorse or promote products derived from this software without
46.\" prior written permission. For written permission, please contact
47.\" openssl-core@openssl.org.
48.\"
49.\" 5. Products derived from this software may not be called "OpenSSL"
50.\" nor may "OpenSSL" appear in their names without prior written
51.\" permission of the OpenSSL Project.
52.\"
53.\" 6. Redistributions of any form whatsoever must retain the following
54.\" acknowledgment:
55.\" "This product includes software developed by the OpenSSL Project
56.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
57.\"
58.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
59.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
62.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
67.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\"
71.Dd $Mdocdate: April 30 2023 $
72.Dt X509_VERIFY_PARAM_SET_FLAGS 3
73.Os
74.Sh NAME
75.Nm X509_VERIFY_PARAM_get0_name ,
76.Nm X509_VERIFY_PARAM_set1_name ,
77.Nm X509_VERIFY_PARAM_set_flags ,
78.Nm X509_VERIFY_PARAM_clear_flags ,
79.Nm X509_VERIFY_PARAM_get_flags ,
80.Nm X509_VERIFY_PARAM_set_purpose ,
81.Nm X509_VERIFY_PARAM_set_trust ,
82.Nm X509_VERIFY_PARAM_set_time ,
83.Nm X509_VERIFY_PARAM_get_time ,
84.Nm X509_VERIFY_PARAM_add0_policy ,
85.Nm X509_VERIFY_PARAM_set1_policies ,
86.Nm X509_VERIFY_PARAM_set_depth ,
87.Nm X509_VERIFY_PARAM_get_depth ,
88.Nm X509_VERIFY_PARAM_set_auth_level ,
89.Nm X509_VERIFY_PARAM_set1_host ,
90.Nm X509_VERIFY_PARAM_add1_host ,
91.Nm X509_VERIFY_PARAM_set_hostflags ,
92.Nm X509_VERIFY_PARAM_get0_peername ,
93.Nm X509_VERIFY_PARAM_set1_email ,
94.Nm X509_VERIFY_PARAM_set1_ip ,
95.Nm X509_VERIFY_PARAM_set1_ip_asc
96.Nd X509 verification parameters
97.Sh SYNOPSIS
98.In openssl/x509_vfy.h
99.Ft const char *
100.Fo X509_VERIFY_PARAM_get0_name
101.Fa "const X509_VERIFY_PARAM *param"
102.Fc
103.Ft int
104.Fo X509_VERIFY_PARAM_set1_name
105.Fa "X509_VERIFY_PARAM *param"
106.Fa "const char *name"
107.Fc
108.Ft int
109.Fo X509_VERIFY_PARAM_set_flags
110.Fa "X509_VERIFY_PARAM *param"
111.Fa "unsigned long flags"
112.Fc
113.Ft int
114.Fo X509_VERIFY_PARAM_clear_flags
115.Fa "X509_VERIFY_PARAM *param"
116.Fa "unsigned long flags"
117.Fc
118.Ft unsigned long
119.Fo X509_VERIFY_PARAM_get_flags
120.Fa "X509_VERIFY_PARAM *param"
121.Fc
122.Ft int
123.Fo X509_VERIFY_PARAM_set_purpose
124.Fa "X509_VERIFY_PARAM *param"
125.Fa "int purpose"
126.Fc
127.Ft int
128.Fo X509_VERIFY_PARAM_set_trust
129.Fa "X509_VERIFY_PARAM *param"
130.Fa "int trust"
131.Fc
132.Ft void
133.Fo X509_VERIFY_PARAM_set_time
134.Fa "X509_VERIFY_PARAM *param"
135.Fa "time_t t"
136.Fc
137.Ft time_t
138.Fo X509_VERIFY_PARAM_get_time
139.Fa const X509_VERIFY_PARAM *param"
140.Fc
141.Ft int
142.Fo X509_VERIFY_PARAM_add0_policy
143.Fa "X509_VERIFY_PARAM *param"
144.Fa "ASN1_OBJECT *policy"
145.Fc
146.Ft int
147.Fo X509_VERIFY_PARAM_set1_policies
148.Fa "X509_VERIFY_PARAM *param"
149.Fa "STACK_OF(ASN1_OBJECT) *policies"
150.Fc
151.Ft void
152.Fo X509_VERIFY_PARAM_set_depth
153.Fa "X509_VERIFY_PARAM *param"
154.Fa "int depth"
155.Fc
156.Ft int
157.Fo X509_VERIFY_PARAM_get_depth
158.Fa "const X509_VERIFY_PARAM *param"
159.Fc
160.Ft void
161.Fo X509_VERIFY_PARAM_set_auth_level
162.Fa "X509_VERIFY_PARAM *param"
163.Fa "int auth_level"
164.Fc
165.Ft int
166.Fo X509_VERIFY_PARAM_set1_host
167.Fa "X509_VERIFY_PARAM *param"
168.Fa "const char *name"
169.Fa "size_t namelen"
170.Fc
171.Ft int
172.Fo X509_VERIFY_PARAM_add1_host
173.Fa "X509_VERIFY_PARAM *param"
174.Fa "const char *name"
175.Fa "size_t namelen"
176.Fc
177.Ft void
178.Fo X509_VERIFY_PARAM_set_hostflags
179.Fa "X509_VERIFY_PARAM *param"
180.Fa "unsigned int flags"
181.Fc
182.Ft char *
183.Fo X509_VERIFY_PARAM_get0_peername
184.Fa "X509_VERIFY_PARAM *param"
185.Fc
186.Ft int
187.Fo X509_VERIFY_PARAM_set1_email
188.Fa "X509_VERIFY_PARAM *param"
189.Fa "const char *email"
190.Fa "size_t emaillen"
191.Fc
192.Ft int
193.Fo X509_VERIFY_PARAM_set1_ip
194.Fa "X509_VERIFY_PARAM *param"
195.Fa "const unsigned char *ip"
196.Fa "size_t iplen"
197.Fc
198.Ft int
199.Fo X509_VERIFY_PARAM_set1_ip_asc
200.Fa "X509_VERIFY_PARAM *param"
201.Fa "const char *ipasc"
202.Fc
203.Sh DESCRIPTION
204These functions manipulate an
205.Vt X509_VERIFY_PARAM
206object associated with a certificate verification operation.
207.Pp
208.Fn X509_VERIFY_PARAM_get0_name
209returns the name of the given
210.Fa param
211object, usually describing its purpose, for example
212.Qq default ,
213.Qq pkcs7 ,
214.Qq smime_sign ,
215.Qq ssl_client ,
216or
217.Qq ssl_server .
218For user-defined objects, the returned pointer may be
219.Dv NULL
220even if the object is otherwise valid.
221.Pp
222.Fn X509_VERIFY_PARAM_set1_name
223sets the name of
224.Fa param
225to a copy of
226.Fa name ,
227or to
228.Dv NULL
229if
230.Fa name
231is
232.Dv NULL .
233.Pp
234.Fn X509_VERIFY_PARAM_set_flags
235sets the flags in
236.Fa param
237by OR'ing it with
238.Fa flags .
239See the
240.Sx VERIFICATION FLAGS
241section for a complete description of values the
242.Fa flags
243parameter can take.
244.Pp
245If the
246.Fa flags
247argument includes any of the flags contained in
248.Dv X509_V_FLAG_POLICY_MASK ,
249that is, any of
250.Dv X509_V_FLAG_POLICY_CHECK ,
251.Dv X509_V_FLAG_EXPLICIT_POLICY ,
252.Dv X509_V_FLAG_INHIBIT_ANY ,
253and
254.Dv X509_V_FLAG_INHIBIT_MAP ,
255then
256.Dv X509_V_FLAG_POLICY_CHECK
257is set in addition to the flags contained in the
258.Fa flags
259argument.
260.Pp
261.Fn X509_VERIFY_PARAM_get_flags
262returns the flags in
263.Fa param .
264.Pp
265.Fn X509_VERIFY_PARAM_clear_flags
266clears the specified
267.Fa flags
268in
269.Fa param .
270.Pp
271Calling this function can result in unusual internal states of the
272.Fa param
273object, for example having a verification time configured but having
274.Dv X509_V_FLAG_USE_CHECK_TIME
275unset, or having
276.Dv X509_V_FLAG_EXPLICIT_POLICY
277set but
278.Dv X509_V_FLAG_POLICY_CHECK
279unset, which may have surprising effects.
280.Pp
281.Fn X509_VERIFY_PARAM_set_purpose
282sets the verification
283.Fa purpose
284identifier in
285.Fa param .
286This determines the acceptable purpose of the certificate chain, for example
287.Dv X509_PURPOSE_SSL_CLIENT
288or
289.Dv X509_PURPOSE_SSL_SERVER .
290Standard purposes are listed in
291.Xr X509_check_purpose 3 ,
292and additional purposes can be defined with
293.Xr X509_PURPOSE_add 3 .
294.Pp
295.Fn X509_VERIFY_PARAM_set_trust
296sets the trust setting in
297.Fa param
298to
299.Fa trust .
300.Pp
301.Fn X509_VERIFY_PARAM_set_time
302sets the flag
303.Dv X509_V_FLAG_USE_CHECK_TIME
304in
305.Fa param
306in addition to the flags already set and sets the verification time to
307.Fa t .
308If this function is not called, the current time is used instead,
309or the UNIX Epoch (January 1, 1970) if
310.Dv X509_V_FLAG_USE_CHECK_TIME
311is manually set using
312.Fn X509_VERIFY_PARAM_set_flags .
313.Pp
314.Fn X509_VERIFY_PARAM_add0_policy
315enables policy checking (it is disabled by default) and adds
316.Fa policy
317to the acceptable policy set.
318.Pp
319.Fn X509_VERIFY_PARAM_set1_policies
320enables policy checking (it is disabled by default) and sets the
321acceptable policy set to
322.Fa policies .
323Any existing policy set is cleared.
324The
325.Fa policies
326parameter can be
327.Dv NULL
328to clear an existing policy set.
329.Pp
330.Fn X509_VERIFY_PARAM_set_depth
331sets the maximum verification depth to
332.Fa depth .
333That is the maximum number of untrusted CA certificates that can appear
334in a chain.
335.Pp
336.Fn X509_VERIFY_PARAM_set_auth_level
337sets the security level as defined in
338.Xr SSL_CTX_set_security_level 3
339for certificate chain validation.
340For a certificate chain to validate, the public keys of all the
341certificates must meet the specified security level.
342The signature algorithm security level is not enforced for the
343chain's trust anchor certificate, which is either directly trusted
344or validated by means other than its signature.
345.Pp
346From the point of view of the X.509 library,
347the default security level is 0.
348However, the SSL library
349uses a different default security level of 1 and calls
350.Fn X509_VERIFY_PARAM_set_auth_level
351with its own level before validating a certificate chain.
352.Pp
353.Fn X509_VERIFY_PARAM_set1_host
354sets the expected DNS hostname to
355.Fa name
356clearing any previously specified hostname or names.
357If
358.Fa name
359is
360.Dv NULL
361or empty, the list of hostnames is cleared, and name checks are not
362performed on the peer certificate.
363.Fa namelen
364should be set to the length of
365.Fa name .
366For historical compatibility, if
367.Fa name
368is NUL-terminated,
369.Fa namelen
370may be specified as zero.
371When a hostname is specified, certificate verification automatically
372invokes
373.Xr X509_check_host 3
374with flags equal to the
375.Fa flags
376argument given to
377.Fn X509_VERIFY_PARAM_set_hostflags
378(default zero).
379.Fn X509_VERIFY_PARAM_set1_host
380will fail if
381.Fa name
382contains any embedded 0 bytes.
383.Pp
384.Fn X509_VERIFY_PARAM_add1_host
385adds
386.Fa name
387as an additional reference identifier that can match the peer's
388certificate.
389Any previous names set via
390.Fn X509_VERIFY_PARAM_set1_host
391and
392.Fn X509_VERIFY_PARAM_add1_host
393are retained.
394No change is made if
395.Fa name
396is
397.Dv NULL
398or empty.
399.Fa namelen
400should be set to the length of
401.Fa name .
402For historical compatibility, if
403.Fa name
404is NUL-terminated,
405.Fa namelen
406may be specified as zero.
407.Fn X509_VERIFY_PARAM_add1_host
408will fail if
409.Fa name
410contains any embedded 0 bytes.
411When multiple names are configured, the peer is considered verified when
412any name matches.
413.Pp
414.Fn X509_VERIFY_PARAM_get0_peername
415returns the DNS hostname or subject CommonName from the peer certificate
416that matched one of the reference identifiers.
417When wildcard matching is not disabled, or when a reference identifier
418specifies a parent domain (starts with ".") rather than a hostname, the
419peer name may be a wildcard name or a sub-domain of the reference
420identifier respectively.
421.Pp
422.Fn X509_VERIFY_PARAM_set1_email
423sets the expected RFC 822 email address to
424.Fa email .
425.Fa emaillen
426should be set to the length of
427.Fa email .
428For historical compatibility, if
429.Fa email
430is NUL-terminated,
431.Fa emaillen
432may be specified as zero,
433.Fn X509_VERIFY_PARAM_set1_email
434will fail if
435.Fa email
436is NULL, an empty string, or contains embedded 0 bytes.
437When an email address is specified, certificate verification
438automatically invokes
439.Xr X509_check_email 3 .
440.Pp
441.Fn X509_VERIFY_PARAM_set1_ip
442sets the expected IP address to
443.Fa ip .
444The
445.Fa ip
446argument is in binary format, in network byte-order, and
447.Fa iplen
448must be set to 4 for IPv4 and 16 for IPv6.
449.Fn X509_VERIFY_PARAM_set1_ip
450will fail if
451.Fa ip
452is NULL or if
453.Fa iplen
454is not 4 or 16.
455When an IP address is specified,
456certificate verification automatically invokes
457.Xr X509_check_ip 3 .
458.Pp
459.Fn X509_VERIFY_PARAM_set1_ip_asc
460sets the expected IP address to
461.Fa ipasc .
462The
463.Fa ipasc
464argument is a NUL-terminal ASCII string:
465dotted decimal quad for IPv4 and colon-separated hexadecimal for IPv6.
466The condensed "::" notation is supported for IPv6 addresses.
467.Fn X509_VERIFY_PARAM_set1_ip_asc
468will fail if
469.Fa ipasc
470is unparsable.
471.Sh RETURN VALUES
472.Fn X509_VERIFY_PARAM_set1_name ,
473.Fn X509_VERIFY_PARAM_set_flags ,
474.Fn X509_VERIFY_PARAM_clear_flags ,
475.Fn X509_VERIFY_PARAM_set_purpose ,
476.Fn X509_VERIFY_PARAM_set_trust ,
477.Fn X509_VERIFY_PARAM_add0_policy ,
478and
479.Fn X509_VERIFY_PARAM_set1_policies
480return 1 for success or 0 for failure.
481.Pp
482.Fn X509_VERIFY_PARAM_set1_host ,
483.Fn X509_VERIFY_PARAM_add1_host ,
484.Fn X509_VERIFY_PARAM_set1_email ,
485.Fn X509_VERIFY_PARAM_set1_ip ,
486and
487.Fn X509_VERIFY_PARAM_set1_ip_asc
488return 1 for success or 0 for failure.
489A failure from these routines will poison
490the
491.Vt X509_VERIFY_PARAM
492object so that future calls to
493.Xr X509_verify_cert 3
494using the poisoned object will fail.
495.Pp
496.Fn X509_VERIFY_PARAM_get_flags
497returns the current verification flags.
498.Pp
499.Fn X509_VERIFY_PARAM_get_time
500always returns the configured verification time.
501It does so even if the returned time will not be used because the flag
502.Dv X509_V_FLAG_USE_CHECK_TIME
503is unset.
504.Pp
505.Fn X509_VERIFY_PARAM_get_depth
506returns the current verification depth.
507.Pp
508.Fn X509_VERIFY_PARAM_get0_name
509and
510.Fn X509_VERIFY_PARAM_get0_peername
511return pointers to strings that are only valid
512during the lifetime of the given
513.Fa param
514object and that must not be freed by the application program.
515.Sh VERIFICATION FLAGS
516The verification flags consists of zero or more of the following
517flags OR'ed together.
518.Pp
519.Dv X509_V_FLAG_CRL_CHECK
520enables CRL checking for the certificate chain leaf certificate.
521An error occurs if a suitable CRL cannot be found.
522.Pp
523.Dv X509_V_FLAG_CRL_CHECK_ALL
524enables CRL checking for the entire certificate chain.
525.Pp
526.Dv X509_V_FLAG_IGNORE_CRITICAL
527disables critical extension checking.
528By default any unhandled critical extensions in certificates or (if
529checked) CRLs results in a fatal error.
530If this flag is set, unhandled critical extensions are ignored.
531.Sy WARNING :
532setting this option for anything other than debugging purposes can be a
533security risk.
534Finer control over which extensions are supported can be performed in
535the verification callback.
536.Pp
537The
538.Dv X509_V_FLAG_X509_STRICT
539flag disables workarounds for some broken certificates and makes the
540verification strictly apply X509 rules.
541.Pp
542.Dv X509_V_FLAG_ALLOW_PROXY_CERTS
543deprecated flag that used to
544enable proxy certificate verification.
545In LibreSSL, this flag has no effect.
546.Pp
547.Dv X509_V_FLAG_POLICY_CHECK
548enables certificate policy checking; by default no policy checking is
549performed.
550Additional information is sent to the verification callback relating to
551policy checking.
552.Pp
553.Dv X509_V_FLAG_EXPLICIT_POLICY ,
554.Dv X509_V_FLAG_INHIBIT_ANY ,
555and
556.Dv X509_V_FLAG_INHIBIT_MAP
557set the
558.Dq require explicit policy ,
559.Dq inhibit any policy ,
560and
561.Dq inhibit policy mapping
562flags, respectively, as defined in RFC 3280.
563These three flags are ignored unless
564.Dv X509_V_FLAG_POLICY_CHECK
565is also set.
566.Pp
567If
568.Dv X509_V_FLAG_NOTIFY_POLICY
569is set and policy checking is successful, a special status code is
570sent to the verification callback.
571.Pp
572By default some additional features such as indirect CRLs and CRLs
573signed by different keys are disabled.
574If
575.Dv X509_V_FLAG_EXTENDED_CRL_SUPPORT
576is set, they are enabled.
577.Pp
578If
579.Dv X509_V_FLAG_USE_DELTAS
580is set, delta CRLs (if present) are used to determine certificate
581status.
582If not set, deltas are ignored.
583.Pp
584.Dv X509_V_FLAG_CHECK_SS_SIGNATURE
585enables checking of the root CA self signed certificate signature.
586By default this check is disabled because it doesn't add any additional
587security but in some cases applications might want to check the
588signature anyway.
589A side effect of not checking the root CA signature is that disabled or
590unsupported message digests on the root CA are not treated as fatal
591errors.
592.Pp
593The deprecated
594.Dv X509_V_FLAG_CB_ISSUER_CHECK
595flag used to enable debugging of certificate issuer checks.
596It is provided for binary backwards compatibility and has no effect.
597.Pp
598When
599.Dv X509_V_FLAG_TRUSTED_FIRST
600is set, construction of the certificate chain in
601.Xr X509_verify_cert 3
602will search the trust store for issuer certificates before searching the
603provided untrusted certificates.
604Local issuer certificates are often more likely to satisfy local
605security requirements and lead to a locally trusted root.
606This is especially important when some certificates in the trust store
607have explicit trust settings; see the trust settings options of the
608.Cm x509
609command in
610.Xr openssl 1 .
611.Pp
612The
613.Dv X509_V_FLAG_NO_ALT_CHAINS
614flag suppresses checking for alternative chains.
615By default, unless
616.Dv X509_V_FLAG_TRUSTED_FIRST
617is set, when building a certificate chain, if the first certificate
618chain found is not trusted, then OpenSSL will attempt to replace
619untrusted certificates supplied by the peer with certificates from the
620trust store to see if an alternative chain can be found that is trusted.
621.Pp
622The
623.Dv X509_V_FLAG_PARTIAL_CHAIN
624flag causes intermediate certificates in the trust store to be treated
625as trust-anchors, in the same way as the self-signed root CA
626certificates.
627This makes it possible to trust certificates issued by an intermediate
628CA without having to trust its ancestor root CA.
629.Pp
630If
631.Dv X509_V_FLAG_USE_CHECK_TIME
632is set, the validity period of certificates and CRLs is checked.
633In this case,
634.Dv X509_V_FLAG_NO_CHECK_TIME
635is ignored.
636If the validation time was set with
637.Fn X509_VERIFY_PARAM_set_time ,
638that time is used.
639If
640.Fn X509_VERIFY_PARAM_set_time
641was not called, the UNIX Epoch (January 1, 1970) is used.
642.Pp
643If neither
644.Dv X509_V_FLAG_USE_CHECK_TIME
645nor
646.Dv X509_V_FLAG_NO_CHECK_TIME
647is set, the validity period of certificates and CRLs is checked
648using the current time.
649This is the default behaviour.
650In this case, if a validation time was set with
651.Fn X509_VERIFY_PARAM_set_time
652but
653.Dv X509_V_FLAG_USE_CHECK_TIME
654was later cleared with
655.Fn X509_VERIFY_PARAM_clear_flags ,
656the configured validation time is ignored
657and the current time is used anyway.
658.Pp
659If
660.Dv X509_V_FLAG_USE_CHECK_TIME
661is not set but
662.Dv X509_V_FLAG_NO_CHECK_TIME
663is set, the validity period of certificates and CRLs is not checked
664at all, and like in the previous case, any configured validation
665time is ignored.
666.Sh EXAMPLES
667Enable CRL checking when performing certificate verification during
668SSL connections associated with an
669.Vt SSL_CTX
670structure
671.Fa ctx :
672.Bd -literal -offset indent
673X509_VERIFY_PARAM *param;
674
675param = X509_VERIFY_PARAM_new();
676X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK);
677SSL_CTX_set1_param(ctx, param);
678X509_VERIFY_PARAM_free(param);
679.Ed
680.Sh SEE ALSO
681.Xr SSL_set1_host 3 ,
682.Xr SSL_set1_param 3 ,
683.Xr X509_check_host 3 ,
684.Xr X509_STORE_CTX_new 3 ,
685.Xr X509_STORE_new 3 ,
686.Xr X509_verify_cert 3 ,
687.Xr X509_VERIFY_PARAM_new 3
688.Sh HISTORY
689.Fn X509_VERIFY_PARAM_set1_name ,
690.Fn X509_VERIFY_PARAM_set_flags ,
691.Fn X509_VERIFY_PARAM_set_purpose ,
692.Fn X509_VERIFY_PARAM_set_trust ,
693.Fn X509_VERIFY_PARAM_set_time ,
694.Fn X509_VERIFY_PARAM_add0_policy ,
695.Fn X509_VERIFY_PARAM_set1_policies ,
696.Fn X509_VERIFY_PARAM_set_depth ,
697and
698.Fn X509_VERIFY_PARAM_get_depth
699first appeared in OpenSSL 0.9.8.
700.Fn X509_VERIFY_PARAM_clear_flags
701and
702.Fn X509_VERIFY_PARAM_get_flags
703first appeared in OpenSSL 0.9.8a.
704All these functions have been available since
705.Ox 4.5 .
706.Pp
707.Fn X509_VERIFY_PARAM_get0_name ,
708.Fn X509_VERIFY_PARAM_set1_host ,
709.Fn X509_VERIFY_PARAM_add1_host ,
710.Fn X509_VERIFY_PARAM_set_hostflags ,
711.Fn X509_VERIFY_PARAM_get0_peername ,
712.Fn X509_VERIFY_PARAM_set1_email ,
713.Fn X509_VERIFY_PARAM_set1_ip ,
714and
715.Fn X509_VERIFY_PARAM_set1_ip_asc
716first appeared in OpenSSL 1.0.2 and have been available since
717.Ox 6.3 .
718.Pp
719.Fn X509_VERIFY_PARAM_set_auth_level
720first appeared in OpenSSL 1.1.0 and
721.Fn X509_VERIFY_PARAM_get_time
722in OpenSSL 1.1.0d.
723Both functions have been available since
724.Ox 7.2 .
725.Sh BUGS
726Delta CRL checking is currently primitive.
727Only a single delta can be used and (partly due to limitations of
728.Vt X509_STORE )
729constructed CRLs are not maintained.
730.Pp
731If CRLs checking is enabled, CRLs are expected to be available in
732the corresponding
733.Vt X509_STORE
734structure.
735No attempt is made to download CRLs from the CRL distribution points
736extension.
diff --git a/src/lib/libcrypto/man/X509_add1_trust_object.3 b/src/lib/libcrypto/man/X509_add1_trust_object.3
deleted file mode 100644
index 067bf64464..0000000000
--- a/src/lib/libcrypto/man/X509_add1_trust_object.3
+++ /dev/null
@@ -1,99 +0,0 @@
1.\" $OpenBSD: X509_add1_trust_object.3,v 1.4 2024/09/02 08:04:32 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 2 2024 $
18.Dt X509_ADD1_TRUST_OBJECT 3
19.Os
20.Sh NAME
21.Nm X509_add1_trust_object ,
22.Nm X509_trust_clear ,
23.Nm X509_add1_reject_object ,
24.Nm X509_reject_clear
25.Nd mark an X.509 certificate as intended for a specific purpose
26.Sh SYNOPSIS
27.In openssl/x509.h
28.Ft int
29.Fo X509_add1_trust_object
30.Fa "X509 *x"
31.Fa "const ASN1_OBJECT *purpose"
32.Fc
33.Ft void
34.Fo X509_trust_clear
35.Fa "X509 *x"
36.Fc
37.Ft int
38.Fo X509_add1_reject_object
39.Fa "X509 *x"
40.Fa "const ASN1_OBJECT *purpose"
41.Fc
42.Ft void
43.Fo X509_reject_clear
44.Fa "X509 *x"
45.Fc
46.Sh DESCRIPTION
47.Fn X509_add1_trust_object
48appends a deep copy of the
49.Fa purpose
50object to the set of intended purposes that
51.Fa x
52contains as non-standard auxiliary data.
53The function
54.Xr OBJ_nid2obj 3
55can be used to create appropriate purpose objects from the
56.Dv NID_*
57constants mentioned in
58.Xr X509_check_purpose 3 ,
59even though the
60.Dv X509_PURPOSE_*
61constants listed in that manual page are not intended for use with
62.Fn X509_add1_trust_object .
63.Pp
64.Fn X509_trust_clear
65frees and removes all purpose objects from the set of intended
66purposes in the non-standard auxiliary data of
67.Fa x .
68.Pp
69.Fn X509_add1_reject_object
70and
71.Fn X509_reject_clear
72are similar except that they operate on a set of unintended purposes.
73.Pp
74As an alternative to using the functions documented in the present
75manual page, X.509 certificate extensions can be used.
76At the price of higher complexity, those allow storing the purpose
77inside the certificate itself in a standard-conforming way rather than
78merely in non-standard auxiliary data associated with the certificate.
79See
80.Xr EXTENDED_KEY_USAGE_new 3
81for details.
82.Sh RETURN VALUES
83.Fn X509_add1_trust_object
84and
85.Fn X509_add1_reject_object
86return the new number of purposes in the respective set
87or 0 if an error occurs, in particular if memory
88allocation fails or if
89.Fa x
90does not contain a sub-object that can hold non-standard auxiliary data.
91.Sh SEE ALSO
92.Xr ASN1_OBJECT_new 3 ,
93.Xr EXTENDED_KEY_USAGE_new 3 ,
94.Xr OBJ_nid2obj 3 ,
95.Xr X509_CERT_AUX_new 3 ,
96.Xr X509_new 3
97.Sh HISTORY
98These functions first appeared in OpenSSL 0.9.4 and have been available since
99.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/X509_check_ca.3 b/src/lib/libcrypto/man/X509_check_ca.3
deleted file mode 100644
index 114bac69e7..0000000000
--- a/src/lib/libcrypto/man/X509_check_ca.3
+++ /dev/null
@@ -1,117 +0,0 @@
1.\" $OpenBSD: X509_check_ca.3,v 1.7 2022/05/10 19:44:29 tb Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Victor B. Wagner <vitus@cryptocom.ru>.
5.\" Copyright (c) 2015, 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: May 10 2022 $
52.Dt X509_CHECK_CA 3
53.Os
54.Sh NAME
55.Nm X509_check_ca
56.Nd check whether a certificate is a CA certificate
57.Sh SYNOPSIS
58.In openssl/x509v3.h
59.Ft int
60.Fo X509_check_ca
61.Fa "X509 *cert"
62.Fc
63.Sh DESCRIPTION
64The
65.Fn X509_check_ca
66function checks whether the given certificate is a CA certificate,
67that is, whether it can be used to sign other certificates.
68.Sh RETURN VALUES
69If
70.Fa cert
71is a CA certificate, a non-zero value is returned; 0 otherwise.
72.Pp
73The following return values identify specific kinds of CA certificates:
74.Bl -tag -width 2n
75.It 1
76an X.509 v3 CA certificate with
77.Sy basicConstraints
78extension CA:TRUE
79.It 3
80a self-signed X.509 v1 certificate
81.It 4
82a certificate with
83.Sy keyUsage
84extension with bit
85.Sy keyCertSign
86set, but without
87.Sy basicConstraints
88.It 5
89a certificate with an outdated Netscape Certificate Type extension telling
90that it is a CA certificate
91.El
92.Sh SEE ALSO
93.Xr BASIC_CONSTRAINTS_new 3 ,
94.Xr EXTENDED_KEY_USAGE_new 3 ,
95.Xr X509_check_issued 3 ,
96.Xr X509_check_purpose 3 ,
97.Xr X509_EXTENSION_new 3 ,
98.Xr X509_new 3 ,
99.Xr X509_verify_cert 3
100.Sh HISTORY
101.Fn X509_check_ca
102first appeared in OpenSSL 0.9.7f and has been available since
103.Ox 3.8 .
104.Sh BUGS
105If
106.Fn X509_check_ca
107fails to cache X509v3 extension values, the return value may
108be incorrect.
109An application should
110call
111.Xr X509_check_purpose 3
112with a
113.Fa purpose
114argument of \-1,
115ensuring that the X509v3 extensions are cached,
116before calling
117.Fn X509_check_ca .
diff --git a/src/lib/libcrypto/man/X509_check_host.3 b/src/lib/libcrypto/man/X509_check_host.3
deleted file mode 100644
index dbc56c0d21..0000000000
--- a/src/lib/libcrypto/man/X509_check_host.3
+++ /dev/null
@@ -1,246 +0,0 @@
1.\" $OpenBSD: X509_check_host.3,v 1.6 2020/09/17 08:04:22 schwarze Exp $
2.\" full merge up to: OpenSSL a09e4d24 Jun 12 01:56:31 2014 -0400
3.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
4.\"
5.\" This file was written by Florian Weimer <fweimer@redhat.com> and
6.\" Viktor Dukhovni <openssl-users@dukhovni.org>.
7.\" Copyright (c) 2012, 2014, 2015, 2016 The OpenSSL Project.
8.\" All rights reserved.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\"
14.\" 1. Redistributions of source code must retain the above copyright
15.\" notice, this list of conditions and the following disclaimer.
16.\"
17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\" notice, this list of conditions and the following disclaimer in
19.\" the documentation and/or other materials provided with the
20.\" distribution.
21.\"
22.\" 3. All advertising materials mentioning features or use of this
23.\" software must display the following acknowledgment:
24.\" "This product includes software developed by the OpenSSL Project
25.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
26.\"
27.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
28.\" endorse or promote products derived from this software without
29.\" prior written permission. For written permission, please contact
30.\" openssl-core@openssl.org.
31.\"
32.\" 5. Products derived from this software may not be called "OpenSSL"
33.\" nor may "OpenSSL" appear in their names without prior written
34.\" permission of the OpenSSL Project.
35.\"
36.\" 6. Redistributions of any form whatsoever must retain the following
37.\" acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
40.\"
41.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
42.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
45.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\"
54.Dd $Mdocdate: September 17 2020 $
55.Dt X509_CHECK_HOST 3
56.Os
57.Sh NAME
58.Nm X509_check_host ,
59.Nm X509_check_email ,
60.Nm X509_check_ip ,
61.Nm X509_check_ip_asc
62.Nd X.509 certificate matching
63.Sh SYNOPSIS
64.In openssl/x509v3.h
65.Ft int
66.Fo X509_check_host
67.Fa "X509 *x"
68.Fa "const char *name"
69.Fa "size_t namelen"
70.Fa "unsigned int flags"
71.Fa "char **peername"
72.Fc
73.Ft int
74.Fo X509_check_email
75.Fa "X509 *x"
76.Fa "const char *address"
77.Fa "size_t addresslen"
78.Fa "unsigned int flags"
79.Fc
80.Ft int
81.Fo X509_check_ip
82.Fa "X509 *x"
83.Fa "const unsigned char *address"
84.Fa "size_t addresslen"
85.Fa "unsigned int flags"
86.Fc
87.Ft int
88.Fo X509_check_ip_asc
89.Fa "X509 *x"
90.Fa "const char *address"
91.Fa "unsigned int flags"
92.Fc
93.Sh DESCRIPTION
94The certificate matching functions are used to check whether a
95certificate matches a given hostname, email address, or IP address.
96The validity of the certificate and its trust level has to be checked by
97other means.
98.Pp
99.Fn X509_check_host
100checks if the certificate Subject Alternative Name (SAN) or Subject
101CommonName (CN) matches the specified hostname, which must be encoded
102in the preferred name syntax described in section 3.5 of RFC 1034.
103By default, wildcards are supported and they match only in the
104left-most label; they may match part of that label with an
105explicit prefix or suffix.
106For example, by default, the host
107.Fa name
108.Qq www.example.com
109would match a certificate with a SAN or CN value of
110.Qq *.example.com ,
111.Qq w*.example.com
112or
113.Qq *w.example.com .
114.Pp
115Per section 6.4.2 of RFC 6125,
116.Fa name
117values representing international domain names must be given in A-label
118form.
119The
120.Fa namelen
121argument must be the number of characters in the name string or zero, in
122which case the length is calculated with
123.Fn strlen name .
124When
125.Fa name
126starts with a dot (e.g.\&
127.Qq .example.com ) ,
128it will be matched by a certificate valid for any sub-domain of
129.Fa name ;
130see also
131.Fa X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
132below.
133.Pp
134When the certificate is matched and
135.Fa peername
136is not
137.Dv NULL ,
138a pointer to a copy of the matching SAN or CN from the peer
139certificate is stored at the address passed in
140.Fa peername .
141The application is responsible for freeing the peername via
142.Xr free 3
143when it is no longer needed.
144.Pp
145.Fn X509_check_email
146checks if the certificate matches the specified email
147.Fa address .
148Only the mailbox syntax of RFC 822 is supported.
149Comments are not allowed,
150and no attempt is made to normalize quoted characters.
151The
152.Fa addresslen
153argument must be the number of characters in the address string or zero,
154in which case the length is calculated with
155.Fn strlen address .
156.Pp
157.Fn X509_check_ip
158checks if the certificate matches a specified IPv4 or IPv6 address.
159The
160.Fa address
161array is in binary format, in network byte order.
162The length is either 4 (IPv4) or 16 (IPv6).
163Only explicitly marked addresses in the certificates are considered;
164IP addresses stored in DNS names and Common Names are ignored.
165.Pp
166.Fn X509_check_ip_asc
167is similar, except that the NUL-terminated string
168.Fa address
169is first converted to the internal representation.
170.Pp
171The
172.Fa flags
173argument is usually 0, but it can be the bitwise OR of the following
174flags.
175.Pp
176The
177.Dv X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
178flag causes the function to consider the subject DN even if the
179certificate contains at least one subject alternative name of the right
180type (DNS name or email address as appropriate); the default is to
181ignore the subject DN when at least one corresponding subject
182alternative names is present.
183.Pp
184The remaining flags are only meaningful for
185.Fn X509_check_host .
186.Pp
187The
188.Dv X509_CHECK_FLAG_NO_WILDCARDS
189flag disables wildcard expansion.
190.Pp
191The
192.Dv X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
193flag suppresses support for
194.Qq *
195as a wildcard pattern in labels that have a
196prefix or suffix, such as
197.Qq www*
198or
199.Qq *www .
200.Pp
201The
202.Dv X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS
203flag allows a
204.Qq *
205that constitutes the complete label of a DNS name (e.g.\&
206.Qq *.example.com )
207to match more than one label in
208.Fa name .
209.Pp
210The
211.Dv X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
212flag restricts
213.Fa name
214values which start with
215.Qq \&. ,
216that would otherwise match any sub-domain in the peer certificate,
217to only match direct child sub-domains.
218Thus, for instance, with this flag set a
219.Fa name
220of
221.Qq .example.com
222would match a peer certificate with a DNS name of
223.Qq www.example.com ,
224but would not match a peer certificate with a DNS name of
225.Qq www.sub.example.com .
226.Sh RETURN VALUES
227The functions return 1 for a successful match, 0 for a failed match and
228-1 for an internal error: typically a memory allocation failure or an
229ASN.1 decoding error.
230.Pp
231All functions can also return -2 if the input is malformed.
232For example,
233.Fn X509_check_host
234returns -2 if the provided
235.Fa name
236contains embedded NUL bytes.
237.Sh SEE ALSO
238.Xr SSL_set1_host 3 ,
239.Xr X509_EXTENSION_new 3 ,
240.Xr X509_get1_email 3 ,
241.Xr X509_new 3 ,
242.Xr X509_VERIFY_PARAM_set1_host 3
243.Sh HISTORY
244These functions first appeared in OpenSSL 1.0.2
245and have been available since
246.Ox 6.1 .
diff --git a/src/lib/libcrypto/man/X509_check_issued.3 b/src/lib/libcrypto/man/X509_check_issued.3
deleted file mode 100644
index f8c2a5297a..0000000000
--- a/src/lib/libcrypto/man/X509_check_issued.3
+++ /dev/null
@@ -1,109 +0,0 @@
1.\" $OpenBSD: X509_check_issued.3,v 1.4 2019/06/06 01:06:59 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Victor B. Wagner <vitus@cryptocom.ru>.
5.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 6 2019 $
52.Dt X509_CHECK_ISSUED 3
53.Os
54.Sh NAME
55.Nm X509_check_issued
56.Nd check whether a certificate was issued using a given CA certificate
57.Sh SYNOPSIS
58.In openssl/x509v3.h
59.Ft int
60.Fo X509_check_issued
61.Fa "X509 *issuer"
62.Fa "X509 *subject"
63.Fc
64.Sh DESCRIPTION
65This function checks whether the certificate
66.Fa subject
67was issued using the CA certificate
68.Fa issuer .
69It does the following checks:
70.Bl -bullet
71.It
72match the issuer field of
73.Fa subject
74against the subject field of
75.Fa issuer
76.It
77if
78.Sy authorityKeyIdentifier
79is present in the
80.Fa subject
81certificate,
82compare it to the
83.Sy subjectKeyIdentifier
84of
85.Fa issuer
86.It
87check the
88.Sy keyUsage
89field of
90.Fa issuer .
91.El
92.Sh RETURN VALUES
93This function returns
94.Dv X509_V_OK
95if the certificate
96.Fa subject
97is issued by
98.Fa issuer ,
99or some
100.Dv X509_V_ERR*
101constant to indicate an error.
102.Sh SEE ALSO
103.Xr X509_check_ca 3 ,
104.Xr X509_new 3 ,
105.Xr X509_verify_cert 3
106.Sh HISTORY
107.Fn X509_check_issued
108first appeared in OpenSSL 0.9.6 and has been available since
109.Ox 2.9 .
diff --git a/src/lib/libcrypto/man/X509_check_private_key.3 b/src/lib/libcrypto/man/X509_check_private_key.3
deleted file mode 100644
index 31df2126cc..0000000000
--- a/src/lib/libcrypto/man/X509_check_private_key.3
+++ /dev/null
@@ -1,73 +0,0 @@
1.\" $OpenBSD: X509_check_private_key.3,v 1.6 2019/06/06 01:06:59 schwarze Exp $
2.\" OpenSSL X509_check_private_key.pod 09ddb878 Jun 5 03:56:07 2017 +0800
3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: June 6 2019 $
19.Dt X509_CHECK_PRIVATE_KEY 3
20.Os
21.Sh NAME
22.Nm X509_check_private_key ,
23.Nm X509_REQ_check_private_key
24.Nd compare public key components
25.Sh SYNOPSIS
26.In openssl/x509.h
27.Ft int
28.Fo X509_check_private_key
29.Fa "const X509 *x"
30.Fa "const EVP_PKEY *k"
31.Fc
32.Ft int
33.Fo X509_REQ_check_private_key
34.Fa "X509_REQ *x"
35.Fa "EVP_PKEY *k"
36.Fc
37.Sh DESCRIPTION
38These functions are seriously misnamed.
39.Fn X509_check_private_key
40compares the
41.Em public
42key components (e.g. exponent and modulus of an RSA key)
43and parameters (e.g. EC params of an EC key) of
44.Fa k
45with the corresponding properties of
46.Fa x .
47Despite the name, it neither checks whether
48.Fa k
49contains private key components at all, nor, if any are present,
50whether they are consistent with the public key components.
51.Pp
52.Fn X509_REQ_check_private_key
53is equivalent to
54.Fn X509_check_private_key
55except that it compares to the public key
56contained in a certificate request.
57.Sh RETURN VALUES
58These functions return 1 if the public key components and parameters
59match, or 0 if they do not or if an error occurs.
60On error or mismatch, a reason code can be obtained using
61.Xr ERR_get_error 3 .
62.Sh SEE ALSO
63.Xr SSL_check_private_key 3 ,
64.Xr X509_new 3 ,
65.Xr X509_REQ_new 3
66.Sh HISTORY
67.Fn X509_check_private_key
68first appeared in SSLeay 0.6.5 and has been available since
69.Ox 2.4 .
70.Pp
71.Fn X509_REQ_check_private_key
72first appeared in OpenSSL 0.9.8 and has been available since
73.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/X509_check_purpose.3 b/src/lib/libcrypto/man/X509_check_purpose.3
deleted file mode 100644
index 8fea6679fc..0000000000
--- a/src/lib/libcrypto/man/X509_check_purpose.3
+++ /dev/null
@@ -1,431 +0,0 @@
1.\" $OpenBSD: X509_check_purpose.3,v 1.12 2024/09/02 08:04:32 tb Exp $
2.\"
3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 2 2024 $
18.Dt X509_CHECK_PURPOSE 3
19.Os
20.Sh NAME
21.Nm X509_check_purpose
22.Nd check intended usage of a public key
23.Sh SYNOPSIS
24.In openssl/x509v3.h
25.Ft int
26.Fo X509_check_purpose
27.Fa "X509 *certificate"
28.Fa "int purpose"
29.Fa "int ca"
30.Fc
31.Sh DESCRIPTION
32If the
33.Fa purpose
34argument is \-1,
35.Fn X509_check_purpose
36ignores the
37.Fa ca
38argument and checks that all the extensions of the
39.Fa certificate
40can be parsed and pass minimal sanity checks, ensuring that
41no extension occurs more than once.
42It also makes sure that all extensions are cached in the
43.Vt X509
44object.
45.Pp
46If the
47.Fa purpose
48argument is not \-1 and the
49.Fa ca
50flag is 0,
51.Fn X509_check_purpose
52also checks whether the public key contained in the
53.Fa certificate
54is intended to be used for the given
55.Fa purpose ,
56which can be one of the following integer constants.
57The check succeeds if none of the conditions given in the list below
58are violated.
59It always fails if parsing fails for any extension contained in the
60.Fa certificate .
61.Bl -tag -width 1n
62.It Dv X509_PURPOSE_SSL_CLIENT
63.Bl -dash -width 1n -compact
64.It
65If the
66.Fa certificate
67contains an Extended Key Usage extension, it contains the RFC 5280
68.Dq TLS WWW client authentication
69purpose
70.Pq Dv NID_client_auth .
71.It
72If the
73.Fa certificate
74contains a Key Usage extension, the
75.Dv digitalSignature
76bit is set.
77.It
78If the
79.Fa certificate
80contains a Netscape Cert Type extension, the
81.Dq SSL client certificate
82bit is set
83.Pq Dv NS_SSL_CLIENT .
84.El
85.It Dv X509_PURPOSE_SSL_SERVER
86.Bl -dash -width 1n -compact
87.It
88If the
89.Fa certificate
90contains an Extended Key Usage extension, it contains the RFC 5280
91.Dq TLS WWW server authentication
92purpose
93.Pq Dv NID_server_auth
94or the private
95.Dq Netscape Server Gated Crypto
96.Pq Dv NID_ns_sgc
97or
98.Dq Microsoft Server Gated Crypto
99.Pq Dv NID_ms_sgc
100purpose.
101.It
102If the
103.Fa certificate
104contains a Key Usage extension, at least one of the
105.Dv digitalSignature
106and
107.Dv keyEncipherment
108bits is set.
109.It
110If the
111.Fa certificate
112contains a Netscape Cert Type extension, the
113.Dq SSL server certificate
114bit is set
115.Pq Dv NS_SSL_SERVER
116.El
117.It Dv X509_PURPOSE_NS_SSL_SERVER
118.\" check_purpose_ns_ssl_server, "Netscape SSL server"
119This does the same checks as
120.Dv X509_PURPOSE_SSL_SERVER
121and additionally requires that a Key Usage extension, if present,
122has the
123.Dv keyEncipherment
124bit set.
125.It Dv X509_PURPOSE_SMIME_SIGN
126.\" check_purpose_smime_sign, "S/MIME signing"
127.Bl -dash -width 1n -compact
128.It
129If the
130.Fa certificate
131contains an Extended Key Usage extension, it contains the RFC 5280
132.Dq Email protection
133purpose
134.Pq Dv NID_email_protect .
135.It
136If the
137.Fa certificate
138contains a Key Usage extension, at least one of the
139.Dv digitalSignature
140and
141.Dv nonRepudiation
142bits is set.
143.It
144If the
145.Fa certificate
146contains a Netscape Cert Type extension, it has the
147.Dq S/MIME certificate
148bit set.
149If the
150.Dq SSL client certificate
151bit is set but the
152.Dq S/MIME certificate
153bit is not, no decision is made.
154.El
155.It Dv X509_PURPOSE_SMIME_ENCRYPT
156.\" check_purpose_smime_encrypt, "S/MIME encryption"
157.Bl -dash -width 1n -compact
158.It
159If the
160.Fa certificate
161contains an Extended Key Usage extension, it contains the RFC 5280
162.Dq Email protection
163purpose
164.Pq Dv NID_email_protect .
165.It
166If the
167.Fa certificate
168contains a Key Usage extension, the
169.Dv keyEncipherment
170bit is set.
171.It
172If the
173.Fa certificate
174contains a Netscape Cert Type extension, it has the
175.Dq S/MIME certificate
176bit set.
177If the
178.Dq SSL client certificate
179bit is set but the
180.Dq S/MIME certificate
181bit is not, no decision is made.
182.El
183.It Dv X509_PURPOSE_CRL_SIGN
184.\" check_purpose_crl_sign, "CRL signing"
185.Bl -dash -width 1n -compact
186.It
187If the
188.Fa certificate
189contains a Key Usage extension, the
190.Dv cRLSign
191bit is set.
192.El
193.It Dv X509_PURPOSE_ANY
194Nothing is required except that, if any extensions are present,
195parsing them needs to succeed.
196.It Dv X509_PURPOSE_OCSP_HELPER
197.\" ocsp_helper, "OCSP helper"
198Nothing is required except that, if any extensions are present,
199parsing them needs to succeed.
200The application program is expected
201to do the actual checking by other means.
202.It Dv X509_PURPOSE_TIMESTAMP_SIGN
203.\" check_purpose_timestamp_sign, "Time Stamp signing"
204.Bl -dash -width 1n -compact
205.It
206The
207.Fa certificate
208contains an Extended Key Usage extension containing the RFC 5280
209.Dq Time Stamping
210purpose and no other purpose.
211This extension is marked as critical.
212.It
213If the
214.Fa certificate
215contains a Key Usage extension, at least one of the
216.Dv digitalSignature
217and
218.Dv nonRepudiation
219bits is set, and no other bits are set.
220.El
221.El
222.Pp
223If the
224.Fa purpose
225argument is not \-1 and the
226.Fa ca
227flag is non-zero,
228.Fn X509_check_purpose
229instead checks, in addition to the minimal sanity checks, whether the
230.Fa certificate
231can be used as a certificate authority certificate
232in the context of the given
233.Fa purpose .
234To succeed, the check always requires that none of the following
235conditions are violated:
236.Pp
237.Bl -dash -width 1n -compact
238.It
239If the
240.Fa certificate
241contains any extensions, parsing them succeeds.
242.It
243If the
244.Fa certificate
245contains a Key Usage extension, the
246.Dv keyCertSign
247bit is set.
248.It
249If the
250.Fa certificate
251contains a Basic Constraints extension, the
252.Fa cA
253field is set.
254.It
255If the
256.Fa certificate
257is a version 1 certificate, the subject name matches the issuer name
258and the certificate is self signed.
259.El
260.Pp
261The check succeeds if none of the additional conditions given in
262the list below are violated.
263.Bl -tag -width 1n
264.It Dv X509_PURPOSE_SSL_CLIENT
265.Bl -dash -width 1n -compact
266.It
267If the
268.Fa certificate
269contains an Extended Key Usage extension, it contains the RFC 5280
270.Dq TLS WWW client authentication
271purpose
272.Pq Dv NID_client_auth .
273.It
274If the
275.Fa certificate
276is not a version 1 certificate and does not contain a Basic Constraints
277extension, it contains a Key Usage extension with the
278.Dv keyCertSign
279bit set or a Netscape Cert Type extension with the
280.Dq SSL CA certificate
281bit set.
282.El
283.It Dv X509_PURPOSE_SSL_SERVER No or Dv X509_PURPOSE_NS_SSL_SERVER
284.Bl -dash -width 1n -compact
285.It
286If the
287.Fa certificate
288contains an Extended Key Usage extension, it contains the RFC 5280
289.Dq TLS WWW server authentication
290purpose
291.Pq Dv NID_server_auth
292or the private
293.Dq Netscape Server Gated Crypto
294.Pq Dv NID_ns_sgc
295or
296.Dq Microsoft Server Gated Crypto
297.Pq Dv NID_ms_sgc
298purpose.
299.It
300If the
301.Fa certificate
302is not a version 1 certificate and does not contain a Basic Constraints
303extension, it contains a Key Usage extension with the
304.Dv keyCertSign
305bit set or a Netscape Cert Type extension with the
306.Dq SSL CA certificate
307bit set.
308.El
309.It Dv X509_PURPOSE_SMIME_SIGN No or Dv X509_PURPOSE_SMIME_ENCRYPT
310.Bl -dash -width 1n -compact
311.It
312If the
313.Fa certificate
314contains an Extended Key Usage extension, it contains the RFC 5280
315.Dq Email protection
316purpose
317.Pq Dv NID_email_protect .
318.It
319If the
320.Fa certificate
321is not a version 1 certificate and does not contain a Basic Constraints
322extension, it contains a Key Usage extension with the
323.Dv keyCertSign
324bit set or a Netscape Cert Type extension with the
325.Dq S/MIME CA certificate
326bit set.
327.El
328.It Xo
329.Dv X509_PURPOSE_CRL_SIGN ,
330.Dv X509_PURPOSE_OCSP_HELPER ,
331or
332.Dv X509_PURPOSE_TIMESTAMP_SIGN
333.Xc
334.Bl -dash -width 1n -compact
335.It
336If the
337.Fa certificate
338is not a version 1 certificate and does not contain a Basic Constraints
339extension, it contains a Key Usage extension with the
340.Dv keyCertSign
341bit set or a Netscape Cert Type extension with at least one of the
342.Dq SSL CA certificate ,
343.Dq S/MIME CA certificate ,
344or
345.Dq Object-signing CA certificate
346bits set.
347.El
348.It Dv X509_PURPOSE_ANY
349Nothing is required except that, if any extensions are present,
350parsing them needs to succeed.
351The check even succeeds if the three other common conditions
352cited above this list are violated.
353.El
354.Pp
355If the function
356.Xr X509_PURPOSE_add 3
357was called before
358.Fn X509_check_purpose ,
359it may have installed different, user-supplied checking functions
360for some of the standard purposes listed above, or it may have
361installed additional, user-supplied checking functions for user-defined
362.Fa purpose
363identifiers not listed above.
364.Sh RETURN VALUES
365If the parsing of certificate extensions fails, sanity checks fail or the
366.Fa purpose
367is invalid,
368.Fn X509_check_purpose
369returns \-1 to indicate the error.
370.Pp
371If the
372.Fa purpose
373argument is \-1 and parsing and minimal sanity checks succeed,
374.Fn X509_check_purpose
375returns 1 to indicate success.
376.Pp
377Otherwise, it returns the following values:
378.Pp
379If
380.Fa ca
381is 0:
382.Bl -column -1 Failure -compact
383.It 0 Ta Failure Ta The
384.Fa certificate
385cannot be used for the
386.Fa purpose .
387.It 1 Ta Success Ta The
388.Fa certificate
389can be used for the
390.Fa purpose .
391.It 2 Ta Unknown Ta \&No decision can be made.
392.El
393.Pp
394If
395.Fa ca
396is non-zero:
397.Bl -column -1 Failure -compact
398.It 0 Ta Failure Ta The
399.Fa certificate
400cannot be used as a CA for the
401.Fa purpose .
402.It 1 Ta Success Ta The
403.Fa certificate
404can be used as a CA for the
405.Fa purpose .
406.It 3 Ta Success Ta The Fa certificate No is a version 1 CA .
407.It 4 Ta Success Ta The Key Usage allows Dv keyCertSign .
408.It 5 Ta Success Ta A Netscape Cert Type allows usage as a CA.
409.El
410.Sh SEE ALSO
411.Xr BASIC_CONSTRAINTS_new 3 ,
412.Xr EXTENDED_KEY_USAGE_new 3 ,
413.Xr X509_new 3 ,
414.Xr X509_PURPOSE_set 3 ,
415.Xr X509V3_get_d2i 3 ,
416.Xr x509v3.cnf 5
417.Sh STANDARDS
418RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
419Certificate Revocation List (CRL) Profile
420.Bl -dash -offset indent -compact
421.It
422section 4.2.1.3: Key Usage
423.It
424section 4.2.1.9: Basic Constraints
425.It
426section 4.2.1.12: Extended Key Usage
427.El
428.Sh HISTORY
429.Fn X509_check_purpose
430first appeared in OpenSSL 0.9.5 and has been available since
431.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/X509_cmp.3 b/src/lib/libcrypto/man/X509_cmp.3
deleted file mode 100644
index b1cdec1773..0000000000
--- a/src/lib/libcrypto/man/X509_cmp.3
+++ /dev/null
@@ -1,235 +0,0 @@
1.\" $OpenBSD: X509_cmp.3,v 1.4 2024/06/07 14:00:09 job Exp $
2.\" full merge up to: OpenSSL ea5d4b89 Jun 6 11:42:02 2019 +0800
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Paul Yang <yang.yang@baishancloud.com>.
22.\" Copyright (c) 2019 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: June 7 2024 $
69.Dt X509_CMP 3
70.Os
71.Sh NAME
72.Nm X509_cmp ,
73.Nm X509_NAME_cmp ,
74.\" The alias X509_name_cmp(3) is intentionally undocumented
75.\" because it is almost unused in real-world code.
76.Nm X509_issuer_and_serial_cmp ,
77.Nm X509_issuer_name_cmp ,
78.Nm X509_subject_name_cmp ,
79.Nm X509_CRL_cmp ,
80.Nm X509_CRL_match
81.Nd compare X.509 certificates and related values
82.\" The function name_cmp() is intentionally undocumented.
83.\" It was a mistake to make it public in the first place,
84.\" and it is no longer part of the public API in OpenSSL 1.1.
85.Sh SYNOPSIS
86.In openssl/x509.h
87.Ft int
88.Fo X509_cmp
89.Fa "const X509 *a"
90.Fa "const X509 *b"
91.Fc
92.Ft int
93.Fo X509_NAME_cmp
94.Fa "const X509_NAME *a"
95.Fa "const X509_NAME *b"
96.Fc
97.Ft int
98.Fo X509_issuer_and_serial_cmp
99.Fa "const X509 *a"
100.Fa "const X509 *b"
101.Fc
102.Ft int
103.Fo X509_issuer_name_cmp
104.Fa "const X509 *a"
105.Fa "const X509 *b"
106.Fc
107.Ft int
108.Fo X509_subject_name_cmp
109.Fa "const X509 *a"
110.Fa "const X509 *b"
111.Fc
112.Ft int
113.Fo X509_CRL_cmp
114.Fa "const X509_CRL *a"
115.Fa "const X509_CRL *b"
116.Fc
117.Ft int
118.Fo X509_CRL_match
119.Fa "const X509_CRL *a"
120.Fa "const X509_CRL *b"
121.Fc
122.Sh DESCRIPTION
123.Fn X509_cmp
124compares two X.509 certificates using
125.Xr memcmp 3
126on the hashes of their canonical (DER) representations as generated with
127.Xr X509_digest 3 .
128The digest function is implementation-specific: LibreSSL uses SHA-512, other
129implementations use SHA-1.
130.Pp
131.Fn X509_NAME_cmp
132compares two X.501
133.Vt Name
134objects using their canonical (DER) representations generated with
135.Xr i2d_X509_NAME 3 .
136.Pp
137.Fn X509_issuer_and_serial_cmp
138compares the
139.Fa issuer
140and
141.Fa serialNumber
142fields of two
143.Vt TBSCertificate
144structures, using
145.Fn X509_NAME_cmp
146for the
147.Fa issuer
148fields.
149.Pp
150.Fn X509_issuer_name_cmp
151compares the
152.Fa issuer
153fields of two
154.Vt TBSCertificate
155structures using
156.Fn X509_NAME_cmp .
157.Pp
158.Fn X509_subject_name_cmp
159compares the
160.Fa subject
161fields of two
162.Vt TBSCertificate
163structures using
164.Fn X509_NAME_cmp .
165.Pp
166.Fn X509_CRL_cmp
167is misnamed; it only compares the
168.Fa issuer
169fields of two
170.Vt TBSCertList
171structures using
172.Fn X509_NAME_cmp .
173.Pp
174.Fn X509_CRL_match
175compares two certificate revocation lists using
176.Xr memcmp 3
177on the hashes of their canonical (DER) representations as generated with
178.Xr X509_CRL_digest 3 .
179The digest function is implementation-specific: LibreSSL uses SHA-512, other
180implementations use SHA-1.
181.Sh RETURN VALUES
182All these functions return 0 to indicate a match or a non-zero value
183to indicate a mismatch.
184.Pp
185.Fn X509_NAME_cmp ,
186.Fn X509_issuer_and_serial_cmp ,
187.Fn X509_issuer_name_cmp ,
188.Fn X509_subject_name_cmp
189and
190.Fn X509_CRL_cmp
191may return -2 to indicate an error.
192.Sh SEE ALSO
193.Xr i2d_X509_NAME 3 ,
194.Xr X509_CRL_new 3 ,
195.Xr X509_digest 3 ,
196.Xr X509_NAME_new 3 ,
197.Xr X509_new 3
198.Sh STANDARDS
199RFC 5280: Internet X.509 Public Key Infrastructure Certificate
200and Certificate Revocation List (CRL) Profile
201.Bl -dash -compact -offset indent
202.It
203section 4.1: Basic Certificate Fields
204.It
205section 5.1: CRL Fields
206.El
207.Sh HISTORY
208.Fn X509_issuer_and_serial_cmp ,
209.Fn X509_issuer_name_cmp ,
210and
211.Fn X509_subject_name_cmp
212first appeared in SSLeay 0.5.1 and
213.Fn X509_NAME_cmp
214and
215.Fn X509_CRL_cmp
216in SSLeay 0.8.0.
217These functions have been available since
218.Ox 2.4 .
219.Pp
220.Fn X509_cmp
221first appeared in OpenSSL 0.9.5 and has been available since
222.Ox 2.7 .
223.Pp
224.Fn X509_CRL_match
225first appeared in OpenSSL 1.0.0 and has been available since
226.Ox 4.9 .
227.Sh BUGS
228For
229.Fn X509_NAME_cmp ,
230.Fn X509_issuer_and_serial_cmp ,
231.Fn X509_issuer_name_cmp ,
232.Fn X509_subject_name_cmp
233and
234.Fn X509_CRL_cmp ,
235the return value -2 sometimes indicates a mismatch and sometimes an error.
diff --git a/src/lib/libcrypto/man/X509_cmp_time.3 b/src/lib/libcrypto/man/X509_cmp_time.3
deleted file mode 100644
index bb430dfbb7..0000000000
--- a/src/lib/libcrypto/man/X509_cmp_time.3
+++ /dev/null
@@ -1,200 +0,0 @@
1.\" $OpenBSD: X509_cmp_time.3,v 1.12 2024/03/05 18:30:40 tb Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Emilia Kasper <emilia@openssl.org>
22.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: March 5 2024 $
69.Dt X509_CMP_TIME 3
70.Os
71.Sh NAME
72.Nm X509_cmp_time ,
73.Nm X509_cmp_current_time ,
74.Nm X509_time_adj_ex ,
75.Nm X509_time_adj ,
76.Nm X509_gmtime_adj
77.Nd ASN.1 Time utilities
78.Sh SYNOPSIS
79.In openssl/x509.h
80.Ft int
81.Fo X509_cmp_time
82.Fa "const ASN1_TIME *asn1_time"
83.Fa "time_t *cmp_time"
84.Fc
85.Ft int
86.Fo X509_cmp_current_time
87.Fa "const ASN1_TIME *asn1_time"
88.Fc
89.Ft ASN1_TIME *
90.Fo X509_time_adj_ex
91.Fa "ASN1_TIME *out_time"
92.Fa "int offset_day"
93.Fa "long offset_sec"
94.Fa "time_t *in_time"
95.Fc
96.Ft ASN1_TIME *
97.Fo X509_time_adj
98.Fa "ASN1_TIME *out_time"
99.Fa "long offset_sec"
100.Fa "time_t *in_time"
101.Fc
102.Ft ASN1_TIME *
103.Fo X509_gmtime_adj
104.Fa "ASN1_TIME *out_time"
105.Fa "long offset_sec"
106.Fc
107.Sh DESCRIPTION
108.Fn X509_cmp_time
109parses
110.Fa asn1_time
111and compares it to
112.Fa cmp_time ,
113or to the current time if
114.Fa cmp_time
115is
116.Dv NULL .
117.Fn X509_cmp_current_time
118compares it to the current time.
119.Pp
120.Fn X509_time_adj_ex
121sets
122.Fa out_time
123to a time
124.Fa offset_day
125and
126.Fa offset_sec
127later than
128.Fa in_time .
129The values of
130.Fa offset_day
131and
132.Fa offset_sec
133can be negative to set a time before
134.Fa in_time .
135The
136.Fa offset_sec
137value can also exceed the number of seconds in a day.
138If
139.Fa in_time
140is
141.Dv NULL ,
142the current time is used instead.
143If
144.Fa out_time
145is
146.Dv NULL ,
147a new
148.Vt ASN1_TIME
149structure is allocated and returned.
150.Pp
151.Fn X509_time_adj
152does the same with a 0 day offset.
153.Pp
154.Fn X509_gmtime_adj
155does the same using the current time instead of
156.Fa in_time ,
157that is, it sets
158.Fa out_time
159to a time
160.Fa offset_sec
161seconds later than the current time.
162.Sh RETURN VALUES
163.Fn X509_cmp_time
164and
165.Fn X509_cmp_current_time
166return -1 if
167.Fa asn1_time
168is earlier than or equal to
169.Fa cmp_time ,
1701 if it is later, or 0 on error.
171.Pp
172.Fn X509_time_adj_ex ,
173.Fn X509_time_adj ,
174and
175.Fn X509_gmtime_adj
176return a pointer to the updated or newly allocated
177.Vt ASN1_TIME
178structure or
179.Dv NULL
180on error.
181.Sh SEE ALSO
182.Xr ASN1_TIME_new 3 ,
183.Xr ASN1_TIME_set 3 ,
184.Xr time 3
185.Sh HISTORY
186.Fn X509_cmp_current_time
187and
188.Fn X509_gmtime_adj
189first appeared in SSLeay 0.6.0 and have been available since
190.Ox 2.4 .
191.Pp
192.Fn X509_cmp_time
193and
194.Fn X509_time_adj
195first appeared in OpenSSL 0.9.6 and have been available since
196.Ox 2.9 .
197.Pp
198.Fn X509_time_adj_ex
199first appeared in OpenSSL 1.0.0 and has been available since
200.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/X509_digest.3 b/src/lib/libcrypto/man/X509_digest.3
deleted file mode 100644
index 7627e07731..0000000000
--- a/src/lib/libcrypto/man/X509_digest.3
+++ /dev/null
@@ -1,155 +0,0 @@
1.\" $OpenBSD: X509_digest.3,v 1.8 2019/08/20 13:27:19 schwarze Exp $
2.\" full merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100
3.\"
4.\" This file was written by Rich Salz <rsalz@openssl.org>
5.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: August 20 2019 $
52.Dt X509_DIGEST 3
53.Os
54.Sh NAME
55.Nm X509_digest ,
56.Nm X509_CRL_digest ,
57.Nm X509_pubkey_digest ,
58.Nm X509_NAME_digest ,
59.Nm X509_REQ_digest ,
60.Nm PKCS7_ISSUER_AND_SERIAL_digest
61.Nd get digests of various objects
62.Sh SYNOPSIS
63.In openssl/x509.h
64.Ft int
65.Fo X509_digest
66.Fa "const X509 *data"
67.Fa "const EVP_MD *type"
68.Fa "unsigned char *md"
69.Fa "unsigned int *len"
70.Fc
71.Ft int
72.Fo X509_CRL_digest
73.Fa "const X509_CRL *data"
74.Fa "const EVP_MD *type"
75.Fa "unsigned char *md"
76.Fa "unsigned int *len"
77.Fc
78.Ft int
79.Fo X509_pubkey_digest
80.Fa "const X509 *data"
81.Fa "const EVP_MD *type"
82.Fa "unsigned char *md"
83.Fa "unsigned int *len"
84.Fc
85.Ft int
86.Fo X509_REQ_digest
87.Fa "const X509_REQ *data"
88.Fa "const EVP_MD *type"
89.Fa "unsigned char *md"
90.Fa "unsigned int *len"
91.Fc
92.Ft int
93.Fo X509_NAME_digest
94.Fa "const X509_NAME *data"
95.Fa "const EVP_MD *type"
96.Fa "unsigned char *md"
97.Fa "unsigned int *len"
98.Fc
99.In openssl/pkcs7.h
100.Ft int
101.Fo PKCS7_ISSUER_AND_SERIAL_digest
102.Fa "PKCS7_ISSUER_AND_SERIAL *data"
103.Fa "const EVP_MD *type"
104.Fa "unsigned char *md"
105.Fa "unsigned int *len"
106.Fc
107.Sh DESCRIPTION
108.Fn X509_pubkey_digest
109returns a digest of the DER representation of the public key contained in
110.Fa data .
111All other functions described here return a digest of the DER
112representation of their entire
113.Fa data
114object.
115.Pp
116The
117.Fa type
118parameter specifies the digest to be used, such as
119.Xr EVP_sha1 3 .
120.Fa md
121is a pointer to the buffer where the digest will be copied and is
122assumed to be large enough; a size of at least
123.Dv EVP_MAX_MD_SIZE
124bytes is suggested.
125The
126.Fa len
127parameter, if not
128.Dv NULL ,
129points to a place where the digest size will be stored.
130.Sh RETURN VALUES
131These functions return 1 for success or 0 for failure.
132.Sh SEE ALSO
133.Xr EVP_get_digestbyname 3 ,
134.Xr X509_cmp 3 ,
135.Xr X509_CRL_new 3 ,
136.Xr X509_NAME_new 3 ,
137.Xr X509_new 3 ,
138.Xr X509_REQ_new 3
139.Sh HISTORY
140.Fn X509_digest ,
141.Fn X509_NAME_digest ,
142and
143.Fn PKCS7_ISSUER_AND_SERIAL_digest
144first appeared in SSLeay 0.6.5 and have been available since
145.Ox 2.4 .
146.Pp
147.Fn X509_CRL_digest
148and
149.Fn X509_REQ_digest
150first appeared in OpenSSL 0.9.6 and have been available since
151.Ox 2.9 .
152.Pp
153.Fn X509_pubkey_digest
154first appeared in OpenSSL 0.9.7 and has been available since
155.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/X509_find_by_subject.3 b/src/lib/libcrypto/man/X509_find_by_subject.3
deleted file mode 100644
index 98a76a1fca..0000000000
--- a/src/lib/libcrypto/man/X509_find_by_subject.3
+++ /dev/null
@@ -1,69 +0,0 @@
1.\" $OpenBSD: X509_find_by_subject.3,v 1.1 2021/07/04 12:56:27 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 4 2021 $
18.Dt X509_FIND_BY_SUBJECT 3
19.Os
20.Sh NAME
21.Nm X509_find_by_subject ,
22.Nm X509_find_by_issuer_and_serial
23.Nd search an array of X.509 certificates
24.Sh SYNOPSIS
25.In openssl/x509.h
26.Ft X509 *
27.Fo X509_find_by_subject
28.Fa "STACK_OF(X509) *sk"
29.Fa "X509_NAME *subject"
30.Fc
31.Ft X509 *
32.Fo X509_find_by_issuer_and_serial
33.Fa "STACK_OF(X509) *sk"
34.Fa "X509_NAME *issuer"
35.Fa "ASN1_INTEGER *serial"
36.Fc
37.Sh DESCRIPTION
38.Fn X509_find_by_subject
39searches the variable-sized array
40.Fa sk
41for a certificate with a matching
42.Fa subject
43name.
44.Pp
45.Fn X509_find_by_issuer_and_serial
46searches the array for a certificate where both the
47.Fa issuer
48name and the
49.Fa serial
50number match the arguments.
51.Sh RETURN VALUES
52These functions return a pointer to the first matching certificate or
53.Dv NULL
54if
55.Fa sk
56is
57.Dv NULL
58or does not contain a matching certificate.
59.Sh SEE ALSO
60.Xr ASN1_INTEGER_new 3 ,
61.Xr STACK_OF 3 ,
62.Xr X509_cmp 3 ,
63.Xr X509_get_serialNumber 3 ,
64.Xr X509_get_subject_name 3 ,
65.Xr X509_NAME_new 3 ,
66.Xr X509_new 3
67.Sh HISTORY
68These functions first appeared in SSLeay 0.8.1 and have been available since
69.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/X509_get0_notBefore.3 b/src/lib/libcrypto/man/X509_get0_notBefore.3
deleted file mode 100644
index 5e5c08b79a..0000000000
--- a/src/lib/libcrypto/man/X509_get0_notBefore.3
+++ /dev/null
@@ -1,264 +0,0 @@
1.\" $OpenBSD: X509_get0_notBefore.3,v 1.7 2024/03/05 18:30:40 tb Exp $
2.\" content checked up to: OpenSSL 27b138e9 May 19 00:16:38 2017 +0000
3.\"
4.\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: March 5 2024 $
19.Dt X509_GET0_NOTBEFORE 3
20.Os
21.Sh NAME
22.Nm X509_get0_notBefore ,
23.Nm X509_get0_notAfter ,
24.Nm X509_getm_notBefore ,
25.Nm X509_getm_notAfter ,
26.Nm X509_get_notBefore ,
27.Nm X509_get_notAfter ,
28.Nm X509_CRL_get0_lastUpdate ,
29.Nm X509_CRL_get0_nextUpdate ,
30.Nm X509_CRL_get_lastUpdate ,
31.Nm X509_CRL_get_nextUpdate ,
32.Nm X509_set1_notBefore ,
33.Nm X509_set1_notAfter ,
34.Nm X509_set_notBefore ,
35.Nm X509_set_notAfter ,
36.Nm X509_CRL_set1_lastUpdate ,
37.Nm X509_CRL_set1_nextUpdate ,
38.Nm X509_CRL_set_lastUpdate ,
39.Nm X509_CRL_set_nextUpdate
40.Nd get and set certificate and CRL validity dates
41.Sh SYNOPSIS
42.In openssl/x509.h
43.Ft const ASN1_TIME *
44.Fo X509_get0_notBefore
45.Fa "const X509 *x"
46.Fc
47.Ft const ASN1_TIME *
48.Fo X509_get0_notAfter
49.Fa "const X509 *x"
50.Fc
51.Ft ASN1_TIME *
52.Fo X509_getm_notBefore
53.Fa "const X509 *x"
54.Fc
55.Ft ASN1_TIME *
56.Fo X509_getm_notAfter
57.Fa "const X509 *x"
58.Fc
59.Ft ASN1_TIME *
60.Fo X509_get_notBefore
61.Fa "const X509 *x"
62.Fc
63.Ft ASN1_TIME *
64.Fo X509_get_notAfter
65.Fa "const X509 *x"
66.Fc
67.Ft const ASN1_TIME *
68.Fo X509_CRL_get0_lastUpdate
69.Fa "const X509_CRL *crl"
70.Fc
71.Ft const ASN1_TIME *
72.Fo X509_CRL_get0_nextUpdate
73.Fa "const X509_CRL *crl"
74.Fc
75.Ft ASN1_TIME *
76.Fo X509_CRL_get_lastUpdate
77.Fa "X509_CRL *crl"
78.Fc
79.Ft ASN1_TIME *
80.Fo X509_CRL_get_nextUpdate
81.Fa "X509_CRL *crl"
82.Fc
83.Ft int
84.Fo X509_set1_notBefore
85.Fa "X509 *x"
86.Fa "const ASN1_TIME *tm"
87.Fc
88.Ft int
89.Fo X509_set1_notAfter
90.Fa "X509 *x"
91.Fa "const ASN1_TIME *tm"
92.Fc
93.Ft int
94.Fo X509_set_notBefore
95.Fa "X509 *x"
96.Fa "const ASN1_TIME *tm"
97.Fc
98.Ft int
99.Fo X509_set_notAfter
100.Fa "X509 *x"
101.Fa "const ASN1_TIME *tm"
102.Fc
103.Ft int
104.Fo X509_CRL_set1_lastUpdate
105.Fa "X509_CRL *crl"
106.Fa "const ASN1_TIME *tm"
107.Fc
108.Ft int
109.Fo X509_CRL_set1_nextUpdate
110.Fa "X509_CRL *crl"
111.Fa "const ASN1_TIME *tm"
112.Fc
113.Ft int
114.Fo X509_CRL_set_lastUpdate
115.Fa "X509_CRL *crl"
116.Fa "const ASN1_TIME *tm"
117.Fc
118.Ft int
119.Fo X509_CRL_set_nextUpdate
120.Fa "X509_CRL *crl"
121.Fa "const ASN1_TIME *tm"
122.Fc
123.Sh DESCRIPTION
124.Fn X509_getm_notBefore
125and
126.Fn X509_getm_notAfter
127return pointers to the
128.Fa notBefore
129and
130.Fa notAfter
131fields of the validity period of the certificate
132.Fa x ,
133respectively.
134.Fn X509_get_notBefore
135and
136.Fn X509_get_notAfter
137are deprecated aliases implemented as macros.
138.Pp
139.Fn X509_get0_notBefore
140and
141.Fn X509_get0_notAfter
142are identical except for the const qualifier on the return type.
143.Pp
144.Fn X509_CRL_get0_lastUpdate
145is misnamed in a confusing way: it returns a pointer to the
146.Fa thisUpdate
147field of the
148.Fa crl ,
149indicating the time when this
150.Fa crl
151was issued.
152.Pp
153.Fn X509_CRL_get0_nextUpdate
154returns a pointer to the
155.Fa nextUpdate
156field of the
157.Fa crl ,
158indicating the time when issuing the subsequent CRL will be due.
159.Pp
160.Fn X509_CRL_get_lastUpdate
161and
162.Fn X509_CRL_get_nextUpdate
163are deprecated and identical except for the const qualifier
164on the argument and on the return type.
165.Pp
166.Fn X509_set1_notBefore ,
167.Fn X509_set1_notAfter ,
168.Fn X509_CRL_set1_lastUpdate ,
169and
170.Fn X509_CRL_set1_nextUpdate
171set the
172.Fa notBefore ,
173.Fa notAfter ,
174.Fa thisUpdate Pq sic!\& ,
175or
176.Fa nextUpdate
177field of
178.Fa x
179or
180.Fa crl ,
181respectively, to a deep copy of
182.Fa tm
183and free the
184.Vt ASN1_TIME
185value that they replace.
186.Pp
187.Fn X509_set_notBefore ,
188.Fn X509_set_notAfter ,
189.Fn X509_CRL_set_lastUpdate ,
190and
191.Fn X509_CRL_set_nextUpdate
192are deprecated aliases.
193.Sh RETURN VALUES
194The
195.Sy get
196functions return internal pointers
197which must not be freed by the application, or
198.Dv NULL
199if the requested field is not available.
200They may crash with a
201.Dv NULL
202pointer access if
203.Fa x
204or
205.Fa crl
206is
207.Dv NULL .
208.Pp
209The
210.Sy set
211functions return 1 on success or 0 on failure.
212They fail if
213.Fa x
214is
215.Dv NULL
216or does not contain a
217.Fa validity
218substructure, if
219.Fa crl
220is
221.Dv NULL ,
222or if
223.Xr ASN1_STRING_dup 3
224fails.
225.Pp
226Except for some cases of
227.Xr ASN1_STRING_dup 3
228failure, these functions do not support
229determining reasons for failure with
230.Xr ERR_get_error 3 .
231.Sh SEE ALSO
232.Xr ASN1_TIME_set 3 ,
233.Xr X509_cmp_time 3 ,
234.Xr X509_CRL_get0_by_serial 3 ,
235.Xr X509_CRL_new 3 ,
236.Xr X509_get_subject_name 3 ,
237.Xr X509_new 3 ,
238.Xr X509_sign 3 ,
239.Xr X509_VAL_new 3 ,
240.Xr X509_verify_cert 3
241.Sh HISTORY
242.Fn X509_get_notBefore ,
243.Fn X509_get_notAfter ,
244.Fn X509_set_notBefore ,
245and
246.Fn X509_set_notAfter
247first appeared in SSLeay 0.6.5 and have been available since
248.Ox 2.4 .
249.Pp
250.Fn X509_CRL_get_lastUpdate
251and
252.Fn X509_CRL_get_nextUpdate
253first appeared in OpenSSL 0.9.2 and have been available since
254.Ox 2.6 .
255.Pp
256.Fn X509_CRL_set_lastUpdate
257and
258.Fn X509_CRL_set_nextUpdate
259first appeared in OpenSSL 0.9.7 and have been available since
260.Ox 3.2 .
261.Pp
262The remaining functions first appeared in OpenSSL 1.1.0
263and have been available since
264.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/X509_get0_signature.3 b/src/lib/libcrypto/man/X509_get0_signature.3
deleted file mode 100644
index dc3be2c70a..0000000000
--- a/src/lib/libcrypto/man/X509_get0_signature.3
+++ /dev/null
@@ -1,280 +0,0 @@
1.\" $OpenBSD: X509_get0_signature.3,v 1.9 2024/08/28 07:18:55 tb Exp $
2.\" selective merge up to:
3.\" OpenSSL man3/X509_get0_signature 2f7a2520 Apr 25 17:28:08 2017 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: August 28 2024 $
70.Dt X509_GET0_SIGNATURE 3
71.Os
72.Sh NAME
73.Nm X509_get0_signature ,
74.Nm X509_REQ_get0_signature ,
75.Nm X509_CRL_get0_signature ,
76.Nm X509_get0_tbs_sigalg ,
77.Nm X509_CRL_get0_tbs_sigalg ,
78.Nm X509_get_signature_type ,
79.Nm X509_get_signature_nid ,
80.Nm X509_REQ_get_signature_nid ,
81.Nm X509_CRL_get_signature_nid ,
82.Nm X509_get_signature_info
83.Nd signature information
84.Sh SYNOPSIS
85.In openssl/x509.h
86.Ft void
87.Fo X509_get0_signature
88.Fa "const ASN1_BIT_STRING **psig"
89.Fa "const X509_ALGOR **palg"
90.Fa "const X509 *x"
91.Fc
92.Ft void
93.Fo X509_REQ_get0_signature
94.Fa "const X509_REQ *req"
95.Fa "const ASN1_BIT_STRING **psig"
96.Fa "const X509_ALGOR **palg"
97.Fc
98.Ft void
99.Fo X509_CRL_get0_signature
100.Fa "const X509_CRL *crl"
101.Fa "const ASN1_BIT_STRING **psig"
102.Fa "const X509_ALGOR **palg"
103.Fc
104.Ft const X509_ALGOR *
105.Fo X509_get0_tbs_sigalg
106.Fa "const X509 *x"
107.Fc
108.Ft const X509_ALGOR *
109.Fo X509_CRL_get0_tbs_sigalg
110.Fa "const X509_CRL *crl"
111.Fc
112.Ft int
113.Fo X509_get_signature_type
114.Fa "const X509 *x"
115.Fc
116.Ft int
117.Fo X509_get_signature_nid
118.Fa "const X509 *x"
119.Fc
120.Ft int
121.Fo X509_REQ_get_signature_nid
122.Fa "const X509_REQ *req"
123.Fc
124.Ft int
125.Fo X509_CRL_get_signature_nid
126.Fa "const X509_CRL *crl"
127.Fc
128.Ft int
129.Fo X509_get_signature_info
130.Fa "X509 *x"
131.Fa "int *md_nid"
132.Fa "int *pkey_nid"
133.Fa "int *security_bits"
134.Fa "uint32_t *flags"
135.Fc
136.Sh DESCRIPTION
137.Fn X509_get0_signature ,
138.Fn X509_REQ_get0_signature ,
139and
140.Fn X509_CRL_get0_signature
141set
142.Pf * Fa psig
143to the signature and
144.Pf * Fa palg
145to the signature algorithm of
146.Fa x ,
147.Fa req ,
148or
149.Fa crl ,
150respectively.
151.Fn X509_get0_tbs_sigalg
152and
153.Fn X509_CRL_get0_tbs_sigalg
154return the signature algorithm in the signed portion of
155.Fa x
156or
157.Fa crl ,
158respectively.
159The values returned are internal pointers
160that must not be freed by the caller.
161.Pp
162.Fn X509_get_signature_type
163returns the base NID corresponding to the signature algorithm of
164.Fa x
165just like
166.Xr EVP_PKEY_base_id 3
167does.
168.Pp
169.Fn X509_get_signature_nid ,
170.Fn X509_REQ_get_signature_nid ,
171and
172.Fn X509_CRL_get_signature_nid
173return the NID corresponding to the signature algorithm of
174.Fa x ,
175.Fa req ,
176or
177.Fa crl ,
178respectively, just like
179.Xr EVP_PKEY_id 3
180does.
181.Pp
182.Fn X509_get_signature_info
183retrieves information about the signature of certificate
184.Fa x .
185The NID of the digest algorithm is written to
186.Pf * Fa md_nid ,
187the public key algorithm to
188.Pf * Fa pkey_nid ,
189the effective security bits to
190.Pf * Fa security_bits ,
191and flag details to
192.Pf * Fa flags .
193Any of the output parameters can be set to
194.Dv NULL
195if the information is not required.
196If
197.Fa flags
198is not a
199.Dv NULL
200pointer,
201.Pf * Fa flags
202is set to the bitwise OR of:
203.Bl -tag -width 1n -offset 3n
204.It Dv X509_SIG_INFO_VALID
205No error occurred.
206This flag is set if
207.Fn X509_get_signature_info
208returns 1.
209.It Dv X509_SIG_INFO_TLS
210The signature algorithm is appropriate for use in TLS.
211For a supported EdDSA algorithm (in LibreSSL this is Ed25519)
212this flag is always set.
213For an RSASSA-PSS PSS algorithm this flag is set if
214the parameters are DER encoded,
215the digest algorithm is one of SHA256, SHA384, or SHA512,
216the same digest algorithm is used in the mask generation function,
217and the salt length is equal to the digest algorithm's output length.
218For all other signature algorithms this flag is set if the digest
219algorithm is one of SHA1, SHA256, SHA384, or SHA512.
220.El
221.Pp
222.Fn X509_get_signature_info
223returns 1 on success and 0 on failure.
224Failure conditions include unsupported signature algorithms,
225certificate parsing errors and memory allocation failure.
226.Pp
227These functions provide lower level access to the signature
228for cases where an application wishes to analyse or generate a
229signature in a form where
230.Xr X509_sign 3
231is not appropriate, for example in a non-standard or unsupported format.
232.Sh SEE ALSO
233.Xr EVP_PKEY_base_id 3 ,
234.Xr OBJ_obj2nid 3 ,
235.Xr X509_ALGOR_new 3 ,
236.Xr X509_CRL_get0_by_serial 3 ,
237.Xr X509_CRL_new 3 ,
238.Xr X509_get_pubkey 3 ,
239.Xr X509_get_subject_name 3 ,
240.Xr X509_get_version 3 ,
241.Xr X509_new 3 ,
242.Xr X509_REQ_new 3 ,
243.Xr X509_sign 3 ,
244.Xr X509_signature_dump 3 ,
245.Xr X509_verify_cert 3
246.Sh HISTORY
247.Fn X509_get_signature_type
248first appeared in SSLeay 0.8.0 and has been available since
249.Ox 2.4 .
250.Pp
251.Fn X509_get0_signature
252and
253.Fn X509_get_signature_nid
254first appeared in OpenSSL 1.0.2.
255.Fn X509_REQ_get0_signature ,
256.Fn X509_CRL_get0_signature ,
257.Fn X509_get0_tbs_sigalg ,
258.Fn X509_REQ_get_signature_nid ,
259and
260.Fn X509_CRL_get_signature_nid
261first appeared in OpenSSL 1.1.0.
262All these functions have been available since
263.Ox 6.3 .
264.Pp
265.Fn X509_CRL_get0_tbs_sigalg
266first appeared in LibreSSL 3.7.1 and has been available since
267.Ox 7.3 .
268.Pp
269.Fn X509_get_signature_info
270first appeared in OpenSSL 1.1.1 and has been available since
271.Ox 7.6 .
272.Sh CAVEATS
273The security bits returned by
274.Fn X509_get_signature_info
275refer to the information available from the certificate signature
276(such as the signing digest).
277In some cases the actual security of the signature is smaller
278because the signing key is less secure.
279For example in a certificate signed using SHA512
280and a 1024-bit RSA key.
diff --git a/src/lib/libcrypto/man/X509_get1_email.3 b/src/lib/libcrypto/man/X509_get1_email.3
deleted file mode 100644
index c38a604899..0000000000
--- a/src/lib/libcrypto/man/X509_get1_email.3
+++ /dev/null
@@ -1,123 +0,0 @@
1.\" $OpenBSD: X509_get1_email.3,v 1.1 2019/08/23 12:23:39 schwarze Exp $
2.\"
3.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: August 23 2019 $
18.Dt X509_GET1_EMAIL 3
19.Os
20.Sh NAME
21.Nm X509_get1_email ,
22.Nm X509_get1_ocsp ,
23.Nm X509_email_free
24.Nd utilities for stacks of strings
25.Sh SYNOPSIS
26.In openssl/x509v3.h
27.Vt typedef char *OPENSSL_STRING ;
28.Ft STACK_OF(OPENSSL_STRING) *
29.Fo X509_get1_email
30.Fa "X509 *certificate"
31.Fc
32.Ft STACK_OF(OPENSSL_STRING) *
33.Fo X509_get1_ocsp
34.Fa "X509 *certificate"
35.Fc
36.Ft void
37.Fo X509_email_free
38.Fa "STACK_OF(OPENSSL_STRING) *stack"
39.Fc
40.Sh DESCRIPTION
41.Fn X509_get1_email
42retrieves all email addresses from the
43.Fa subject
44field and from any
45Subject Alternative Name extension of the
46.Fa certificate .
47.Pp
48.Fn X509_get1_ocsp
49retrieves all uniform resource identifiers
50from all
51.Vt AccessDescription
52objects having an
53.Fa accessMethod
54of OCSP which are contained in the Authority Information Access extension
55of the
56.Fa certificate .
57.Pp
58.Fn X509_email_free
59frees all strings stored in the
60.Fa stack
61as well as the stack itself.
62If
63.Fa stack
64is a
65.Dv NULL
66pointer, no action occurs.
67.Sh RETURN VALUES
68.Fn X509_REQ_get1_email
69and
70.Fn X509_get1_ocsp
71return newly allocated stacks of
72.Vt char *
73containing copies of the addresses in question, or
74.Dv NULL
75if there are no addresses or if an error occurs.
76.Sh SEE ALSO
77.Xr OCSP_sendreq_new 3 ,
78.Xr OCSP_SERVICELOC_new 3 ,
79.Xr OPENSSL_sk_new 3 ,
80.Xr STACK_OF 3 ,
81.Xr X509_check_email 3 ,
82.Xr X509_get_ext_d2i 3 ,
83.Xr X509_get_subject_name 3 ,
84.Xr X509_new 3 ,
85.Xr x509v3.cnf 5
86.Sh STANDARDS
87RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
88Certificate Revocation List (CRL) Profile
89.Bl -dash -offset indent -compact
90.It
91section 4.1: Basic Certificate Fields
92.It
93section 4.1.2.6: Subject
94.It
95section 4.2.1.6: Subject Alternative Name
96.It
97section 4.2.2.1: Authority Information Access
98.El
99.Pp
100RFC 2985: PKCS #9: Selected Object Classes and Attribute Types
101.Bl -dash -offset indent -compact
102.It
103section 5.2.1: Electronic-mail address
104.It
105appendix B.3.5: emailAddress
106.El
107.Sh HISTORY
108.Fn X509_get1_email
109and
110.Fn X509_email_free
111first appeared in OpenSSL 0.9.6 and have been available since
112.Ox 2.9 .
113.Pp
114.Fn X509_get1_ocsp
115first appeared in OpenSSL 0.9.8h and has been available since
116.Ox 4.5 .
117.Sh BUGS
118.Fn X509_email_free
119is utterly misnamed.
120It does not operate on any
121.Vt X509
122object, nor is it in any way restricted to email addresses;
123instead, it simply frees a stack of strings.
diff --git a/src/lib/libcrypto/man/X509_get_extension_flags.3 b/src/lib/libcrypto/man/X509_get_extension_flags.3
deleted file mode 100644
index 1d7f29c687..0000000000
--- a/src/lib/libcrypto/man/X509_get_extension_flags.3
+++ /dev/null
@@ -1,234 +0,0 @@
1.\" $OpenBSD: X509_get_extension_flags.3,v 1.4 2023/04/30 19:40:23 tb Exp $
2.\" full merge up to: OpenSSL 361136f4 Sep 1 18:56:58 2015 +0100
3.\" selective merge up to: OpenSSL 2b2e3106f Feb 16 15:04:45 2021 +0000
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: April 30 2023 $
53.Dt X509_GET_EXTENSION_FLAGS 3
54.Os
55.Sh NAME
56.Nm X509_get_extension_flags ,
57.Nm X509_get_key_usage ,
58.Nm X509_get_extended_key_usage
59.Nd retrieve certificate extension data
60.Sh SYNOPSIS
61.In openssl/x509v3.h
62.Ft uint32_t
63.Fo X509_get_extension_flags
64.Fa "X509 *x"
65.Fc
66.Ft uint32_t
67.Fo X509_get_key_usage
68.Fa "X509 *x"
69.Fc
70.Ft uint32_t
71.Fo X509_get_extended_key_usage
72.Fa "X509 *x"
73.Fc
74.Sh DESCRIPTION
75These functions retrieve information related to commonly used
76certificate extensions.
77.Pp
78.Fn X509_get_extension_flags
79retrieves general information about a certificate.
80It returns one or more of the following flags OR'ed together.
81.Bl -tag -width Ds
82.It Dv EXFLAG_V1
83The certificate is an obsolete version 1 certificate.
84.It Dv EXFLAG_BCONS
85The certificate contains a basic constraints extension.
86.It Dv EXFLAG_CA
87The certificate contains basic constraints and asserts the CA flag.
88.It Dv EXFLAG_PROXY
89The certificate is a valid proxy certificate.
90In LibreSSL this flag is never set.
91.It Dv EXFLAG_SI
92The certificate is self issued (that is subject and issuer names match).
93.It Dv EXFLAG_SS
94The subject and issuer names match and extension values imply it is self
95signed.
96.It Dv EXFLAG_FRESHEST
97The freshest CRL extension is present in the certificate.
98.It Dv EXFLAG_CRITICAL
99The certificate contains an unhandled critical extension.
100.It Dv EXFLAG_INVALID
101Some certificate extension values are invalid or inconsistent.
102The certificate should be rejected.
103This bit may also be raised after an out-of-memory error while
104processing the X509 object, so it may not be related to the processed
105ASN1 object itself.
106.\" EXFLAG_NO_FINGERPRINT is not available in LibreSSL. Do we need
107.\" https://github.com/openssl/openssl/issues/13698 and the fix it fixes?
108.\".It Dv EXFLAG_NO_FINGERPRINT
109.\" Failed to compute the internal SHA1 hash value of the certificate.
110.\" This may be due to malloc failure or because no SHA1 implementation was
111.\" found.
112.It Dv EXFLAG_INVALID_POLICY
113The
114.Dv NID_certificate_policies
115certificate extension is invalid or inconsistent.
116The certificate should be rejected.
117This bit may also be raised after an out-of-memory error while
118processing the X509 object, so it may not be related to the processed
119ASN1 object itself.
120.It Dv EXFLAG_KUSAGE
121The certificate contains a key usage extension.
122The value can be retrieved using
123.Fn X509_get_key_usage .
124.It Dv EXFLAG_XKUSAGE
125The certificate contains an extended key usage extension.
126The value can be retrieved using
127.Fn X509_get_extended_key_usage .
128.El
129.Pp
130.Fn X509_get_key_usage
131returns the value of the key usage extension.
132If key usage is present, it returns zero or more of these flags:
133.Dv KU_DIGITAL_SIGNATURE ,
134.Dv KU_NON_REPUDIATION ,
135.Dv KU_KEY_ENCIPHERMENT ,
136.Dv KU_DATA_ENCIPHERMENT ,
137.Dv KU_KEY_AGREEMENT ,
138.Dv KU_KEY_CERT_SIGN ,
139.Dv KU_CRL_SIGN ,
140.Dv KU_ENCIPHER_ONLY ,
141or
142.Dv KU_DECIPHER_ONLY ,
143corresponding to individual key usage bits.
144If key usage is absent,
145.Dv UINT32_MAX
146is returned.
147.Pp
148The following aliases for these flags are defined in
149.In openssl/x509.h :
150.Dv X509v3_KU_DIGITAL_SIGNATURE ,
151.Dv X509v3_KU_NON_REPUDIATION ,
152.Dv X509v3_KU_KEY_ENCIPHERMENT ,
153.Dv X509v3_KU_DATA_ENCIPHERMENT ,
154.Dv X509v3_KU_KEY_AGREEMENT ,
155.Dv X509v3_KU_KEY_CERT_SIGN ,
156.Dv X509v3_KU_CRL_SIGN ,
157.Dv X509v3_KU_ENCIPHER_ONLY ,
158and
159.Dv X509v3_KU_DECIPHER_ONLY .
160.\" X509v3_KU_UNDEF is intentionally undocumented because nothing uses it.
161.Pp
162.Fn X509_get_extended_key_usage
163returns the value of the extended key usage extension.
164If extended key usage is present, it returns zero or more of these
165flags:
166.Dv XKU_SSL_SERVER ,
167.Dv XKU_SSL_CLIENT ,
168.Dv XKU_SMIME ,
169.Dv XKU_CODE_SIGN
170.Dv XKU_OCSP_SIGN ,
171.Dv XKU_TIMESTAMP ,
172.Dv XKU_DVCS ,
173or
174.Dv XKU_ANYEKU .
175These correspond to the OIDs
176.Qq id-kp-serverAuth ,
177.Qq id-kp-clientAuth ,
178.Qq id-kp-emailProtection ,
179.Qq id-kp-codeSigning ,
180.Qq id-kp-OCSPSigning ,
181.Qq id-kp-timeStamping ,
182.Qq id-kp-dvcs ,
183and
184.Qq anyExtendedKeyUsage ,
185respectively.
186Additionally,
187.Dv XKU_SGC
188is set if either Netscape or Microsoft SGC OIDs are present.
189.Pp
190The value of the flags correspond to extension values which are cached
191in the
192.Vt X509
193structure.
194If the flags returned do not provide sufficient information,
195an application should examine extension values directly,
196for example using
197.Xr X509_get_ext_d2i 3 .
198.Pp
199If the key usage or extended key usage extension is absent then
200typically usage is unrestricted.
201For this reason
202.Fn X509_get_key_usage
203and
204.Fn X509_get_extended_key_usage
205return
206.Dv UINT32_MAX
207when the corresponding extension is absent.
208Applications can additionally check the return value of
209.Fn X509_get_extension_flags
210and take appropriate action if an extension is absent.
211.Sh RETURN VALUES
212.Fn X509_get_extension_flags ,
213.Fn X509_get_key_usage
214and
215.Fn X509_get_extended_key_usage
216return sets of flags corresponding to the certificate extension values.
217.Sh SEE ALSO
218.Xr BASIC_CONSTRAINTS_new 3 ,
219.Xr EXTENDED_KEY_USAGE_new 3 ,
220.Xr POLICYINFO_new 3 ,
221.Xr X509_check_ca 3 ,
222.Xr X509_check_purpose 3 ,
223.Xr X509_EXTENSION_new 3 ,
224.Xr X509_get_ext_d2i 3 ,
225.Xr X509_get_subject_name 3 ,
226.Xr X509_get_version 3 ,
227.Xr X509_new 3
228.Sh HISTORY
229.Nm X509_get_extension_flags ,
230.Nm X509_get_key_usage ,
231and
232.Nm X509_get_extended_key_usage
233first appeared in OpenSSL 1.1.0 and have been available since
234.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/X509_get_pubkey.3 b/src/lib/libcrypto/man/X509_get_pubkey.3
deleted file mode 100644
index 0829397982..0000000000
--- a/src/lib/libcrypto/man/X509_get_pubkey.3
+++ /dev/null
@@ -1,296 +0,0 @@
1.\" $OpenBSD: X509_get_pubkey.3,v 1.13 2022/03/31 17:27:17 naddy Exp $
2.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2020, 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: March 31 2022 $
69.Dt X509_GET_PUBKEY 3
70.Os
71.Sh NAME
72.Nm X509_get_pubkey ,
73.Nm X509_get0_pubkey ,
74.Nm X509_set_pubkey ,
75.Nm X509_get_X509_PUBKEY ,
76.Nm X509_get0_pubkey_bitstr ,
77.Nm X509_REQ_get_pubkey ,
78.Nm X509_REQ_get0_pubkey ,
79.Nm X509_REQ_set_pubkey ,
80.Nm X509_extract_key ,
81.Nm X509_REQ_extract_key
82.Nd get or set certificate or certificate request public key
83.Sh SYNOPSIS
84.In openssl/x509.h
85.Ft EVP_PKEY *
86.Fo X509_get_pubkey
87.Fa "X509 *x"
88.Fc
89.Ft EVP_PKEY *
90.Fo X509_get0_pubkey
91.Fa "const X509 *x"
92.Fc
93.Ft int
94.Fo X509_set_pubkey
95.Fa "X509 *x"
96.Fa "EVP_PKEY *pkey"
97.Fc
98.Ft X509_PUBKEY *
99.Fo X509_get_X509_PUBKEY
100.Fa "const X509 *x"
101.Fc
102.Ft ASN1_BIT_STRING *
103.Fo X509_get0_pubkey_bitstr
104.Fa "const X509 *x"
105.Fc
106.Ft EVP_PKEY *
107.Fo X509_REQ_get_pubkey
108.Fa "X509_REQ *req"
109.Fc
110.Ft EVP_PKEY *
111.Fo X509_REQ_get0_pubkey
112.Fa "X509_REQ *req"
113.Fc
114.Ft int
115.Fo X509_REQ_set_pubkey
116.Fa "X509_REQ *x"
117.Fa "EVP_PKEY *pkey"
118.Fc
119.Ft EVP_PKEY *
120.Fo X509_extract_key
121.Fa "X509 *x"
122.Fc
123.Ft EVP_PKEY *
124.Fo X509_REQ_extract_key
125.Fa "X509_REQ *req"
126.Fc
127.Sh DESCRIPTION
128.Fn X509_get_pubkey
129attempts to decode the public key for certificate
130.Fa x .
131If successful, it returns the public key as an
132.Vt EVP_PKEY
133pointer with its reference count incremented: this means the returned
134key must be freed up after use.
135.Fn X509_get0_pubkey
136is similar except that it does not increment the reference count
137of the returned
138.Vt EVP_PKEY ,
139so it must not be freed up after use.
140.Pp
141.Fn X509_get_X509_PUBKEY
142returns an internal pointer to the
143.Vt SubjectPublicKeyInfo
144structure contained in
145.Fa x .
146The returned value must not be freed up after use.
147.Pp
148.Fn X509_get0_pubkey_bitstr
149returns an internal pointer to just the public key contained in this
150.Vt SubjectPublicKeyInfo
151structure, without the information about the algorithm used.
152.Pp
153.Fn X509_set_pubkey
154attempts to set the public key for certificate
155.Fa x
156to
157.Fa pkey .
158The key
159.Fa pkey
160should be freed up after use.
161.Pp
162.Fn X509_REQ_get_pubkey ,
163.Fn X509_REQ_get0_pubkey ,
164and
165.Fn X509_REQ_set_pubkey
166are similar but operate on certificate request
167.Fa req .
168.Pp
169The first time a public key is decoded, the
170.Vt EVP_PKEY
171structure is cached in the certificate or certificate request itself.
172Subsequent calls return the cached structure with its reference count
173incremented to improve performance.
174.Pp
175.Fn X509_extract_key
176and
177.Fn X509_REQ_extract_key
178are deprecated aliases for
179.Fn X509_get_pubkey
180and
181.Fn X509_REQ_get_pubkey ,
182respectively, implemented as macros.
183.Sh RETURN VALUES
184.Fn X509_get_pubkey ,
185.Fn X509_get0_pubkey ,
186.Fn X509_get_X509_PUBKEY ,
187.Fn X509_get0_pubkey_bitstr ,
188.Fn X509_REQ_get_pubkey ,
189.Fn X509_REQ_get0_pubkey ,
190.Fn X509_extract_key ,
191and
192.Fn X509_REQ_extract_key
193return a public key or
194.Dv NULL
195if an error occurred.
196.Pp
197.Fn X509_set_pubkey
198and
199.Fn X509_REQ_set_pubkey
200return 1 for success or 0 for failure.
201.Pp
202In some cases of failure of
203.Fn X509_get0_pubkey ,
204.Fn X509_set_pubkey ,
205.Fn X509_REQ_get_pubkey ,
206.Fn X509_REQ_get0_pubkey ,
207and
208.Fn X509_REQ_set_pubkey ,
209the reason can be determined with
210.Xr ERR_get_error 3 .
211.Sh ERRORS
212.Fn X509_get_pubkey ,
213.Fn X509_get0_pubkey ,
214.Fn X509_REQ_get_pubkey ,
215.Fn X509_extract_key ,
216and
217.Fn X509_REQ_extract_key
218provide diagnostics as documented for
219.Xr X509_PUBKEY_get 3 .
220If
221.Fa x
222or
223.Fa req
224is
225.Dv NULL
226or contains no certificate information,
227they fail without pushing an error onto the stack.
228.Pp
229.Fn X509_get_X509_PUBKEY
230provides no diagnostics and crashes by accessing a
231.Dv NULL
232pointer if
233.Fa x
234is
235.Dv NULL
236or contains no certificate information,
237.Pp
238.Fn X509_get0_pubkey_bitstr
239provides no diagnostics
240and fails without pushing an error onto the stack if
241.Fa x
242is
243.Dv NULL ,
244but it crashes by accessing a
245.Dv NULL
246pointer if
247.Fa x
248contains no certificate information.
249.Sh SEE ALSO
250.Xr d2i_X509 3 ,
251.Xr X509_CRL_get0_by_serial 3 ,
252.Xr X509_NAME_add_entry_by_txt 3 ,
253.Xr X509_NAME_ENTRY_get_object 3 ,
254.Xr X509_NAME_get_index_by_NID 3 ,
255.Xr X509_NAME_print_ex 3 ,
256.Xr X509_new 3 ,
257.Xr X509_PUBKEY_new 3 ,
258.Xr X509_REQ_new 3 ,
259.Xr X509_sign 3 ,
260.Xr X509_verify_cert 3 ,
261.Xr X509V3_get_d2i 3
262.Sh STANDARDS
263RFC 5280, Internet X.509 Public Key Infrastructure Certificate
264and Certificate Revocation List (CRL) Profile,
265section 4.1 Basic Certificate Fields
266.Pp
267RFC 2986: PKCS #10: Certification Request Syntax Specification,
268section 4.1 CertificationRequestInfo
269.Sh HISTORY
270.Fn X509_extract_key
271and
272.Fn X509_REQ_extract_key
273first appeared in SSLeay 0.5.1 but returned a pointer to an
274.Vt RSA
275object before SSLeay 0.6.0.
276.Fn X509_get_pubkey ,
277.Fn X509_set_pubkey ,
278.Fn X509_REQ_get_pubkey ,
279and
280.Fn X509_REQ_set_pubkey
281first appeared in SSLeay 0.6.5.
282.Fn X509_get_X509_PUBKEY
283first appeared in SSLeay 0.8.0.
284These functions have been available since
285.Ox 2.4 .
286.Pp
287.Fn X509_get0_pubkey_bitstr
288first appeared in OpenSSL 0.9.7 and has been available since
289.Ox 3.4 .
290.Pp
291.Fn X509_get0_pubkey
292first appeared in OpenSSL 1.1.0 and has been available since
293.Ox 6.3 .
294.Fn X509_REQ_get0_pubkey
295first appeared in OpenSSL 1.1.0 and has been available since
296.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/X509_get_pubkey_parameters.3 b/src/lib/libcrypto/man/X509_get_pubkey_parameters.3
deleted file mode 100644
index 181361477e..0000000000
--- a/src/lib/libcrypto/man/X509_get_pubkey_parameters.3
+++ /dev/null
@@ -1,99 +0,0 @@
1.\" $OpenBSD: X509_get_pubkey_parameters.3,v 1.2 2021/11/26 13:35:10 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 26 2021 $
18.Dt X509_GET_PUBKEY_PARAMETERS 3
19.Os
20.Sh NAME
21.Nm X509_get_pubkey_parameters
22.Nd copy public key parameters from a chain
23.Sh SYNOPSIS
24.In openssl/x509.h
25.Ft int
26.Fo X509_get_pubkey_parameters
27.Fa "EVP_PKEY *pkey"
28.Fa "STACK_OF(X509) *chain"
29.Fc
30.Sh DESCRIPTION
31.Fn X509_get_pubkey_parameters
32copies public key parameters from the first appropriate certificate in the
33.Fa chain .
34.Pp
35If
36.Fa pkey
37is not
38.Dv NULL
39and already contains complete public key parameters or uses an
40algorithm that does not use any parameters, no action occurs and
41the function indicates success without inspecting the existing
42parameters, without inspecting the
43.Fa chain ,
44and without comparing any parameters.
45.Pp
46Otherwise, all public key parameters are copied
47from the first certificate in the
48.Fa chain
49that contains complete public key parameters
50to each certificate preceding it in the
51.Fa chain .
52Unless
53.Fa pkey
54is a
55.Dv NULL
56pointer, the same parameters are also copied to
57.Fa pkey .
58.Sh RETURN VALUES
59.Fn X509_get_pubkey_parameters
60returns 1 for success or 0 for failure.
61.Sh ERRORS
62The following diagnostics can be retrieved with
63.Xr ERR_get_error 3 ,
64.Xr ERR_GET_REASON 3 ,
65and
66.Xr ERR_reason_error_string 3 :
67.Bl -tag -width Ds
68.It Dv X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY Qq unable to get certs public key
69Retrieving the public key from a certificate in the
70.Fa chain
71failed before a certificate containing complete public key parameters
72could be found.
73.It Xo
74.Dv X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN
75.Qq unable to find parameters in chain
76.Xc
77None of the certificates in the chain
78contain complete public key parameters.
79.El
80.Sh SEE ALSO
81.Xr EVP_PKEY_copy_parameters 3 ,
82.Xr EVP_PKEY_new 3 ,
83.Xr X509_get_pubkey 3 ,
84.Xr X509_new 3
85.Sh HISTORY
86.Fn X509_get_pubkey_parameters
87first appeared in SSLeay 0.8.0 and has been available since
88.Ox 2.4 .
89.Sh CAVEATS
90If
91.Fn X509_get_pubkey_parameters
92fails and returns 0, a part of the parameters may or may not have
93been copied before the failure was detected, whereas other parts of
94.Fa pkey
95and
96.Fa chain
97may remain unchanged.
98So in case of failure, the state of the arguments may change
99and possibly become inconsistent.
diff --git a/src/lib/libcrypto/man/X509_get_serialNumber.3 b/src/lib/libcrypto/man/X509_get_serialNumber.3
deleted file mode 100644
index 7d757c7a71..0000000000
--- a/src/lib/libcrypto/man/X509_get_serialNumber.3
+++ /dev/null
@@ -1,129 +0,0 @@
1.\" $OpenBSD: X509_get_serialNumber.3,v 1.5 2020/06/19 12:01:20 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 19 2020 $
52.Dt X509_GET_SERIALNUMBER 3
53.Os
54.Sh NAME
55.Nm X509_get_serialNumber ,
56.Nm X509_get0_serialNumber ,
57.Nm X509_set_serialNumber
58.Nd get or set certificate serial number
59.Sh SYNOPSIS
60.In openssl/x509.h
61.Ft ASN1_INTEGER *
62.Fo X509_get_serialNumber
63.Fa "X509 *x"
64.Fc
65.Ft const ASN1_INTEGER *
66.Fo X509_get0_serialNumber
67.Fa "const X509 *x"
68.Fc
69.Ft int
70.Fo X509_set_serialNumber
71.Fa "X509 *x"
72.Fa "ASN1_INTEGER *serial"
73.Fc
74.Sh DESCRIPTION
75.Fn X509_get_serialNumber
76returns the serial number of certificate
77.Fa x
78as an
79.Vt ASN1_INTEGER
80structure which can be examined or initialised.
81The value returned is an internal pointer which must not be freed
82up after the call.
83.Pp
84.Fn X509_get0_serialNumber
85does the same except that it accepts a constant argument
86and returns a constant result.
87.Pp
88.Fn X509_set_serialNumber
89sets the serial number of certificate
90.Fa x
91to
92.Fa serial .
93A copy of the serial number is used internally so
94.Fa serial
95should be freed up after use.
96.Sh RETURN VALUES
97.Fn X509_get_serialNumber
98and
99.Fn X509_get0_serialNumber
100return a pointer to an
101.Vt ASN1_INTEGER
102structure.
103.Pp
104.Fn X509_set_serialNumber
105returns 1 for success or 0 for failure.
106In some cases of failure, the reason can be determined with
107.Xr ERR_get_error 3 .
108.Sh SEE ALSO
109.Xr d2i_X509 3 ,
110.Xr X509_CRL_get0_by_serial 3 ,
111.Xr X509_get_pubkey 3 ,
112.Xr X509_NAME_add_entry_by_txt 3 ,
113.Xr X509_NAME_ENTRY_get_object 3 ,
114.Xr X509_NAME_get_index_by_NID 3 ,
115.Xr X509_NAME_print_ex 3 ,
116.Xr X509_new 3 ,
117.Xr X509_sign 3 ,
118.Xr X509_verify_cert 3 ,
119.Xr X509V3_get_d2i 3
120.Sh HISTORY
121.Fn X509_get_serialNumber
122and
123.Fn X509_set_serialNumber
124first appeared in SSLeay 0.6.5 and have been available since
125.Ox 2.4 .
126.Pp
127.Fn X509_get0_serialNumber
128first appeared in OpenSSL 1.1.0 and has been available since
129.Ox 6.4 .
diff --git a/src/lib/libcrypto/man/X509_get_subject_name.3 b/src/lib/libcrypto/man/X509_get_subject_name.3
deleted file mode 100644
index fb9611f645..0000000000
--- a/src/lib/libcrypto/man/X509_get_subject_name.3
+++ /dev/null
@@ -1,189 +0,0 @@
1.\" $OpenBSD: X509_get_subject_name.3,v 1.10 2020/10/21 17:17:44 tb Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: October 21 2020 $
52.Dt X509_GET_SUBJECT_NAME 3
53.Os
54.Sh NAME
55.Nm X509_get_subject_name ,
56.Nm X509_set_subject_name ,
57.Nm X509_get_issuer_name ,
58.Nm X509_set_issuer_name ,
59.Nm X509_REQ_get_subject_name ,
60.Nm X509_REQ_set_subject_name ,
61.Nm X509_CRL_get_issuer ,
62.Nm X509_CRL_set_issuer_name
63.Nd get and set issuer or subject names
64.Sh SYNOPSIS
65.In openssl/x509.h
66.Ft X509_NAME *
67.Fo X509_get_subject_name
68.Fa "const X509 *x"
69.Fc
70.Ft int
71.Fo X509_set_subject_name
72.Fa "X509 *x"
73.Fa "X509_NAME *name"
74.Fc
75.Ft X509_NAME *
76.Fo X509_get_issuer_name
77.Fa "const X509 *x"
78.Fc
79.Ft int
80.Fo X509_set_issuer_name
81.Fa "X509 *x"
82.Fa "X509_NAME *name"
83.Fc
84.Ft X509_NAME *
85.Fo X509_REQ_get_subject_name
86.Fa "const X509_REQ *req"
87.Fc
88.Ft int
89.Fo X509_REQ_set_subject_name
90.Fa "X509_REQ *req"
91.Fa "X509_NAME *name"
92.Fc
93.Ft X509_NAME *
94.Fo X509_CRL_get_issuer
95.Fa "const X509_CRL *crl"
96.Fc
97.Ft int
98.Fo X509_CRL_set_issuer_name
99.Fa "X509_CRL *x"
100.Fa "X509_NAME *name"
101.Fc
102.Sh DESCRIPTION
103.Fn X509_get_subject_name
104returns the subject name of certificate
105.Fa x .
106The returned value is an internal pointer which must not be freed.
107.Pp
108.Fn X509_set_subject_name
109sets the issuer name of certificate
110.Fa x
111to
112.Fa name .
113The
114.Fa name
115parameter is copied internally and should be freed up when it is no
116longer needed.
117.Pp
118.Fn X509_get_issuer_name
119and
120.Fn X509_set_issuer_name
121are identical to
122.Fn X509_get_subject_name
123and
124.Fn X509_set_subject_name
125except that they get and set the issuer name of
126.Fa x .
127.Pp
128Similarly
129.Fn X509_REQ_get_subject_name ,
130.Fn X509_REQ_set_subject_name ,
131.Fn X509_CRL_get_issuer ,
132and
133.Fn X509_CRL_set_issuer_name
134get or set the subject or issuer names of certificate requests
135of CRLs, respectively.
136.Sh RETURN VALUES
137.Fn X509_get_subject_name ,
138.Fn X509_get_issuer_name ,
139.Fn X509_REQ_get_subject_name ,
140and
141.Fn X509_CRL_get_issuer
142return a pointer to an
143.Vt X509_NAME
144object.
145.Pp
146.Fn X509_set_subject_name ,
147.Fn X509_set_issuer_name ,
148.Fn X509_REQ_set_subject_name ,
149and
150.Fn X509_CRL_set_issuer_name
151return 1 for success or 0 for failure.
152In some cases of failure, the reason can be determined with
153.Xr ERR_get_error 3 .
154.Sh SEE ALSO
155.Xr d2i_X509_NAME 3 ,
156.Xr X509_CRL_get0_by_serial 3 ,
157.Xr X509_CRL_new 3 ,
158.Xr X509_get_pubkey 3 ,
159.Xr X509_NAME_add_entry_by_txt 3 ,
160.Xr X509_NAME_ENTRY_get_object 3 ,
161.Xr X509_NAME_get_index_by_NID 3 ,
162.Xr X509_NAME_new 3 ,
163.Xr X509_NAME_print_ex 3 ,
164.Xr X509_new 3 ,
165.Xr X509_REQ_new 3 ,
166.Xr X509_sign 3 ,
167.Xr X509_verify_cert 3 ,
168.Xr X509V3_get_d2i 3
169.Sh HISTORY
170.Fn X509_get_subject_name
171and
172.Fn X509_get_issuer_name
173appeared in SSLeay 0.4 or earlier.
174.Fn X509_set_subject_name ,
175.Fn X509_set_issuer_name ,
176.Fn X509_REQ_get_subject_name ,
177and
178.Fn X509_REQ_set_subject_name
179first appeared in SSLeay 0.6.5.
180These functions have been available since
181.Ox 2.4 .
182.Pp
183.Fn X509_CRL_get_issuer
184first appeared in OpenSSL 0.9.2b and has been available since
185.Ox 2.6 .
186.Pp
187.Fn X509_CRL_set_issuer_name
188first appeared in OpenSSL 0.9.7 and has been available since
189.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/X509_get_version.3 b/src/lib/libcrypto/man/X509_get_version.3
deleted file mode 100644
index ee46ff7c8c..0000000000
--- a/src/lib/libcrypto/man/X509_get_version.3
+++ /dev/null
@@ -1,162 +0,0 @@
1.\" $OpenBSD: X509_get_version.3,v 1.8 2020/10/21 17:17:44 tb Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2015, 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: October 21 2020 $
52.Dt X509_GET_VERSION 3
53.Os
54.Sh NAME
55.Nm X509_get_version ,
56.Nm X509_set_version ,
57.Nm X509_REQ_get_version ,
58.Nm X509_REQ_set_version ,
59.Nm X509_CRL_get_version ,
60.Nm X509_CRL_set_version
61.Nd get or set certificate, certificate request, or CRL version
62.Sh SYNOPSIS
63.In openssl/x509.h
64.Ft long
65.Fo X509_get_version
66.Fa "const X509 *x"
67.Fc
68.Ft int
69.Fo X509_set_version
70.Fa "X509 *x"
71.Fa "long version"
72.Fc
73.Ft long
74.Fo X509_REQ_get_version
75.Fa "const X509_REQ *req"
76.Fc
77.Ft int
78.Fo X509_REQ_set_version
79.Fa "X509_REQ *x"
80.Fa "long version"
81.Fc
82.Ft long
83.Fo X509_CRL_get_version
84.Fa "const X509_CRL *crl"
85.Fc
86.Ft int
87.Fo X509_CRL_set_version
88.Fa "X509_CRL *x"
89.Fa "long version"
90.Fc
91.Sh DESCRIPTION
92.Fn X509_get_version
93returns the numerical value of the version field of certificate
94.Fa x .
95Note: this is defined by standards (X.509 et al.) to be one less
96than the certificate version.
97So a version 3 certificate will return 2 and a version 1 certificate
98will return 0.
99.Pp
100.Fn X509_set_version
101sets the numerical value of the version field of certificate
102.Fa x
103to
104.Fa version .
105.Pp
106Similarly
107.Fn X509_REQ_get_version ,
108.Fn X509_REQ_set_version ,
109.Fn X509_CRL_get_version ,
110and
111.Fn X509_CRL_set_version
112get and set the version number of certificate requests and CRLs.
113.Pp
114The version field of certificates, certificate requests, and CRLs
115has a DEFAULT value of v1(0) meaning the field should be omitted
116for version 1.
117This is handled transparently by these functions.
118.Sh RETURN VALUES
119.Fn X509_get_version ,
120.Fn X509_REQ_get_version ,
121and
122.Fn X509_CRL_get_version
123return the numerical value of the version field.
124.Pp
125.Fn X509_set_version ,
126.Fn X509_REQ_set_version ,
127and
128.Fn X509_CRL_set_version
129return 1 for success or 0 for failure.
130In some cases of failure, the reason can be determined with
131.Xr ERR_get_error 3 .
132.Sh SEE ALSO
133.Xr d2i_X509 3 ,
134.Xr X509_CRL_get0_by_serial 3 ,
135.Xr X509_CRL_new 3 ,
136.Xr X509_get_pubkey 3 ,
137.Xr X509_get_subject_name 3 ,
138.Xr X509_NAME_add_entry_by_txt 3 ,
139.Xr X509_NAME_ENTRY_get_object 3 ,
140.Xr X509_NAME_get_index_by_NID 3 ,
141.Xr X509_NAME_print_ex 3 ,
142.Xr X509_new 3 ,
143.Xr X509_REQ_new 3 ,
144.Xr X509_sign 3 ,
145.Xr X509_verify_cert 3 ,
146.Xr X509V3_get_d2i 3
147.Sh HISTORY
148.Fn X509_get_version ,
149.Fn X509_set_version ,
150.Fn X509_REQ_get_version ,
151and
152.Fn X509_REQ_set_version
153first appeared in SSLeay 0.6.5 and have been available since
154.Ox 2.4 .
155.Pp
156.Fn X509_CRL_get_version
157first appeared in OpenSSL 0.9.2b and has been available since
158.Ox 2.6 .
159.Pp
160.Fn X509_CRL_set_version
161first appeared in OpenSSL 0.9.7 and has been available since
162.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/X509_keyid_set1.3 b/src/lib/libcrypto/man/X509_keyid_set1.3
deleted file mode 100644
index c529fc742b..0000000000
--- a/src/lib/libcrypto/man/X509_keyid_set1.3
+++ /dev/null
@@ -1,171 +0,0 @@
1.\" $OpenBSD: X509_keyid_set1.3,v 1.2 2021/07/09 14:41:14 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 9 2021 $
18.Dt X509_KEYID_SET1 3
19.Os
20.Sh NAME
21.Nm X509_keyid_set1 ,
22.Nm X509_keyid_get0 ,
23.Nm X509_alias_set1 ,
24.Nm X509_alias_get0
25.Nd auxiliary certificate data for PKCS#12
26.Sh SYNOPSIS
27.In openssl/x509.h
28.Ft int
29.Fo X509_keyid_set1
30.Fa "X509 *x"
31.Fa "const unsigned char *data"
32.Fa "int len"
33.Fc
34.Ft unsigned char *
35.Fo X509_keyid_get0
36.Fa "X509 *x"
37.Fa "int *plen"
38.Fc
39.Ft int
40.Fo X509_alias_set1
41.Fa "X509 *x"
42.Fa "const unsigned char *data"
43.Fa "int len"
44.Fc
45.Ft unsigned char *
46.Fo X509_alias_get0
47.Fa "X509 *x"
48.Fa "int *plen"
49.Fc
50.Sh DESCRIPTION
51These functions store non-standard auxiliary data in
52.Fa x
53and retrieve it.
54.Pp
55The
56.Fa len
57bytes of
58.Fa data
59stored using
60.Fn X509_keyid_set1
61will be written to the
62.Sy localKeyID
63attribute of the PKCS#12 structure if
64.Xr PKCS12_create 3
65is later called on
66.Fa x ,
67and the
68.Fa data
69stored using
70.Fn X509_alias_set1
71will be written to the
72.Sy friendlyName
73attribute.
74If
75.Fa data
76points to a NUL-terminated string, \-1 can be passed as the
77.Fa len
78argument to let
79.Fa len
80be calculated internally using
81.Xr strlen 3 .
82If a
83.Dv NULL
84pointer is passed as the
85.Fa data
86argument, the respective auxiliary data stored in
87.Fa x ,
88if any, is removed from
89.Fa x
90and freed.
91.Pp
92Conversely,
93.Xr PKCS12_parse 3
94retrieves these attributes from a PKCS#12 structure such that they can
95subsequently be accessed with
96.Fn X509_keyid_get0
97and
98.Fn X509_alias_get0 .
99Unless
100.Dv NULL
101is passed for the
102.Fa plen
103argument, these functions store the size of the returned buffer in bytes in
104.Pf * Fa plen .
105After the call, the returned buffer is not necessarily NUL-terminated,
106but it may contain internal NUL bytes.
107.Pp
108API design is very incomplete; given the complexity of PKCS#12,
109that's probably an asset rather than a defect.
110The PKCS#12 standard defines many attributes that cannot be stored in
111.Vt X509
112objects.
113.Pp
114To associate certificates with alternative names and key identifiers,
115X.509 certificate extensions are more commonly used than PKCS#12
116attributes, for example using
117.Xr X509_EXTENSION_create_by_NID 3
118with
119.Dv NID_subject_alt_name
120or
121.Dv NID_subject_key_identifier .
122.Sh RETURN VALUES
123.Fn X509_keyid_set1
124and
125.Fn X509_alias_set1
126return 1 if
127.Fa data
128is
129.Dv NULL
130or if the input
131.Fa data
132was successfully copied into
133.Fa x ,
134or 0 if
135.Fa data
136is not
137.Dv NULL
138but could not be copied because
139.Fa x
140is
141.Dv NULL
142or memory allocation failed.
143.Pp
144.Fn X509_keyid_get0
145and
146.Fn X509_alias_get0
147return an internal pointer to an array of bytes or
148.Dv NULL
149if
150.Fa x
151does not contain auxiliary data of the requested kind.
152.Sh SEE ALSO
153.Xr ASN1_STRING_set 3 ,
154.Xr X509_CERT_AUX_new 3 ,
155.Xr X509_EXTENSION_new 3 ,
156.Xr X509_new 3 ,
157.Xr X509V3_get_d2i 3
158.Sh HISTORY
159.Fn X509_alias_set1
160and
161.Fn X509_alias_get0
162first appeared in OpenSSL 0.9.5 and have been available since
163.Ox 2.7 .
164.Pp
165.Fn X509_keyid_set1
166first appeared in OpenSSL 0.9.6 and has been available since
167.Ox 2.9 .
168.Pp
169.Fn X509_keyid_get0
170first appeared in OpenSSL 0.9.8 and has been available since
171.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/X509_load_cert_file.3 b/src/lib/libcrypto/man/X509_load_cert_file.3
deleted file mode 100644
index 95a83dd00e..0000000000
--- a/src/lib/libcrypto/man/X509_load_cert_file.3
+++ /dev/null
@@ -1,133 +0,0 @@
1.\" $OpenBSD: X509_load_cert_file.3,v 1.1 2021/11/09 16:23:04 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 9 2021 $
18.Dt X509_LOAD_CERT_FILE 3
19.Os
20.Sh NAME
21.Nm X509_load_cert_file ,
22.Nm X509_load_crl_file ,
23.Nm X509_load_cert_crl_file
24.Nd read, decode, and cache certificates and CRLs
25.Sh SYNOPSIS
26.In openssl/x509_vfy.h
27.Ft int
28.Fo X509_load_cert_file
29.Fa "X509_LOOKUP *ctx"
30.Fa "const char *file"
31.Fa "int type"
32.Fc
33.Ft int
34.Fo X509_load_crl_file
35.Fa "X509_LOOKUP *ctx"
36.Fa "const char *file"
37.Fa "int type"
38.Fc
39.Ft int
40.Fo X509_load_cert_crl_file
41.Fa "X509_LOOKUP *ctx"
42.Fa "const char *file"
43.Fa "int type"
44.Fc
45.Sh DESCRIPTION
46.Fn X509_load_cert_file
47with a
48.Fa type
49of
50.Dv X509_FILETYPE_PEM
51reads one or more certificates in PEM format from the given
52.Fa file
53using
54.Xr PEM_read_bio_X509_AUX 3 ;
55with a type of
56.Dv X509_FILETYPE_ASN1 ,
57if reads one certificate in DER format using
58.Xr d2i_X509_bio 3 .
59The certificates read are added to the
60.Vt X509_STORE
61memory cache object associated with the given
62.Fa ctx
63using
64.Xr X509_STORE_add_cert 3 .
65.Pp
66.Fn X509_load_crl_file
67with a
68.Fa type
69of
70.Dv X509_FILETYPE_PEM
71reads one or more certificate revocation lists in PEM format from the given
72.Fa file
73using
74.Xr PEM_read_bio_X509_CRL 3 ;
75with a type of
76.Dv X509_FILETYPE_ASN1 ,
77if reads one certificate revocation lists in DER format using
78.Xr d2i_X509_CRL_bio 3 .
79The certificate revocation lists read are added to the
80.Vt X509_STORE
81memory cache object associated with the given
82.Fa ctx
83using
84.Xr X509_STORE_add_crl 3 .
85.Pp
86.Fn X509_load_cert_crl_file
87with a
88.Fa type
89of
90.Dv X509_FILETYPE_PEM
91read one or more certificates and/or certificate revocation lists
92in PEM format from the given
93.Fa file
94using
95.Xr PEM_X509_INFO_read_bio 3
96and adds them to the
97.Vt X509_STORE
98memory cache object associated with the given
99.Fa ctx
100using
101.Xr X509_STORE_add_cert 3
102and
103.Xr X509_STORE_add_crl 3 ,
104respectively.
105.Pp
106.Fn X509_load_cert_crl_file
107with a
108.Fa type
109of
110.Dv X509_FILETYPE_ASN1
111is equivalent to
112.Fn X509_load_cert_file
113and cannot be used to read a certificate revocation list.
114.Sh RETURN VALUES
115These functions return the number of objects loaded or 0 on error.
116.Sh SEE ALSO
117.Xr d2i_X509_bio 3 ,
118.Xr PEM_read_PrivateKey 3 ,
119.Xr X509_LOOKUP_new 3 ,
120.Xr X509_OBJECT_get0_X509 3 ,
121.Xr X509_STORE_load_locations 3 ,
122.Xr X509_STORE_new 3
123.Sh HISTORY
124.Fn X509_load_cert_file
125first appeared in SSLeay 0.8.0 and
126.Fn X509_load_crl_file
127in SSLeay 0.9.0.
128These functions have been available since
129.Ox 2.4 .
130.Pp
131.Fn X509_load_cert_crl_file
132first appeared in OpenSSL 0.9.5 and has been available since
133.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/X509_new.3 b/src/lib/libcrypto/man/X509_new.3
deleted file mode 100644
index 7b62363d4d..0000000000
--- a/src/lib/libcrypto/man/X509_new.3
+++ /dev/null
@@ -1,279 +0,0 @@
1.\" $OpenBSD: X509_new.3,v 1.45 2024/09/02 08:04:32 tb Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2016, 2018, 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2002, 2006, 2015, 2016 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: September 2 2024 $
70.Dt X509_NEW 3
71.Os
72.Sh NAME
73.Nm X509_new ,
74.Nm X509_dup ,
75.Nm X509_REQ_to_X509 ,
76.Nm X509_free ,
77.Nm X509_up_ref ,
78.Nm X509_chain_up_ref
79.Nd X.509 certificate object
80.Sh SYNOPSIS
81.In openssl/x509.h
82.Ft X509 *
83.Fn X509_new void
84.Ft X509 *
85.Fo X509_dup
86.Fa "X509 *a"
87.Fc
88.Ft X509 *
89.Fo X509_REQ_to_X509
90.Fa "X509_REQ *req"
91.Fa "int days"
92.Fa "EVP_PKEY *pkey"
93.Fc
94.Ft void
95.Fo X509_free
96.Fa "X509 *a"
97.Fc
98.Ft int
99.Fo X509_up_ref
100.Fa "X509 *a"
101.Fc
102.Ft STACK_OF(X509) *
103.Fo X509_chain_up_ref
104.Fa "STACK_OF(X509) *chain"
105.Fc
106.Sh DESCRIPTION
107.Fn X509_new
108allocates and initializes an empty
109.Vt X509
110object with reference count 1.
111It represents an ASN.1
112.Vt Certificate
113structure defined in RFC 5280 section 4.1.
114It can hold a public key together with information about the person,
115organization, device, or function the associated private key belongs to.
116.Pp
117.Fn X509_dup
118creates a deep copy of
119.Fa a
120using
121.Xr ASN1_item_dup 3 ,
122setting the reference count of the copy to 1.
123.Pp
124.Fn X509_REQ_to_X509
125allocates a new certificate object, copies the public key from
126.Fa req
127into it, copies the subject name of
128.Fa req
129to both the subject and issuer names of the new certificate, sets the
130.Fa notBefore
131field to the current time and the
132.Fa notAfter
133field to the given number of
134.Fa days
135in the future, and signs the new certificate with
136.Xr X509_sign 3
137using
138.Fa pkey
139and the MD5 algorithm.
140If
141.Fa req
142contains at least one attribute,
143the version of the new certificate is set to 2.
144.Pp
145.Fn X509_free
146decrements the reference count of the
147.Vt X509
148structure
149.Fa a
150and frees it up if the reference count reaches 0.
151If
152.Fa a
153is a
154.Dv NULL
155pointer, no action occurs.
156.Pp
157.Fn X509_up_ref
158increments the reference count of
159.Fa a
160by 1.
161This function is useful if a certificate structure is being used
162by several different operations each of which will free it up after
163use: this avoids the need to duplicate the entire certificate
164structure.
165.Pp
166.Fn X509_chain_up_ref
167performs a shallow copy of the given
168.Fa chain
169using
170.Fn sk_X509_dup
171and increments the reference count of each contained certificate
172by 1.
173Its purpose is similar to
174.Fn X509_up_ref :
175The returned chain persists after the original is freed.
176.Sh RETURN VALUES
177.Fn X509_new ,
178.Fn X509_dup ,
179and
180.Fn X509_REQ_to_X509
181return a pointer to the newly allocated object or
182.Dv NULL
183if an error occurs; an error code can be obtained by
184.Xr ERR_get_error 3 .
185.Pp
186.Fn X509_up_ref
187returns 1 for success or 0 for failure.
188.Pp
189.Fn X509_chain_up_ref
190returns the copy of the
191.Fa chain
192or
193.Dv NULL
194if an error occurs.
195.Sh SEE ALSO
196.Xr ASIdentifiers_new 3 ,
197.Xr ASRange_new 3 ,
198.Xr AUTHORITY_KEYID_new 3 ,
199.Xr BASIC_CONSTRAINTS_new 3 ,
200.Xr crypto 3 ,
201.Xr d2i_X509 3 ,
202.Xr IPAddressRange_new 3 ,
203.Xr PKCS8_PRIV_KEY_INFO_new 3 ,
204.Xr X509_ALGOR_new 3 ,
205.Xr X509_ATTRIBUTE_new 3 ,
206.Xr X509_check_ca 3 ,
207.Xr X509_check_host 3 ,
208.Xr X509_check_issued 3 ,
209.Xr X509_check_private_key 3 ,
210.Xr X509_check_purpose 3 ,
211.Xr X509_CINF_new 3 ,
212.Xr X509_cmp 3 ,
213.Xr X509_CRL_new 3 ,
214.Xr X509_digest 3 ,
215.Xr X509_EXTENSION_new 3 ,
216.Xr X509_find_by_subject 3 ,
217.Xr X509_get0_notBefore 3 ,
218.Xr X509_get0_signature 3 ,
219.Xr X509_get1_email 3 ,
220.Xr X509_get_ex_new_index 3 ,
221.Xr X509_get_extension_flags 3 ,
222.Xr X509_get_pubkey 3 ,
223.Xr X509_get_pubkey_parameters 3 ,
224.Xr X509_get_serialNumber 3 ,
225.Xr X509_get_subject_name 3 ,
226.Xr X509_get_version 3 ,
227.Xr X509_INFO_new 3 ,
228.Xr X509_load_cert_file 3 ,
229.Xr X509_LOOKUP_hash_dir 3 ,
230.Xr X509_LOOKUP_new 3 ,
231.Xr X509_NAME_new 3 ,
232.Xr X509_OBJECT_new 3 ,
233.Xr X509_PKEY_new 3 ,
234.Xr X509_print_ex 3 ,
235.Xr X509_PUBKEY_new 3 ,
236.Xr X509_PURPOSE_set 3 ,
237.Xr X509_REQ_new 3 ,
238.Xr X509_SIG_new 3 ,
239.Xr X509_sign 3 ,
240.Xr X509_STORE_CTX_new 3 ,
241.Xr X509_STORE_get_by_subject 3 ,
242.Xr X509_STORE_new 3 ,
243.Xr X509v3_addr_add_inherit 3 ,
244.Xr X509v3_addr_get_range 3 ,
245.Xr X509v3_addr_inherits 3 ,
246.Xr X509v3_addr_subset 3 ,
247.Xr X509v3_addr_validate_path 3 ,
248.Xr X509v3_asid_add_id_or_range 3
249.Sh STANDARDS
250RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
251Certificate Revocation List (CRL) Profile
252.Sh HISTORY
253.Fn X509_new
254and
255.Fn X509_free
256appeared in SSLeay 0.4 or earlier,
257.Fn X509_dup
258in SSLeay 0.4.4, and
259.Fn X509_REQ_to_X509
260in SSLeay 0.6.0 .
261These functions have been available since
262.Ox 2.4 .
263.Pp
264.Fn X509_up_ref
265first appeared in OpenSSL 1.1.0 and has been available since
266.Ox 6.1 .
267.Pp
268.Fn X509_chain_up_ref
269first appeared in OpenSSL 1.0.2 and has been available since
270.Ox 6.3 .
271.Sh BUGS
272The X.509 public key infrastructure and its data types contain too
273many design bugs to list them.
274For lots of examples, see the classic
275.Lk https://www.cs.auckland.ac.nz/~pgut001/pubs/x509guide.txt\
276 "X.509 Style Guide"
277that
278.An Peter Gutmann
279published in 2000.
diff --git a/src/lib/libcrypto/man/X509_ocspid_print.3 b/src/lib/libcrypto/man/X509_ocspid_print.3
deleted file mode 100644
index b9b6c92fbb..0000000000
--- a/src/lib/libcrypto/man/X509_ocspid_print.3
+++ /dev/null
@@ -1,58 +0,0 @@
1.\" $OpenBSD: X509_ocspid_print.3,v 1.1 2021/08/06 21:45:55 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: August 6 2021 $
18.Dt X509_OCSPID_PRINT 3
19.Os
20.Sh NAME
21.Nm X509_ocspid_print
22.Nd pretty-print hashes of subject name and public key
23.Sh SYNOPSIS
24.In openssl/x509.h
25.Ft int
26.Fo X509_ocspid_print
27.Fa "BIO *bio"
28.Fa "X509 *issuer"
29.Fc
30.Sh DESCRIPTION
31.Fn X509_ocspid_print
32produces human-readable output to
33.Fa bio
34containing hexadecimal representations of SHA-1 hashes of the
35DER-encoded forms of the subject name and the public key of the
36.Fa issuer
37certificate, as these hashes appear in OCSP requests.
38.Sh RETURN VALUES
39.Fn X509_ocspid_print
40returns 1 for success or 0 for failure.
41.Sh EXAMPLES
42This function is used by the
43.Fl ocspid
44flag of the
45.Xr openssl 1
46.Cm x509
47command.
48.Sh SEE ALSO
49.Xr EVP_sha1 3 ,
50.Xr i2d_X509_NAME 3 ,
51.Xr OCSP_cert_to_id 3 ,
52.Xr OCSP_REQUEST_new 3 ,
53.Xr X509_get_pubkey 3 ,
54.Xr X509_get_subject_name 3
55.Sh HISTORY
56.Fn X509_ocspid_print
57first appeared in OpenSSL 0.9.7 and has been available since
58.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/X509_print_ex.3 b/src/lib/libcrypto/man/X509_print_ex.3
deleted file mode 100644
index c769e77c32..0000000000
--- a/src/lib/libcrypto/man/X509_print_ex.3
+++ /dev/null
@@ -1,279 +0,0 @@
1.\" $OpenBSD: X509_print_ex.3,v 1.5 2025/03/09 14:02:46 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 9 2025 $
18.Dt X509_PRINT_EX 3
19.Os
20.Sh NAME
21.Nm X509_print_ex ,
22.Nm X509_CERT_AUX_print ,
23.Nm X509_print_ex_fp ,
24.Nm X509_print ,
25.Nm X509_print_fp
26.Nd pretty-print an X.509 certificate
27.Sh SYNOPSIS
28.In openssl/x509.h
29.Ft int
30.Fo X509_print_ex
31.Fa "BIO *bio"
32.Fa "X509 *x"
33.Fa "unsigned long nameflags"
34.Fa "unsigned long skipflags"
35.Fc
36.Ft int
37.Fo X509_CERT_AUX_print
38.Fa "BIO *bio"
39.Fa "X509_CERT_AUX *aux"
40.Fa "int indent"
41.Fc
42.Ft int
43.Fo X509_print_ex_fp
44.Fa "FILE *fp"
45.Fa "X509 *x"
46.Fa "unsigned long nameflags"
47.Fa "unsigned long skipflags"
48.Fc
49.Ft int
50.Fo X509_print
51.Fa "BIO *bio"
52.Fa "X509 *x"
53.Fc
54.Ft int
55.Fo X509_print_fp
56.Fa "FILE *fp"
57.Fa "X509 *x"
58.Fc
59.Sh DESCRIPTION
60.Fn X509_print_ex
61prints information contained in
62.Fa x
63to
64.Fa bio
65in human-readable form.
66Printing is aborted as soon as any operation fails, with the exception
67that failures while attempting to decode or print the public key,
68the X.509 version 3 extensions, or non-standard auxiliary data are
69not considered as errors.
70.Pp
71By default, the following blocks of information are printed
72in the following order.
73Each block can be skipped by setting the corresponding bit in
74.Fa skipflags ,
75provided in parentheses after each block description.
76.Bl -bullet
77.It
78A pair of lines reading
79.Qq Certificate:\&
80and
81.Qq Data:\&
82containing no information.
83.Pq Dv X509_FLAG_NO_HEADER
84.It
85The certificate version number as defined by the standard,
86followed in parentheses by the value contained in the version field
87in hexadecimal notation.
88See
89.Xr X509_get_version 3
90for details.
91.Pq Dv X509_FLAG_NO_VERSION
92.It
93The serial number of the certificate as returned by
94.Xr X509_get_serialNumber 3 .
95If it is not \-1 and converting it to
96.Vt long
97succeeds, it is printed in both decimal and hexadecimal format.
98If it is \-1, too wide to fit in
99.Vt long ,
100or conversion fails, it is printed byte-by-byte in hexadecimal notation.
101.Pq Dv X509_FLAG_NO_SERIAL
102.It
103The name of the signature algorithm is printed with
104.Xr X509_signature_print 3 .
105.Pq Dv X509_FLAG_NO_SIGNAME
106.It
107The issuer name returned by
108.Xr X509_get_issuer_name 3
109is printed with
110.Xr X509_NAME_print_ex 3 .
111.Pq Dv X509_FLAG_NO_ISSUER
112.It
113The validity period from
114.Xr X509_get_notBefore 3
115to
116.Xr X509_get_notAfter 3
117is printed using
118.Xr ASN1_TIME_print 3 .
119.Pq Dv X509_FLAG_NO_VALIDITY
120.It
121The subject name returned from
122.Xr X509_get_subject_name 3
123is printed with
124.Xr X509_NAME_print_ex 3 .
125.Pq Dv X509_FLAG_NO_SUBJECT
126.It
127The public key algorithm is printed with
128.Xr i2a_ASN1_OBJECT 3 ,
129and the public key returned from
130.Xr X509_get_pubkey 3
131with
132.Xr EVP_PKEY_print_public 3 .
133.Pq Dv X509_FLAG_NO_PUBKEY
134.It
135All X.509 extensions contained in the certificate are printed with
136.Xr X509V3_extensions_print 3 .
137.Pq Dv X509_FLAG_NO_EXTENSIONS
138.It
139The signature is printed with
140.Xr X509_signature_print 3 .
141.Pq Dv X509_FLAG_NO_SIGDUMP
142.It
143Non-standard auxiliary data associated with the certificate is printed
144using the function
145.Fn X509_CERT_AUX_print
146documented below.
147.Pq Dv X509_FLAG_NO_AUX
148.El
149.Pp
150The
151.Fa nameflags
152argument modifies the format for printing X.501
153.Vt Name
154objects contained in
155.Fa x .
156It is passed through to
157.Xr X509_NAME_print_ex 3 .
158If
159.Fa nameflags
160is
161.Dv X509_FLAG_COMPAT ,
162the
163.Fa indent
164argument of
165.Xr X509_NAME_print_ex 3
166is set to 16 spaces and the traditional SSLeay format is used.
167Otherwise, if the only bit set in
168.Dv XN_FLAG_SEP_MASK
169is
170.Dv XN_FLAG_SEP_MULTILINE ,
171.Fa indent
172is set to 12 spaces.
173Otherwise,
174.Fa indent
175is set to zero.
176.Pp
177.Fn X509_CERT_AUX_print
178prints information contained in
179.Fa aux
180to
181.Fa bio
182in human-readable form with a left margin of
183.Fa indent
184spaces.
185If
186.Fa aux
187is
188.Dv NULL ,
189it prints nothing.
190.Pp
191Information is printed in the following order:
192.Bl -bullet
193.It
194Purposes the certificate is intended to be used for as set with
195.Xr X509_add1_trust_object 3 ,
196each printed with
197.Xr OBJ_obj2txt 3 .
198.It
199Purposes the certificate is explicitly
200.Em not
201intended to be used for as set with
202.Xr X509_add1_reject_object 3 ,
203again each printed with
204.Xr OBJ_obj2txt 3 .
205.It
206If
207.Fa aux
208contains data set with
209.Xr X509_alias_set1 3 ,
210the raw bytes are printed in unencoded form.
211.It
212If
213.Fa aux
214contains data set with
215.Xr X509_keyid_set1 3 ,
216the bytes are printed in hexadecimal notation with colons in between.
217.El
218.Pp
219.Fn X509_print_ex_fp
220is similar to
221.Fn X509_print_ex
222except that it prints to
223.Fa fp .
224.Pp
225.Fn X509_print
226and
227.Fn X509_print_fp
228are wrapper functions setting the
229.Fa nameflags
230to
231.Dv XN_FLAG_COMPAT
232and the
233.Fa skipflags
234to
235.Dv X509_FLAG_COMPAT .
236.Sh RETURN VALUES
237.Fn X509_print_ex ,
238.Fn X509_print_ex_fp ,
239.Fn X509_print ,
240and
241.Fn X509_print_fp
242return 1 if all requested information was successfully printed,
243even if failures occurred while attempting to decode or print the
244public key or X.509 version 3 extensions, or 0 if any other operation
245failed.
246.Pp
247.Fn X509_CERT_AUX_print
248always returns 1 and silently ignores write errors.
249.Sh SEE ALSO
250.Xr BIO_new 3 ,
251.Xr X509_CERT_AUX_new 3 ,
252.Xr X509_CRL_print 3 ,
253.Xr X509_new 3 ,
254.Xr X509_REQ_print_ex 3
255.Sh HISTORY
256.Fn X509_print
257first appeared in SSLeay 0.5.1 and was changed to print to a
258.Vt BIO
259in SSLeay 0.6.0.
260.Fn X509_print_fp
261first appeared in SSLeay 0.6.0.
262Both functions have been available since
263.Ox 2.4 .
264.Pp
265.Fn X509_CERT_AUX_print
266first appeared in OpenSSL 0.9.5 and has been available since
267.Ox 2.7 .
268.Pp
269.Fn X509_print_ex
270and
271.Fn X509_print_ex_fp
272first appeared in OpenSSL 0.9.7 and have been available since
273.Ox 3.2 .
274.Sh BUGS
275If arbitrary data was stored into
276.Fa x
277using
278.Xr X509_alias_set1 3 ,
279these functions may print binary data and even NUL bytes.
diff --git a/src/lib/libcrypto/man/X509_sign.3 b/src/lib/libcrypto/man/X509_sign.3
deleted file mode 100644
index 059d92bac5..0000000000
--- a/src/lib/libcrypto/man/X509_sign.3
+++ /dev/null
@@ -1,209 +0,0 @@
1.\" $OpenBSD: X509_sign.3,v 1.11 2024/03/06 02:34:14 tb Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2015, 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 6 2024 $
52.Dt X509_SIGN 3
53.Os
54.Sh NAME
55.Nm X509_sign ,
56.Nm X509_sign_ctx ,
57.Nm X509_verify ,
58.Nm X509_REQ_sign ,
59.Nm X509_REQ_sign_ctx ,
60.Nm X509_REQ_verify ,
61.Nm X509_CRL_sign ,
62.Nm X509_CRL_sign_ctx ,
63.Nm X509_CRL_verify
64.Nd sign or verify certificate, certificate request, or CRL signature
65.Sh SYNOPSIS
66.In openssl/x509.h
67.Ft int
68.Fo X509_sign
69.Fa "X509 *x"
70.Fa "EVP_PKEY *pkey"
71.Fa "const EVP_MD *md"
72.Fc
73.Ft int
74.Fo X509_sign_ctx
75.Fa "X509 *x"
76.Fa "EVP_MD_CTX *ctx"
77.Fc
78.Ft int
79.Fo X509_verify
80.Fa "X509 *a"
81.Fa "EVP_PKEY *r"
82.Fc
83.Ft int
84.Fo X509_REQ_sign
85.Fa "X509_REQ *x"
86.Fa "EVP_PKEY *pkey"
87.Fa "const EVP_MD *md"
88.Fc
89.Ft int
90.Fo X509_REQ_sign_ctx
91.Fa "X509_REQ *x"
92.Fa "EVP_MD_CTX *ctx"
93.Fc
94.Ft int
95.Fo X509_REQ_verify
96.Fa "X509_REQ *a"
97.Fa "EVP_PKEY *r"
98.Fc
99.Ft int
100.Fo X509_CRL_sign
101.Fa "X509_CRL *x"
102.Fa "EVP_PKEY *pkey"
103.Fa "const EVP_MD *md"
104.Fc
105.Ft int
106.Fo X509_CRL_sign_ctx
107.Fa "X509_CRL *x"
108.Fa "EVP_MD_CTX *ctx"
109.Fc
110.Ft int
111.Fo X509_CRL_verify
112.Fa "X509_CRL *a"
113.Fa "EVP_PKEY *r"
114.Fc
115.Sh DESCRIPTION
116.Fn X509_sign
117signs the certificate
118.Fa x
119using the private key
120.Fa pkey
121and the message digest
122.Fa md
123and sets the signature in
124.Fa x .
125.Fn X509_sign_ctx
126also signs the certificate
127.Fa x
128but uses the parameters contained in digest context
129.Fa ctx .
130.Pp
131.Fn X509_verify
132verifies the signature of certificate
133.Fa x
134using the public key
135.Fa pkey .
136Only the signature is checked: no other checks (such as certificate
137chain validity) are performed.
138.Pp
139.Fn X509_REQ_sign ,
140.Fn X509_REQ_sign_ctx ,
141.Fn X509_REQ_verify ,
142.Fn X509_CRL_sign ,
143.Fn X509_CRL_sign_ctx ,
144and
145.Fn X509_CRL_verify
146sign and verify certificate requests and CRLs, respectively.
147.Pp
148.Fn X509_sign_ctx
149is used where the default parameters for the corresponding public key
150and digest are not suitable.
151It can be used to sign keys using RSA-PSS for example.
152.Sh RETURN VALUES
153.Fn X509_sign ,
154.Fn X509_sign_ctx ,
155.Fn X509_REQ_sign ,
156.Fn X509_REQ_sign_ctx ,
157.Fn X509_CRL_sign ,
158and
159.Fn X509_CRL_sign_ctx
160return the size of the signature in bytes for success or 0 for failure.
161.Pp
162.Fn X509_verify ,
163.Fn X509_REQ_verify ,
164and
165.Fn X509_CRL_verify
166return 1 if the signature is valid or 0 if the signature check fails.
167If the signature could not be checked at all because it was invalid or
168some other error occurred, then -1 is returned.
169.Pp
170In some cases of failure, the reason can be determined with
171.Xr ERR_get_error 3 .
172.Sh SEE ALSO
173.Xr d2i_X509 3 ,
174.Xr EVP_DigestInit 3 ,
175.Xr X509_CRL_get0_by_serial 3 ,
176.Xr X509_CRL_new 3 ,
177.Xr X509_get_pubkey 3 ,
178.Xr X509_get_subject_name 3 ,
179.Xr X509_get_version 3 ,
180.Xr X509_NAME_add_entry_by_txt 3 ,
181.Xr X509_NAME_ENTRY_get_object 3 ,
182.Xr X509_NAME_get_index_by_NID 3 ,
183.Xr X509_NAME_print_ex 3 ,
184.Xr X509_new 3 ,
185.Xr X509_REQ_new 3 ,
186.Xr X509_verify_cert 3 ,
187.Xr X509V3_get_d2i 3
188.Sh HISTORY
189.Fn X509_verify
190appeared in SSLeay 0.4 or earlier.
191.Fn X509_sign
192and
193.Fn X509_REQ_sign
194first appeared in SSLeay 0.4.4.
195.Fn X509_REQ_verify
196and
197.Fn X509_CRL_verify
198first appeared in SSLeay 0.4.5b.
199.Fn X509_CRL_sign
200first appeared in SSLeay 0.5.1.
201These functions have been available since
202.Ox 2.4 .
203.Pp
204.Fn X509_sign_ctx ,
205.Fn X509_REQ_sign_ctx ,
206and
207.Fn X509_CRL_sign_ctx
208first appeared in OpenSSL 1.0.1 and have been available since
209.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/X509_signature_dump.3 b/src/lib/libcrypto/man/X509_signature_dump.3
deleted file mode 100644
index 3333a615bf..0000000000
--- a/src/lib/libcrypto/man/X509_signature_dump.3
+++ /dev/null
@@ -1,85 +0,0 @@
1.\" $OpenBSD: X509_signature_dump.3,v 1.3 2024/12/06 12:51:13 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 6 2024 $
18.Dt X509_SIGNATURE_DUMP 3
19.Os
20.Sh NAME
21.Nm X509_signature_dump ,
22.Nm X509_signature_print
23.Nd pretty-print ASN.1 strings
24.Sh SYNOPSIS
25.In openssl/x509.h
26.Ft int
27.Fo X509_signature_dump
28.Fa "BIO *bio"
29.Fa "const ASN1_STRING *signature"
30.Fa "int indent"
31.Fc
32.Ft int
33.Fo X509_signature_print
34.Fa "BIO *bio"
35.Fa "const X509_ALGOR *algorithm"
36.Fa "const ASN1_STRING *signature"
37.Fc
38.Sh DESCRIPTION
39.Fn X509_signature_dump
40writes the data bytes contained in the
41.Fa signature
42to
43.Fa bio
44in hexadecimal format with colons between bytes,
4518 bytes per output line, each line indented with
46.Fa indent
47space characters.
48.Pp
49.Fn X509_signature_print
50writes the name of the signature
51.Fa algorithm ,
52or, if no name for it is known, its object identifier (OID) to
53.Fa bio
54using
55.Xr i2a_ASN1_OBJECT 3 .
56After that, if a method object for the algorithm can be retrieved with
57.Xr EVP_PKEY_asn1_find 3
58and if that object defines a printing method, that printing method is
59used to print the
60.Fa signature .
61Otherwise, unless the
62.Fa signature
63is
64.Dv NULL ,
65it is printed using
66.Fn X509_signature_dump .
67.Sh RETURN VALUES
68These functions return 1 on success or 0 on failure.
69They fail and return as soon as any write operation fails.
70.Sh SEE ALSO
71.Xr ASN1_STRING_new 3 ,
72.Xr ASN1_STRING_print_ex 3 ,
73.Xr BIO_new 3 ,
74.Xr EVP_PKEY_asn1_find 3 ,
75.Xr OBJ_find_sigid_algs 3 ,
76.Xr X509_ALGOR_new 3 ,
77.Xr X509_get0_signature 3
78.Sh HISTORY
79.Fn X509_signature_print
80first appeared in OpenSSL 0.9.7 and has been available since
81.Ox 3.2 .
82.Pp
83.Fn X509_signature_dump
84first appeared in OpenSSL 1.0.1 and has been available since
85.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/X509_verify_cert.3 b/src/lib/libcrypto/man/X509_verify_cert.3
deleted file mode 100644
index 9c085d7780..0000000000
--- a/src/lib/libcrypto/man/X509_verify_cert.3
+++ /dev/null
@@ -1,93 +0,0 @@
1.\" $OpenBSD: X509_verify_cert.3,v 1.8 2019/06/06 01:06:59 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2009, 2015 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 6 2019 $
52.Dt X509_VERIFY_CERT 3
53.Os
54.Sh NAME
55.Nm X509_verify_cert
56.Nd discover and verify X509 certificate chain
57.Sh SYNOPSIS
58.In openssl/x509.h
59.Ft int
60.Fo X509_verify_cert
61.Fa "X509_STORE_CTX *ctx"
62.Fc
63.Sh DESCRIPTION
64The
65.Fn X509_verify_cert
66function attempts to discover and validate a certificate chain based on
67parameters in
68.Fa ctx .
69.Pp
70Applications rarely call this function directly, but it is used by
71OpenSSL internally for certificate validation, in both the S/MIME and
72SSL/TLS code.
73.Sh RETURN VALUES
74If a complete chain can be built and validated this function returns 1,
75otherwise it returns a value <= 0 indicating failure.
76.Pp
77Additional error information can be obtained by examining
78.Fa ctx ,
79using
80.Xr X509_STORE_CTX_get_error 3 .
81.Sh SEE ALSO
82.Xr openssl 1 ,
83.Xr X509_STORE_CTX_get_error 3 ,
84.Xr X509_STORE_CTX_new 3
85.Sh HISTORY
86.Fn X509_verify_cert
87first appeared in SSLeay 0.8.0 and has been available since
88.Ox 2.4 .
89.Sh BUGS
90This function uses the header
91.In openssl/x509.h
92as opposed to most chain verification functions which use
93.In openssl/x509_vfy.h .
diff --git a/src/lib/libcrypto/man/X509v3_addr_add_inherit.3 b/src/lib/libcrypto/man/X509v3_addr_add_inherit.3
deleted file mode 100644
index 4b2d150c86..0000000000
--- a/src/lib/libcrypto/man/X509v3_addr_add_inherit.3
+++ /dev/null
@@ -1,475 +0,0 @@
1.\" $OpenBSD: X509v3_addr_add_inherit.3,v 1.11 2023/10/01 22:46:21 tb Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 1 2023 $
18.Dt X509V3_ADDR_ADD_INHERIT 3
19.Os
20.Sh NAME
21.Nm X509v3_addr_add_inherit ,
22.Nm X509v3_addr_add_prefix ,
23.Nm X509v3_addr_add_range ,
24.Nm X509v3_addr_canonize ,
25.Nm X509v3_addr_is_canonical
26.Nd RFC 3779 IP address delegation extensions
27.Sh SYNOPSIS
28.In openssl/x509v3.h
29.Ft int
30.Fo X509v3_addr_add_inherit
31.Fa "IPAddrBlocks *addrblocks"
32.Fa "const unsigned afi"
33.Fa "const unsigned *safi"
34.Fc
35.Ft int
36.Fo X509v3_addr_add_prefix
37.Fa "IPAddrBlocks *addrblocks"
38.Fa "const unsigned afi"
39.Fa "const unsigned *safi"
40.Fa "unsigned char *prefix"
41.Fa "const int prefixlen"
42.Fc
43.Ft int
44.Fo X509v3_addr_add_range
45.Fa "IPAddrBlocks *addrblocks"
46.Fa "const unsigned afi"
47.Fa "const unsigned *safi"
48.Fa "unsigned char *min"
49.Fa "unsigned char *max"
50.Fc
51.Ft int
52.Fo X509v3_addr_canonize
53.Fa "IPAddrBlocks *addrblocks"
54.Fc
55.Ft int
56.Fo X509v3_addr_is_canonical
57.Fa "IPAddrBlocks *addrblocks"
58.Fc
59.Sh DESCRIPTION
60An
61.Vt IPAddrBlocks
62object represents the content of
63an IP address delegation extension
64as defined in RFC 3779, section 2.2.3.1.
65It holds lists of IP address prefixes and IP address ranges
66delegated from the issuer to the subject of the certificate.
67It can be instantiated as explained in the EXAMPLES section
68and its internals are documented in
69.Xr IPAddressRange_new 3 .
70.Pp
71Each list in a well-formed
72.Vt IPAddrBlocks
73object is uniquely identified by
74an address family identifier (AFI) and
75an optional subsequent address family identifier (SAFI).
76Lists can be absent or can contain an
77.Dq inherit
78marker to indicate that the resources are to be inherited
79from the corresponding list of the issuer certificate.
80.Pp
81Per specification, an AFI is an unsigned 16-bit integer and
82a SAFI is an unsigned 8-bit integer.
83For IPv4 and IPv6 there are the predefined constants
84.Dv IANA_AFI_IPV4
85and
86.Dv IANA_AFI_IPV6 ,
87which should be the only values used for
88.Fa afi
89in this API.
90In practice,
91.Fa safi
92is always NULL.
93.Fa afi
94is generally silently truncated to its lowest 16 bits and, if
95.Fa safi
96is non-NULL,
97only the lowest 8 bits of the value pointed at are used.
98.Pp
99.Fn X509v3_addr_add_inherit
100adds a list with an
101.Dq inherit
102marker to
103.Fa addrblocks .
104If a list corresponding to
105.Fa afi
106and
107.Fa safi
108already exists, no action occurs if it is marked
109.Dq inherit ,
110otherwise the call fails.
111.Pp
112.Fn X509v3_addr_add_prefix
113adds a newly allocated internal representation of the
114.Fa prefix
115of length
116.Fa prefixlen
117to the list corresponding to
118.Fa afi
119and the optional
120.Fa safi
121in
122.Fa addrblocks .
123If no such list exists, it is created first.
124If the list exists and is marked
125.Dq inherit ,
126the call fails.
127.Fa prefix
128is expected to be a byte array in network byte order.
129It should point at enough memory to accommodate
130.Fa prefixlen
131bits and it is recommended that all the bits not covered by the
132.Fa prefixlen
133be set to 0.
134It is the caller's responsibility to ensure that the
135.Fa prefix
136has no address in common with any of
137the prefixes or ranges already in the list.
138If
139.Fa afi
140is
141.Dv IANA_AFI_IPV4 ,
142.Fa prefixlen
143should be between 0 and 32 (inclusive) and if
144.Fa afi
145is
146.Dv IANA_AFI_IPV6 ,
147.Fa prefixlen
148should be between 0 and 128 (inclusive).
149.Pp
150.Fn X509v3_addr_add_range
151is similar to
152.Fn X509v3_addr_add_prefix
153for the closed interval of IP addresses between
154.Fa min
155and
156.Fa max
157in network presentation.
158If
159.Fa afi
160is
161.Dv IANA_AFI_IPV4 ,
162.Fa min
163and
164.Fa max
165should point at 4 bytes of memory
166and if
167.Fa afi
168is
169.Dv IANA_AFI_IPV6 ,
170.Fa min
171and
172.Fa max
173should point at 16 bytes of memory.
174In case the range of IP addresses between
175.Fa min
176and
177.Fa max
178is a prefix, a prefix will be added instead of a range.
179It is the caller's responsibility to ensure that
180.Fa min
181is less than or equal to
182.Fa max
183and that it does not contain any address already present
184in the list.
185Failure to do so will result in a subsequent failure of
186.Fn X509v3_addr_canonize .
187.Pp
188.Fn X509v3_addr_canonize
189attempts to bring the
190.Pf non- Dv NULL
191.Fa addrblocks
192into canonical form.
193An
194.Vt IPAddrBlocks
195object is said to be in canonical form if it conforms
196to the ordering specified in RFC 3779:
197section 2.2.3.3 requires that
198the list of lists be sorted first by increasing
199.Fa afi
200and then by increasing
201.Fa safi ,
202where NULL is the minimal SAFI;
203section 2.2.3.6 requires that each list be in minimal form and sorted.
204The minimality requirement is that all adjacent prefixes
205and ranges must be merged into a single range and that each
206range must be expressed as a prefix, if possible.
207In particular, any given address can be in at most one list entry.
208The order is by increasing minimal IP address in network byte order.
209.Pp
210.Fn X509v3_addr_is_canonical
211indicates whether
212.Fa addrblocks
213is in canonical form.
214.Sh RETURN VALUES
215All these functions return 1 on success and 0 on failure.
216Memory allocation failure is one possible reason for all of them.
217Sometimes an error code can be obtained by
218.Xr ERR_get_error 3 .
219.Pp
220.Fn X509v3_addr_add_inherit
221fails if the list corresponding to
222.Fa afi
223and the optional
224.Fa safi
225already exists and is not marked
226.Dq inherit .
227.Pp
228.Fn X509v3_addr_add_prefix
229and
230.Fn X509v3_addr_add_range
231fail if a list corresponding to
232.Fa afi
233and the optional
234.Fa safi
235already exists and is marked
236.Dq inherit ,
237or if
238.Fa prefixlen
239is outside the interval [0,32] for IPv4 addresses
240or [0,128] for IPv6 addresses.
241.Pp
242.Fn X509v3_addr_canonize
243fails if one of the lists in
244.Fa addrblocks
245is malformed,
246in particular if it contains corrupt, overlapping,
247or duplicate entries.
248Corruption includes ranges where
249.Fa max
250is strictly smaller than
251.Fa min .
252The error conditions are generally indistinguishable.
253.Pp
254.Fn X509v3_addr_is_canonical
255returns 1 if
256.Fa addrblocks
257is in canonical form.
258A return value of 0 can indicate non-canonical form or a corrupted list.
259.Sh EXAMPLES
260Construct the first extension from RFC 3779, Appendix B.
261.Bd -literal
262#include <sys/socket.h>
263#include <arpa/inet.h>
264
265#include <err.h>
266#include <stdio.h>
267#include <unistd.h>
268
269#include <openssl/asn1.h>
270#include <openssl/objects.h>
271#include <openssl/x509.h>
272#include <openssl/x509v3.h>
273
274const char *prefixes[] = {
275 "10.0.32/20", "10.0.64/24", "10.1/16",
276 "10.2.48/20", "10.2.64/24", "10.3/16",
277};
278#define N_PREFIXES (sizeof(prefixes) / sizeof(prefixes[0]))
279
280static void
281hexdump(const unsigned char *buf, size_t len)
282{
283 size_t i;
284
285 for (i = 1; i <= len; i++)
286 printf(" 0x%02x,%s", buf[i \- 1], i % 8 ? "" : "\en");
287 if (len % 8)
288 printf("\en");
289}
290
291int
292main(void)
293{
294 IPAddrBlocks *addrblocks;
295 X509_EXTENSION *ext;
296 unsigned char *der;
297 int der_len;
298 size_t i;
299
300 if (pledge("stdio", NULL) == \-1)
301 err(1, "pledge");
302
303 /*
304 * Somebody forgot to implement IPAddrBlocks_new(). IPAddrBlocks
305 * is the same as STACK_OF(IPAddressFamily). As such, it should
306 * have IPAddressFamily_cmp() as its comparison function. It is
307 * not possible to call sk_new(3) because IPAddressFamily_cmp()
308 * is not part of the public API. The correct comparison function
309 * can be installed as a side-effect of X509v3_addr_canonize(3).
310 */
311 if ((addrblocks = sk_IPAddressFamily_new_null()) == NULL)
312 err(1, "sk_IPAddressFamily_new_null");
313 if (!X509v3_addr_canonize(addrblocks))
314 errx(1, "X509v3_addr_canonize");
315
316 /* Add the prefixes as IPv4 unicast. */
317 for (i = 0; i < N_PREFIXES; i++) {
318 unsigned char addr[16] = {0};
319 int len;
320 int unicast = 1; /* SAFI for unicast forwarding. */
321
322 len = inet_net_pton(AF_INET, prefixes[i], addr,
323 sizeof(addr));
324 if (len == \-1)
325 errx(1, "inet_net_pton(%s)", prefixes[i]);
326 if (!X509v3_addr_add_prefix(addrblocks, IANA_AFI_IPV4,
327 &unicast, addr, len))
328 errx(1, "X509v3_addr_add_prefix(%s)", prefixes[i]);
329 }
330 if (!X509v3_addr_add_inherit(addrblocks, IANA_AFI_IPV6, NULL))
331 errx(1, "X509v3_addr_add_inherit");
332
333 /*
334 * Ensure the extension is in canonical form. Otherwise the two
335 * adjacent prefixes 10.2.48/20 and 10.2.64/24 are not merged into
336 * the range 10.2.48.0--10.2.64.255. This results in invalid DER
337 * encoding from X509V3_EXT_i2d(3) and i2d_X509_EXTENSION(3).
338 */
339 if (!X509v3_addr_canonize(addrblocks))
340 errx(1, "X509v3_addr_canonize");
341
342 /* Create the extension with the correct OID; mark it critical. */
343 ext = X509V3_EXT_i2d(NID_sbgp_ipAddrBlock, 1, addrblocks);
344 if (ext == NULL)
345 errx(1, "X509V3_EXT_i2d");
346
347 der = NULL;
348 if ((der_len = i2d_X509_EXTENSION(ext, &der)) <= 0)
349 errx(1, "i2d_X509_EXTENSION");
350
351 hexdump(der, der_len);
352
353 /* One way of implementing IPAddrBlocks_free(). */
354 sk_IPAddressFamily_pop_free(addrblocks, IPAddressFamily_free);
355 X509_EXTENSION_free(ext);
356 free(der);
357
358 return 0;
359}
360.Ed
361.Pp
362Implement the missing public API
363.Fn d2i_IPAddrBlocks
364and
365.Fn i2d_IPAddrBlocks
366using
367.Xr ASN1_item_d2i 3 :
368.Bd -literal
369IPAddrBlocks *
370d2i_IPAddrBlocks(IPAddrBlocks **addrblocks, const unsigned char **in,
371 long len)
372{
373 const X509V3_EXT_METHOD *v3_addr;
374
375 if ((v3_addr = X509V3_EXT_get_nid(NID_sbgp_ipAddrBlock)) == NULL)
376 return NULL;
377 return (IPAddrBlocks *)ASN1_item_d2i((ASN1_VALUE **)addrblocks,
378 in, len, ASN1_ITEM_ptr(v3_addr\->it));
379}
380
381int
382i2d_IPAddrBlocks(IPAddrBlocks *addrblocks, unsigned char **out)
383{
384 const X509V3_EXT_METHOD *v3_addr;
385
386 if ((v3_addr = X509V3_EXT_get_nid(NID_sbgp_ipAddrBlock)) == NULL)
387 return \-1;
388 return ASN1_item_i2d((ASN1_VALUE *)addrblocks, out,
389 ASN1_ITEM_ptr(v3_addr\->it));
390}
391.Ed
392.Pp
393The use of the undocumented macro
394.Dv ASN1_ITEM_ptr()
395is necessary if compatibility with modern versions of other implementations
396is desired.
397.Sh SEE ALSO
398.Xr ASIdentifiers_new 3 ,
399.Xr crypto 3 ,
400.Xr inet_net_ntop 3 ,
401.Xr inet_ntop 3 ,
402.Xr IPAddressRange_new 3 ,
403.Xr X509_new 3 ,
404.Xr X509v3_addr_get_range 3 ,
405.Xr X509v3_addr_validate_path 3 ,
406.Xr X509v3_asid_add_id_or_range 3
407.Sh STANDARDS
408RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers:
409.Bl -dash -compact
410.It
411section 2: IP Address delegation extension
412.El
413.Pp
414RFC 7020: The Internet Numbers Registry System
415.Pp
416RFC 7249: Internet Number Registries
417.Pp
418.Rs
419.%T Address Family Numbers
420.%U https://www.iana.org/assignments/address\-family\-numbers
421.Re
422.Pp
423.Rs
424.%T Subsequent Address Family Identifiers (SAFI) Parameters
425.%U https://www.iana.org/assignments/safi\-namespace
426.Re
427.Sh HISTORY
428These functions first appeared in OpenSSL 0.9.8e
429and have been available since
430.Ox 7.1 .
431.Sh BUGS
432.Fn IPAddrBlocks_new ,
433.Fn IPAddrBlocks_free ,
434.Fn d2i_IPAddrBlocks ,
435and
436.Fn i2d_IPAddrBlocks
437do not exist and
438.Fa IPAddrBlocks_it
439is not public.
440The above examples show how to implement the four missing functions
441with public API.
442.Pp
443.Fn X509v3_addr_add_range
444should check for inverted range bounds and overlaps
445on insertion and fail instead of creating a nonsensical
446.Fa addrblocks
447that fails to be canonized by
448.Fn X509v3_addr_canonize .
449.Pp
450If
451.Dv NULL
452is passed to
453.Xr X509v3_asid_canonize 3 ,
454it succeeds.
455.Fn X509v3_addr_is_canonical
456considers
457.Dv NULL
458to be a canonical
459.Vt IPAddrBlocks .
460In contrast,
461.Fn X509v3_addr_canonize
462crashes with a
463.Dv NULL
464dereference.
465.Pp
466The code only supports the IPv4 and IPv6 AFIs.
467This is not consistently enforced across implementations.
468.Pp
469.Fn X509v3_addr_add_range
470fails to clear the unused bits set to 1 in the last octet of
471the
472.Vt ASN1_BIT_STRING
473representation of
474.Fa max .
475This confuses some software.
diff --git a/src/lib/libcrypto/man/X509v3_addr_get_range.3 b/src/lib/libcrypto/man/X509v3_addr_get_range.3
deleted file mode 100644
index e0d83b1162..0000000000
--- a/src/lib/libcrypto/man/X509v3_addr_get_range.3
+++ /dev/null
@@ -1,132 +0,0 @@
1.\" $OpenBSD: X509v3_addr_get_range.3,v 1.2 2023/09/30 14:12:40 schwarze Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 30 2023 $
18.Dt X509V3_ADDR_GET_RANGE 3
19.Os
20.Sh NAME
21.Nm X509v3_addr_get_afi ,
22.Nm X509v3_addr_get_range
23.Nd parse helpers for the IP address delegation extension
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft unsigned
27.Fn X509v3_addr_get_afi "const IPAddressFamily *af"
28.Ft int
29.Fo X509v3_addr_get_range
30.Fa "IPAddressOrRange *aor"
31.Fa "const unsigned afi"
32.Fa "unsigned char *min"
33.Fa "unsigned char *max"
34.Fa "const int length"
35.Fc
36.Sh DESCRIPTION
37.Fn X509v3_addr_get_afi
38returns the address family identifier (AFI) of
39.Fa af .
40.Pp
41.Fn X509v3_addr_get_range
42converts the minimum and maximum addresses in
43the address prefix or range
44.Fa aor
45from internal encoding to IP addresses in network byte order
46and places copies in the arrays
47.Fa min
48and
49.Fa max ,
50of size
51.Fa length .
52The
53.Fa length
54must be large enough to accommodate an address for
55.Fa afi ,
56which is at least 4 for
57.Dv IANA_AFI_IPV4
58and at least 16 for
59.Dv IANA_AFI_IPV6 .
60.Sh RETURN VALUES
61.Fn X509v3_addr_get_afi
62returns the AFI encoded in
63.Fa af
64or 0 if
65.Fa af
66does not contain a valid AFI, or if the AFI is not IPv4 or IPv6.
67.Pp
68.Fn X509v3_addr_get_range
69returns the number of bytes copied into
70.Fa min
71and
72.Fa max
73or 0 on error.
74An error occurs if
75.Fa aor
76is malformed, if
77.Fa afi
78is not
79.Dv IANA_AFI_IPV4
80or
81.Dv IANA_AFI_IPV6 ,
82if either
83.Fa min
84or
85.Fa max
86is
87.Dv NULL ,
88or if
89.Fa length
90is smaller than 4 or 16, respectively.
91.Sh SEE ALSO
92.Xr crypto 3 ,
93.Xr inet_ntop 3 ,
94.Xr IPAddressRange_new 3 ,
95.Xr X509_new 3 ,
96.Xr X509v3_addr_add_inherit 3
97.Sh STANDARDS
98RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers:
99.Bl -dash -compact
100.It
101section 2: IP Address delegation extension
102.It
103section 2.2.3.3: Element addressFamily
104.It
105section 2.2.3.7: Type IPAddressOrRange
106.It
107section 2.2.3.8: Element addressPrefix and Type IPAddress
108.El
109.Pp
110.Rs
111.%T Address Family Numbers
112.%U https://www.iana.org/assignments/address-family-numbers
113.Re
114.Sh HISTORY
115These functions first appeared in OpenSSL 0.9.8e
116and have been available since
117.Ox 7.1 .
118.Sh BUGS
119There is no accessor for the SAFI of
120.Fa af .
121.Pp
122An error from
123.Fn X509v3_addr_get_afi
124is indistinguishable from the reserved AFI 0 being set on
125.Fa af .
126.Pp
127It is not entirely clear how a caller is supposed to obtain an
128.Vt IPAddressFamily
129object or an
130.Vt IPAddressOrRange
131object without reaching into various structs documented in
132.Xr IPAddressRange_new 3 .
diff --git a/src/lib/libcrypto/man/X509v3_addr_inherits.3 b/src/lib/libcrypto/man/X509v3_addr_inherits.3
deleted file mode 100644
index 8e3cecf7ae..0000000000
--- a/src/lib/libcrypto/man/X509v3_addr_inherits.3
+++ /dev/null
@@ -1,104 +0,0 @@
1.\" $OpenBSD: X509v3_addr_inherits.3,v 1.3 2023/09/30 14:21:57 schwarze Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 30 2023 $
18.Dt X509V3_ADDR_INHERITS 3
19.Os
20.Sh NAME
21.Nm X509v3_addr_inherits ,
22.Nm X509v3_asid_inherits
23.Nd RFC 3779 inheritance
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft int
27.Fn X509v3_addr_inherits "IPAddrBlocks *addrblocks"
28.Ft int
29.Fn X509v3_asid_inherits "ASIdentifiers *asids"
30.Sh DESCRIPTION
31.Fn X509v3_addr_inherits
32determines if there is at least one address family in
33.Fa addrblocks
34that uses inheritance.
35.Pp
36.Fn X509v3_asid_inherits
37is intended to determine if at least one of
38the list of autonomous system numbers or
39the list of routing domain identifiers
40uses inheritance.
41.Sh RETURN VALUES
42.Fn X509v3_addr_inherits
43returns 1 if and only if
44.Fa addrblocks
45contains at least one
46.Fa IPAddressFamily
47object that is correctly marked
48.Dq inherit :
49its
50.Fa IPAddressChoice
51is of
52.Fa type
53.Dv IPAddressChoice_inherit
54and its
55.Fa inherit
56element is present.
57Otherwise it returns 0.
58.Pp
59.Fn X509v3_asid_inherits
60returns 1 if and only if
61at least one of the
62.Fa asnum
63or the
64.Fa rdi
65lists has
66.Fa type
67.Dv ASIdentifierChoice_inherit .
68Otherwise it returns 0.
69.Sh SEE ALSO
70.Xr ASIdentifiers_new 3 ,
71.Xr ASRange_new 3 ,
72.Xr crypto 3 ,
73.Xr IPAddressRange_new 3 ,
74.Xr X509_new 3 ,
75.Xr X509v3_addr_add_inherit 3 ,
76.Xr X509v3_asid_add_inherit 3
77.Sh STANDARDS
78RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers:
79.Bl -dash -compact
80.It
81section 2: IP Address delegation extension
82.It
83section 2.2.3.5: Element inherit
84.It
85section 3: AS identifiers delegation extension
86.It
87section 3.2.3.3: Element inherit
88.El
89.Sh HISTORY
90These functions first appeared in OpenSSL 0.9.8e
91and have been available since
92.Ox 7.1 .
93.Sh BUGS
94.Fn X509v3_asid_inherits
95ignores whether the
96.Fa inherit
97element is present or absent in the list that is considered to use inheritance.
98.Pp
99There is no API that determines whether all lists contained in an
100.Vt ASIdentifiers
101or an
102.Vt IPAddrBlocks
103object inherit.
104See RFC 9287, 5.1.2 for an example where this is relevant.
diff --git a/src/lib/libcrypto/man/X509v3_addr_subset.3 b/src/lib/libcrypto/man/X509v3_addr_subset.3
deleted file mode 100644
index 93714a26fa..0000000000
--- a/src/lib/libcrypto/man/X509v3_addr_subset.3
+++ /dev/null
@@ -1,176 +0,0 @@
1.\" $OpenBSD: X509v3_addr_subset.3,v 1.2 2023/09/30 14:24:00 schwarze Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 30 2023 $
18.Dt X509V3_ADDR_SUBSET 3
19.Os
20.Sh NAME
21.Nm X509v3_addr_subset ,
22.Nm X509v3_asid_subset
23.Nd RFC 3779 subset relationship
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft int
27.Fn X509v3_addr_subset "IPAddrBlocks *child" "IPAddrBlocks *parent"
28.Ft int
29.Fn X509v3_asid_subset "ASIdentifiers *child" "ASIdentifiers *parent"
30.Sh DESCRIPTION
31.Fn X509v3_addr_subset
32determines if all IP address resources present in
33.Fa child
34are contained in the corresponding resources in
35.Fa parent .
36.Pp
37The implementation assumes but does not ensure that both
38.Fa child
39and
40.Fa parent
41are in canonical form as described in
42.Xr X509v3_addr_is_canonical 3 .
43In particular, both
44.Fa child
45and
46.Fa parent
47are sorted appropriately and they contain at most one
48.Vt IPAddressFamily
49object per address family identifier (AFI) and optional
50subsequent address family identifier (SAFI).
51.Pp
52The checks are, in order:
53.Bl -enum
54.It
55If
56.Fa child
57is
58.Dv NULL
59or identical to
60.Fa parent
61then
62.Fa child
63is a subset of
64.Fa parent .
65In particular, a
66.Dv NULL
67.Fa parent
68is allowed for a
69.Dv NULL
70.Fa child .
71.It
72If
73.Fa parent
74is
75.Dv NULL
76then
77.Fa child
78is not a subset of
79.Fa parent .
80.It
81If
82.Xr X509v3_addr_inherits 3
83determines that
84.Fa child
85inherits or that
86.Fa parent
87inherits
88then
89.Fa child
90is not a subset of
91.Fa parent .
92.It
93Each address prefix or range in
94.Fa child
95must be a subset of an address prefix or range in the
96.Fa parent ,
97taking AFI and optional SAFI into account:
98.Bl -bullet -compact
99.It
100For each
101.Vt IPAddressFamily
102of
103.Fa child
104there must be an
105.Vt IPAddressFamily
106of
107.Fa parent
108with the same AFI and optional SAFI.
109.It
110Since the address prefixes and ranges in corresponding
111.Vt IPAddressFamily
112objects in
113.Fa child
114and
115.Fa parent
116are sorted in ascending order,
117and do not overlap,
118they can be traversed simultaneously in linear time.
119For each prefix or range in
120.Fa child
121there must be a prefix or range in
122.Fa parent
123whose minimal address is smaller
124and whose maximal address is larger.
125.El
126If any of these steps fails,
127.Fa child
128is not a subset of
129.Fa parent .
130.El
131.Pp
132.Fn X509v3_asid_subset
133determines if all AS identifier resources in
134.Fa child
135are contained in the corresponding resources in
136.Fa parent .
137.Pp
138The description for
139.Fn X509v3_addr_subset
140applies mutatis mutandis.
141In particular,
142.Fa child
143and
144.Fa parent
145must be in canonical form per
146.Xr X509v3_asid_is_canonical 3 ,
147but this is not enforced.
148.Sh RETURN VALUES
149.Fn X509v3_addr_subset
150and
151.Fn X509v3_asid_subset
152return 1 if and only if
153.Fa child
154is a subset of
155.Fa parent ,
156otherwise they return 0.
157If both
158.Fa child
159and
160.Fa parent
161are in canonical form,
162these functions cannot fail.
163.Sh SEE ALSO
164.Xr ASIdentifiers_new 3 ,
165.Xr ASRange_new 3 ,
166.Xr crypto 3 ,
167.Xr IPAddressRange_new 3 ,
168.Xr X509_new 3 ,
169.Xr X509v3_addr_add_inherit 3 ,
170.Xr X509v3_asid_add_inherit 3
171.Sh STANDARDS
172RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers.
173.Sh HISTORY
174These functions first appeared in OpenSSL 0.9.8e
175and have been available since
176.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/X509v3_addr_validate_path.3 b/src/lib/libcrypto/man/X509v3_addr_validate_path.3
deleted file mode 100644
index fe6065d599..0000000000
--- a/src/lib/libcrypto/man/X509v3_addr_validate_path.3
+++ /dev/null
@@ -1,203 +0,0 @@
1.\" $OpenBSD: X509v3_addr_validate_path.3,v 1.5 2023/09/30 19:07:38 tb Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 30 2023 $
18.Dt X509V3_ADDR_VALIDATE_PATH 3
19.Os
20.Sh NAME
21.Nm X509v3_addr_validate_path ,
22.Nm X509v3_addr_validate_resource_set ,
23.Nm X509v3_asid_validate_path ,
24.Nm X509v3_asid_validate_resource_set
25.Nd RFC 3779 path validation for IP address and AS number delegation
26.Sh SYNOPSIS
27.In openssl/x509v3.h
28.Ft int
29.Fn X509v3_addr_validate_path "X509_STORE_CTX *ctx"
30.Ft int
31.Fo X509v3_addr_validate_resource_set
32.Fa "STACK_OF(X509) *chain"
33.Fa "IPAddrBlocks *addrblocks"
34.Fa "int allow_inherit"
35.Fc
36.Ft int
37.Fn X509v3_asid_validate_path "X509_STORE_CTX *ctx"
38.Ft int
39.Fo X509v3_asid_validate_resource_set
40.Fa "STACK_OF(X509) *chain"
41.Fa "ASIdentifiers *asid"
42.Fa "int allow_inherit"
43.Fc
44.Sh DESCRIPTION
45Both RFC 3779 extensions require additional checking in the certification
46path validation.
47.Bl -enum
48.It
49The initial set of allowed IP address and AS number resources is defined in
50the trust anchor, where inheritance is not allowed.
51.It
52An issuer may only delegate subsets of resources present in its
53RFC 3779 extensions or subsets of resources inherited from its issuer.
54.It
55If an RFC 3779 extension is present in a certificate,
56the same type of extension must also be present in its issuer.
57.It
58All RFC 3779 extensions
59appearing in the validation path must be in canonical form
60according to
61.Xr X509v3_addr_is_canonical 3
62and
63.Xr X509v3_asid_is_canonical 3 .
64.El
65.Pp
66.Fn X509v3_addr_validate_path
67and
68.Fn X509v3_asid_validate_path
69are called from
70.Xr X509_verify_cert 3
71as part of the verification chain building.
72On encountering an error or a violation of the above rules,
73.Fa error ,
74.Fa error_depth ,
75and
76.Fa current_cert
77are set on
78.Fa ctx
79and the verify callback is called with
80.Fa ok
81set to 0.
82.Dv X509_V_ERR_INVALID_EXTENSION
83indicates a non-canonical resource,
84.Dv X509_V_ERR_UNNESTED_RESOURCE
85indicates a violation of the other rules above.
86In rare circumstances, the error can be
87.Dv X509_V_ERR_UNSPECIFIED
88and for IP address resources
89.Dv X509_V_ERR_OUT_OF_MEM
90is also possible.
91.Pp
92.Fn X509v3_addr_validate_resource_set
93validates the resources in
94.Fa addrblocks
95against a specific certificate
96.Fa chain .
97After checking that
98.Fa addrblocks
99is canonical, its IP addresses are checked to be covered in
100the certificate at depth 0,
101then the chain is walked all the way to the trust anchor
102until an error or a violation of the above rules is encountered.
103.Fa addrblocks
104is allowed to use inheritance according to
105.Xr X509v3_addr_inherits 3
106if and only if
107.Fa allow_inherit
108is non-zero.
109.Pp
110.Fn X509v3_asid_validate_resource_set
111performs similar checks as
112.Fn X509v3_addr_validate_resource_set
113for
114.Fa asid .
115.Sh RETURN VALUES
116All these functions return 1 on successful validation and 0 otherwise.
117.Pp
118For
119.Fn X509v3_addr_validate_path
120and
121.Fn X509v3_asid_validate_path
122a non-empty
123.Fa chain
124and a
125.Fa verify_cb
126must be present on
127.Fa ctx ,
128otherwise they fail and set the
129.Fa error
130on
131.Fa ctx
132to
133.Dv X509_V_ERR_UNSPECIFIED .
134The
135.Fa verify_cb
136is called with the error codes described above
137on most errors encountered during validation.
138Some malformed extensions can lead to an error
139that cannot be intercepted by the callback.
140With the exception of an allocation error,
141no error codes are set on the error stack.
142.Pp
143.Fn X509v3_addr_validate_resource_set
144accepts a
145.Dv NULL
146.Fa addrblocks
147and
148.Fn X509v3_asid_validate_resource_set
149accepts a
150.Dv NULL
151.Fa asid
152as valid.
153They fail if
154.Fa chain
155is
156.Dv NULL
157or empty.
158If
159.Fa allow_inherit
160is 0,
161.Fa addrblocks
162or
163.Fa asid
164is checked for inheritance with
165.Xr X509v3_addr_inherits 3
166or
167.Xr X509v3_asid_inherits 3 .
168The remaining failure cases are the same as for
169.Fn X509v3_addr_validate_path
170and
171.Fn X509v3_asid_validate_path .
172They cannot and do not attempt to communicate
173the cause of the error to the caller.
174.Sh SEE ALSO
175.Xr ASIdentifiers_new 3 ,
176.Xr crypto 3 ,
177.Xr IPAddressRange_new 3 ,
178.Xr X509_new 3 ,
179.Xr X509_STORE_CTX_get_error 3 ,
180.Xr X509_verify_cert 3 ,
181.Xr X509v3_addr_add_inherit 3 ,
182.Xr X509v3_addr_inherits 3 ,
183.Xr X509v3_asid_add_id_or_range 3
184.Sh STANDARDS
185RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers:
186.Bl -dash -compact
187.It
188section 2.3: IP Address Delegation Extension Certification Path Validation
189.It
190section 3.3: Autonomous System Identifier Delegation Extension Certification
191Path Validation
192.El
193.Pp
194RFC 5280: Internet X.509 Public Key Infrastructure Certificate
195and Certificate Revocation List (CRL) Profile
196.Bl -dash -compact
197.It
198section 6: Certification Path Validation
199.El
200.Sh HISTORY
201These functions first appeared in OpenSSL 0.9.8e
202and have been available since
203.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3 b/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3
deleted file mode 100644
index 81221ca9bc..0000000000
--- a/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3
+++ /dev/null
@@ -1,327 +0,0 @@
1.\" $OpenBSD: X509v3_asid_add_id_or_range.3,v 1.9 2023/09/30 18:16:44 tb Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 30 2023 $
18.Dt X509V3_ASID_ADD_ID_OR_RANGE 3
19.Os
20.Sh NAME
21.Nm X509v3_asid_add_id_or_range ,
22.Nm X509v3_asid_add_inherit ,
23.Nm X509v3_asid_canonize ,
24.Nm X509v3_asid_is_canonical
25.Nd RFC 3779 autonomous system identifier delegation extension
26.Sh SYNOPSIS
27.In openssl/x509v3.h
28.Ft int
29.Fo X509v3_asid_add_id_or_range
30.Fa "ASIdentifiers *asid"
31.Fa "int type"
32.Fa "ASN1_INTEGER *min"
33.Fa "ASN1_INTEGER *max"
34.Fc
35.Ft int
36.Fo X509v3_asid_add_inherit
37.Fa "ASIdentifiers *asid"
38.Fa "int type"
39.Fc
40.Ft int
41.Fo X509v3_asid_canonize
42.Fa "ASIdentifiers *asid"
43.Fc
44.Ft int
45.Fo X509v3_asid_is_canonical
46.Fa "ASIdentifiers *asid"
47.Fc
48.Sh DESCRIPTION
49An
50.Vt ASIdentifiers
51object represents the content of the certificate extension
52defined in RFC 3779, section 3.2.3.1.
53It can be instantiated with
54.Xr ASIdentifiers_new 3
55and its internals are documented in
56.Xr ASRange_new 3 .
57.Pp
58An autonomous system is identified by an unsigned 32-bit integer,
59called an AS identifier or AS number.
60An
61.Vt ASIdentifiers
62object can hold two lists:
63a list of
64.Fa type
65.Dv V3_ASID_ASNUM
66containing individual AS identifiers and ranges of AS identifiers,
67and an obsolete list of
68.Fa type
69.Dv V3_ASID_RDI
70containing routing domain identifiers (RDIs).
71Either of these lists may be absent, or it may contain nothing
72but a special
73.Dq inherit
74marker that indicates that the list is inherited from the issuer
75of the certificate.
76.Pp
77.Fn X509v3_asid_add_id_or_range
78adds an individual identifier or a range of identifiers to the list of
79.Fa type
80(either
81.Dv V3_ASID_ASNUM
82or
83.Dv V3_ASID_RDI )
84in
85.Fa asid .
86If no such list exists, it is created first.
87If a list of
88.Fa type
89already exists and contains the
90.Dq inherit
91marker, the call fails.
92.Fa min
93must be a
94.Pf non- Dv NULL
95.Vt ASN1_INTEGER .
96If
97.Fa max
98is
99.Dv NULL ,
100.Fa min
101is added as an individual identifier.
102Ownership of
103.Fa min
104and
105.Fa max
106is transferred to
107.Fa asid
108on success.
109It is the responsibility of the caller to ensure that
110the resulting
111.Fa asid
112does not contain lists with overlapping ranges and that
113.Fa min
114is strictly less than
115.Fa max
116if both are
117.Pf non- Dv NULL .
118The caller should also ensure that the AS identifiers are
11932-bit integers.
120Failure to do so may result in an
121.Fa asid
122that cannot be brought into canonical form by
123.Fn X509v3_asid_canonize .
124.Pp
125.Fn X509v3_asid_add_inherit
126adds the list of
127.Fa type
128(either
129.Dv V3_ASID_ASNUM
130or
131.Dv V3_ASID_RDI )
132in
133.Fa asid
134if necessary and marks it
135.Dq inherit .
136This fails if
137.Fa asid
138already contains a list of
139.Fa type
140that is not marked
141.Dq inherit .
142.Pp
143.Fn X509v3_asid_canonize
144attempts to bring both lists in
145.Fa asid
146into canonical form.
147If
148.Fa asid
149is
150.Dv NULL
151the call succeeds and no action occurs.
152A list is in canonical form if it is either one of
153.Bl -dash -compact
154.It
155absent,
156.It
157marked
158.Dq inherit ,
159.It
160non-empty and all identifiers and ranges are listed in increasing order.
161Ranges must not overlap,
162.\" the following is not currently specified and leads to ambiguity:
163.\" contain at least two elements,
164and adjacent ranges must be fully merged.
165.El
166.Pp
167.Fn X509v3_asid_canonize
168merges adjacent ranges
169but refuses to merge overlapping ranges or to discard duplicates.
170For example, the adjacent ranges [a,b] and [b+1,c] are merged
171into the single range [a,c], but if both [a,b] and [b,c] appear in a list,
172this results in an error since they are considered overlapping.
173Likewise, the identifier a is absorbed into the adjacent
174range [a+1,b] to yield [a,b].
175.Fn X509v3_asid_canonize
176errors if the minimum of any range is larger than the maximum.
177In contrast, minimum and maximum of a range may be equal.
178.Pp
179.Fn X509v3_asid_is_canonical
180checks whether
181.Fa asid
182is in canonical form.
183Once
184.Fn X509v3_asid_canonize
185is called successfully on
186.Fa asid ,
187all subsequent calls to
188.Fn X509v3_asid_is_canonical
189succeed on an unmodified
190.Fa asid
191unless memory allocation fails.
192.Sh RETURN VALUES
193All these functions return 1 on success and 0 on failure.
194.Pp
195.Fn X509v3_asid_add_id_or_range
196and
197.Fn X509v3_asid_add_inherit
198fail if
199.Fa asid
200is
201.Dv NULL
202or if
203.Fa type
204is distinct from
205.Dv V3_ASID_ASNUM
206and
207.Dv V3_ASID_RDI ,
208or on memory allocation failure.
209In addition,
210.Fn X509v3_asid_add_id_or_range
211fails if
212.Fa asid
213contains a list of
214.Fa type
215that is marked
216.Dq inherit ,
217and
218.Fn X509v3_asid_add_inherit
219fails if
220.Fa asid
221contains a list of
222.Fa type
223that is not marked
224.Dq inherit .
225.Pp
226.Fn X509v3_asid_canonize
227fails if either list is empty and not marked
228.Dq inherit ,
229or if it is malformed, or if memory allocation fails.
230Malformed lists include lists containing duplicate, overlapping,
231or malformed elements, for example AS ranges where the minimum is
232larger than the maximum.
233Some of these failure modes result in an error being pushed onto the
234error stack.
235.Pp
236.Fn X509v3_asid_is_canonical
237returns 1 if
238.Fa asid
239is canonical and 0 if it is not canonical or on memory allocation
240failure.
241.Sh SEE ALSO
242.Xr ASIdentifiers_new 3 ,
243.Xr crypto 3 ,
244.Xr s2i_ASN1_INTEGER 3 ,
245.Xr X509_new 3 ,
246.Xr X509v3_addr_add_inherit 3 ,
247.Xr X509v3_addr_validate_path 3
248.Sh STANDARDS
249RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers,
250.Bl -dash -compact
251.It
252section 3: Autonomous System Delegation Extension
253.El
254.Pp
255.Rs
256.%T Autonomous System (AS) Numbers
257.%U https://www.iana.org/assignments/as-numbers
258.Re
259.Sh HISTORY
260These functions first appeared in OpenSSL 0.9.8e
261and have been available since
262.Ox 7.1 .
263.Sh BUGS
264.Fn X509v3_asid_add_id_or_range
265does not check for inverted range bounds and overlaps
266on insertion.
267It is very easy to create an
268.Fa asid
269that fails to be canonized by
270.Fn X509v3_asid_canonize
271and it is very hard to diagnose why.
272.Pp
273Both
274.Fn X509v3_asid_add_id_or_range
275and
276.Fn X509v3_asid_add_inherit
277can leave
278.Fa asid
279in a corrupted state if memory allocation fails during their execution.
280In addition,
281.Fn X509v3_asid_add_id_or_range
282may already have freed the
283.Fa min
284and
285.Fa max
286arguments on failure.
287.Pp
288RFC 3779 does not explicitly disallow ranges where the minimum
289is equal to the maximum.
290The isolated AS identifier
291.Fa min
292and the AS range
293.Bq Fa min , Ns Fa min
294where the minimum and the maximum are equal to
295.Fa min
296have the same semantics.
297.Fn X509v3_asid_is_canonical
298accepts both representations as valid and
299.Fn X509v3_asid_canonize
300does not prefer either representation over the other.
301The encodings of the two representations produced by
302.Xr i2d_ASIdentifiers 3
303are distinct.
304.Pp
305.Fn X509v3_asid_is_canonical
306does not fully check inheriting lists to be well formed.
307It only checks the
308.Fa type
309to be
310.Dv ASIdentifierChoice_inherit
311and ignores the presence or absence of the
312.Fa inherit
313element.
314.Fn X509v3_asid_canonize
315does not fix that up.
316This can lead to incorrect or unexpected DER encoding of
317.Dq canonical
318.Vt ASIdentifiers
319objects.
320In particular, it is possible to construct an
321.Vt ASIdentifiers
322object for which both
323.Fn X509v3_asid_is_canonical
324and
325.Xr X509v3_asid_inherits 3
326return 1, and after a round trip through DER the latter
327returns 0.
diff --git a/src/lib/libcrypto/man/X509v3_get_ext_by_NID.3 b/src/lib/libcrypto/man/X509v3_get_ext_by_NID.3
deleted file mode 100644
index 8c7c159f80..0000000000
--- a/src/lib/libcrypto/man/X509v3_get_ext_by_NID.3
+++ /dev/null
@@ -1,408 +0,0 @@
1.\" $OpenBSD: X509v3_get_ext_by_NID.3,v 1.15 2024/05/22 09:44:10 tb Exp $
2.\" full merge up to: OpenSSL fd38836b Jun 20 15:25:43 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: May 22 2024 $
52.Dt X509V3_GET_EXT_BY_NID 3
53.Os
54.Sh NAME
55.Nm X509v3_get_ext_count ,
56.Nm X509v3_get_ext ,
57.Nm X509v3_get_ext_by_NID ,
58.Nm X509v3_get_ext_by_OBJ ,
59.Nm X509v3_get_ext_by_critical ,
60.Nm X509v3_delete_ext ,
61.Nm X509v3_add_ext ,
62.Nm X509_get_ext_count ,
63.Nm X509_get_ext ,
64.Nm X509_get_ext_by_NID ,
65.Nm X509_get_ext_by_OBJ ,
66.Nm X509_get_ext_by_critical ,
67.Nm X509_delete_ext ,
68.Nm X509_add_ext ,
69.Nm X509_CRL_get_ext_count ,
70.Nm X509_CRL_get_ext ,
71.Nm X509_CRL_get_ext_by_NID ,
72.Nm X509_CRL_get_ext_by_OBJ ,
73.Nm X509_CRL_get_ext_by_critical ,
74.Nm X509_CRL_delete_ext ,
75.Nm X509_CRL_add_ext ,
76.Nm X509_REVOKED_get_ext_count ,
77.Nm X509_REVOKED_get_ext ,
78.Nm X509_REVOKED_get_ext_by_NID ,
79.Nm X509_REVOKED_get_ext_by_OBJ ,
80.Nm X509_REVOKED_get_ext_by_critical ,
81.Nm X509_REVOKED_delete_ext ,
82.Nm X509_REVOKED_add_ext
83.Nd extension stack utility functions
84.Sh SYNOPSIS
85.In openssl/x509.h
86.Ft int
87.Fo X509v3_get_ext_count
88.Fa "const STACK_OF(X509_EXTENSION) *x"
89.Fc
90.Ft X509_EXTENSION *
91.Fo X509v3_get_ext
92.Fa "const STACK_OF(X509_EXTENSION) *x"
93.Fa "int loc"
94.Fc
95.Ft int
96.Fo X509v3_get_ext_by_NID
97.Fa "const STACK_OF(X509_EXTENSION) *x"
98.Fa "int nid"
99.Fa "int lastpos"
100.Fc
101.Ft int
102.Fo X509v3_get_ext_by_OBJ
103.Fa "const STACK_OF(X509_EXTENSION) *x"
104.Fa "const ASN1_OBJECT *obj"
105.Fa "int lastpos"
106.Fc
107.Ft int
108.Fo X509v3_get_ext_by_critical
109.Fa "const STACK_OF(X509_EXTENSION) *x"
110.Fa "int crit"
111.Fa "int lastpos"
112.Fc
113.Ft X509_EXTENSION *
114.Fo X509v3_delete_ext
115.Fa "STACK_OF(X509_EXTENSION) *x"
116.Fa "int loc"
117.Fc
118.Ft STACK_OF(X509_EXTENSION) *
119.Fo X509v3_add_ext
120.Fa "STACK_OF(X509_EXTENSION) **x"
121.Fa "X509_EXTENSION *ex"
122.Fa "int loc"
123.Fc
124.Ft int
125.Fo X509_get_ext_count
126.Fa "const X509 *x"
127.Fc
128.Ft X509_EXTENSION *
129.Fo X509_get_ext
130.Fa "const X509 *x"
131.Fa "int loc"
132.Fc
133.Ft int
134.Fo X509_get_ext_by_NID
135.Fa "const X509 *x"
136.Fa "int nid"
137.Fa "int lastpos"
138.Fc
139.Ft int
140.Fo X509_get_ext_by_OBJ
141.Fa "const X509 *x"
142.Fa "const ASN1_OBJECT *obj"
143.Fa "int lastpos"
144.Fc
145.Ft int
146.Fo X509_get_ext_by_critical
147.Fa "const X509 *x"
148.Fa "int crit"
149.Fa "int lastpos"
150.Fc
151.Ft X509_EXTENSION *
152.Fo X509_delete_ext
153.Fa "X509 *x"
154.Fa "int loc"
155.Fc
156.Ft int
157.Fo X509_add_ext
158.Fa "X509 *x"
159.Fa "X509_EXTENSION *ex"
160.Fa "int loc"
161.Fc
162.Ft int
163.Fo X509_CRL_get_ext_count
164.Fa "const X509_CRL *x"
165.Fc
166.Ft X509_EXTENSION *
167.Fo X509_CRL_get_ext
168.Fa "const X509_CRL *x"
169.Fa "int loc"
170.Fc
171.Ft int
172.Fo X509_CRL_get_ext_by_NID
173.Fa "const X509_CRL *x"
174.Fa "int nid"
175.Fa "int lastpos"
176.Fc
177.Ft int
178.Fo X509_CRL_get_ext_by_OBJ
179.Fa "const X509_CRL *x"
180.Fa "const ASN1_OBJECT *obj"
181.Fa "int lastpos"
182.Fc
183.Ft int
184.Fo X509_CRL_get_ext_by_critical
185.Fa "const X509_CRL *x"
186.Fa "int crit"
187.Fa "int lastpos"
188.Fc
189.Ft X509_EXTENSION *
190.Fo X509_CRL_delete_ext
191.Fa "X509_CRL *x"
192.Fa "int loc"
193.Fc
194.Ft int
195.Fo X509_CRL_add_ext
196.Fa "X509_CRL *x"
197.Fa "X509_EXTENSION *ex"
198.Fa "int loc"
199.Fc
200.Ft int
201.Fo X509_REVOKED_get_ext_count
202.Fa "const X509_REVOKED *x"
203.Fc
204.Ft X509_EXTENSION *
205.Fo X509_REVOKED_get_ext
206.Fa "const X509_REVOKED *x"
207.Fa "int loc"
208.Fc
209.Ft int
210.Fo X509_REVOKED_get_ext_by_NID
211.Fa "const X509_REVOKED *x"
212.Fa "int nid"
213.Fa "int lastpos"
214.Fc
215.Ft int
216.Fo X509_REVOKED_get_ext_by_OBJ
217.Fa "const X509_REVOKED *x"
218.Fa "const ASN1_OBJECT *obj"
219.Fa "int lastpos"
220.Fc
221.Ft int
222.Fo X509_REVOKED_get_ext_by_critical
223.Fa "const X509_REVOKED *x"
224.Fa "int crit"
225.Fa "int lastpos"
226.Fc
227.Ft X509_EXTENSION *
228.Fo X509_REVOKED_delete_ext
229.Fa "X509_REVOKED *x"
230.Fa "int loc"
231.Fc
232.Ft int
233.Fo X509_REVOKED_add_ext
234.Fa "X509_REVOKED *x"
235.Fa "X509_EXTENSION *ex"
236.Fa "int loc"
237.Fc
238.Sh DESCRIPTION
239.Fn X509v3_get_ext_count
240retrieves the number of extensions in
241.Fa x .
242.Pp
243.Fn X509v3_get_ext
244retrieves extension
245.Fa loc
246from
247.Fa x .
248The index
249.Fa loc
250can take any value from 0 to
251.Fn X509_get_ext_count x No \- 1 .
252The returned extension is an internal pointer which must not be
253freed up by the application.
254.Pp
255.Fn X509v3_get_ext_by_NID
256and
257.Fn X509v3_get_ext_by_OBJ
258look for an extension with
259.Fa nid
260or
261.Fa obj
262from extension stack
263.Fa x .
264The search starts from the extension after
265.Fa lastpos
266or from the beginning if
267.Fa lastpos
268is \-1.
269If the extension is found, its index is returned; otherwise, a negative
270value is returned.
271.Pp
272.Fn X509v3_get_ext_by_critical
273is similar to
274.Fn X509v3_get_ext_by_NID
275except that it looks for an extension of criticality
276.Fa crit .
277A zero value for
278.Fa crit
279looks for a non-critical extension; a non-zero value looks for a
280critical extension.
281.Pp
282.Fn X509v3_delete_ext
283deletes the extension with index
284.Fa loc
285from
286.Fa x .
287The deleted extension is returned and must be freed by the caller.
288If
289.Fa loc
290is an invalid index value,
291.Dv NULL
292is returned.
293.Pp
294.Fn X509v3_add_ext
295adds the extension
296.Fa ex
297to the stack
298.Pf * Fa x
299at position
300.Fa loc .
301If
302.Fa loc
303is \-1, the new extension is added to the end.
304If
305.Pf * Fa x
306is
307.Dv NULL ,
308a new stack will be allocated.
309The passed extension
310.Fa ex
311is duplicated internally so it must be freed after use.
312.Pp
313.Fn X509_get_ext_count ,
314.Fn X509_get_ext ,
315.Fn X509_get_ext_by_NID ,
316.Fn X509_get_ext_by_OBJ ,
317.Fn X509_get_ext_by_critical ,
318.Fn X509_delete_ext ,
319and
320.Fn X509_add_ext
321operate on the extensions of certificate
322.Fa x .
323They are otherwise identical to the X509v3 functions.
324.Pp
325.Fn X509_CRL_get_ext_count ,
326.Fn X509_CRL_get_ext ,
327.Fn X509_CRL_get_ext_by_NID ,
328.Fn X509_CRL_get_ext_by_OBJ ,
329.Fn X509_CRL_get_ext_by_critical ,
330.Fn X509_CRL_delete_ext ,
331and
332.Fn X509_CRL_add_ext
333operate on the extensions of the CRL
334.Fa x .
335They are otherwise identical to the X509v3 functions.
336.Pp
337.Fn X509_REVOKED_get_ext_count ,
338.Fn X509_REVOKED_get_ext ,
339.Fn X509_REVOKED_get_ext_by_NID ,
340.Fn X509_REVOKED_get_ext_by_OBJ ,
341.Fn X509_REVOKED_get_ext_by_critical ,
342.Fn X509_REVOKED_delete_ext ,
343and
344.Fn X509_REVOKED_add_ext
345operate on the extensions of the CRL entry
346.Fa x .
347They are otherwise identical to the X509v3 functions.
348.Pp
349These functions are used to examine stacks of extensions directly.
350Many applications will want to parse or encode and add an extension:
351they should use the extension encode and decode functions instead
352such as
353.Xr X509_get_ext_d2i 3 .
354.Pp
355Extension indices start from zero, so a zero index return value is
356not an error.
357These search functions start from the extension
358.Em after
359the
360.Fa lastpos
361parameter, so it should initially be set to \-1.
362If it is set to 0, the initial extension will not be checked.
363.Sh RETURN VALUES
364.Fn X509v3_get_ext_count
365returns the extension count.
366.Pp
367.Fn X509v3_get_ext ,
368.Fn X509v3_delete_ext ,
369and
370.Fn X509_delete_ext
371return an
372.Vt X509_EXTENSION
373pointer or
374.Dv NULL
375if an error occurs.
376.Pp
377.Fn X509v3_get_ext_by_NID ,
378.Fn X509v3_get_ext_by_OBJ ,
379and
380.Fn X509v3_get_ext_by_critical
381return the extension index or \-1 if an error occurs.
382In addition,
383.Fn X509v3_get_ext_by_NID
384returns \-2 if
385.Xr OBJ_nid2obj 3
386fails on the requested
387.Fa nid .
388.Pp
389.Fn X509v3_add_ext
390returns a stack of extensions or
391.Dv NULL
392on error.
393.Pp
394.Fn X509_add_ext
395returns 1 on success or 0 on error.
396.Sh SEE ALSO
397.Xr OBJ_nid2obj 3 ,
398.Xr X509_CRL_new 3 ,
399.Xr X509_EXTENSION_new 3 ,
400.Xr X509_new 3 ,
401.Xr X509_REVOKED_new 3 ,
402.Xr X509V3_EXT_print 3 ,
403.Xr X509V3_extensions_print 3 ,
404.Xr X509V3_get_d2i 3
405.Sh HISTORY
406These functions first appeared in SSLeay 0.8.0
407and have been available since
408.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/a2d_ASN1_OBJECT.3 b/src/lib/libcrypto/man/a2d_ASN1_OBJECT.3
deleted file mode 100644
index 7d36a54be2..0000000000
--- a/src/lib/libcrypto/man/a2d_ASN1_OBJECT.3
+++ /dev/null
@@ -1,84 +0,0 @@
1.\" $OpenBSD: a2d_ASN1_OBJECT.3,v 1.3 2023/08/09 17:34:39 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: August 9 2023 $
18.Dt A2D_ASN1_OBJECT 3
19.Os
20.Sh NAME
21.Nm a2d_ASN1_OBJECT
22.Nd DER content octets of an ASN.1 object identifier
23.Sh SYNOPSIS
24.In openssl/asn1.h
25.Ft int
26.Fo a2d_ASN1_OBJECT
27.Fa "unsigned char *der_out"
28.Fa "int olen"
29.Fa "const char *val_in"
30.Fa "int ilen"
31.Fc
32.Sh DESCRIPTION
33.Fn a2d_ASN1_OBJECT
34accepts an ASCII string
35.Fa val_in
36of
37.Fa ilen
38bytes and interprets it as the numerical form of an ASN.1 object identifier.
39It writes the content octets of the DER encoding of the object identifier
40to the buffer
41.Fa der_out
42which is
43.Fa olen
44bytes long.
45The identifier and length octets of the DER encoding are not written.
46.Pp
47If
48.Fa ilen
49is \-1, the
50.Xr strlen 3
51of
52.Fa val_in
53is used instead.
54.Pp
55If
56.Fa der_out
57is a
58.Dv NULL
59pointer, writing the content octets is skipped
60and only the return value is calculated.
61.Sh RETURN VALUES
62.Fn a2d_ASN1_OBJECT
63returns the number of content octets that were or would be written or 0 if
64.Fa ilen
65is 0, if
66.Fa val_in
67is not a valid representation of an object identifier,
68if memory allocation fails, or if the number of content octets
69would be larger than
70.Fa olen .
71.Sh SEE ALSO
72.Xr ASN1_OBJECT_new 3 ,
73.Xr i2d_ASN1_OBJECT 3 ,
74.Xr OBJ_create 3
75.Sh STANDARDS
76ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
77Information technology - ASN.1 encoding rules:
78Specification of Basic Encoding Rules (BER), Canonical Encoding
79Rules (CER) and Distinguished Encoding Rules (DER),
80section 8.19: Encoding of an object identifier value
81.Sh HISTORY
82.Fn a2d_ASN1_OBJECT
83first appeared in SSLeay 0.8.0 and has been available since
84.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/a2i_ipadd.3 b/src/lib/libcrypto/man/a2i_ipadd.3
deleted file mode 100644
index 1372b2acfd..0000000000
--- a/src/lib/libcrypto/man/a2i_ipadd.3
+++ /dev/null
@@ -1,136 +0,0 @@
1.\" $OpenBSD: a2i_ipadd.3,v 1.1 2024/12/27 15:30:17 schwarze Exp $
2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 27 2024 $
18.Dt A2I_IPADD 3
19.Os
20.Sh NAME
21.Nm a2i_ipadd ,
22.Nm a2i_IPADDRESS ,
23.Nm a2i_IPADDRESS_NC
24.Nd parse Internet Protocol addresses into ASN.1 OCTET STRINGs for X.509
25.Sh SYNOPSIS
26.In openssl/x509v3.h
27.Ft int
28.Fo a2i_ipadd
29.Fa "unsigned char *ipout"
30.Fa "const char *ipasc"
31.Fc
32.Ft ASN1_OCTET_STRING *
33.Fo a2i_IPADDRESS
34.Fa "const char *ipasc"
35.Fc
36.Ft ASN1_OCTET_STRING *
37.Fo a2i_IPADDRESS_NC
38.Fa "const char *ipasc"
39.Fc
40.Sh DESCRIPTION
41.Fn a2i_ipadd
42and
43.Fn a2i_IPADDRESS
44parse the string
45.Fa ipasc
46containing an IPv4 or IPv6 address
47in one of the following formats:
48.Bd -literal -offset indent
49d.d.d.d
50x:x:x:x:x:x:x:x (exactly 8 words)
51(x:)*x::x(:x)* (less than 8 words)
52(x:)*x:: (less than 8 words)
53::x(:x)* (less than 8 words)
54::
55(x:)*d.d.d.d (up to 6 hexadecimal words, :: can be used)
56.Ed
57.Pp
58where each
59.Ar d
60represents a non-negative decimal number less than 256
61with one, two or three digits and each
62.Ar x
63represents a non-negative hexadecimal number
64with one, two, three, or four digits.
65Both the lower case letters a-f and the upper case letters A-F can be used.
66.Pp
67.Fn a2i_ipadd
68stores the bytes of the address in network byte order (big endian) starting at
69.Fa ipout .
70The caller is responsible for providing sufficient space;
71always providing a buffer of at least 16 bytes is recommended,
72even if an IPv4 address is expected, to avoid buffer overruns in case
73.Fa ipasc
74is malformed.
75.Pp
76.Fn a2i_IPADDRESS
77stores the address in a newly allocated ASN.1
78.Vt OCTET STRING .
79.Pp
80.Fn a2i_IPADDRESS_NC
81expects
82.Fa ipasc
83to contain two addresses of the same address family in the above form,
84separated by a slash
85.Pq Sq /
86character, and stores the concatenation of both addresses
87in a newly allocated ASN.1
88.Vt OCTET STRING ,
89which is typically used for address/mask pairs
90in name constraint extensions of CA certificates.
91.Sh RETURN VALUES
92.Fn a2i_ipadd
93returns the number of bytes written to
94.Fa ipout
95in case of success, i.e. 4 for an IPv4 or 16 for an IPv6 address,
96or 0 if parsing failed.
97.Pp
98.Fn a2i_IPADDRESS
99and
100.Fn a2i_IPADDRESS_NC
101return the new object or
102.Dv NULL
103if parsing or memory allocation failed.
104.Sh SEE ALSO
105.Xr a2i_ASN1_STRING 3 ,
106.Xr ASN1_OCTET_STRING_new 3 ,
107.Xr ASN1_OCTET_STRING_set 3 ,
108.Xr GENERAL_NAME_new 3 ,
109.Xr IPAddressRange_new 3 ,
110.Xr NAME_CONSTRAINTS_new 3 ,
111.Xr s2i_ASN1_OCTET_STRING 3 ,
112.Xr X509_EXTENSION_new 3
113.Sh STANDARDS
114RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
115Certificate Revocation List (CRL) Profile
116.Bl -dash -width 1n -compact
117.It
118section 4.2.1.6: Subject Alternative Name
119.It
120section 4.2.1.10: Name Constraints
121.El
122.Sh HISTORY
123.Fn a2i_IPADDRESS
124and
125.Fn a2i_IPADDRESS_NC
126first appeared in OpenSSL 0.9.8 and
127.Fn a2i_ipadd
128in OpenSSL 0.9.8e.
129They have been available since
130.Ox 4.5 .
131.Sh CAVEATS
132While some syntax errors are caught, only minimal validation takes place,
133and these functions often return objects that make no sense, in particular
134in the context of IPv6.
135For example, the trailing :d.d.d.d syntax can be appended
136to a hexadecimal part that results in twelve arbitrary bytes.
diff --git a/src/lib/libcrypto/man/bn_dump.3 b/src/lib/libcrypto/man/bn_dump.3
deleted file mode 100644
index b4272441e5..0000000000
--- a/src/lib/libcrypto/man/bn_dump.3
+++ /dev/null
@@ -1,415 +0,0 @@
1.\" $OpenBSD: bn_dump.3,v 1.9 2023/11/16 18:10:19 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL crypto/bn/README.pod aebb9aac Jul 19 09:27:53 2016 -0400
4.\"
5.\" This file was written by Ulf Moeller <ulf@openssl.org>.
6.\" Copyright (c) 2000, 2003, 2006, 2009 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: November 16 2023 $
54.Dt BN_DUMP 3
55.Os
56.Sh NAME
57.Nm bn_mul_words ,
58.Nm bn_mul_add_words ,
59.Nm bn_sqr_words ,
60.Nm bn_div_words ,
61.Nm bn_add_words ,
62.Nm bn_sub_words ,
63.Nm bn_mul_comba4 ,
64.Nm bn_mul_comba8 ,
65.Nm bn_sqr_comba4 ,
66.Nm bn_sqr_comba8 ,
67.Nm bn_mul_normal ,
68.Nm bn_expand ,
69.Nm bn_wexpand
70.Nd BIGNUM library internal functions
71.Sh SYNOPSIS
72.Fd #include "bn_local.h"
73.Ft BN_ULONG
74.Fo bn_mul_words
75.Fa "BN_ULONG *rp"
76.Fa "BN_ULONG *ap"
77.Fa "int num"
78.Fa "BN_ULONG w"
79.Fc
80.Ft BN_ULONG
81.Fo bn_mul_add_words
82.Fa "BN_ULONG *rp"
83.Fa "BN_ULONG *ap"
84.Fa "int num"
85.Fa "BN_ULONG w"
86.Fc
87.Ft void
88.Fo bn_sqr_words
89.Fa "BN_ULONG *rp"
90.Fa "BN_ULONG *ap"
91.Fa "int num"
92.Fc
93.Ft BN_ULONG
94.Fo bn_div_words
95.Fa "BN_ULONG h"
96.Fa "BN_ULONG l"
97.Fa "BN_ULONG d"
98.Fc
99.Ft BN_ULONG
100.Fo bn_add_words
101.Fa "BN_ULONG *rp"
102.Fa "BN_ULONG *ap"
103.Fa "BN_ULONG *bp"
104.Fa "int num"
105.Fc
106.Ft BN_ULONG
107.Fo bn_sub_words
108.Fa "BN_ULONG *rp"
109.Fa "BN_ULONG *ap"
110.Fa "BN_ULONG *bp"
111.Fa "int num"
112.Fc
113.Ft void
114.Fo bn_mul_comba4
115.Fa "BN_ULONG *r"
116.Fa "BN_ULONG *a"
117.Fa "BN_ULONG *b"
118.Fc
119.Ft void
120.Fo bn_mul_comba8
121.Fa "BN_ULONG *r"
122.Fa "BN_ULONG *a"
123.Fa "BN_ULONG *b"
124.Fc
125.Ft void
126.Fo bn_sqr_comba4
127.Fa "BN_ULONG *r"
128.Fa "BN_ULONG *a"
129.Fc
130.Ft void
131.Fo bn_sqr_comba8
132.Fa "BN_ULONG *r"
133.Fa "BN_ULONG *a"
134.Fc
135.Ft void
136.Fo bn_mul_normal
137.Fa "BN_ULONG *r"
138.Fa "BN_ULONG *a"
139.Fa "int na"
140.Fa "BN_ULONG *b"
141.Fa "int nb"
142.Fc
143.Ft BIGNUM *
144.Fo bn_expand
145.Fa "BIGNUM *a"
146.Fa "int bits"
147.Fc
148.Ft BIGNUM *
149.Fo bn_wexpand
150.Fa "BIGNUM *a"
151.Fa "int n"
152.Fc
153.Sh DESCRIPTION
154This page documents some internal functions used by the
155.Vt BIGNUM
156implementation.
157They are described here to facilitate debugging and extending the
158library.
159They are
160.Em not
161to be used by applications.
162.Ss The BIGNUM structure
163.Bd -literal
164typedef struct bignum_st BIGNUM;
165
166struct bignum_st {
167 BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
168 int top; /* Index of last used d +1. */
169 /* The next are internal book keeping for bn_expand. */
170 int dmax; /* Size of the d array. */
171 int neg; /* one if the number is negative */
172 int flags;
173};
174.Ed
175.Pp
176The integer value is stored in
177.Fa d ,
178a
179.Xr malloc 3 Ap ed
180array of words
181.Pq Vt BN_ULONG ,
182least significant word first.
183.Vt BN_ULONG
184is a macro that expands to
185.Vt unsigned long Pq = Vt uint64_t
186on
187.Dv _LP64
188platforms and
189.Vt unsigned int Pq = Vt uint32_t
190elsewhere.
191.Pp
192.Fa dmax
193is the size of the
194.Fa d
195array that has been allocated.
196.Fa top
197is the number of words being used, so for a value of 4, bn.d[0]=4 and
198bn.top=1.
199.Fa neg
200is 1 if the number is negative.
201When a
202.Vt BIGNUM
203is 0, the
204.Fa d
205field can be
206.Dv NULL
207and
208.Fa top
209== 0.
210.Pp
211.Fa flags
212is a bit field of flags which are defined in
213.In openssl/bn.h .
214The flags begin with
215.Dv BN_FLG_ .
216The functions
217.Xr BN_set_flags 3
218and
219.Xr BN_get_flags 3
220enable or inspect
221.Fa flags .
222.Pp
223Various routines in this library require the use of temporary
224.Vt BIGNUM
225variables during their execution.
226Since dynamic memory allocation to create
227.Vt BIGNUM Ns s
228is rather expensive when used in conjunction with repeated subroutine
229calls, the
230.Vt BN_CTX
231structure is used.
232This structure contains BN_CTX_NUM
233.Vt BIGNUM Ns s ;
234see
235.Xr BN_CTX_start 3 .
236.Ss Low level arithmetic operations
237These functions are implemented in C and for several platforms in
238assembly language:
239.Pp
240.Fn bn_mul_words rp ap num w
241operates on the
242.Fa num
243word arrays
244.Fa rp
245and
246.Fa ap .
247It computes
248.Fa ap
249*
250.Fa w ,
251places the result in
252.Fa rp ,
253and returns the high word (carry).
254.Pp
255.Fn bn_mul_add_words rp ap num w
256operates on the
257.Fa num
258word arrays
259.Fa rp
260and
261.Fa ap .
262It computes
263.Fa ap
264*
265.Fa w
266+
267.Fa rp ,
268places the result in
269.Fa rp ,
270and returns the high word (carry).
271.Pp
272.Fn bn_sqr_words rp ap num
273operates on the
274.Fa num
275word array
276.Fa ap
277and the
278.Pf 2* Fa num
279word array
280.Fa ap .
281It computes
282.Fa ap
283*
284.Fa ap
285word-wise, and places the low and high bytes of the result in
286.Fa rp .
287.Pp
288.Fn bn_div_words h l d
289divides the two word number
290.Pq Fa h , Fa l
291by
292.Fa d
293and returns the result.
294.Pp
295.Fn bn_add_words rp ap bp num
296operates on the
297.Fa num
298word arrays
299.Fa ap ,
300.Fa bp
301and
302.Fa rp .
303It computes
304.Fa ap
305+
306.Fa bp ,
307places the result in
308.Fa rp ,
309and returns the high word (carry).
310.Pp
311.Fn bn_sub_words rp ap bp num
312operates on the
313.Fa num
314word arrays
315.Fa ap ,
316.Fa bp
317and
318.Fa rp .
319It computes
320.Fa ap
321-
322.Fa bp ,
323places the result in
324.Fa rp ,
325and returns the carry (1 if
326.Fa bp
327\(ra
328.Fa ap ,
3290 otherwise).
330.Pp
331.Fn bn_mul_comba4 r a b
332operates on the 4 word arrays
333.Fa a
334and
335.Fa b
336and the 8-word array
337.Fa r .
338It computes
339.Fa a Ns * Ns Fa b
340and places the result in
341.Fa r .
342.Pp
343.Fn bn_mul_comba8 r a b
344operates on the 8-word arrays
345.Fa a
346and
347.Fa b
348and the 16-word array
349.Fa r .
350It computes
351.Fa a Ns * Ns Fa b
352and places the result in
353.Fa r .
354.Pp
355.Fn bn_sqr_comba4 r a b
356operates on the 4-word arrays
357.Fa a
358and
359.Fa b
360and the 8-word array
361.Fa r .
362.Pp
363.Fn bn_sqr_comba8 r a b
364operates on the 8-word arrays
365.Fa a
366and
367.Fa b
368and the 16 word array
369.Fa r .
370.Pp
371The following functions are implemented in C:
372.Pp
373.Fn bn_mul_normal r a na b nb
374operates on the
375.Fa na
376word array
377.Fa a ,
378the
379.Fa nb
380word array
381.Fa b
382and the
383.Fa na Ns + Ns Fa nb
384word array
385.Fa r .
386It computes
387.Fa a Ns * Ns Fa b
388and places the result in
389.Fa r .
390.Pp
391.Xr BN_mul 3
392calls
393.Fn bn_mul_comba4
394if both factors are 4 words long,
395.Fn bn_mul_comba8
396if both factors are 8 words long,
397or
398.Fn bn_mul_normal
399otherwise.
400.Ss Size changes
401.Fn bn_expand
402ensures that
403.Fa b
404has enough space for a
405.Fa bits
406bit number.
407.Fn bn_wexpand
408ensures that
409.Fa b
410has enough space for an
411.Fa n
412word number.
413They return 0 on error or 1 otherwise.
414.Sh SEE ALSO
415.Xr BN_new 3
diff --git a/src/lib/libcrypto/man/crypto.3 b/src/lib/libcrypto/man/crypto.3
deleted file mode 100644
index f1367e9e62..0000000000
--- a/src/lib/libcrypto/man/crypto.3
+++ /dev/null
@@ -1,419 +0,0 @@
1.\" $OpenBSD: crypto.3,v 1.30 2024/12/07 19:22:15 schwarze Exp $
2.\" OpenSSL a9c85cea Nov 11 09:33:55 2016 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ulf Moeller <ulf@openssl.org> and
22.\" Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000, 2002 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: December 7 2024 $
70.Dt CRYPTO 3
71.Os
72.Sh NAME
73.Nm crypto
74.Nd OpenSSL cryptographic library
75.Sh DESCRIPTION
76The OpenSSL crypto library implements a wide range of cryptographic
77algorithms used in various Internet standards.
78The services provided by this library are used by the OpenSSL
79implementations of TLS and S/MIME, and they have also been used to
80implement SSH, OpenPGP, and other cryptographic standards.
81.Pp
82.Sy Symmetric ciphers
83including AES, Blowfish, CAST, ChaCha20, IDEA, DES, RC2, and RC4
84are provided by the generic interface
85.Xr EVP_EncryptInit 3 .
86Low-level stand-alone interfaces include
87.Xr AES_encrypt 3 ,
88.Xr BF_set_key 3 ,
89.Xr ChaCha 3 ,
90.Xr DES_set_key 3 ,
91.Xr RC2_encrypt 3 ,
92and
93.Xr RC4 3 .
94.Pp
95.Sy Public key cryptography and key agreement
96are provided by
97.Xr DH_new 3 ,
98.Xr ECDH_compute_key 3 ,
99.Xr X25519 3 ,
100.Xr DSA_new 3 ,
101.Xr ECDSA_SIG_new 3 ,
102.Xr RSA_new 3 ,
103and
104.Xr EVP_PKEY_new 3 .
105.Pp
106.Sy Certificates
107are handled by
108.Xr X509_new 3
109and
110.Xr X509v3_add_ext 3 .
111.Pp
112.Sy Authentication codes and hash functions
113offered include
114.Xr EVP_DigestInit 3 ,
115.Xr CMAC_Init 3 ,
116.Xr HMAC 3 ,
117.Xr MD4 3 ,
118.Xr MD5 3 ,
119.Xr RIPEMD160 3 ,
120.Xr SHA1 3 ,
121and
122.Xr SHA256 3 .
123.Pp
124.Sy Input, output, and data encoding
125facilities include
126.Xr ASN1_TYPE_get 3 ,
127.Xr BIO_new 3 ,
128.Xr CMS_ContentInfo_new 3 ,
129.Xr evp 3 ,
130.Xr EVP_EncodeInit 3 ,
131.Xr PEM_read 3 ,
132.Xr PKCS7_encrypt 3 ,
133.Xr PKCS7_sign 3 ,
134.Xr PKCS12_create 3 ,
135and
136.Xr SMIME_write_PKCS7 3 .
137.Pp
138.Sy Auxiliary features include:
139.Bl -dash -compact
140.It
141configuration file handling: see
142.Xr OPENSSL_config 3
143.It
144error reporting: see
145.Xr ERR 3
146.It
147.Xr OCSP_REQUEST_new 3
148.It
149.Xr UI_new 3
150.El
151.Pp
152.Sy Internal utilities
153include
154.Xr BIO_f_buffer 3 ,
155.Xr BN_new 3 ,
156.Xr EC_GROUP_new 3 ,
157.Xr lh_new 3 ,
158and
159.Xr STACK_OF 3 .
160.Sh NAMING CONVENTIONS
161Elements used in the names of API functions include the following:
162.Bl -tag -width Ds
163.It add0
164See
165.Dq set0
166below.
167.It add1
168See
169.Dq set1
170below.
171.It BIO
172basic input and/or output abstraction:
173The function manipulates objects of the idiosyncratic OpenSSL
174.Vt BIO
175object type.
176See
177.Xr BIO_new 3 .
178.It bio
179The function uses a
180.Vt BIO
181object for input or output.
182In many cases, simpler variants of the function are available
183that operate directly on
184.In stdio.h
185.Vt FILE
186objects or directly in RAM, usually using byte arrays.
187.It BIO_f_
188filter BIO:
189The function returns a pointer to a static built-in object that,
190when passed to
191.Xr BIO_new 3 ,
192results in the creation of a BIO object that can write data to
193and/or read data from another
194.Vt BIO
195object.
196.It BIO_s_
197source and/or sink BIO:
198The function returns a pointer to a static built-in object that,
199when passed to
200.Xr BIO_new 3 ,
201results in the creation of a BIO object
202that can write data to an external destination
203and/or read data from an external source,
204for example a file descriptor or object, a memory buffer, or the network.
205.It BN
206big number:
207The function operates on
208.Vt BIGNUM
209objects representing integer numbers of variable, almost unlimited size.
210See
211.Xr BN_new 3 .
212.It cb
213callback:
214The function takes or returns a function pointer
215that is called by API functions from inside the library.
216The function pointed to may be defined by the application program.
217In some cases, API functions with
218.Dq cb
219in their name may return function pointers to internal functions
220defined inside the library that are not API functions.
221The element
222.Dq cb
223is also used in the names of some function pointer datatypes
224declared with
225.Sy typedef .
226In a small number of cases, the all caps form
227.Dq CB
228is used with the same meaning.
229.It CTX
230context:
231The function operates on a wrapper object around another object.
232The purposes and properties of such
233.Dq CTX
234wrapper objects vary wildly depending on the objects in question.
235A few function names use the lower case form
236.Dq ctx
237in the same sense.
238.It d2i
239DER to internal:
240The function decodes input conforming to ASN.1 basic encoding rules (BER)
241and either stores the result in an existing object
242or in a newly allocated object.
243The latter is usually preferable because
244creating a new object is more robust and less error prone.
245In spite of the name, the input usually does not need to conform to ASN.1
246distinguished encoding rules (DER), which are more restrictive than BER.
247.It EVP
248digital EnVeloPe library:
249See
250.Xr evp 3 .
251.It ex
252This name element is used for two completely unrelated purposes.
253.Pp
254extended version:
255The function is similar to an older function without the
256.Dq ex
257in its name, but takes one or more additional arguments
258in order to make it more versatile.
259In several cases, the older version is now deprecated.
260.Pp
261extra data:
262Some object types support storing additional, application-specific data
263inside objects in addition to the data the object is designed to hold.
264The function sets, retrieves, or prepares for using such extra data.
265Related function names usually contain
266.Dq ex_data
267or
268.Dq ex_new_index .
269See
270.Xr CRYPTO_set_ex_data 3 .
271.It fp
272file pointer:
273The function takes a
274.Vt FILE *
275argument.
276Usually, the function is a variant of another function taking a
277.Vt BIO *
278argument instead.
279.It i2d
280internal to DER:
281The function encodes an object passed as an argument
282according to ASN.1 distinguished encoding rules (DER).
283There are a few rare exceptions of functions that have
284.Dq i2d
285in their name but produce output anyway
286that only conforms to ASN.1 basic encoding rules (BER) and not to DER.
287.It get0
288The function returns an internal pointer
289owned by the object passed as an argument.
290The returned pointer must not be freed by the calling code.
291It will be freed automatically
292when the object owning the pointer will be freed.
293.It get1
294The function returns a copy of a sub-object
295of an object passed as an argument.
296The caller is responsible for freeing the returned object
297when it is no longer needed.
298.Pp
299If the object type is reference counted, usually the reference count
300is incremented instead of copying the object.
301Consequently, modifying the returned object may still impact all
302objects containing references to it.
303The caller is responsible for freeing the returned object
304when it is no longer needed; for reference-counted objects still
305referenced elsewhere, this will merely decrement the reference count.
306.It get
307Functions containing
308.Dq get
309in their name without a following digit may behave in
310.Dq get0
311or, more rarely, in
312.Dq get1
313style.
314To find out which is the case, refer to the individual manual pages.
315.It lh
316linear hash:
317The function manipulates a dynamic hash table.
318See
319.Xr lh_new 3 .
320.It md
321message digest.
322Some function names use the all caps form
323.Dq MD
324in the same sense.
325.It meth
326The function manipulates an object holding a function table.
327Usually, such function tables allow the application program
328to implement additional cryptographic or I/O algorithms
329and to use them with the same high-level API functions as the
330algorithms provided by the library itself, or to replace the
331implementations of algorithms provided by the library with
332custom implementations provided by the application program.
333Some API functions use the name elements
334.Dq method
335or
336.Dq METHOD
337in the same sense.
338See also the
339.Dq cb
340entry in the present list.
341.It nid
342numerical identifier:
343A non-standard, LibreSSL-specific
344.Vt int
345number associated with an ASN.1 object identifier.
346In several cases, the all caps form
347.Dq NID
348is used in the same sense.
349See
350.Xr OBJ_nid2obj 3 .
351.It obj
352This name element and its all caps form
353.Dq OBJ
354usually refer to ASN.1 object identifiers represented by the
355.Vt ASN1_OBJECT
356data type.
357See
358.Xr ASN1_OBJECT_new 3 .
359.It PKEY
360In most cases, this name element and its lower case form
361.Dq pkey
362mean
363.Dq private key ,
364but for both forms, there are some cases where they mean
365.Dq public key
366instead.
367.It set0
368The function transfers ownership of a pointer passed as an argument
369to an object passed as another argument,
370by storing the pointer inside the object.
371The transferred pointer must not be freed by the calling code.
372It will be freed automatically
373when the object now owning the pointer will be freed.
374.It set1
375The function copies the content of one object passed as an argument
376into another object also passed as an argument.
377When the calling code no longer needs the copied object,
378it can free that object.
379.Pp
380In some cases, if the object to be copied is reference counted,
381the function does not actually copy the object but merely increments
382its reference count and stores the pointer to it in the other object.
383When the calling code no longer needs its original pointer to
384the now inner object, it can free the original pointer, thus
385decrementing the reference count of the inner object
386and transferring ownership of the inner object to the outer object.
387The inner object will then be freed automatically
388when the outer object is freed later on.
389.It set
390Functions containing
391.Dq set
392in their name without a following digit may behave in
393.Dq set0
394or, more rarely, in
395.Dq set1
396style.
397To find out which is the case, refer to the individual manual pages.
398.It sk
399stack:
400The function manipulates a variable-sized array of pointers
401in the idiosyncratic style described in
402.Xr OPENSSL_sk_new 3 .
403.It TS
404X.509 time-stamp protocol:
405See
406.Xr TS_REQ_new 3 .
407.It up_ref
408The function increments the reference count of the argument by one.
409Only a minority of object types support reference counting.
410For those that do, if the reference count is greater than one,
411the corresponding
412.Dq free
413function reverses the effect of one call to the
414.Dq up_ref
415function rather than freeing the object.
416.El
417.Sh SEE ALSO
418.Xr openssl 1 ,
419.Xr ssl 3
diff --git a/src/lib/libcrypto/man/d2i_ASN1_NULL.3 b/src/lib/libcrypto/man/d2i_ASN1_NULL.3
deleted file mode 100644
index 037c9c93e1..0000000000
--- a/src/lib/libcrypto/man/d2i_ASN1_NULL.3
+++ /dev/null
@@ -1,92 +0,0 @@
1.\" $OpenBSD: d2i_ASN1_NULL.3,v 1.5 2023/09/26 09:36:22 tb Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 26 2023 $
18.Dt D2I_ASN1_NULL 3
19.Os
20.Sh NAME
21.Nm d2i_ASN1_NULL ,
22.Nm i2d_ASN1_NULL
23.Nd decode and encode an ASN.1 NULL type
24.Sh SYNOPSIS
25.In openssl/asn1.h
26.Ft ASN1_NULL *
27.Fo d2i_ASN1_NULL
28.Fa "ASN1_NULL **val_out"
29.Fa "const unsigned char **der_in"
30.Fa "long length"
31.Fc
32.Ft int
33.Fo i2d_ASN1_NULL
34.Fa "ASN1_NULL *val_in"
35.Fa "unsigned char **der_out"
36.Fc
37.Sh DESCRIPTION
38These functions decode and encode the ASN.1 value NULL of type NULL.
39For details about the semantics, examples, caveats, and bugs, see
40.Xr ASN1_item_d2i 3 .
41.Pp
42.Fn d2i_ASN1_NULL
43verifies that the BER-encoded value at
44.Pf * Fa der_in
45is NULL and of type NULL.
46It fails if
47.Fa length
48is less than 2 or if the first two bytes of
49.Pf * Fa der_in
50differ from 0x05 and 0x00.
51In case of success,
52.Pf * Fa der_in
53is advanced by two bytes and
54.Pf * Fa val_out
55is set to a specific invalid pointer representing the unique
56.Vt ASN1_NULL
57object.
58.Pp
59.Fn i2d_ASN1_NULL
60ignores
61.Fa val_in
62and encodes the ASN.1 value NULL of type NULL using DER.
63Specifically, it writes the identifier octet for the type NULL,
640x05, followed by the length octet 0x00, and no content or
65end-of-content octets.
66.Sh RETURN VALUES
67.Fn d2i_ASN1_NULL
68returns a specific invalid pointer representing the unique
69.Vt ASN1_NULL
70object or
71.Dv NULL
72if an error occurs.
73.Pp
74.Fn i2d_ASN1_NULL
75returns 2 if successful or 0 if an error occurs.
76.Sh SEE ALSO
77.Xr ASN1_item_d2i 3 ,
78.Xr ASN1_item_new 3 ,
79.Xr ASN1_NULL_new 3 ,
80.Xr ASN1_TYPE_get 3
81.Sh STANDARDS
82ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
83Information technology - ASN.1 encoding rules:
84Specification of Basic Encoding Rules (BER), Canonical Encoding
85Rules (CER) and Distinguished Encoding Rules (DER),
86section 8.8: Encoding of a null value
87.Sh HISTORY
88.Fn d2i_ASN1_NULL
89and
90.Fn i2d_ASN1_NULL
91first appeared in OpenSSL 0.9.5 and have been available since
92.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 b/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3
deleted file mode 100644
index bbb70ad8c6..0000000000
--- a/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3
+++ /dev/null
@@ -1,164 +0,0 @@
1.\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.15 2025/03/14 21:32:15 tb Exp $
2.\"
3.\" Copyright (c) 2017, 2022, 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 14 2025 $
18.Dt D2I_ASN1_OBJECT 3
19.Os
20.Sh NAME
21.Nm d2i_ASN1_OBJECT ,
22.Nm i2d_ASN1_OBJECT ,
23.Nm OBJ_get0_data ,
24.Nm OBJ_length
25.Nd decode and encode ASN.1 object identifiers
26.Sh SYNOPSIS
27.In openssl/asn1.h
28.Ft ASN1_OBJECT *
29.Fo d2i_ASN1_OBJECT
30.Fa "ASN1_OBJECT **val_out"
31.Fa "const unsigned char **der_in"
32.Fa "long length"
33.Fc
34.Ft int
35.Fo i2d_ASN1_OBJECT
36.Fa "const ASN1_OBJECT *val_in"
37.Fa "unsigned char **der_out"
38.Fc
39.In openssl/objects.h
40.Ft const unsigned char *
41.Fn OBJ_get0_data "const ASN1_OBJECT *val_in"
42.Ft size_t
43.Fn OBJ_length "const ASN1_OBJECT *val_in"
44.Sh DESCRIPTION
45These functions decode and encode ASN.1 object identifiers.
46For details about the semantics, examples, caveats, and bugs, see
47.Xr ASN1_item_d2i 3 .
48.Pp
49The LibreSSL implementation of
50.Fn d2i_ASN1_OBJECT
51always calls
52.Xr ASN1_OBJECT_free 3
53if an existing object is passed in via
54.Fa val_out
55and it always creates a new object from scratch.
56Other implementations may attempt to reuse an existing object,
57which is fragile and prone to bugs.
58Consequently, always passing
59.Dv NULL
60for the
61.Fa val_out
62argument is recommended.
63.Pp
64The objects returned from
65.Fn d2i_ASN1_OBJECT
66and the data contained in them are always marked as dynamically
67allocated, so when they are no longer needed,
68.Xr ASN1_OBJECT_free 3
69can be called on them.
70.Pp
71.Fn i2d_ASN1_OBJECT
72encodes the object identifier pointed to by
73.Fa val_in
74into DER format.
75.Fn OBJ_get0_data
76and
77.Fn OBJ_length
78only deal with the content octets of that DER encoding,
79without taking the identifier and length octets into account.
80.Sh RETURN VALUES
81.Fn d2i_ASN1_OBJECT
82returns a pointer to the new
83.Vt ASN1_OBJECT
84object or
85.Dv NULL
86if an error occurs.
87With other implementations, it might return a pointer to the reused
88.Vt ASN1_OBJECT .
89.Pp
90.Fn i2d_ASN1_OBJECT
91returns the number of octets successfully encoded
92or a value <= 0 if an error occurs.
93.Pp
94.Fn OBJ_get0_data
95returns an internal pointer to the first content octet of the DER
96encoding of
97.Fa val_in .
98The other content octets follow the returned pointer contiguously.
99.Fn OBJ_length
100returns the number of content octets contained in the DER encoding of
101.Fa val_in .
102This number is always smaller than the total length of the encoding
103returned by
104.Xr ASN1_object_size 3 .
105.Pp
106If
107.Fa val_in
108is a
109.Dv NULL
110pointer or points to an empty object, for example one freshly created with
111.Xr ASN1_OBJECT_new 3 ,
112.Fn OBJ_get0_data
113returns
114.Dv NULL
115and
116.Fn OBJ_length
117returns zero.
118.Sh SEE ALSO
119.Xr a2d_ASN1_OBJECT 3 ,
120.Xr ASN1_item_d2i 3 ,
121.Xr ASN1_OBJECT_new 3 ,
122.Xr ASN1_put_object 3 ,
123.Xr OBJ_nid2obj 3
124.Sh STANDARDS
125ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
126Information technology - ASN.1 encoding rules:
127Specification of Basic Encoding Rules (BER), Canonical Encoding
128Rules (CER) and Distinguished Encoding Rules (DER),
129section 8.19: Encoding of an object identifier value
130.Sh HISTORY
131.Fn d2i_ASN1_OBJECT
132and
133.Fn i2d_ASN1_OBJECT
134first appeared in SSLeay 0.5.1 and have been available since
135.Ox 2.4 .
136.Pp
137.Fn OBJ_get0_data
138and
139.Fn OBJ_length
140first appeared in OpenSSL 1.1.0 and have been available since
141.Ox 7.1 .
142.Sh CAVEATS
143.Fn d2i_ASN1_OBJECT
144never sets the long and short names of the object, not even if the
145object identifier matches one that is built into the library.
146To find the names of an object identifier parsed from DER or BER
147input, call
148.Xr OBJ_obj2nid 3
149on the returned object, and then
150.Xr OBJ_nid2sn 3
151and
152.Xr OBJ_nid2ln 3
153on the result.
154.Pp
155Calling
156.Fn OBJ_get0_data
157and then accessing memory in front of the returned pointer
158results in undefined behaviour.
159In particular, it is not possible to find the identifier or
160length octets in that way; use
161.Xr ASN1_put_object 3
162or
163.Fn i2d_ASN1_OBJECT
164instead.
diff --git a/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3 b/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3
deleted file mode 100644
index d544af0fe4..0000000000
--- a/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3
+++ /dev/null
@@ -1,461 +0,0 @@
1.\" $OpenBSD: d2i_ASN1_OCTET_STRING.3,v 1.20 2024/02/13 12:38:43 job Exp $
2.\"
3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: February 13 2024 $
18.Dt D2I_ASN1_OCTET_STRING 3
19.Os
20.Sh NAME
21.Nm d2i_ASN1_OCTET_STRING ,
22.Nm i2d_ASN1_OCTET_STRING ,
23.Nm d2i_ASN1_BIT_STRING ,
24.Nm i2d_ASN1_BIT_STRING ,
25.Nm d2i_ASN1_INTEGER ,
26.Nm i2d_ASN1_INTEGER ,
27.Nm d2i_ASN1_UINTEGER ,
28.Nm d2i_ASN1_ENUMERATED ,
29.Nm i2d_ASN1_ENUMERATED ,
30.Nm d2i_ASN1_UTF8STRING ,
31.Nm i2d_ASN1_UTF8STRING ,
32.Nm d2i_ASN1_IA5STRING ,
33.Nm i2d_ASN1_IA5STRING ,
34.Nm d2i_ASN1_UNIVERSALSTRING ,
35.Nm i2d_ASN1_UNIVERSALSTRING ,
36.Nm d2i_ASN1_BMPSTRING ,
37.Nm i2d_ASN1_BMPSTRING ,
38.Nm d2i_ASN1_GENERALSTRING ,
39.Nm i2d_ASN1_GENERALSTRING ,
40.Nm d2i_ASN1_T61STRING ,
41.Nm i2d_ASN1_T61STRING ,
42.Nm d2i_ASN1_VISIBLESTRING ,
43.Nm i2d_ASN1_VISIBLESTRING ,
44.Nm d2i_ASN1_PRINTABLESTRING ,
45.Nm i2d_ASN1_PRINTABLESTRING ,
46.Nm d2i_ASN1_PRINTABLE ,
47.Nm i2d_ASN1_PRINTABLE ,
48.Nm d2i_DIRECTORYSTRING ,
49.Nm i2d_DIRECTORYSTRING ,
50.Nm d2i_DISPLAYTEXT ,
51.Nm i2d_DISPLAYTEXT ,
52.Nm d2i_ASN1_GENERALIZEDTIME ,
53.Nm i2d_ASN1_GENERALIZEDTIME ,
54.Nm d2i_ASN1_UTCTIME ,
55.Nm i2d_ASN1_UTCTIME ,
56.Nm d2i_ASN1_TIME ,
57.Nm i2d_ASN1_TIME
58.Nd decode and encode ASN1_STRING objects
59.Sh SYNOPSIS
60.In openssl/asn1.h
61.Ft ASN1_OCTET_STRING *
62.Fo d2i_ASN1_OCTET_STRING
63.Fa "ASN1_OCTET_STRING **val_out"
64.Fa "const unsigned char **der_in"
65.Fa "long length"
66.Fc
67.Ft int
68.Fo i2d_ASN1_OCTET_STRING
69.Fa "ASN1_OCTET_STRING *val_in"
70.Fa "unsigned char **der_out"
71.Fc
72.Ft ASN1_BIT_STRING *
73.Fo d2i_ASN1_BIT_STRING
74.Fa "ASN1_BIT_STRING **val_out"
75.Fa "const unsigned char **der_in"
76.Fa "long length"
77.Fc
78.Ft int
79.Fo i2d_ASN1_BIT_STRING
80.Fa "ASN1_BIT_STRING *val_in"
81.Fa "unsigned char **der_out"
82.Fc
83.Ft ASN1_INTEGER *
84.Fo d2i_ASN1_INTEGER
85.Fa "ASN1_INTEGER **val_out"
86.Fa "const unsigned char **der_in"
87.Fa "long length"
88.Fc
89.Ft int
90.Fo i2d_ASN1_INTEGER
91.Fa "ASN1_INTEGER *val_in"
92.Fa "unsigned char **der_out"
93.Fc
94.Ft ASN1_INTEGER *
95.Fo d2i_ASN1_UINTEGER
96.Fa "ASN1_INTEGER **val_out"
97.Fa "const unsigned char **der_in"
98.Fa "long length"
99.Fc
100.Ft ASN1_ENUMERATED *
101.Fo d2i_ASN1_ENUMERATED
102.Fa "ASN1_ENUMERATED **val_out"
103.Fa "const unsigned char **der_in"
104.Fa "long length"
105.Fc
106.Ft int
107.Fo i2d_ASN1_ENUMERATED
108.Fa "ASN1_ENUMERATED *val_in"
109.Fa "unsigned char **der_out"
110.Fc
111.Ft ASN1_UTF8STRING *
112.Fo d2i_ASN1_UTF8STRING
113.Fa "ASN1_UTF8STRING **val_out"
114.Fa "const unsigned char **der_in"
115.Fa "long length"
116.Fc
117.Ft int
118.Fo i2d_ASN1_UTF8STRING
119.Fa "ASN1_UTF8STRING *val_in"
120.Fa "unsigned char **der_out"
121.Fc
122.Ft ASN1_IA5STRING *
123.Fo d2i_ASN1_IA5STRING
124.Fa "ASN1_IA5STRING **val_out"
125.Fa "const unsigned char **der_in"
126.Fa "long length"
127.Fc
128.Ft int
129.Fo i2d_ASN1_IA5STRING
130.Fa "ASN1_IA5STRING *val_in"
131.Fa "unsigned char **der_out"
132.Fc
133.Ft ASN1_UNIVERSALSTRING *
134.Fo d2i_ASN1_UNIVERSALSTRING
135.Fa "ASN1_UNIVERSALSTRING **val_out"
136.Fa "const unsigned char **der_in"
137.Fa "long length"
138.Fc
139.Ft int
140.Fo i2d_ASN1_UNIVERSALSTRING
141.Fa "ASN1_UNIVERSALSTRING *val_in"
142.Fa "unsigned char **der_out"
143.Fc
144.Ft ASN1_BMPSTRING *
145.Fo d2i_ASN1_BMPSTRING
146.Fa "ASN1_BMPSTRING **val_out"
147.Fa "const unsigned char **der_in"
148.Fa "long length"
149.Fc
150.Ft int
151.Fo i2d_ASN1_BMPSTRING
152.Fa "ASN1_BMPSTRING *val_in"
153.Fa "unsigned char **der_out"
154.Fc
155.Ft ASN1_GENERALSTRING *
156.Fo d2i_ASN1_GENERALSTRING
157.Fa "ASN1_GENERALSTRING **val_out"
158.Fa "const unsigned char **der_in"
159.Fa "long length"
160.Fc
161.Ft int
162.Fo i2d_ASN1_GENERALSTRING
163.Fa "ASN1_GENERALSTRING *val_in"
164.Fa "unsigned char **der_out"
165.Fc
166.Ft ASN1_T61STRING *
167.Fo d2i_ASN1_T61STRING
168.Fa "ASN1_T61STRING **val_out"
169.Fa "const unsigned char **der_in"
170.Fa "long length"
171.Fc
172.Ft int
173.Fo i2d_ASN1_T61STRING
174.Fa "ASN1_T61STRING *val_in"
175.Fa "unsigned char **der_out"
176.Fc
177.Ft ASN1_VISIBLESTRING *
178.Fo d2i_ASN1_VISIBLESTRING
179.Fa "ASN1_VISIBLESTRING **val_out"
180.Fa "const unsigned char **der_in"
181.Fa "long length"
182.Fc
183.Ft int
184.Fo i2d_ASN1_VISIBLESTRING
185.Fa "ASN1_VISIBLESTRING *val_in"
186.Fa "unsigned char **der_out"
187.Fc
188.Ft ASN1_PRINTABLESTRING *
189.Fo d2i_ASN1_PRINTABLESTRING
190.Fa "ASN1_PRINTABLESTRING **val_out"
191.Fa "const unsigned char **der_in"
192.Fa "long length"
193.Fc
194.Ft int
195.Fo i2d_ASN1_PRINTABLESTRING
196.Fa "ASN1_PRINTABLESTRING *val_in"
197.Fa "unsigned char **der_out"
198.Fc
199.Ft ASN1_STRING *
200.Fo d2i_ASN1_PRINTABLE
201.Fa "ASN1_STRING **val_out"
202.Fa "const unsigned char **der_in"
203.Fa "long length"
204.Fc
205.Ft int
206.Fo i2d_ASN1_PRINTABLE
207.Fa "ASN1_STRING *val_in"
208.Fa "unsigned char **der_out"
209.Fc
210.Ft ASN1_STRING *
211.Fo d2i_DIRECTORYSTRING
212.Fa "ASN1_STRING **val_out"
213.Fa "const unsigned char **der_in"
214.Fa "long length"
215.Fc
216.Ft int
217.Fo i2d_DIRECTORYSTRING
218.Fa "ASN1_STRING *val_in"
219.Fa "unsigned char **der_out"
220.Fc
221.Ft ASN1_STRING *
222.Fo d2i_DISPLAYTEXT
223.Fa "ASN1_STRING **val_out"
224.Fa "const unsigned char **der_in"
225.Fa "long length"
226.Fc
227.Ft int
228.Fo i2d_DISPLAYTEXT
229.Fa "ASN1_STRING *val_in"
230.Fa "unsigned char **der_out"
231.Fc
232.Ft ASN1_GENERALIZEDTIME *
233.Fo d2i_ASN1_GENERALIZEDTIME
234.Fa "ASN1_GENERALIZEDTIME **val_out"
235.Fa "const unsigned char **der_in"
236.Fa "long length"
237.Fc
238.Ft int
239.Fo i2d_ASN1_GENERALIZEDTIME
240.Fa "ASN1_GENERALIZEDTIME *val_in"
241.Fa "unsigned char **der_out"
242.Fc
243.Ft ASN1_UTCTIME *
244.Fo d2i_ASN1_UTCTIME
245.Fa "ASN1_UTCTIME **val_out"
246.Fa "const unsigned char **der_in"
247.Fa "long length"
248.Fc
249.Ft int
250.Fo i2d_ASN1_UTCTIME
251.Fa "ASN1_UTCTIME *val_in"
252.Fa "unsigned char **der_out"
253.Fc
254.Ft ASN1_TIME *
255.Fo d2i_ASN1_TIME
256.Fa "ASN1_TIME **val_out"
257.Fa "const unsigned char **der_in"
258.Fa "long length"
259.Fc
260.Ft int
261.Fo i2d_ASN1_TIME
262.Fa "ASN1_TIME *val_in"
263.Fa "unsigned char **der_out"
264.Fc
265.Sh DESCRIPTION
266These functions decode and encode various ASN.1 built-in types
267that can be represented by
268.Vt ASN1_STRING
269objects.
270For details about the semantics, examples, caveats, and bugs, see
271.Xr ASN1_item_d2i 3 .
272.Pp
273The format consists of one identifier byte, one or more length bytes,
274and one or more content bytes.
275The identifier bytes and corresponding ASN.1 types are as follows:
276.Bl -column ASN1_GENERALIZEDTIME identifier
277.It Em OpenSSL type Ta Em identifier Ta Em ASN.1 type
278.It Ta
279.It Vt ASN1_OCTET_STRING Ta 0x04 Ta OCTET STRING
280.It Vt ASN1_BIT_STRING Ta 0x03 Ta BIT STRING
281.It Vt ASN1_INTEGER Ta 0x02 Ta INTEGER
282.It Vt ASN1_ENUMERATED Ta 0x0a Ta ENUMERATED
283.It Vt ASN1_UTF8STRING Ta 0x0c Ta UTF8String
284.It Vt ASN1_IA5STRING Ta 0x16 Ta IA5String
285.It Vt ASN1_UNIVERSALSTRING Ta 0x1c Ta UniversalString
286.It Vt ASN1_BMPSTRING Ta 0x1e Ta BMPString
287.It Vt ASN1_GENERALSTRING Ta 0x1b Ta GeneralString
288.It Vt ASN1_T61STRING Ta 0x14 Ta T61String
289.It Vt ASN1_VISIBLESTRING Ta 0x1a Ta VisibleString
290.It Vt ASN1_PRINTABLESTRING Ta 0x13 Ta PrintableString
291.It Vt ASN1_GENERALIZEDTIME Ta 0x18 Ta GeneralizedTime
292.It Vt ASN1_UTCTIME Ta 0x17 Ta UTCTime
293.El
294.Pp
295.Fn d2i_DIRECTORYSTRING
296and
297.Fn i2d_DIRECTORYSTRING
298decode and encode an ASN.1
299.Vt DirectoryString
300structure defined in RFC 5280 section 4.1.2.4
301and used for ASN.1
302.Vt EDIPartyName
303structures; see
304.Xr EDIPARTYNAME_new 3 .
305When decoding, it accepts any of the types UTF8String, UniversalString,
306BMPString, T61String, or PrintableString.
307When encoding,
308it writes out the character string type that is actually passed in.
309.Pp
310.Fn d2i_ASN1_PRINTABLE
311and
312.Fn i2d_ASN1_PRINTABLE
313are non-standard variants of
314.Fn d2i_DIRECTORYSTRING
315and
316.Fn i2d_DIRECTORYSTRING
317that also accept IA5String, NumericString, BIT STRING, and SEQUENCE
318ASN.1 values as well as ASN.1 values with unknown identifier
319bytes (0x07, 0x08, 0x09, 0x0b, 0x0d, 0x0e, 0x0f, 0x1d, and 0x1f).
320Even though the standard requires the use of
321.Vt DirectoryString
322in the relative distinguished names described in
323.Xr X509_NAME_ENTRY_new 3 ,
324the library accepts this wider range of choices.
325.Pp
326.Fn d2i_DISPLAYTEXT
327and
328.Fn i2d_DISPLAYTEXT
329decode and encode an ASN.1
330.Vt DisplayText
331structure defined in RFC 5280 section 4.2.1.4
332and used for ASN.1
333.Vt UserNotice
334structures in certificate policies; see
335.Xr USERNOTICE_new 3 .
336When decoding, it accepts any of the types UTF8String, IA5String,
337BMPString, or VisibleString.
338When encoding,
339it writes out the character string type that is actually passed in.
340.Pp
341.Fn d2i_ASN1_TIME
342and
343.Fn i2d_ASN1_TIME
344decode and encode an ASN.1
345.Vt Time
346structure defined in RFC 5280 section 4.1
347and used for ASN.1
348.Vt Validity
349structures in certificates; see
350.Xr X509_VAL_new 3 .
351They are also used for certificate revocation lists; see
352.Xr X509_CRL_INFO_new 3 .
353When decoding, it accepts either GeneralizedTime or UTCTime.
354When encoding, it writes out the time type that is actually passed in.
355.Pp
356The following constants describe the ASN.1 tags that are valid
357when decoding with the above functions.
358See
359.Xr ASN1_tag2bit 3
360for more details about the
361.Dv B_ASN1_*
362constants.
363.Bl -column d2i_DIRECTORYSTRING() B_ASN1_DIRECTORYSTRING -offset indent
364.It decoding function Ta mask constant
365.It Fn d2i_DIRECTORYSTRING Ta Dv B_ASN1_DIRECTORYSTRING
366.It Fn d2i_ASN1_PRINTABLE Ta Dv B_ASN1_PRINTABLE
367.It Fn d2i_DISPLAYTEXT Ta Dv B_ASN1_DISPLAYTEXT
368.It Fn d2i_ASN1_TIME Ta Dv B_ASN1_TIME
369.El
370.Pp
371.Fn d2i_ASN1_UINTEGER
372is similar to
373.Fn d2i_ASN1_INTEGER
374except that it ignores the sign bit in the BER encoding and treats
375all integers as positive.
376It helps to process BER input produced by broken software
377that neglects adding a leading NUL content byte where required.
378.Sh RETURN VALUES
379The
380.Fn d2i_*
381decoding functions return an
382.Vt ASN1_STRING
383object or
384.Dv NULL
385if an error occurs.
386.Pp
387The
388.Fn i2d_*
389encoding functions return the number of bytes successfully encoded
390or a negative value if an error occurs.
391.Sh SEE ALSO
392.Xr ASN1_item_d2i 3 ,
393.Xr ASN1_STRING_new 3
394.Sh STANDARDS
395ITU-T Recommendation X.680, also known as ISO/IEC 8824-1:
396Information technology - Abstract Syntax Notation One (ASN.1):
397Specification of basic notation
398.Pp
399RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
400Certificate Revocation List (CRL) Profile
401.Sh HISTORY
402.Fn d2i_ASN1_OCTET_STRING ,
403.Fn i2d_ASN1_OCTET_STRING ,
404.Fn d2i_ASN1_BIT_STRING ,
405.Fn i2d_ASN1_BIT_STRING ,
406.Fn d2i_ASN1_INTEGER ,
407.Fn i2d_ASN1_INTEGER ,
408.Fn d2i_ASN1_IA5STRING ,
409.Fn i2d_ASN1_IA5STRING ,
410.Fn d2i_ASN1_T61STRING ,
411.Fn i2d_ASN1_T61STRING ,
412.Fn d2i_ASN1_PRINTABLESTRING ,
413.Fn i2d_ASN1_PRINTABLESTRING ,
414.Fn d2i_ASN1_PRINTABLE ,
415.Fn i2d_ASN1_PRINTABLE ,
416.Fn d2i_ASN1_UTCTIME ,
417and
418.Fn i2d_ASN1_UTCTIME
419first appeared in SSLeay 0.5.1 and have been available since
420.Ox 2.4 .
421.Pp
422.Fn d2i_ASN1_BMPSTRING
423and
424.Fn i2d_ASN1_BMPSTRING
425first appeared in SSLeay 0.9.1.
426.Fn d2i_ASN1_ENUMERATED ,
427.Fn i2d_ASN1_ENUMERATED ,
428.Fn d2i_ASN1_GENERALIZEDTIME ,
429.Fn i2d_ASN1_GENERALIZEDTIME ,
430.Fn d2i_ASN1_TIME ,
431and
432.Fn i2d_ASN1_TIME
433first appeared in OpenSSL 0.9.2b.
434.Fn d2i_ASN1_UINTEGER ,
435.Fn d2i_ASN1_UTF8STRING ,
436.Fn i2d_ASN1_UTF8STRING ,
437.Fn d2i_ASN1_VISIBLESTRING ,
438.Fn i2d_ASN1_VISIBLESTRING ,
439.Fn d2i_DIRECTORYSTRING ,
440.Fn i2d_DIRECTORYSTRING ,
441.Fn d2i_DISPLAYTEXT
442and
443.Fn i2d_DISPLAYTEXT
444first appeared in OpenSSL 0.9.3.
445These functions have been available since
446.Ox 2.6 .
447.Pp
448.Fn d2i_ASN1_UNIVERSALSTRING ,
449.Fn i2d_ASN1_UNIVERSALSTRING ,
450.Fn d2i_ASN1_GENERALSTRING ,
451and
452.Fn i2d_ASN1_GENERALSTRING
453first appeared in OpenSSL 0.9.7 and have been available since
454.Ox 3.2 .
455.Sh CAVEATS
456Other implementations may accept or emit invalid DER encodings of
457GeneralizedTime and UTCTime.
458Portable applications should use
459.Fn ASN1_STRING_length
460to double check whether a given GeneralizedTime or UTCTime object is at least
46115 or 13 bytes, respectively.
diff --git a/src/lib/libcrypto/man/d2i_ASN1_SEQUENCE_ANY.3 b/src/lib/libcrypto/man/d2i_ASN1_SEQUENCE_ANY.3
deleted file mode 100644
index 654f0b1e6b..0000000000
--- a/src/lib/libcrypto/man/d2i_ASN1_SEQUENCE_ANY.3
+++ /dev/null
@@ -1,98 +0,0 @@
1.\" $OpenBSD: d2i_ASN1_SEQUENCE_ANY.3,v 1.3 2021/12/09 19:05:09 schwarze Exp $
2.\"
3.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 9 2021 $
18.Dt D2I_ASN1_SEQUENCE_ANY 3
19.Os
20.Sh NAME
21.Nm d2i_ASN1_SEQUENCE_ANY ,
22.Nm i2d_ASN1_SEQUENCE_ANY ,
23.Nm d2i_ASN1_SET_ANY ,
24.Nm i2d_ASN1_SET_ANY
25.Nd decode and encode ASN.1 sequences and sets
26.Sh SYNOPSIS
27.In openssl/asn1.h
28.Ft ASN1_SEQUENCE_ANY *
29.Fo d2i_ASN1_SEQUENCE_ANY
30.Fa "ASN1_SEQUENCE_ANY **val_out"
31.Fa "const unsigned char **der_in"
32.Fa "long length"
33.Fc
34.Ft int
35.Fo i2d_ASN1_SEQUENCE_ANY
36.Fa "const ASN1_SEQUENCE_ANY *val_in"
37.Fa "unsigned char **der_out"
38.Fc
39.Ft ASN1_SEQUENCE_ANY *
40.Fo d2i_ASN1_SET_ANY
41.Fa "ASN1_SEQUENCE_ANY **val_out"
42.Fa "const unsigned char **der_in"
43.Fa "long length"
44.Fc
45.Ft int
46.Fo i2d_ASN1_SET_ANY
47.Fa "const ASN1_SEQUENCE_ANY *val_in"
48.Fa "unsigned char **der_out"
49.Fc
50.Sh DESCRIPTION
51These functions decode and encode ASN.1 sequences and sets,
52which are also represented by the
53.Dv V_ASN1_SEQUENCE
54and
55.Dv V_ASN1_SET
56type identifier constants, respectively.
57For details about the semantics, examples, caveats, and bugs, see
58.Xr ASN1_item_d2i 3 .
59.Pp
60The type
61.Vt ASN1_SEQUENCE_ANY
62is defined as
63.Vt STACK_OF(ASN1_TYPE) .
64Whether such an object represents a sequence or a set is not stored
65in the object itself but needs to be remembered separately.
66.Pp
67Like for
68.Xr d2i_ASN1_TYPE 3
69and
70.Xr i2d_ASN1_TYPE 3 ,
71the type of the individual values contained in the sequence or set
72is not specified when calling the functions.
73It might vary among the members, and it is stored together with
74each value in each
75.Vt ASN1_TYPE
76object contained in the sequence or set.
77.Sh RETURN VALUES
78.Fn d2i_ASN1_SEQUENCE_ANY
79returns an
80.Vt ASN1_SEQUENCE_ANY
81object or
82.Dv NULL
83if an error occurs.
84.Pp
85.Fn i2d_ASN1_SEQUENCE_ANY
86returns the number of bytes written or a negative value if an error
87occurs.
88.Sh SEE ALSO
89.Xr ASN1_item_d2i 3 ,
90.Xr ASN1_TYPE_new 3
91.Sh HISTORY
92.Fn d2i_ASN1_SEQUENCE_ANY ,
93.Fn i2d_ASN1_SEQUENCE_ANY ,
94.Fn d2i_ASN1_SET_ANY ,
95and
96.Fn i2d_ASN1_SET_ANY
97first appeared in OpenSSL 1.0.0 and have been available since
98.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/d2i_AUTHORITY_KEYID.3 b/src/lib/libcrypto/man/d2i_AUTHORITY_KEYID.3
deleted file mode 100644
index 413f41e179..0000000000
--- a/src/lib/libcrypto/man/d2i_AUTHORITY_KEYID.3
+++ /dev/null
@@ -1,75 +0,0 @@
1.\" $OpenBSD: d2i_AUTHORITY_KEYID.3,v 1.2 2018/03/21 16:09:51 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 21 2018 $
18.Dt D2I_AUTHORITY_KEYID 3
19.Os
20.Sh NAME
21.Nm d2i_AUTHORITY_KEYID ,
22.Nm i2d_AUTHORITY_KEYID
23.Nd decode and encode X.509 authority key identifiers
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft AUTHORITY_KEYID *
27.Fo d2i_AUTHORITY_KEYID
28.Fa "AUTHORITY_KEYID **val_out"
29.Fa "const unsigned char **der_in"
30.Fa "long length"
31.Fc
32.Ft int
33.Fo i2d_AUTHORITY_KEYID
34.Fa "AUTHORITY_KEYID *val_in"
35.Fa "unsigned char **der_out"
36.Fc
37.Sh DESCRIPTION
38.Fn d2i_AUTHORITY_KEYID
39and
40.Fn i2d_AUTHORITY_KEYID
41decode and encode an ASN.1
42.Vt AuthorityKeyIdentifier
43structure defined in RFC 5280 section 4.2.1.1.
44For details about the semantics, examples, caveats, and bugs, see
45.Xr ASN1_item_d2i 3 .
46.Sh RETURN VALUES
47.Fn d2i_AUTHORITY_KEYID
48returns an
49.Vt AUTHORITY_KEYID
50object or
51.Dv NULL
52if an error occurs.
53.Pp
54.Fn i2d_AUTHORITY_KEYID
55returns the number of bytes successfully encoded or a negative value
56if an error occurs.
57.Sh SEE ALSO
58.Xr ASN1_item_d2i 3 ,
59.Xr AUTHORITY_KEYID_new 3 ,
60.Xr X509_EXTENSION_new 3
61.Sh STANDARDS
62RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
63Certificate Revocation List (CRL) Profile:
64.Bl -dash -compact
65.It
66section 4.2.1.1: Certificate Extensions: Authority Key Identifier
67.It
68section 5.2.1: CRL Extensions: Authority Key Identifier
69.El
70.Sh HISTORY
71.Fn d2i_AUTHORITY_KEYID
72and
73.Fn i2d_AUTHORITY_KEYID
74first appeared in OpenSSL 0.9.2b and have been available since
75.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/d2i_BASIC_CONSTRAINTS.3 b/src/lib/libcrypto/man/d2i_BASIC_CONSTRAINTS.3
deleted file mode 100644
index 2964a1f90e..0000000000
--- a/src/lib/libcrypto/man/d2i_BASIC_CONSTRAINTS.3
+++ /dev/null
@@ -1,106 +0,0 @@
1.\" $OpenBSD: d2i_BASIC_CONSTRAINTS.3,v 1.3 2018/03/22 21:08:22 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 22 2018 $
18.Dt D2I_BASIC_CONSTRAINTS 3
19.Os
20.Sh NAME
21.Nm d2i_BASIC_CONSTRAINTS ,
22.Nm i2d_BASIC_CONSTRAINTS ,
23.Nm d2i_EXTENDED_KEY_USAGE ,
24.Nm i2d_EXTENDED_KEY_USAGE
25.Nd decode and encode X.509 key usage purposes
26.Sh SYNOPSIS
27.In openssl/x509v3.h
28.Ft BASIC_CONSTRAINTS *
29.Fo d2i_BASIC_CONSTRAINTS
30.Fa "BASIC_CONSTRAINTS **val_out"
31.Fa "const unsigned char **der_in"
32.Fa "long length"
33.Fc
34.Ft int
35.Fo i2d_BASIC_CONSTRAINTS
36.Fa "BASIC_CONSTRAINTS *val_in"
37.Fa "unsigned char **der_out"
38.Fc
39.Ft EXTENDED_KEY_USAGE *
40.Fo d2i_EXTENDED_KEY_USAGE
41.Fa "EXTENDED_KEY_USAGE **val_out"
42.Fa "const unsigned char **der_in"
43.Fa "long length"
44.Fc
45.Ft int
46.Fo i2d_EXTENDED_KEY_USAGE
47.Fa "EXTENDED_KEY_USAGE *val_in"
48.Fa "unsigned char **der_out"
49.Fc
50.Sh DESCRIPTION
51These functions decode and encode data structures describing the
52intended purposes that the key contained in an X.509 certificate
53is to be used for.
54For details about the semantics, examples, caveats, and bugs, see
55.Xr ASN1_item_d2i 3 .
56.Pp
57.Fn d2i_BASIC_CONSTRAINTS
58and
59.Fn i2d_BASIC_CONSTRAINTS
60decode and encode an ASN.1
61.Vt BasicConstraints
62structure defined in RFC 5280 section 4.2.1.9.
63.Pp
64.Fn d2i_EXTENDED_KEY_USAGE
65and
66.Fn i2d_EXTENDED_KEY_USAGE
67decode and encode an ASN.1
68.Vt ExtKeyUsageSyntax
69structure defined in RFC 5280 section 4.2.1.12.
70.Sh RETURN VALUES
71.Fn d2i_BASIC_CONSTRAINTS
72and
73.Fn d2i_EXTENDED_KEY_USAGE
74return a
75.Vt BASIC_CONSTRAINTS
76or
77.Vt EXTENDED_KEY_USAGE
78object, respectively, or
79.Dv NULL
80if an error occurs.
81.Pp
82.Fn i2d_BASIC_CONSTRAINTS
83and
84.Fn i2d_EXTENDED_KEY_USAGE
85return the number of bytes successfully encoded or a negative value
86if an error occurs.
87.Sh SEE ALSO
88.Xr ASN1_item_d2i 3 ,
89.Xr BASIC_CONSTRAINTS_new 3 ,
90.Xr EXTENDED_KEY_USAGE_new 3 ,
91.Xr X509_EXTENSION_new 3
92.Sh STANDARDS
93RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
94Certificate Revocation List (CRL) Profile
95.Sh HISTORY
96.Fn d2i_BASIC_CONSTRAINTS
97and
98.Fn i2d_BASIC_CONSTRAINTS
99first appeared in OpenSSL 0.9.2b and have been available since
100.Ox 2.6 .
101.Pp
102.Fn d2i_EXTENDED_KEY_USAGE
103and
104.Fn i2d_EXTENDED_KEY_USAGE
105first appeared in OpenSSL 0.9.7 and have been available since
106.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/d2i_CMS_ContentInfo.3 b/src/lib/libcrypto/man/d2i_CMS_ContentInfo.3
deleted file mode 100644
index 0c61047c42..0000000000
--- a/src/lib/libcrypto/man/d2i_CMS_ContentInfo.3
+++ /dev/null
@@ -1,128 +0,0 @@
1.\" $OpenBSD: d2i_CMS_ContentInfo.3,v 1.3 2019/11/02 15:39:46 schwarze Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\"
4.\" Permission to use, copy, modify, and distribute this software for any
5.\" purpose with or without fee is hereby granted, provided that the above
6.\" copyright notice and this permission notice appear in all copies.
7.\"
8.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\"
16.Dd $Mdocdate: November 2 2019 $
17.Dt D2I_CMS_CONTENTINFO 3
18.Os
19.Sh NAME
20.Nm d2i_CMS_ContentInfo ,
21.Nm i2d_CMS_ContentInfo ,
22.Nm d2i_CMS_bio ,
23.Nm i2d_CMS_bio ,
24.Nm d2i_CMS_ReceiptRequest ,
25.Nm i2d_CMS_ReceiptRequest
26.Nd decode and encode Cryptographic Message Syntax data
27.Sh SYNOPSIS
28.In openssl/cms.h
29.Ft CMS_ContentInfo *
30.Fo d2i_CMS_ContentInfo
31.Fa "CMS_ContentInfo **val_out"
32.Fa "const unsigned char **der_in"
33.Fa "long length"
34.Fc
35.Ft int
36.Fo i2d_CMS_ContentInfo
37.Fa "CMS_ContentInfo *val_in"
38.Fa "unsigned char **out"
39.Fc
40.Ft CMS_ContentInfo *
41.Fo d2i_CMS_bio
42.Fa "BIO *in_bio"
43.Fa "CMS_ContentInfo **val_out"
44.Fc
45.Ft int
46.Fo i2d_CMS_bio
47.Fa "BIO *out_bio"
48.Fa "CMS_ContentInfo *val_in"
49.Fc
50.Ft CMS_ReceiptRequest *
51.Fo d2i_CMS_ReceiptRequest
52.Fa "CMS_ReceiptRequest **val_out"
53.Fa "const unsigned char **der_in"
54.Fa "long length"
55.Fc
56.Ft int
57.Fo i2d_CMS_ReceiptRequest
58.Fa "CMS_ReceiptRequest *val_in"
59.Fa "unsigned char **out"
60.Fc
61.Sh DESCRIPTION
62These functions decode and encode Cryptographic Message Syntax
63data structures.
64For details about the semantics, examples, caveats, and bugs, see
65.Xr ASN1_item_d2i 3 .
66.Pp
67.Fn d2i_CMS_ContentInfo
68and
69.Fn i2d_CMS_ContentInfo
70decode and encode a
71.Vt CMS_ContentInfo
72structure defined in RFC 5652 section 3.
73.Fn d2i_CMS_bio
74and
75.Fn i2d_CMS_bio
76are similar except that they decode or encode using a
77.Vt BIO
78pointer.
79.Pp
80.Fn d2i_CMS_ReceiptRequest
81and
82.Fn i2d_CMS_ReceiptRequest
83decode and encode a
84.Vt CMS_ReceiptRequest
85structure defined in RFC 2634 section 2.7.
86.Sh RETURN VALUES
87.Fn d2i_CMS_ContentInfo
88and
89.Fn d2i_CMS_bio
90return a valid
91.Vt CMS_ContentInfo
92structure or
93.Dv NULL
94if an error occurs.
95.Pp
96.Fn d2i_CMS_ReceiptRequest
97returns a valid
98.Vt CMS_ReceiptRequest
99structure or
100.Dv NULL
101if an error occurs.
102.Pp
103.Fn i2d_CMS_ContentInfo
104and
105.Fn i2d_CMS_ReceiptRequest
106return the number of bytes successfully encoded
107or a negative value if an error occurs.
108.Pp
109.Fn i2d_CMS_bio
110returns 1 for success or 0 if an error occurs.
111.Pp
112For all functions, the error code can be obtained by
113.Xr ERR_get_error 3 .
114.Sh SEE ALSO
115.Xr ASN1_item_d2i 3 ,
116.Xr CMS_ContentInfo_new 3 ,
117.Xr CMS_get0_type 3 ,
118.Xr CMS_ReceiptRequest_create0 3 ,
119.Xr i2d_CMS_bio_stream 3
120.Sh STANDARDS
121RFC 5652: Cryptographic Message Syntax, section 3: General Syntax
122.Pp
123RFC 2634: Enhanced Security Services for S/MIME,
124section 2.7: Receipt Request Syntax
125.Sh HISTORY
126These functions first appeared in OpenSSL 0.9.8h
127and have been available since
128.Ox 6.7 .
diff --git a/src/lib/libcrypto/man/d2i_DHparams.3 b/src/lib/libcrypto/man/d2i_DHparams.3
deleted file mode 100644
index 7fd9878dc0..0000000000
--- a/src/lib/libcrypto/man/d2i_DHparams.3
+++ /dev/null
@@ -1,99 +0,0 @@
1.\" $OpenBSD: d2i_DHparams.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
5.\" Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2000, 2002, 2015, 2017 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: March 27 2018 $
54.Dt D2I_DHPARAMS 3
55.Os
56.Sh NAME
57.Nm d2i_DHparams ,
58.Nm i2d_DHparams
59.Nd PKCS#3 DH parameter functions
60.Sh SYNOPSIS
61.In openssl/dh.h
62.Ft DH *
63.Fo d2i_DHparams
64.Fa "DH **a"
65.Fa "unsigned char **pp"
66.Fa "long length"
67.Fc
68.Ft int
69.Fo i2d_DHparams
70.Fa "DH *a"
71.Fa "unsigned char **pp"
72.Fc
73.Sh DESCRIPTION
74These functions decode and encode PKCS#3 DH parameters using the
75DHparameter structure described in PKCS#3.
76They otherwise behave in a way similar to
77.Xr d2i_X509 3
78and
79.Xr i2d_X509 3 .
80.Sh RETURN VALUES
81.Fn d2i_DHparams
82returns a
83.Vt DH
84object or
85.Dv NULL
86if an error occurs.
87.Pp
88.Fn i2d_DHparams
89returns the number of bytes successfully encoded or a value <= 0
90if an error occurs.
91.Sh SEE ALSO
92.Xr d2i_X509 3 ,
93.Xr DH_new 3
94.Sh HISTORY
95.Fn d2i_DHparams
96and
97.Fn i2d_DHparams
98first appeared in SSLeay 0.5.1 and have been available since
99.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/d2i_DIST_POINT.3 b/src/lib/libcrypto/man/d2i_DIST_POINT.3
deleted file mode 100644
index 34bdb26fb4..0000000000
--- a/src/lib/libcrypto/man/d2i_DIST_POINT.3
+++ /dev/null
@@ -1,201 +0,0 @@
1.\" $OpenBSD: d2i_DIST_POINT.3,v 1.4 2018/03/23 04:34:23 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 23 2018 $
18.Dt D2I_DIST_POINT 3
19.Os
20.Sh NAME
21.Nm d2i_DIST_POINT ,
22.Nm i2d_DIST_POINT ,
23.Nm d2i_CRL_DIST_POINTS ,
24.Nm i2d_CRL_DIST_POINTS ,
25.Nm d2i_DIST_POINT_NAME ,
26.Nm i2d_DIST_POINT_NAME ,
27.Nm d2i_ISSUING_DIST_POINT ,
28.Nm i2d_ISSUING_DIST_POINT ,
29.Nm d2i_ACCESS_DESCRIPTION ,
30.Nm i2d_ACCESS_DESCRIPTION ,
31.Nm d2i_AUTHORITY_INFO_ACCESS ,
32.Nm i2d_AUTHORITY_INFO_ACCESS
33.Nd decode and encode X.509 data access extensions
34.Sh SYNOPSIS
35.In openssl/x509v3.h
36.Ft DIST_POINT *
37.Fo d2i_DIST_POINT
38.Fa "DIST_POINT_NAME **val_out"
39.Fa "const unsigned char **der_in"
40.Fa "long length"
41.Fc
42.Ft int
43.Fo i2d_DIST_POINT
44.Fa "DIST_POINT *val_in"
45.Fa "unsigned char **der_out"
46.Fc
47.Ft CRL_DIST_POINTS *
48.Fo d2i_CRL_DIST_POINTS
49.Fa "CRL_DIST_POINTS_NAME **val_out"
50.Fa "const unsigned char **der_in"
51.Fa "long length"
52.Fc
53.Ft int
54.Fo i2d_CRL_DIST_POINTS
55.Fa "CRL_DIST_POINTS *val_in"
56.Fa "unsigned char **der_out"
57.Fc
58.Ft DIST_POINT_NAME *
59.Fo d2i_DIST_POINT_NAME
60.Fa "DIST_POINT_NAME_NAME **val_out"
61.Fa "const unsigned char **der_in"
62.Fa "long length"
63.Fc
64.Ft int
65.Fo i2d_DIST_POINT_NAME
66.Fa "DIST_POINT_NAME *val_in"
67.Fa "unsigned char **der_out"
68.Fc
69.Ft ISSUING_DIST_POINT *
70.Fo d2i_ISSUING_DIST_POINT
71.Fa "ISSUING_DIST_POINT_NAME **val_out"
72.Fa "const unsigned char **der_in"
73.Fa "long length"
74.Fc
75.Ft int
76.Fo i2d_ISSUING_DIST_POINT
77.Fa "ISSUING_DIST_POINT *val_in"
78.Fa "unsigned char **der_out"
79.Fc
80.Ft ACCESS_DESCRIPTION *
81.Fo d2i_ACCESS_DESCRIPTION
82.Fa "ACCESS_DESCRIPTION_NAME **val_out"
83.Fa "const unsigned char **der_in"
84.Fa "long length"
85.Fc
86.Ft int
87.Fo i2d_ACCESS_DESCRIPTION
88.Fa "ACCESS_DESCRIPTION *val_in"
89.Fa "unsigned char **der_out"
90.Fc
91.Ft AUTHORITY_INFO_ACCESS *
92.Fo d2i_AUTHORITY_INFO_ACCESS
93.Fa "AUTHORITY_INFO_ACCESS_NAME **val_out"
94.Fa "const unsigned char **der_in"
95.Fa "long length"
96.Fc
97.Ft int
98.Fo i2d_AUTHORITY_INFO_ACCESS
99.Fa "AUTHORITY_INFO_ACCESS *val_in"
100.Fa "unsigned char **der_out"
101.Fc
102.Sh DESCRIPTION
103These functions decode and encode X.509 extensions that communicate
104where to retrieve additional information online.
105For details about the semantics, examples, caveats, and bugs, see
106.Xr ASN1_item_d2i 3 .
107.Pp
108.Fn d2i_DIST_POINT
109and
110.Fn i2d_DIST_POINT
111decode and encode an ASN.1
112.Vt DistributionPoint
113structure defined in RFC 5280 section 4.2.1.13.
114.Pp
115.Fn d2i_CRL_DIST_POINTS
116and
117.Fn i2d_CRL_DIST_POINTS
118decode and encode an ASN.1
119.Vt CRLDistributionPoints
120structure defined in RFC 5280 section 4.2.1.13.
121.Pp
122.Fn d2i_DIST_POINT_NAME
123and
124.Fn i2d_DIST_POINT_NAME
125decode and encode an ASN.1
126.Vt DistributionPointName
127structure defined in RFC 5280 section 4.2.1.13.
128.Pp
129.Fn d2i_ISSUING_DIST_POINT
130and
131.Fn i2d_ISSUING_DIST_POINT
132decode and encode an ASN.1
133.Vt IssuingDistributionPoint
134structure defined in RFC 5280 section 5.2.5.
135.Pp
136.Fn d2i_ACCESS_DESCRIPTION
137and
138.Fn i2d_ACCESS_DESCRIPTION
139decode and encode an ASN.1
140.Vt AccessDescription
141structure defined in RFC 5280 section 4.2.2.1.
142.Pp
143.Fn d2i_AUTHORITY_INFO_ACCESS
144and
145.Fn i2d_AUTHORITY_INFO_ACCESS
146decode and encode an ASN.1
147.Vt AuthorityInfoAccessSyntax
148structure defined in RFC 5280 section 4.2.2.1.
149.Sh RETURN VALUES
150.Fn d2i_DIST_POINT ,
151.Fn d2i_CRL_DIST_POINTS ,
152.Fn d2i_DIST_POINT_NAME ,
153.Fn d2i_ISSUING_DIST_POINT ,
154.Fn d2i_ACCESS_DESCRIPTION ,
155and
156.Fn d2i_AUTHORITY_INFO_ACCESS
157return an object of the respective type or
158.Dv NULL
159if an error occurs.
160.Pp
161.Fn i2d_DIST_POINT ,
162.Fn i2d_CRL_DIST_POINTS ,
163.Fn i2d_DIST_POINT_NAME ,
164.Fn i2d_ISSUING_DIST_POINT ,
165.Fn i2d_ACCESS_DESCRIPTION ,
166and
167.Fn i2d_AUTHORITY_INFO_ACCESS
168return the number of bytes successfully encoded or a negative value
169if an error occurs.
170.Sh SEE ALSO
171.Xr ACCESS_DESCRIPTION_new 3 ,
172.Xr ASN1_item_d2i 3 ,
173.Xr DIST_POINT_new 3 ,
174.Xr X509_EXTENSION_new 3
175.Sh STANDARDS
176RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
177Certificate Revocation List (CRL) Profile
178.Sh HISTORY
179.Fn d2i_DIST_POINT ,
180.Fn i2d_DIST_POINT ,
181.Fn d2i_CRL_DIST_POINTS ,
182.Fn i2d_CRL_DIST_POINTS ,
183.Fn d2i_DIST_POINT_NAME ,
184and
185.Fn i2d_DIST_POINT_NAME
186first appeared in OpenSSL 0.9.3 and have been available since
187.Ox 2.6 .
188.Pp
189.Fn d2i_ACCESS_DESCRIPTION ,
190.Fn i2d_ACCESS_DESCRIPTION ,
191.Fn d2i_AUTHORITY_INFO_ACCESS ,
192and
193.Fn i2d_AUTHORITY_INFO_ACCESS
194first appeared in OpenSSL 0.9.5 and have been available since
195.Ox 2.7 .
196.Pp
197.Fn d2i_ISSUING_DIST_POINT
198and
199.Fn i2d_ISSUING_DIST_POINT
200first appeared in OpenSSL 1.0.0 and have been available since
201.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/d2i_DSAPublicKey.3 b/src/lib/libcrypto/man/d2i_DSAPublicKey.3
deleted file mode 100644
index 37ef22e1b9..0000000000
--- a/src/lib/libcrypto/man/d2i_DSAPublicKey.3
+++ /dev/null
@@ -1,412 +0,0 @@
1.\" $OpenBSD: d2i_DSAPublicKey.3,v 1.14 2018/08/26 17:03:32 tb Exp $
2.\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2003, 2013, 2015, 2016 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: August 26 2018 $
53.Dt D2I_DSAPUBLICKEY 3
54.Os
55.Sh NAME
56.Nm d2i_DSAPublicKey ,
57.Nm i2d_DSAPublicKey ,
58.Nm d2i_DSA_PUBKEY ,
59.Nm i2d_DSA_PUBKEY ,
60.Nm d2i_DSA_PUBKEY_bio ,
61.Nm d2i_DSA_PUBKEY_fp ,
62.Nm i2d_DSA_PUBKEY_bio ,
63.Nm i2d_DSA_PUBKEY_fp ,
64.Nm d2i_DSAPrivateKey ,
65.Nm i2d_DSAPrivateKey ,
66.Nm d2i_DSAPrivateKey_bio ,
67.Nm d2i_DSAPrivateKey_fp ,
68.Nm i2d_DSAPrivateKey_bio ,
69.Nm i2d_DSAPrivateKey_fp ,
70.Nm d2i_DSAparams ,
71.Nm i2d_DSAparams ,
72.Nm d2i_DSAparams_bio ,
73.Nm i2d_DSAparams_bio ,
74.Nm d2i_DSAparams_fp ,
75.Nm i2d_DSAparams_fp ,
76.Nm DSAparams_dup ,
77.Nm d2i_DSA_SIG ,
78.Nm i2d_DSA_SIG
79.Nd decode and encode DSA keys
80.Sh SYNOPSIS
81.In openssl/dsa.h
82.Ft DSA *
83.Fo d2i_DSAPublicKey
84.Fa "DSA **val_out"
85.Fa "const unsigned char **der_in"
86.Fa "long length"
87.Fc
88.Ft int
89.Fo i2d_DSAPublicKey
90.Fa "const DSA *val_in"
91.Fa "unsigned char **der_out"
92.Fc
93.In openssl/x509.h
94.Ft DSA *
95.Fo d2i_DSA_PUBKEY
96.Fa "DSA **val_out"
97.Fa "const unsigned char **der_in"
98.Fa "long length"
99.Fc
100.Ft int
101.Fo i2d_DSA_PUBKEY
102.Fa "const DSA *val_in"
103.Fa "unsigned char **der_out"
104.Fc
105.Ft DSA *
106.Fo d2i_DSA_PUBKEY_bio
107.Fa "BIO *in_bio"
108.Fa "DSA **val_out"
109.Fc
110.Ft DSA *
111.Fo d2i_DSA_PUBKEY_fp
112.Fa "FILE *in_fp"
113.Fa "DSA **val_out"
114.Fc
115.Ft int
116.Fo i2d_DSA_PUBKEY_bio
117.Fa "BIO *out_bio"
118.Fa "DSA *val_in"
119.Fc
120.Ft int
121.Fo i2d_DSA_PUBKEY_fp
122.Fa "FILE *out_fp"
123.Fa "DSA *val_in"
124.Fc
125.In openssl/dsa.h
126.Ft DSA *
127.Fo d2i_DSAPrivateKey
128.Fa "DSA **val_out"
129.Fa "const unsigned char **der_in"
130.Fa "long length"
131.Fc
132.Ft int
133.Fo i2d_DSAPrivateKey
134.Fa "const DSA *val_in"
135.Fa "unsigned char **der_out"
136.Fc
137.In openssl/x509.h
138.Ft DSA *
139.Fo d2i_DSAPrivateKey_bio
140.Fa "BIO *in_bio"
141.Fa "DSA **val_out"
142.Fc
143.Ft DSA *
144.Fo d2i_DSAPrivateKey_fp
145.Fa "FILE *in_fp"
146.Fa "DSA **val_out"
147.Fc
148.Ft int
149.Fo i2d_DSAPrivateKey_bio
150.Fa "BIO *out_bio"
151.Fa "DSA *val_in"
152.Fc
153.Ft int
154.Fo i2d_DSAPrivateKey_fp
155.Fa "FILE *out_fp"
156.Fa "DSA *val_in"
157.Fc
158.In openssl/dsa.h
159.Ft DSA *
160.Fo d2i_DSAparams
161.Fa "DSA **val_out"
162.Fa "const unsigned char **der_in"
163.Fa "long length"
164.Fc
165.Ft int
166.Fo i2d_DSAparams
167.Fa "const DSA *val_in"
168.Fa "unsigned char **der_out"
169.Fc
170.Ft DSA *
171.Fo d2i_DSAparams_bio
172.Fa "BIO *in_bio"
173.Fa "DSA **val_out"
174.Fc
175.Ft int
176.Fo i2d_DSAparams_bio
177.Fa "BIO *out_bio"
178.Fa "DSA *val_in"
179.Fc
180.Ft DSA *
181.Fo d2i_DSAparams_fp
182.Fa "FILE *in_fp"
183.Fa "DSA **val_out"
184.Fc
185.Ft int
186.Fo i2d_DSAparams_fp
187.Fa FILE *out_fp
188.Fa "DSA *val_in"
189.Fc
190.Ft DSA *
191.Fo DSAparams_dup
192.Fa "DSA *val_in"
193.Fc
194.Ft DSA_SIG *
195.Fo d2i_DSA_SIG
196.Fa "DSA_SIG **val_out"
197.Fa "const unsigned char **der_in"
198.Fa "long length"
199.Fc
200.Ft int
201.Fo i2d_DSA_SIG
202.Fa "const DSA_SIG *val_in"
203.Fa "unsigned char **der_out"
204.Fc
205.Sh DESCRIPTION
206These functions decode and encode DSA keys and parameters.
207For details about the semantics, examples, caveats, and bugs, see
208.Xr ASN1_item_d2i 3 .
209.Pp
210.Fn d2i_DSAPublicKey
211and
212.Fn i2d_DSAPublicKey
213decode and encode the DSA public key components using a non-standard
214format, so consider using
215.Fn d2i_DSA_PUBKEY
216and
217.Fn i2d_DSA_PUBKEY
218instead.
219The actual data encoded depends on the value of
220.Fa val_in->write_params .
221If
222.Fa val_in->write_params
223is zero, only the
224.Fa val_in->pub_key
225field is encoded as an ASN.1 INTEGER.
226If
227.Fa val_in->write_params
228is 1, then a SEQUENCE consisting of the
229.Fa val_in->p ,
230.Fa val_in->q ,
231.Fa val_in->g ,
232and
233.Fa val_in->pub_key
234fields is encoded.
235.Pp
236.Fn d2i_DSA_PUBKEY
237and
238.Fn i2d_DSA_PUBKEY
239decode and encode a DSA public key using an ASN.1
240.Vt SubjectPublicKeyInfo
241structure defined in RFC 5280 section 4.1
242and documented in
243.Xr X509_PUBKEY_new 3 .
244.Fn d2i_DSA_PUBKEY_bio ,
245.Fn d2i_DSA_PUBKEY_fp ,
246.Fn i2d_DSA_PUBKEY_bio ,
247and
248.Fn i2d_DSA_PUBKEY_fp
249are similar except that they decode or encode using a
250.Vt BIO
251or
252.Vt FILE
253pointer.
254.Pp
255.Fn d2i_DSAPrivateKey
256and
257.Fn i2d_DSAPrivateKey
258decode and encode the DSA private key components.
259The
260.Vt DSA
261object passed to the private key encoding functions should have all
262the private key components present.
263These functions use a non-standard structure consisting of a
264SEQUENCE containing the
265.Fa val_in->p ,
266.Fa val_in->q ,
267.Fa val_in->g ,
268.Fa val_in->pub_key ,
269and
270.Fa val_in->priv_key
271fields.
272This data format is unencrypted.
273For private key security when writing private keys to files,
274consider using
275.Xr PEM_write_DSAPrivateKey 3
276instead.
277.Fn d2i_DSAPrivateKey_bio ,
278.Fn d2i_DSAPrivateKey_fp ,
279.Fn i2d_DSAPrivateKey_bio ,
280and
281.Fn i2d_DSAPrivateKey_fp
282are similar except that they decode or encode using a
283.Vt BIO
284or
285.Vt FILE
286pointer.
287.Pp
288.Fn d2i_DSAparams
289and
290.Fn i2d_DSAparams
291decode and encode the DSA parameters using an ASN.1
292.Vt Dss-Parms
293structure defined in RFC 3279 section 2.3.2
294and used for the parameters field of the ASN.1
295.Vt AlgorithmIdentifier
296structure defined in RFC 5280 section 4.1.1.2.
297.Fn d2i_DSAparams_bio ,
298.Fn i2d_DSAparams_bio ,
299.Fn d2i_DSAparams_fp ,
300.Fn i2d_DSAparams_fp
301are similar except that they decode or encode using a
302.Vt BIO
303or
304.Vt FILE
305pointer.
306.Pp
307.Fn DSAparams_dup
308allocates and initializes an empty
309.Vt DSA
310object and copies the DSA parameters from
311.Fa val_in
312to it by calling
313.Fn i2d_DSAparams
314and
315.Fn d2i_DSAparams .
316If a private or public key are present in
317.Fa val_in ,
318they are not copied.
319.Pp
320.Fn d2i_DSA_SIG
321and
322.Fn i2d_DSA_SIG
323decode and encode a DSA signature using an ASN.1
324.Vt Dss-Sig-Value
325structure as defined in RFC 3279 section 2.2.2
326and used for the signatureValue field of the ASN.1
327.Vt Certificate
328structure described in RFC 5280 sections 4.1.1.3 and 5.1.1.3.
329.Sh RETURN VALUES
330.Fn d2i_DSAPublicKey ,
331.Fn d2i_DSA_PUBKEY ,
332.Fn d2i_DSA_PUBKEY_bio ,
333.Fn d2i_DSA_PUBKEY_fp ,
334.Fn d2i_DSAPrivateKey ,
335.Fn d2i_DSAPrivateKey_bio ,
336.Fn d2i_DSAPrivateKey_fp ,
337.Fn d2i_DSAparams ,
338.Fn d2i_DSAparams_bio ,
339.Fn d2i_DSAparams_fp ,
340and
341.Fn DSAparams_dup
342return a valid
343.Vt DSA
344object or
345.Dv NULL
346if an error occurs.
347.Pp
348.Fn d2i_DSA_SIG
349returns a valid
350.Vt DSA_SIG
351object or
352.Dv NULL
353if an error occurs.
354.Sh SEE ALSO
355.Xr ASN1_item_d2i 3 ,
356.Xr DSA_new 3 ,
357.Xr DSA_SIG_new 3 ,
358.Xr EVP_PKEY_set1_DSA 3 ,
359.Xr PEM_write_DSAPrivateKey 3 ,
360.Xr X509_PUBKEY_new 3
361.Sh STANDARDS
362RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
363Certificate Revocation List (CRL) Profile,
364section 4.1: Basic Certificate Fields
365.Pp
366RFC 3279: Algorithms and Identifiers for the Internet X.509 Public
367Key Infrastructure Certificate and Certificate Revocation List (CRL)
368Profile:
369.Bl -dash -compact
370.It
371section 2.2.2: DSA Signature Algorithm
372.It
373section 2.3.2: DSA Signature Keys
374.El
375.Sh HISTORY
376.Fn d2i_DSAPublicKey ,
377.Fn i2d_DSAPublicKey ,
378.Fn d2i_DSAPrivateKey ,
379and
380.Fn i2d_DSAPrivateKey
381first appeared in SSLeay 0.6.0.
382.Fn d2i_DSAPrivateKey_bio ,
383.Fn d2i_DSAPrivateKey_fp ,
384.Fn i2d_DSAPrivateKey_bio ,
385.Fn i2d_DSAPrivateKey_fp ,
386.Fn d2i_DSAparams ,
387.Fn i2d_DSAparams ,
388.Fn d2i_DSAparams_bio ,
389.Fn i2d_DSAparams_bio ,
390.Fn d2i_DSAparams_fp ,
391.Fn i2d_DSAparams_fp ,
392and
393.Fn DSAparams_dup
394first appeared in SSLeay 0.8.0.
395These functions have been available since
396.Ox 2.4 .
397.Pp
398.Fn d2i_DSA_SIG
399and
400.Fn i2d_DSA_SIG
401first appeared in OpenSSL 0.9.3 and have been available since
402.Ox 2.6 .
403.Pp
404.Fn d2i_DSA_PUBKEY ,
405.Fn i2d_DSA_PUBKEY ,
406.Fn d2i_DSA_PUBKEY_bio ,
407.Fn d2i_DSA_PUBKEY_fp ,
408.Fn i2d_DSA_PUBKEY_bio ,
409and
410.Fn i2d_DSA_PUBKEY_fp
411first appeared in OpenSSL 0.9.5 and have been available since
412.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/d2i_ECPKParameters.3 b/src/lib/libcrypto/man/d2i_ECPKParameters.3
deleted file mode 100644
index c4ede82f3b..0000000000
--- a/src/lib/libcrypto/man/d2i_ECPKParameters.3
+++ /dev/null
@@ -1,467 +0,0 @@
1.\" $OpenBSD: d2i_ECPKParameters.3,v 1.13 2024/10/24 21:42:10 tb Exp $
2.\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Matt Caswell <matt@openssl.org>.
22.\" Copyright (c) 2013, 2015 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: October 24 2024 $
69.Dt D2I_ECPKPARAMETERS 3
70.Os
71.Sh NAME
72.Nm d2i_ECPKParameters ,
73.Nm i2d_ECPKParameters ,
74.Nm d2i_ECPKParameters_bio ,
75.Nm i2d_ECPKParameters_bio ,
76.Nm d2i_ECPKParameters_fp ,
77.Nm i2d_ECPKParameters_fp ,
78.Nm d2i_ECParameters ,
79.Nm i2d_ECParameters ,
80.Nm ECParameters_dup ,
81.Nm d2i_ECPrivateKey ,
82.Nm i2d_ECPrivateKey ,
83.Nm d2i_ECPrivateKey_bio ,
84.Nm i2d_ECPrivateKey_bio ,
85.Nm d2i_ECPrivateKey_fp ,
86.Nm i2d_ECPrivateKey_fp ,
87.Nm o2i_ECPublicKey ,
88.Nm i2o_ECPublicKey ,
89.Nm ECPKParameters_print ,
90.Nm ECPKParameters_print_fp ,
91.Nm ECParameters_print ,
92.Nm ECParameters_print_fp ,
93.Nm d2i_EC_PUBKEY ,
94.Nm i2d_EC_PUBKEY ,
95.Nm d2i_EC_PUBKEY_bio ,
96.Nm i2d_EC_PUBKEY_bio ,
97.Nm d2i_EC_PUBKEY_fp ,
98.Nm i2d_EC_PUBKEY_fp
99.Nd decode and encode ASN.1 representations of elliptic curve entities
100.Sh SYNOPSIS
101.In openssl/ec.h
102.Ft EC_GROUP *
103.Fo d2i_ECPKParameters
104.Fa "EC_GROUP **val_out"
105.Fa "const unsigned char **der_in"
106.Fa "long length"
107.Fc
108.Ft int
109.Fo i2d_ECPKParameters
110.Fa "const EC_GROUP *val_in"
111.Fa "unsigned char **der_out"
112.Fc
113.Ft EC_GROUP *
114.Fo d2i_ECPKParameters_bio
115.Fa "BIO *in_bio"
116.Fa "EC_GROUP **val_out"
117.Fc
118.Ft int
119.Fo i2d_ECPKParameters_bio
120.Fa "BIO *out_bio"
121.Fa "EC_GROUP *val_in"
122.Fc
123.Ft EC_GROUP *
124.Fo d2i_ECPKParameters_fp
125.Fa "FILE *in_fp"
126.Fa "EC_GROUP **val_out"
127.Fc
128.Ft int
129.Fo i2d_ECPKParameters_fp
130.Fa "FILE *out_fp"
131.Fa "EC_GROUP *val_in"
132.Fc
133.Ft EC_KEY *
134.Fo d2i_ECParameters
135.Fa "EC_KEY **val_out"
136.Fa "const unsigned char **der_in"
137.Fa "long length"
138.Fc
139.Ft int
140.Fo i2d_ECParameters
141.Fa "EC_KEY *val_in"
142.Fa "unsigned char **der_out"
143.Fc
144.Ft EC_KEY *
145.Fo ECParameters_dup
146.Fa "EC_KEY *val_in"
147.Fc
148.Ft EC_KEY *
149.Fo d2i_ECPrivateKey
150.Fa "EC_KEY **val_out"
151.Fa "const unsigned char **der_in"
152.Fa "long length"
153.Fc
154.Ft int
155.Fo i2d_ECPrivateKey
156.Fa "EC_KEY *val_in"
157.Fa "unsigned char **der_out"
158.Fc
159.Ft EC_KEY *
160.Fo d2i_ECPrivateKey_bio
161.Fa "BIO *in_bio"
162.Fa "EC_KEY **val_out"
163.Fc
164.Ft int
165.Fo i2d_ECPrivateKey_bio
166.Fa "BIO *out_bio"
167.Fa "EC_KEY *val_in"
168.Fc
169.Ft EC_KEY *
170.Fo d2i_ECPrivateKey_fp
171.Fa "FILE *in_fp"
172.Fa "EC_KEY **val_out"
173.Fc
174.Ft int
175.Fo i2d_ECPrivateKey_fp
176.Fa "FILE *out_fp"
177.Fa "EC_KEY *val_in"
178.Fc
179.Ft EC_KEY *
180.Fo o2i_ECPublicKey
181.Fa "EC_KEY **val_out"
182.Fa "const unsigned char **der_in"
183.Fa "long length"
184.Fc
185.Ft int
186.Fo i2o_ECPublicKey
187.Fa "const EC_KEY *val_in"
188.Fa "unsigned char **der_out"
189.Fc
190.Ft int
191.Fo ECPKParameters_print
192.Fa "BIO *out_bio"
193.Fa "const EC_GROUP *val_in"
194.Fa "int indent"
195.Fc
196.Ft int
197.Fo ECPKParameters_print_fp
198.Fa "FILE *out_fp"
199.Fa "const EC_GROUP *val_in"
200.Fa "int indent"
201.Fc
202.Ft int
203.Fo ECParameters_print
204.Fa "BIO *out_bio"
205.Fa "const EC_KEY *val_in"
206.Fc
207.Ft int
208.Fo ECParameters_print_fp
209.Fa "FILE *out_fp"
210.Fa "const EC_KEY *val_in"
211.Fc
212.In openssl/x509.h
213.Ft EC_KEY *
214.Fo d2i_EC_PUBKEY
215.Fa "EC_KEY **val_out"
216.Fa "const unsigned char **der_in"
217.Fa "long length"
218.Fc
219.Ft int
220.Fo i2d_EC_PUBKEY
221.Fa "EC_KEY *val_in"
222.Fa "unsigned char **der_out"
223.Fc
224.Ft EC_KEY *
225.Fo d2i_EC_PUBKEY_bio
226.Fa "BIO *in_bio"
227.Fa "EC_KEY **val_out"
228.Fc
229.Ft int
230.Fo i2d_EC_PUBKEY_bio
231.Fa "BIO *out_bio"
232.Fa "EC_KEY *val_in"
233.Fc
234.Ft EC_KEY *
235.Fo d2i_EC_PUBKEY_fp
236.Fa "FILE *in_fp"
237.Fa "EC_KEY **val_out"
238.Fc
239.Ft int
240.Fo i2d_EC_PUBKEY_fp
241.Fa "FILE *out_fp"
242.Fa "EC_KEY *val_in"
243.Fc
244.Sh DESCRIPTION
245These functions decode and encode elliptic curve keys and parameters.
246For details about the semantics, examples, caveats, and bugs, see
247.Xr ASN1_item_d2i 3 .
248.Pp
249.Fn d2i_ECPKParameters
250and
251.Fn i2d_ECPKParameters
252decode and encode the parameters of an elliptic curve.
253.Fn d2i_ECPKParameters_bio ,
254.Fn i2d_ECPKParameters_bio ,
255.Fn d2i_ECPKParameters_fp ,
256and
257.Fn i2d_ECPKParameters_fp
258are similar except that they decode or encode using a
259.Vt BIO
260or
261.Vt FILE
262pointer.
263These four functions are currently implemented as macros.
264.Pp
265.Fn d2i_ECParameters
266does the same parsing as
267.Fn d2i_ECPKParameters
268but saves the result in the
269.Fa group
270field of an
271.Vt EC_KEY
272structure.
273.Pp
274.Fn i2d_ECParameters
275produces the same output as
276.Fn i2d_ECPKParameters
277but uses
278.Fa val_in->group
279for input instead of
280.Fa val_in .
281.Pp
282.Fn ECParameters_dup
283allocates and initializes an empty
284.Vt EC_KEY
285object and copies the EC parameters from
286.Fa val_in
287to it by calling
288.Fn i2d_ECParameters
289and
290.Fn d2i_ECParameters .
291If a private or public key or any flags are present in
292.Fa val_in ,
293they are not copied.
294.Pp
295.Fn d2i_ECPrivateKey
296and
297.Fn i2d_ECPrivateKey
298decode and encode an EC private key using an ASN.1
299.Vt ECPrivateKey
300structure defined in RFC 5915 section 3 and used for the privateKey
301field of the ASN.1
302.Vt PrivateKeyInfo
303structure defined in RFC 5208 section 5, see
304.Xr PKCS8_PRIV_KEY_INFO_new 3 .
305.Fn d2i_ECPrivateKey_bio ,
306.Fn i2d_ECPrivateKey_bio ,
307.Fn d2i_ECPrivateKey_fp ,
308and
309.Fn i2d_ECPrivateKey_fp
310are similar except that they decode or encode using a
311.Vt BIO
312or
313.Vt FILE
314pointer.
315.Pp
316.Fn o2i_ECPublicKey
317and
318.Fn i2o_ECPublicKey
319decode and encode an EC public key.
320In contrast to
321.Xr ASN1_item_d2i 3 ,
322.Fn o2i_ECPublicKey
323requires
324.Fa val_out ,
325.Pf * Fa val_out ,
326and
327.Po Pf * Fa val_out Pc Ns -> Ns Fa group
328to be
329.Pf non- Dv NULL .
330.Pp
331.Fn ECPKParameters_print
332and
333.Fn ECPKParameters_print_fp
334print human-readable output of the public parameters of the
335.Vt EC_GROUP
336to
337.Fa out_bio
338or
339.Fa out_fp .
340The output lines are indented by
341.Fa indent
342spaces.
343.Pp
344.Fn ECParameters_print
345and
346.Fn ECParameters_print_fp
347print the parameter components of
348.Fa val_in
349to
350.Fa out_bio
351or
352.Fa out_fp .
353.Pp
354.Fn d2i_EC_PUBKEY
355and
356.Fn i2d_EC_PUBKEY
357decode and encode an EC public key using an ASN.1
358.Vt SubjectPublicKeyInfo
359structure defined in RFC 5280 section 4.1 and documented in
360.Xr X509_PUBKEY_new 3 .
361.Fn d2i_EC_PUBKEY_bio ,
362.Fn i2d_EC_PUBKEY_bio ,
363.Fn d2i_EC_PUBKEY_fp ,
364and
365.Fn i2d_EC_PUBKEY_fp
366are similar except that they decode or encode using a
367.Vt BIO
368or
369.Vt FILE
370pointer.
371.Sh RETURN VALUES
372.Fn d2i_ECPKParameters ,
373.Fn d2i_ECPKParameters_bio ,
374and
375.Fn d2i_ECPKParameters_fp
376return a valid
377.Vt EC_GROUP
378structure or
379.Dv NULL
380if an error occurs.
381.Pp
382.Fn d2i_ECParameters ,
383.Fn ECParameters_dup ,
384.Fn d2i_ECPrivateKey ,
385.Fn d2i_ECPrivateKey_bio ,
386.Fn d2i_ECPrivateKey_fp ,
387.Fn o2i_ECPublicKey ,
388.Fn d2i_EC_PUBKEY ,
389.Fn d2i_EC_PUBKEY_bio ,
390and
391.Fn d2i_EC_PUBKEY_fp
392return a valid
393.Vt EC_KEY
394structure or
395.Dv NULL
396if an error occurs.
397.Pp
398.Fn i2d_ECPKParameters ,
399.Fn i2d_ECParameters ,
400.Fn i2d_ECPrivateKey ,
401.Fn i2o_ECPublicKey ,
402and
403.Fn i2d_EC_PUBKEY
404return the number of bytes successfully encoded or a negative value if
405an error occurs.
406.Pp
407.Fn i2d_ECPKParameters_bio ,
408.Fn i2d_ECPKParameters_fp ,
409.Fn i2d_ECPrivateKey_bio ,
410.Fn i2d_ECPrivateKey_fp ,
411.Fn ECPKParameters_print ,
412.Fn ECPKParameters_print_fp ,
413.Fn ECParameters_print ,
414.Fn ECParameters_print_fp ,
415.Fn i2d_EC_PUBKEY_bio ,
416and
417.Fn i2d_EC_PUBKEY_fp
418return 1 for success or 0 if an error occurs.
419.Sh SEE ALSO
420.Xr ASN1_item_d2i 3 ,
421.Xr EC_GROUP_copy 3 ,
422.Xr EC_GROUP_new 3 ,
423.Xr EC_KEY_new 3 ,
424.Xr EVP_PKEY_set1_EC_KEY 3 ,
425.Xr PEM_write_ECPrivateKey 3 ,
426.Xr PKCS8_PRIV_KEY_INFO_new 3 ,
427.Xr X509_PUBKEY_new 3
428.Sh STANDARDS
429RFC 5915: Elliptic Curve Private Key Structure
430.Pp
431RFC 5208: Public-Key Cryptography Standards (PKCS) #8:
432Private-Key Information Syntax Specification
433.Pp
434RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
435Certificate Revocation List (CRL) Profile,
436section 4.1: Basic Certificate Fields
437.Sh HISTORY
438.Fn d2i_ECPKParameters ,
439.Fn i2d_ECPKParameters ,
440.Fn d2i_ECPKParameters_bio ,
441.Fn i2d_ECPKParameters_bio ,
442.Fn d2i_ECPKParameters_fP ,
443.Fn i2d_ECPKParameters_fp ,
444.Fn d2i_ECParameters ,
445.Fn i2d_ECParameters ,
446.Fn ECParameters_dup ,
447.Fn d2i_ECPrivateKey ,
448.Fn i2d_ECPrivateKey ,
449.Fn d2i_ECPrivateKey_bio ,
450.Fn i2d_ECPrivateKey_bio ,
451.Fn d2i_ECPrivateKey_fp ,
452.Fn i2d_ECPrivateKey_fp ,
453.Fn o2i_ECPublicKey ,
454.Fn i2o_ECPublicKey ,
455.Fn ECPKParameters_print ,
456.Fn ECPKParameters_print_fp ,
457.Fn ECParameters_print ,
458.Fn ECParameters_print_fp ,
459.Fn d2i_EC_PUBKEY ,
460.Fn i2d_EC_PUBKEY ,
461.Fn d2i_EC_PUBKEY_bio ,
462.Fn i2d_EC_PUBKEY_bio ,
463.Fn d2i_EC_PUBKEY_fp ,
464and
465.Fn i2d_EC_PUBKEY_fp
466first appeared in OpenSSL 0.9.8 and have been available since
467.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/d2i_ESS_SIGNING_CERT.3 b/src/lib/libcrypto/man/d2i_ESS_SIGNING_CERT.3
deleted file mode 100644
index c1d61d3b5e..0000000000
--- a/src/lib/libcrypto/man/d2i_ESS_SIGNING_CERT.3
+++ /dev/null
@@ -1,118 +0,0 @@
1.\" $OpenBSD: d2i_ESS_SIGNING_CERT.3,v 1.2 2018/03/23 04:34:23 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 23 2018 $
18.Dt D2I_ESS_SIGNING_CERT 3
19.Os
20.Sh NAME
21.Nm d2i_ESS_SIGNING_CERT ,
22.Nm i2d_ESS_SIGNING_CERT ,
23.Nm d2i_ESS_CERT_ID ,
24.Nm i2d_ESS_CERT_ID ,
25.Nm d2i_ESS_ISSUER_SERIAL ,
26.Nm i2d_ESS_ISSUER_SERIAL
27.Nd decode and encode signing certificates for S/MIME
28.Sh SYNOPSIS
29.In openssl/ts.h
30.Ft ESS_SIGNING_CERT *
31.Fo d2i_ESS_SIGNING_CERT
32.Fa "ESS_SIGNING_CERT **val_out"
33.Fa "const unsigned char **der_in"
34.Fa "long length"
35.Fc
36.Ft int
37.Fo i2d_ESS_SIGNING_CERT
38.Fa "const ESS_SIGNING_CERT *val_in"
39.Fa "unsigned char **der_out"
40.Fc
41.Ft ESS_CERT_ID *
42.Fo d2i_ESS_CERT_ID
43.Fa "ESS_CERT_ID **val_out"
44.Fa "const unsigned char **der_in"
45.Fa "long length"
46.Fc
47.Ft int
48.Fo i2d_ESS_CERT_ID
49.Fa "const ESS_CERT_ID *val_in"
50.Fa "unsigned char **der_out"
51.Fc
52.Ft ESS_ISSUER_SERIAL *
53.Fo d2i_ESS_ISSUER_SERIAL
54.Fa "ESS_ISSUER_SERIAL **val_out"
55.Fa "const unsigned char **der_in"
56.Fa "long length"
57.Fc
58.Ft int
59.Fo i2d_ESS_ISSUER_SERIAL
60.Fa "const ESS_ISSUER_SERIAL *val_in"
61.Fa "unsigned char **der_out"
62.Fc
63.Sh DESCRIPTION
64These functions decode and encode signing certificate attribute
65structures.
66For details about the semantics, examples, caveats, and bugs, see
67.Xr ASN1_item_d2i 3 .
68.Pp
69.Fn d2i_ESS_SIGNING_CERT
70and
71.Fn i2d_ESS_SIGNING_CERT
72decode and encode an ASN.1
73.Vt SigningCertificate
74structure defined in RFC 2634 section 5.4.
75.Pp
76.Fn d2i_ESS_CERT_ID
77and
78.Fn i2d_ESS_CERT_ID
79decode and encode an ASN.1
80.Vt ESSCertID
81structure defined in RFC 2634 section 5.4.1.
82.Pp
83.Fn d2i_ESS_ISSUER_SERIAL
84and
85.Fn i2d_ESS_ISSUER_SERIAL
86decode and encode an ASN.1
87.Vt IssuerSerial
88structure defined in RFC 2634 section 5.4.1.
89.Sh RETURN VALUES
90.Fn d2i_ESS_SIGNING_CERT ,
91.Fn d2i_ESS_CERT_ID ,
92and
93.Fn d2i_ESS_ISSUER_SERIAL
94return an
95.Vt ESS_SIGNING_CERT ,
96.Vt ESS_CERT_ID ,
97or
98.Vt ESS_ISSUER_SERIAL
99object, respectively, or
100.Dv NULL
101if an error occurs.
102.Pp
103.Fn i2d_ESS_SIGNING_CERT ,
104.Fn i2d_ESS_CERT_ID ,
105and
106.Fn i2d_ESS_ISSUER_SERIAL
107return the number of bytes successfully encoded or a negative value
108if an error occurs.
109.Sh SEE ALSO
110.Xr ASN1_item_d2i 3 ,
111.Xr ESS_SIGNING_CERT_new 3
112.Sh STANDARDS
113RFC 2634: Enhanced Security Services for S/MIME,
114section 5: Signing Certificate Attribute
115.Sh HISTORY
116These functions first appeared in OpenSSL 1.0.0
117and have been available since
118.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/d2i_GENERAL_NAME.3 b/src/lib/libcrypto/man/d2i_GENERAL_NAME.3
deleted file mode 100644
index bfdcc6c67c..0000000000
--- a/src/lib/libcrypto/man/d2i_GENERAL_NAME.3
+++ /dev/null
@@ -1,160 +0,0 @@
1.\" $OpenBSD: d2i_GENERAL_NAME.3,v 1.4 2018/03/22 21:08:22 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 22 2018 $
18.Dt D2I_GENERAL_NAME 3
19.Os
20.Sh NAME
21.Nm d2i_GENERAL_NAME ,
22.Nm i2d_GENERAL_NAME ,
23.Nm d2i_GENERAL_NAMES ,
24.Nm i2d_GENERAL_NAMES ,
25.Nm d2i_EDIPARTYNAME ,
26.Nm i2d_EDIPARTYNAME ,
27.Nm d2i_OTHERNAME ,
28.Nm i2d_OTHERNAME
29.Nd decode and encode names for use in X.509 extensions
30.Sh SYNOPSIS
31.In openssl/x509v3.h
32.Ft GENERAL_NAME *
33.Fo d2i_GENERAL_NAME
34.Fa "GENERAL_NAME **val_out"
35.Fa "const unsigned char **der_in"
36.Fa "long length"
37.Fc
38.Ft int
39.Fo i2d_GENERAL_NAME
40.Fa "GENERAL_NAME *val_in"
41.Fa "unsigned char **der_out"
42.Fc
43.Ft GENERAL_NAMES *
44.Fo d2i_GENERAL_NAMES
45.Fa "GENERAL_NAMES **val_out"
46.Fa "const unsigned char **der_in"
47.Fa "long length"
48.Fc
49.Ft int
50.Fo i2d_GENERAL_NAMES
51.Fa "GENERAL_NAMES *val_in"
52.Fa "unsigned char **der_out"
53.Fc
54.Ft EDIPARTYNAME *
55.Fo d2i_EDIPARTYNAME
56.Fa "EDIPARTYNAME **val_out"
57.Fa "const unsigned char **der_in"
58.Fa "long length"
59.Fc
60.Ft int
61.Fo i2d_EDIPARTYNAME
62.Fa "EDIPARTYNAME *val_in"
63.Fa "unsigned char **der_out"
64.Fc
65.Ft OTHERNAME *
66.Fo d2i_OTHERNAME
67.Fa "OTHERNAME **val_out"
68.Fa "const unsigned char **der_in"
69.Fa "long length"
70.Fc
71.Ft int
72.Fo i2d_OTHERNAME
73.Fa "OTHERNAME *val_in"
74.Fa "unsigned char **der_out"
75.Fc
76.Sh DESCRIPTION
77These functions decode and encode names that can be used in X.509
78extensions.
79For details about the semantics, examples, caveats, and bugs, see
80.Xr ASN1_item_d2i 3 .
81.Pp
82.Fn d2i_GENERAL_NAME
83and
84.Fn i2d_GENERAL_NAME
85decode and encode an ASN.1
86.Vt GeneralName
87structure defined in RFC 5280 section 4.2.1.6.
88.Pp
89.Fn d2i_GENERAL_NAMES
90and
91.Fn i2d_GENERAL_NAMES
92decode and encode an ASN.1
93.Vt GeneralNames
94structure defined in RFC 5280 section 4.2.1.6.
95.Pp
96.Fn d2i_EDIPARTYNAME
97and
98.Fn i2d_EDIPARTYNAME
99decode and encode an ASN.1
100.Vt EDIPartyName
101structure defined in RFC 5280 section 4.2.1.6.
102.Pp
103.Fn d2i_OTHERNAME
104and
105.Fn i2d_OTHERNAME
106decode and encode an ASN.1
107.Vt OtherName
108structure defined in RFC 5280 section 4.2.1.6.
109.Sh RETURN VALUES
110.Fn d2i_GENERAL_NAME ,
111.Fn d2i_GENERAL_NAMES ,
112.Fn d2i_EDIPARTYNAME ,
113and
114.Fn d2i_OTHERNAME
115return a
116.Vt GENERAL_NAME ,
117.Vt GENERAL_NAMES ,
118.Vt EDIPARTYNAME ,
119or
120.Vt OTHERNAME
121object, respectively, or
122.Dv NULL
123if an error occurs.
124.Pp
125.Fn i2d_GENERAL_NAME ,
126.Fn i2d_GENERAL_NAMES ,
127.Fn i2d_EDIPARTYNAME ,
128and
129.Fn i2d_OTHERNAME
130return the number of bytes successfully encoded or a negative value
131if an error occurs.
132.Sh SEE ALSO
133.Xr ASN1_item_d2i 3 ,
134.Xr d2i_X509_NAME 3 ,
135.Xr GENERAL_NAME_new 3 ,
136.Xr X509_EXTENSION_new 3
137.Sh STANDARDS
138RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
139Certificate Revocation List (CRL) Profile,
140section 4.2: Certificate Extensions
141.Sh HISTORY
142.Fn d2i_GENERAL_NAME ,
143.Fn i2d_GENERAL_NAME ,
144.Fn d2i_GENERAL_NAMES ,
145and
146.Fn i2d_GENERAL_NAMES
147first appeared in OpenSSL 0.9.2b and have been available since
148.Ox 2.6 .
149.Pp
150.Fn d2i_OTHERNAME
151and
152.Fn i2d_OTHERNAME
153first appeared in OpenSSL 0.9.5 and have been available since
154.Ox 2.7 .
155.Pp
156.Fn d2i_EDIPARTYNAME
157and
158.Fn i2d_EDIPARTYNAME
159first appeared in OpenSSL 0.9.7 and have been available since
160.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/d2i_OCSP_REQUEST.3 b/src/lib/libcrypto/man/d2i_OCSP_REQUEST.3
deleted file mode 100644
index 07a990556d..0000000000
--- a/src/lib/libcrypto/man/d2i_OCSP_REQUEST.3
+++ /dev/null
@@ -1,181 +0,0 @@
1.\" $OpenBSD: d2i_OCSP_REQUEST.3,v 1.3 2021/03/12 05:18:00 jsg Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 12 2021 $
18.Dt D2I_OCSP_REQUEST 3
19.Os
20.Sh NAME
21.Nm d2i_OCSP_REQUEST ,
22.Nm i2d_OCSP_REQUEST ,
23.Nm d2i_OCSP_SIGNATURE ,
24.Nm i2d_OCSP_SIGNATURE ,
25.Nm d2i_OCSP_REQINFO ,
26.Nm i2d_OCSP_REQINFO ,
27.Nm d2i_OCSP_ONEREQ ,
28.Nm i2d_OCSP_ONEREQ ,
29.Nm d2i_OCSP_CERTID ,
30.Nm i2d_OCSP_CERTID ,
31.Nm d2i_OCSP_SERVICELOC ,
32.Nm i2d_OCSP_SERVICELOC
33.Nd decode and encode OCSP requests
34.Sh SYNOPSIS
35.In openssl/ocsp.h
36.Ft OCSP_REQUEST *
37.Fo d2i_OCSP_REQUEST
38.Fa "OCSP_REQUEST **val_out"
39.Fa "const unsigned char **der_in"
40.Fa "long length"
41.Fc
42.Ft int
43.Fo i2d_OCSP_REQUEST
44.Fa "OCSP_REQUEST *val_in"
45.Fa "unsigned char **der_out"
46.Fc
47.Ft OCSP_SIGNATURE *
48.Fo d2i_OCSP_SIGNATURE
49.Fa "OCSP_SIGNATURE **val_out"
50.Fa "const unsigned char **der_in"
51.Fa "long length"
52.Fc
53.Ft int
54.Fo i2d_OCSP_SIGNATURE
55.Fa "OCSP_SIGNATURE *val_in"
56.Fa "unsigned char **der_out"
57.Fc
58.Ft OCSP_REQINFO *
59.Fo d2i_OCSP_REQINFO
60.Fa "OCSP_REQINFO **val_out"
61.Fa "const unsigned char **der_in"
62.Fa "long length"
63.Fc
64.Ft int
65.Fo i2d_OCSP_REQINFO
66.Fa "OCSP_REQINFO *val_in"
67.Fa "unsigned char **der_out"
68.Fc
69.Ft OCSP_ONEREQ *
70.Fo d2i_OCSP_ONEREQ
71.Fa "OCSP_ONEREQ **val_out"
72.Fa "const unsigned char **der_in"
73.Fa "long length"
74.Fc
75.Ft int
76.Fo i2d_OCSP_ONEREQ
77.Fa "OCSP_ONEREQ *val_in"
78.Fa "unsigned char **der_out"
79.Fc
80.Ft OCSP_CERTID *
81.Fo d2i_OCSP_CERTID
82.Fa "OCSP_CERTID **val_out"
83.Fa "const unsigned char **der_in"
84.Fa "long length"
85.Fc
86.Ft int
87.Fo i2d_OCSP_CERTID
88.Fa "OCSP_CERTID *val_in"
89.Fa "unsigned char **der_out"
90.Fc
91.Ft OCSP_SERVICELOC *
92.Fo d2i_OCSP_SERVICELOC
93.Fa "OCSP_SERVICELOC **val_out"
94.Fa "const unsigned char **der_in"
95.Fa "long length"
96.Fc
97.Ft int
98.Fo i2d_OCSP_SERVICELOC
99.Fa "OCSP_SERVICELOC *val_in"
100.Fa "unsigned char **der_out"
101.Fc
102.Sh DESCRIPTION
103These functions decode and encode ASN.1 structures used for OCSP
104requests.
105For details about the semantics, examples, caveats, and bugs, see
106.Xr ASN1_item_d2i 3 .
107.Pp
108.Fn d2i_OCSP_REQUEST
109and
110.Fn i2d_OCSP_REQUEST
111decode and encode an ASN.1
112.Vt OCSPRequest
113structure defined in RFC 6960 section 4.1.1.
114.Pp
115.Fn d2i_OCSP_SIGNATURE
116and
117.Fn i2d_OCSP_SIGNATURE
118decode and encode an ASN.1
119.Vt Signature
120structure defined in RFC 6960 section 4.1.1.
121.Pp
122.Fn d2i_OCSP_REQINFO
123and
124.Fn i2d_OCSP_REQINFO
125decode and encode an ASN.1
126.Vt TBSRequest
127structure defined in RFC 6960 section 4.1.1.
128.Pp
129.Fn d2i_OCSP_ONEREQ
130and
131.Fn i2d_OCSP_ONEREQ
132decode and encode an ASN.1
133.Vt Request
134structure defined in RFC 6960 section 4.1.1.
135.Pp
136.Fn d2i_OCSP_CERTID
137and
138.Fn i2d_OCSP_CERTID
139decode and encode an ASN.1
140.Vt CertID
141structure defined in RFC 6960 section 4.1.1.
142.Pp
143.Fn d2i_OCSP_SERVICELOC
144and
145.Fn i2d_OCSP_SERVICELOC
146decode and encode an ASN.1
147.Vt ServiceLocator
148structure defined in RFC 6960 section 4.4.6.
149.Sh RETURN VALUES
150.Fn d2i_OCSP_REQUEST ,
151.Fn d2i_OCSP_SIGNATURE ,
152.Fn d2i_OCSP_REQINFO ,
153.Fn d2i_OCSP_ONEREQ ,
154.Fn d2i_OCSP_CERTID ,
155and
156.Fn d2i_OCSP_SERVICELOC
157return an object of the respective type or
158.Dv NULL
159if an error occurs.
160.Pp
161.Fn i2d_OCSP_REQUEST ,
162.Fn i2d_OCSP_SIGNATURE ,
163.Fn i2d_OCSP_REQINFO ,
164.Fn i2d_OCSP_ONEREQ ,
165.Fn i2d_OCSP_CERTID ,
166and
167.Fn i2d_OCSP_SERVICELOC
168return the number of bytes successfully encoded or a negative value
169if an error occurs.
170.Sh SEE ALSO
171.Xr ASN1_item_d2i 3 ,
172.Xr OCSP_CERTID_new 3 ,
173.Xr OCSP_REQUEST_new 3 ,
174.Xr OCSP_SERVICELOC_new 3
175.Sh STANDARDS
176RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
177Status Protocol, section 4.1: Request Syntax
178.Sh HISTORY
179These functions first appeared in OpenSSL 0.9.7
180and have been available since
181.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/d2i_OCSP_RESPONSE.3 b/src/lib/libcrypto/man/d2i_OCSP_RESPONSE.3
deleted file mode 100644
index 716e85dc6e..0000000000
--- a/src/lib/libcrypto/man/d2i_OCSP_RESPONSE.3
+++ /dev/null
@@ -1,248 +0,0 @@
1.\" $OpenBSD: d2i_OCSP_RESPONSE.3,v 1.4 2021/03/12 05:18:00 jsg Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 12 2021 $
18.Dt D2I_OCSP_RESPONSE 3
19.Os
20.Sh NAME
21.Nm d2i_OCSP_RESPONSE ,
22.Nm i2d_OCSP_RESPONSE ,
23.Nm d2i_OCSP_RESPBYTES ,
24.Nm i2d_OCSP_RESPBYTES ,
25.Nm d2i_OCSP_BASICRESP ,
26.Nm i2d_OCSP_BASICRESP ,
27.Nm d2i_OCSP_RESPDATA ,
28.Nm i2d_OCSP_RESPDATA ,
29.Nm d2i_OCSP_RESPID ,
30.Nm i2d_OCSP_RESPID ,
31.Nm d2i_OCSP_SINGLERESP ,
32.Nm i2d_OCSP_SINGLERESP ,
33.Nm d2i_OCSP_CERTSTATUS ,
34.Nm i2d_OCSP_CERTSTATUS ,
35.Nm d2i_OCSP_REVOKEDINFO ,
36.Nm i2d_OCSP_REVOKEDINFO ,
37.Nm d2i_OCSP_CRLID ,
38.Nm i2d_OCSP_CRLID
39.Nd decode and encode OCSP responses
40.Sh SYNOPSIS
41.In openssl/ocsp.h
42.Ft OCSP_RESPONSE *
43.Fo d2i_OCSP_RESPONSE
44.Fa "OCSP_RESPONSE **val_out"
45.Fa "const unsigned char **der_in"
46.Fa "long length"
47.Fc
48.Ft int
49.Fo i2d_OCSP_RESPONSE
50.Fa "OCSP_RESPONSE *val_in"
51.Fa "unsigned char **der_out"
52.Fc
53.Ft OCSP_RESPBYTES *
54.Fo d2i_OCSP_RESPBYTES
55.Fa "OCSP_RESPBYTES **val_out"
56.Fa "const unsigned char **der_in"
57.Fa "long length"
58.Fc
59.Ft int
60.Fo i2d_OCSP_RESPBYTES
61.Fa "OCSP_RESPBYTES *val_in"
62.Fa "unsigned char **der_out"
63.Fc
64.Ft OCSP_BASICRESP *
65.Fo d2i_OCSP_BASICRESP
66.Fa "OCSP_BASICRESP **val_out"
67.Fa "const unsigned char **der_in"
68.Fa "long length"
69.Fc
70.Ft int
71.Fo i2d_OCSP_BASICRESP
72.Fa "OCSP_BASICRESP *val_in"
73.Fa "unsigned char **der_out"
74.Fc
75.Ft OCSP_RESPDATA *
76.Fo d2i_OCSP_RESPDATA
77.Fa "OCSP_RESPDATA **val_out"
78.Fa "const unsigned char **der_in"
79.Fa "long length"
80.Fc
81.Ft int
82.Fo i2d_OCSP_RESPDATA
83.Fa "OCSP_RESPDATA *val_in"
84.Fa "unsigned char **der_out"
85.Fc
86.Ft OCSP_RESPID *
87.Fo d2i_OCSP_RESPID
88.Fa "OCSP_RESPID **val_out"
89.Fa "const unsigned char **der_in"
90.Fa "long length"
91.Fc
92.Ft int
93.Fo i2d_OCSP_RESPID
94.Fa "OCSP_RESPID *val_in"
95.Fa "unsigned char **der_out"
96.Fc
97.Ft OCSP_SINGLERESP *
98.Fo d2i_OCSP_SINGLERESP
99.Fa "OCSP_SINGLERESP **val_out"
100.Fa "const unsigned char **der_in"
101.Fa "long length"
102.Fc
103.Ft int
104.Fo i2d_OCSP_SINGLERESP
105.Fa "OCSP_SINGLERESP *val_in"
106.Fa "unsigned char **der_out"
107.Fc
108.Ft OCSP_CERTSTATUS *
109.Fo d2i_OCSP_CERTSTATUS
110.Fa "OCSP_CERTSTATUS **val_out"
111.Fa "const unsigned char **der_in"
112.Fa "long length"
113.Fc
114.Ft int
115.Fo i2d_OCSP_CERTSTATUS
116.Fa "OCSP_CERTSTATUS *val_in"
117.Fa "unsigned char **der_out"
118.Fc
119.Ft OCSP_REVOKEDINFO *
120.Fo d2i_OCSP_REVOKEDINFO
121.Fa "OCSP_REVOKEDINFO **val_out"
122.Fa "const unsigned char **der_in"
123.Fa "long length"
124.Fc
125.Ft int
126.Fo i2d_OCSP_REVOKEDINFO
127.Fa "OCSP_REVOKEDINFO *val_in"
128.Fa "unsigned char **der_out"
129.Fc
130.Ft OCSP_CRLID *
131.Fo d2i_OCSP_CRLID
132.Fa "OCSP_CRLID **val_out"
133.Fa "const unsigned char **der_in"
134.Fa "long length"
135.Fc
136.Ft int
137.Fo i2d_OCSP_CRLID
138.Fa "OCSP_CRLID *val_in"
139.Fa "unsigned char **der_out"
140.Fc
141.Sh DESCRIPTION
142These functions decode and encode ASN.1 structures used for OCSP
143responses.
144For details about the semantics, examples, caveats, and bugs, see
145.Xr ASN1_item_d2i 3 .
146.Pp
147.Fn d2i_OCSP_RESPONSE
148and
149.Fn i2d_OCSP_RESPONSE
150decode and encode an ASN.1
151.Vt OCSPResponse
152structure defined in RFC 6960 section 4.2.1.
153.Pp
154.Fn d2i_OCSP_RESPBYTES
155and
156.Fn i2d_OCSP_RESPBYTES
157decode and encode an ASN.1
158.Vt ResponseBytes
159structure defined in RFC 6960 section 4.2.1.
160.Pp
161.Fn d2i_OCSP_BASICRESP
162and
163.Fn i2d_OCSP_BASICRESP
164decode and encode an ASN.1
165.Vt BasicOCSPResponse
166structure defined in RFC 6960 section 4.2.1.
167.Pp
168.Fn d2i_OCSP_RESPDATA
169and
170.Fn i2d_OCSP_RESPDATA
171decode and encode an ASN.1
172.Vt ResponseData
173structure defined in RFC 6960 section 4.2.1.
174.Pp
175.Fn d2i_OCSP_RESPID
176and
177.Fn i2d_OCSP_RESPID
178decode and encode an ASN.1
179.Vt ResponderID
180structure defined in RFC 6960 section 4.2.1.
181.Pp
182.Fn d2i_OCSP_SINGLERESP
183and
184.Fn i2d_OCSP_SINGLERESP
185decode and encode an ASN.1
186.Vt SingleResponse
187structure defined in RFC 6960 section 4.2.1.
188.Pp
189.Fn d2i_OCSP_CERTSTATUS
190and
191.Fn i2d_OCSP_CERTSTATUS
192decode and encode an ASN.1
193.Vt CertStatus
194structure defined in RFC 6960 section 4.2.1.
195.Pp
196.Fn d2i_OCSP_REVOKEDINFO
197and
198.Fn i2d_OCSP_REVOKEDINFO
199decode and encode an ASN.1
200.Vt RevokedInfo
201structure defined in RFC 6960 section 4.2.1.
202.Pp
203.Fn d2i_OCSP_CRLID
204and
205.Fn i2d_OCSP_CRLID
206decode and encode an ASN.1
207.Vt CrlID
208structure defined in RFC 6960 section 4.4.2.
209.Sh RETURN VALUES
210.Fn d2i_OCSP_RESPONSE ,
211.Fn d2i_OCSP_RESPBYTES ,
212.Fn d2i_OCSP_BASICRESP ,
213.Fn d2i_OCSP_RESPDATA ,
214.Fn d2i_OCSP_RESPID ,
215.Fn d2i_OCSP_SINGLERESP ,
216.Fn d2i_OCSP_CERTSTATUS ,
217.Fn d2i_OCSP_REVOKEDINFO ,
218and
219.Fn d2i_OCSP_CRLID
220return an object of the respective type or
221.Dv NULL
222if an error occurs.
223.Pp
224.Fn i2d_OCSP_RESPONSE ,
225.Fn i2d_OCSP_RESPBYTES ,
226.Fn i2d_OCSP_BASICRESP ,
227.Fn i2d_OCSP_RESPDATA ,
228.Fn i2d_OCSP_RESPID ,
229.Fn i2d_OCSP_SINGLERESP ,
230.Fn i2d_OCSP_CERTSTATUS ,
231.Fn i2d_OCSP_REVOKEDINFO ,
232and
233.Fn i2d_OCSP_CRLID
234return the number of bytes successfully encoded or a negative value
235if an error occurs.
236.Sh SEE ALSO
237.Xr ASN1_item_d2i 3 ,
238.Xr OCSP_CRLID_new 3 ,
239.Xr OCSP_REQUEST_new 3 ,
240.Xr OCSP_RESPONSE_new 3 ,
241.Xr OCSP_SINGLERESP_new 3
242.Sh STANDARDS
243RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
244Status Protocol, section 4.2: Response Syntax
245.Sh HISTORY
246These functions first appeared in OpenSSL 0.9.7
247and have been available since
248.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/d2i_PKCS12.3 b/src/lib/libcrypto/man/d2i_PKCS12.3
deleted file mode 100644
index 55272d1f36..0000000000
--- a/src/lib/libcrypto/man/d2i_PKCS12.3
+++ /dev/null
@@ -1,202 +0,0 @@
1.\" $OpenBSD: d2i_PKCS12.3,v 1.2 2018/03/21 17:57:48 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 21 2018 $
18.Dt D2I_PKCS12 3
19.Os
20.Sh NAME
21.Nm d2i_PKCS12 ,
22.Nm i2d_PKCS12 ,
23.Nm d2i_PKCS12_bio ,
24.Nm i2d_PKCS12_bio ,
25.Nm d2i_PKCS12_fp ,
26.Nm i2d_PKCS12_fp ,
27.Nm d2i_PKCS12_MAC_DATA ,
28.Nm i2d_PKCS12_MAC_DATA ,
29.Nm d2i_PKCS12_SAFEBAG ,
30.Nm i2d_PKCS12_SAFEBAG ,
31.Nm d2i_PKCS12_BAGS ,
32.Nm i2d_PKCS12_BAGS
33.Nd decode and encode PKCS#12 structures
34.Sh SYNOPSIS
35.In openssl/pkcs12.h
36.Ft PKCS12 *
37.Fo d2i_PKCS12
38.Fa "PKCS12 **val_out"
39.Fa "const unsigned char **der_in"
40.Fa "long length"
41.Fc
42.Ft int
43.Fo i2d_PKCS12
44.Fa "PKCS12 *val_in"
45.Fa "unsigned char **der_out"
46.Fc
47.Ft PKCS12 *
48.Fo d2i_PKCS12_bio
49.Fa "BIO *in_bio"
50.Fa "PKCS12 **val_out"
51.Fc
52.Ft int
53.Fo i2d_PKCS12_bio
54.Fa "BIO *out_bio"
55.Fa "PKCS12 *val_in"
56.Fc
57.Ft PKCS12 *
58.Fo d2i_PKCS12_fp
59.Fa "FILE *in_fp"
60.Fa "PKCS12 **val_out"
61.Fc
62.Ft int
63.Fo i2d_PKCS12_fp
64.Fa "FILE *out_fp"
65.Fa "PKCS12 *val_in"
66.Fc
67.Ft PKCS12_MAC_DATA *
68.Fo d2i_PKCS12_MAC_DATA
69.Fa "PKCS12_MAC_DATA **val_out"
70.Fa "const unsigned char **der_in"
71.Fa "long length"
72.Fc
73.Ft int
74.Fo i2d_PKCS12_MAC_DATA
75.Fa "PKCS12_MAC_DATA *val_in"
76.Fa "unsigned char **der_out"
77.Fc
78.Ft PKCS12_SAFEBAG *
79.Fo d2i_PKCS12_SAFEBAG
80.Fa "PKCS12_SAFEBAG **val_out"
81.Fa "const unsigned char **der_in"
82.Fa "long length"
83.Fc
84.Ft int
85.Fo i2d_PKCS12_SAFEBAG
86.Fa "PKCS12_SAFEBAG *val_in"
87.Fa "unsigned char **der_out"
88.Fc
89.Ft PKCS12_BAGS *
90.Fo d2i_PKCS12_BAGS
91.Fa "PKCS12_BAGS **val_out"
92.Fa "const unsigned char **der_in"
93.Fa "long length"
94.Fc
95.Ft int
96.Fo i2d_PKCS12_BAGS
97.Fa "PKCS12_BAGS *val_in"
98.Fa "unsigned char **der_out"
99.Fc
100.Sh DESCRIPTION
101These functions decode and encode PKCS#12 structures.
102For details about the semantics, examples, caveats, and bugs, see
103.Xr ASN1_item_d2i 3 .
104.Pp
105.Fn d2i_PKCS12
106and
107.Fn i2d_PKCS12
108decode and encode an ASN.1
109.Vt PFX
110.Pq personal information exchange
111structure defined in RFC 7292 section 4.
112.Fn d2i_PKCS12_bio ,
113.Fn i2d_PKCS12_bio ,
114.Fn d2i_PKCS12_fp ,
115and
116.Fn i2d_PKCS12_fp
117are similar except that they decode or encode using a
118.Vt BIO
119or
120.Vt FILE
121pointer.
122.Pp
123.Fn d2i_PKCS12_MAC_DATA
124and
125.Fn i2d_PKCS12_MAC_DATA
126decode and encode an ASN.1
127.Vt MacData
128structure defined in RFC 7292 section 4.
129.Pp
130.Fn d2i_PKCS12_SAFEBAG
131and
132.Fn i2d_PKCS12_SAFEBAG
133decode and encode an ASN.1
134.Vt SafeBag
135structure defined in RFC 7292 section 4.2.
136.Pp
137.Fn d2i_PKCS12_BAGS
138and
139.Fn i2d_PKCS12_BAGS
140decode and encode the bagValue field of an ASN.1
141.Vt SafeBag
142structure.
143.Sh RETURN VALUES
144.Fn d2i_PKCS12 ,
145.Fn d2i_PKCS12_bio ,
146and
147.Fn d2i_PKCS12_fp
148return a
149.Vt PKCS12
150object or
151.Dv NULL
152if an error occurs.
153.Pp
154.Fn d2i_PKCS12_MAC_DATA ,
155.Fn d2i_PKCS12_SAFEBAG ,
156and
157.Fn d2i_PKCS12_BAGS
158return a
159.Vt PKCS12_MAC_DATA ,
160.Vt PKCS12_SAFEBAG ,
161or
162.Vt PKCS12_BAGS
163object, respectively, or
164.Dv NULL
165if an error occurs.
166.Pp
167.Fn i2d_PKCS12 ,
168.Fn i2d_PKCS12_MAC_DATA ,
169.Fn i2d_PKCS12_SAFEBAG ,
170and
171.Fn i2d_PKCS12_BAGS
172return the number of bytes successfully encoded or a negative value
173if an error occurs.
174.Pp
175.Fn i2d_PKCS12_bio
176and
177.Fn i2d_PKCS12_fp
178return 1 for success or 0 if an error occurs.
179.Sh SEE ALSO
180.Xr ASN1_item_d2i 3 ,
181.Xr PKCS12_create 3 ,
182.Xr PKCS12_new 3 ,
183.Xr PKCS12_parse 3 ,
184.Xr PKCS12_SAFEBAG_new 3
185.Sh STANDARDS
186RFC 7292: PKCS #12: Personal Information Exchange Syntax
187.Sh HISTORY
188.Fn d2i_PKCS12 ,
189.Fn i2d_PKCS12 ,
190.Fn d2i_PKCS12_bio ,
191.Fn i2d_PKCS12_bio ,
192.Fn d2i_PKCS12_fp ,
193.Fn i2d_PKCS12_fp ,
194.Fn d2i_PKCS12_MAC_DATA ,
195.Fn i2d_PKCS12_MAC_DATA ,
196.Fn d2i_PKCS12_SAFEBAG ,
197.Fn i2d_PKCS12_SAFEBAG ,
198.Fn d2i_PKCS12_BAGS ,
199and
200.Fn i2d_PKCS12_BAGS
201first appeared in OpenSSL 0.9.3 and have been available since
202.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/d2i_PKCS7.3 b/src/lib/libcrypto/man/d2i_PKCS7.3
deleted file mode 100644
index e587787465..0000000000
--- a/src/lib/libcrypto/man/d2i_PKCS7.3
+++ /dev/null
@@ -1,341 +0,0 @@
1.\" $OpenBSD: d2i_PKCS7.3,v 1.7 2023/04/25 18:05:07 tb Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: April 25 2023 $
18.Dt D2I_PKCS7 3
19.Os
20.Sh NAME
21.Nm d2i_PKCS7 ,
22.Nm i2d_PKCS7 ,
23.Nm d2i_PKCS7_bio ,
24.Nm i2d_PKCS7_bio ,
25.Nm d2i_PKCS7_fp ,
26.Nm i2d_PKCS7_fp ,
27.Nm d2i_PKCS7_DIGEST ,
28.Nm i2d_PKCS7_DIGEST ,
29.Nm d2i_PKCS7_ENCRYPT ,
30.Nm i2d_PKCS7_ENCRYPT ,
31.Nm d2i_PKCS7_ENC_CONTENT ,
32.Nm i2d_PKCS7_ENC_CONTENT ,
33.Nm d2i_PKCS7_ENVELOPE ,
34.Nm i2d_PKCS7_ENVELOPE ,
35.Nm d2i_PKCS7_ISSUER_AND_SERIAL ,
36.Nm i2d_PKCS7_ISSUER_AND_SERIAL ,
37.Nm d2i_PKCS7_RECIP_INFO ,
38.Nm i2d_PKCS7_RECIP_INFO ,
39.Nm d2i_PKCS7_SIGNED ,
40.Nm i2d_PKCS7_SIGNED ,
41.Nm d2i_PKCS7_SIGNER_INFO ,
42.Nm i2d_PKCS7_SIGNER_INFO ,
43.Nm d2i_PKCS7_SIGN_ENVELOPE ,
44.Nm i2d_PKCS7_SIGN_ENVELOPE
45.Nd decode and encode PKCS#7 data structures
46.Sh SYNOPSIS
47.In openssl/pkcs7.h
48.Ft PKCS7 *
49.Fo d2i_PKCS7
50.Fa "PKCS7 **val_out"
51.Fa "const unsigned char **der_in"
52.Fa "long length"
53.Fc
54.Ft int
55.Fo i2d_PKCS7
56.Fa "PKCS7 *val_in"
57.Fa "unsigned char **der_out"
58.Fc
59.Ft PKCS7 *
60.Fo d2i_PKCS7_bio
61.Fa "BIO *in_bio"
62.Fa "PKCS7 **val_out"
63.Fc
64.Ft int
65.Fo i2d_PKCS7_bio
66.Fa "BIO *out_bio"
67.Fa "PKCS7 *val_in"
68.Fc
69.Ft PKCS7 *
70.Fo d2i_PKCS7_fp
71.Fa "FILE *in_fp"
72.Fa "PKCS7 **val_out"
73.Fc
74.Ft int
75.Fo i2d_PKCS7_fp
76.Fa "FILE *out_fp"
77.Fa "PKCS7 *val_in"
78.Fc
79.Ft PKCS7_DIGEST *
80.Fo d2i_PKCS7_DIGEST
81.Fa "PKCS7_DIGEST **val_out"
82.Fa "const unsigned char **der_in"
83.Fa "long length"
84.Fc
85.Ft int
86.Fo i2d_PKCS7_DIGEST
87.Fa "PKCS7_DIGEST *val_in"
88.Fa "unsigned char **der_out"
89.Fc
90.Ft PKCS7_ENCRYPT *
91.Fo d2i_PKCS7_ENCRYPT
92.Fa "PKCS7_ENCRYPT **val_out"
93.Fa "const unsigned char **der_in"
94.Fa "long length"
95.Fc
96.Ft int
97.Fo i2d_PKCS7_ENCRYPT
98.Fa "PKCS7_ENCRYPT *val_in"
99.Fa "unsigned char **der_out"
100.Fc
101.Ft PKCS7_ENC_CONTENT *
102.Fo d2i_PKCS7_ENC_CONTENT
103.Fa "PKCS7_ENC_CONTENT **val_out"
104.Fa "const unsigned char **der_in"
105.Fa "long length"
106.Fc
107.Ft int
108.Fo i2d_PKCS7_ENC_CONTENT
109.Fa "PKCS7_ENC_CONTENT *val_in"
110.Fa "unsigned char **der_out"
111.Fc
112.Ft PKCS7_ENVELOPE *
113.Fo d2i_PKCS7_ENVELOPE
114.Fa "PKCS7_ENVELOPE **val_out"
115.Fa "const unsigned char **der_in"
116.Fa "long length"
117.Fc
118.Ft int
119.Fo i2d_PKCS7_ENVELOPE
120.Fa "PKCS7_ENVELOPE *val_in"
121.Fa "unsigned char **der_out"
122.Fc
123.Ft PKCS7_ISSUER_AND_SERIAL *
124.Fo d2i_PKCS7_ISSUER_AND_SERIAL
125.Fa "PKCS7_ISSUER_AND_SERIAL **val_out"
126.Fa "const unsigned char **der_in"
127.Fa "long length"
128.Fc
129.Ft int
130.Fo i2d_PKCS7_ISSUER_AND_SERIAL
131.Fa "PKCS7_ISSUER_AND_SERIAL *val_in"
132.Fa "unsigned char **der_out"
133.Fc
134.Ft PKCS7_RECIP_INFO *
135.Fo d2i_PKCS7_RECIP_INFO
136.Fa "PKCS7_RECIP_INFO **val_out"
137.Fa "const unsigned char **der_in"
138.Fa "long length"
139.Fc
140.Ft int
141.Fo i2d_PKCS7_RECIP_INFO
142.Fa "PKCS7_RECIP_INFO *val_in"
143.Fa "unsigned char **der_out"
144.Fc
145.Ft PKCS7_SIGNED *
146.Fo d2i_PKCS7_SIGNED
147.Fa "PKCS7_SIGNED **val_out"
148.Fa "const unsigned char **der_in"
149.Fa "long length"
150.Fc
151.Ft int
152.Fo i2d_PKCS7_SIGNED
153.Fa "PKCS7_SIGNED *val_in"
154.Fa "unsigned char **der_out"
155.Fc
156.Ft PKCS7_SIGNER_INFO *
157.Fo d2i_PKCS7_SIGNER_INFO
158.Fa "PKCS7_SIGNER_INFO **val_out"
159.Fa "const unsigned char **der_in"
160.Fa "long length"
161.Fc
162.Ft int
163.Fo i2d_PKCS7_SIGNER_INFO
164.Fa "PKCS7_SIGNER_INFO *val_in"
165.Fa "unsigned char **der_out"
166.Fc
167.Ft PKCS7_SIGN_ENVELOPE *
168.Fo d2i_PKCS7_SIGN_ENVELOPE
169.Fa "PKCS7_SIGN_ENVELOPE **val_out"
170.Fa "const unsigned char **der_in"
171.Fa "long length"
172.Fc
173.Ft int
174.Fo i2d_PKCS7_SIGN_ENVELOPE
175.Fa "PKCS7_SIGN_ENVELOPE *val_in"
176.Fa "unsigned char **der_out"
177.Fc
178.Sh DESCRIPTION
179These functions decode and encode PKCS#7 data structures.
180For details about the semantics, examples, caveats, and bugs, see
181.Xr ASN1_item_d2i 3 .
182.Pp
183.Fn d2i_PKCS7
184and
185.Fn i2d_PKCS7
186decode and encode an ASN.1
187.Vt ContentInfo
188structure defined in RFC 2315 section 7.
189.Fn d2i_PKCS7_bio ,
190.Fn i2d_PKCS7_bio ,
191.Fn d2i_PKCS7_fp ,
192and
193.Fn i2d_PKCS7_fp
194are similar except that they decode or encode using a
195.Vt BIO
196or
197.Vt FILE
198pointer.
199.Pp
200.Fn d2i_PKCS7_DIGEST
201and
202.Fn i2d_PKCS7_DIGEST
203decode and encode an ASN.1
204.Vt DigestedData
205structure defined in RFC 2315 section 12.
206.Pp
207.Fn d2i_PKCS7_ENCRYPT
208and
209.Fn i2d_PKCS7_ENCRYPT
210decode and encode an ASN.1
211.Vt EncryptedData
212structure defined in RFC 2315 section 13.
213.Pp
214.Fn d2i_PKCS7_ENC_CONTENT
215and
216.Fn i2d_PKCS7_ENC_CONTENT
217decode and encode an ASN.1
218.Vt EncryptedContentInfo
219structure defined in RFC 2315 section 10.1.
220.Pp
221.Fn d2i_PKCS7_ENVELOPE
222and
223.Fn i2d_PKCS7_ENVELOPE
224decode and encode an ASN.1
225.Vt EnvelopedData
226structure defined in RFC 2315 section 10.
227.Pp
228.Fn d2i_PKCS7_ISSUER_AND_SERIAL
229and
230.Fn i2d_PKCS7_ISSUER_AND_SERIAL
231decode and encode an ASN.1
232.Vt IssuerAndSerialNumber
233structure defined in RFC 2315 section 6.7.
234.Pp
235.Fn d2i_PKCS7_RECIP_INFO
236and
237.Fn i2d_PKCS7_RECIP_INFO
238decode and encode an ASN.1
239.Vt RecipientInfo
240structure defined in RFC 2315 section 10.2.
241.Pp
242.Fn d2i_PKCS7_SIGNED
243and
244.Fn i2d_PKCS7_SIGNED
245decode and encode an ASN.1
246.Vt SignedData
247structure defined in RFC 2315 section 9.
248.Pp
249.Fn d2i_PKCS7_SIGNER_INFO
250and
251.Fn i2d_PKCS7_SIGNER_INFO
252decode and encode an ASN.1
253.Vt SignerInfo
254structure defined in RFC 2315 section 9.2.
255.Pp
256.Fn d2i_PKCS7_SIGN_ENVELOPE
257and
258.Fn i2d_PKCS7_SIGN_ENVELOPE
259decode and encode an ASN.1
260.Vt SignedAndEnvelopedData
261structure defined in RFC 2315 section 11.
262.Sh RETURN VALUES
263.Fn d2i_PKCS7 ,
264.Fn d2i_PKCS7_bio ,
265and
266.Fn d2i_PKCS7_fp
267return a
268.Vt PKCS7
269object or
270.Dv NULL
271if an error occurs.
272.Pp
273.Fn d2i_PKCS7_DIGEST ,
274.Fn d2i_PKCS7_ENCRYPT ,
275.Fn d2i_PKCS7_ENC_CONTENT ,
276.Fn d2i_PKCS7_ENVELOPE ,
277.Fn d2i_PKCS7_ISSUER_AND_SERIAL ,
278.Fn d2i_PKCS7_RECIP_INFO ,
279.Fn d2i_PKCS7_SIGNED ,
280.Fn d2i_PKCS7_SIGNER_INFO ,
281and
282.Fn d2i_PKCS7_SIGN_ENVELOPE
283return an object of the respective type or
284.Dv NULL
285if an error occurs.
286.Pp
287.Fn i2d_PKCS7 ,
288.Fn i2d_PKCS7_DIGEST ,
289.Fn i2d_PKCS7_ENCRYPT ,
290.Fn i2d_PKCS7_ENC_CONTENT ,
291.Fn i2d_PKCS7_ENVELOPE ,
292.Fn i2d_PKCS7_ISSUER_AND_SERIAL ,
293.Fn i2d_PKCS7_RECIP_INFO ,
294.Fn i2d_PKCS7_SIGNED ,
295.Fn i2d_PKCS7_SIGNER_INFO ,
296and
297.Fn i2d_PKCS7_SIGN_ENVELOPE
298return the number of bytes successfully encoded or a negative value
299if an error occurs.
300.Pp
301.Fn i2d_PKCS7_bio
302and
303.Fn i2d_PKCS7_fp
304return 1 for success or 0 if an error occurs.
305.Sh SEE ALSO
306.Xr ASN1_item_d2i 3 ,
307.Xr i2d_PKCS7_bio_stream 3 ,
308.Xr PEM_write_bio_PKCS7_stream 3 ,
309.Xr PEM_write_PKCS7 3 ,
310.Xr PKCS7_new 3 ,
311.Xr SMIME_write_PKCS7 3
312.Sh STANDARDS
313RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5
314.Sh HISTORY
315.Fn d2i_PKCS7 ,
316.Fn i2d_PKCS7 ,
317.Fn d2i_PKCS7_bio ,
318.Fn i2d_PKCS7_bio ,
319.Fn d2i_PKCS7_fp ,
320.Fn i2d_PKCS7_fp ,
321.Fn d2i_PKCS7_DIGEST ,
322.Fn i2d_PKCS7_DIGEST ,
323.Fn d2i_PKCS7_ENCRYPT ,
324.Fn i2d_PKCS7_ENCRYPT ,
325.Fn d2i_PKCS7_ENC_CONTENT ,
326.Fn i2d_PKCS7_ENC_CONTENT ,
327.Fn d2i_PKCS7_ENVELOPE ,
328.Fn i2d_PKCS7_ENVELOPE ,
329.Fn d2i_PKCS7_ISSUER_AND_SERIAL ,
330.Fn i2d_PKCS7_ISSUER_AND_SERIAL ,
331.Fn d2i_PKCS7_RECIP_INFO ,
332.Fn i2d_PKCS7_RECIP_INFO ,
333.Fn d2i_PKCS7_SIGNED ,
334.Fn i2d_PKCS7_SIGNED ,
335.Fn d2i_PKCS7_SIGNER_INFO ,
336.Fn i2d_PKCS7_SIGNER_INFO ,
337.Fn d2i_PKCS7_SIGN_ENVELOPE ,
338and
339.Fn i2d_PKCS7_SIGN_ENVELOPE
340first appeared in SSLeay 0.5.1 and have been available since
341.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/d2i_PKCS8PrivateKey_bio.3 b/src/lib/libcrypto/man/d2i_PKCS8PrivateKey_bio.3
deleted file mode 100644
index 58dd989fae..0000000000
--- a/src/lib/libcrypto/man/d2i_PKCS8PrivateKey_bio.3
+++ /dev/null
@@ -1,172 +0,0 @@
1.\" $OpenBSD: d2i_PKCS8PrivateKey_bio.3,v 1.11 2019/06/07 19:28:52 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2016, 2017 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 7 2019 $
52.Dt D2I_PKCS8PRIVATEKEY_BIO 3
53.Os
54.Sh NAME
55.Nm d2i_PKCS8PrivateKey_bio ,
56.Nm d2i_PKCS8PrivateKey_fp ,
57.Nm i2d_PKCS8PrivateKey_bio ,
58.Nm i2d_PKCS8PrivateKey_fp ,
59.Nm i2d_PKCS8PrivateKey_nid_bio ,
60.Nm i2d_PKCS8PrivateKey_nid_fp
61.Nd PKCS#8 format private key functions
62.Sh SYNOPSIS
63.In openssl/evp.h
64.Ft EVP_PKEY *
65.Fo d2i_PKCS8PrivateKey_bio
66.Fa "BIO *bp"
67.Fa "EVP_PKEY **x"
68.Fa "pem_password_cb *cb"
69.Fa "void *u"
70.Fc
71.Ft EVP_PKEY *
72.Fo d2i_PKCS8PrivateKey_fp
73.Fa "FILE *fp"
74.Fa "EVP_PKEY **x"
75.Fa "pem_password_cb *cb"
76.Fa "void *u"
77.Fc
78.Ft int
79.Fo i2d_PKCS8PrivateKey_bio
80.Fa "BIO *bp"
81.Fa "EVP_PKEY *x"
82.Fa "const EVP_CIPHER *enc"
83.Fa "char *kstr"
84.Fa "int klen"
85.Fa "pem_password_cb *cb"
86.Fa "void *u"
87.Fc
88.Ft int
89.Fo i2d_PKCS8PrivateKey_fp
90.Fa "FILE *fp"
91.Fa "EVP_PKEY *x"
92.Fa "const EVP_CIPHER *enc"
93.Fa "char *kstr"
94.Fa "int klen"
95.Fa "pem_password_cb *cb"
96.Fa "void *u"
97.Fc
98.Ft int
99.Fo i2d_PKCS8PrivateKey_nid_bio
100.Fa "BIO *bp"
101.Fa "EVP_PKEY *x"
102.Fa "int nid"
103.Fa "char *kstr"
104.Fa "int klen"
105.Fa "pem_password_cb *cb"
106.Fa "void *u"
107.Fc
108.Ft int
109.Fo i2d_PKCS8PrivateKey_nid_fp
110.Fa "FILE *fp"
111.Fa "EVP_PKEY *x"
112.Fa "int nid"
113.Fa "char *kstr"
114.Fa "int klen"
115.Fa "pem_password_cb *cb"
116.Fa "void *u"
117.Fc
118.Sh DESCRIPTION
119The PKCS#8 functions encode and decode private keys in PKCS#8 format
120using both PKCS#5 v1.5 and PKCS#5 v2.0 password based encryption
121algorithms.
122.Pp
123Other than the use of DER as opposed to PEM these functions are
124identical to the corresponding functions described in
125.Xr PEM_read_PrivateKey 3 .
126.Pp
127These functions are currently the only way to store encrypted private
128keys using DER format.
129.Pp
130Currently all the functions use
131.Vt BIO
132or
133.Vt FILE
134pointers.
135There are no functions which work directly on memory,
136though this can be readily worked around
137by converting the buffers to memory BIOs;
138see
139.Xr BIO_s_mem 3
140for details.
141.Sh RETURN VALUES
142.Fn d2i_PKCS8PrivateKey_bio
143and
144.Fn d2i_PKCS8PrivateKey_fp
145return a
146.Vt EVP_PKEY
147object or
148.Dv NULL
149if an error occurs.
150.Pp
151.Fn i2d_PKCS8PrivateKey_bio ,
152.Fn i2d_PKCS8PrivateKey_fp ,
153.Fn i2d_PKCS8PrivateKey_nid_bio ,
154and
155.Fn i2d_PKCS8PrivateKey_nid_fp
156return 1 on success or 0 on error.
157.Sh SEE ALSO
158.Xr d2i_X509_SIG 3 ,
159.Xr PEM_write_PKCS8PrivateKey 3 ,
160.Xr PKCS8_PRIV_KEY_INFO_new 3
161.Sh HISTORY
162These functions first appeared in OpenSSL 0.9.5
163and have been available since
164.Ox 2.7 .
165.Sh CAVEATS
166Do not confuse these functions with
167.Xr i2d_PKCS8PrivateKeyInfo_bio 3
168and
169.Xr i2d_PKCS8PrivateKeyInfo_fp 3 ,
170which write out private keys in
171.Sy unencrypted
172DER format.
diff --git a/src/lib/libcrypto/man/d2i_PKCS8_PRIV_KEY_INFO.3 b/src/lib/libcrypto/man/d2i_PKCS8_PRIV_KEY_INFO.3
deleted file mode 100644
index 1ac0f2c308..0000000000
--- a/src/lib/libcrypto/man/d2i_PKCS8_PRIV_KEY_INFO.3
+++ /dev/null
@@ -1,127 +0,0 @@
1.\" $OpenBSD: d2i_PKCS8_PRIV_KEY_INFO.3,v 1.3 2018/03/21 21:18:08 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 21 2018 $
18.Dt D2I_PKCS8_PRIV_KEY_INFO 3
19.Os
20.Sh NAME
21.Nm d2i_PKCS8_PRIV_KEY_INFO ,
22.Nm i2d_PKCS8_PRIV_KEY_INFO ,
23.Nm d2i_PKCS8_PRIV_KEY_INFO_bio ,
24.Nm i2d_PKCS8_PRIV_KEY_INFO_bio ,
25.Nm d2i_PKCS8_PRIV_KEY_INFO_fp ,
26.Nm i2d_PKCS8_PRIV_KEY_INFO_fp
27.Nd decode and encode PKCS#8 private key
28.Sh SYNOPSIS
29.In openssl/x509.h
30.Ft PKCS8_PRIV_KEY_INFO *
31.Fo d2i_PKCS8_PRIV_KEY_INFO
32.Fa "PKCS8_PRIV_KEY_INFO **val_out"
33.Fa "const unsigned char **der_in"
34.Fa "long length"
35.Fc
36.Ft int
37.Fo i2d_PKCS8_PRIV_KEY_INFO
38.Fa "PKCS8_PRIV_KEY_INFO *val_in"
39.Fa "unsigned char **der_out"
40.Fc
41.Ft PKCS8_PRIV_KEY_INFO *
42.Fo d2i_PKCS8_PRIV_KEY_INFO_bio
43.Fa "BIO *in_bio"
44.Fa "PKCS8_PRIV_KEY_INFO **val_out"
45.Fc
46.Ft int
47.Fo i2d_PKCS8_PRIV_KEY_INFO_bio
48.Fa "BIO *out_bio"
49.Fa "PKCS8_PRIV_KEY_INFO *val_in"
50.Fc
51.Ft PKCS8_PRIV_KEY_INFO *
52.Fo d2i_PKCS8_PRIV_KEY_INFO_fp
53.Fa "FILE *in_fp"
54.Fa "PKCS8_PRIV_KEY_INFO **val_out"
55.Fc
56.Ft int
57.Fo i2d_PKCS8_PRIV_KEY_INFO_fp
58.Fa "BIO *out_fp"
59.Fa "PKCS8_PRIV_KEY_INFO *val_in"
60.Fc
61.Sh DESCRIPTION
62.Fn d2i_PKCS8_PRIV_KEY_INFO
63and
64.Fn i2d_PKCS8_PRIV_KEY_INFO
65decode and encode an ASN.1
66.Vt PrivateKeyInfo
67structure defined in RFC 5208 section 5.
68.Pp
69.Fn d2i_PKCS8_PRIV_KEY_INFO_bio ,
70.Fn i2d_PKCS8_PRIV_KEY_INFO_bio ,
71.Fn d2i_PKCS8_PRIV_KEY_INFO_fp ,
72and
73.Fn i2d_PKCS8_PRIV_KEY_INFO_fp
74are similar except that they decode or encode using a
75.Vt BIO
76or
77.Vt FILE
78pointer.
79.Pp
80For details about the semantics, examples, caveats, and bugs, see
81.Xr ASN1_item_d2i 3 .
82.Pp
83These functions all use unencrypted DER format.
84To store private keys in encrypted form, consider
85.Xr d2i_PKCS8PrivateKey_bio 3
86or
87.Xr PEM_write_PKCS8PrivateKey 3 .
88.Sh RETURN VALUES
89.Fn d2i_PKCS8_PRIV_KEY_INFO ,
90.Fn d2i_PKCS8_PRIV_KEY_INFO_bio ,
91and
92.Fn d2i_PKCS8_PRIV_KEY_INFO_fp
93return a
94.Vt PKCS8_PRIV_KEY_INFO
95object or
96.Dv NULL
97if an error occurs.
98.Pp
99.Fn i2d_PKCS8_PRIV_KEY_INFO
100returns the number of bytes successfully encoded or a negative value
101if an error occurs.
102.Pp
103.Fn i2d_PKCS8_PRIV_KEY_INFO_bio
104and
105.Fn i2d_PKCS8_PRIV_KEY_INFO_fp
106return 1 for success or 0 if an error occurs.
107.Sh SEE ALSO
108.Xr ASN1_item_d2i 3 ,
109.Xr d2i_PKCS8PrivateKey_bio 3 ,
110.Xr d2i_PrivateKey 3 ,
111.Xr PEM_write_PKCS8_PRIV_KEY_INFO 3 ,
112.Xr PKCS8_PRIV_KEY_INFO_new 3
113.Sh STANDARDS
114RFC 5208: PKCS#8: Private-Key Information Syntax Specification
115.Sh HISTORY
116.Fn d2i_PKCS8_PRIV_KEY_INFO
117and
118.Fn i2d_PKCS8_PRIV_KEY_INFO
119first appeared in OpenSSL 0.9.3.
120.Fn d2i_PKCS8_PRIV_KEY_INFO_bio ,
121.Fn i2d_PKCS8_PRIV_KEY_INFO_bio ,
122.Fn d2i_PKCS8_PRIV_KEY_INFO_fp ,
123and
124.Fn i2d_PKCS8_PRIV_KEY_INFO_fp
125first appeared in OpenSSL 0.9.4.
126All these functions have been available since
127.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/d2i_PKEY_USAGE_PERIOD.3 b/src/lib/libcrypto/man/d2i_PKEY_USAGE_PERIOD.3
deleted file mode 100644
index df8639264c..0000000000
--- a/src/lib/libcrypto/man/d2i_PKEY_USAGE_PERIOD.3
+++ /dev/null
@@ -1,74 +0,0 @@
1.\" $OpenBSD: d2i_PKEY_USAGE_PERIOD.3,v 1.2 2018/03/21 16:09:51 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 21 2018 $
18.Dt D2I_PKEY_USAGE_PERIOD 3
19.Os
20.Sh NAME
21.Nm d2i_PKEY_USAGE_PERIOD ,
22.Nm i2d_PKEY_USAGE_PERIOD
23.Nd decode and encode X.509 key usage period extensions
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft PKEY_USAGE_PERIOD *
27.Fo d2i_PKEY_USAGE_PERIOD
28.Fa "PKEY_USAGE_PERIOD **val_out"
29.Fa "const unsigned char **der_in"
30.Fa "long length"
31.Fc
32.Ft int
33.Fo i2d_PKEY_USAGE_PERIOD
34.Fa "PKEY_USAGE_PERIOD *val_in"
35.Fa "unsigned char **der_out"
36.Fc
37.Sh DESCRIPTION
38.Fn d2i_PKEY_USAGE_PERIOD
39and
40.Fn i2d_PKEY_USAGE_PERIOD
41decode and encode an ASN.1
42.Vt PrivateKeyUsagePeriod
43structure defined in RFC 3280 section 4.2.1.4.
44For details about the semantics, examples, caveats, and bugs, see
45.Xr ASN1_item_d2i 3 .
46.Sh RETURN VALUES
47.Fn d2i_PKEY_USAGE_PERIOD
48returns a
49.Vt PKEY_USAGE_PERIOD
50object or
51.Dv NULL
52if an error occurs.
53.Pp
54.Fn i2d_PKEY_USAGE_PERIOD
55returns the number of bytes successfully encoded or a negative value
56if an error occurs.
57.Sh SEE ALSO
58.Xr ASN1_item_d2i 3 ,
59.Xr PKEY_USAGE_PERIOD_new 3 ,
60.Xr X509_EXTENSION_new 3
61.Sh STANDARDS
62RFC 3280: Internet X.509 Public Key Infrastructure Certificate and
63Certificate Revocation List (CRL) Profile,
64section 4.2.1.4: Private Key Usage Period
65.Pp
66RFC 3280 was obsoleted by RFC 5280; see
67.Xr PKEY_USAGE_PERIOD_new 3
68for details.
69.Sh HISTORY
70.Fn d2i_PKEY_USAGE_PERIOD
71and
72.Fn i2d_PKEY_USAGE_PERIOD
73first appeared in OpenSSL 0.9.2b and have been available since
74.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/d2i_POLICYINFO.3 b/src/lib/libcrypto/man/d2i_POLICYINFO.3
deleted file mode 100644
index bae78b17c7..0000000000
--- a/src/lib/libcrypto/man/d2i_POLICYINFO.3
+++ /dev/null
@@ -1,165 +0,0 @@
1.\" $OpenBSD: d2i_POLICYINFO.3,v 1.2 2018/03/21 17:57:48 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 21 2018 $
18.Dt D2I_POLICYINFO 3
19.Os
20.Sh NAME
21.Nm d2i_POLICYINFO ,
22.Nm i2d_POLICYINFO ,
23.Nm d2i_CERTIFICATEPOLICIES ,
24.Nm i2d_CERTIFICATEPOLICIES ,
25.Nm d2i_POLICYQUALINFO ,
26.Nm i2d_POLICYQUALINFO ,
27.Nm d2i_USERNOTICE ,
28.Nm i2d_USERNOTICE ,
29.Nm d2i_NOTICEREF ,
30.Nm i2d_NOTICEREF
31.Nd decode and encode X.509 certificate policies
32.Sh SYNOPSIS
33.In openssl/x509v3.h
34.Ft POLICYINFO *
35.Fo d2i_POLICYINFO
36.Fa "POLICYINFO **val_out"
37.Fa "const unsigned char **der_in"
38.Fa "long length"
39.Fc
40.Ft int
41.Fo i2d_POLICYINFO
42.Fa "POLICYINFO *val_in"
43.Fa "unsigned char **der_out"
44.Fc
45.Ft CERTIFICATEPOLICIES *
46.Fo d2i_CERTIFICATEPOLICIES
47.Fa "CERTIFICATEPOLICIES **val_out"
48.Fa "const unsigned char **der_in"
49.Fa "long length"
50.Fc
51.Ft int
52.Fo i2d_CERTIFICATEPOLICIES
53.Fa "CERTIFICATEPOLICIES *val_in"
54.Fa "unsigned char **der_out"
55.Fc
56.Ft POLICYQUALINFO *
57.Fo d2i_POLICYQUALINFO
58.Fa "POLICYQUALINFO **val_out"
59.Fa "const unsigned char **der_in"
60.Fa "long length"
61.Fc
62.Ft int
63.Fo i2d_POLICYQUALINFO
64.Fa "POLICYQUALINFO *val_in"
65.Fa "unsigned char **der_out"
66.Fc
67.Ft USERNOTICE *
68.Fo d2i_USERNOTICE
69.Fa "USERNOTICE **val_out"
70.Fa "const unsigned char **der_in"
71.Fa "long length"
72.Fc
73.Ft int
74.Fo i2d_USERNOTICE
75.Fa "USERNOTICE *val_in"
76.Fa "unsigned char **der_out"
77.Fc
78.Ft NOTICEREF *
79.Fo d2i_NOTICEREF
80.Fa "NOTICEREF **val_out"
81.Fa "const unsigned char **der_in"
82.Fa "long length"
83.Fc
84.Ft int
85.Fo i2d_NOTICEREF
86.Fa "NOTICEREF *val_in"
87.Fa "unsigned char **der_out"
88.Fc
89.Sh DESCRIPTION
90These functions decode and encode X.509 certificate policies.
91For details about the semantics, examples, caveats, and bugs, see
92.Xr ASN1_item_d2i 3 .
93.Pp
94.Fn d2i_POLICYINFO
95and
96.Fn i2d_POLICYINFO
97decode and encode an ASN.1
98.Vt PolicyInformation
99structure defined in RFC 5280 section 4.2.1.4.
100.Pp
101.Fn d2i_CERTIFICATEPOLICIES
102and
103.Fn i2d_CERTIFICATEPOLICIES
104decode and encode an ASN.1
105.Vt CertificatePolicies
106structure defined in RFC 5280 section 4.2.1.4.
107.Pp
108.Fn d2i_POLICYQUALINFO
109and
110.Fn i2d_POLICYQUALINFO
111decode and encode an ASN.1
112.Vt PolicyQualifierInfo
113structure defined in RFC 5280 section 4.2.1.4.
114.Pp
115.Fn d2i_USERNOTICE
116and
117.Fn i2d_USERNOTICE
118decode and encode an ASN.1
119.Vt UserNotice
120structure defined in RFC 5280 section 4.2.1.4.
121.Pp
122.Fn d2i_NOTICEREF
123and
124.Fn i2d_NOTICEREF
125decode and encode an ASN.1
126.Vt NoticeReference
127structure defined in RFC 5280 section 4.2.1.4.
128.Sh RETURN VALUES
129.Fn d2i_POLICYINFO ,
130.Fn d2i_CERTIFICATEPOLICIES ,
131.Fn d2i_POLICYQUALINFO ,
132.Fn d2i_USERNOTICE ,
133and
134.Fn d2i_NOTICEREF
135return a
136.Vt POLICYINFO ,
137.Vt CERTIFICATEPOLICIES ,
138.Vt POLICYQUALINFO ,
139.Vt USERNOTICE ,
140or
141.Vt NOTICEREF
142object, respectively, or
143.Dv NULL
144if an error occurs.
145.Pp
146.Fn i2d_POLICYINFO ,
147.Fn i2d_CERTIFICATEPOLICIES ,
148.Fn i2d_POLICYQUALINFO ,
149.Fn i2d_USERNOTICE ,
150and
151.Fn i2d_NOTICEREF
152return the number of bytes successfully encoded or a negative value
153if an error occurs.
154.Sh SEE ALSO
155.Xr ASN1_item_d2i 3 ,
156.Xr POLICYINFO_new 3 ,
157.Xr X509_EXTENSION_new 3
158.Sh STANDARDS
159RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
160Certificate Revocation List (CRL) Profile,
161section 4.2.1.4: Certificate Policies
162.Sh HISTORY
163These functions first appeared in OpenSSL 0.9.3
164and have been available since
165.Ox 2.6 .
diff --git a/src/lib/libcrypto/man/d2i_PrivateKey.3 b/src/lib/libcrypto/man/d2i_PrivateKey.3
deleted file mode 100644
index b544ea0e9a..0000000000
--- a/src/lib/libcrypto/man/d2i_PrivateKey.3
+++ /dev/null
@@ -1,312 +0,0 @@
1.\" $OpenBSD: d2i_PrivateKey.3,v 1.11 2024/10/24 21:42:10 tb Exp $
2.\" full merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\" notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\" notice, this list of conditions and the following disclaimer in
33.\" the documentation and/or other materials provided with the
34.\" distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\" software must display the following acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\" endorse or promote products derived from this software without
43.\" prior written permission. For written permission, please contact
44.\" openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\" nor may "OpenSSL" appear in their names without prior written
48.\" permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\" acknowledgment:
52.\" "This product includes software developed by the OpenSSL Project
53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: October 24 2024 $
69.Dt D2I_PRIVATEKEY 3
70.Os
71.Sh NAME
72.Nm d2i_PrivateKey ,
73.Nm d2i_AutoPrivateKey ,
74.Nm d2i_PrivateKey_bio ,
75.Nm d2i_PrivateKey_fp ,
76.Nm i2d_PrivateKey ,
77.Nm i2d_PrivateKey_bio ,
78.Nm i2d_PrivateKey_fp ,
79.Nm i2d_PKCS8PrivateKeyInfo_bio ,
80.Nm i2d_PKCS8PrivateKeyInfo_fp ,
81.Nm d2i_PublicKey ,
82.Nm i2d_PublicKey
83.Nd decode and encode EVP_PKEY objects
84.Sh SYNOPSIS
85.In openssl/evp.h
86.Ft EVP_PKEY *
87.Fo d2i_PrivateKey
88.Fa "int type"
89.Fa "EVP_PKEY **val_out"
90.Fa "const unsigned char **der_in"
91.Fa "long length"
92.Fc
93.Ft EVP_PKEY *
94.Fo d2i_AutoPrivateKey
95.Fa "EVP_PKEY **val_out"
96.Fa "const unsigned char **der_in"
97.Fa "long length"
98.Fc
99.Ft EVP_PKEY *
100.Fo d2i_PrivateKey_bio
101.Fa "BIO *in_bio"
102.Fa "EVP_PKEY **val_out"
103.Fc
104.Ft EVP_PKEY *
105.Fo d2i_PrivateKey_fp
106.Fa "FILE *in_fp"
107.Fa "EVP_PKEY **val_out"
108.Fc
109.Ft int
110.Fo i2d_PrivateKey
111.Fa "EVP_PKEY *val_in"
112.Fa "unsigned char **der_out"
113.Fc
114.Ft int
115.Fo i2d_PrivateKey_bio
116.Fa "BIO *out_bio"
117.Fa "EVP_PKEY *val_in"
118.Fc
119.Ft int
120.Fo i2d_PrivateKey_fp
121.Fa "FILE *out_fp"
122.Fa "EVP_PKEY *val_in"
123.Fc
124.Ft int
125.Fo i2d_PKCS8PrivateKeyInfo_bio
126.Fa "BIO *out_bio"
127.Fa "EVP_PKEY *val_in"
128.Fc
129.Ft int
130.Fo i2d_PKCS8PrivateKeyInfo_fp
131.Fa "FILE *out_fp"
132.Fa "EVP_PKEY *val_in"
133.Fc
134.Ft EVP_PKEY *
135.Fo d2i_PublicKey
136.Fa "int type"
137.Fa "EVP_PKEY **val_out"
138.Fa "const unsigned char **der_in"
139.Fa "long length"
140.Fc
141.Ft int
142.Fo i2d_PublicKey
143.Fa "EVP_PKEY *val_in"
144.Fa "unsigned char **der_out"
145.Fc
146.Sh DESCRIPTION
147These are algorithm-independent interfaces to decode and encode
148private and public keys.
149For details about the semantics, examples, caveats, and bugs, see
150.Xr ASN1_item_d2i 3 .
151.Pp
152.Fn d2i_PrivateKey
153decodes a private key using algorithm
154.Fa type .
155It attempts to use any algorithm specific format or the PKCS#8 unencrypted
156.Vt PrivateKeyInfo
157format defined in RFC 5208 section 5.
158The
159.Fa type
160parameter should be a public key algorithm constant such as
161.Dv EVP_PKEY_RSA .
162An error occurs if the decoded key does not match
163.Fa type .
164.Pp
165.Fn d2i_AutoPrivateKey
166is similar to
167.Fn d2i_PrivateKey
168except that it attempts to automatically detect the algorithm.
169.Pp
170.Fn d2i_PrivateKey_bio
171and
172.Fn d2i_PrivateKey_fp
173are similar to
174.Fn d2i_PrivateKey
175except that they read from a
176.Vt BIO
177or
178.Vt FILE
179pointer.
180.Pp
181.Fn i2d_PrivateKey
182encodes
183.Fa val_in .
184It uses an algorithm specific format or, if none is defined for
185that key type, the PKCS#8 unencrypted
186.Vt PrivateKeyInfo
187format.
188.Pp
189.Fn i2d_PrivateKey_bio
190and
191.Fn i2d_PrivateKey_fp
192are similar to
193.Fn i2d_PrivateKey
194except that they write to a
195.Vt BIO
196or
197.Vt FILE
198pointer and use a different convention for their return values.
199.Pp
200.Fn i2d_PKCS8PrivateKeyInfo_bio
201and
202.Fn i2d_PKCS8PrivateKeyInfo_fp
203encode
204.Fa val_in
205in PKCS#8 unencrypted
206.Vt PrivateKeyInfo
207format.
208They are similar to
209.Fn i2d_PrivateKey
210except that they don't use any algorithm-specific formats
211and that they write to a
212.Vt BIO
213or
214.Vt FILE
215pointer rather than to a buffer.
216.Pp
217All these functions use DER format and unencrypted keys.
218Applications wishing to encrypt or decrypt private keys should use other
219functions such as
220.Xr d2i_PKCS8PrivateKey_bio 3
221instead.
222.Pp
223If
224.Pf * Fa val_out
225is not
226.Dv NULL
227when calling
228.Fn d2i_PrivateKey
229or
230.Fn d2i_AutoPrivateKey
231(i.e. an existing structure is being reused) and the key format is
232PKCS#8, then
233.Pf * Fa val_out
234will be freed and replaced on a successful call.
235.Pp
236.Fn d2i_PublicKey
237calls
238.Xr d2i_DSAPublicKey 3 ,
239.Xr o2i_ECPublicKey 3 ,
240or
241.Xr d2i_RSAPublicKey 3
242depending on
243.Fa type
244and stores the result in the returned
245.Vt EVP_PKEY
246object.
247.Pp
248.Fn i2d_PublicKey
249calls
250.Xr i2d_DSAPublicKey 3 ,
251.Xr i2o_ECPublicKey 3 ,
252or
253.Xr i2d_RSAPublicKey 3
254depending on the algorithm used by
255.Fa val_in .
256.Sh RETURN VALUES
257.Fn d2i_PrivateKey ,
258.Fn d2i_AutoPrivateKey ,
259.Fn d2i_PrivateKey_bio ,
260.Fn d2i_PrivateKey_fp ,
261and
262.Fn d2i_PublicKey
263return a valid
264.Vt EVP_PKEY
265structure or
266.Dv NULL
267if an error occurs.
268.Pp
269.Fn i2d_PrivateKey
270and
271.Fn i2d_PublicKey
272return the number of bytes successfully encoded or a negative value if
273an error occurs.
274.Pp
275.Fn i2d_PrivateKey_bio ,
276.Fn i2d_PrivateKey_fp ,
277.Fn i2d_PKCS8PrivateKeyInfo_bio ,
278and
279.Fn i2d_PKCS8PrivateKeyInfo_fp
280return 1 for success or 0 if an error occurs.
281.Pp
282For all functions, the error code can be obtained by calling
283.Xr ERR_get_error 3 .
284.Sh SEE ALSO
285.Xr d2i_PKCS8_PRIV_KEY_INFO 3 ,
286.Xr d2i_PKCS8PrivateKey_bio 3 ,
287.Xr EVP_PKEY_new 3 ,
288.Xr EVP_PKEY_type 3 ,
289.Xr PEM_write_PrivateKey 3 ,
290.Xr PKCS8_PRIV_KEY_INFO_new 3
291.Sh STANDARDS
292RFC 5208: Public-Key Cryptography Standards (PKCS) #8: Private-Key
293Information Syntax Specification
294.Sh HISTORY
295.Fn d2i_PrivateKey ,
296.Fn i2d_PrivateKey ,
297.Fn d2i_PublicKey ,
298and
299.Fn i2d_PublicKey
300first appeared in SSLeay 0.6.0 and have been available since
301.Ox 2.4 .
302.Pp
303.Fn d2i_AutoPrivateKey ,
304.Fn d2i_PrivateKey_bio ,
305.Fn d2i_PrivateKey_fp ,
306.Fn i2d_PrivateKey_bio ,
307.Fn i2d_PrivateKey_fp ,
308.Fn i2d_PKCS8PrivateKeyInfo_bio ,
309and
310.Fn i2d_PKCS8PrivateKeyInfo_fp
311first appeared in OpenSSL 0.9.5 and have been available since
312.Ox 2.7 .
diff --git a/src/lib/libcrypto/man/d2i_RSAPublicKey.3 b/src/lib/libcrypto/man/d2i_RSAPublicKey.3
deleted file mode 100644
index d6c376d84b..0000000000
--- a/src/lib/libcrypto/man/d2i_RSAPublicKey.3
+++ /dev/null
@@ -1,389 +0,0 @@
1.\" $OpenBSD: d2i_RSAPublicKey.3,v 1.13 2018/03/27 17:35:50 schwarze Exp $
2.\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ulf Moeller <ulf@openssl.org> and
22.\" Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000, 2002, 2003, 2009, 2016 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: March 27 2018 $
71.Dt D2I_RSAPUBLICKEY 3
72.Os
73.Sh NAME
74.Nm d2i_RSAPublicKey ,
75.Nm i2d_RSAPublicKey ,
76.Nm d2i_RSAPrivateKey ,
77.Nm i2d_RSAPrivateKey ,
78.Nm d2i_Netscape_RSA ,
79.Nm i2d_Netscape_RSA ,
80.Nm d2i_RSA_PSS_PARAMS ,
81.Nm i2d_RSA_PSS_PARAMS ,
82.Nm d2i_RSAPublicKey_bio ,
83.Nm d2i_RSAPublicKey_fp ,
84.Nm i2d_RSAPublicKey_bio ,
85.Nm i2d_RSAPublicKey_fp ,
86.Nm d2i_RSAPrivateKey_bio ,
87.Nm d2i_RSAPrivateKey_fp ,
88.Nm i2d_RSAPrivateKey_bio ,
89.Nm i2d_RSAPrivateKey_fp ,
90.Nm d2i_RSA_PUBKEY ,
91.Nm i2d_RSA_PUBKEY ,
92.Nm d2i_RSA_PUBKEY_bio ,
93.Nm d2i_RSA_PUBKEY_fp ,
94.Nm i2d_RSA_PUBKEY_bio ,
95.Nm i2d_RSA_PUBKEY_fp
96.Nd decode and encode RSA keys and parameters
97.Sh SYNOPSIS
98.In openssl/rsa.h
99.Ft RSA *
100.Fo d2i_RSAPublicKey
101.Fa "RSA **val_out"
102.Fa "const unsigned char **der_in"
103.Fa "long length"
104.Fc
105.Ft int
106.Fo i2d_RSAPublicKey
107.Fa "RSA *val_in"
108.Fa "unsigned char **der_out"
109.Fc
110.Ft RSA *
111.Fo d2i_RSAPrivateKey
112.Fa "RSA **val_out"
113.Fa "const unsigned char **der_in"
114.Fa "long length"
115.Fc
116.Ft int
117.Fo i2d_RSAPrivateKey
118.Fa "RSA *val_in"
119.Fa "unsigned char **der_out"
120.Fc
121.Ft RSA *
122.Fo d2i_Netscape_RSA
123.Fa "RSA **val_out"
124.Fa "const unsigned char **der_in"
125.Fa "long length"
126.Fa "int (*cb)()"
127.Fc
128.Ft int
129.Fo i2d_Netscape_RSA
130.Fa "RSA *val_in"
131.Fa "unsigned char **der_out"
132.Fa "int (*cb)()"
133.Fc
134.Ft RSA_PSS_PARAMS *
135.Fo d2i_RSA_PSS_PARAMS
136.Fa "RSA_PSS_PARAMS **val_out"
137.Fa "const unsigned char **der_in"
138.Fa "long length"
139.Fc
140.Ft int
141.Fo i2d_RSA_PSS_PARAMS
142.Fa "RSA_PSS_PARAMS *val_in"
143.Fa "unsigned char **der_out"
144.Fc
145.In openssl/x509.h
146.Ft RSA *
147.Fo d2i_RSAPublicKey_bio
148.Fa "BIO *in_bio"
149.Fa "RSA **val_out"
150.Fc
151.Ft RSA *
152.Fo d2i_RSAPublicKey_fp
153.Fa "FILE *in_fp"
154.Fa "RSA **val_out"
155.Fc
156.Ft int
157.Fo i2d_RSAPublicKey_bio
158.Fa "BIO *out_bio"
159.Fa "RSA *val_in"
160.Fc
161.Ft int
162.Fo i2d_RSAPublicKey_fp
163.Fa "FILE *out_fp"
164.Fa "RSA *val_in"
165.Fc
166.Ft RSA *
167.Fo d2i_RSAPrivateKey_bio
168.Fa "BIO *in_bio"
169.Fa "RSA **val_out"
170.Fc
171.Ft RSA *
172.Fo d2i_RSAPrivateKey_fp
173.Fa "FILE *in_fp"
174.Fa "RSA **val_out"
175.Fc
176.Ft int
177.Fo i2d_RSAPrivateKey_bio
178.Fa "BIO *out_bio"
179.Fa "RSA *val_in"
180.Fc
181.Ft int
182.Fo i2d_RSAPrivateKey_fp
183.Fa "FILE *out_fp"
184.Fa "RSA *val_in"
185.Fc
186.Ft RSA *
187.Fo d2i_RSA_PUBKEY
188.Fa "RSA **val_out"
189.Fa "const unsigned char **der_in"
190.Fa "long length"
191.Fc
192.Ft int
193.Fo i2d_RSA_PUBKEY
194.Fa "RSA *val_in"
195.Fa "unsigned char **der_out"
196.Fc
197.Ft RSA *
198.Fo d2i_RSA_PUBKEY_bio
199.Fa "BIO *in_bio"
200.Fa "RSA **val_out"
201.Fc
202.Ft RSA *
203.Fo d2i_RSA_PUBKEY_fp
204.Fa "FILE *in_fp"
205.Fa "RSA **val_out"
206.Fc
207.Ft int
208.Fo i2d_RSA_PUBKEY_bio
209.Fa "BIO *out_bio"
210.Fa "RSA *val_in"
211.Fc
212.Ft int
213.Fo i2d_RSA_PUBKEY_fp
214.Fa "FILE *out_fp"
215.Fa "RSA *val_in"
216.Fc
217.Sh DESCRIPTION
218These functions decode and encode RSA private and public keys.
219For details about the semantics, examples, caveats, and bugs, see
220.Xr ASN1_item_d2i 3 .
221.Pp
222.Fn d2i_RSAPublicKey
223and
224.Fn i2d_RSAPublicKey
225decode and encode a PKCS#1
226.Vt RSAPublicKey
227structure defined in RFC 8017 appendix A.1.1.
228.Fn d2i_RSAPublicKey_bio ,
229.Fn d2i_RSAPublicKey_fp ,
230.Fn i2d_RSAPublicKey_bio ,
231and
232.Fn i2d_RSAPublicKey_fp
233are similar except that they decode or encode using a
234.Vt BIO
235or
236.Vt FILE
237pointer.
238.Pp
239.Fn d2i_RSAPrivateKey
240and
241.Fn i2d_RSAPrivateKey
242decode and encode a PKCS#1
243.Vt RSAPrivateKey
244structure defined in RFC 8017 appendix A.1.2.
245The
246.Vt RSA
247structure passed to the private key encoding functions should have
248all the PKCS#1 private key components present.
249The data encoded by the private key functions is unencrypted and
250therefore offers no private key security.
251.Fn d2i_RSAPrivateKey_bio ,
252.Fn d2i_RSAPrivateKey_fp ,
253.Fn i2d_RSAPrivateKey_bio ,
254and
255.Fn i2d_RSAPrivateKey_fp
256are similar except that they decode or encode using a
257.Vt BIO
258or
259.Vt FILE
260pointer.
261.Pp
262.Fn d2i_Netscape_RSA
263and
264.Fn i2d_Netscape_RSA
265decode and encode an RSA private key in NET format.
266These functions are present to provide compatibility with
267certain very old software.
268The NET format has some severe security weaknesses and should be
269avoided if possible.
270.Pp
271.Fn d2i_RSA_PSS_PARAMS
272and
273.Fn i2d_RSA_PSS_PARAMS
274decode and encode a PKCS#1
275.Vt RSASSA-PSS-params
276structure defined in RFC 8017 appendix A.2.3 and documented in
277.Xr RSA_PSS_PARAMS_new 3 .
278.Pp
279.Fn d2i_RSA_PUBKEY
280and
281.Fn i2d_RSA_PUBKEY
282decode and encode an RSA public key using an ASN.1
283.Vt SubjectPublicKeyInfo
284structure defined in RFC 5280 section 4.1 and documented in
285.Xr X509_PUBKEY_new 3 .
286.Fn d2i_RSA_PUBKEY_bio ,
287.Fn d2i_RSA_PUBKEY_fp ,
288.Fn i2d_RSA_PUBKEY_bio ,
289and
290.Fn i2d_RSA_PUBKEY_fp
291are similar except that they decode or encode using a
292.Vt BIO
293or
294.Vt FILE
295pointer.
296.Sh RETURN VALUES
297.Fn d2i_RSAPublicKey ,
298.Fn d2i_RSAPublicKey_bio ,
299.Fn d2i_RSAPublicKey_fp ,
300.Fn d2i_RSAPrivateKey ,
301.Fn d2i_RSAPrivateKey_bio ,
302.Fn d2i_RSAPrivateKey_fp ,
303.Fn d2i_Netscape_RSA ,
304.Fn d2i_RSA_PUBKEY ,
305.Fn d2i_RSA_PUBKEY_bio ,
306and
307.Fn d2i_RSA_PUBKEY_fp
308return a valid
309.Vt RSA
310object or
311.Dv NULL
312if an error occurs.
313.Pp
314.Fn d2i_RSA_PSS_PARAMS
315returns a valid
316.Vt RSA_PSS_PARAMS
317object or
318.Dv NULL
319if an error occurs.
320.Pp
321.Fn i2d_RSAPublicKey ,
322.Fn i2d_RSAPrivateKey ,
323.Fn i2d_Netscape_RSA ,
324.Fn i2d_RSA_PSS_PARAMS ,
325and
326.Fn i2d_RSA_PUBKEY
327return the number of bytes successfully encoded or a negative value
328if an error occurs.
329.Pp
330.Fn i2d_RSAPublicKey_bio ,
331.Fn i2d_RSAPublicKey_fp ,
332.Fn i2d_RSAPrivateKey_bio ,
333.Fn i2d_RSAPrivateKey_fp ,
334.Fn i2d_RSA_PUBKEY_bio ,
335and
336.Fn i2d_RSA_PUBKEY_fp
337return 1 for success or 0 if an error occurs.
338.Sh SEE ALSO
339.Xr ASN1_item_d2i 3 ,
340.Xr EVP_PKEY_set1_RSA 3 ,
341.Xr PEM_write_RSAPrivateKey 3 ,
342.Xr RSA_new 3 ,
343.Xr RSA_PSS_PARAMS_new 3 ,
344.Xr X509_PUBKEY_new 3
345.Sh STANDARDS
346RFC 8017: PKCS #1: RSA Cryptography Specifications
347.Pp
348RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
349Certificate Revocation List (CRL) Profile,
350section 4.1: Basic Certificate Fields
351.Sh HISTORY
352.Fn d2i_RSAPublicKey ,
353.Fn i2d_RSAPublicKey ,
354.Fn d2i_RSAPrivateKey ,
355.Fn i2d_RSAPrivateKey ,
356.Fn d2i_RSAPrivateKey_fp ,
357.Fn i2d_RSAPrivateKey_fp ,
358.Fn d2i_Netscape_RSA ,
359and
360.Fn i2d_Netscape_RSA
361first appeared in SSLeay 0.5.1.
362.Fn d2i_RSAPrivateKey_bio
363and
364.Fn i2d_RSAPrivateKey_bio
365first appeared in SSLeay 0.6.0.
366.Fn d2i_RSAPublicKey_bio ,
367.Fn d2i_RSAPublicKey_fp ,
368.Fn i2d_RSAPublicKey_bio ,
369and
370.Fn i2d_RSAPublicKey_fp
371first appeared in SSLeay 0.8.1.
372These functions have been available since
373.Ox 2.4 .
374.Pp
375.Fn d2i_RSA_PUBKEY ,
376.Fn i2d_RSA_PUBKEY ,
377.Fn d2i_RSA_PUBKEY_bio ,
378.Fn d2i_RSA_PUBKEY_fp ,
379.Fn i2d_RSA_PUBKEY_bio ,
380and
381.Fn i2d_RSA_PUBKEY_fp
382first appeared in OpenSSL 0.9.5 and have been available since
383.Ox 2.7 .
384.Pp
385.Fn d2i_RSA_PSS_PARAMS
386and
387.Fn i2d_RSA_PSS_PARAMS
388first appeared in OpenSSL 1.0.1 and have been available since
389.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/d2i_TS_REQ.3 b/src/lib/libcrypto/man/d2i_TS_REQ.3
deleted file mode 100644
index 9f7c860fa1..0000000000
--- a/src/lib/libcrypto/man/d2i_TS_REQ.3
+++ /dev/null
@@ -1,333 +0,0 @@
1.\" $OpenBSD: d2i_TS_REQ.3,v 1.2 2018/03/23 04:34:23 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 23 2018 $
18.Dt D2I_TS_REQ 3
19.Os
20.Sh NAME
21.Nm d2i_TS_REQ ,
22.Nm i2d_TS_REQ ,
23.Nm d2i_TS_REQ_bio ,
24.Nm i2d_TS_REQ_bio ,
25.Nm d2i_TS_REQ_fp ,
26.Nm i2d_TS_REQ_fp ,
27.Nm d2i_TS_RESP ,
28.Nm i2d_TS_RESP ,
29.Nm d2i_TS_RESP_bio ,
30.Nm i2d_TS_RESP_bio ,
31.Nm d2i_TS_RESP_fp ,
32.Nm i2d_TS_RESP_fp ,
33.Nm d2i_TS_STATUS_INFO ,
34.Nm i2d_TS_STATUS_INFO ,
35.Nm d2i_TS_TST_INFO ,
36.Nm i2d_TS_TST_INFO ,
37.Nm d2i_TS_TST_INFO_bio ,
38.Nm i2d_TS_TST_INFO_bio ,
39.Nm d2i_TS_TST_INFO_fp ,
40.Nm i2d_TS_TST_INFO_fp ,
41.Nm d2i_TS_ACCURACY ,
42.Nm i2d_TS_ACCURACY ,
43.Nm d2i_TS_MSG_IMPRINT ,
44.Nm i2d_TS_MSG_IMPRINT ,
45.Nm d2i_TS_MSG_IMPRINT_bio ,
46.Nm i2d_TS_MSG_IMPRINT_bio ,
47.Nm d2i_TS_MSG_IMPRINT_fp ,
48.Nm i2d_TS_MSG_IMPRINT_fp
49.Nd decode and encode X.509 time-stamp protocol structures
50.Sh SYNOPSIS
51.In openssl/ts.h
52.Ft TS_REQ *
53.Fo d2i_TS_REQ
54.Fa "TS_REQ **val_out"
55.Fa "const unsigned char **der_in"
56.Fa "long length"
57.Fc
58.Ft int
59.Fo i2d_TS_REQ
60.Fa "const TS_REQ *val_in"
61.Fa "unsigned char **der_out"
62.Fc
63.Ft TS_REQ *
64.Fo d2i_TS_REQ_bio
65.Fa "BIO *in_bio"
66.Fa "TS_REQ **val_out"
67.Fc
68.Ft int
69.Fo i2d_TS_REQ_bio
70.Fa "BIO *out_bio"
71.Fa "TS_REQ *val_in"
72.Fc
73.Ft TS_REQ *
74.Fo d2i_TS_REQ_fp
75.Fa "FILE *in_fp"
76.Fa "TS_REQ **val_out"
77.Fc
78.Ft int
79.Fo i2d_TS_REQ_fp
80.Fa "FILE *out_fp"
81.Fa "TS_REQ *val_in"
82.Fc
83.Ft TS_RESP *
84.Fo d2i_TS_RESP
85.Fa "TS_RESP **val_out"
86.Fa "const unsigned char **der_in"
87.Fa "long length"
88.Fc
89.Ft int
90.Fo i2d_TS_RESP
91.Fa "const TS_RESP *val_in"
92.Fa "unsigned char **der_out"
93.Fc
94.Ft TS_RESP *
95.Fo d2i_TS_RESP_bio
96.Fa "BIO *in_bio"
97.Fa "TS_RESP **val_out"
98.Fc
99.Ft int
100.Fo i2d_TS_RESP_bio
101.Fa "BIO *out_bio"
102.Fa "TS_RESP *val_in"
103.Fc
104.Ft TS_RESP *
105.Fo d2i_TS_RESP_fp
106.Fa "FILE *in_fp"
107.Fa "TS_RESP **val_out"
108.Fc
109.Ft int
110.Fo i2d_TS_RESP_fp
111.Fa "FILE *out_fp"
112.Fa "TS_RESP *val_in"
113.Fc
114.Ft TS_STATUS_INFO *
115.Fo d2i_TS_STATUS_INFO
116.Fa "TS_STATUS_INFO **val_out"
117.Fa "const unsigned char **der_in"
118.Fa "long length"
119.Fc
120.Ft int
121.Fo i2d_TS_STATUS_INFO
122.Fa "const TS_STATUS_INFO *val_in"
123.Fa "unsigned char **der_out"
124.Fc
125.Ft TS_TST_INFO *
126.Fo d2i_TS_TST_INFO
127.Fa "TS_TST_INFO **val_out"
128.Fa "const unsigned char **der_in"
129.Fa "long length"
130.Fc
131.Ft int
132.Fo i2d_TS_TST_INFO
133.Fa "const TS_TST_INFO *val_in"
134.Fa "unsigned char **der_out"
135.Fc
136.Ft TS_TST_INFO *
137.Fo d2i_TS_TST_INFO_bio
138.Fa "BIO *in_bio"
139.Fa "TS_TST_INFO **val_out"
140.Fc
141.Ft int
142.Fo i2d_TS_TST_INFO_bio
143.Fa "BIO *out_bio"
144.Fa "TS_TST_INFO *val_in"
145.Fc
146.Ft TS_TST_INFO *
147.Fo d2i_TS_TST_INFO_fp
148.Fa "FILE *in_fp"
149.Fa "TS_TST_INFO **val_out"
150.Fc
151.Ft int
152.Fo i2d_TS_TST_INFO_fp
153.Fa "FILE *out_fp"
154.Fa "TS_TST_INFO *val_in"
155.Fc
156.Ft TS_ACCURACY *
157.Fo d2i_TS_ACCURACY
158.Fa "TS_ACCURACY **val_out"
159.Fa "const unsigned char **der_in"
160.Fa "long length"
161.Fc
162.Ft int
163.Fo i2d_TS_ACCURACY
164.Fa "const TS_ACCURACY *val_in"
165.Fa "unsigned char **der_out"
166.Fc
167.Ft TS_MSG_IMPRINT *
168.Fo d2i_TS_MSG_IMPRINT
169.Fa "TS_MSG_IMPRINT **val_out"
170.Fa "const unsigned char **der_in"
171.Fa "long length"
172.Fc
173.Ft int
174.Fo i2d_TS_MSG_IMPRINT
175.Fa "const TS_MSG_IMPRINT *val_in"
176.Fa "unsigned char **der_out"
177.Fc
178.Ft TS_MSG_IMPRINT *
179.Fo d2i_TS_MSG_IMPRINT_bio
180.Fa "BIO *in_bio"
181.Fa "TS_MSG_IMPRINT **val_out"
182.Fc
183.Ft int
184.Fo i2d_TS_MSG_IMPRINT_bio
185.Fa "BIO *out_bio"
186.Fa "TS_MSG_IMPRINT *val_in"
187.Fc
188.Ft TS_MSG_IMPRINT *
189.Fo d2i_TS_MSG_IMPRINT_fp
190.Fa "FILE *in_fp"
191.Fa "TS_MSG_IMPRINT **val_out"
192.Fc
193.Ft int
194.Fo i2d_TS_MSG_IMPRINT_fp
195.Fa "FILE *out_fp"
196.Fa "TS_MSG_IMPRINT *val_in"
197.Fc
198.Sh DESCRIPTION
199These functions decode and encode X.509 structures used for the
200time-stamp protocol.
201For details about the semantics, examples, caveats, and bugs, see
202.Xr ASN1_item_d2i 3 .
203.Pp
204.Fn d2i_TS_REQ
205and
206.Fn i2d_TS_REQ
207decode and encode an ASN.1
208.Vt TimeStampReq
209structure defined in RFC 3161 section 2.4.1.
210.Fn d2i_TS_REQ_bio ,
211.Fn i2d_TS_REQ_bio ,
212.Fn d2i_TS_REQ_fp ,
213and
214.Fn i2d_TS_REQ_fp
215are similar except that they decode or encode using a
216.Vt BIO
217or
218.Vt FILE
219pointer.
220.Pp
221.Fn d2i_TS_RESP
222and
223.Fn i2d_TS_RESP
224decode and encode an ASN.1
225.Vt TimeStampResp
226structure defined in RFC 3161 section 2.4.2.
227.Fn d2i_TS_RESP_bio ,
228.Fn i2d_TS_RESP_bio ,
229.Fn d2i_TS_RESP_fp ,
230and
231.Fn i2d_TS_RESP_fp
232are similar except that they decode or encode using a
233.Vt BIO
234or
235.Vt FILE
236pointer.
237.Pp
238.Fn d2i_TS_STATUS_INFO
239and
240.Fn i2d_TS_STATUS_INFO
241decode and encode an ASN.1
242.Vt PKIStatusInfo
243structure defined in RFC 3161 section 2.4.2.
244.Pp
245.Fn d2i_TS_TST_INFO
246and
247.Fn i2d_TS_TST_INFO
248decode and encode an ASN.1
249.Vt TSTInfo
250structure defined in RFC 3161 section 2.4.2.
251.Fn d2i_TS_TST_INFO_bio ,
252.Fn i2d_TS_TST_INFO_bio ,
253.Fn d2i_TS_TST_INFO_fp ,
254and
255.Fn i2d_TS_TST_INFO_fp
256are similar except that they decode or encode using a
257.Vt BIO
258or
259.Vt FILE
260pointer.
261.Pp
262.Fn d2i_TS_ACCURACY
263and
264.Fn i2d_TS_ACCURACY
265decode and encode an ASN.1
266.Vt Accuracy
267structure defined in RFC 3161 section 2.4.2.
268.Pp
269.Fn d2i_TS_MSG_IMPRINT
270and
271.Fn i2d_TS_MSG_IMPRINT
272decode and encode an ASN.1
273.Vt MessageImprint
274structure defined in RFC 3161 section 2.4.1.
275.Fn d2i_TS_MSG_IMPRINT_bio ,
276.Fn i2d_TS_MSG_IMPRINT_bio ,
277.Fn d2i_TS_MSG_IMPRINT_fp ,
278and
279.Fn i2d_TS_MSG_IMPRINT_fp
280are similar except that they decode or encode using a
281.Vt BIO
282or
283.Vt FILE
284pointer.
285.Sh RETURN VALUES
286.Fn d2i_TS_REQ ,
287.Fn d2i_TS_REQ_bio ,
288.Fn d2i_TS_REQ_fp ,
289.Fn d2i_TS_RESP ,
290.Fn d2i_TS_RESP_bio ,
291.Fn d2i_TS_RESP_fp ,
292.Fn d2i_TS_STATUS_INFO ,
293.Fn d2i_TS_TST_INFO ,
294.Fn d2i_TS_TST_INFO_bio ,
295.Fn d2i_TS_TST_INFO_fp ,
296.Fn d2i_TS_ACCURACY ,
297.Fn d2i_TS_MSG_IMPRINT ,
298.Fn d2i_TS_MSG_IMPRINT_bio ,
299and
300.Fn d2i_TS_MSG_IMPRINT_fp
301return an object of the respective type or
302.Dv NULL
303if an error occurs.
304.Pp
305.Fn i2d_TS_REQ ,
306.Fn i2d_TS_RESP ,
307.Fn i2d_TS_STATUS_INFO ,
308.Fn i2d_TS_TST_INFO ,
309.Fn i2d_TS_ACCURACY ,
310and
311.Fn i2d_TS_MSG_IMPRINT
312return the number of bytes successfully encoded or a negative value
313if an error occurs.
314.Pp
315.Fn i2d_TS_REQ_bio ,
316.Fn i2d_TS_REQ_fp ,
317.Fn i2d_TS_RESP_bio ,
318.Fn i2d_TS_RESP_fp ,
319.Fn i2d_TS_TST_INFO_bio ,
320.Fn i2d_TS_TST_INFO_fp ,
321.Fn i2d_TS_MSG_IMPRINT_bio ,
322and
323.Fn i2d_TS_MSG_IMPRINT_fp
324return 1 for success or 0 if an error occurs.
325.Sh SEE ALSO
326.Xr ASN1_item_d2i 3 ,
327.Xr TS_REQ_new 3
328.Sh STANDARDS
329RFC 3161: Internet X.509 Public Key Infrastructure Time-Stamp Protocol
330.Sh HISTORY
331These functions first appeared in OpenSSL 1.0.0
332and have been available since
333.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/d2i_X509.3 b/src/lib/libcrypto/man/d2i_X509.3
deleted file mode 100644
index 6102e49e0e..0000000000
--- a/src/lib/libcrypto/man/d2i_X509.3
+++ /dev/null
@@ -1,362 +0,0 @@
1.\" $OpenBSD: d2i_X509.3,v 1.11 2021/10/27 10:35:43 schwarze Exp $
2.\" OpenSSL d2i_X509.pod checked up to:
3.\" 256989ce4 Jun 19 15:00:32 2020 +0200
4.\" OpenSSL i2d_re_X509_tbs.pod checked up to:
5.\" 61f805c1 Jan 16 01:01:46 2018 +0800
6.\"
7.\" This file is a derived work.
8.\" The changes are covered by the following Copyright and license:
9.\"
10.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
11.\"
12.\" Permission to use, copy, modify, and distribute this software for any
13.\" purpose with or without fee is hereby granted, provided that the above
14.\" copyright notice and this permission notice appear in all copies.
15.\"
16.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
17.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
18.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23.\"
24.\" The original files were written by Dr. Stephen Henson <steve@openssl.org>,
25.\" Emilia Kasper <emilia@openssl.org>, Viktor Dukhovni <viktor@openssl.org>,
26.\" and Rich Salz <rsalz@openssl.org>.
27.\" Copyright (c) 2002, 2014, 2016 The OpenSSL Project.
28.\" All rights reserved.
29.\"
30.\" Redistribution and use in source and binary forms, with or without
31.\" modification, are permitted provided that the following conditions
32.\" are met:
33.\"
34.\" 1. Redistributions of source code must retain the above copyright
35.\" notice, this list of conditions and the following disclaimer.
36.\"
37.\" 2. Redistributions in binary form must reproduce the above copyright
38.\" notice, this list of conditions and the following disclaimer in
39.\" the documentation and/or other materials provided with the
40.\" distribution.
41.\"
42.\" 3. All advertising materials mentioning features or use of this
43.\" software must display the following acknowledgment:
44.\" "This product includes software developed by the OpenSSL Project
45.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
46.\"
47.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
48.\" endorse or promote products derived from this software without
49.\" prior written permission. For written permission, please contact
50.\" openssl-core@openssl.org.
51.\"
52.\" 5. Products derived from this software may not be called "OpenSSL"
53.\" nor may "OpenSSL" appear in their names without prior written
54.\" permission of the OpenSSL Project.
55.\"
56.\" 6. Redistributions of any form whatsoever must retain the following
57.\" acknowledgment:
58.\" "This product includes software developed by the OpenSSL Project
59.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
60.\"
61.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
62.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
63.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
64.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
65.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
66.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
67.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
68.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
70.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
71.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
72.\" OF THE POSSIBILITY OF SUCH DAMAGE.
73.\"
74.Dd $Mdocdate: October 27 2021 $
75.Dt D2I_X509 3
76.Os
77.Sh NAME
78.Nm d2i_X509 ,
79.Nm i2d_X509 ,
80.Nm d2i_X509_bio ,
81.Nm d2i_X509_fp ,
82.Nm i2d_X509_bio ,
83.Nm i2d_X509_fp ,
84.Nm d2i_X509_AUX ,
85.Nm i2d_X509_AUX ,
86.Nm d2i_X509_CERT_AUX ,
87.Nm i2d_X509_CERT_AUX ,
88.Nm d2i_X509_CINF ,
89.Nm i2d_X509_CINF ,
90.Nm d2i_X509_VAL ,
91.Nm i2d_X509_VAL ,
92.Nm i2d_re_X509_tbs ,
93.Nm i2d_re_X509_CRL_tbs ,
94.Nm i2d_re_X509_REQ_tbs
95.Nd decode and encode X.509 certificates
96.Sh SYNOPSIS
97.In openssl/x509.h
98.Ft X509 *
99.Fo d2i_X509
100.Fa "X509 **val_out"
101.Fa "const unsigned char **der_in"
102.Fa "long length"
103.Fc
104.Ft int
105.Fo i2d_X509
106.Fa "X509 *val_in"
107.Fa "unsigned char **der_out"
108.Fc
109.Ft X509 *
110.Fo d2i_X509_bio
111.Fa "BIO *in_bio"
112.Fa "X509 **val_out"
113.Fc
114.Ft X509 *
115.Fo d2i_X509_fp
116.Fa "FILE *in_fp"
117.Fa "X509 **val_out"
118.Fc
119.Ft int
120.Fo i2d_X509_bio
121.Fa "BIO *out_bio"
122.Fa "X509 *val_in"
123.Fc
124.Ft int
125.Fo i2d_X509_fp
126.Fa "FILE *out_fp"
127.Fa "X509 *val_in"
128.Fc
129.Ft X509 *
130.Fo d2i_X509_AUX
131.Fa "X509 **val_out"
132.Fa "const unsigned char **der_in"
133.Fa "long length"
134.Fc
135.Ft int
136.Fo i2d_X509_AUX
137.Fa "X509 *val_in"
138.Fa "unsigned char **der_out"
139.Fc
140.Ft X509_CERT_AUX *
141.Fo d2i_X509_CERT_AUX
142.Fa "X509_CERT_AUX **val_out"
143.Fa "const unsigned char **der_in"
144.Fa "long length"
145.Fc
146.Ft int
147.Fo i2d_X509_CERT_AUX
148.Fa "X509_CERT_AUX *val_in"
149.Fa "unsigned char **der_out"
150.Fc
151.Ft X509_CINF *
152.Fo d2i_X509_CINF
153.Fa "X509_CINF **val_out"
154.Fa "const unsigned char **der_in"
155.Fa "long length"
156.Fc
157.Ft int
158.Fo i2d_X509_CINF
159.Fa "X509_CINF *val_in"
160.Fa "unsigned char **der_out"
161.Fc
162.Ft X509_VAL *
163.Fo d2i_X509_VAL
164.Fa "X509_VAL **val_out"
165.Fa "const unsigned char **der_in"
166.Fa "long length"
167.Fc
168.Ft int
169.Fo i2d_X509_VAL
170.Fa "X509_VAL *val_in"
171.Fa "unsigned char **der_out"
172.Fc
173.Ft int
174.Fo i2d_re_X509_tbs
175.Fa "X509 *x"
176.Fa "unsigned char **out"
177.Fc
178.Ft int
179.Fo i2d_re_X509_CRL_tbs
180.Fa "X509_CRL *crl"
181.Fa "unsigned char **pp"
182.Fc
183.Ft int
184.Fo i2d_re_X509_REQ_tbs
185.Fa "X509_REQ *req"
186.Fa "unsigned char **pp"
187.Fc
188.Sh DESCRIPTION
189These functions decode and encode X.509 certificates
190and some of their substructures.
191For details about the semantics, examples, caveats, and bugs, see
192.Xr ASN1_item_d2i 3 .
193.Pp
194.Fn d2i_X509
195and
196.Fn i2d_X509
197decode and encode an ASN.1
198.Vt Certificate
199structure defined in RFC 5280 section 4.1.
200.Pp
201.Fn d2i_X509_bio ,
202.Fn d2i_X509_fp ,
203.Fn i2d_X509_bio ,
204and
205.Fn i2d_X509_fp
206are similar except that they decode or encode using a
207.Vt BIO
208or
209.Vt FILE
210pointer.
211.Pp
212.Fn d2i_X509_AUX
213is similar to
214.Fn d2i_X509 ,
215but the input is expected to consist of an X.509 certificate followed
216by auxiliary trust information.
217This is used by the PEM routines to read TRUSTED CERTIFICATE objects.
218This function should not be called on untrusted input.
219.Pp
220.Fn i2d_X509_AUX
221is similar to
222.Fn i2d_X509 ,
223but the encoded output contains both the certificate and any auxiliary
224trust information.
225This is used by the PEM routines to write TRUSTED CERTIFICATE objects.
226Note that this is a non-standard OpenSSL-specific data format.
227.Pp
228.Fn d2i_X509_CERT_AUX
229and
230.Fn i2d_X509_CERT_AUX
231decode and encode optional non-standard auxiliary data appended to
232a certificate, for example friendly alias names and trust data.
233.Pp
234.Fn d2i_X509_CINF
235and
236.Fn i2d_X509_CINF
237decode and encode an ASN.1
238.Vt TBSCertificate
239structure defined in RFC 5280 section 4.1.
240.Pp
241.Fn d2i_X509_VAL
242and
243.Fn i2d_X509_VAL
244decode and encode an ASN.1
245.Vt Validity
246structure defined in RFC 5280 section 4.1.
247.Pp
248.Fn i2d_re_X509_tbs
249is similar to
250.Fn i2d_X509 ,
251except it encodes only the TBSCertificate portion of the certificate.
252.Fn i2d_re_X509_CRL_tbs
253and
254.Fn i2d_re_X509_REQ_tbs
255are analogous for CRL and certificate request, respectively.
256The "re" in
257.Fn i2d_re_X509_tbs
258stands for "re-encode", and ensures that a fresh encoding is generated
259in case the object has been modified after creation.
260.Pp
261The encoding of the TBSCertificate portion of a certificate is cached in
262the
263.Vt X509
264structure internally to improve encoding performance and to ensure
265certificate signatures are verified correctly in some certificates with
266broken (non-DER) encodings.
267.Pp
268If, after modification, the
269.Vt X509
270object is re-signed with
271.Xr X509_sign 3 ,
272the encoding is automatically renewed.
273Otherwise, the encoding of the TBSCertificate portion of the
274.Vt X509
275can be manually renewed by calling
276.Fn i2d_re_X509_tbs .
277.Sh RETURN VALUES
278.Fn d2i_X509 ,
279.Fn d2i_X509_bio ,
280.Fn d2i_X509_fp ,
281and
282.Fn d2i_X509_AUX
283return a valid
284.Vt X509
285structure or
286.Dv NULL
287if an error occurs.
288.Pp
289.Fn d2i_X509_CERT_AUX ,
290.Fn d2i_X509_CINF ,
291and
292.Fn d2i_X509_VAL
293return an
294.Vt X509_CERT_AUX ,
295.Vt X509_CINF ,
296or
297.Vt X509_VAL
298object, respectively, or
299.Dv NULL
300if an error occurs.
301.Pp
302.Fn i2d_X509 ,
303.Fn i2d_X509_AUX ,
304.Fn i2d_X509_CERT_AUX ,
305.Fn i2d_X509_CINF ,
306and
307.Fn i2d_X509_VAL
308return the number of bytes successfully encoded or a negative value
309if an error occurs.
310.Pp
311.Fn i2d_X509_bio
312and
313.Fn i2d_X509_fp
314return 1 for success or 0 if an error occurs.
315.Pp
316.Fn i2d_re_X509_tbs ,
317.Fn i2d_re_X509_CRL_tbs ,
318and
319.Fn i2d_re_X509_REQ_tbs
320return the number of bytes successfully encoded or 0 if an error occurs.
321.Pp
322For all functions, the error code can be obtained by
323.Xr ERR_get_error 3 .
324.Sh SEE ALSO
325.Xr ASN1_item_d2i 3 ,
326.Xr X509_CINF_new 3 ,
327.Xr X509_new 3
328.Sh STANDARDS
329RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
330Certificate Revocation List (CRL) Profile
331.Sh HISTORY
332.Fn d2i_X509 ,
333.Fn i2d_X509 ,
334.Fn d2i_X509_fp ,
335.Fn i2d_X509_fp ,
336.Fn d2i_X509_CINF ,
337.Fn i2d_X509_CINF ,
338.Fn d2i_X509_VAL ,
339and
340.Fn i2d_X509_VAL
341first appeared in SSLeay 0.5.1.
342.Fn d2i_X509_bio
343and
344.Fn i2d_X509_bio
345first appeared in SSLeay 0.6.0.
346These functions have been available since
347.Ox 2.4 .
348.Pp
349.Fn d2i_X509_AUX ,
350.Fn i2d_X509_AUX ,
351.Fn d2i_X509_CERT_AUX ,
352and
353.Fn i2d_X509_CERT_AUX
354first appeared in OpenSSL 0.9.5 and have been available since
355.Ox 2.7 .
356.Pp
357.Fn i2d_re_X509_tbs ,
358.Fn i2d_re_X509_CRL_tbs ,
359and
360.Fn i2d_re_X509_REQ_tbs
361first appeared in OpenSSL 1.1.0 and have been available since
362.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/d2i_X509_ALGOR.3 b/src/lib/libcrypto/man/d2i_X509_ALGOR.3
deleted file mode 100644
index 252f3fc344..0000000000
--- a/src/lib/libcrypto/man/d2i_X509_ALGOR.3
+++ /dev/null
@@ -1,89 +0,0 @@
1.\" $OpenBSD: d2i_X509_ALGOR.3,v 1.11 2025/03/14 21:32:15 tb Exp $
2.\"
3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 14 2025 $
18.Dt D2I_X509_ALGOR 3
19.Os
20.Sh NAME
21.Nm d2i_X509_ALGOR ,
22.Nm i2d_X509_ALGOR ,
23.Nm d2i_X509_ALGORS ,
24.Nm i2d_X509_ALGORS
25.Nd decode and encode algorithm identifiers
26.Sh SYNOPSIS
27.In openssl/x509.h
28.Ft X509_ALGOR *
29.Fo d2i_X509_ALGOR
30.Fa "X509_ALGOR **val_out"
31.Fa "const unsigned char **der_in"
32.Fa "long length"
33.Fc
34.Ft int
35.Fo i2d_X509_ALGOR
36.Fa "X509_ALGOR *val_in"
37.Fa "unsigned char **der_out"
38.Fc
39.Ft X509_ALGORS *
40.Fo d2i_X509_ALGORS
41.Fa "X509_ALGORS **val_out"
42.Fa "const unsigned char **der_in"
43.Fa "long length"
44.Fc
45.Ft int
46.Fo i2d_X509_ALGORS
47.Fa "X509_ALGORS *val_in"
48.Fa "unsigned char **der_out"
49.Fc
50.Sh DESCRIPTION
51.Fn d2i_X509_ALGOR
52and
53.Fn i2d_X509_ALGOR
54decode and encode an ASN.1
55.Vt AlgorithmIdentifier
56structure defined in RFC 5280 section 4.1.1.2.
57.Pp
58.Fn d2i_X509_ALGORS
59and
60.Fn i2d_X509_ALGORS
61decode and encode an ASN.1 sequence of
62.Vt AlgorithmIdentifier
63structures.
64The data type
65.Vt X509_ALGORS
66is defined as
67.Vt STACK_OF(X509_ALGOR) .
68.Pp
69For details about the semantics, examples, caveats, and bugs, see
70.Xr ASN1_item_d2i 3 .
71.Sh SEE ALSO
72.Xr ASN1_item_d2i 3 ,
73.Xr STACK_OF 3 ,
74.Xr X509_ALGOR_new 3
75.Sh STANDARDS
76RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
77Certificate Revocation List (CRL) Profile
78.Sh HISTORY
79.Fn d2i_X509_ALGOR
80and
81.Fn i2d_X509_ALGOR
82first appeared in SSLeay 0.5.1 and have been available since
83.Ox 2.4 .
84.Pp
85.Fn d2i_X509_ALGORS
86and
87.Fn i2d_X509_ALGORS
88first appeared in OpenSSL 0.9.8h and have been available since
89.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3 b/src/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3
deleted file mode 100644
index 6b070e5e51..0000000000
--- a/src/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3
+++ /dev/null
@@ -1,76 +0,0 @@
1.\" $OpenBSD: d2i_X509_ATTRIBUTE.3,v 1.3 2018/03/27 17:35:50 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 27 2018 $
18.Dt D2I_X509_ATTRIBUTE 3
19.Os
20.Sh NAME
21.Nm d2i_X509_ATTRIBUTE ,
22.Nm i2d_X509_ATTRIBUTE
23.\" In the following line, "X.501" and "Attribute" are not typos.
24.\" The "Attribute" type is defined in X.501, not in X.509.
25.\" The type in called "Attribute" with capital "A", not "attribute".
26.Nd decode and encode generic X.501 Attribute
27.Sh SYNOPSIS
28.In openssl/x509.h
29.Ft X509_ATTRIBUTE *
30.Fo d2i_X509_ATTRIBUTE
31.Fa "X509_ATTRIBUTE **val_out"
32.Fa "const unsigned char **der_in"
33.Fa "long length"
34.Fc
35.Ft int
36.Fo i2d_X509_ATTRIBUTE
37.Fa "X509_ATTRIBUTE *val_in"
38.Fa "unsigned char **der_out"
39.Fc
40.Sh DESCRIPTION
41.Fn d2i_X509_ATTRIBUTE
42and
43.Fn i2d_X509_ATTRIBUTE
44decode and encode a generic ASN.1
45.Vt Attribute
46structure defined in X.501 section 8.2.
47For details about the semantics, examples, caveats, and bugs, see
48.Xr ASN1_item_d2i 3 .
49.Sh RETURN VALUES
50.Fn d2i_X509_ATTRIBUTE
51returns an
52.Vt X509_ATTRIBUTE
53object or
54.Dv NULL
55if an error occurs.
56.Pp
57.Fn i2d_X509_ATTRIBUTE
58returns the number of bytes successfully encoded or a negative value
59if an error occurs.
60.Sh SEE ALSO
61.Xr ASN1_item_d2i 3 ,
62.Xr d2i_PKCS12 3 ,
63.Xr d2i_PKCS8_PRIV_KEY_INFO 3 ,
64.Xr d2i_X509_EXTENSION 3 ,
65.Xr d2i_X509_REQ 3 ,
66.Xr X509_ATTRIBUTE_new 3
67.Sh STANDARDS
68ITU-T Recommendation X.501, also known as ISO/IEC 9594-2: Information
69Technology Open Systems Interconnection The Directory: Models,
70section 8.2: Overall structure
71.Sh HISTORY
72.Fn d2i_X509_ATTRIBUTE
73and
74.Fn i2d_X509_ATTRIBUTE
75first appeared in SSLeay 0.5.1 and have been available since
76.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/d2i_X509_CRL.3 b/src/lib/libcrypto/man/d2i_X509_CRL.3
deleted file mode 100644
index 79c1ed9f8c..0000000000
--- a/src/lib/libcrypto/man/d2i_X509_CRL.3
+++ /dev/null
@@ -1,148 +0,0 @@
1.\" $OpenBSD: d2i_X509_CRL.3,v 1.10 2025/03/15 15:17:41 tb Exp $
2.\"
3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 15 2025 $
18.Dt D2I_X509_CRL 3
19.Os
20.Sh NAME
21.Nm d2i_X509_CRL ,
22.Nm i2d_X509_CRL ,
23.Nm d2i_X509_CRL_bio ,
24.Nm d2i_X509_CRL_fp ,
25.Nm i2d_X509_CRL_bio ,
26.Nm i2d_X509_CRL_fp ,
27.Nm d2i_X509_CRL_INFO ,
28.Nm i2d_X509_CRL_INFO ,
29.Nm d2i_X509_REVOKED ,
30.Nm i2d_X509_REVOKED
31.Nd decode and encode X.509 certificate revocation lists
32.Sh SYNOPSIS
33.In openssl/x509.h
34.Ft X509_CRL *
35.Fo d2i_X509_CRL
36.Fa "X509_CRL **val_out"
37.Fa "const unsigned char **der_in"
38.Fa "long length"
39.Fc
40.Ft int
41.Fo i2d_X509_CRL
42.Fa "X509_CRL *val_in"
43.Fa "unsigned char **der_out"
44.Fc
45.Ft X509_CRL *
46.Fo d2i_X509_CRL_bio
47.Fa "BIO *in_bio"
48.Fa "X509_CRL **val_out"
49.Fc
50.Ft X509_CRL *
51.Fo d2i_X509_CRL_fp
52.Fa "FILE *in_fp"
53.Fa "X509_CRL **val_out"
54.Fc
55.Ft int
56.Fo i2d_X509_CRL_bio
57.Fa "BIO *out_bio"
58.Fa "X509_CRL *val_in"
59.Fc
60.Ft int
61.Fo i2d_X509_CRL_fp
62.Fa "FILE *out_fp"
63.Fa "X509_CRL *val_in"
64.Fc
65.Ft X509_CRL_INFO *
66.Fo d2i_X509_CRL_INFO
67.Fa "X509_CRL_INFO **val_out"
68.Fa "const unsigned char **der_in"
69.Fa "long length"
70.Fc
71.Ft int
72.Fo i2d_X509_CRL_INFO
73.Fa "X509_CRL_INFO *val_in"
74.Fa "unsigned char **der_out"
75.Fc
76.Ft X509_REVOKED *
77.Fo d2i_X509_REVOKED
78.Fa "X509_REVOKED **val_out"
79.Fa "const unsigned char **der_in"
80.Fa "long length"
81.Fc
82.Ft int
83.Fo i2d_X509_REVOKED
84.Fa "X509_REVOKED *val_in"
85.Fa "unsigned char **der_out"
86.Fc
87.Sh DESCRIPTION
88These functions decode and encode X.509 certificate revocation lists.
89For details about the semantics, examples, caveats, and bugs, see
90.Xr ASN1_item_d2i 3 .
91.Pp
92.Fn d2i_X509_CRL
93and
94.Fn i2d_X509_CRL
95decode and encode an ASN.1
96.Vt CertificateList
97structure defined in RFC 5280 section 5.1.
98.Pp
99.Fn d2i_X509_CRL_bio ,
100.Fn d2i_X509_CRL_fp ,
101.Fn i2d_X509_CRL_bio ,
102and
103.Fn i2d_X509_CRL_fp
104are similar except that they decode or encode using a
105.Vt BIO
106or
107.Vt FILE
108pointer.
109.Pp
110.Fn d2i_X509_CRL_INFO
111and
112.Fn i2d_X509_CRL_INFO
113decode and encode an ASN.1
114.Vt TBSCertList
115structure defined in RFC 5280 section 5.1.
116.Pp
117.Fn d2i_X509_REVOKED
118and
119.Fn i2d_X509_REVOKED
120decode and encode an ASN.1 structure representing one element of
121the revokedCertificates field of the ASN.1
122.Vt TBSCertList
123structure.
124.Sh SEE ALSO
125.Xr ASN1_item_d2i 3 ,
126.Xr X509_CRL_new 3 ,
127.Xr X509_REVOKED_new 3
128.Sh STANDARDS
129RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
130Certificate Revocation List (CRL) Profile,
131section 5: CRL and CRL Extensions Profile
132.Sh HISTORY
133.Fn d2i_X509_CRL ,
134.Fn i2d_X509_CRL ,
135.Fn d2i_X509_CRL_fp ,
136.Fn i2d_X509_CRL_fp ,
137.Fn d2i_X509_CRL_INFO ,
138.Fn i2d_X509_CRL_INFO ,
139.Fn d2i_X509_REVOKED ,
140and
141.Fn i2d_X509_REVOKED
142first appeared in SSLeay 0.5.1.
143.Fn d2i_X509_CRL_bio
144and
145.Fn i2d_X509_CRL_bio
146first appeared in SSLeay 0.6.0.
147These functions have been available since
148.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/d2i_X509_EXTENSION.3 b/src/lib/libcrypto/man/d2i_X509_EXTENSION.3
deleted file mode 100644
index 46a680c1ba..0000000000
--- a/src/lib/libcrypto/man/d2i_X509_EXTENSION.3
+++ /dev/null
@@ -1,104 +0,0 @@
1.\" $OpenBSD: d2i_X509_EXTENSION.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $
2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: March 27 2018 $
18.Dt D2I_X509_EXTENSION 3
19.Os
20.Sh NAME
21.Nm d2i_X509_EXTENSION ,
22.Nm i2d_X509_EXTENSION ,
23.Nm d2i_X509_EXTENSIONS ,
24.Nm i2d_X509_EXTENSIONS
25.\" In the next line, the capital "E" is not a typo.
26.\" The ASN.1 structure is called "Extensions", not "extensions".
27.Nd decode and encode X.509 Extensions
28.Sh SYNOPSIS
29.In openssl/x509.h
30.Ft X509_EXTENSION *
31.Fo d2i_X509_EXTENSION
32.Fa "X509_EXTENSION **val_out"
33.Fa "const unsigned char **der_in"
34.Fa "long length"
35.Fc
36.Ft int
37.Fo i2d_X509_EXTENSION
38.Fa "X509_EXTENSION *val_in"
39.Fa "unsigned char **der_out"
40.Fc
41.Ft X509_EXTENSIONS *
42.Fo d2i_X509_EXTENSIONS
43.Fa "X509_EXTENSIONS **val_out"
44.Fa "const unsigned char **der_in"
45.Fa "long length"
46.Fc
47.Ft int
48.Fo i2d_X509_EXTENSIONS
49.Fa "X509_EXTENSIONS *val_in"
50.Fa "unsigned char **der_out"
51.Fc
52.Sh DESCRIPTION
53.Fn d2i_X509_EXTENSION
54and
55.Fn i2d_X509_EXTENSION
56decode and encode an ASN.1
57.Vt Extension
58structure defined in RFC 5280 section 4.1.
59.Pp
60.Fn d2i_X509_EXTENSIONS
61and
62.Fn i2d_X509_EXTENSIONS
63decode and encode an ASN.1
64.Vt Extensions
65structure defined in RFC 5280 section 4.1,
66which is a SEQUENCE OF
67.Vt Extension .
68.Sh RETURN VALUES
69.Fn d2i_X509_EXTENSION
70and
71.Fn d2i_X509_EXTENSIONS
72return an
73.Vt X509_EXTENSION
74or
75.Vt X509_EXTENSIONS
76object, respectively, or
77.Dv NULL
78if an error occurs.
79.Pp
80.Fn i2d_X509_EXTENSION
81and
82.Fn i2d_X509_EXTENSIONS
83return the number of bytes successfully encoded or a negative value
84if an error occurs.
85.Sh SEE ALSO
86.Xr ASN1_item_d2i 3 ,
87.Xr X509_EXTENSION_new 3 ,
88.Xr X509V3_get_d2i 3 ,
89.Xr X509v3_get_ext_by_NID 3
90.Sh STANDARDS
91RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
92Certificate Revocation List (CRL) Profile
93.Sh HISTORY
94.Fn d2i_X509_EXTENSION
95and
96.Fn i2d_X509_EXTENSION
97first appeared in SSLeay 0.6.2 and have been available since
98.Ox 2.4 .
99.Pp
100.Fn d2i_X509_EXTENSIONS
101and
102.Fn i2d_X509_EXTENSIONS
103first appeared in OpenSSL 0.9.8h and have been available since
104.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/d2i_X509_NAME.3 b/src/lib/libcrypto/man/d2i_X509_NAME.3
deleted file mode 100644
index f5cafaee97..0000000000
--- a/src/lib/libcrypto/man/d2i_X509_NAME.3
+++ /dev/null
@@ -1,213 +0,0 @@
1.\" $OpenBSD: d2i_X509_NAME.3,v 1.18 2025/03/14 21:32:15 tb Exp $
2.\" checked up to:
3.\" OpenSSL crypto/d2i_X509_NAME 4692340e Jun 7 15:49:08 2016 -0400 and
4.\" OpenSSL man3/X509_NAME_get0_der 99d63d46 Oct 26 13:56:48 2016 -0400
5.\"
6.\" Copyright (c) 2016, 2018 Ingo Schwarze <schwarze@openbsd.org>
7.\"
8.\" Permission to use, copy, modify, and distribute this software for any
9.\" purpose with or without fee is hereby granted, provided that the above
10.\" copyright notice and this permission notice appear in all copies.
11.\"
12.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\"
20.Dd $Mdocdate: March 14 2025 $
21.Dt D2I_X509_NAME 3
22.Os
23.Sh NAME
24.Nm d2i_X509_NAME ,
25.Nm i2d_X509_NAME ,
26.Nm X509_NAME_get0_der ,
27.Nm X509_NAME_dup ,
28.Nm X509_NAME_set ,
29.Nm d2i_X509_NAME_ENTRY ,
30.Nm i2d_X509_NAME_ENTRY ,
31.Nm X509_NAME_ENTRY_dup
32.\" In the following line, "X.501" and "Name" are not typos.
33.\" The "Name" type is defined in X.501, not in X.509.
34.\" The type is called "Name" with capital "N", not "name".
35.Nd decode and encode X.501 Name objects
36.Sh SYNOPSIS
37.In openssl/x509.h
38.Ft X509_NAME *
39.Fo d2i_X509_NAME
40.Fa "X509_NAME **val_out"
41.Fa "const unsigned char **der_in"
42.Fa "long length"
43.Fc
44.Ft int
45.Fo i2d_X509_NAME
46.Fa "X509_NAME *val_in"
47.Fa "unsigned char **der_out"
48.Fc
49.Ft int
50.Fo X509_NAME_get0_der
51.Fa "X509_NAME *val_in"
52.Fa "const unsigned char **der_out"
53.Fa "size_t *out_len"
54.Fc
55.Ft X509_NAME *
56.Fo X509_NAME_dup
57.Fa "X509_NAME *val_in"
58.Fc
59.Ft int
60.Fo X509_NAME_set
61.Fa "X509_NAME **val_out"
62.Fa "X509_NAME *val_in"
63.Fc
64.Ft X509_NAME_ENTRY *
65.Fo d2i_X509_NAME_ENTRY
66.Fa "X509_NAME_ENTRY **val_out"
67.Fa "const unsigned char **der_in"
68.Fa "long length"
69.Fc
70.Ft int
71.Fo i2d_X509_NAME_ENTRY
72.Fa "X509_NAME_ENTRY *val_in"
73.Fa "unsigned char **der_out"
74.Fc
75.Ft X509_NAME_ENTRY *
76.Fo X509_NAME_ENTRY_dup
77.Fa "X509_NAME_ENTRY *val_in"
78.Fc
79.Sh DESCRIPTION
80These functions decode and encode X.501
81.Vt Name
82objects using DER format.
83For details about the semantics, examples, caveats, and bugs, see
84.Xr ASN1_item_d2i 3 .
85.Pp
86.Fn d2i_X509_NAME
87and
88.Fn i2d_X509_NAME
89decode and encode an ASN.1
90.Vt Name
91structure defined in RFC 5280 section 4.1.2.4.
92.Pp
93.Fn X509_NAME_get0_der
94is a variant of
95.Fn i2d_X509_NAME
96that does not copy the encoded output but instead returns a pointer
97to the internally cached DER-encoded version of the name.
98Also, it does not return the length of the output in bytes,
99but instead stores it in
100.Fa out_len .
101If the cached encoded form happens to be out of date, both functions
102update it before copying it or returning a pointer to it.
103.Pp
104.Fn X509_NAME_dup
105copies
106.Fa val_in
107by calling
108.Fn i2d_X509_NAME
109and
110.Fn d2i_X509_NAME .
111.Pp
112.Fn X509_NAME_set
113makes sure that
114.Pf * Fa val_out
115contains the same data as
116.Fa val_in
117after the call, except that it fails if
118.Fa val_in
119is
120.Dv NULL .
121If
122.Pf * Fa val_out
123is the same pointer as
124.Fa val_in ,
125the function succeeds without changing anything.
126Otherwise, it copies
127.Fa val_in
128using
129.Fn X509_NAME_dup ,
130and in case of success, it frees
131.Pf * Fa val_out
132and sets it to a pointer to the new object.
133When the function fails, it never changes anything.
134In any case,
135.Fa val_in
136remains valid and may or may not be the same pointer as
137.Pf * Fa val_out
138after the call.
139.Pp
140.Fn d2i_X509_NAME_ENTRY
141and
142.Fn i2d_X509_NAME_ENTRY
143decode and encode an ASN.1
144.Vt RelativeDistinguishedName
145structure defined in RFC 5280 section 4.1.2.4.
146.Pp
147.Fn X509_NAME_ENTRY_dup
148copies
149.Fa val_in
150by calling
151.Fn i2d_X509_NAME_ENTRY
152and
153.Fn d2i_X509_NAME_ENTRY .
154.Sh RETURN VALUES
155.Fn d2i_X509_NAME
156and
157.Fn X509_NAME_dup
158return the new
159.Vt X509_NAME
160object or
161.Dv NULL
162if an error occurs.
163.Pp
164.Fn X509_NAME_set
165and
166.Fn X509_NAME_get0_der
167return 1 on success or 0 if an error occurs.
168.Pp
169.Fn d2i_X509_NAME_ENTRY
170and
171.Fn X509_NAME_ENTRY_dup
172return the new
173.Vt X509_NAME_ENTRY
174object or
175.Dv NULL
176if an error occurs.
177.Pp
178.Fn i2d_X509_NAME
179and
180.Fn i2d_X509_NAME_ENTRY
181return the number of bytes successfully encoded or a negative value
182if an error occurs.
183.Sh SEE ALSO
184.Xr ASN1_item_d2i 3 ,
185.Xr X509_NAME_ENTRY_new 3 ,
186.Xr X509_NAME_new 3 ,
187.Xr X509_NAME_print_ex 3
188.Sh STANDARDS
189RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
190Certificate Revocation List (CRL) Profile
191.Pp
192ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
193Information technology - ASN.1 encoding rules:
194Specification of Basic Encoding Rules (BER), Canonical Encoding
195Rules (CER) and Distinguished Encoding Rules (DER).
196.Sh HISTORY
197.Fn X509_NAME_dup
198first appeared in SSLeay 0.4.4.
199.Fn d2i_X509_NAME ,
200.Fn i2d_X509_NAME ,
201.Fn d2i_X509_NAME_ENTRY ,
202.Fn i2d_X509_NAME_ENTRY ,
203and
204.Fn X509_NAME_ENTRY_dup
205first appeared in SSLeay 0.5.1.
206.Fn X509_NAME_set
207first appeared in SSLeay 0.8.0.
208These functions have been available since
209.Ox 2.4 .
210.Pp
211.Fn X509_NAME_get0_der
212first appeared in OpenSSL 1.1.0 and has been available since
213.Ox 6.3 .
diff --git a/src/lib/libcrypto/man/d2i_X509_REQ.3 b/src/lib/libcrypto/man/d2i_X509_REQ.3
deleted file mode 100644
index 95785a2d25..0000000000
--- a/src/lib/libcrypto/man/d2i_X509_REQ.3
+++ /dev/null
@@ -1,151 +0,0 @@
1.\" $OpenBSD: d2i_X509_REQ.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $
2.\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\"
4.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: March 27 2018 $
19.Dt D2I_X509_REQ 3
20.Os
21.Sh NAME
22.Nm d2i_X509_REQ ,
23.Nm i2d_X509_REQ ,
24.Nm d2i_X509_REQ_bio ,
25.Nm d2i_X509_REQ_fp ,
26.Nm i2d_X509_REQ_bio ,
27.Nm i2d_X509_REQ_fp ,
28.Nm d2i_X509_REQ_INFO ,
29.Nm i2d_X509_REQ_INFO
30.Nd decode and encode PKCS#10 certification requests
31.Sh SYNOPSIS
32.In openssl/x509.h
33.Ft X509_REQ *
34.Fo d2i_X509_REQ
35.Fa "X509_REQ **val_out"
36.Fa "const unsigned char **der_in"
37.Fa "long length"
38.Fc
39.Ft int
40.Fo i2d_X509_REQ
41.Fa "X509_REQ *val_in"
42.Fa "unsigned char **der_out"
43.Fc
44.Ft X509_REQ *
45.Fo d2i_X509_REQ_bio
46.Fa "BIO *in_bio"
47.Fa "X509_REQ **val_out"
48.Fc
49.Ft X509_REQ *
50.Fo d2i_X509_REQ_fp
51.Fa "FILE *in_fp"
52.Fa "X509_REQ **val_out"
53.Fc
54.Ft int
55.Fo i2d_X509_REQ_bio
56.Fa "BIO *out_bio"
57.Fa "X509_REQ *val_in"
58.Fc
59.Ft int
60.Fo i2d_X509_REQ_fp
61.Fa "FILE *out_fp"
62.Fa "X509_REQ *val_in"
63.Fc
64.Ft X509_REQ_INFO *
65.Fo d2i_X509_REQ_INFO
66.Fa "X509_REQ_INFO **val_out"
67.Fa "const unsigned char **der_in"
68.Fa "long length"
69.Fc
70.Ft int
71.Fo i2d_X509_REQ_INFO
72.Fa "X509_REQ_INFO *val_in"
73.Fa "unsigned char **der_out"
74.Fc
75.Sh DESCRIPTION
76These functions decode and encode PKCS#10 certification requests.
77For details about the semantics, examples, caveats, and bugs, see
78.Xr ASN1_item_d2i 3 .
79.Pp
80.Fn d2i_X509_REQ
81and
82.Fn i2d_X509_REQ
83decode and encode an ASN.1
84.Vt CertificationRequest
85structure defined in RFC 2986 section 4.2.
86.Fn d2i_X509_REQ_bio ,
87.Fn d2i_X509_REQ_fp ,
88.Fn i2d_X509_REQ_bio ,
89and
90.Fn i2d_X509_REQ_fp
91are similar except that they decode or encode using a
92.Vt BIO
93or
94.Vt FILE
95pointer.
96.Pp
97.Fn d2i_X509_REQ_INFO
98and
99.Fn i2d_X509_REQ_INFO
100decode and encode an ASN.1
101.Vt CertificationRequestInfo
102structure defined in RFC 2986 section 4.1.
103.Sh RETURN VALUES
104.Fn d2i_X509_REQ ,
105.Fn d2i_X509_REQ_bio ,
106and
107.Fn d2i_X509_REQ_fp
108return an
109.Vt X509_REQ
110object or
111.Dv NULL
112if an error occurs.
113.Pp
114.Fn d2i_X509_REQ_INFO
115returns an
116.Vt X509_REQ_INFO
117object or
118.Dv NULL
119if an error occurs.
120.Pp
121.Fn i2d_X509_REQ
122and
123.Fn i2d_X509_REQ_INFO
124return the number of bytes successfully encoded or a negative value
125if an error occurs.
126.Pp
127.Fn i2d_X509_REQ_bio
128and
129.Fn i2d_X509_REQ_fp
130return 1 for success or 0 if an error occurs.
131.Sh SEE ALSO
132.Xr ASN1_item_d2i 3 ,
133.Xr PEM_read_X509_REQ 3 ,
134.Xr X509_REQ_new 3
135.Sh STANDARDS
136RFC 2986: PKCS #10: Certification Request Syntax Specification
137.Sh HISTORY
138.Fn d2i_X509_REQ ,
139.Fn i2d_X509_REQ ,
140.Fn d2i_X509_REQ_fp ,
141.Fn i2d_X509_REQ_fp ,
142.Fn d2i_X509_REQ_INFO ,
143and
144.Fn i2d_X509_REQ_INFO
145first appeared in SSLeay 0.5.1.
146.Fn d2i_X509_REQ_bio
147and
148.Fn i2d_X509_REQ_bio
149first appeared in SSLeay 0.6.0.
150These functions have been available since
151.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/d2i_X509_SIG.3 b/src/lib/libcrypto/man/d2i_X509_SIG.3
deleted file mode 100644
index c9fbf86633..0000000000
--- a/src/lib/libcrypto/man/d2i_X509_SIG.3
+++ /dev/null
@@ -1,159 +0,0 @@
1.\" $OpenBSD: d2i_X509_SIG.3,v 1.10 2025/03/14 21:32:15 tb Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\"
4.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: March 14 2025 $
19.Dt D2I_X509_SIG 3
20.Os
21.Sh NAME
22.Nm d2i_X509_SIG ,
23.Nm i2d_X509_SIG ,
24.Nm d2i_PKCS8_bio ,
25.Nm i2d_PKCS8_bio ,
26.Nm d2i_PKCS8_fp ,
27.Nm i2d_PKCS8_fp
28.\" In the next line, the number "7" is not a typo.
29.\" These functions are misnamed.
30.Nd decode and encode PKCS#7 digest information
31.Sh SYNOPSIS
32.In openssl/x509.h
33.Ft X509_SIG *
34.Fo d2i_X509_SIG
35.Fa "X509_SIG **val_out"
36.Fa "const unsigned char **der_in"
37.Fa "long length"
38.Fc
39.Ft int
40.Fo i2d_X509_SIG
41.Fa "X509_SIG *val_in"
42.Fa "unsigned char **der_out"
43.Fc
44.Ft X509_SIG *
45.Fo d2i_PKCS8_bio
46.Fa "BIO *in_bio"
47.Fa "X509_SIG **val_out"
48.Fc
49.Ft int
50.Fo i2d_PKCS8_bio
51.Fa "BIO *out_bio"
52.Fa "X509_SIG *val_in"
53.Fc
54.Ft X509_SIG *
55.Fo d2i_PKCS8_fp
56.Fa "FILE *in_fp"
57.Fa "X509_SIG **val_out"
58.Fc
59.Ft int
60.Fo i2d_PKCS8_fp
61.Fa "FILE *out_fp"
62.Fa "X509_SIG *val_in"
63.Fc
64.Sh DESCRIPTION
65.Fn d2i_X509_SIG
66and
67.Fn i2d_X509_SIG
68decode and encode an ASN.1
69.Vt DigestInfo
70structure defined in RFC 2315 section 9.4
71and equivalently in RFC 8017 section 9.2.
72For details about the semantics, examples, caveats, and bugs, see
73.Xr ASN1_item_d2i 3 .
74.Pp
75.Fn d2i_PKCS8_bio
76and
77.Fn d2i_PKCS8_fp
78are similar to
79.Fn d2i_X509_SIG
80except that they read from a
81.Vt BIO
82or
83.Vt FILE
84pointer.
85.Pp
86.Fn i2d_PKCS8_bio
87and
88.Fn i2d_PKCS8_fp
89are similar to
90.Fn i2d_X509_SIG
91except that they write to a
92.Vt BIO
93or
94.Vt FILE
95pointer.
96.Sh RETURN VALUES
97.Fn d2i_X509_SIG ,
98.Fn d2i_PKCS8_bio ,
99and
100.Fn d2i_PKCS8_fp
101return a
102.Vt X509_SIG
103object or
104.Dv NULL
105if an error occurs.
106.Pp
107.Fn i2d_X509_SIG
108returns the number of bytes successfully encoded or a negative value
109if an error occurs.
110.Pp
111.Fn i2d_PKCS8_bio
112and
113.Fn i2d_PKCS8_fp
114return 1 for success or 0 if an error occurs.
115.Sh SEE ALSO
116.Xr ASN1_item_d2i 3 ,
117.Xr PKCS7_new 3 ,
118.Xr RSA_sign 3 ,
119.Xr X509_SIG_new 3
120.Sh STANDARDS
121RFC 2315: PKCS #7: Cryptographic Message Syntax,
122section 9: Signed-data content type
123.Pp
124RFC 8017: PKCS #1: RSA Cryptography Specifications,
125section 9: Encoding Methods for Signatures
126.Sh HISTORY
127.Fn d2i_X509_SIG
128and
129.Fn i2d_X509_SIG
130first appeared in SSLeay 0.5.1 and have been available since
131.Ox 2.4 .
132.Pp
133.Fn d2i_PKCS8_bio ,
134.Fn i2d_PKCS8_bio ,
135.Fn d2i_PKCS8_fp ,
136and
137.Fn i2d_PKCS8_fp
138first appeared in OpenSSL 0.9.4 and have been available since
139.Ox 2.6 .
140.Sh BUGS
141.Fn d2i_PKCS8_bio ,
142.Fn i2d_PKCS8_bio ,
143.Fn d2i_PKCS8_fp ,
144and
145.Fn i2d_PKCS8_fp
146are severely misnamed and should have been called
147.Dq d2i_X509_SIG_bio
148and so on.
149.Pp
150Or arguably, the
151.Vt X509_SIG
152object is misnamed itself, considering that it represents
153.Vt DigestInfo
154from PKCS#7 and PKCS#1.
155Then again, calling it
156.Dq PKCS8
157instead clearly isn't an improvement.
158.Pp
159Either way, these names just don't fit.
diff --git a/src/lib/libcrypto/man/des_read_pw.3 b/src/lib/libcrypto/man/des_read_pw.3
deleted file mode 100644
index 7cb35b47f8..0000000000
--- a/src/lib/libcrypto/man/des_read_pw.3
+++ /dev/null
@@ -1,197 +0,0 @@
1.\" $OpenBSD: des_read_pw.3,v 1.12 2024/08/24 07:48:37 tb Exp $
2.\" full merge up to: OpenSSL doc/crypto/des.pod
3.\" 53934822 Jun 9 16:39:19 2016 -0400
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Ulf Moeller <ulf@openssl.org>.
23.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: August 24 2024 $
70.Dt DES_READ_PW 3
71.Os
72.Sh NAME
73.Nm EVP_read_pw_string ,
74.Nm EVP_read_pw_string_min ,
75.Nm EVP_set_pw_prompt ,
76.Nm EVP_get_pw_prompt
77.Nd compatibility user interface functions
78.Sh SYNOPSIS
79.In openssl/evp.h
80.Ft int
81.Fo EVP_read_pw_string
82.Fa "char *buf"
83.Fa "int length"
84.Fa "const char *prompt"
85.Fa "int verify"
86.Fc
87.Ft int
88.Fo EVP_read_pw_string_min
89.Fa "char *buf"
90.Fa "int min_length"
91.Fa "int length"
92.Fa "const char *prompt"
93.Fa "int verify"
94.Fc
95.Ft void
96.Fo EVP_set_pw_prompt
97.Fa "const char *default_prompt"
98.Fc
99.Ft char *
100.Fn EVP_get_pw_prompt void
101.Sh DESCRIPTION
102.Fn EVP_read_pw_string
103writes the
104.Fa prompt
105to
106.Pa /dev/tty ,
107or, if that could not be opened, to standard output, turns echo off,
108and reads an input string from
109.Pa /dev/tty ,
110or, if that could not be opened, from standard input.
111The string is returned in
112.Fa buf ,
113which must have space for at least
114.Fa length
115bytes.
116If the
117.Fa length
118argument exceeds
119.Dv BUFSIZ ,
120.Dv BUFSIZ
121is used instead.
122If
123.Fa verify
124is set, the user is asked for the password twice and unless the two
125copies match, an error is returned.
126.Pp
127.Fn EVP_read_pw_string_min
128additionally checks that the password is at least
129.Fa min_length
130bytes long.
131.Pp
132.Fn EVP_set_pw_prompt
133sets a default prompt to a copy of
134.Fa default_prompt ,
135or clears the default prompt if the
136.Fa default_prompt
137argument is
138.Dv NULL
139or an empty string.
140If the
141.Fa default_prompt
142argument is longer than 79 bytes,
143the copy is silently truncated to a string length of 79 bytes.
144.Pp
145As long as a default prompt is set,
146.Fn EVP_read_pw_string
147and
148.Fn EVP_read_pw_string_min
149can be called with a
150.Fa prompt
151argument of
152.Dv NULL ,
153in which case the default prompt is used instead.
154.Sh RETURN VALUES
155.Fn EVP_read_pw_string
156and
157.Fn EVP_read_pw_string_min
158return 0 on success or a negative value on failure.
159.Pp
160They return \-1 if
161.Fa length
162is less than or equal to zero or on memory allocation failure.
163They return \-1 or \-2 if the internal call to
164.Xr UI_process 3
165fails.
166.Pp
167In addition,
168.Fa EVP_read_pw_string_min
169returns \-1 if
170.Fa min_length
171is negative, if
172.Fa length
173is less than or equal to
174.Fa min_length ,
175or if the user entered a password shorter than
176.Fa min_length .
177.Pp
178.Fn EVP_get_pw_prompt
179returns an internal pointer to static memory containing the default prompt, or
180.Dv NULL
181if no default prompt is set.
182.Sh SEE ALSO
183.Xr UI_new 3
184.Sh HISTORY
185.Fn EVP_read_pw_string
186first appeared in SSLeay 0.5.1 and
187.Fn EVP_set_pw_prompt
188and
189.Fn EVP_get_pw_prompt
190in SSLeay 0.6.0.
191These functions have been available since
192.Ox 2.4 .
193.Pp
194.Fn EVP_read_pw_string_min
195first appeared in OpenSSL 1.0.0
196and has been available since
197.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/evp.3 b/src/lib/libcrypto/man/evp.3
deleted file mode 100644
index 2c54c0f981..0000000000
--- a/src/lib/libcrypto/man/evp.3
+++ /dev/null
@@ -1,249 +0,0 @@
1.\" $OpenBSD: evp.3,v 1.36 2024/12/06 14:27:49 schwarze Exp $
2.\" full merge up to: OpenSSL man7/evp 24a535ea Sep 22 13:14:20 2020 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>,
5.\" Matt Caswell <matt@openssl.org>, Geoff Thorpe <geoff@openssl.org>,
6.\" and Dr. Stephen Henson <steve@openssl.org>.
7.\" Copyright (c) 2000, 2002, 2006, 2013, 2016 The OpenSSL Project.
8.\" All rights reserved.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\"
14.\" 1. Redistributions of source code must retain the above copyright
15.\" notice, this list of conditions and the following disclaimer.
16.\"
17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\" notice, this list of conditions and the following disclaimer in
19.\" the documentation and/or other materials provided with the
20.\" distribution.
21.\"
22.\" 3. All advertising materials mentioning features or use of this
23.\" software must display the following acknowledgment:
24.\" "This product includes software developed by the OpenSSL Project
25.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
26.\"
27.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
28.\" endorse or promote products derived from this software without
29.\" prior written permission. For written permission, please contact
30.\" openssl-core@openssl.org.
31.\"
32.\" 5. Products derived from this software may not be called "OpenSSL"
33.\" nor may "OpenSSL" appear in their names without prior written
34.\" permission of the OpenSSL Project.
35.\"
36.\" 6. Redistributions of any form whatsoever must retain the following
37.\" acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
40.\"
41.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
42.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
45.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\"
54.Dd $Mdocdate: December 6 2024 $
55.Dt EVP 3
56.Os
57.Sh NAME
58.Nm evp
59.Nd high-level cryptographic functions
60.Sh SYNOPSIS
61.In openssl/evp.h
62.Sh DESCRIPTION
63The EVP library provides a high-level interface to cryptographic
64functions.
65The abbreviation
66.Dq EVP
67is intended to mean
68.Dq EnVeloPe
69in the sense of
70.Dq wrapper library .
71It is not related to the technical meaning of the term
72.Dq envelope
73in contexts like
74.Xr CMS_encrypt 3 ,
75.Xr EVP_SealInit 3 ,
76.Xr PKCS7_encrypt 3 ,
77or
78.Xr SMIME_write_ASN1 3 .
79.Pp
80.Xr EVP_SealInit 3
81and
82.Xr EVP_OpenInit 3
83provide public key encryption and decryption to implement digital
84"envelopes".
85.Pp
86The
87.Xr EVP_DigestSignInit 3
88and
89.Xr EVP_DigestVerifyInit 3
90functions implement digital signatures and Message Authentication Codes
91(MACs).
92Also see the older
93.Xr EVP_SignInit 3
94and
95.Xr EVP_VerifyInit 3
96functions.
97.Pp
98Symmetric encryption is available with the
99.Xr EVP_EncryptInit 3
100functions.
101The
102.Xr EVP_DigestInit 3
103functions provide message digests.
104.Pp
105Authenticated encryption with additional data (AEAD) is available with
106the
107.Xr EVP_AEAD_CTX_init 3
108functions.
109.Pp
110The
111.Fn EVP_PKEY_*
112functions provide a high-level interface to asymmetric algorithms.
113To create a new
114.Vt EVP_PKEY ,
115see
116.Xr EVP_PKEY_new 3 .
117.Vt EVP_PKEY Ns s
118can be associated with a private key of a particular algorithm
119by using the functions described in the
120.Xr EVP_PKEY_set1_RSA 3
121page, or new keys can be generated using
122.Xr EVP_PKEY_keygen 3 .
123.Vt EVP_PKEY Ns s
124can be compared using
125.Xr EVP_PKEY_cmp 3
126or printed using
127.Xr EVP_PKEY_print_private 3 .
128.Pp
129The
130.Fn EVP_PKEY_*
131functions support the full range of asymmetric algorithm operations:
132.Bl -bullet
133.It
134For key agreement, see
135.Xr EVP_PKEY_derive 3 .
136.It
137For signing and verifying, see
138.Xr EVP_PKEY_sign 3 ,
139.Xr EVP_PKEY_verify 3 ,
140and
141.Xr EVP_PKEY_verify_recover 3 .
142However, note that these functions do not perform a digest of the
143data to be signed.
144Therefore, normally you would use the
145.Xr EVP_DigestSignInit 3
146functions for this purpose.
147.It
148For encryption and decryption see
149.Xr EVP_PKEY_encrypt 3
150and
151.Xr EVP_PKEY_decrypt 3 ,
152respectively.
153However, note that these functions perform encryption and decryption only.
154As public key encryption is an expensive operation, normally you
155would wrap an encrypted message in a digital envelope using the
156.Xr EVP_SealInit 3
157and
158.Xr EVP_OpenInit 3
159functions.
160.El
161.Pp
162The
163.Xr EVP_BytesToKey 3
164function provides some limited support for password based encryption.
165Careful selection of the parameters will provide a PKCS#5 PBKDF1
166compatible implementation.
167However, new applications should typically not use this (preferring, for
168example, PBKDF2 from PCKS#5).
169.Pp
170The
171.Xr EVP_EncodeInit 3
172family of functions provides base64 encoding and decoding.
173.Sh SEE ALSO
174.Xr ASN1_item_digest 3 ,
175.Xr ASN1_item_sign 3 ,
176.Xr BIO_f_cipher 3 ,
177.Xr BIO_f_md 3 ,
178.Xr CMAC_Init 3 ,
179.Xr CMS_encrypt 3 ,
180.Xr CMS_sign 3 ,
181.Xr crypto 3 ,
182.Xr d2i_PKCS8PrivateKey_bio 3 ,
183.Xr d2i_PrivateKey 3 ,
184.Xr EVP_AEAD_CTX_init 3 ,
185.Xr EVP_aes_128_cbc 3 ,
186.Xr EVP_BytesToKey 3 ,
187.Xr EVP_camellia_128_cbc 3 ,
188.Xr EVP_chacha20 3 ,
189.Xr EVP_CIPHER_CTX_ctrl 3 ,
190.Xr EVP_CIPHER_CTX_get_cipher_data 3 ,
191.Xr EVP_CIPHER_CTX_init 3 ,
192.Xr EVP_CIPHER_CTX_set_flags 3 ,
193.Xr EVP_CIPHER_do_all 3 ,
194.Xr EVP_CIPHER_meth_new 3 ,
195.Xr EVP_CIPHER_nid 3 ,
196.Xr EVP_des_cbc 3 ,
197.Xr EVP_DigestInit 3 ,
198.Xr EVP_DigestSignInit 3 ,
199.Xr EVP_DigestVerifyInit 3 ,
200.Xr EVP_EncodeInit 3 ,
201.Xr EVP_EncryptInit 3 ,
202.Xr EVP_MD_CTX_ctrl 3 ,
203.Xr EVP_MD_nid 3 ,
204.Xr EVP_OpenInit 3 ,
205.Xr EVP_PKCS82PKEY 3 ,
206.Xr EVP_PKEY_asn1_get_count 3 ,
207.Xr EVP_PKEY_cmp 3 ,
208.Xr EVP_PKEY_CTX_ctrl 3 ,
209.Xr EVP_PKEY_CTX_get_operation 3 ,
210.Xr EVP_PKEY_CTX_new 3 ,
211.Xr EVP_PKEY_CTX_set_hkdf_md 3 ,
212.Xr EVP_PKEY_decrypt 3 ,
213.Xr EVP_PKEY_derive 3 ,
214.Xr EVP_PKEY_encrypt 3 ,
215.Xr EVP_PKEY_get_default_digest_nid 3 ,
216.Xr EVP_PKEY_keygen 3 ,
217.Xr EVP_PKEY_new 3 ,
218.Xr EVP_PKEY_print_private 3 ,
219.Xr EVP_PKEY_set1_RSA 3 ,
220.Xr EVP_PKEY_sign 3 ,
221.Xr EVP_PKEY_size 3 ,
222.Xr EVP_PKEY_verify 3 ,
223.Xr EVP_PKEY_verify_recover 3 ,
224.Xr EVP_rc4 3 ,
225.Xr EVP_SealInit 3 ,
226.Xr EVP_sha1 3 ,
227.Xr EVP_sha3_224 3 ,
228.Xr EVP_SignInit 3 ,
229.Xr EVP_sm3 3 ,
230.Xr EVP_sm4_cbc 3 ,
231.Xr EVP_VerifyInit 3 ,
232.Xr HMAC 3 ,
233.Xr OCSP_basic_sign 3 ,
234.Xr OCSP_request_sign 3 ,
235.Xr PEM_get_EVP_CIPHER_INFO 3 ,
236.Xr PEM_read_bio_PrivateKey 3 ,
237.Xr PKCS12_create 3 ,
238.Xr PKCS5_PBKDF2_HMAC 3 ,
239.Xr PKCS7_encrypt 3 ,
240.Xr PKCS7_sign 3 ,
241.Xr RSA_pkey_ctx_ctrl 3 ,
242.Xr SSL_CTX_set_tlsext_ticket_key_cb 3 ,
243.Xr X509_ALGOR_set0 3 ,
244.Xr X509_check_private_key 3 ,
245.Xr X509_digest 3 ,
246.Xr X509_get_pubkey 3 ,
247.Xr X509_PUBKEY_set 3 ,
248.Xr X509_sign 3 ,
249.Xr X509_to_X509_REQ 3
diff --git a/src/lib/libcrypto/man/i2a_ASN1_STRING.3 b/src/lib/libcrypto/man/i2a_ASN1_STRING.3
deleted file mode 100644
index 7d46474775..0000000000
--- a/src/lib/libcrypto/man/i2a_ASN1_STRING.3
+++ /dev/null
@@ -1,255 +0,0 @@
1.\" $OpenBSD: i2a_ASN1_STRING.3,v 1.5 2024/12/27 15:30:17 schwarze Exp $
2.\"
3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 27 2024 $
18.Dt I2A_ASN1_STRING 3
19.Os
20.Sh NAME
21.Nm i2a_ASN1_STRING ,
22.Nm i2a_ASN1_INTEGER ,
23.Nm i2a_ASN1_ENUMERATED ,
24.Nm a2i_ASN1_STRING ,
25.Nm a2i_ASN1_INTEGER ,
26.Nm a2i_ASN1_ENUMERATED
27.Nd hexadecimal dump of an ASN.1 string
28.Sh SYNOPSIS
29.In openssl/asn1.h
30.Ft int
31.Fo i2a_ASN1_STRING
32.Fa "BIO *out_bio"
33.Fa "const ASN1_STRING *a"
34.Fa "int type"
35.Fc
36.Ft int
37.Fo i2a_ASN1_INTEGER
38.Fa "BIO *out_bio"
39.Fa "const ASN1_INTEGER *a"
40.Fc
41.Ft int
42.Fo i2a_ASN1_ENUMERATED
43.Fa "BIO *out_bio"
44.Fa "const i2a_ASN1_ENUMERATED *a"
45.Fc
46.Ft int
47.Fo a2i_ASN1_STRING
48.Fa "BIO *in_bio"
49.Fa "ASN1_STRING *out_string"
50.Fa "char *buffer"
51.Fa "int size"
52.Fc
53.Ft int
54.Fo a2i_ASN1_INTEGER
55.Fa "BIO *in_bio"
56.Fa "ASN1_INTEGER *out_string"
57.Fa "char *buffer"
58.Fa "int size"
59.Fc
60.Ft int
61.Fo a2i_ASN1_ENUMERATED
62.Fa "BIO *in_bio"
63.Fa "ASN1_ENUMERATED *out_string"
64.Fa "char *buffer"
65.Fa "int size"
66.Fc
67.Sh DESCRIPTION
68The functions
69.Fn i2a_ASN1_STRING ,
70.Fn i2a_ASN1_INTEGER ,
71and
72.Fn i2a_ASN1_ENUMERATED
73write a hexadecimal representation of
74.Fa a
75to
76.Fa out_bio .
77The
78.Fa type
79argument is ignored.
80.Pp
81Each byte of
82.Xr ASN1_STRING_get0_data 3
83is written as a number consisting of two upper-case hexadecimal digits.
84After each group of 70 digits, a backslash and a linefeed
85are inserted before the next digit.
86.Pp
87If the
88.Xr ASN1_STRING_length 3
89of
90.Fa a
91is 0, instead a pair of zero digits
92.Pq Qq 00
93is written by
94.Fn i2a_ASN1_INTEGER
95and
96.Fn i2a_ASN1_ENUMERATED
97and a single zero digit
98.Pq Qq 0
99by
100.Fn i2a_ASN1_STRING .
101If
102.Fa a
103is a
104.Dv NULL
105pointer, nothing is written.
106.Pp
107If
108.Fa a
109represents a negative integer,
110.Fn i2a_ASN1_INTEGER
111prepends a minus sign to the output.
112.Pp
113The functions
114.Fn a2i_ASN1_STRING ,
115.Fn a2i_ASN1_INTEGER ,
116and
117.Fn a2i_ASN1_ENUMERATED
118parse a hexadecimal representation of an ASN.1 string into
119.Fa out_string .
120Both lower-case and upper-case hexadecimal digits are accepted.
121Every pair of input digits is converted into one output byte.
122.Pp
123On every input line, the trailing newline character and an optional
124carriage return character preceding it are ignored.
125The trailing newline need not be present on the last line.
126If there is a backslash character before the newline character,
127parsing is continued on the next input line.
128.Pp
129At least one pair of input digits is required by
130.Fn a2i_ASN1_INTEGER
131and
132.Fn a2i_ASN1_ENUMERATED ,
133whereas
134.Fn a2i_ASN1_STRING
135converts empty input to an empty string.
136.Pp
137These functions are able to parse the output of
138.Fn i2a_ASN1_ENUMERATED .
139They can parse the output of
140.Fn i2a_ASN1_INTEGER
141unless
142.Fa a
143was negative, and they can parse the output of
144.Fn i2a_ASN1_STRING
145unless the
146.Xr ASN1_STRING_length 3
147of
148.Fa a
149was 0.
150.Pp
151Parsing fails if an input line contains an odd number of input
152digits or if memory allocation fails.
153.Pp
154These functions use the
155.Fa buffer
156provided by the caller and assume it is at least
157.Fa size
158bytes long.
159It is unspecified what the buffer contains after the functions return.
160.Sh RETURN VALUES
161The functions
162.Fn i2a_ASN1_STRING ,
163.Fn i2a_ASN1_INTEGER ,
164and
165.Fn i2a_ASN1_ENUMERATED
166return the number of bytes written or \-1 if
167.Xr BIO_write 3
168fails.
169In particular, they all return 0 when
170.Fa a
171is a
172.Dv NULL
173pointer.
174.Fn i2a_ASN1_STRING
175returns 1 for an empty string or an even number greater than 1
176for a string that is not empty.
177.Fn i2a_ASN1_INTEGER
178returns an even number greater than 1 for positive input
179or an odd number greater than 2 for negative input.
180.Fn i2a_ASN1_ENUMERATED
181always returns a non-negative even number when successful.
182.Pp
183The functions
184.Fn a2i_ASN1_STRING ,
185.Fn a2i_ASN1_INTEGER ,
186and
187.Fn a2i_ASN1_ENUMERATED
188are intended to return 1 for success or 0 for failure, but see the
189.Sx BUGS
190section for a number of traps.
191.Sh SEE ALSO
192.Xr a2i_ipadd 3 ,
193.Xr ASN1_STRING_length 3 ,
194.Xr ASN1_STRING_new 3 ,
195.Xr ASN1_STRING_print_ex 3 ,
196.Xr i2a_ASN1_OBJECT 3 ,
197.Xr i2s_ASN1_INTEGER 3
198.Sh HISTORY
199.Fn i2a_ASN1_INTEGER
200and
201.Fn a2i_ASN1_INTEGER
202first appeared in SSLeay 0.6.0.
203.Fn i2a_ASN1_STRING
204and
205.Fn a2i_ASN1_STRING
206first appeared in SSLeay 0.6.5.
207.Fn a2i_ASN1_STRING
208has been part of the public API since SSLeay 0.6.5 and
209.Fn i2a_ASN1_STRING
210since SSLeay 0.8.0.
211These functions have been available since
212.Ox 2.4 .
213.Pp
214.Fn i2a_ASN1_ENUMERATED
215and
216.Fn a2i_ASN1_ENUMERATED
217first appeared in OpenSSL 0.9.2 and have been available since
218.Ox 2.6 .
219.Sh BUGS
220If the first call to
221.Xr BIO_gets 3
222does not return any data, even if that is caused by a fatal I/O error,
223if the BIO type does not support the
224.Dq gets
225operation, or if it is caused by the BIO being non-blocking,
226.Fn a2i_ASN1_STRING
227immediately succeeds and returns an empty
228.Fa out_string .
229.Pp
230If
231.Fn BIO_gets 3
232returns a partial line, for example because the given
233.Fa size
234is insufficient to contain one of the input lines
235or for reasons specific to the BIO type,
236.Fn a2i_ASN1_STRING ,
237.Fn a2i_ASN1_INTEGER ,
238and
239.Fn a2i_ASN1_ENUMERATED
240may fail or silently return a truncated result.
241The caller is responsible for providing a
242.Fa buffer
243of sufficient size to contain the longest possible input line
244and for choosing a BIO of a type that only returns complete
245input lines and does not perform partial reads.
246.Pp
247The functions
248.Fn a2i_ASN1_STRING ,
249.Fn a2i_ASN1_INTEGER ,
250and
251.Fn a2i_ASN1_ENUMERATED
252do not support non-blocking BIOs.
253Reading is terminated as soon as
254.Xr BIO_gets 3
255returns a value less than 1.
diff --git a/src/lib/libcrypto/man/i2d_CMS_bio_stream.3 b/src/lib/libcrypto/man/i2d_CMS_bio_stream.3
deleted file mode 100644
index b60468464c..0000000000
--- a/src/lib/libcrypto/man/i2d_CMS_bio_stream.3
+++ /dev/null
@@ -1,95 +0,0 @@
1.\" $OpenBSD: i2d_CMS_bio_stream.3,v 1.6 2023/05/01 07:28:11 tb Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: May 1 2023 $
52.Dt I2D_CMS_BIO_STREAM 3
53.Os
54.Sh NAME
55.Nm i2d_CMS_bio_stream
56.Nd output CMS_ContentInfo structure in BER format
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft int
60.Fo i2d_CMS_bio_stream
61.Fa "BIO *out"
62.Fa "CMS_ContentInfo *cms"
63.Fa "BIO *data"
64.Fa "int flags"
65.Fc
66.Sh DESCRIPTION
67.Fn i2d_CMS_bio_stream
68outputs a
69.Vt CMS_ContentInfo
70structure in BER format.
71.Pp
72It is otherwise identical to the function
73.Xr SMIME_write_CMS 3 .
74.Pp
75This function is effectively a version of
76.Xr i2d_CMS_bio 3
77supporting streaming.
78.Sh RETURN VALUES
79.Fn i2d_CMS_bio_stream
80returns 1 for success or 0 for failure.
81.Sh SEE ALSO
82.Xr CMS_ContentInfo_new 3 ,
83.Xr CMS_encrypt 3 ,
84.Xr CMS_sign 3 ,
85.Xr ERR_get_error 3 ,
86.Xr PEM_write_bio_CMS_stream 3 ,
87.Xr SMIME_write_CMS 3
88.Sh HISTORY
89.Fn i2d_CMS_bio_stream
90first appeared in OpenSSL 1.0.0
91and has been available since
92.Ox 6.7 .
93.Sh BUGS
94The prefix "i2d" is arguably wrong because the function outputs BER
95format.
diff --git a/src/lib/libcrypto/man/i2d_PKCS7_bio_stream.3 b/src/lib/libcrypto/man/i2d_PKCS7_bio_stream.3
deleted file mode 100644
index 7a47ba3026..0000000000
--- a/src/lib/libcrypto/man/i2d_PKCS7_bio_stream.3
+++ /dev/null
@@ -1,94 +0,0 @@
1.\" $OpenBSD: i2d_PKCS7_bio_stream.3,v 1.11 2023/05/01 07:28:11 tb Exp $
2.\" OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2007, 2008, 2009, 2013 The OpenSSL Project.
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: May 1 2023 $
53.Dt I2D_PKCS7_BIO_STREAM 3
54.Os
55.Sh NAME
56.Nm i2d_PKCS7_bio_stream
57.Nd output PKCS7 structure in BER format
58.Sh SYNOPSIS
59.In openssl/pkcs7.h
60.Ft int
61.Fo i2d_PKCS7_bio_stream
62.Fa "BIO *out"
63.Fa "PKCS7 *p7"
64.Fa "BIO *data"
65.Fa "int flags"
66.Fc
67.Sh DESCRIPTION
68.Fn i2d_PKCS7_bio_stream
69outputs a
70.Vt PKCS7
71structure in BER format.
72It is otherwise identical to the function
73.Xr SMIME_write_PKCS7 3 .
74This function is effectively a version of
75.Xr i2d_PKCS7_bio 3
76supporting streaming.
77.Sh RETURN VALUES
78.Fn i2d_PKCS7_bio_stream
79returns 1 for success or 0 for failure.
80.Sh SEE ALSO
81.Xr BIO_new 3 ,
82.Xr ERR_get_error 3 ,
83.Xr PEM_write_bio_PKCS7_stream 3 ,
84.Xr PEM_write_PKCS7 3 ,
85.Xr PKCS7_final 3 ,
86.Xr PKCS7_new 3 ,
87.Xr SMIME_write_PKCS7 3
88.Sh HISTORY
89.Fn i2d_PKCS7_bio_stream
90first appeared in OpenSSL 1.0.0 and has been available since
91.Ox 4.9 .
92.Sh BUGS
93The prefix "i2d" is arguably wrong because the function outputs BER
94format.
diff --git a/src/lib/libcrypto/man/lh_new.3 b/src/lib/libcrypto/man/lh_new.3
deleted file mode 100644
index 2550a7d2e7..0000000000
--- a/src/lib/libcrypto/man/lh_new.3
+++ /dev/null
@@ -1,554 +0,0 @@
1.\" $OpenBSD: lh_new.3,v 1.13 2024/03/05 22:15:29 tb Exp $
2.\" full merge up to:
3.\" OpenSSL doc/crypto/lhash.pod 1bc74519 May 20 08:11:46 2016 -0400
4.\" selective merge up to:
5.\" OpenSSL doc/man3/OPENSSL_LH_COMPFUNC.pod 24a535ea Sep 22 13:14:20 2020 +0100
6.\"
7.\" --------------------------------------------------------------------------
8.\" Major patches to this file were contributed by
9.\" Ulf Moeller <ulf@openssl.org>, Geoff Thorpe <geoff@openssl.org>,
10.\" and Ben Laurie <ben@openssl.org>.
11.\" --------------------------------------------------------------------------
12.\" Copyright (c) 2000, 2001, 2002, 2008, 2009 The OpenSSL Project.
13.\" All rights reserved.
14.\"
15.\" Redistribution and use in source and binary forms, with or without
16.\" modification, are permitted provided that the following conditions
17.\" are met:
18.\"
19.\" 1. Redistributions of source code must retain the above copyright
20.\" notice, this list of conditions and the following disclaimer.
21.\"
22.\" 2. Redistributions in binary form must reproduce the above copyright
23.\" notice, this list of conditions and the following disclaimer in
24.\" the documentation and/or other materials provided with the
25.\" distribution.
26.\"
27.\" 3. All advertising materials mentioning features or use of this
28.\" software must display the following acknowledgment:
29.\" "This product includes software developed by the OpenSSL Project
30.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
31.\"
32.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
33.\" endorse or promote products derived from this software without
34.\" prior written permission. For written permission, please contact
35.\" openssl-core@openssl.org.
36.\"
37.\" 5. Products derived from this software may not be called "OpenSSL"
38.\" nor may "OpenSSL" appear in their names without prior written
39.\" permission of the OpenSSL Project.
40.\"
41.\" 6. Redistributions of any form whatsoever must retain the following
42.\" acknowledgment:
43.\" "This product includes software developed by the OpenSSL Project
44.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
45.\"
46.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
47.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
50.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
52.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
57.\" OF THE POSSIBILITY OF SUCH DAMAGE.
58.\"
59.\" --------------------------------------------------------------------------
60.\" Parts of this file are derived from SSLeay documentation,
61.\" which is covered by the following Copyright and license:
62.\" --------------------------------------------------------------------------
63.\"
64.\" Copyright (C) 1995-1998 Tim Hudson (tjh@cryptsoft.com)
65.\" All rights reserved.
66.\"
67.\" This package is an SSL implementation written
68.\" by Eric Young (eay@cryptsoft.com).
69.\" The implementation was written so as to conform with Netscapes SSL.
70.\"
71.\" This library is free for commercial and non-commercial use as long as
72.\" the following conditions are aheared to. The following conditions
73.\" apply to all code found in this distribution, be it the RC4, RSA,
74.\" lhash, DES, etc., code; not just the SSL code. The SSL documentation
75.\" included with this distribution is covered by the same copyright terms
76.\" except that the holder is Tim Hudson (tjh@cryptsoft.com).
77.\"
78.\" Copyright remains Eric Young's, and as such any Copyright notices in
79.\" the code are not to be removed.
80.\" If this package is used in a product, Eric Young should be given
81.\" attribution as the author of the parts of the library used.
82.\" This can be in the form of a textual message at program startup or
83.\" in documentation (online or textual) provided with the package.
84.\"
85.\" Redistribution and use in source and binary forms, with or without
86.\" modification, are permitted provided that the following conditions
87.\" are met:
88.\" 1. Redistributions of source code must retain the copyright
89.\" notice, this list of conditions and the following disclaimer.
90.\" 2. Redistributions in binary form must reproduce the above copyright
91.\" notice, this list of conditions and the following disclaimer in the
92.\" documentation and/or other materials provided with the distribution.
93.\" 3. All advertising materials mentioning features or use of this software
94.\" must display the following acknowledgement:
95.\" "This product includes cryptographic software written by
96.\" Eric Young (eay@cryptsoft.com)"
97.\" The word 'cryptographic' can be left out if the rouines from the
98.\" library being used are not cryptographic related :-).
99.\" 4. If you include any Windows specific code (or a derivative thereof)
100.\" from the apps directory (application code) you must include an
101.\" acknowledgement: "This product includes software written by
102.\" Tim Hudson (tjh@cryptsoft.com)"
103.\"
104.\" THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
105.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
106.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
107.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
108.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
109.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
110.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
111.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
112.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
113.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
114.\" SUCH DAMAGE.
115.\"
116.\" The licence and distribution terms for any publically available version or
117.\" derivative of this code cannot be changed. i.e. this code cannot simply be
118.\" copied and put under another distribution licence
119.\" [including the GNU Public Licence.]
120.\"
121.Dd $Mdocdate: March 5 2024 $
122.Dt LH_NEW 3
123.Os
124.Sh NAME
125.Nm lh_new ,
126.Nm lh_free ,
127.Nm lh_insert ,
128.Nm lh_delete ,
129.Nm lh_retrieve ,
130.Nm lh_doall ,
131.Nm lh_doall_arg ,
132.Nm lh_error ,
133.Nm LHASH_COMP_FN_TYPE ,
134.Nm LHASH_HASH_FN_TYPE ,
135.Nm LHASH_DOALL_FN_TYPE ,
136.Nm LHASH_DOALL_ARG_FN_TYPE ,
137.Nm lh_strhash
138.Nd dynamic hash table
139.Sh SYNOPSIS
140.In openssl/lhash.h
141.Fn DECLARE_LHASH_OF <type>
142.Ft LHASH *
143.Fn lh_<type>_new void
144.Ft void
145.Fo lh_<type>_free
146.Fa "LHASH_OF(<type>) *table"
147.Fc
148.Ft <type> *
149.Fo lh_<type>_insert
150.Fa "LHASH_OF(<type>) *table"
151.Fa "<type> *data"
152.Fc
153.Ft <type> *
154.Fo lh_<type>_delete
155.Fa "LHASH_OF(<type>) *table"
156.Fa "<type> *data"
157.Fc
158.Ft <type> *
159.Fo lh_<type>_retrieve
160.Fa "LHASH_OF(<type>) *table"
161.Fa "<type> *data"
162.Fc
163.Ft void
164.Fo lh_<type>_doall
165.Fa "LHASH_OF(<type>) *table"
166.Fa "LHASH_DOALL_FN_TYPE func"
167.Fc
168.Ft void
169.Fo lh_<type>_doall_arg
170.Fa "LHASH_OF(<type>) *table"
171.Fa "LHASH_DOALL_ARG_FN_TYPE func"
172.Fa "<type2>"
173.Fa "<type2> *arg"
174.Fc
175.Ft int
176.Fo lh_<type>_error
177.Fa "LHASH_OF(<type>) *table"
178.Fc
179.Ft typedef int
180.Fo (*LHASH_COMP_FN_TYPE)
181.Fa "const void *"
182.Fa "const void *"
183.Fc
184.Ft typedef unsigned long
185.Fo (*LHASH_HASH_FN_TYPE)
186.Fa "const void *"
187.Fc
188.Ft typedef void
189.Fo (*LHASH_DOALL_FN_TYPE)
190.Fa "const void *"
191.Fc
192.Ft typedef void
193.Fo (*LHASH_DOALL_ARG_FN_TYPE)
194.Fa "const void *"
195.Fa "const void *"
196.Fc
197.Ft unsigned long
198.Fo lh_strhash
199.Fa "const char *c"
200.Fc
201.Sh DESCRIPTION
202This library implements type-checked dynamic hash tables.
203The hash table entries can be arbitrary structures.
204Usually they consist of key and value fields.
205.Pp
206.Fn lh_<type>_new
207creates a new
208.Vt LHASH_OF(<type>)
209structure to store arbitrary data entries, and provides the hash and
210compare callbacks to be used in organising the table's entries.
211The hash callback takes a pointer to a table entry as its argument
212and returns an unsigned long hash value for its key field.
213The hash value is normally truncated to a power of 2, so make sure that
214your hash function returns well mixed low order bits.
215The compare callback takes two arguments (pointers to two hash table
216entries), and returns 0 if their keys are equal, non-zero otherwise.
217If your hash table will contain items of some particular type and the
218hash and compare callbacks hash and compare these types, then the
219.Fn DECLARE_LHASH_HASH_FN
220and
221.Fn IMPLEMENT_LHASH_COMP_FN
222macros can be used to create callback wrappers of the prototypes
223required by
224.Fn lh_<type>_new .
225These provide per-variable casts before calling the type-specific
226callbacks written by the application author.
227These macros, as well as those used for the doall callbacks, are
228defined as;
229.Bd -literal -offset 2n
230#define DECLARE_LHASH_HASH_FN(name, o_type) \e
231 unsigned long name##_LHASH_HASH(const void *);
232#define IMPLEMENT_LHASH_HASH_FN(name, o_type) \e
233 unsigned long name##_LHASH_HASH(const void *arg) { \e
234 const o_type *a = arg; \e
235 return name##_hash(a); }
236#define LHASH_HASH_FN(name) name##_LHASH_HASH
237
238#define DECLARE_LHASH_COMP_FN(name, o_type) \e
239 int name##_LHASH_COMP(const void *, const void *);
240#define IMPLEMENT_LHASH_COMP_FN(name, o_type) \e
241 int name##_LHASH_COMP(const void *arg1, const void *arg2) { \e
242 const o_type *a = arg1; \e
243 const o_type *b = arg2; \e
244 return name##_cmp(a,b); }
245#define LHASH_COMP_FN(name) name##_LHASH_COMP
246
247#define DECLARE_LHASH_DOALL_FN(name, o_type) \e
248 void name##_LHASH_DOALL(void *);
249#define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \e
250 void name##_LHASH_DOALL(void *arg) { \e
251 o_type *a = arg; \e
252 name##_doall(a); }
253#define LHASH_DOALL_FN(name) name##_LHASH_DOALL
254
255#define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \e
256 void name##_LHASH_DOALL_ARG(void *, void *);
257#define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \e
258 void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \e
259 o_type *a = arg1; \e
260 a_type *b = arg2; \e
261 name##_doall_arg(a, b); }
262#define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG
263.Ed
264.Pp
265An example of a hash table storing (pointers to) structures of type
266\&'STUFF' could be defined as follows;
267.Bd -literal -offset 2n
268/* Calculate the hash value of 'tohash' (implemented elsewhere) */
269unsigned long STUFF_hash(const STUFF *tohash);
270/* Order 'arg1' and 'arg2' (implemented elsewhere) */
271int stuff_cmp(const STUFF *arg1, const STUFF *arg2);
272/* Create type-safe wrapper functions for use in the LHASH internals */
273static IMPLEMENT_LHASH_HASH_FN(stuff, STUFF);
274static IMPLEMENT_LHASH_COMP_FN(stuff, STUFF);
275/* ... */
276int main(int argc, char *argv[]) {
277 /* Create the new hash table using the hash/compare wrappers */
278 LHASH_OF(STUFF) *hashtable =
279 lh_STUFF_new(LHASH_HASH_FN(STUFF_hash),
280 LHASH_COMP_FN(STUFF_cmp));
281 /* ... */
282}
283.Ed
284.Pp
285.Fn lh_<type>_free
286frees the
287.Vt LHASH_OF(<type>)
288structure
289.Fa table .
290Allocated hash table entries will not be freed; consider using
291.Fn lh_<type>_doall
292to deallocate any remaining entries in the hash table (see below).
293.Pp
294.Fn lh_<type>_insert
295inserts the structure pointed to by
296.Fa data
297into
298.Fa table .
299If there already is an entry with the same key, the old value is
300replaced.
301Note that
302.Fn lh_<type>_insert
303stores pointers, the data are not copied.
304.Pp
305.Fn lh_<type>_delete
306deletes an entry from
307.Fa table .
308.Pp
309.Fn lh_<type>_retrieve
310looks up an entry in
311.Fa table .
312Normally,
313.Fa data
314is a structure with the key field(s) set; the function will return a
315pointer to a fully populated structure.
316.Pp
317.Fn lh_<type>_doall
318will, for every entry in the hash table, call
319.Fa func
320with the data item as its parameter.
321For
322.Fn lh_<type>_doall
323and
324.Fn lh_<type>_doall_arg ,
325function pointer casting should be avoided in the callbacks (see
326.Sx NOTES )
327\(em instead use the declare/implement macros to create type-checked
328wrappers that cast variables prior to calling your type-specific
329callbacks.
330An example of this is illustrated here where the callback is used to
331cleanup resources for items in the hash table prior to the hashtable
332itself being deallocated:
333.Bd -literal -offset 2n
334/* Clean up resources belonging to 'a' (this is implemented elsewhere) */
335void STUFF_cleanup_doall(STUFF *a);
336/* Implement a prototype-compatible wrapper for "STUFF_cleanup" */
337IMPLEMENT_LHASH_DOALL_FN(STUFF_cleanup, STUFF)
338 /* ... then later in the code ... */
339/* So to run "STUFF_cleanup" against all items in a hash table ... */
340lh_STUFF_doall(hashtable, LHASH_DOALL_FN(STUFF_cleanup));
341/* Then the hash table itself can be deallocated */
342lh_STUFF_free(hashtable);
343.Ed
344.Pp
345A callback may delete entries from the hash table, however, it is
346not safe to insert new entries.
347.Pp
348.Fn lh_<type>_doall_arg
349is the same as
350.Fn lh_<type>_doall
351except that
352.Fa func
353will be called with
354.Fa arg
355as the second argument and
356.Fa func
357should be of type
358.Vt LHASH_DOALL_ARG_FN_TYPE
359(a callback prototype that is passed both the table entry and an extra
360argument).
361As with
362.Fn lh_<type>_doall ,
363you can instead choose to declare your callback with a prototype
364matching the types you are dealing with and use the declare/implement
365macros to create compatible wrappers that cast variables before calling
366your type-specific callbacks.
367An example of this is demonstrated here (printing all hash table entries
368to a BIO that is provided by the caller):
369.Bd -literal -offset 2n
370/* Print item 'a' to 'output_bio' (this is implemented elsewhere) */
371void STUFF_print_doall_arg(const STUFF *a, BIO *output_bio);
372/* Implement a prototype-compatible wrapper for "STUFF_print" */
373static IMPLEMENT_LHASH_DOALL_ARG_FN(STUFF, const STUFF, BIO)
374 /* ... then later in the code ... */
375/* Print out the entire hashtable to a particular BIO */
376lh_STUFF_doall_arg(hashtable, LHASH_DOALL_ARG_FN(STUFF_print), BIO,
377 logging_bio);
378.Ed
379.Pp
380.Fn lh_<type>_error
381can be used to determine if an error occurred in the last operation.
382.Sh RETURN VALUES
383.Fn lh_<type>_new
384returns
385.Dv NULL
386on error, otherwise a pointer to the new
387.Vt LHASH
388structure.
389.Pp
390When a hash table entry is replaced,
391.Fn lh_<type>_insert
392returns the value being replaced.
393.Dv NULL
394is returned on normal operation and on error.
395.Pp
396.Fn lh_<type>_delete
397returns the entry being deleted.
398.Dv NULL
399is returned if there is no such value in the hash table.
400.Pp
401.Fn lh_<type>_retrieve
402returns the hash table entry if it has been found, or
403.Dv NULL
404otherwise.
405.Pp
406.Fn lh_<type>_error
407returns 1 if an error occurred in the last operation, or 0 otherwise.
408.Sh NOTES
409The various LHASH macros and callback types exist to make it possible to
410write type-checked code without resorting to function-prototype casting
411\(em an evil that makes application code much harder to audit/verify and
412also opens the window of opportunity for stack corruption and other
413hard-to-find bugs.
414It also, apparently, violates ANSI-C.
415.Pp
416The LHASH code regards table entries as constant data.
417As such, it internally represents
418.Fn lh_<type>_insert Ap ed
419items with a
420.Vt const void *
421pointer type.
422This is why callbacks such as those used by
423.Fn lh_<type>_doall
424and
425.Fn lh_<type>_doall_arg
426declare their prototypes with "const", even for the parameters that pass
427back the table items' data pointers \(em for consistency, user-provided
428data is "const" at all times as far as the LHASH code is concerned.
429However, as callers are themselves providing these pointers, they can
430choose whether they too should be treating all such parameters as
431constant.
432.Pp
433As an example, a hash table may be maintained by code that, for
434reasons of encapsulation, has only "const" access to the data being
435indexed in the hash table (i.e. it is returned as "const" from
436elsewhere in their code) \(em in this case the LHASH prototypes are
437appropriate as-is.
438Conversely, if the caller is responsible for the life-time of the data
439in question, then they may well wish to make modifications to table item
440passed back in the
441.Fn lh_<type>_doall
442or
443.Fn lh_<type>_doall_arg
444callbacks (see the "STUFF_cleanup" example above).
445If so, the caller can either cast the "const" away (if they're providing
446the raw callbacks themselves) or use the macros to declare/implement the
447wrapper functions without "const" types.
448.Pp
449Callers that only have "const" access to data they are indexing in a
450table, yet declare callbacks without constant types (or cast the "const"
451away themselves), are therefore creating their own risks/bugs without
452being encouraged to do so by the API.
453On a related note, those auditing code should pay special attention
454to any instances of DECLARE/IMPLEMENT_LHASH_DOALL_[ARG_]_FN macros
455that provide types without any "const" qualifiers.
456.Sh INTERNALS
457The following description is based on the SSLeay documentation:
458.Pp
459The lhash library implements a hash table described in the
460.Em Communications of the ACM
461in 1991.
462What makes this hash table different is that as the table fills,
463the hash table is increased (or decreased) in size via
464.Xr reallocarray 3 .
465When a 'resize' is done, instead of all hashes being redistributed over
466twice as many 'buckets', one bucket is split.
467So when an 'expand' is done, there is only a minimal cost to
468redistribute some values.
469Subsequent inserts will cause more single 'bucket' redistributions but
470there will never be a sudden large cost due to redistributing all the
471\&'buckets'.
472.Pp
473The state for a particular hash table is kept in the
474.Vt LHASH
475structure.
476The decision to increase or decrease the hash table size is made
477depending on the 'load' of the hash table.
478The load is the number of items in the hash table divided by the size of
479the hash table.
480The default values are as follows.
481If (hash->up_load < load) => expand.
482If (hash->down_load > load) => contract.
483The
484.Fa up_load
485has a default value of 1 and
486.Fa down_load
487has a default value of 2.
488These numbers can be modified by the application by just playing
489with the
490.Fa up_load
491and
492.Fa down_load
493variables.
494The 'load' is kept in a form which is multiplied by 256.
495So hash->up_load=8*256 will cause a load of 8 to be set.
496.Pp
497If you are interested in performance, the field to watch is
498.Fa num_comp_calls .
499The hash library keeps track of the 'hash' value for each item so when a
500lookup is done, the 'hashes' are compared, if there is a match, then a
501full compare is done, and hash->num_comp_calls is incremented.
502If num_comp_calls is not equal to num_delete plus num_retrieve, it means
503that your hash function is generating hashes that are the same for
504different values.
505It is probably worth changing your hash function if this is the case
506because even if your hash table has 10 items in a 'bucket', it can be
507searched with 10
508.Vt unsigned long
509compares and 10 linked list traverses.
510This will be much less expensive that 10 calls to your compare function.
511.Pp
512.Fn lh_strhash
513is a demo string hashing function.
514Since the LHASH routines would normally be passed structures, this
515routine would not normally be passed to
516.Fn lh_<type>_new ,
517rather it would be used in the function passed to
518.Fn lh_<type>_new .
519.Sh SEE ALSO
520.Xr crypto 3
521.Sh HISTORY
522.Fn lh_new ,
523.Fn lh_free ,
524.Fn lh_insert ,
525.Fn lh_delete ,
526.Fn lh_retrieve ,
527.Fn lh_doall ,
528and
529.Fn lh_strhash
530appeared in SSLeay 0.4 or earlier.
531.Fn lh_doall_arg
532first appeared in SSLeay 0.5.1.
533These functions have been available since
534.Ox 2.4 .
535.Pp
536.Fn lh_<type>_error
537was added in SSLeay 0.9.1b.
538.Pp
539In OpenSSL 0.9.7, all lhash functions that were passed function pointers
540were changed for better type safety, and the function types
541.Vt LHASH_COMP_FN_TYPE ,
542.Vt LHASH_HASH_FN_TYPE ,
543.Vt LHASH_DOALL_FN_TYPE ,
544and
545.Vt LHASH_DOALL_ARG_FN_TYPE
546became available.
547.Pp
548In OpenSSL 1.0.0, the lhash interface was revamped for even better type
549checking.
550.Sh BUGS
551.Fn lh_<type>_insert
552returns
553.Dv NULL
554both for success and error.
diff --git a/src/lib/libcrypto/man/openssl.cnf.5 b/src/lib/libcrypto/man/openssl.cnf.5
deleted file mode 100644
index 4047eb059a..0000000000
--- a/src/lib/libcrypto/man/openssl.cnf.5
+++ /dev/null
@@ -1,361 +0,0 @@
1.\" $OpenBSD: openssl.cnf.5,v 1.11 2024/07/08 15:02:28 jmc Exp $
2.\" full merge up to: OpenSSL man5/config b53338cb Feb 28 12:30:28 2017 +0100
3.\" selective merge up to: OpenSSL a8c5ed81 Jul 18 13:57:25 2017 -0400
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 1999, 2000, 2004, 2013, 2015, 2016, 2017 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: July 8 2024 $
54.Dt OPENSSL.CNF 5
55.Os
56.Sh NAME
57.Nm openssl.cnf
58.Nd OpenSSL configuration files
59.Sh DESCRIPTION
60The OpenSSL CONF library can be used to read configuration files; see
61.Xr CONF_modules_load_file 3 .
62It is used for the OpenSSL master configuration file
63.Pa /etc/ssl/openssl.cnf
64and in a few other places such as certificate extension files for the
65.Xr openssl 1
66.Cm x509
67utility.
68OpenSSL applications can also use the CONF library for their own
69purposes.
70.Pp
71A configuration file is divided into a number of sections.
72Each section starts with a line
73.Bq Ar section_name
74and ends when a new section is started or the end of the file is reached.
75A section name can consist of alphanumeric characters and underscores.
76.Pp
77The first section of a configuration file is special and is referred to
78as the
79.Dq default section .
80It is usually unnamed and extends from the start of file to the
81first named section.
82When a name is being looked up, it is first looked up in a named
83section (if any) and then in the default section.
84.Pp
85The environment is mapped onto a section called
86.Ic ENV .
87.Pp
88Comments can be included by preceding them with the
89.Ql #
90character.
91.Pp
92Each section in a configuration file consists of a number of name and
93value pairs of the form
94.Ar name Ns = Ns Ar value .
95.Pp
96The
97.Ar name
98string can contain any alphanumeric characters as well as a few
99punctuation symbols such as
100.Ql \&.
101.Ql \&,
102.Ql \&;
103and
104.Ql _ .
105.Pp
106The
107.Ar value
108string consists of the string following the
109.Ql =
110character until the end of the line with any leading and trailing
111whitespace removed.
112.Pp
113The value string undergoes variable expansion.
114This can be done by including substrings of the form
115.Pf $ Ar name
116or
117.Pf $ Brq Ar name :
118this will substitute the value of the named variable in the current
119section.
120It is also possible to substitute a value from another section using the
121syntax
122.Pf $ Ar section Ns :: Ns Ar name
123or
124.Pf $ Brq Ar section Ns :: Ns Ar name .
125By using the form
126.Pf $ Ic ENV Ns :: Ns Ar name ,
127environment variables can be substituted.
128It is also possible to assign values to environment variables by using
129the name
130.Ic ENV Ns :: Ns Ar name .
131This will work if the program looks up environment variables using
132the CONF library instead of calling
133.Xr getenv 3
134directly.
135The value string must not exceed 64k in length after variable expansion or an
136error will occur.
137.Pp
138It is possible to escape certain characters by using any kind of quote
139or the
140.Ql \e
141character.
142By making the last character of a line a
143.Ql \e ,
144a
145.Ar value
146string can be spread across multiple lines.
147In addition the sequences
148.Ql \en ,
149.Ql \er ,
150.Ql \eb ,
151and
152.Ql \et
153are recognized.
154.Sh OPENSSL LIBRARY CONFIGURATION
155Applications can automatically configure certain aspects of OpenSSL
156using the master OpenSSL configuration file, or optionally an
157alternative configuration file.
158The
159.Xr openssl 1
160utility includes this functionality: any sub command uses the master
161OpenSSL configuration file unless an option is used in the sub command
162to use an alternative configuration file.
163.Pp
164To enable library configuration, the default section needs to contain
165an appropriate line which points to the main configuration section.
166The default name is
167.Ic openssl_conf ,
168which is used by the
169.Xr openssl 1
170utility.
171Other applications may use an alternative name such as
172.Sy myapplication_conf .
173All library configuration lines appear in the default section
174at the start of the configuration file.
175.Pp
176The configuration section should consist of a set of name value pairs
177which contain specific module configuration information.
178The
179.Ar name
180represents the name of the configuration module.
181The meaning of the
182.Ar value
183is module specific: it may, for example, represent a further
184configuration section containing configuration module specific
185information.
186For example:
187.Bd -literal -offset indent
188# The following line must be in the default section.
189openssl_conf = openssl_init
190
191[openssl_init]
192oid_section = new_oids
193
194[new_oids]
195\&... new oids here ...
196.Ed
197.Pp
198The features of each configuration module are described below.
199.Ss ASN1 Object Configuration Module
200This module has the name
201.Ic oid_section .
202The value of this variable points to a section containing name value
203pairs of OIDs: the name is the OID short and long name, and the value is the
204numerical form of the OID.
205Although some of the
206.Xr openssl 1
207utility subcommands already have their own ASN1 OBJECT section
208functionality, not all do.
209By using the ASN1 OBJECT configuration module, all the
210.Xr openssl 1
211utility subcommands can see the new objects as well as any compliant
212applications.
213For example:
214.Bd -literal -offset indent
215[new_oids]
216some_new_oid = 1.2.3.4
217some_other_oid = 1.2.3.5
218.Ed
219.Pp
220It is also possible to set the value to the long name followed by a
221comma and the numerical OID form.
222For example:
223.Pp
224.Dl shortName = some object long name, 1.2.3.4
225.Sh FILES
226.Bl -tag -width /etc/ssl/openssl.cnf -compact
227.It Pa /etc/ssl/openssl.cnf
228standard configuration file
229.El
230.Sh EXAMPLES
231Here is a sample configuration file using some of the features
232mentioned above:
233.Bd -literal -offset indent
234# This is the default section.
235HOME=/temp
236RANDFILE= ${ENV::HOME}/.rnd
237configdir=$ENV::HOME/config
238
239[ section_one ]
240# We are now in section one.
241
242# Quotes permit leading and trailing whitespace
243any = " any variable name "
244
245other = A string that can \e
246cover several lines \e
247by including \e\e characters
248
249message = Hello World\en
250
251[ section_two ]
252greeting = $section_one::message
253.Ed
254.Pp
255This next example shows how to expand environment variables safely.
256.Pp
257Suppose you want a variable called
258.Sy tmpfile
259to refer to a temporary filename.
260The directory it is placed in can determined by the
261.Ev TEMP
262or
263.Ev TMP
264environment variables but they may not be set to any value at all.
265If you just include the environment variable names and the variable
266doesn't exist then this will cause an error when an attempt is made to
267load the configuration file.
268By making use of the default section both values can be looked up with
269.Ev TEMP
270taking priority and
271.Pa /tmp
272used if neither is defined:
273.Bd -literal -offset indent
274TMP=/tmp
275# The above value is used if TMP isn't in the environment
276TEMP=$ENV::TMP
277# The above value is used if TEMP isn't in the environment
278tmpfile=${ENV::TEMP}/tmp.filename
279.Ed
280.Pp
281More complex OpenSSL library configuration.
282Add OID:
283.Bd -literal -offset indent
284# Default appname: should match "appname" parameter (if any)
285# supplied to CONF_modules_load_file et al.
286openssl_conf = openssl_conf_section
287
288[openssl_conf_section]
289# Configuration module list
290oid_section = new_oids
291
292[new_oids]
293# New OID, just short name
294newoid1 = 1.2.3.4.1
295# New OID shortname and long name
296newoid2 = New OID 2 long name, 1.2.3.4.2
297.Ed
298.Pp
299The above examples can be used with any application supporting library
300configuration if "openssl_conf" is modified to match the appropriate
301"appname".
302.Pp
303For example if the second sample file above is saved to "example.cnf"
304then the command line:
305.Pp
306.Dl OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
307.Pp
308will output:
309.Dl 0:d=0 hl=2 l= 4 prim: OBJECT :newoid1
310.Pp
311showing that the OID "newoid1" has been added as "1.2.3.4.1".
312.Sh SEE ALSO
313.Xr openssl 1 ,
314.Xr CONF_modules_load_file 3 ,
315.Xr OPENSSL_config 3 ,
316.Xr x509v3.cnf 5
317.Sh CAVEATS
318If a configuration file attempts to expand a variable that doesn't
319exist, then an error is flagged and the file will not load.
320This can also happen if an attempt is made to expand an environment
321variable that doesn't exist.
322For example, in a previous version of OpenSSL the default OpenSSL
323master configuration file used the value of
324.Ev HOME
325which may not be defined on non Unix systems and would cause an error.
326.Pp
327This can be worked around by including a default section to provide
328a default value: then if the environment lookup fails, the default
329value will be used instead.
330For this to work properly, the default value must be defined earlier
331in the configuration file than the expansion.
332See the
333.Sx EXAMPLES
334section for an example of how to do this.
335.Pp
336If the same variable is defined more than once in the same section,
337then all but the last value will be silently ignored.
338In certain circumstances such as with DNs, the same field may occur
339multiple times.
340This is usually worked around by ignoring any characters before an
341initial
342.Ql \&. ,
343for example:
344.Bd -literal -offset indent
3451.OU="My first OU"
3462.OU="My Second OU"
347.Ed
348.Sh BUGS
349Currently there is no way to include characters using the octal
350.Pf \e Ar nnn
351form.
352Strings are all NUL terminated, so NUL bytes cannot form part of
353the value.
354.Pp
355The escaping isn't quite right: if you want to use sequences like
356.Ql \en ,
357you can't use any quote escaping on the same line.
358.Pp
359Files are loaded in a single pass.
360This means that a variable expansion will only work if the variables
361referenced are defined earlier in the file.
diff --git a/src/lib/libcrypto/man/s2i_ASN1_INTEGER.3 b/src/lib/libcrypto/man/s2i_ASN1_INTEGER.3
deleted file mode 100644
index a2105bc4bc..0000000000
--- a/src/lib/libcrypto/man/s2i_ASN1_INTEGER.3
+++ /dev/null
@@ -1,215 +0,0 @@
1.\" $OpenBSD: s2i_ASN1_INTEGER.3,v 1.9 2024/12/27 15:30:17 schwarze Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 27 2024 $
18.Dt S2I_ASN1_INTEGER 3
19.Os
20.Sh NAME
21.Nm i2s_ASN1_ENUMERATED ,
22.Nm i2s_ASN1_ENUMERATED_TABLE ,
23.Nm i2s_ASN1_INTEGER ,
24.Nm s2i_ASN1_INTEGER ,
25.Nm i2s_ASN1_OCTET_STRING ,
26.Nm s2i_ASN1_OCTET_STRING
27.Nd ASN.1 data type conversion utilities for certificate extensions
28.Sh SYNOPSIS
29.In openssl/asn1.h
30.In openssl/x509v3.h
31.Ft "char *"
32.Fo i2s_ASN1_ENUMERATED
33.Fa "X509V3_EXT_METHOD *method"
34.Fa "const ASN1_ENUMERATED *a"
35.Fc
36.Ft "char *"
37.Fo i2s_ASN1_INTEGER
38.Fa "X509V3_EXT_METHOD *method"
39.Fa "const ASN1_INTEGER *a"
40.Fc
41.Ft "ASN1_INTEGER *"
42.Fo s2i_ASN1_INTEGER
43.Fa "X509V3_EXT_METHOD *method"
44.Fa "const char *value"
45.Fc
46.Ft "char *"
47.Fo i2s_ASN1_OCTET_STRING
48.Fa "X509V3_EXT_METHOD *method"
49.Fa "const ASN1_OCTET_STRING *aos"
50.Fc
51.Ft "ASN1_OCTET_STRING *"
52.Fo s2i_ASN1_OCTET_STRING
53.Fa "X509V3_EXT_METHOD *method"
54.Fa "X509V3_CTX *ctx"
55.Fa "const char *value"
56.Fc
57.Ft "char *"
58.Fo i2s_ASN1_ENUMERATED_TABLE
59.Fa "X509V3_EXT_METHOD *method"
60.Fa "const ASN1_ENUMERATED *a"
61.Fc
62.Sh DESCRIPTION
63These functions convert to and from
64.Vt ASN1_ENUMERATED ,
65.Vt ASN1_INTEGER ,
66and
67.Vt ASN1_OCTET_STRING
68objects.
69They are primarily used internally for parsing configuration files and
70displaying X.509v3 certificate extensions.
71With the exception of
72.Fn i2s_ASN1_ENUMERATED_TABLE ,
73these functions ignore the
74.Fa method
75argument.
76Any object or string returned by these functions must be freed by the caller.
77.Pp
78.Fn i2s_ASN1_ENUMERATED
79and
80.Fn i2s_ASN1_INTEGER
81first convert
82.Fa a
83into a
84.Vt BIGNUM
85object with
86.Xr ASN1_ENUMERATED_to_BN 3
87or
88.Xr ASN1_INTEGER_to_BN 3
89and then derive a string representation using
90.Xr BN_bn2dec 3
91or
92.Xr BN_bn2hex 3 .
93Decimal representation is used if the number has less than 128 bits,
94otherwise hexadecimal representation is used to avoid excessive conversion cost.
95.Pp
96.Fn s2i_ASN1_INTEGER
97converts the NUL-terminated decimal or hexadecimal string representation of
98an integer in
99.Fa value
100into an
101.Vt ASN1_INTEGER
102object.
103A sign prefix of
104.Sq -
105indicates a negative number and the base prefixes
106.Sq 0x
107and
108.Sq 0X
109indicate hexadecimal representation,
110otherwise decimal representation is assumed.
111After skipping the sign and base prefixes, an intermediate conversion into a
112.Vt BIGNUM
113is performed using
114.Xr BN_dec2bn 3
115or
116.Xr BN_hex2bn 3
117and the
118.Vt ASN1_INTEGER
119is then obtained with
120.Xr BN_to_ASN1_INTEGER 3 .
121.Pp
122.Fn i2s_ASN1_OCTET_STRING
123converts the octets in
124.Fa aos
125into a string where the octets are colon-separated and
126represented as pairs of uppercase hexadecimal digits.
127.Pp
128.Fn s2i_ASN1_OCTET_STRING
129converts the NUL-terminated string
130.Fa str
131into an
132.Vt ASN1_OCTET_STRING .
133The
134.Fa method
135and
136.Fa ctx
137arguments are ignored.
138Every pair of hexadecimal digits is converted into an octet.
139Colons are ignored if they are at the start, the end or
140if they separate two pairs of digits.
141.Pp
142.Fn i2s_ASN1_ENUMERATED_TABLE
143looks up the value of
144.Fa a
145in the
146.Fa usr_data
147field of the
148.Pf non- Dv NULL
149.Fa method
150and returns a copy of the associated long name.
151If no match is found,
152.Fa a
153is passed to
154.Fn i2s_ASN1_ENUMERATED .
155The
156.Fa method
157argument can be provided by application programs or it can be a
158default method obtained from
159.Xr X509V3_EXT_get_nid 3 .
160The default
161.Fa methods
162corresponding to the following
163.Fa nid
164arguments have strings configured in their usr_data field:
165.Pp
166.Bl -column NID_netscape_cert_type "Netscape certificate type (obsolete)" -compact
167.It Dv NID_crl_reason Ta reason codes, RFC 5280, 5.3.1
168.It Dv NID_key_usage Ta key usage, RFC 5280, 4.2.1.3
169.It Dv NID_netscape_cert_type Ta Netscape certificate type (obsolete)
170.El
171.Sh RETURN VALUES
172.Fn i2s_ASN1_ENUMERATED ,
173.Fn i2s_ASN1_ENUMERATED_TABLE ,
174.Fn i2s_ASN1_INTEGER ,
175and
176.Fn i2s_ASN1_OCTET_STRING
177return a NUL-terminated string, or NULL on memory allocation failure.
178.Pp
179.Fn s2i_ASN1_INTEGER
180returns an
181.Vt ASN1_INTEGER ,
182or NULL on error.
183Error conditions are memory allocation failure or if
184.Fa value
185is not a valid decimal or hexadecimal encoding of an integer.
186.Pp
187.Fn s2i_ASN1_OCTET_STRING
188returns an
189.Vt ASN1_OCTET_STRING ,
190or NULL on error.
191Error conditions are memory allocation failure or if
192.Fa value
193contains an odd number of hexadecimal digits or anything except
194colons at the start, the end or between pairs of hexadecimal digits.
195.Pp
196Error codes can sometimes be obtained by
197.Xr ERR_get_error 3 .
198.Sh SEE ALSO
199.Xr a2i_ASN1_INTEGER 3 ,
200.Xr a2i_ipadd 3 ,
201.Xr ASN1_INTEGER_new 3 ,
202.Xr ASN1_INTEGER_to_BN 3 ,
203.Xr ASN1_OCTET_STRING_new 3 ,
204.Xr crypto 3 ,
205.Xr v2i_ASN1_BIT_STRING 3 ,
206.Xr X509V3_get_d2i 3
207.Sh HISTORY
208These functions first appeared in OpenSSL 0.9.4 and
209have been available since
210.Ox 2.6 .
211.Sh BUGS
212Of these functions at least
213.Fn i2s_ASN1_ENUMERATED_TABLE
214can succeed while setting an error and fail without setting an error
215on the error stack.
diff --git a/src/lib/libcrypto/man/v2i_ASN1_BIT_STRING.3 b/src/lib/libcrypto/man/v2i_ASN1_BIT_STRING.3
deleted file mode 100644
index 36d9f7496b..0000000000
--- a/src/lib/libcrypto/man/v2i_ASN1_BIT_STRING.3
+++ /dev/null
@@ -1,125 +0,0 @@
1.\" $OpenBSD: v2i_ASN1_BIT_STRING.3,v 1.1 2024/12/24 09:48:56 schwarze Exp $
2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 24 2024 $
18.Dt V2I_ASN1_BIT_STRING 3
19.Os
20.Sh NAME
21.Nm v2i_ASN1_BIT_STRING ,
22.Nm i2v_ASN1_BIT_STRING
23.Nd ASN.1 BIT STRING utility functions for certificate extensions
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft ASN1_BIT_STRING *
27.Fo v2i_ASN1_BIT_STRING
28.Fa "X509V3_EXT_METHOD *method"
29.Fa "X509V3_CTX *ctx"
30.Fa "STACK_OF(CONF_VALUE) *nval"
31.Fc
32.Ft STACK_OF(CONF_VALUE) *
33.Fo i2v_ASN1_BIT_STRING
34.Fa "X509V3_EXT_METHOD *method"
35.Fa "ASN1_BIT_STRING *bit_string"
36.Fa "STACK_OF(CONF_VALUE) *nval"
37.Fc
38.Sh DESCRIPTION
39.Fn v2i_ASN1_BIT_STRING
40allocates a new ASN.1
41.Vt BIT STRING
42object and initializes it from a list of bit names.
43The
44.Fa nval
45argument is essentially used as the list of the names of the bits to set.
46Both long names and short names can be used.
47One name is taken from each element of
48.Fa nval .
49The
50.Fa ctx
51argument and any section names or values contained in the elements of
52.Fa nval
53are ignored.
54To convert a C string containing a comma-separated list of names
55to the input format of this function,
56.Xr X509V3_parse_list 3
57can be used.
58.Pp
59.Fn i2v_ASN1_BIT_STRING
60translates the numbers of the bits that are set in the
61.Fa bit_string
62to long names.
63For each bit that is set,
64one element containing the corresponding long name is added to
65.Fa nval .
66If a
67.Dv NULL
68pointer is passed for the
69.Fa nval
70argument, a new
71.Vt STACK_OF(CONF_VALUE)
72is allocated.
73.Pp
74For both functions, the
75.Fa method
76argument is only used for the translation of bit names to bit numbers
77and vice versa.
78Any names and bit numbers that do not occur in the
79.Fa usr_data
80translation table in the
81.Fa method
82are silently ignored.
83.Pp
84For the following arguments,
85.Xr X509V3_EXT_get_nid 3
86returns static constant
87.Fa method
88objects supporting these functions:
89.Pp
90.Bl -tag -width NID_netscape_cert_type -compact
91.It Dv NID_crl_reason
92reason codes, RFC 5280 section 5.3.1
93.It Dv NID_key_usage
94key usage purposes, RFC 5280 section 4.2.1.3
95.It Dv NID_netscape_cert_type
96Netscape certificate types (obsolete)
97.El
98.Pp
99While an application program could theoretically provide its own
100.Fa method
101object containing a custom translation table, that is unlikely to be
102useful for any practical purpose.
103.Sh RETURN VALUES
104.Fn v2i_ASN1_BIT_STRING
105returns the new
106.Vt BIT STRING
107object and
108.Fn i2v_ASN1_BIT_STRING
109the modified or new list of bit names.
110Both functions return
111.Dv NULL
112if an error occurs, in particular if memory allocation fails.
113.Sh SEE ALSO
114.Xr ASN1_BIT_STRING_new 3 ,
115.Xr ASN1_BIT_STRING_set 3 ,
116.Xr i2s_ASN1_ENUMERATED_TABLE 3 ,
117.Xr STACK_OF 3 ,
118.Xr tls_peer_ocsp_crl_reason 3 ,
119.Xr X509_get_key_usage 3 ,
120.Xr X509V3_EXT_get_nid 3 ,
121.Xr X509V3_get_d2i 3 ,
122.Xr X509V3_parse_list 3
123.Sh HISTORY
124These functions first appeared in OpenSSL 0.9.8 and have been available since
125.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/x509_verify.3 b/src/lib/libcrypto/man/x509_verify.3
deleted file mode 100644
index b9fe13a54f..0000000000
--- a/src/lib/libcrypto/man/x509_verify.3
+++ /dev/null
@@ -1,221 +0,0 @@
1.\" $OpenBSD: x509_verify.3,v 1.2 2020/09/14 14:21:46 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Bob Beck <beck@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 14 2020 $
18.Dt X509_VERIFY 3
19.Os
20.Sh NAME
21.Nm x509_verify ,
22.Nm x509_verify_ctx_new ,
23.Nm x509_verify_ctx_free ,
24.Nm x509_verify_ctx_set_max_depth ,
25.Nm x509_verify_ctx_set_max_signatures ,
26.Nm x509_verify_ctx_set_max_chains ,
27.Nm x509_verify_ctx_set_purpose ,
28.Nm x509_verify_ctx_set_intermediates ,
29.Nm x509_verify_ctx_error_string ,
30.Nm x509_verify_ctx_error_depth ,
31.Nm x509_verify_ctx_chain
32.Nd discover and verify X.509 certificate chains
33.Sh SYNOPSIS
34.In openssl/x509_verify.h
35.Ft size_t
36.Fo x509_verify
37.Fa "X509_VERIFY_CTX *ctx"
38.Fa "X509 *leaf"
39.Fa "char *name"
40.Fc
41.Ft X509_VERIFY_CTX *
42.Fo x509_verify_ctx_new
43.Fa "STACK_OF(X509) *roots"
44.Fc
45.Ft void
46.Fo x509_verify_ctx_free
47.Fa "X509_VERIFY_CTX *ctx"
48.Fc
49.Ft int
50.Fo x509_verify_ctx_set_max_depth
51.Fa "X509_VERIFY_CTX *ctx"
52.Fa "size_t max"
53.Fc
54.Ft int
55.Fo x509_verify_ctx_set_max_signatures
56.Fa "X509_VERIFY_CTX *ctx"
57.Fa "size_t max"
58.Fc
59.Ft int
60.Fo x509_verify_ctx_set_max_chains
61.Fa "X509_VERIFY_CTX *ctx"
62.Fa "size_t max"
63.Fc
64.Ft int
65.Fo x509_verify_ctx_set_purpose
66.Fa "X509_VERIFY_CTX *ctx"
67.Fa "int purpose_id"
68.Fc
69.Ft int
70.Fo x509_verify_ctx_set_intermediates
71.Fa "X509_VERIFY_CTX *ctx"
72.Fa "STACK_OF(X509) *intermediates"
73.Fc
74.Ft const char *
75.Fo x509_verify_ctx_error_string
76.Fa "X509_VERIFY_CTX *ctx"
77.Fc
78.Ft size_t
79.Fo x509_verify_ctx_error_depth
80.Fa "X509_VERIFY_CTX *ctx"
81.Fc
82.Ft STACK_OF(X509) *
83.Fo x509_verify_ctx_chain
84.Fa "X509_VERIFY_CTX *ctx"
85.Fa "size_t index"
86.Fc
87.Sh DESCRIPTION
88The
89.Fn x509_verify
90function attempts to discover and validate all certificate chains
91for the
92.Fa name
93from the
94.Fa leaf
95certificate based on the parameters in
96.Fa ctx .
97Multiple chains may be built and validated.
98Revocation checking is not done by this function, and should be
99performed by the caller on any returned chains if so desired.
100.Pp
101.Fn x509_verify_ctx_new
102allocates a new context using the trusted
103.Fa roots .
104In case of success, it increments the reference count of
105.Fa roots .
106.Pp
107.Fn x509_verify_ctx_free
108frees
109.Fa ctx
110and decrements the reference count of the
111.Fa roots
112and
113.Fa intermediates
114associated with it.
115If
116.Fa ctx
117is
118.Dv NULL ,
119no action occurs.
120.Pp
121.Fn x509_verify_ctx_set_max_depth
122sets the maximum depth of certificate chains that will be constructed to
123.Fa max ,
124which can be in the range from 1 to the default of 32.
125.Pp
126.Fn x509_verify_ctx_set_max_signatures
127sets the maximum number of public key signature operations that will be
128used when verifying certificate chains to
129.Fa max ,
130which can be in the range from 1 to 100000.
131The default is 256.
132.Pp
133.Fn x509_verify_ctx_set_max_chains
134sets the maximum number of chains which may be returned to
135.Fa max ,
136which can be in the range from 1 to the default of 8.
137.Pp
138.Fn x509_verify_ctx_set_purpose
139sets the certificate purpose for validation to
140.Fa purpose_id .
141The
142.Dv X509_PURPOSE_*
143constants listed in
144.Xr X509_check_purpose 3
145can be used.
146.Pp
147.Fn x509_verify_ctx_set_intermediates
148provides some intermediate certificates, typically received from
149the peer, to be used for building chains.
150In case of success, this function increases the reference count of
151.Fa intermediates .
152.Pp
153.Fn x509_verify_ctx_error_string
154extracts a description of the last error encountered by a previous
155call to
156.Fn x509_verify
157from
158.Fa ctx .
159.Pp
160.Fn x509_verify_ctx_error_depth
161extracts the depth of the last error encountered by a previous
162call to
163.Fn x509_verify
164from
165.Fa ctx .
166.Pp
167.Fn x509_verify_ctx_chain
168extracts the validated chain with the given
169.Fa index
170from
171.Fa ctx
172after a previous call to
173.Fn x509_verify .
174The
175.Fa index
176starts at 0, and it is an error to pass a number
177greater than or equal to the return value of
178.Fn x509_verify .
179The returned chain is neither copied,
180nor is its reference count increased.
181.Sh RETURN VALUES
182.Fn x509_verify
183returns the number of chains successfully built and validated
184or 0 on failure.
185.Pp
186.Fn x509_verify_ctx_new
187returns a newly allocated context or
188.Dv NULL
189on failure.
190.Pp
191.Fn x509_verify_ctx_set_max_depth ,
192.Fn x509_verify_ctx_set_max_signatures ,
193.Fn x509_verify_ctx_set_max_chains ,
194.Fn x509_verify_ctx_set_purpose ,
195and
196.Fn x509_verify_ctx_set_intermediates
197return 1 on success or 0 on failure.
198.Pp
199.Fn x509_verify_ctx_error_string
200returns a pointer to a human readable error string.
201If no error occurred,
202.Qq ok
203is returned.
204.Pp
205.Fn x509_verify_ctx_chain
206returns an internal pointer to a validated chain or
207.Dv NULL
208if
209.Fa index
210is greater than or equal to the number of chains
211that were successfully built and validated.
212The returned pointer becomes invalid when
213.Fa ctx
214is destroyed.
215.Sh SEE ALSO
216.Xr X509_verify_cert 3
217.Sh HISTORY
218These functions first appeared in
219.Ox 6.8 .
220.Sh AUTHORS
221.An Bob Beck Aq Mt beck@openbsd.org
diff --git a/src/lib/libcrypto/man/x509v3.cnf.5 b/src/lib/libcrypto/man/x509v3.cnf.5
deleted file mode 100644
index 89f52d6a01..0000000000
--- a/src/lib/libcrypto/man/x509v3.cnf.5
+++ /dev/null
@@ -1,738 +0,0 @@
1.\" $OpenBSD: x509v3.cnf.5,v 1.8 2022/03/31 17:27:17 naddy Exp $
2.\" full merge up to:
3.\" OpenSSL man5/x509v3_config a41815f0 Mar 17 18:43:53 2017 -0700
4.\" selective merge up to: OpenSSL 36cf10cf Oct 4 02:11:08 2017 -0400
5.\"
6.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
7.\" Copyright (c) 2004, 2006, 2013, 2014, 2015, 2016 The OpenSSL Project.
8.\" All rights reserved.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\"
14.\" 1. Redistributions of source code must retain the above copyright
15.\" notice, this list of conditions and the following disclaimer.
16.\"
17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\" notice, this list of conditions and the following disclaimer in
19.\" the documentation and/or other materials provided with the
20.\" distribution.
21.\"
22.\" 3. All advertising materials mentioning features or use of this
23.\" software must display the following acknowledgment:
24.\" "This product includes software developed by the OpenSSL Project
25.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
26.\"
27.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
28.\" endorse or promote products derived from this software without
29.\" prior written permission. For written permission, please contact
30.\" openssl-core@openssl.org.
31.\"
32.\" 5. Products derived from this software may not be called "OpenSSL"
33.\" nor may "OpenSSL" appear in their names without prior written
34.\" permission of the OpenSSL Project.
35.\"
36.\" 6. Redistributions of any form whatsoever must retain the following
37.\" acknowledgment:
38.\" "This product includes software developed by the OpenSSL Project
39.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
40.\"
41.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
42.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
45.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\"
54.Dd $Mdocdate: March 31 2022 $
55.Dt X509V3.CNF 5
56.Os
57.Sh NAME
58.Nm x509v3.cnf
59.Nd X.509 V3 certificate extension configuration format
60.Sh DESCRIPTION
61Several of the OpenSSL utilities can add extensions to a certificate or
62certificate request based on the contents of a configuration file.
63The file format is based on the
64.Xr openssl.cnf 5
65format.
66.Pp
67Typically the application will contain an option to point to an
68extension section.
69Each line of the extension section takes the form:
70.Pp
71.D1 Ar extension_name Ns = Ns Oo Cm critical , Oc Ar extension_options
72.Pp
73If
74.Cm critical
75is present, then the extension will be critical.
76.Pp
77The format of
78.Ar extension_options
79depends on the value of
80.Ar extension_name .
81.Pp
82There are four main types of extension: string extensions, multi-valued
83extensions, raw extensions, and arbitrary extensions.
84.Pp
85String extensions simply have a string which contains either the value
86itself or how it is obtained.
87For example:
88.Pp
89.Dl nsComment="This is a Comment"
90.Pp
91Multi-valued extensions have a short form and a long form.
92The short form is a list of names and values:
93.Pp
94.Dl basicConstraints=critical,CA:true,pathlen:1
95.Pp
96The long form allows the values to be placed in a separate section:
97.Bd -literal -offset indent
98basicConstraints=critical,@bs_section
99
100[bs_section]
101CA=true
102pathlen=1
103.Ed
104.Pp
105Both forms are equivalent.
106.Pp
107The syntax of raw extensions is governed by the extension code:
108it can for example contain data in multiple sections.
109The correct syntax to use is defined by the extension code itself:
110check out the certificate policies extension for an example.
111.Pp
112If an extension type is unsupported, then the arbitrary extension
113syntax must be used; see the
114.Sx ARBITRARY EXTENSIONS
115section for more details.
116.Sh STANDARD EXTENSIONS
117The following sections describe each supported extension in detail.
118.Ss Basic constraints
119This is a multi-valued extension which indicates whether a certificate
120is a CA certificate.
121The first (mandatory) name is
122.Ic CA
123followed by
124.Cm TRUE
125or
126.Cm FALSE .
127If
128.Ic CA
129is
130.Cm TRUE ,
131then an optional
132.Ic pathlen
133name followed by a non-negative value can be included.
134For example:
135.Bd -literal -offset indent
136basicConstraints=CA:TRUE
137basicConstraints=CA:FALSE
138basicConstraints=critical,CA:TRUE, pathlen:0
139.Ed
140.Pp
141A CA certificate must include the
142.Ic basicConstraints
143value with the
144.Ic CA
145field set to
146.Cm TRUE .
147An end user certificate must either set
148.Ic CA
149to
150.Cm FALSE
151or exclude the extension entirely.
152Some software may require the inclusion of
153.Ic basicConstraints
154with
155.Ic CA
156set to
157.Cm FALSE
158for end entity certificates.
159.Pp
160The
161.Ic pathlen
162parameter indicates the maximum number of CAs that can appear below
163this one in a chain.
164So if you have a CA with a
165.Ic pathlen
166of zero, it can only be used to sign end user certificates and not
167further CAs.
168.Ss Key usage
169Key usage is a multi-valued extension consisting of a list of names of
170the permitted key usages.
171.Pp
172The supported names are:
173.Ic digitalSignature ,
174.Ic nonRepudiation ,
175.Ic keyEncipherment ,
176.Ic dataEncipherment ,
177.Ic keyAgreement ,
178.Ic keyCertSign ,
179.Ic cRLSign ,
180.Ic encipherOnly ,
181and
182.Ic decipherOnly .
183Examples:
184.Bd -literal -offset indent
185keyUsage=digitalSignature, nonRepudiation
186keyUsage=critical, keyCertSign
187.Ed
188.Ss Extended key usage
189This extension consists of a list of purposes for
190which the certificate public key can be used.
191.Pp
192These can either be object short names or the dotted numerical form of OIDs.
193While any OID can be used, only certain values make sense.
194In particular the following PKIX, NS and MS values are meaningful:
195.Bl -column emailProtection
196.It Em value Ta Em meaning
197.It Ic serverAuth Ta TLS server authentication
198.It Ic clientAuth Ta TLS client authentication
199.It Ic codeSigning Ta code signing
200.It Ic emailProtection Ta E-mail protection (S/MIME)
201.It Ic timeStamping Ta trusted timestamping
202.It Ic OCSPSigning Ta OCSP signing
203.It Ic ipsecIKE Ta IPsec internet key exchange
204.It Ic msCodeInd Ta Microsoft individual code signing (authenticode)
205.It Ic msCodeCom Ta Microsoft commercial code signing (authenticode)
206.It Ic msCTLSign Ta Microsoft trust list signing
207.It Ic msEFS Ta Microsoft encrypted file system
208.El
209.Pp
210Examples:
211.Bd -literal -offset indent
212extendedKeyUsage=critical,codeSigning,1.2.3.4
213extendedKeyUsage=serverAuth,clientAuth
214.Ed
215.Ss Subject key identifier
216This is really a string extension and can take two possible values.
217Either the word
218.Cm hash
219which will automatically follow the guidelines in RFC 3280
220or a hex string giving the extension value to include.
221The use of the hex string is strongly discouraged.
222Example:
223.Pp
224.Dl subjectKeyIdentifier=hash
225.Ss Authority key identifier
226The authority key identifier extension permits two options,
227.Cm keyid
228and
229.Cm issuer :
230both can take the optional value
231.Cm always .
232.Pp
233If the
234.Cm keyid
235option is present, an attempt is made to copy the subject
236key identifier from the parent certificate.
237If the value
238.Cm always
239is present, then an error is returned if the option fails.
240.Pp
241The
242.Cm issuer
243option copies the issuer and serial number from the issuer certificate.
244This will only be done if the
245.Cm keyid
246option fails or is not included unless the
247.Cm always
248flag will always include the value.
249Example:
250.Pp
251.Dl authorityKeyIdentifier=keyid,issuer
252.Ss Subject alternative name
253The subject alternative name extension allows various literal values to
254be included in the configuration file.
255These include
256.Ic email
257(an email address),
258.Ic URI
259(a uniform resource indicator),
260.Ic DNS
261(a DNS domain name),
262.Ic RID
263(a registered ID: OBJECT IDENTIFIER),
264.Ic IP
265(an IP address),
266.Ic dirName
267(a distinguished name), and
268.Ic otherName .
269.Pp
270The
271.Ic email
272option can include a special
273.Cm copy
274value.
275This will automatically include any email addresses contained in the
276certificate subject name in the extension.
277.Pp
278The IP address used in the
279.Ic IP
280options can be in either IPv4 or IPv6 format.
281.Pp
282The value of
283.Ic dirName
284should point to a section containing the distinguished name to use as a
285set of name value pairs.
286Multi values AVAs can be formed by prefacing the name with a
287.Ql +
288character.
289.Pp
290.Ic otherName
291can include arbitrary data associated with an OID: the value should
292be the OID followed by a semicolon and the content in standard
293.Xr ASN1_generate_nconf 3
294format.
295Examples:
296.Bd -literal -offset 2n
297subjectAltName=email:copy,email:my@other.address,URI:http://my.url.here/
298subjectAltName=IP:192.168.7.1
299subjectAltName=IP:13::17
300subjectAltName=email:my@other.address,RID:1.2.3.4
301subjectAltName=otherName:1.2.3.4;UTF8:some other identifier
302
303subjectAltName=dirName:dir_sect
304
305[dir_sect]
306C=UK
307O=My Organization
308OU=My Unit
309CN=My Name
310.Ed
311.Ss Issuer alternative name
312The issuer alternative name option supports all the literal options of
313subject alternative name.
314It does not support the
315.Ic email : Ns Cm copy
316option because that would not make sense.
317It does support an additional
318.Ic issuer : Ns Cm copy
319option that will copy all the subject alternative name values from
320the issuer certificate (if possible).
321Example:
322.Pp
323.Dl issuerAltName = issuer:copy
324.Ss Authority info access
325The authority information access extension gives details about how to
326access certain information relating to the CA.
327Its syntax is
328.Ar accessOID ; location
329where
330.Ar location
331has the same syntax as subject alternative name (except that
332.Ic email : Ns Cm copy
333is not supported).
334.Ar accessOID
335can be any valid OID but only certain values are meaningful,
336for example
337.Cm OCSP
338and
339.Cm caIssuers .
340Example:
341.Bd -literal -offset indent
342authorityInfoAccess = OCSP;URI:http://ocsp.my.host/
343authorityInfoAccess = caIssuers;URI:http://my.ca/ca.html
344.Ed
345.Ss CRL distribution points
346This is a multi-valued extension whose options can be either in
347.Ar name : Ns Ar value
348pair form using the same form as subject alternative name or a
349single value representing a section name containing all the
350distribution point fields.
351.Pp
352For a
353.Ar name : Ns Ar value
354pair a new DistributionPoint with the fullName field set to the
355given value, both the cRLissuer and reasons fields are omitted in
356this case.
357.Pp
358In the single option case, the section indicated contains values
359for each field.
360In this section:
361.Pp
362If the name is
363.Ic fullname ,
364the value field should contain the full name of the distribution
365point in the same format as subject alternative name.
366.Pp
367If the name is
368.Ic relativename ,
369then the value field should contain a section name whose contents
370represent a DN fragment to be placed in this field.
371.Pp
372The name
373.Ic CRLIssuer ,
374if present, should contain a value for this field in subject
375alternative name format.
376.Pp
377If the name is
378.Ic reasons ,
379the value field should consist of a comma separated field containing
380the reasons.
381Valid reasons are:
382.Cm keyCompromise ,
383.Cm CACompromise ,
384.Cm affiliationChanged ,
385.Cm superseded ,
386.Cm cessationOfOperation ,
387.Cm certificateHold ,
388.Cm privilegeWithdrawn ,
389and
390.Cm AACompromise .
391.Pp
392Simple examples:
393.Bd -literal -offset indent
394crlDistributionPoints=URI:http://myhost.com/myca.crl
395crlDistributionPoints=URI:http://my.com/my.crl,URI:http://oth.com/my.crl
396.Ed
397.Pp
398Full distribution point example:
399.Bd -literal -offset indent
400crlDistributionPoints=crldp1_section
401
402[crldp1_section]
403fullname=URI:http://myhost.com/myca.crl
404CRLissuer=dirName:issuer_sect
405reasons=keyCompromise, CACompromise
406
407[issuer_sect]
408C=UK
409O=Organisation
410CN=Some Name
411.Ed
412.Ss Issuing distribution point
413This extension should only appear in CRLs.
414It is a multi-valued extension whose syntax is similar to the "section"
415pointed to by the CRL distribution points extension with a few
416differences.
417.Pp
418The names
419.Ic reasons
420and
421.Ic CRLissuer
422are not recognized.
423.Pp
424The name
425.Ic onlysomereasons
426is accepted, which sets this field.
427The value is in the same format as the CRL distribution point
428.Ic reasons
429field.
430.Pp
431The names
432.Ic onlyuser ,
433.Ic onlyCA ,
434.Ic onlyAA ,
435and
436.Ic indirectCRL
437are also accepted.
438The values should be a boolean values
439.Cm ( TRUE
440or
441.Cm FALSE )
442to indicate the value of the corresponding field.
443Example:
444.Bd -literal -offset indent
445issuingDistributionPoint=critical, @idp_section
446
447[idp_section]
448fullname=URI:http://myhost.com/myca.crl
449indirectCRL=TRUE
450onlysomereasons=keyCompromise, CACompromise
451
452[issuer_sect]
453C=UK
454O=Organisation
455CN=Some Name
456.Ed
457.Ss Certificate policies
458This is a raw extension.
459All the fields of this extension can be set by using the appropriate
460syntax.
461.Pp
462If you follow the PKIX recommendations and just use one OID, then you
463just include the value of that OID.
464Multiple OIDs can be set separated by commas, for example:
465.Pp
466.Dl certificatePolicies= 1.2.4.5, 1.1.3.4
467.Pp
468If you wish to include qualifiers, then the policy OID and qualifiers
469need to be specified in a separate section: this is done by using the
470.Pf @ Ar section
471syntax instead of a literal OID value.
472.Pp
473The section referred to must include the policy OID using the name
474.Ic policyIdentifier .
475.Ic CPSuri
476qualifiers can be included using the syntax:
477.Pp
478.D1 Ic CPS . Ns Ar nnn Ns = Ns Ar value
479.Pp
480.Ic userNotice
481qualifiers can be set using the syntax:
482.Pp
483.D1 Ic userNotice . Ns Ar nnn Ns =@ Ns Ar notice
484.Pp
485The value of the
486.Ic userNotice
487qualifier is specified in the relevant section.
488This section can include
489.Ic explicitText ,
490.Ic organization ,
491and
492.Ic noticeNumbers
493options.
494.Ic explicitText
495and
496.Ic organization
497are text strings,
498and
499.Ic noticeNumbers
500is a comma separated list of numbers.
501The
502.Ic organization
503and
504.Ic noticeNumbers
505options (if included) must
506.Em both
507be present.
508If you use the
509.Ic userNotice
510option with IE5 then you need the
511.Ic ia5org
512option at the top level to modify the encoding: otherwise it will
513not be interpreted properly.
514Example:
515.Bd -literal -offset indent
516certificatePolicies=ia5org,1.2.3.4,1.5.6.7.8,@polsect
517
518[polsect]
519policyIdentifier = 1.3.5.8
520CPS.1="http://my.host.name/"
521CPS.2="http://my.your.name/"
522userNotice.1=@notice
523
524[notice]
525explicitText="Explicit Text Here"
526organization="Organisation Name"
527noticeNumbers=1,2,3,4
528.Ed
529.Pp
530The
531.Ic ia5org
532option changes the type of the
533.Ic organization
534field.
535In RFC 2459, it can only be of type
536.Vt DisplayText .
537In RFC 3280,
538.Vt IA5String
539is also permissible.
540Some software (for example some versions of MSIE) may require
541.Ic ia5org .
542.Ss Policy constraints
543This is a multi-valued extension which consists of the names
544.Ic requireExplicitPolicy
545or
546.Ic inhibitPolicyMapping
547and a non-negative integer value.
548At least one component must be present.
549Example:
550.Pp
551.Dl policyConstraints = requireExplicitPolicy:3
552.Ss Inhibit any policy
553This is a string extension whose value must be a non-negative integer.
554Example:
555.Pp
556.Dl inhibitAnyPolicy = 2
557.Ss Name constraints
558The name constraints extension is a multi-valued extension.
559The name should begin with the word
560.Cm permitted
561or
562.Cm excluded ,
563followed by a semicolon.
564The rest of the name and the value follows the syntax of subjectAltName
565except
566.Ic email : Ns Cm copy
567is not supported and the
568.Ic IP
569form should consist of an IP addresses and subnet mask separated
570by a slash.
571Examples:
572.Bd -literal -offset indent
573nameConstraints=permitted;IP:192.168.0.0/255.255.0.0
574nameConstraints=permitted;email:.somedomain.com
575nameConstraints=excluded;email:.com
576.Ed
577.Ss OCSP no check
578The OCSP no check extension is a string extension,
579but its value is ignored.
580Example:
581.Pp
582.Dl noCheck = ignored
583.Ss TLS Feature (aka must staple)
584This is a multi-valued extension consisting of a list of TLS extension
585identifiers.
586Each identifier may be a number in the range from 0 to 65535 or a
587supported name.
588When a TLS client sends a listed extension, the TLS server is expected
589to include that extension in its reply.
590.Pp
591The supported names are:
592.Cm status_request
593and
594.Cm status_request_v2 .
595Example:
596.Pp
597.Dl tlsfeature = status_request
598.Sh DEPRECATED EXTENSIONS
599The following extensions are non-standard, Netscape specific and largely
600obsolete.
601Their use in new applications is discouraged.
602.Ss Netscape string extensions
603Netscape comment
604.Ic ( nsComment )
605is a string extension containing a comment which will be displayed when
606the certificate is viewed in some browsers.
607Example:
608.Pp
609.Dl nsComment = "Some Random Comment"
610.Pp
611Other supported extensions in this category are:
612.Ic nsBaseUrl ,
613.Ic nsRevocationUrl ,
614.Ic nsCaRevocationUrl ,
615.Ic nsRenewalUrl ,
616.Ic nsCaPolicyUrl ,
617and
618.Ic nsSslServerName .
619.Ss Netscape certificate type
620This is a multi-valued extensions which consists of a list of flags to
621be included.
622It was used to indicate the purposes for which a certificate could be
623used.
624The
625.Ic basicConstraints ,
626.Ic keyUsage ,
627and extended key usage extensions are now used instead.
628.Pp
629Acceptable values for
630.Ic nsCertType
631are:
632.Cm client ,
633.Cm server ,
634.Cm email ,
635.Cm objsign ,
636.Cm reserved ,
637.Cm sslCA ,
638.Cm emailCA ,
639.Cm objCA .
640.Sh ARBITRARY EXTENSIONS
641If an extension is not supported by the OpenSSL code, then it must
642be encoded using the arbitrary extension format.
643It is also possible to use the arbitrary format for supported
644extensions.
645Extreme care should be taken to ensure that the data is formatted
646correctly for the given extension type.
647.Pp
648There are two ways to encode arbitrary extensions.
649.Pp
650The first way is to use the word
651.Cm ASN1
652followed by the extension content using the same syntax as
653.Xr ASN1_generate_nconf 3 .
654For example:
655.Bd -literal -offset indent
6561.2.3.4=critical,ASN1:UTF8String:Some random data
6571.2.3.4=ASN1:SEQUENCE:seq_sect
658
659[seq_sect]
660field1 = UTF8:field1
661field2 = UTF8:field2
662.Ed
663.Pp
664It is also possible to use the word
665.Cm DER
666to include the raw encoded data in any extension.
667.Bd -literal -offset indent
6681.2.3.4=critical,DER:01:02:03:04
6691.2.3.4=DER:01020304
670.Ed
671.Pp
672The value following
673.Cm DER
674is a hex dump of the DER encoding of the extension.
675Any extension can be placed in this form to override the default behaviour.
676For example:
677.Pp
678.Dl basicConstraints=critical,DER:00:01:02:03
679.Sh FILES
680.Bl -tag -width /etc/ssl/x509v3.cnf -compact
681.It Pa /etc/ssl/x509v3.cnf
682standard configuration file
683.El
684.Sh SEE ALSO
685.Xr openssl 1 ,
686.Xr ASN1_generate_nconf 3 ,
687.Xr OPENSSL_config 3 ,
688.Xr openssl.cnf 5
689.Sh HISTORY
690X509v3 extension code was first added to OpenSSL 0.9.2.
691.Sh CAVEATS
692There is no guarantee that a specific implementation will process a
693given extension.
694It may therefore sometimes be possible to use certificates for purposes
695prohibited by their extensions because a specific application does not
696recognize or honour the values of the relevant extensions.
697.Pp
698The
699.Cm DER
700and
701.Cm ASN1
702options should be used with caution.
703It is possible to create totally invalid extensions if they are not used
704carefully.
705.Pp
706If an extension is multi-value and a field value must contain a comma,
707the long form must be used.
708Otherwise the comma would be misinterpreted as a field separator.
709For example,
710.Pp
711.Dl subjectAltName=URI:ldap://somehost.com/CN=foo,OU=bar
712.Pp
713will produce an error, but the following form is valid:
714.Bd -literal -offset indent
715subjectAltName=@subject_alt_section
716
717[subject_alt_section]
718subjectAltName=URI:ldap://somehost.com/CN=foo,OU=bar
719.Ed
720.Pp
721Due to the behaviour of the OpenSSL CONF library, the same field
722name can only occur once in a section.
723That means that
724.Bd -literal -offset indent
725subjectAltName=@alt_section
726
727[alt_section]
728email=steve@here
729email=steve@there
730.Ed
731.Pp
732will only use the last value.
733This can be worked around by using the form:
734.Bd -literal -offset indent
735[alt_section]
736email.1=steve@here
737email.2=steve@there
738.Ed