D2I_RSAPUBLICKEY(3)
β¨ NAME β¨
okay bestie, welcome to the D2I_RSAPUBLICKEY(3) page β this is the whole RSA encode/decode squad, and yes, they all showed up:
d2i_RSAPublicKey,i2d_RSAPublicKeyd2i_RSAPrivateKey,i2d_RSAPrivateKeyd2i_Netscape_RSA,i2d_Netscape_RSAd2i_RSA_PSS_PARAMS,i2d_RSA_PSS_PARAMSd2i_RSAPublicKey_bio,d2i_RSAPublicKey_fp,i2d_RSAPublicKey_bio,i2d_RSAPublicKey_fpd2i_RSAPrivateKey_bio,d2i_RSAPrivateKey_fp,i2d_RSAPrivateKey_bio,i2d_RSAPrivateKey_fpd2i_RSA_PUBKEY,i2d_RSA_PUBKEYd2i_RSA_PUBKEY_bio,d2i_RSA_PUBKEY_fp,i2d_RSA_PUBKEY_bio,i2d_RSA_PUBKEY_fp
and their whole thing is: decode and encode RSA keys and parameters. periodt. π
πΈ SYNOPSIS πΈ
okay, here's the whole cast in code form, exactly as it appears in the header files and function signatures:
#include <openssl/rsa.h>
RSA *
d2i_RSAPublicKey(RSA **val_out, const unsigned char **der_in,
long length);
int
i2d_RSAPublicKey(RSA *val_in, unsigned char **der_out);
RSA *
d2i_RSAPrivateKey(RSA **val_out, const unsigned char **der_in,
long length);
int
i2d_RSAPrivateKey(RSA *val_in, unsigned char **der_out);
RSA *
d2i_Netscape_RSA(RSA **val_out, const unsigned char **der_in,
long length, int (*cb)());
int
i2d_Netscape_RSA(RSA *val_in, unsigned char **der_out, int (*cb)());
RSA_PSS_PARAMS *
d2i_RSA_PSS_PARAMS(RSA_PSS_PARAMS **val_out,
const unsigned char **der_in, long length);
int
i2d_RSA_PSS_PARAMS(RSA_PSS_PARAMS *val_in, unsigned char **der_out);
#include <openssl/x509.h>
RSA *
d2i_RSAPublicKey_bio(BIO *in_bio, RSA **val_out);
RSA *
d2i_RSAPublicKey_fp(FILE *in_fp, RSA **val_out);
int
i2d_RSAPublicKey_bio(BIO *out_bio, RSA *val_in);
int
i2d_RSAPublicKey_fp(FILE *out_fp, RSA *val_in);
RSA *
d2i_RSAPrivateKey_bio(BIO *in_bio, RSA **val_out);
RSA *
d2i_RSAPrivateKey_fp(FILE *in_fp, RSA **val_out);
int
i2d_RSAPrivateKey_bio(BIO *out_bio, RSA *val_in);
int
i2d_RSAPrivateKey_fp(FILE *out_fp, RSA *val_in);
RSA *
d2i_RSA_PUBKEY(RSA **val_out, const unsigned char **der_in,
long length);
int
i2d_RSA_PUBKEY(RSA *val_in, unsigned char **der_out);
RSA *
d2i_RSA_PUBKEY_bio(BIO *in_bio, RSA **val_out);
RSA *
d2i_RSA_PUBKEY_fp(FILE *in_fp, RSA **val_out);
int
i2d_RSA_PUBKEY_bio(BIO *out_bio, RSA *val_in);
int
i2d_RSA_PUBKEY_fp(FILE *out_fp, RSA *val_in);
π¦ DESCRIPTION π¦
These functions decode and encode RSA private and public keys. For all the deep-lore details about the semantics, examples, caveats, and bugs, go read ASN1_item_d2i(3). that's the parent page, iykyk. π
d2i_RSAPublicKey() and i2d_RSAPublicKey() decode and encode a PKCS#1 RSAPublicKey structure defined in RFC 8017 appendix A.1.1. The _bio and _fp girlies β d2i_RSAPublicKey_bio(), d2i_RSAPublicKey_fp(), i2d_RSAPublicKey_bio(), and i2d_RSAPublicKey_fp() β are similar except that they decode or encode using a BIO or FILE pointer. slay. π
d2i_RSAPrivateKey() and i2d_RSAPrivateKey() decode and encode a PKCS#1 RSAPrivateKey structure defined in RFC 8017 appendix A.1.2. The RSA structure passed to the private key encoding functions should have all the PKCS#1 private key components present. Big important caution: the data encoded by the private key functions is unencrypted and therefore offers no private key security β like, that's not a cute vibe, bestie, that's a warning. π d2i_RSAPrivateKey_bio(), d2i_RSAPrivateKey_fp(), i2d_RSAPrivateKey_bio(), and i2d_RSAPrivateKey_fp() are similar except that they decode or encode using a BIO or FILE pointer.
d2i_Netscape_RSA() and i2d_Netscape_RSA() decode and encode an RSA private key in NET format. These functions are present to provide compatibility with certain very old software. The NET format has some severe security weaknesses and should be avoided if possible. fr fr, avoid if you can. π
d2i_RSA_PSS_PARAMS() and i2d_RSA_PSS_PARAMS() decode and encode a PKCS#1 RSASSA-PSS-params structure defined in RFC 8017 appendix A.2.3 and documented in RSA_PSS_PARAMS_new(3).
d2i_RSA_PUBKEY() and i2d_RSA_PUBKEY() decode and encode an RSA public key using an ASN.1 SubjectPublicKeyInfo structure defined in RFC 5280 section 4.1 and documented in X509_PUBKEY_new(3). d2i_RSA_PUBKEY_bio(), d2i_RSA_PUBKEY_fp(), i2d_RSA_PUBKEY_bio(), and i2d_RSA_PUBKEY_fp() are similar except that they decode or encode using a BIO or FILE pointer. π
π«Ά RETURN VALUES π«Ά
okay, return-value tea β:
d2i_RSAPublicKey(),d2i_RSAPublicKey_bio(),d2i_RSAPublicKey_fp(),d2i_RSAPrivateKey(),d2i_RSAPrivateKey_bio(),d2i_RSAPrivateKey_fp(),d2i_Netscape_RSA(),d2i_RSA_PUBKEY(),d2i_RSA_PUBKEY_bio(), andd2i_RSA_PUBKEY_fp()return a validRSAobject orNULLif an error occurs.d2i_RSA_PSS_PARAMS()returns a validRSA_PSS_PARAMSobject orNULLif an error occurs.i2d_RSAPublicKey(),i2d_RSAPrivateKey(),i2d_Netscape_RSA(),i2d_RSA_PSS_PARAMS(), andi2d_RSA_PUBKEY()return the number of bytes successfully encoded or a negative value if an error occurs.i2d_RSAPublicKey_bio(),i2d_RSAPublicKey_fp(),i2d_RSAPrivateKey_bio(),i2d_RSAPrivateKey_fp(),i2d_RSA_PUBKEY_bio(), andi2d_RSA_PUBKEY_fp()return1for success or0if an error occurs.
π SEE ALSO π
go peek at these icons:
ASN1_item_d2i(3)EVP_PKEY_set1_RSA(3)PEM_write_RSAPrivateKey(3)RSA_new(3)RSA_PSS_PARAMS_new(3)X509_PUBKEY_new(3)
π STANDARDS π
- RFC 8017: PKCS #1: RSA Cryptography Specifications
- RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile, section 4.1: Basic Certificate Fields
π§ HISTORY π§
storytime, bestie:
d2i_RSAPublicKey(),i2d_RSAPublicKey(),d2i_RSAPrivateKey(),i2d_RSAPrivateKey(),d2i_RSAPrivateKey_fp(),i2d_RSAPrivateKey_fp(),d2i_Netscape_RSA(), andi2d_Netscape_RSA()first appeared in SSLeay 0.5.1.d2i_RSAPrivateKey_bio()andi2d_RSAPrivateKey_bio()first appeared in SSLeay 0.6.0.d2i_RSAPublicKey_bio(),d2i_RSAPublicKey_fp(),i2d_RSAPublicKey_bio(), andi2d_RSAPublicKey_fp()first appeared in SSLeay 0.8.1.- These functions have been available since OpenBSD 2.4.
d2i_RSA_PUBKEY(),i2d_RSA_PUBKEY(),d2i_RSA_PUBKEY_bio(),d2i_RSA_PUBKEY_fp(),i2d_RSA_PUBKEY_bio(), andi2d_RSA_PUBKEY_fp()first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7.d2i_RSA_PSS_PARAMS()andi2d_RSA_PSS_PARAMS()first appeared in OpenSSL 1.0.1 and have been available since OpenBSD 5.3.
π this cute little manual moment was brought to you by Debian, dated March 27, 2018 β and yeah, it was the D2I_RSAPUBLICKEY(3) page all along. mwah! π
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· OpenSSL
- Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2000, 2002, 2003, 2009, 2016 The OpenSSL Project
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms