#include <openssl/pkcs8.h>
#include <limits.h>
#include <openssl/asn1t.h>
#include <openssl/asn1.h>
#include <openssl/bio.h>
#include <openssl/buf.h>
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/digest.h>
#include <openssl/hmac.h>
#include <openssl/mem.h>
#include <openssl/rand.h>
#include <openssl/x509.h>
#include "../bytestring/internal.h"
#include "../internal.h"
#include "../x509/internal.h"
#include "internal.h"
int pkcs12_iterations_acceptable(uint64_t iterations) { … }
ASN1_SEQUENCE(PKCS8_PRIV_KEY_INFO) = … ASN1_SEQUENCE_END(PKCS8_PRIV_KEY_INFO)
IMPLEMENT_ASN1_FUNCTIONS_const(…)
EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8) { … }
PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey) { … }
PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *pkcs8, const char *pass,
int pass_len_in) { … }
X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass,
int pass_len_in, const uint8_t *salt, size_t salt_len,
int iterations, PKCS8_PRIV_KEY_INFO *p8inf) { … }
struct pkcs12_context { … };
static int PKCS12_handle_sequence(
CBS *sequence, struct pkcs12_context *ctx,
int (*handle_element)(CBS *cbs, struct pkcs12_context *ctx)) { … }
static const uint8_t kKeyBag[] = …;
static const uint8_t kPKCS8ShroudedKeyBag[] = …;
static const uint8_t kCertBag[] = …;
static const uint8_t kFriendlyName[] = …;
static const uint8_t kLocalKeyID[] = …;
static const uint8_t kX509Certificate[] = …;
static int parse_bag_attributes(CBS *attrs, uint8_t **out_friendly_name,
size_t *out_friendly_name_len) { … }
static int PKCS12_handle_safe_bag(CBS *safe_bag, struct pkcs12_context *ctx) { … }
static const uint8_t kPKCS7Data[] = …;
static const uint8_t kPKCS7EncryptedData[] = …;
static int PKCS12_handle_content_info(CBS *content_info,
struct pkcs12_context *ctx) { … }
static int pkcs12_check_mac(int *out_mac_ok, const char *password,
size_t password_len, const CBS *salt,
uint32_t iterations, const EVP_MD *md,
const CBS *authsafes, const CBS *expected_mac) { … }
int PKCS12_get_key_and_certs(EVP_PKEY **out_key, STACK_OF(X509) *out_certs,
CBS *ber_in, const char *password) { … }
void PKCS12_PBE_add(void) { … }
struct pkcs12_st { … };
PKCS12 *d2i_PKCS12(PKCS12 **out_p12, const uint8_t **ber_bytes,
size_t ber_len) { … }
PKCS12* d2i_PKCS12_bio(BIO *bio, PKCS12 **out_p12) { … }
PKCS12* d2i_PKCS12_fp(FILE *fp, PKCS12 **out_p12) { … }
int i2d_PKCS12(const PKCS12 *p12, uint8_t **out) { … }
int i2d_PKCS12_bio(BIO *bio, const PKCS12 *p12) { … }
int i2d_PKCS12_fp(FILE *fp, const PKCS12 *p12) { … }
int PKCS12_parse(const PKCS12 *p12, const char *password, EVP_PKEY **out_pkey,
X509 **out_cert, STACK_OF(X509) **out_ca_certs) { … }
int PKCS12_verify_mac(const PKCS12 *p12, const char *password,
int password_len) { … }
static int add_bag_attributes(CBB *bag, const char *name, size_t name_len,
const uint8_t *key_id, size_t key_id_len) { … }
static int add_cert_bag(CBB *cbb, X509 *cert, const char *name,
const uint8_t *key_id, size_t key_id_len) { … }
static int add_cert_safe_contents(CBB *cbb, X509 *cert,
const STACK_OF(X509) *chain, const char *name,
const uint8_t *key_id, size_t key_id_len) { … }
static int add_encrypted_data(CBB *out, int pbe_nid, const char *password,
size_t password_len, uint32_t iterations,
const uint8_t *in, size_t in_len) { … }
PKCS12 *PKCS12_create(const char *password, const char *name,
const EVP_PKEY *pkey, X509 *cert,
const STACK_OF(X509)* chain, int key_nid, int cert_nid,
int iterations, int mac_iterations, int key_type) { … }
void PKCS12_free(PKCS12 *p12) { … }