Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 84cffed
  • /
  • doc
  • /
  • man3
  • /
  • EVP_PKEY_is_a.pod
Raw File
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:6ca64de6b340b14bc8cc234b9af01e04a01b1fb9
directory badge Iframe embedding
swh:1:dir:fb11c3c61200dd2a61cc663271a985debddf4a73
EVP_PKEY_is_a.pod
=pod

=head1 NAME

EVP_PKEY_is_a, EVP_PKEY_can_sign, EVP_PKEY_typenames_do_all,
EVP_PKEY_get0_first_alg_name
- key type and capabilities functions

=head1 SYNOPSIS

 #include <openssl/evp.h>

 int EVP_PKEY_is_a(const EVP_PKEY *pkey, const char *name);
 int EVP_PKEY_can_sign(const EVP_PKEY *pkey);
 void EVP_PKEY_typenames_do_all(const EVP_PKEY *pkey,
                                void (*fn)(const char *name, void *data),
                                void *data);
 const char *EVP_PKEY_get0_first_alg_name(const EVP_PKEY *key);

=head1 DESCRIPTION

EVP_PKEY_is_a() checks if the key type of I<pkey> is I<name>.

EVP_PKEY_can_sign() checks if the functionality for the key type of
I<pkey> supports signing.  No other check is done, such as whether
I<pkey> contains a private key.

EVP_PKEY_typenames_do_all() traverses all names for I<pkey>'s key type, and
calls I<fn> with each name and I<data>.  For example, an RSA B<EVP_PKEY> may
be named both C<RSA> and C<rsaEncryption>.
The order of the names is undefined.

EVP_PKEY_get0_first_alg_name() returns the first algorithm name that is found
for the given I<pkey>. Note that the I<pkey> may have multiple synonyms
associated with it. In this case it is undefined which one will be returned.
Ownership of the returned string is retained by the I<pkey> object and should
not be freed by the caller.

=head1 RETURN VALUES

EVP_PKEY_is_a() returns 1 if I<pkey> has the key type I<name>,
otherwise 0.

EVP_PKEY_can_sign() returns 1 if the I<pkey> key type functionality
supports signing, otherwise 0.

EVP_PKEY_get0_first_alg_name() returns the name that is found or NULL on error.

=head1 EXAMPLES

=head2 EVP_PKEY_is_a()

The loaded providers and what key types they support will ultimately
determine what I<name> is possible to use with EVP_PKEY_is_a().  We do know
that the default provider supports RSA, DH, DSA and EC keys, so we can use
this as an crude example:

 #include <openssl/evp.h>

 ...
     /* |pkey| is an EVP_PKEY* */
     if (EVP_PKEY_is_a(pkey, "RSA")) {
         BIGNUM *modulus = NULL;
         if (EVP_PKEY_get_bn_param(pkey, "n", &modulus))
             /* do whatever with the modulus */
         BN_free(modulus);
     }

=head2 EVP_PKEY_can_sign()

 #include <openssl/evp.h>

 ...
     /* |pkey| is an EVP_PKEY* */
     if (!EVP_PKEY_can_sign(pkey)) {
         fprintf(stderr, "Not a signing key!");
         exit(1);
     }
     /* Sign something... */

=head1 HISTORY

The functions described here were added in OpenSSL 3.0.

=head1 COPYRIGHT

Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License").  You may not use
this file except in compliance with the License.  You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.

=cut

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top