xref: /freebsd/crypto/openssl/doc/man3/X509_check_private_key.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimX509_check_private_key, X509_REQ_check_private_key - check the consistency
6e71b7053SJung-uk Kimof a private key with the public key in an X509 certificate or certificate
7e71b7053SJung-uk Kimrequest
8e71b7053SJung-uk Kim
9e71b7053SJung-uk Kim=head1 SYNOPSIS
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim #include <openssl/x509.h>
12e71b7053SJung-uk Kim
13e71b7053SJung-uk Kim int X509_check_private_key(X509 *x, EVP_PKEY *k);
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k);
16e71b7053SJung-uk Kim
17e71b7053SJung-uk Kim=head1 DESCRIPTION
18e71b7053SJung-uk Kim
19e71b7053SJung-uk KimX509_check_private_key() function checks the consistency of private
20e71b7053SJung-uk Kimkey B<k> with the public key in B<x>.
21e71b7053SJung-uk Kim
22e71b7053SJung-uk KimX509_REQ_check_private_key() is equivalent to X509_check_private_key()
23e71b7053SJung-uk Kimexcept that B<x> represents a certificate request of structure B<X509_REQ>.
24e71b7053SJung-uk Kim
25e71b7053SJung-uk Kim=head1 RETURN VALUES
26e71b7053SJung-uk Kim
27e71b7053SJung-uk KimX509_check_private_key() and X509_REQ_check_private_key() return 1 if
28e71b7053SJung-uk Kimthe keys match each other, and 0 if not.
29e71b7053SJung-uk Kim
30e71b7053SJung-uk KimIf the key is invalid or an error occurred, the reason code can be
31e71b7053SJung-uk Kimobtained using L<ERR_get_error(3)>.
32e71b7053SJung-uk Kim
33e71b7053SJung-uk Kim=head1 BUGS
34e71b7053SJung-uk Kim
35e71b7053SJung-uk KimThe B<check_private_key> functions don't check if B<k> itself is indeed
36e71b7053SJung-uk Kima private key or not. It merely compares the public materials (e.g. exponent
37e71b7053SJung-uk Kimand modulus of an RSA key) and/or key parameters (e.g. EC params of an EC key)
38e71b7053SJung-uk Kimof a key pair. So if you pass a public key to these functions in B<k>, it will
39e71b7053SJung-uk Kimreturn success.
40e71b7053SJung-uk Kim
41e71b7053SJung-uk Kim=head1 SEE ALSO
42e71b7053SJung-uk Kim
43e71b7053SJung-uk KimL<ERR_get_error(3)>
44e71b7053SJung-uk Kim
45e71b7053SJung-uk Kim=head1 COPYRIGHT
46e71b7053SJung-uk Kim
47e71b7053SJung-uk KimCopyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
48e71b7053SJung-uk Kim
49*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
50e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
51e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
52e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
53e71b7053SJung-uk Kim
54e71b7053SJung-uk Kim=cut
55