man > EVP_KEYMGMT-RSA(7ssl)

๐Ÿ“– NAME

EVP_PKEY-RSA, EVP_KEYMGMT-RSA, RSA โ€” EVP_PKEY RSA keytype and algorithm support

๐Ÿš€ Quick Reference

Use CaseCommandDescription
๐Ÿ”‘ Generate RSA key pair (simple)EVP_RSA_gen(4096)Generate a 4096-bit RSA key pair
๐Ÿ”‘ Generate RSA key pair (context)EVP_PKEY_keygen_init + EVP_PKEY_generateGenerate RSA key using EVP_PKEY_CTX
โš™๏ธ Generate RSA key with custom paramsEVP_PKEY_CTX_set_params(pctx, params)Set bits, primes, e before generation
๐Ÿ” Access RSA key componentsEVP_PKEY_get_bn_param(pkey, "n", &n)Retrieve modulus, exponent, factors, CRT params

๐Ÿ“ Description

The RSA keytype is implemented in OpenSSL's default and FIPS providers. That implementation supports the basic RSA keys, containing the modulus n, the public exponent e, the private exponent d, and a collection of prime factors, exponents and coefficient for CRT calculations, of which the first few are known as p and q, dP and dQ, and qInv.

๐Ÿ”ง Common RSA parameters

In addition to the common parameters that all keytypes should support (see provider-keymgmt(7)), the RSA keytype implementation supports the following.

โš™๏ธ RSA key generation parameters

When generating RSA keys, the following key generation parameters may be used.

๐Ÿงช RSA key generation parameters for FIPS module testing

โš ๏ธ For algorithm testing purposes only. Do not use these to generate RSA keys for a production environment.

๐Ÿงช RSA key parameters for FIPS module testing

โš ๏ธ For testing only. The following intermediate values can be retrieved only if the FIPS test values above are set. Should not be accessed in a production environment.

๐Ÿ“œ Conforming to

๐Ÿ’ก Examples

An EVP_PKEY context can be obtained by calling:

EVP_PKEY_CTX *pctx =
    EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL);

An RSA key can be generated simply like this:

pkey = EVP_RSA_gen(4096);

or like this:

EVP_PKEY *pkey = NULL;
EVP_PKEY_CTX *pctx =
    EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL);

EVP_PKEY_keygen_init(pctx);
EVP_PKEY_generate(pctx, &pkey);
EVP_PKEY_CTX_free(pctx);

An RSA key can be generated with key generation parameters:

unsigned int primes = 3;
unsigned int bits = 4096;
OSSL_PARAM params[3];
EVP_PKEY *pkey = NULL;
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL);

EVP_PKEY_keygen_init(pctx);

params[0] = OSSL_PARAM_construct_uint("bits", &bits);
params[1] = OSSL_PARAM_construct_uint("primes", &primes);
params[2] = OSSL_PARAM_construct_end();
EVP_PKEY_CTX_set_params(pctx, params);

EVP_PKEY_generate(pctx, &pkey);
EVP_PKEY_print_private(bio_out, pkey, 0, NULL);
EVP_PKEY_CTX_free(pctx);

๐Ÿ“š See also

ยฉ๏ธ Copyright

Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.

EVP_KEYMGMT-RSA(7ssl)
๐Ÿ“– NAME ๐Ÿš€ Quick Reference ๐Ÿ“ Description
๐Ÿ”ง Common RSA parameters โš™๏ธ RSA key generation parameters ๐Ÿงช RSA key generation parameters for FIPS module testing ๐Ÿงช RSA key parameters for FIPS module testing
๐Ÿ“œ Conforming to ๐Ÿ’ก Examples ๐Ÿ“š See also ยฉ๏ธ Copyright

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 20:59 @2600:1f28:365:80b0:b91e:58eb:6587:15c8
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^