11cb0ef41Sopenharmony_ci/* 21cb0ef41Sopenharmony_ci * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. 31cb0ef41Sopenharmony_ci * 41cb0ef41Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 51cb0ef41Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 61cb0ef41Sopenharmony_ci * in the file LICENSE in the source distribution or at 71cb0ef41Sopenharmony_ci * https://www.openssl.org/source/license.html 81cb0ef41Sopenharmony_ci */ 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci#include <stdio.h> 111cb0ef41Sopenharmony_ci#include "internal/cryptlib.h" 121cb0ef41Sopenharmony_ci#include <openssl/asn1t.h> 131cb0ef41Sopenharmony_ci#include <openssl/pkcs12.h> 141cb0ef41Sopenharmony_ci#include "p12_local.h" 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci/* PKCS#12 ASN1 module */ 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciASN1_SEQUENCE(PKCS12) = { 191cb0ef41Sopenharmony_ci ASN1_SIMPLE(PKCS12, version, ASN1_INTEGER), 201cb0ef41Sopenharmony_ci ASN1_SIMPLE(PKCS12, authsafes, PKCS7), 211cb0ef41Sopenharmony_ci ASN1_OPT(PKCS12, mac, PKCS12_MAC_DATA) 221cb0ef41Sopenharmony_ci} ASN1_SEQUENCE_END(PKCS12) 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(PKCS12) 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciASN1_SEQUENCE(PKCS12_MAC_DATA) = { 271cb0ef41Sopenharmony_ci ASN1_SIMPLE(PKCS12_MAC_DATA, dinfo, X509_SIG), 281cb0ef41Sopenharmony_ci ASN1_SIMPLE(PKCS12_MAC_DATA, salt, ASN1_OCTET_STRING), 291cb0ef41Sopenharmony_ci ASN1_OPT(PKCS12_MAC_DATA, iter, ASN1_INTEGER) 301cb0ef41Sopenharmony_ci} ASN1_SEQUENCE_END(PKCS12_MAC_DATA) 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(PKCS12_MAC_DATA) 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ciASN1_ADB_TEMPLATE(bag_default) = ASN1_EXP(PKCS12_BAGS, value.other, ASN1_ANY, 0); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ciASN1_ADB(PKCS12_BAGS) = { 371cb0ef41Sopenharmony_ci ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.x509cert, ASN1_OCTET_STRING, 0)), 381cb0ef41Sopenharmony_ci ADB_ENTRY(NID_x509Crl, ASN1_EXP(PKCS12_BAGS, value.x509crl, ASN1_OCTET_STRING, 0)), 391cb0ef41Sopenharmony_ci ADB_ENTRY(NID_sdsiCertificate, ASN1_EXP(PKCS12_BAGS, value.sdsicert, ASN1_IA5STRING, 0)), 401cb0ef41Sopenharmony_ci} ASN1_ADB_END(PKCS12_BAGS, 0, type, 0, &bag_default_tt, NULL); 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ciASN1_SEQUENCE(PKCS12_BAGS) = { 431cb0ef41Sopenharmony_ci ASN1_SIMPLE(PKCS12_BAGS, type, ASN1_OBJECT), 441cb0ef41Sopenharmony_ci ASN1_ADB_OBJECT(PKCS12_BAGS), 451cb0ef41Sopenharmony_ci} ASN1_SEQUENCE_END(PKCS12_BAGS) 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(PKCS12_BAGS) 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ciASN1_ADB_TEMPLATE(safebag_default) = ASN1_EXP(PKCS12_SAFEBAG, value.other, ASN1_ANY, 0); 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ciASN1_ADB(PKCS12_SAFEBAG) = { 521cb0ef41Sopenharmony_ci ADB_ENTRY(NID_keyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, PKCS8_PRIV_KEY_INFO, 0)), 531cb0ef41Sopenharmony_ci ADB_ENTRY(NID_pkcs8ShroudedKeyBag, ASN1_EXP(PKCS12_SAFEBAG, value.shkeybag, X509_SIG, 0)), 541cb0ef41Sopenharmony_ci ADB_ENTRY(NID_safeContentsBag, ASN1_EXP_SEQUENCE_OF(PKCS12_SAFEBAG, value.safes, PKCS12_SAFEBAG, 0)), 551cb0ef41Sopenharmony_ci ADB_ENTRY(NID_certBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)), 561cb0ef41Sopenharmony_ci ADB_ENTRY(NID_crlBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)), 571cb0ef41Sopenharmony_ci ADB_ENTRY(NID_secretBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)) 581cb0ef41Sopenharmony_ci} ASN1_ADB_END(PKCS12_SAFEBAG, 0, type, 0, &safebag_default_tt, NULL); 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ciASN1_SEQUENCE(PKCS12_SAFEBAG) = { 611cb0ef41Sopenharmony_ci ASN1_SIMPLE(PKCS12_SAFEBAG, type, ASN1_OBJECT), 621cb0ef41Sopenharmony_ci ASN1_ADB_OBJECT(PKCS12_SAFEBAG), 631cb0ef41Sopenharmony_ci ASN1_SET_OF_OPT(PKCS12_SAFEBAG, attrib, X509_ATTRIBUTE) 641cb0ef41Sopenharmony_ci} ASN1_SEQUENCE_END(PKCS12_SAFEBAG) 651cb0ef41Sopenharmony_ci 661cb0ef41Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(PKCS12_SAFEBAG) 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ci/* SEQUENCE OF SafeBag */ 691cb0ef41Sopenharmony_ciASN1_ITEM_TEMPLATE(PKCS12_SAFEBAGS) = 701cb0ef41Sopenharmony_ci ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, PKCS12_SAFEBAGS, PKCS12_SAFEBAG) 711cb0ef41Sopenharmony_ciASN1_ITEM_TEMPLATE_END(PKCS12_SAFEBAGS) 721cb0ef41Sopenharmony_ci 731cb0ef41Sopenharmony_ci/* Authsafes: SEQUENCE OF PKCS7 */ 741cb0ef41Sopenharmony_ciASN1_ITEM_TEMPLATE(PKCS12_AUTHSAFES) = 751cb0ef41Sopenharmony_ci ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, PKCS12_AUTHSAFES, PKCS7) 761cb0ef41Sopenharmony_ciASN1_ITEM_TEMPLATE_END(PKCS12_AUTHSAFES) 77