Blame doc/man3/RSA_check_key.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
RSA_check_key_ex, RSA_check_key - validate private RSA keys
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/rsa.h>
Packit c4476c
Packit c4476c
 int RSA_check_key_ex(RSA *rsa, BN_GENCB *cb);
Packit c4476c
Packit c4476c
 int RSA_check_key(RSA *rsa);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
RSA_check_key_ex() function validates RSA keys.
Packit c4476c
It checks that B

and B<q> are

Packit c4476c
in fact prime, and that B<n = p*q>.
Packit c4476c
Packit c4476c
It does not work on RSA public keys that have only the modulus
Packit c4476c
and public exponent elements populated.
Packit c4476c
It also checks that B<d*e = 1 mod (p-1*q-1)>,
Packit c4476c
and that B<dmp1>, B<dmq1> and B<iqmp> are set correctly or are B<NULL>.
Packit c4476c
It performs integrity checks on all
Packit c4476c
the RSA key material, so the RSA key structure must contain all the private
Packit c4476c
key data too.
Packit c4476c
Therefore, it cannot be used with any arbitrary RSA key object,
Packit c4476c
even if it is otherwise fit for regular RSA operation.
Packit c4476c
Packit c4476c
The B<cb> parameter is a callback that will be invoked in the same
Packit c4476c
manner as L<BN_is_prime_ex(3)>.
Packit c4476c
Packit c4476c
RSA_check_key() is equivalent to RSA_check_key_ex() with a NULL B<cb>.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
RSA_check_key_ex() and RSA_check_key()
Packit c4476c
return 1 if B<rsa> is a valid RSA key, and 0 otherwise.
Packit c4476c
They return -1 if an error occurs while checking the key.
Packit c4476c
Packit c4476c
If the key is invalid or an error occurred, the reason code can be
Packit c4476c
obtained using L<ERR_get_error(3)>.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
Unlike most other RSA functions, this function does B<not> work
Packit c4476c
transparently with any underlying ENGINE implementation because it uses the
Packit c4476c
key data in the RSA structure directly. An ENGINE implementation can
Packit c4476c
override the way key data is stored and handled, and can even provide
Packit c4476c
support for HSM keys - in which case the RSA structure may contain B<no>
Packit c4476c
key data at all! If the ENGINE in question is only being used for
Packit c4476c
acceleration or analysis purposes, then in all likelihood the RSA key data
Packit c4476c
is complete and untouched, but this can't be assumed in the general case.
Packit c4476c
Packit c4476c
=head1 BUGS
Packit c4476c
Packit c4476c
A method of verifying the RSA key using opaque RSA API functions might need
Packit c4476c
to be considered. Right now RSA_check_key() simply uses the RSA structure
Packit c4476c
elements directly, bypassing the RSA_METHOD table altogether (and
Packit c4476c
completely violating encapsulation and object-orientation in the process).
Packit c4476c
The best fix will probably be to introduce a "check_key()" handler to the
Packit c4476c
RSA_METHOD function table so that alternative implementations can also
Packit c4476c
provide their own verifiers.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<BN_is_prime_ex(3)>,
Packit c4476c
L<ERR_get_error(3)>
Packit c4476c
Packit c4476c
=head1 HISTORY
Packit c4476c
Packit c4476c
RSA_check_key_ex() appeared after OpenSSL 1.0.2.
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut