1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci#include <stdio.h> 11e1051a39Sopenharmony_ci#include "internal/cryptlib.h" 12e1051a39Sopenharmony_ci#include <openssl/asn1t.h> 13e1051a39Sopenharmony_ci#include <openssl/pkcs12.h> 14e1051a39Sopenharmony_ci#include "p12_local.h" 15e1051a39Sopenharmony_ci 16e1051a39Sopenharmony_ci/* PKCS#12 ASN1 module */ 17e1051a39Sopenharmony_ci 18e1051a39Sopenharmony_ciASN1_SEQUENCE(PKCS12) = { 19e1051a39Sopenharmony_ci ASN1_SIMPLE(PKCS12, version, ASN1_INTEGER), 20e1051a39Sopenharmony_ci ASN1_SIMPLE(PKCS12, authsafes, PKCS7), 21e1051a39Sopenharmony_ci ASN1_OPT(PKCS12, mac, PKCS12_MAC_DATA) 22e1051a39Sopenharmony_ci} ASN1_SEQUENCE_END(PKCS12) 23e1051a39Sopenharmony_ci 24e1051a39Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(PKCS12) 25e1051a39Sopenharmony_ci 26e1051a39Sopenharmony_ciASN1_SEQUENCE(PKCS12_MAC_DATA) = { 27e1051a39Sopenharmony_ci ASN1_SIMPLE(PKCS12_MAC_DATA, dinfo, X509_SIG), 28e1051a39Sopenharmony_ci ASN1_SIMPLE(PKCS12_MAC_DATA, salt, ASN1_OCTET_STRING), 29e1051a39Sopenharmony_ci ASN1_OPT(PKCS12_MAC_DATA, iter, ASN1_INTEGER) 30e1051a39Sopenharmony_ci} ASN1_SEQUENCE_END(PKCS12_MAC_DATA) 31e1051a39Sopenharmony_ci 32e1051a39Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(PKCS12_MAC_DATA) 33e1051a39Sopenharmony_ci 34e1051a39Sopenharmony_ciASN1_ADB_TEMPLATE(bag_default) = ASN1_EXP(PKCS12_BAGS, value.other, ASN1_ANY, 0); 35e1051a39Sopenharmony_ci 36e1051a39Sopenharmony_ciASN1_ADB(PKCS12_BAGS) = { 37e1051a39Sopenharmony_ci ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.x509cert, ASN1_OCTET_STRING, 0)), 38e1051a39Sopenharmony_ci ADB_ENTRY(NID_x509Crl, ASN1_EXP(PKCS12_BAGS, value.x509crl, ASN1_OCTET_STRING, 0)), 39e1051a39Sopenharmony_ci ADB_ENTRY(NID_sdsiCertificate, ASN1_EXP(PKCS12_BAGS, value.sdsicert, ASN1_IA5STRING, 0)), 40e1051a39Sopenharmony_ci} ASN1_ADB_END(PKCS12_BAGS, 0, type, 0, &bag_default_tt, NULL); 41e1051a39Sopenharmony_ci 42e1051a39Sopenharmony_ciASN1_SEQUENCE(PKCS12_BAGS) = { 43e1051a39Sopenharmony_ci ASN1_SIMPLE(PKCS12_BAGS, type, ASN1_OBJECT), 44e1051a39Sopenharmony_ci ASN1_ADB_OBJECT(PKCS12_BAGS), 45e1051a39Sopenharmony_ci} ASN1_SEQUENCE_END(PKCS12_BAGS) 46e1051a39Sopenharmony_ci 47e1051a39Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(PKCS12_BAGS) 48e1051a39Sopenharmony_ci 49e1051a39Sopenharmony_ciASN1_ADB_TEMPLATE(safebag_default) = ASN1_EXP(PKCS12_SAFEBAG, value.other, ASN1_ANY, 0); 50e1051a39Sopenharmony_ci 51e1051a39Sopenharmony_ciASN1_ADB(PKCS12_SAFEBAG) = { 52e1051a39Sopenharmony_ci ADB_ENTRY(NID_keyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, PKCS8_PRIV_KEY_INFO, 0)), 53e1051a39Sopenharmony_ci ADB_ENTRY(NID_pkcs8ShroudedKeyBag, ASN1_EXP(PKCS12_SAFEBAG, value.shkeybag, X509_SIG, 0)), 54e1051a39Sopenharmony_ci ADB_ENTRY(NID_safeContentsBag, ASN1_EXP_SEQUENCE_OF(PKCS12_SAFEBAG, value.safes, PKCS12_SAFEBAG, 0)), 55e1051a39Sopenharmony_ci ADB_ENTRY(NID_certBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)), 56e1051a39Sopenharmony_ci ADB_ENTRY(NID_crlBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)), 57e1051a39Sopenharmony_ci ADB_ENTRY(NID_secretBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)) 58e1051a39Sopenharmony_ci} ASN1_ADB_END(PKCS12_SAFEBAG, 0, type, 0, &safebag_default_tt, NULL); 59e1051a39Sopenharmony_ci 60e1051a39Sopenharmony_ciASN1_SEQUENCE(PKCS12_SAFEBAG) = { 61e1051a39Sopenharmony_ci ASN1_SIMPLE(PKCS12_SAFEBAG, type, ASN1_OBJECT), 62e1051a39Sopenharmony_ci ASN1_ADB_OBJECT(PKCS12_SAFEBAG), 63e1051a39Sopenharmony_ci ASN1_SET_OF_OPT(PKCS12_SAFEBAG, attrib, X509_ATTRIBUTE) 64e1051a39Sopenharmony_ci} ASN1_SEQUENCE_END(PKCS12_SAFEBAG) 65e1051a39Sopenharmony_ci 66e1051a39Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(PKCS12_SAFEBAG) 67e1051a39Sopenharmony_ci 68e1051a39Sopenharmony_ci/* SEQUENCE OF SafeBag */ 69e1051a39Sopenharmony_ciASN1_ITEM_TEMPLATE(PKCS12_SAFEBAGS) = 70e1051a39Sopenharmony_ci ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, PKCS12_SAFEBAGS, PKCS12_SAFEBAG) 71e1051a39Sopenharmony_ciASN1_ITEM_TEMPLATE_END(PKCS12_SAFEBAGS) 72e1051a39Sopenharmony_ci 73e1051a39Sopenharmony_ci/* Authsafes: SEQUENCE OF PKCS7 */ 74e1051a39Sopenharmony_ciASN1_ITEM_TEMPLATE(PKCS12_AUTHSAFES) = 75e1051a39Sopenharmony_ci ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, PKCS12_AUTHSAFES, PKCS7) 76e1051a39Sopenharmony_ciASN1_ITEM_TEMPLATE_END(PKCS12_AUTHSAFES) 77