1RSA_CHECK_KEY(3)                    OpenSSL                   RSA_CHECK_KEY(3)
2
3
4

NAME

6       RSA_check_key_ex, RSA_check_key - validate private RSA keys
7

SYNOPSIS

9        #include <openssl/rsa.h>
10
11        int RSA_check_key_ex(RSA *rsa, BN_GENCB *cb);
12
13        int RSA_check_key(RSA *rsa);
14

DESCRIPTION

16       RSA_check_key_ex() function validates RSA keys.  It checks that p and q
17       are in fact prime, and that n = p*q.
18
19       It does not work on RSA public keys that have only the modulus and
20       public exponent elements populated.  It also checks that d*e = 1 mod
21       (p-1*q-1), and that dmp1, dmq1 and iqmp are set correctly or are NULL.
22       It performs integrity checks on all the RSA key material, so the RSA
23       key structure must contain all the private key data too.  Therefore, it
24       cannot be used with any arbitrary RSA key object, even if it is
25       otherwise fit for regular RSA operation.
26
27       The cb parameter is a callback that will be invoked in the same manner
28       as BN_is_prime_ex(3).
29
30       RSA_check_key() is equivalent to RSA_check_key_ex() with a NULL cb.
31

RETURN VALUES

33       RSA_check_key_ex() and RSA_check_key() return 1 if rsa is a valid RSA
34       key, and 0 otherwise.  They return -1 if an error occurs while checking
35       the key.
36
37       If the key is invalid or an error occurred, the reason code can be
38       obtained using ERR_get_error(3).
39

NOTES

41       Unlike most other RSA functions, this function does not work
42       transparently with any underlying ENGINE implementation because it uses
43       the key data in the RSA structure directly. An ENGINE implementation
44       can override the way key data is stored and handled, and can even
45       provide support for HSM keys - in which case the RSA structure may
46       contain no key data at all! If the ENGINE in question is only being
47       used for acceleration or analysis purposes, then in all likelihood the
48       RSA key data is complete and untouched, but this can't be assumed in
49       the general case.
50

BUGS

52       A method of verifying the RSA key using opaque RSA API functions might
53       need to be considered. Right now RSA_check_key() simply uses the RSA
54       structure elements directly, bypassing the RSA_METHOD table altogether
55       (and completely violating encapsulation and object-orientation in the
56       process).  The best fix will probably be to introduce a "check_key()"
57       handler to the RSA_METHOD function table so that alternative
58       implementations can also provide their own verifiers.
59

SEE ALSO

61       BN_is_prime_ex(3), ERR_get_error(3)
62

HISTORY

64       RSA_check_key_ex() appeared after OpenSSL 1.0.2.
65
67       Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
68
69       Licensed under the OpenSSL license (the "License").  You may not use
70       this file except in compliance with the License.  You can obtain a copy
71       in the file LICENSE in the source distribution or at
72       <https://www.openssl.org/source/license.html>.
73
74
75
761.1.1                             2018-09-11                  RSA_CHECK_KEY(3)
Impressum