2
0

EVP_SignInit.pod 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. =pod
  2. =head1 NAME
  3. EVP_SignInit, EVP_SignUpdate, EVP_SignFinal - EVP signing functions
  4. =head1 SYNOPSIS
  5. #include <openssl/evp.h>
  6. int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
  7. int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
  8. int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *sig,unsigned int *s, EVP_PKEY *pkey);
  9. void EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type);
  10. int EVP_PKEY_size(EVP_PKEY *pkey);
  11. =head1 DESCRIPTION
  12. The EVP signature routines are a high level interface to digital
  13. signatures.
  14. EVP_SignInit_ex() sets up signing context B<ctx> to use digest
  15. B<type> from ENGINE B<impl>. B<ctx> must be initialized with
  16. EVP_MD_CTX_init() before calling this function.
  17. EVP_SignUpdate() hashes B<cnt> bytes of data at B<d> into the
  18. signature context B<ctx>. This function can be called several times on the
  19. same B<ctx> to include additional data.
  20. EVP_SignFinal() signs the data in B<ctx> using the private key B<pkey> and
  21. places the signature in B<sig>. The number of bytes of data written (i.e. the
  22. length of the signature) will be written to the integer at B<s>, at most
  23. EVP_PKEY_size(pkey) bytes will be written.
  24. EVP_SignInit() initializes a signing context B<ctx> to use the default
  25. implementation of digest B<type>.
  26. EVP_PKEY_size() returns the maximum size of a signature in bytes. The actual
  27. signature returned by EVP_SignFinal() may be smaller.
  28. =head1 RETURN VALUES
  29. EVP_SignInit_ex(), EVP_SignUpdate() and EVP_SignFinal() return 1
  30. for success and 0 for failure.
  31. EVP_PKEY_size() returns the maximum size of a signature in bytes.
  32. The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
  33. =head1 NOTES
  34. The B<EVP> interface to digital signatures should almost always be used in
  35. preference to the low level interfaces. This is because the code then becomes
  36. transparent to the algorithm used and much more flexible.
  37. Due to the link between message digests and public key algorithms the correct
  38. digest algorithm must be used with the correct public key type. A list of
  39. algorithms and associated public key algorithms appears in
  40. L<EVP_DigestInit(3)|EVP_DigestInit(3)>.
  41. When signing with DSA private keys the random number generator must be seeded
  42. or the operation will fail. The random number generator does not need to be
  43. seeded for RSA signatures.
  44. The call to EVP_SignFinal() internally finalizes a copy of the digest context.
  45. This means that calls to EVP_SignUpdate() and EVP_SignFinal() can be called
  46. later to digest and sign additional data.
  47. Since only a copy of the digest context is ever finalized the context must
  48. be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak
  49. will occur.
  50. =head1 BUGS
  51. Older versions of this documentation wrongly stated that calls to
  52. EVP_SignUpdate() could not be made after calling EVP_SignFinal().
  53. Since the private key is passed in the call to EVP_SignFinal() any error
  54. relating to the private key (for example an unsuitable key and digest
  55. combination) will not be indicated until after potentially large amounts of
  56. data have been passed through EVP_SignUpdate().
  57. It is not possible to change the signing parameters using these function.
  58. The previous two bugs are fixed in the newer EVP_SignDigest*() function.
  59. =head1 SEE ALSO
  60. L<EVP_VerifyInit(3)|EVP_VerifyInit(3)>,
  61. L<EVP_DigestInit(3)|EVP_DigestInit(3)>, L<err(3)|err(3)>,
  62. L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>,
  63. L<md5(3)|md5(3)>, L<mdc2(3)|mdc2(3)>, L<ripemd(3)|ripemd(3)>,
  64. L<sha(3)|sha(3)>, L<dgst(1)|dgst(1)>
  65. =head1 HISTORY
  66. EVP_SignInit(), EVP_SignUpdate() and EVP_SignFinal() are
  67. available in all versions of SSLeay and OpenSSL.
  68. EVP_SignInit_ex() was added in OpenSSL 0.9.7.
  69. =cut