EVP_SignInit.pod 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. =pod
  2. =head1 NAME
  3. EVP_PKEY_size,
  4. EVP_SignInit, EVP_SignInit_ex, EVP_SignUpdate, EVP_SignFinal,
  5. EVP_PKEY_security_bits - EVP signing
  6. functions
  7. =head1 SYNOPSIS
  8. #include <openssl/evp.h>
  9. int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
  10. int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
  11. int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sig, unsigned int *s, EVP_PKEY *pkey);
  12. void EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type);
  13. int EVP_PKEY_size(EVP_PKEY *pkey);
  14. int EVP_PKEY_security_bits(const EVP_PKEY *pkey);
  15. =head1 DESCRIPTION
  16. The EVP signature routines are a high level interface to digital
  17. signatures.
  18. EVP_SignInit_ex() sets up signing context B<ctx> to use digest
  19. B<type> from ENGINE B<impl>. B<ctx> must be created with
  20. EVP_MD_CTX_new() before calling this function.
  21. EVP_SignUpdate() hashes B<cnt> bytes of data at B<d> into the
  22. signature context B<ctx>. This function can be called several times on the
  23. same B<ctx> to include additional data.
  24. EVP_SignFinal() signs the data in B<ctx> using the private key B<pkey> and
  25. places the signature in B<sig>. B<sig> must be at least EVP_PKEY_size(pkey)
  26. bytes in size. B<s> is an OUT parameter, and not used as an IN parameter.
  27. The number of bytes of data written (i.e. the length of the signature)
  28. will be written to the integer at B<s>, at most EVP_PKEY_size(pkey) bytes
  29. will be written.
  30. EVP_SignInit() initializes a signing context B<ctx> to use the default
  31. implementation of digest B<type>.
  32. EVP_PKEY_size() returns the maximum size of a signature in bytes. The actual
  33. signature returned by EVP_SignFinal() may be smaller.
  34. EVP_PKEY_security_bits() returns the number of security bits of the given B<pkey>,
  35. bits of security is defined in NIST SP800-57.
  36. =head1 RETURN VALUES
  37. EVP_SignInit_ex(), EVP_SignUpdate() and EVP_SignFinal() return 1
  38. for success and 0 for failure.
  39. EVP_PKEY_size() returns the maximum size of a signature in bytes.
  40. The error codes can be obtained by L<ERR_get_error(3)>.
  41. EVP_PKEY_security_bits() returns the number of security bits.
  42. =head1 NOTES
  43. The B<EVP> interface to digital signatures should almost always be used in
  44. preference to the low level interfaces. This is because the code then becomes
  45. transparent to the algorithm used and much more flexible.
  46. When signing with DSA private keys the random number generator must be seeded
  47. or the operation will fail. The random number generator does not need to be
  48. seeded for RSA signatures.
  49. The call to EVP_SignFinal() internally finalizes a copy of the digest context.
  50. This means that calls to EVP_SignUpdate() and EVP_SignFinal() can be called
  51. later to digest and sign additional data.
  52. Since only a copy of the digest context is ever finalized the context must
  53. be cleaned up after use by calling EVP_MD_CTX_free() or a memory leak
  54. will occur.
  55. =head1 BUGS
  56. Older versions of this documentation wrongly stated that calls to
  57. EVP_SignUpdate() could not be made after calling EVP_SignFinal().
  58. Since the private key is passed in the call to EVP_SignFinal() any error
  59. relating to the private key (for example an unsuitable key and digest
  60. combination) will not be indicated until after potentially large amounts of
  61. data have been passed through EVP_SignUpdate().
  62. It is not possible to change the signing parameters using these function.
  63. The previous two bugs are fixed in the newer EVP_SignDigest*() function.
  64. =head1 SEE ALSO
  65. L<EVP_VerifyInit(3)>,
  66. L<EVP_DigestInit(3)>,
  67. L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
  68. L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
  69. L<SHA1(3)>, L<dgst(1)>
  70. =head1 COPYRIGHT
  71. Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
  72. Licensed under the OpenSSL license (the "License"). You may not use
  73. this file except in compliance with the License. You can obtain a copy
  74. in the file LICENSE in the source distribution or at
  75. L<https://www.openssl.org/source/license.html>.
  76. =cut