X509_CHECK_PRIVATE_KEY(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’– NAME πŸ’–

okay bestie, this is the X509_CHECK_PRIVATE_KEY(3) library functions manual page, and it's about two functions: X509_check_private_key and X509_REQ_check_private_key. Their whole thing is comparing public key components. That's the assignment. That's the vibe. πŸ’…


✨ SYNOPSIS ✨

library β€œlibcrypto” #include <openssl/x509.h>

int
X509_check_private_key(const X509 *x, const EVP_PKEY *k);

int
X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k);

πŸ¦‹ DESCRIPTION πŸ¦‹

Real talk: these functions are seriously misnamed. Not me making it up β€” that's literally what the page says. X509_check_private_key() compares the public key components (e.g. exponent and modulus of an RSA key) and parameters (e.g. EC params of an EC key) of k with the corresponding properties of x. 🧚

And here's the plot twist: despite the name, it neither checks whether k contains private key components at all, nor, if any are present, whether they are consistent with the public key components. The name is lowkey giving catfish. πŸ™ˆ

X509_REQ_check_private_key() is equivalent to X509_check_private_key() β€” except that it compares to the public key contained in a certificate request. Same energy, different object. πŸŽ€


πŸ”₯ RETURN VALUES πŸ”₯

These functions return 1 if the public key components and parameters match, or 0 if they do not match or if an error occurs. So yeah: 1 = we love to see it, 0 = something's off (or it errored). πŸ’€

On error or mismatch, a reason code can be obtained using ERR_get_error(3). Go get that context, bestie. πŸ”


🌈 SEE ALSO 🌈


πŸ‘‘ HISTORY πŸ‘‘

X509_check_private_key() first appeared in SSLeay 0.6.5 and has been available since OpenBSD 2.4. An icon, honestly. ✨

X509_REQ_check_private_key() first appeared in OpenSSL 0.9.8 and has been available since OpenBSD 4.5. We love a late arrival with main character energy. 🫢


This page is from Debian, dated June 8, 2025, and its manual name is X509_CHECK_PRIVATE_KEY(3). Byeee β€” go compare those public key components responsibly! πŸ’–πŸŽ€

πŸ“¦ where this page comes from