RSA_CHECK_KEY(3)
π NAME π
okay bestie, welcome to the libcrypto Library Functions Manual page for RSA_check_key(3). Its whole entire job? validate private RSA keys. that's it, that's the vibe β¨
π SYNOPSIS π
library βlibcryptoβ #include <openssl/rsa.h>
int
RSA_check_key(RSA *rsa);
π¦ DESCRIPTION π¦
so RSA_check_key() is literally the vibe check for an RSA key β it validates RSA keys, no cap π
here's what it's actually checking, bestie:
- it checks that
rsa->pandrsa->qare in fact prime, and thatrsa->nsatisfiesn = p*q. - it also checks that
rsa->dandrsa->esatisfyd*e = 1 mod ((p-1)*(q-1)). - and it checks that
rsa->dmp1,rsa->dmq1, andresa->iqmpare set correctly or areNULL. yes, that's literallyresa->iqmpin the original β keeping it exact, bestie π
huge caveat incoming π¨: this function does not work on RSA public keys that have only the modulus and public exponent elements populated. It performs integrity checks on all the RSA key material, so the RSA key structure must contain all the private key data too. Therefore, it cannot be used with any arbitrary RSA key object, even if it is otherwise fit for regular RSA operation. π
πΈ RETURN VALUES πΈ
RSA_check_key()returns1ifrsais a valid RSA key, and0otherwise.-1is returned if an error occurs while checking the key.- If the key is invalid or an error occurred, the reason code can be obtained using
ERR_get_error(3). π«Ά
π SEE ALSO π
π HISTORY π
RSA_check_key() first appeared in OpenSSL 0.9.4 and has been available since OpenBSD 2.6. iconic behavior, honestly β
π BUGS π
okay so there's some design discourse here, and ngl it's giving "we know, we know":
- A method of verifying the RSA key using opaque RSA API functions might need to be considered.
- Right now
RSA_check_key()simply uses the RSA structure elements directly, bypassing theRSA_METHODtable altogether (and completely violating encapsulation and object-orientation in the process). not me calling out the whole architecture π - The best fix will probably be to introduce a
check_key()handler to theRSA_METHODfunction table so that alternative implementations can also provide their own verifiers. slay, future-proofing, we love to see it π
xoxo, this page is from the Debian source, dated June 8, 2025, and it's RSA_CHECK_KEY(3) β mwah π
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2000, 2002 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms