1656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* pkcs12.h */ 2e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * project 1999. 4656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */ 5656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* ==================================================================== 6656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 7656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 8656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Redistribution and use in source and binary forms, with or without 9656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * modification, are permitted provided that the following conditions 10656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * are met: 11656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 12656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 1. Redistributions of source code must retain the above copyright 13656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * notice, this list of conditions and the following disclaimer. 14656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 15656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 16656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * notice, this list of conditions and the following disclaimer in 17656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * the documentation and/or other materials provided with the 18656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * distribution. 19656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 20656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 3. All advertising materials mentioning features or use of this 21656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * software must display the following acknowledgment: 22656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * "This product includes software developed by the OpenSSL Project 23656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 25656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * endorse or promote products derived from this software without 27656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * prior written permission. For written permission, please contact 28656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * licensing@OpenSSL.org. 29656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 30656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 5. Products derived from this software may not be called "OpenSSL" 31656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * nor may "OpenSSL" appear in their names without prior written 32656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * permission of the OpenSSL Project. 33656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 34656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 6. Redistributions of any form whatsoever must retain the following 35656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * acknowledgment: 36656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * "This product includes software developed by the OpenSSL Project 37656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 39656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * OF THE POSSIBILITY OF SUCH DAMAGE. 51656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * ==================================================================== 52656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 53656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * This product includes cryptographic software written by Eric Young 54656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * (eay@cryptsoft.com). This product includes software written by Tim 55656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Hudson (tjh@cryptsoft.com). 56656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 57656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */ 58656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 59656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef HEADER_PKCS12_H 60656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define HEADER_PKCS12_H 61656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 62656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <openssl/bio.h> 63656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <openssl/x509.h> 64656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 65656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef __cplusplus 66656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectextern "C" { 67656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif 68656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 69656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_KEY_ID 1 70656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_IV_ID 2 71656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_MAC_ID 3 72656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 73656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Default iteration count */ 74656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef PKCS12_DEFAULT_ITER 75656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER 76656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif 77656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 78656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_MAC_KEY_LENGTH 20 79656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 80656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_SALT_LEN 8 81656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 82656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Uncomment out next line for unicode password and names, otherwise ASCII */ 83656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 84656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/*#define PBE_UNICODE*/ 85656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 86656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef PBE_UNICODE 87656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_key_gen PKCS12_key_gen_uni 88656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni 89656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#else 90656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_key_gen PKCS12_key_gen_asc 91656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc 92656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif 93656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 94656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* MS key usage constants */ 95656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 96656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define KEY_EX 0x10 97656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define KEY_SIG 0x80 98656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 99656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct { 100656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectX509_SIG *dinfo; 101656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectASN1_OCTET_STRING *salt; 102656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectASN1_INTEGER *iter; /* defaults to 1 */ 103656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project} PKCS12_MAC_DATA; 104656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 105656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct { 106656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectASN1_INTEGER *version; 107656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12_MAC_DATA *mac; 108656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS7 *authsafes; 109656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project} PKCS12; 110656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 111656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct { 112656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectASN1_OBJECT *type; 113656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectunion { 114656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project struct pkcs12_bag_st *bag; /* secret, crl and certbag */ 115656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project struct pkcs8_priv_key_info_st *keybag; /* keybag */ 116656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project X509_SIG *shkeybag; /* shrouded key bag */ 117656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project STACK_OF(PKCS12_SAFEBAG) *safes; 118656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project ASN1_TYPE *other; 119656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project}value; 120656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectSTACK_OF(X509_ATTRIBUTE) *attrib; 121656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project} PKCS12_SAFEBAG; 122656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 123656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectDECLARE_STACK_OF(PKCS12_SAFEBAG) 124656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectDECLARE_ASN1_SET_OF(PKCS12_SAFEBAG) 125656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectDECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG) 126656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 127656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct pkcs12_bag_st { 128656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectASN1_OBJECT *type; 129656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectunion { 130656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project ASN1_OCTET_STRING *x509cert; 131656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project ASN1_OCTET_STRING *x509crl; 132656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project ASN1_OCTET_STRING *octet; 133656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project ASN1_IA5STRING *sdsicert; 134656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project ASN1_TYPE *other; /* Secret or other bag */ 135656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project}value; 136656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project} PKCS12_BAGS; 137656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 138656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_ERROR 0 139656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_OK 1 140656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 141656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Compatibility macros */ 142656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 143656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_x5092certbag PKCS12_x5092certbag 144656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag 145656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 146656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_certbag2x509 PKCS12_certbag2x509 147656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl 148656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 149656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_unpack_p7data PKCS12_unpack_p7data 150656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_pack_authsafes PKCS12_pack_authsafes 151656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes 152656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata 153656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 154656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_decrypt_skey PKCS12_decrypt_skey 155656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS8_decrypt PKCS8_decrypt 156656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 157656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type) 158656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type) 159656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type 160656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 161656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_get_attr(bag, attr_nid) \ 162656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project PKCS12_get_attr_gen(bag->attrib, attr_nid) 163656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 164656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS8_get_attr(p8, attr_nid) \ 165656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project PKCS12_get_attr_gen(p8->attributes, attr_nid) 166656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 167656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0) 168656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 169656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 170656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509); 171656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl); 172656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectX509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag); 173656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectX509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag); 174656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 175656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, 176656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int nid2); 177656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8); 178656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen); 179656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, 180656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int passlen); 181656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectX509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, 182656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project const char *pass, int passlen, 183656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project unsigned char *salt, int saltlen, int iter, 184656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project PKCS8_PRIV_KEY_INFO *p8); 185656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, 186656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int passlen, unsigned char *salt, 187656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int saltlen, int iter, 188656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project PKCS8_PRIV_KEY_INFO *p8); 189656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); 190656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7); 191656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, 192656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project unsigned char *salt, int saltlen, int iter, 193656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project STACK_OF(PKCS12_SAFEBAG) *bags); 194656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen); 195656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 196656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); 197656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectSTACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12); 198656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 199656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen); 200656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, 201656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int namelen); 202656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, 203656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int namelen); 204656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, 205656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int namelen); 206656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); 207656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid); 208656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectchar *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); 209656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectunsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, 210656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int passlen, unsigned char *in, int inlen, 211656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project unsigned char **data, int *datalen, int en_de); 212656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectvoid * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, 213656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf); 214656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, 215656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project const char *pass, int passlen, 216656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project void *obj, int zbuf); 217656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12 *PKCS12_init(int mode); 218656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, 219656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int saltlen, int id, int iter, int n, 220656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project unsigned char *out, const EVP_MD *md_type); 221656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type); 222656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 223656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type, 224656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int en_de); 225656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, 226656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project unsigned char *mac, unsigned int *maclen); 227656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); 228656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, 229656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project unsigned char *salt, int saltlen, int iter, 230656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project const EVP_MD *md_type); 231656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, 232656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int saltlen, const EVP_MD *md_type); 23398d58bb80c64b02a33662f0ea80351d4a1535267Brian Carlstromunsigned char *OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); 23498d58bb80c64b02a33662f0ea80351d4a1535267Brian Carlstromchar *OPENSSL_uni2asc(unsigned char *uni, int unilen); 235221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 236656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectDECLARE_ASN1_FUNCTIONS(PKCS12) 237656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectDECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) 238656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectDECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG) 239656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectDECLARE_ASN1_FUNCTIONS(PKCS12_BAGS) 240656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 241656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectDECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) 242656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectDECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) 243656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 244656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectvoid PKCS12_PBE_add(void); 245656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, 246656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project STACK_OF(X509) **ca); 247656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, 248656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, 249656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int mac_iter, int keytype); 250656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 251656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); 252656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, 253656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int key_usage, int iter, 254656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int key_nid, char *pass); 255656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, 256656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project int safe_nid, int iter, char *pass); 257656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); 258656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 259656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint i2d_PKCS12_bio(BIO *bp, PKCS12 *p12); 260656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); 261656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); 262656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectPKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); 263656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass); 264656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 265656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* BEGIN ERROR CODES */ 266656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* The following lines are auto generated by the script mkerr.pl. Any changes 267656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * made after this point may be overwritten when the script is next run. 268656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */ 269656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectvoid ERR_load_PKCS12_strings(void); 270656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 271656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Error codes for the PKCS12 functions. */ 272656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 273656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Function codes. */ 274656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PARSE_BAG 129 275656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PARSE_BAGS 103 276656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME 100 277656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC 127 278656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI 102 279656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_ADD_LOCALKEYID 104 280656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_CREATE 105 281656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_GEN_MAC 107 282656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_INIT 109 283656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106 284656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108 285656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117 286656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_KEY_GEN_ASC 110 287656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_KEY_GEN_UNI 111 288656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_MAKE_KEYBAG 112 289656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113 290656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_NEWPASS 128 291656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_PACK_P7DATA 114 292656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 293656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_PARSE 118 294656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_PBE_CRYPT 119 295656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_PBE_KEYIVGEN 120 296656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_SETUP_MAC 122 297656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_SET_MAC 123 298656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130 299656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_UNPACK_P7DATA 131 300656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS12_VERIFY_MAC 126 301656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS8_ADD_KEYUSAGE 124 302656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_F_PKCS8_ENCRYPT 125 303656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 304656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Reason codes. */ 305656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_CANT_PACK_STRUCTURE 100 306656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 307656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_DECODE_ERROR 101 308656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_ENCODE_ERROR 102 309656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_ENCRYPT_ERROR 103 310656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 311656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_INVALID_NULL_ARGUMENT 104 312656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 313656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_IV_GEN_ERROR 106 314656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_KEY_GEN_ERROR 107 315656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_MAC_ABSENT 108 316656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_MAC_GENERATION_ERROR 109 317656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_MAC_SETUP_ERROR 110 318656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_MAC_STRING_SET_ERROR 111 319656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_MAC_VERIFY_ERROR 112 320656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_MAC_VERIFY_FAILURE 113 321656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_PARSE_ERROR 114 322656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115 323656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 324656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117 325656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 326656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 327656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project 328656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef __cplusplus 329656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project} 330656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif 331656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif 332