EVP_PKEY_get_size.pod 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. =pod
  2. =head1 NAME
  3. EVP_PKEY_get_size, EVP_PKEY_get_bits, EVP_PKEY_get_security_bits,
  4. EVP_PKEY_bits, EVP_PKEY_security_bits, EVP_PKEY_size
  5. - EVP_PKEY information functions
  6. =head1 SYNOPSIS
  7. #include <openssl/evp.h>
  8. int EVP_PKEY_get_size(const EVP_PKEY *pkey);
  9. int EVP_PKEY_get_bits(const EVP_PKEY *pkey);
  10. int EVP_PKEY_get_security_bits(const EVP_PKEY *pkey);
  11. #define EVP_PKEY_bits EVP_PKEY_get_bits
  12. #define EVP_PKEY_security_bits EVP_PKEY_get_security_bits
  13. #define EVP_PKEY_size EVP_PKEY_get_size
  14. =head1 DESCRIPTION
  15. EVP_PKEY_get_size() returns the maximum suitable size for the output
  16. buffers for almost all operations that can be done with I<pkey>.
  17. This corresponds to the provider parameter B<OSSL_PKEY_PARAM_MAX_SIZE>.
  18. The primary documented use is with L<EVP_SignFinal(3)> and
  19. L<EVP_SealInit(3)>, but it isn't limited there. The returned size is
  20. also large enough for the output buffer of L<EVP_PKEY_sign(3)>,
  21. L<EVP_PKEY_encrypt(3)>, L<EVP_PKEY_decrypt(3)>, L<EVP_PKEY_derive(3)>.
  22. It must be stressed that, unless the documentation for the operation
  23. that's being performed says otherwise, the size returned by
  24. EVP_PKEY_get_size() is only preliminary and not exact, so the final
  25. contents of the target buffer may be smaller. It is therefore crucial
  26. to take note of the size given back by the function that performs the
  27. operation, such as L<EVP_PKEY_sign(3)> (the I<siglen> argument will
  28. receive that length), to avoid bugs.
  29. EVP_PKEY_get_bits() returns the cryptographic length of the cryptosystem
  30. to which the key in I<pkey> belongs, in bits. Note that the definition
  31. of cryptographic length is specific to the key cryptosystem.
  32. This length corresponds to the provider parameter B<OSSL_PKEY_PARAM_BITS>.
  33. EVP_PKEY_get_security_bits() returns the number of security bits of the given
  34. I<pkey>, bits of security is defined in NIST SP800-57.
  35. This corresponds to the provider parameter B<OSSL_PKEY_PARAM_SECURITY_BITS>.
  36. =head1 RETURN VALUES
  37. EVP_PKEY_get_size(), EVP_PKEY_get_bits() and EVP_PKEY_get_security_bits()
  38. return a positive number, or 0 if this size isn't available.
  39. =head1 NOTES
  40. Most functions that have an output buffer and are mentioned with
  41. EVP_PKEY_get_size() have a functionality where you can pass NULL for the
  42. buffer and still pass a pointer to an integer and get the exact size
  43. that this function call delivers in the context that it's called in.
  44. This allows those functions to be called twice, once to find out the
  45. exact buffer size, then allocate the buffer in between, and call that
  46. function again actually output the data. For those functions, it
  47. isn't strictly necessary to call EVP_PKEY_get_size() to find out the
  48. buffer size, but may be useful in cases where it's desirable to know
  49. the upper limit in advance.
  50. It should also be especially noted that EVP_PKEY_get_size() shouldn't be
  51. used to get the output size for EVP_DigestSignFinal(), according to
  52. L<EVP_DigestSignFinal(3)/NOTES>.
  53. =head1 SEE ALSO
  54. L<provider-keymgmt(7)>,
  55. L<EVP_SignFinal(3)>,
  56. L<EVP_SealInit(3)>,
  57. L<EVP_PKEY_sign(3)>,
  58. L<EVP_PKEY_encrypt(3)>,
  59. L<EVP_PKEY_decrypt(3)>,
  60. L<EVP_PKEY_derive(3)>
  61. =head1 HISTORY
  62. The EVP_PKEY_bits(), EVP_PKEY_security_bits(), and EVP_PKEY_size() functions
  63. were renamed to include C<get> in their names in OpenSSL 3.0, respectively.
  64. The old names are kept as non-deprecated alias macros.
  65. =head1 COPYRIGHT
  66. Copyright 2020-2021 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>.
  71. =cut