1RSA_check_key(3)                    OpenSSL                   RSA_check_key(3)
2
3
4

NAME

6       RSA_check_key - validate private RSA keys
7

SYNOPSIS

9        #include <openssl/rsa.h>
10
11        int RSA_check_key(RSA *rsa);
12

DESCRIPTION

14       This function validates RSA keys. It checks that p and q are in fact
15       prime, and that n = p*q.
16
17       It also checks that d*e = 1 mod (p-1*q-1), and that dmp1, dmq1 and iqmp
18       are set correctly or are NULL.
19
20       As such, this function can not be used with any arbitrary RSA key
21       object, even if it is otherwise fit for regular RSA operation. See
22       NOTES for more information.
23

RETURN VALUE

25       RSA_check_key() returns 1 if rsa is a valid RSA key, and 0 otherwise.
26       -1 is returned if an error occurs while checking the key.
27
28       If the key is invalid or an error occurred, the reason code can be
29       obtained using ERR_get_error(3).
30

NOTES

32       This function does not work on RSA public keys that have only the modu‐
33       lus and public exponent elements populated. It performs integrity
34       checks on all the RSA key material, so the RSA key structure must con‐
35       tain all the private key data too.
36
37       Unlike most other RSA functions, this function does not work transpar‐
38       ently with any underlying ENGINE implementation because it uses the key
39       data in the RSA structure directly. An ENGINE implementation can over‐
40       ride the way key data is stored and handled, and can even provide sup‐
41       port for HSM keys - in which case the RSA structure may contain no key
42       data at all! If the ENGINE in question is only being used for accelera‐
43       tion or analysis purposes, then in all likelihood the RSA key data is
44       complete and untouched, but this can't be assumed in the general case.
45

BUGS

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

SEE ALSO

56       rsa(3), ERR_get_error(3)
57

HISTORY

59       RSA_check_key() appeared in OpenSSL 0.9.4.
60
61
62
630.9.8b                            2002-09-25                  RSA_check_key(3)
Impressum