summaryrefslogtreecommitdiff
path: root/security/nss/lib/pkcs12/p12t.h
blob: 6b9d3da1bbf030e1517651f293d2a8a0927c1bda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 * 
 * The Original Code is the Netscape security libraries.
 * 
 * The Initial Developer of the Original Code is Netscape
 * Communications Corporation.  Portions created by Netscape are 
 * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
 * Rights Reserved.
 * 
 * Contributor(s):
 * 
 * Alternatively, the contents of this file may be used under the
 * terms of the GNU General Public License Version 2 or later (the
 * "GPL"), in which case the provisions of the GPL are applicable 
 * instead of those above.  If you wish to allow use of your 
 * version of this file only under the terms of the GPL and not to
 * allow others to use your version of this file under the MPL,
 * indicate your decision by deleting the provisions above and
 * replace them with the notice and other provisions required by
 * the GPL.  If you do not delete the provisions above, a recipient
 * may use your version of this file under either the MPL or the
 * GPL.
 */

#ifndef _P12T_H_
#define _P12T_H_

#include "secoid.h"
#include "key.h"
#include "pkcs11.h"
#include "secpkcs7.h"
#include "secdig.h"	/* for SGNDigestInfo */

#define SEC_PKCS12_VERSION	3

/* structure declarations */
typedef struct sec_PKCS12PFXItemStr sec_PKCS12PFXItem;
typedef struct sec_PKCS12MacDataStr sec_PKCS12MacData;
typedef struct sec_PKCS12AuthenticatedSafeStr sec_PKCS12AuthenticatedSafe;
typedef struct sec_PKCS12SafeContentsStr sec_PKCS12SafeContents;
typedef struct sec_PKCS12SafeBagStr sec_PKCS12SafeBag;
typedef struct sec_PKCS12PKCS8ShroudedKeyBagStr sec_PKCS12PKCS8ShroudedKeyBag;
typedef struct sec_PKCS12CertBagStr sec_PKCS12CertBag;
typedef struct sec_PKCS12CRLBagStr sec_PKCS12CRLBag;
typedef struct sec_PKCS12SecretBag sec_PKCS12SecretBag;
typedef struct sec_PKCS12AttributeStr sec_PKCS12Attribute;

struct sec_PKCS12CertBagStr {
    /* what type of cert is stored? */
    SECItem bagID;

    /* certificate information */
    union {
	SECItem x509Cert;
	SECItem SDSICert;
    } value;
};

struct sec_PKCS12CRLBagStr {
    /* what type of cert is stored? */
    SECItem bagID;

    /* certificate information */
    union {
	SECItem x509CRL;
    } value;
};

struct sec_PKCS12SecretBag {
    /* what type of secret? */
    SECItem secretType;

    /* secret information.  ssshhhh be vewy vewy quiet. */
    SECItem secretContent;
};

struct sec_PKCS12AttributeStr {
    SECItem attrType;
    SECItem **attrValue;
};

struct sec_PKCS12SafeBagStr {

    /* What type of bag are we using? */
    SECItem safeBagType;

    /* Dependent upon the type of bag being used. */
    union {
	SECKEYPrivateKeyInfo *pkcs8KeyBag;
	SECKEYEncryptedPrivateKeyInfo *pkcs8ShroudedKeyBag;
	sec_PKCS12CertBag *certBag;
	sec_PKCS12CRLBag *crlBag;
	sec_PKCS12SecretBag *secretBag;
	sec_PKCS12SafeContents *safeContents;
    } safeBagContent;

    sec_PKCS12Attribute **attribs;

    /* used locally */
    SECOidData *bagTypeTag;
    PRArenaPool *arena;
    unsigned int nAttribs;

    /* used for validation/importing */
    PRBool problem, noInstall, validated, hasKey, removeExisting, installed;
    int error;

    PRBool swapUnicodeBytes;
    PK11SlotInfo *slot;
    SECItem *pwitem;
    PRBool oldBagType;
};
    
struct sec_PKCS12SafeContentsStr {
    sec_PKCS12SafeBag **safeBags;
    SECItem **encodedSafeBags;
    
    /* used locally */
    PRArenaPool *arena;
    unsigned int bagCount;
};

struct sec_PKCS12MacDataStr {
    SGNDigestInfo safeMac;
    SECItem macSalt;
    SECItem iter;
};

struct sec_PKCS12PFXItemStr {

    SECItem version;

    /* Content type will either be Data (password integrity mode)
     * or signedData (public-key integrity mode)
     */
    SEC_PKCS7ContentInfo *authSafe;
    SECItem encodedAuthSafe;

    /* Only present in password integrity mode */
    sec_PKCS12MacData macData;
    SECItem encodedMacData;
};

struct sec_PKCS12AuthenticatedSafeStr {
    /* Content type will either be encryptedData (password privacy mode)
     * or envelopedData (public-key privacy mode)
     */
    SEC_PKCS7ContentInfo **safes;
    SECItem **encodedSafes;

    /* used locally */
    unsigned int safeCount;
    SECItem dummySafe;
};

extern const SEC_ASN1Template sec_PKCS12PFXItemTemplate[];
extern const SEC_ASN1Template sec_PKCS12MacDataTemplate[];
extern const SEC_ASN1Template sec_PKCS12AuthenticatedSafeTemplate[];
extern const SEC_ASN1Template sec_PKCS12SafeContentsTemplate[];
extern const SEC_ASN1Template sec_PKCS12SafeContentsDecodeTemplate[];
extern const SEC_ASN1Template sec_PKCS12NestedSafeContentsDecodeTemplate[];
extern const SEC_ASN1Template sec_PKCS12CertBagTemplate[];
extern const SEC_ASN1Template sec_PKCS12CRLBagTemplate[];
extern const SEC_ASN1Template sec_PKCS12SecretBagTemplate[];
extern const SEC_ASN1Template sec_PKCS12PointerToCertBagTemplate[];
extern const SEC_ASN1Template sec_PKCS12PointerToCRLBagTemplate[];
extern const SEC_ASN1Template sec_PKCS12PointerToSecretBagTemplate[];
extern const SEC_ASN1Template sec_PKCS12PointerToSafeContentsTemplate[];
extern const SEC_ASN1Template sec_PKCS12AttributeTemplate[];
extern const SEC_ASN1Template sec_PKCS12PointerToContentInfoTemplate[];
extern const SEC_ASN1Template sec_PKCS12SafeBagTemplate[];

#endif