EVP_PBE_CipherInit.pod 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. =pod
  2. =head1 NAME
  3. EVP_PBE_CipherInit, EVP_PBE_CipherInit_ex,
  4. EVP_PBE_find, EVP_PBE_find_ex,
  5. EVP_PBE_alg_add_type, EVP_PBE_alg_add - Password based encryption routines
  6. =head1 SYNOPSIS
  7. #include <openssl/evp.h>
  8. int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
  9. ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
  10. int EVP_PBE_CipherInit_ex(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
  11. ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de,
  12. OSSL_LIB_CTX *libctx, const char *propq);
  13. int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,
  14. EVP_PBE_KEYGEN **pkeygen);
  15. int EVP_PBE_find_ex(int type, int pbe_nid, int *pcnid, int *pmnid,
  16. EVP_PBE_KEYGEN **pkeygen, EVP_PBE_KEYGEN_EX **keygen_ex);
  17. int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,
  18. int md_nid, EVP_PBE_KEYGEN *keygen);
  19. int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
  20. EVP_PBE_KEYGEN *keygen);
  21. =head1 DESCRIPTION
  22. =head2 PBE operations
  23. EVP_PBE_CipherInit() and EVP_PBE_CipherInit_ex() initialise an B<EVP_CIPHER_CTX>
  24. I<ctx> for encryption (I<en_de>=1) or decryption (I<en_de>=0) using the password
  25. I<pass> of length I<passlen>. The PBE algorithm type and parameters are extracted
  26. from an OID I<pbe_obj> and parameters I<param>.
  27. EVP_PBE_CipherInit_ex() also allows the application to specify a library context
  28. I<libctx> and property query I<propq> to select appropriate algorithm
  29. implementations.
  30. =head2 PBE algorithm search
  31. EVP_PBE_find() and EVP_PBE_find_ex() search for a matching algorithm using two parameters:
  32. 1. An algorithm type I<type> which can be:
  33. =over 4
  34. =item *
  35. EVP_PBE_TYPE_OUTER - A PBE algorithm
  36. =item *
  37. EVP_PBE_TYPE_PRF - A pseudo-random function
  38. =item *
  39. EVP_PBE_TYPE_KDF - A key derivation function
  40. =back
  41. 2. A I<pbe_nid> which can represent the algorithm identifier with parameters e.g.
  42. B<NID_pbeWithSHA1AndRC2_CBC> or an algorithm class e.g. B<NID_pbes2>.
  43. They return the algorithm's cipher ID I<pcnid>, digest ID I<pmnid> and a key
  44. generation function for the algorithm I<pkeygen>. EVP_PBE_CipherInit_ex() also
  45. returns an extended key generation function I<keygen_ex> which takes a library
  46. context and property query.
  47. If a NULL is supplied for any of I<pcnid>, I<pmnid>, I<pkeygen> or I<pkeygen_ex>
  48. then this parameter is not returned.
  49. =head2 PBE algorithm add
  50. EVP_PBE_alg_add_type() and EVP_PBE_alg_add() add an algorithm to the list
  51. of known algorithms. Their parameters have the same meaning as for
  52. EVP_PBE_find() and EVP_PBE_find_ex() functions.
  53. =head1 NOTES
  54. The arguments I<pbe_obj> and I<param> to EVP_PBE_CipherInit() and EVP_PBE_CipherInit_ex()
  55. together form an B<X509_ALGOR> and can often be extracted directly from this structure.
  56. =head1 RETURN VALUES
  57. Return value is 1 for success and 0 if an error occurred.
  58. =head1 SEE ALSO
  59. L<PKCS5_PBE_keyivgen(3)>,
  60. L<PKCS12_PBE_keyivgen_ex(3)>,
  61. L<PKCS5_v2_PBE_keyivgen_ex(3)>,
  62. L<PKCS12_pbe_crypt_ex(3)>,
  63. L<PKCS12_create_ex(3)>
  64. =head1 HISTORY
  65. EVP_PBE_CipherInit_ex() and EVP_PBE_find_ex() were added in OpenSSL 3.0.
  66. =head1 COPYRIGHT
  67. Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
  68. Licensed under the Apache License 2.0 (the "License"). You may not use
  69. this file except in compliance with the License. You can obtain a copy
  70. in the file LICENSE in the source distribution or at
  71. L<https://www.openssl.org/source/license.html>.
  72. =cut