EVP_PKEY_get_size.pod 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. The primary documented use is with L<EVP_SignFinal(3)> and
  18. L<EVP_SealInit(3)>, but it isn't limited there. The returned size is
  19. also large enough for the output buffer of L<EVP_PKEY_sign(3)>,
  20. L<EVP_PKEY_encrypt(3)>, L<EVP_PKEY_decrypt(3)>, L<EVP_PKEY_derive(3)>.
  21. It must be stressed that, unless the documentation for the operation
  22. that's being performed says otherwise, the size returned by
  23. EVP_PKEY_get_size() is only preliminary and not exact, so the final
  24. contents of the target buffer may be smaller. It is therefore crucial
  25. to take note of the size given back by the function that performs the
  26. operation, such as L<EVP_PKEY_sign(3)> (the I<siglen> argument will
  27. receive that length), to avoid bugs.
  28. EVP_PKEY_get_bits() returns the cryptographic length of the cryptosystem
  29. to which the key in I<pkey> belongs, in bits. Note that the definition
  30. of cryptographic length is specific to the key cryptosystem.
  31. EVP_PKEY_get_security_bits() returns the number of security bits of the given
  32. I<pkey>, bits of security is defined in NIST SP800-57.
  33. =head1 RETURN VALUES
  34. EVP_PKEY_get_size(), EVP_PKEY_get_bits() and EVP_PKEY_get_security_bits()
  35. return a positive number, or 0 if this size isn't available.
  36. =head1 NOTES
  37. Most functions that have an output buffer and are mentioned with
  38. EVP_PKEY_get_size() have a functionality where you can pass NULL for the
  39. buffer and still pass a pointer to an integer and get the exact size
  40. that this function call delivers in the context that it's called in.
  41. This allows those functions to be called twice, once to find out the
  42. exact buffer size, then allocate the buffer in between, and call that
  43. function again actually output the data. For those functions, it
  44. isn't strictly necessary to call EVP_PKEY_get_size() to find out the
  45. buffer size, but may be useful in cases where it's desirable to know
  46. the upper limit in advance.
  47. It should also be especially noted that EVP_PKEY_get_size() shouldn't be
  48. used to get the output size for EVP_DigestSignFinal(), according to
  49. L<EVP_DigestSignFinal(3)/NOTES>.
  50. =head1 SEE ALSO
  51. L<EVP_SignFinal(3)>,
  52. L<EVP_SealInit(3)>,
  53. L<EVP_PKEY_sign(3)>,
  54. L<EVP_PKEY_encrypt(3)>,
  55. L<EVP_PKEY_decrypt(3)>,
  56. L<EVP_PKEY_derive(3)>
  57. =head1 HISTORY
  58. The EVP_PKEY_bits(), EVP_PKEY_security_bits(), and EVP_PKEY_size() functions
  59. were renamed to include C<get> in their names in OpenSSL 3.0, respectively.
  60. The old names are kept as non-deprecated alias macros.
  61. =head1 COPYRIGHT
  62. Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
  63. Licensed under the Apache License 2.0 (the "License"). You may not use
  64. this file except in compliance with the License. You can obtain a copy
  65. in the file LICENSE in the source distribution or at
  66. L<https://www.openssl.org/source/license.html>.
  67. =cut