evp.pod 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. =pod
  2. =head1 NAME
  3. evp - high-level cryptographic functions
  4. =head1 SYNOPSIS
  5. #include <openssl/evp.h>
  6. =head1 DESCRIPTION
  7. The EVP library provides a high-level interface to cryptographic
  8. functions.
  9. L<B<EVP_Seal>I<...>|EVP_SealInit(3)> and L<B<EVP_Open>I<...>|EVP_OpenInit(3)>
  10. provide public key encryption and decryption to implement digital "envelopes".
  11. The L<B<EVP_DigestSign>I<...>|EVP_DigestSignInit(3)> and
  12. L<B<EVP_DigestVerify>I<...>|EVP_DigestVerifyInit(3)> functions implement
  13. digital signatures and Message Authentication Codes (MACs). Also see the older
  14. L<B<EVP_Sign>I<...>|EVP_SignInit(3)> and L<B<EVP_Verify>I<...>|EVP_VerifyInit(3)>
  15. functions.
  16. Symmetric encryption is available with the L<B<EVP_Encrypt>I<...>|EVP_EncryptInit(3)>
  17. functions. The L<B<EVP_Digest>I<...>|EVP_DigestInit(3)> functions provide message digests.
  18. The B<EVP_PKEY>I<...> functions provide a high level interface to
  19. asymmetric algorithms. To create a new EVP_PKEY see
  20. L<EVP_PKEY_new(3)|EVP_PKEY_new(3)>. EVP_PKEYs can be associated
  21. with a private key of a particular algorithm by using the functions
  22. described on the L<EVP_PKEY_set1_RSA(3)|EVP_PKEY_set1_RSA(3)> page, or
  23. new keys can be generated using L<EVP_PKEY_keygen(3)|EVP_PKEY_keygen(3)>.
  24. EVP_PKEYs can be compared using L<EVP_PKEY_cmp(3)|EVP_PKEY_cmp(3)>, or printed using
  25. L<EVP_PKEY_print_private(3)|EVP_PKEY_print_private(3)>.
  26. The EVP_PKEY functions support the full range of asymmetric algorithm operations:
  27. =over
  28. =item For key agreement see L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
  29. =item For signing and verifying see L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
  30. L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)> and L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>.
  31. However, note that
  32. these functions do not perform a digest of the data to be signed. Therefore
  33. normally you would use the L<B<EVP_DigestSign>I<...>|EVP_DigestSignInit(3)>
  34. functions for this purpose.
  35. =item For encryption and decryption see L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>
  36. and L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)> respectively. However, note that
  37. these functions perform encryption and decryption only. As public key
  38. encryption is an expensive operation, normally you would wrap
  39. an encrypted message in a "digital envelope" using the L<B<EVP_Seal>I<...>|EVP_SealInit(3)> and
  40. L<B<EVP_Open>I<...>|EVP_OpenInit(3)> functions.
  41. =back
  42. The L<EVP_BytesToKey(3)|EVP_BytesToKey(3)> function provides some limited support for password
  43. based encryption. Careful selection of the parameters will provide a PKCS#5 PBKDF1 compatible
  44. implementation. However, new applications should not typically use this (preferring, for example,
  45. PBKDF2 from PCKS#5).
  46. The L<B<EVP_Encode>I<...>|EVP_EncodeInit(3)> and
  47. L<B<EVP_Decode>I<...>|EVP_EncodeInit(3)> functions implement base 64 encoding
  48. and decoding.
  49. Algorithms are loaded with L<OpenSSL_add_all_algorithms(3)|OpenSSL_add_all_algorithms(3)>.
  50. All the symmetric algorithms (ciphers), digests and asymmetric algorithms
  51. (public key algorithms) can be replaced by L<ENGINE|engine(3)> modules providing alternative
  52. implementations. If ENGINE implementations of ciphers or digests are registered
  53. as defaults, then the various EVP functions will automatically use those
  54. implementations automatically in preference to built in software
  55. implementations. For more information, consult the engine(3) man page.
  56. Although low level algorithm specific functions exist for many algorithms
  57. their use is discouraged. They cannot be used with an ENGINE and ENGINE
  58. versions of new algorithms cannot be accessed using the low level functions.
  59. Also makes code harder to adapt to new algorithms and some options are not
  60. cleanly supported at the low level and some operations are more efficient
  61. using the high level interface.
  62. =head1 SEE ALSO
  63. L<EVP_DigestInit(3)|EVP_DigestInit(3)>,
  64. L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>,
  65. L<EVP_OpenInit(3)|EVP_OpenInit(3)>,
  66. L<EVP_SealInit(3)|EVP_SealInit(3)>,
  67. L<EVP_DigestSignInit(3)|EVP_DigestSignInit(3)>,
  68. L<EVP_SignInit(3)|EVP_SignInit(3)>,
  69. L<EVP_VerifyInit(3)|EVP_VerifyInit(3)>,
  70. L<EVP_EncodeInit(3)>,
  71. L<EVP_PKEY_new(3)|EVP_PKEY_new(3)>,
  72. L<EVP_PKEY_set1_RSA(3)|EVP_PKEY_set1_RSA(3)>,
  73. L<EVP_PKEY_keygen(3)|EVP_PKEY_keygen(3)>,
  74. L<EVP_PKEY_print_private(3)|EVP_PKEY_print_private(3)>,
  75. L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
  76. L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
  77. L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
  78. L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
  79. L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
  80. L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>,
  81. L<EVP_BytesToKey(3)|EVP_BytesToKey(3)>,
  82. L<OpenSSL_add_all_algorithms(3)|OpenSSL_add_all_algorithms(3)>,
  83. L<engine(3)|engine(3)>
  84. =cut