Lines Matching refs:p12
31 int PKCS12_mac_present(const PKCS12 *p12) in PKCS12_mac_present() argument
33 return p12->mac ? 1 : 0; in PKCS12_mac_present()
40 const PKCS12 *p12) in PKCS12_get0_mac() argument
42 if (p12->mac) { in PKCS12_get0_mac()
43 X509_SIG_get0(p12->mac->dinfo, pmacalg, pmac); in PKCS12_get0_mac()
45 *psalt = p12->mac->salt; in PKCS12_get0_mac()
47 *piter = p12->mac->iter; in PKCS12_get0_mac()
156 static int pkcs12_gen_mac(PKCS12 *p12, const char *pass, int passlen, in pkcs12_gen_mac() argument
177 if (!PKCS7_type_is_data(p12->authsafes)) { in pkcs12_gen_mac()
182 if (p12->authsafes->d.data == NULL) { in pkcs12_gen_mac()
187 salt = p12->mac->salt->data; in pkcs12_gen_mac()
188 saltlen = p12->mac->salt->length; in pkcs12_gen_mac()
189 if (p12->mac->iter == NULL) in pkcs12_gen_mac()
192 iter = ASN1_INTEGER_get(p12->mac->iter); in pkcs12_gen_mac()
193 X509_SIG_get0(p12->mac->dinfo, &macalg, NULL); in pkcs12_gen_mac()
203 md = md_fetch = EVP_MD_fetch(p12->authsafes->ctx.libctx, md_name, in pkcs12_gen_mac()
204 p12->authsafes->ctx.propq); in pkcs12_gen_mac()
222 keylen = PBMAC1_PBKDF2_HMAC(p12->authsafes->ctx.libctx, p12->authsafes->ctx.propq, in pkcs12_gen_mac()
266 p12->authsafes->ctx.libctx, p12->authsafes->ctx.propq)) { in pkcs12_gen_mac()
274 || !HMAC_Update(hmac, p12->authsafes->d.data->data, in pkcs12_gen_mac()
275 p12->authsafes->d.data->length) in pkcs12_gen_mac()
288 int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, in PKCS12_gen_mac() argument
291 return pkcs12_gen_mac(p12, pass, passlen, mac, maclen, NID_undef, NID_undef, NULL); in PKCS12_gen_mac()
295 int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen) in PKCS12_verify_mac() argument
303 if (p12->mac == NULL) { in PKCS12_verify_mac()
308 X509_SIG_get0(p12->mac->dinfo, &macalg, NULL); in PKCS12_verify_mac()
323 if (!pkcs12_gen_mac(p12, pass, passlen, mac, &maclen, md_nid, NID_undef, NULL)) { in PKCS12_verify_mac()
330 if (!pkcs12_gen_mac(p12, pass, passlen, mac, &maclen, NID_undef, NID_undef, NULL)) { in PKCS12_verify_mac()
335 X509_SIG_get0(p12->mac->dinfo, NULL, &macoct); in PKCS12_verify_mac()
344 int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, in PKCS12_set_mac() argument
357 if (PKCS12_setup_mac(p12, iter, salt, saltlen, md_type) == PKCS12_ERROR) { in PKCS12_set_mac()
364 if (!pkcs12_gen_mac(p12, pass, passlen, mac, &maclen, NID_undef, NID_undef, NULL)) { in PKCS12_set_mac()
368 X509_SIG_getm(p12->mac->dinfo, NULL, &macoct); in PKCS12_set_mac()
386 static int pkcs12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, in pkcs12_setup_mac() argument
391 PKCS12_MAC_DATA_free(p12->mac); in pkcs12_setup_mac()
392 p12->mac = NULL; in pkcs12_setup_mac()
394 if ((p12->mac = PKCS12_MAC_DATA_new()) == NULL) in pkcs12_setup_mac()
397 if ((p12->mac->iter = ASN1_INTEGER_new()) == NULL) { in pkcs12_setup_mac()
401 if (!ASN1_INTEGER_set(p12->mac->iter, iter)) { in pkcs12_setup_mac()
410 if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) in pkcs12_setup_mac()
412 p12->mac->salt->length = saltlen; in pkcs12_setup_mac()
414 if (RAND_bytes_ex(p12->authsafes->ctx.libctx, p12->mac->salt->data, in pkcs12_setup_mac()
418 memcpy(p12->mac->salt->data, salt, saltlen); in pkcs12_setup_mac()
420 X509_SIG_getm(p12->mac->dinfo, &macalg, NULL); in pkcs12_setup_mac()
430 int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, in PKCS12_setup_mac() argument
433 return pkcs12_setup_mac(p12, iter, salt, saltlen, EVP_MD_get_type(md_type)); in PKCS12_setup_mac()
436 int PKCS12_set_pbmac1_pbkdf2(PKCS12 *p12, const char *pass, int passlen, in PKCS12_set_pbmac1_pbkdf2() argument
490 if (pkcs12_setup_mac(p12, iter, salt ? salt : known_salt, saltlen, in PKCS12_set_pbmac1_pbkdf2()
506 X509_SIG_getm(p12->mac->dinfo, &macalg, &macoct); in PKCS12_set_pbmac1_pbkdf2()
513 if (!pkcs12_gen_mac(p12, pass, passlen, mac, &maclen, in PKCS12_set_pbmac1_pbkdf2()