| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "RSA_CHECK_KEY 3SSL" |
| 58 |
.TH RSA_CHECK_KEY 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
RSA_check_key_ex, RSA_check_key \- validate private RSA keys |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
.Vb 1 |
| 68 |
\& #include <openssl/rsa.h> |
| 69 |
.Ve |
| 70 |
.PP |
| 71 |
The following functions have been deprecated since OpenSSL 3.0, and can be |
| 72 |
hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value, |
| 73 |
see \fBopenssl_user_macros\fR\|(7): |
| 74 |
.PP |
| 75 |
.Vb 1 |
| 76 |
\& int RSA_check_key_ex(const RSA *rsa, BN_GENCB *cb); |
| 77 |
\& |
| 78 |
\& int RSA_check_key(const RSA *rsa); |
| 79 |
.Ve |
| 80 |
.SH DESCRIPTION |
| 81 |
.IX Header "DESCRIPTION" |
| 82 |
Both of the functions described on this page are deprecated. |
| 83 |
Applications should instead use \fBEVP_PKEY_public_check\fR\|(3), |
| 84 |
\&\fBEVP_PKEY_private_check\fR\|(3) and \fBEVP_PKEY_pairwise_check\fR\|(3). |
| 85 |
.PP |
| 86 |
\&\fBRSA_check_key_ex()\fR function validates RSA keys. |
| 87 |
It checks that \fBp\fR and \fBq\fR are |
| 88 |
in fact prime, and that \fBn = p*q\fR. |
| 89 |
.PP |
| 90 |
It does not work on RSA public keys that have only the modulus |
| 91 |
and public exponent elements populated. |
| 92 |
It also checks that \fBd*e = 1 mod (p\-1*q\-1)\fR, |
| 93 |
and that \fBdmp1\fR, \fBdmq1\fR and \fBiqmp\fR are set correctly or are \fBNULL\fR. |
| 94 |
It performs integrity checks on all |
| 95 |
the RSA key material, so the RSA key structure must contain all the private |
| 96 |
key data too. |
| 97 |
Therefore, it cannot be used with any arbitrary RSA key object, |
| 98 |
even if it is otherwise fit for regular RSA operation. |
| 99 |
.PP |
| 100 |
The \fBcb\fR parameter is a callback that will be invoked in the same |
| 101 |
manner as \fBBN_is_prime_ex\fR\|(3). |
| 102 |
.PP |
| 103 |
\&\fBRSA_check_key()\fR is equivalent to \fBRSA_check_key_ex()\fR with a NULL \fBcb\fR. |
| 104 |
.SH "RETURN VALUES" |
| 105 |
.IX Header "RETURN VALUES" |
| 106 |
\&\fBRSA_check_key_ex()\fR and \fBRSA_check_key()\fR |
| 107 |
return 1 if \fBrsa\fR is a valid RSA key, and 0 otherwise. |
| 108 |
They return \-1 if an error occurs while checking the key. |
| 109 |
.PP |
| 110 |
If the key is invalid or an error occurred, the reason code can be |
| 111 |
obtained using \fBERR_get_error\fR\|(3). |
| 112 |
.SH NOTES |
| 113 |
.IX Header "NOTES" |
| 114 |
Unlike most other RSA functions, this function does \fBnot\fR work |
| 115 |
transparently with any underlying ENGINE implementation because it uses the |
| 116 |
key data in the RSA structure directly. An ENGINE implementation can |
| 117 |
override the way key data is stored and handled, and can even provide |
| 118 |
support for HSM keys \- in which case the RSA structure may contain \fBno\fR |
| 119 |
key data at all! If the ENGINE in question is only being used for |
| 120 |
acceleration or analysis purposes, then in all likelihood the RSA key data |
| 121 |
is complete and untouched, but this can't be assumed in the general case. |
| 122 |
.SH BUGS |
| 123 |
.IX Header "BUGS" |
| 124 |
A method of verifying the RSA key using opaque RSA API functions might need |
| 125 |
to be considered. Right now \fBRSA_check_key()\fR simply uses the RSA structure |
| 126 |
elements directly, bypassing the RSA_METHOD table altogether (and |
| 127 |
completely violating encapsulation and object-orientation in the process). |
| 128 |
The best fix will probably be to introduce a "\fBcheck_key()\fR" handler to the |
| 129 |
RSA_METHOD function table so that alternative implementations can also |
| 130 |
provide their own verifiers. |
| 131 |
.SH "SEE ALSO" |
| 132 |
.IX Header "SEE ALSO" |
| 133 |
\&\fBBN_is_prime_ex\fR\|(3), |
| 134 |
\&\fBERR_get_error\fR\|(3) |
| 135 |
.SH HISTORY |
| 136 |
.IX Header "HISTORY" |
| 137 |
All of these functions were deprecated in OpenSSL 3.0. |
| 138 |
.PP |
| 139 |
\&\fBRSA_check_key_ex()\fR appeared after OpenSSL 1.0.2. |
| 140 |
.SH COPYRIGHT |
| 141 |
.IX Header "COPYRIGHT" |
| 142 |
Copyright 2000\-2020 The OpenSSL Project Authors. All Rights Reserved. |
| 143 |
.PP |
| 144 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 145 |
this file except in compliance with the License. You can obtain a copy |
| 146 |
in the file LICENSE in the source distribution or at |
| 147 |
<https://www.openssl.org/source/license.html>. |