]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/RSA_check_key.pod
Clarify documentation of SSL_CTX_set_verify client side behavior
[thirdparty/openssl.git] / doc / man3 / RSA_check_key.pod
CommitLineData
2186cd8e
UM
1=pod
2
3=head1 NAME
4
c952780c 5RSA_check_key_ex, RSA_check_key - validate private RSA keys
2186cd8e
UM
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
2afb29b4
RS
11 int RSA_check_key_ex(RSA *rsa, BN_GENCB *cb);
12
2186cd8e
UM
13 int RSA_check_key(RSA *rsa);
14
15=head1 DESCRIPTION
16
2afb29b4
RS
17RSA_check_key_ex() function validates RSA keys.
18It checks that B<p> and B<q> are
2186cd8e
UM
19in fact prime, and that B<n = p*q>.
20
2afb29b4
RS
21It does not work on RSA public keys that have only the modulus
22and public exponent elements populated.
6a3fff5e 23It also checks that B<d*e = 1 mod (p-1*q-1)>,
2186cd8e 24and that B<dmp1>, B<dmq1> and B<iqmp> are set correctly or are B<NULL>.
2afb29b4
RS
25It performs integrity checks on all
26the RSA key material, so the RSA key structure must contain all the private
27key data too.
28Therefore, it cannot be used with any arbitrary RSA key object,
29even if it is otherwise fit for regular RSA operation.
30
31The B<cb> parameter is a callback that will be invoked in the same
9b86974e 32manner as L<BN_is_prime_ex(3)>.
2186cd8e 33
2afb29b4 34RSA_check_key() is equivalent to RSA_check_key_ex() with a NULL B<cb>.
2186cd8e 35
1f13ad31 36=head1 RETURN VALUES
2186cd8e 37
2afb29b4
RS
38RSA_check_key_ex() and RSA_check_key()
39return 1 if B<rsa> is a valid RSA key, and 0 otherwise.
40They return -1 if an error occurs while checking the key.
2186cd8e
UM
41
42If the key is invalid or an error occurred, the reason code can be
9b86974e 43obtained using L<ERR_get_error(3)>.
2186cd8e 44
db802c60
RL
45=head1 NOTES
46
0af9a89c
GT
47Unlike most other RSA functions, this function does B<not> work
48transparently with any underlying ENGINE implementation because it uses the
49key data in the RSA structure directly. An ENGINE implementation can
50override the way key data is stored and handled, and can even provide
51support for HSM keys - in which case the RSA structure may contain B<no>
52key data at all! If the ENGINE in question is only being used for
53acceleration or analysis purposes, then in all likelihood the RSA key data
54is complete and untouched, but this can't be assumed in the general case.
55
56=head1 BUGS
57
58A method of verifying the RSA key using opaque RSA API functions might need
59to be considered. Right now RSA_check_key() simply uses the RSA structure
60elements directly, bypassing the RSA_METHOD table altogether (and
61completely violating encapsulation and object-orientation in the process).
62The best fix will probably be to introduce a "check_key()" handler to the
63RSA_METHOD function table so that alternative implementations can also
64provide their own verifiers.
db802c60 65
2186cd8e
UM
66=head1 SEE ALSO
67
9b86974e 68L<BN_is_prime_ex(3)>,
9b86974e 69L<ERR_get_error(3)>
2186cd8e
UM
70
71=head1 HISTORY
72
2afb29b4 73RSA_check_key_ex() appeared after OpenSSL 1.0.2.
2186cd8e 74
e2f92610
RS
75=head1 COPYRIGHT
76
61f805c1 77Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
e2f92610 78
4746f25a 79Licensed under the Apache License 2.0 (the "License"). You may not use
e2f92610
RS
80this file except in compliance with the License. You can obtain a copy
81in the file LICENSE in the source distribution or at
82L<https://www.openssl.org/source/license.html>.
83
84=cut