EVP_PKEY_size.pod 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. =pod
  2. =head1 NAME
  3. EVP_PKEY_size, EVP_PKEY_bits, EVP_PKEY_security_bits
  4. - EVP_PKEY information functions
  5. =head1 SYNOPSIS
  6. #include <openssl/evp.h>
  7. int EVP_PKEY_size(const EVP_PKEY *pkey);
  8. int EVP_PKEY_bits(const EVP_PKEY *pkey);
  9. int EVP_PKEY_security_bits(const EVP_PKEY *pkey);
  10. =head1 DESCRIPTION
  11. EVP_PKEY_size() returns the maximum suitable size for the output
  12. buffers for almost all operations that can be done with I<pkey>.
  13. The primary documented use is with L<EVP_SignFinal(3)> and
  14. L<EVP_SealInit(3)>, but it isn't limited there. The returned size is
  15. also large enough for the output buffer of L<EVP_PKEY_sign(3)>,
  16. L<EVP_PKEY_encrypt(3)>, L<EVP_PKEY_decrypt(3)>, L<EVP_PKEY_derive(3)>.
  17. It must be stressed that, unless the documentation for the operation
  18. that's being performed says otherwise, the size returned by
  19. EVP_PKEY_size() is only preliminary and not exact, so the final
  20. contents of the target buffer may be smaller. It is therefore crucial
  21. to take note of the size given back by the function that performs the
  22. operation, such as L<EVP_PKEY_sign(3)> (the I<siglen> argument will
  23. receive that length), to avoid bugs.
  24. EVP_PKEY_bits() returns the cryptographic length of the cryptosystem
  25. to which the key in I<pkey> belongs, in bits. Note that the definition
  26. of cryptographic length is specific to the key cryptosystem.
  27. EVP_PKEY_security_bits() returns the number of security bits of the given
  28. I<pkey>, bits of security is defined in NIST SP800-57.
  29. =head1 RETURN VALUES
  30. EVP_PKEY_size(), EVP_PKEY_bits() and EVP_PKEY_security_bits() return a
  31. positive number, or 0 if this size isn't available.
  32. =head1 NOTES
  33. Most functions that have an output buffer and are mentioned with
  34. EVP_PKEY_size() have a functionality where you can pass NULL for the
  35. buffer and still pass a pointer to an integer and get the exact size
  36. that this function call delivers in the context that it's called in.
  37. This allows those functions to be called twice, once to find out the
  38. exact buffer size, then allocate the buffer in between, and call that
  39. function again actually output the data. For those functions, it
  40. isn't strictly necessary to call EVP_PKEY_size() to find out the
  41. buffer size, but may be useful in cases where it's desirable to know
  42. the upper limit in advance.
  43. It should also be especially noted that EVP_PKEY_size() shouldn't be
  44. used to get the output size for EVP_DigestSignFinal(), according to
  45. L<EVP_DigestSignFinal(3)/NOTES>.
  46. =head1 SEE ALSO
  47. L<EVP_SignFinal(3)>,
  48. L<EVP_SealInit(3)>,
  49. L<EVP_PKEY_sign(3)>,
  50. L<EVP_PKEY_encrypt(3)>,
  51. L<EVP_PKEY_decrypt(3)>,
  52. L<EVP_PKEY_derive(3)>
  53. =head1 COPYRIGHT
  54. Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
  55. Licensed under the Apache License 2.0 (the "License"). You may not use
  56. this file except in compliance with the License. You can obtain a copy
  57. in the file LICENSE in the source distribution or at
  58. L<https://www.openssl.org/source/license.html>.
  59. =cut