1 .\" $OpenBSD: RSA_check_key.3,v 1.4 2016/12/11 12:21:48 schwarze Exp $
2 .\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000
4 .\" This file was written by Ulf Moeller <ulf@openssl.org> and
5 .\" Geoff Thorpe <geoff@openssl.org>.
6 .\" Copyright (c) 2000, 2002 The OpenSSL Project. All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: December 11 2016 $
57 .Nd validate private RSA keys
65 This function validates RSA keys.
70 are in fact prime, and that
78 satisfy d*e = 1 mod ((p-1)*(q-1)),
84 are set correctly or are
87 This function does not work on RSA public keys that have only the
88 modulus and public exponent elements populated.
89 It performs integrity checks on all the RSA key material, so the
91 key structure must contain all the private key data too.
92 Therefore, it cannot be used with any arbitrary
94 key object, even if it is otherwise fit for regular RSA operation.
96 Unlike most other RSA functions, this function does
98 work transparently with any underlying
100 implementation because it uses the key data in the
105 implementation can override the way key data is stored and handled,
106 and can even provide support for HSM keys - in which case the
108 structure may contain
113 in question is only being used for acceleration or analysis purposes,
114 then in all likelihood the RSA key data is complete and untouched,
115 but this can't be assumed in the general case.
120 is a valid RSA key, and 0 otherwise.
121 -1 is returned if an error occurs while checking the key.
123 If the key is invalid or an error occurred, the reason code can be
125 .Xr ERR_get_error 3 .
127 .Xr BN_is_prime_ex 3 ,
128 .Xr ERR_get_error 3 ,
132 appeared in OpenSSL 0.9.4.
134 A method of verifying the RSA key using opaque RSA API functions might
135 need to be considered.
140 structure elements directly, bypassing the
142 table altogether (and completely violating encapsulation and
143 object-orientation in the process).
144 The best fix will probably be to introduce a check_key() handler
147 function table so that alternative implementations can also provide