5 EVP_PKEY_is_a, EVP_PKEY_can_sign
6 - key type and capabilities functions
10 #include <openssl/evp.h>
12 int EVP_PKEY_is_a(const EVP_PKEY *pkey, const char *name);
13 int EVP_PKEY_can_sign(const EVP_PKEY *pkey);
17 EVP_PKEY_is_a() checks if the key type of I<pkey> is I<name>.
19 EVP_PKEY_can_sign() checks if the functionality for the key type of
20 I<pkey> supports signing. No other check is done, such as whether
21 I<pkey> contains a private key.
25 EVP_PKEY_is_a() returns 1 if I<pkey> has the key type I<name>,
28 EVP_PKEY_can_sign() returns 1 if the I<pkey> key type functionality
29 supports signing, otherwise 0.
33 =head2 EVP_PKEY_is_a()
35 The loaded providers and what key types they support will ultimately
36 determine what I<name> is possible to use with EVP_PKEY_is_a(). We do know
37 that the default provider supports RSA, DH, DSA and EC keys, so we can use
38 this as an crude example:
40 #include <openssl/evp.h>
43 /* |pkey| is an EVP_PKEY* */
44 if (EVP_PKEY_is_a(pkey, "RSA")) {
45 BIGNUM *modulus = NULL;
46 if (EVP_PKEY_get_bn_param(pkey, "n", &modulus))
47 /* do whatever with the modulus */
51 =head2 EVP_PKEY_can_sign()
53 #include <openssl/evp.h>
56 /* |pkey| is an EVP_PKEY* */
57 if (!EVP_PKEY_can_sign(pkey)) {
58 fprintf(stderr, "Not a signing key!");
61 /* Sign something... */
65 Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
67 Licensed under the Apache License 2.0 (the "License"). You may not use
68 this file except in compliance with the License. You can obtain a copy
69 in the file LICENSE in the source distribution or at
70 L<https://www.openssl.org/source/license.html>.