EVP_PBE_CIPHERINIT(3SSL)
π EVP_PBE_CIPHERINIT π
okay so bestie, welcome to the OpenSSL manual page for EVP_PBE_CIPHERINIT (that's the 3SSL section, iykyk). This is the password based encryption girlies β the whole squad: EVP_PBE_CipherInit, EVP_PBE_CipherInit_ex, EVP_PBE_find, EVP_PBE_find_ex, EVP_PBE_alg_add_type, EVP_PBE_alg_add. Password based encryption routines. periodt.
β¨ SYNOPSIS β¨
#include <openssl/evp.h>
int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
int EVP_PBE_CipherInit_ex(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de,
OSSL_LIB_CTX *libctx, const char *propq);
int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,
EVP_PBE_KEYGEN **pkeygen);
int EVP_PBE_find_ex(int type, int pbe_nid, int *pcnid, int *pmnid,
EVP_PBE_KEYGEN **pkeygen, EVP_PBE_KEYGEN_EX **keygen_ex);
int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,
int md_nid, EVP_PBE_KEYGEN *keygen);
int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
EVP_PBE_KEYGEN *keygen);
πΈ DESCRIPTION πΈ
π PBE operations
EVP_PBE_CipherInit() and EVP_PBE_CipherInit_ex() get an EVP_CIPHER_CTX called ctx all set up and ready β either for encryption (en_de=1) or for decryption (en_de=0) β using the password pass whose length is passlen. π«Ά
The PBE algorithm type and its parameters get pulled out of an OID pbe_obj and the parameters param.
EVP_PBE_CipherInit_ex() is the extra version, and the way that it slays is that it also lets your app specify a library context libctx and a property query propq so it can pick the right algorithm implementations. π
π PBE algorithm search
EVP_PBE_find() and EVP_PBE_find_ex() go looking for a matching algorithm, and they use two parameters to do it:
- An algorithm type
type, which can be any of these three icons:
EVP_PBE_TYPE_OUTERβ a PBE algorithmEVP_PBE_TYPE_PRFβ a pseudo-random functionEVP_PBE_TYPE_KDFβ a key derivation function
- A
pbe_nid, which can be the algorithm identifier with parameters β likeNID_pbeWithSHA1AndRC2_CBCβ or an algorithm class, likeNID_pbes2.
They hand back the algorithm's cipher ID pcnid, its digest ID pmnid, and a key generation function for the algorithm pkeygen. And EVP_PBE_CipherInit_ex() (yes, the _ex one again, she's everywhere) also returns an extended key generation function keygen_ex, which takes a library context and a property query. β¨
Heads up bestie: if you pass aNULLfor any ofpcnid,pmnid,pkeygenorpkeygen_ex, then that parameter just doesn't get returned. No drama, no error, it's just not your moment. π
β PBE algorithm add
EVP_PBE_alg_add_type() and EVP_PBE_alg_add() add an algorithm to the list of known algorithms. Their parameters mean exactly the same thing as they do for EVP_PBE_find() and EVP_PBE_find_ex(). Same vibes, different function name. π
π NOTES π
The arguments pbe_obj and param that go into EVP_PBE_CipherInit() and EVP_PBE_CipherInit_ex() β together β form an X509_ALGOR, and honestly you can often just pull them straight out of that structure. Convenient? We love her. π
π«‘ RETURN VALUES π«‘
Return value is 1 for success and 0 if an error occurred. That's it, that's the whole vibe check. π
π SEE ALSO π
PKCS5_PBE_keyivgen(3), PKCS12_PBE_keyivgen_ex(3), PKCS5_v2_PBE_keyivgen_ex(3), PKCS12_pbe_crypt_ex(3), PKCS12_create_ex(3)
π¦ HISTORY π¦
EVP_PBE_CipherInit_ex() and EVP_PBE_find_ex() were added in OpenSSL 3.0. New girls on the block. π
Β©οΈ COPYRIGHT Β©οΈ
Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page bestie!! π this one's from OpenSSL version 4.0.3, dated 2026-09-29, and it's the EVP_PBE_CIPHERINIT(3SSL) manual β go forth and encrypt responsibly, ily, bye!! πππ«Ά
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms