Go to the documentation of this file.
71 #include "../bytestring/internal.h"
72 #include "../internal.h"
110 size_t salt_len,
uint8_t id,
unsigned iterations,
115 if (iterations < 1) {
123 uint8_t *pass_raw = NULL, *
I = NULL;
124 size_t pass_raw_len = 0, I_len = 0;
150 if (salt_len + block_size - 1 < salt_len ||
151 pass_raw_len + block_size - 1 < pass_raw_len) {
155 size_t S_len = block_size * ((salt_len + block_size - 1) / block_size);
156 size_t P_len = block_size * ((pass_raw_len + block_size - 1) / block_size);
157 I_len = S_len + P_len;
164 if (I_len != 0 &&
I == NULL) {
169 for (
size_t i = 0;
i < S_len;
i++) {
170 I[
i] = salt[
i % salt_len];
172 for (
size_t i = 0;
i < P_len;
i++) {
173 I[
i + S_len] = pass_raw[
i % pass_raw_len];
176 while (out_len != 0) {
195 size_t todo = out_len < A_len ? out_len : A_len;
206 for (
size_t i = 0;
i < block_size;
i++) {
213 assert(I_len % block_size == 0);
214 for (
size_t i = 0;
i < I_len;
i += block_size) {
216 for (
size_t j = block_size - 1; j < block_size; j--) {
217 carry +=
I[
i + j] + B[j];
235 const char *pass,
size_t pass_len,
236 const uint8_t *salt,
size_t salt_len,
259 size_t pass_len,
CBS *param) {
285 {0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x01, 0x06},
294 {0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x01, 0x01},
303 {0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x01, 0x03},
312 {0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0d},
334 unsigned iterations,
const char *pass,
335 size_t pass_len,
const uint8_t *salt,
344 CBB algorithm,
oid, param, salt_cbb;
361 const char *pass,
size_t pass_len,
const uint8_t *
in,
386 if (!
suite->decrypt_init(
suite, &
ctx, pass, pass_len, algorithm)) {
397 if (in_len > INT_MAX) {
447 const char *pass,
size_t pass_len,
448 const uint8_t *salt,
size_t salt_len,
449 int iterations,
const EVP_PKEY *pkey) {
452 size_t plaintext_len = 0;
463 if (salt_buf == NULL ||
471 if (iterations <= 0) {
477 if (!
CBB_init(&plaintext_cbb, 128) ||
496 pass, pass_len, salt, salt_len);
499 pass, pass_len, salt, salt_len);
506 if (max_out < plaintext_len) {
#define CBS_get_asn1_uint64
#define EVP_marshal_private_key
#define EVP_MD_block_size
OPENSSL_EXPORT const ASN1_OBJECT * obj
#define EVP_CIPHER_CTX_init
#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC
#define EVP_MAX_KEY_LENGTH
#define OPENSSL_PUT_ERROR(library, reason)
static const struct pbe_suite * get_pkcs12_pbe_suite(int pbe_nid)
#define OPENSSL_ARRAY_SIZE(array)
#define CBS_ASN1_OCTETSTRING
#define EVP_CIPHER_iv_length
static struct test_ctx ctx
#define EVP_DigestInit_ex
#define EVP_parse_private_key
#define PKCS12_DEFAULT_ITER
static const struct pbe_suite kBuiltinPBE[]
static void * OPENSSL_memset(void *dst, int c, size_t n)
#define pkcs12_iterations_acceptable
int pkcs8_pbe_decrypt(uint8_t **out, size_t *out_len, CBS *algorithm, const char *pass, size_t pass_len, const uint8_t *in, size_t in_len)
#define PKCS8_R_KEY_GEN_ERROR
#define PKCS8_R_INVALID_CHARACTERS
#define EVP_CIPHER_CTX_block_size
#define PKCS8_R_UNKNOWN_ALGORITHM
unsigned __int64 uint64_t
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
const EVP_MD *(* md_func)(void)
static int pkcs12_encode_password(const char *in, size_t in_len, uint8_t **out, size_t *out_len)
int pkcs12_key_gen(const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len, uint8_t id, unsigned iterations, size_t out_len, uint8_t *out, const EVP_MD *md)
#define PKCS8_R_BAD_ITERATION_COUNT
const OPENSSL_EXPORT EVP_CIPHER * EVP_des_ede3_cbc(void)
#define PKCS5_pbe2_decrypt_init
#define PKCS5_pbe2_encrypt_init
EVP_PKEY * PKCS8_parse_encrypted_private_key(CBS *cbs, const char *pass, size_t pass_len)
#define EVP_MAX_MD_BLOCK_SIZE
int pkcs12_pbe_encrypt_init(CBB *out, EVP_CIPHER_CTX *ctx, int alg, unsigned iterations, const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len)
static int pkcs12_pbe_decrypt_init(const struct pbe_suite *suite, EVP_CIPHER_CTX *ctx, const char *pass, size_t pass_len, CBS *param)
#define EVP_CipherFinal_ex
#define EVP_CipherInit_ex
#define EVP_DigestFinal_ex
#define EVP_DecryptUpdate
int PKCS8_marshal_encrypted_private_key(CBB *out, int pbe_nid, const EVP_CIPHER *cipher, const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len, int iterations, const EVP_PKEY *pkey)
UniquePtr< SSL_SESSION > ret
#define EVP_CIPHER_CTX_cleanup
const EVP_CIPHER *(* cipher_func)(void)
#define EVP_MAX_IV_LENGTH
#define EVP_CIPHER_key_length
#define EVP_DecryptFinal_ex
#define NID_pbe_WithSHA1And128BitRC4
const OPENSSL_EXPORT EVP_MD * EVP_sha1(void)
#define NID_pbe_WithSHA1And40BitRC2_CBC
static int pkcs12_pbe_cipher_init(const struct pbe_suite *suite, EVP_CIPHER_CTX *ctx, unsigned iterations, const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len, int is_encrypt)
#define PKCS8_R_DECODE_ERROR
#define CBS_ASN1_SEQUENCE
#define EVP_MD_CTX_cleanup
#define PKCS8_R_KEYGEN_FAILURE
#define ERR_R_MALLOC_FAILURE
#define CBB_add_asn1_uint64
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:43