1.\" $OpenBSD: EVP_PKEY_cmp.3,v 1.12 2021/10/19 17:42:49 schwarze Exp $ 2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400 3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 4.\" 5.\" This file is a derived work. 6.\" The changes are covered by the following Copyright and license: 7.\" 8.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 9.\" 10.\" Permission to use, copy, modify, and distribute this software for any 11.\" purpose with or without fee is hereby granted, provided that the above 12.\" copyright notice and this permission notice appear in all copies. 13.\" 14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21.\" 22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>. 23.\" Copyright (c) 2006, 2013, 2014, 2016 The OpenSSL Project. 24.\" All rights reserved. 25.\" 26.\" Redistribution and use in source and binary forms, with or without 27.\" modification, are permitted provided that the following conditions 28.\" are met: 29.\" 30.\" 1. Redistributions of source code must retain the above copyright 31.\" notice, this list of conditions and the following disclaimer. 32.\" 33.\" 2. Redistributions in binary form must reproduce the above copyright 34.\" notice, this list of conditions and the following disclaimer in 35.\" the documentation and/or other materials provided with the 36.\" distribution. 37.\" 38.\" 3. All advertising materials mentioning features or use of this 39.\" software must display the following acknowledgment: 40.\" "This product includes software developed by the OpenSSL Project 41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 42.\" 43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 44.\" endorse or promote products derived from this software without 45.\" prior written permission. For written permission, please contact 46.\" openssl-core@openssl.org. 47.\" 48.\" 5. Products derived from this software may not be called "OpenSSL" 49.\" nor may "OpenSSL" appear in their names without prior written 50.\" permission of the OpenSSL Project. 51.\" 52.\" 6. Redistributions of any form whatsoever must retain the following 53.\" acknowledgment: 54.\" "This product includes software developed by the OpenSSL Project 55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 56.\" 57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 69.\" 70.Dd $Mdocdate: October 19 2021 $ 71.Dt EVP_PKEY_CMP 3 72.Os 73.Sh NAME 74.Nm EVP_PKEY_missing_parameters , 75.Nm EVP_PKEY_copy_parameters , 76.Nm EVP_PKEY_cmp_parameters , 77.Nm EVP_PKEY_cmp 78.Nd public key parameter and comparison functions 79.Sh SYNOPSIS 80.In openssl/evp.h 81.Ft int 82.Fo EVP_PKEY_missing_parameters 83.Fa "const EVP_PKEY *pkey" 84.Fc 85.Ft int 86.Fo EVP_PKEY_copy_parameters 87.Fa "EVP_PKEY *destination" 88.Fa "const EVP_PKEY *source" 89.Fc 90.Ft int 91.Fo EVP_PKEY_cmp_parameters 92.Fa "const EVP_PKEY *a" 93.Fa "const EVP_PKEY *b" 94.Fc 95.Ft int 96.Fo EVP_PKEY_cmp 97.Fa "const EVP_PKEY *a" 98.Fa "const EVP_PKEY *b" 99.Fc 100.Sh DESCRIPTION 101.Fn EVP_PKEY_missing_parameters 102checks whether any public key parameters are missing from 103.Fa pkey . 104.Pp 105.Fn EVP_PKEY_copy_parameters 106copies all public key parameters from the 107.Fa source 108to the 109.Fa destination . 110If the algorithm does not use parameters, no action occurs. 111.Pp 112.Fn EVP_PKEY_cmp_parameters 113compares the public key parameters of 114.Fa a 115and 116.Fa b . 117This is only supported for algorithms that use parameters. 118.Pp 119.Fn EVP_PKEY_cmp 120compares the public key components of 121.Fa a 122and 123.Fa b . 124If the algorithm uses public key parameters, 125it also compares the parameters. 126.Pp 127The main purpose of the functions 128.Fn EVP_PKEY_missing_parameters 129and 130.Fn EVP_PKEY_copy_parameters 131is to handle public keys in certificates where the parameters are 132sometimes omitted from a public key if they are inherited from the CA 133that signed it. 134.Pp 135Since OpenSSL private keys contain public key components too, the 136function 137.Fn EVP_PKEY_cmp 138can also be used to determine if a private key matches a public key. 139.Sh RETURN VALUES 140.Fn EVP_PKEY_missing_parameters 141returns 1 if the public key parameters of 142.Fa pkey 143are missing or incomplete or 0 if they are present and complete 144or if the algorithm doesn't use parameters. 145.Pp 146.Fn EVP_PKEY_copy_parameters 147returns 1 for success or 0 for failure. 148In particular, it fails if the key types mismatch or if the public 149key parameters in the 150.Fa source 151are missing or incomplete. 152.Pp 153.Fn EVP_PKEY_cmp_parameters 154and 155.Fn EVP_PKEY_cmp 156return 1 if the keys match, 0 if they don't match, -1 if the key types 157are different and -2 if the operation is not supported. 158.Sh SEE ALSO 159.Xr EVP_PKEY_asn1_set_public 3 , 160.Xr EVP_PKEY_CTX_new 3 , 161.Xr EVP_PKEY_keygen 3 , 162.Xr EVP_PKEY_new 3 , 163.Xr X509_get_pubkey_parameters 3 164.Sh HISTORY 165.Fn EVP_PKEY_missing_parameters 166and 167.Fn EVP_PKEY_copy_parameters 168first appeared in SSLeay 0.8.0. 169.Fn EVP_PKEY_cmp_parameters 170first appeared in SSLeay 0.9.0. 171These functions have been available since 172.Ox 2.4 . 173.Pp 174.Fn EVP_PKEY_cmp 175first appeared in OpenSSL 0.9.8 and has been available since 176.Ox 4.5 . 177