5 RSA_check_key - validate private RSA keys
9 #include <openssl/rsa.h>
11 int RSA_check_key(RSA *rsa);
15 This function validates RSA keys. It checks that B<p> and B<q> are
16 in fact prime, and that B<n = p*q>.
18 It also checks that B<d*e = 1 mod (p-1*q-1)>,
19 and that B<dmp1>, B<dmq1> and B<iqmp> are set correctly or are B<NULL>.
21 The key's public components may not be B<NULL>.
25 RSA_check_key() returns 1 if B<rsa> is a valid RSA key, and 0 otherwise.
26 -1 is returned if an error occurs while checking the key.
28 If the key is invalid or an error occurred, the reason code can be
29 obtained using L<ERR_get_error(3)|ERR_get_error(3)>.
33 RSA_check_key() can only check soft keys. If given hard keys, i.e. keys
34 that were retreived from an ENGINE (with ENGINE_load_private_key()),
35 RSA_check_key() will always return 0, as if the key was invalid. The
36 reason is that the private components B<p>, B<q> and B<d> are normally
37 not available to OpenSSL for hard keys, and the checks can therefore not
42 L<rsa(3)|rsa(3)>, L<err(3)|err(3)>
46 RSA_check_key() appeared in OpenSSL 0.9.4.