1RSA_check_key(3) OpenSSL RSA_check_key(3)
2
3
4
6 RSA_check_key - validate private RSA keys
7
9 #include <openssl/rsa.h>
10
11 int RSA_check_key(RSA *rsa);
12
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
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
32 This function does not work on RSA public keys that have only the
33 modulus and public exponent elements populated. It performs integrity
34 checks on all the RSA key material, so the RSA key structure must
35 contain all the private key data too.
36
37 Unlike most other RSA functions, this function does not work
38 transparently with any underlying ENGINE implementation because it uses
39 the key data in the RSA structure directly. An ENGINE implementation
40 can override the way key data is stored and handled, and can even
41 provide support for HSM keys - in which case the RSA structure may
42 contain no key data at all! If the ENGINE in question is only being
43 used for acceleration or analysis purposes, then in all likelihood the
44 RSA key data is complete and untouched, but this can't be assumed in
45 the general case.
46
48 A method of verifying the RSA key using opaque RSA API functions might
49 need to be considered. Right now RSA_check_key() simply uses the RSA
50 structure elements directly, bypassing the RSA_METHOD table altogether
51 (and completely violating encapsulation and object-orientation in the
52 process). The best fix will probably be to introduce a "check_key()"
53 handler to the RSA_METHOD function table so that alternative
54 implementations can also provide their own verifiers.
55
57 rsa(3), ERR_get_error(3)
58
60 RSA_check_key() appeared in OpenSSL 0.9.4.
61
62
63
641.0.2o 2018-03-27 RSA_check_key(3)