security/nss/lib/pkcs12/p12.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:f9855f4f5bb2
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
6 #ifndef _P12_H_
7 #define _P12_H_
8
9 #include "secoid.h"
10 #include "key.h"
11 #include "secpkcs7.h"
12 #include "p12t.h"
13
14 typedef int (PR_CALLBACK * PKCS12OpenFunction)(void *arg);
15 typedef int (PR_CALLBACK * PKCS12ReadFunction)(void *arg,
16 unsigned char *buffer,
17 unsigned int *lenRead,
18 unsigned int maxLen);
19 typedef int (PR_CALLBACK * PKCS12WriteFunction)(void *arg,
20 unsigned char *buffer,
21 unsigned int *bufLen,
22 unsigned int *lenWritten);
23 typedef int (PR_CALLBACK * PKCS12CloseFunction)(void *arg);
24 typedef SECStatus (PR_CALLBACK * PKCS12UnicodeConvertFunction)(
25 PLArenaPool *arena,
26 SECItem *dest, SECItem *src,
27 PRBool toUnicode,
28 PRBool swapBytes);
29 typedef void (PR_CALLBACK * SEC_PKCS12EncoderOutputCallback)(
30 void *arg, const char *buf,
31 unsigned long len);
32 typedef void (PR_CALLBACK * SEC_PKCS12DecoderOutputCallback)(
33 void *arg, const char *buf,
34 unsigned long len);
35 /*
36 * In NSS 3.12 or later, 'arg' actually points to a CERTCertificate,
37 * the 'leafCert' variable in sec_pkcs12_validate_cert in p12d.c.
38 * See r1.35 of p12d.c ("Patch 2" in bug 321584).
39 */
40 typedef SECItem * (PR_CALLBACK * SEC_PKCS12NicknameCollisionCallback)(
41 SECItem *old_nickname,
42 PRBool *cancel,
43 void *arg);
44
45
46
47
48 typedef SECStatus (PR_CALLBACK *digestOpenFn)(void *arg, PRBool readData);
49 typedef SECStatus (PR_CALLBACK *digestCloseFn)(void *arg, PRBool removeFile);
50 typedef int (PR_CALLBACK *digestIOFn)(void *arg, unsigned char *buf,
51 unsigned long len);
52
53 typedef struct SEC_PKCS12ExportContextStr SEC_PKCS12ExportContext;
54 typedef struct SEC_PKCS12SafeInfoStr SEC_PKCS12SafeInfo;
55 typedef struct SEC_PKCS12DecoderContextStr SEC_PKCS12DecoderContext;
56 typedef struct SEC_PKCS12DecoderItemStr SEC_PKCS12DecoderItem;
57
58 struct sec_PKCS12PasswordModeInfo {
59 SECItem *password;
60 SECOidTag algorithm;
61 };
62
63 struct sec_PKCS12PublicKeyModeInfo {
64 CERTCertificate *cert;
65 CERTCertDBHandle *certDb;
66 SECOidTag algorithm;
67 int keySize;
68 };
69
70 struct SEC_PKCS12DecoderItemStr {
71 SECItem *der;
72 SECOidTag type;
73 PRBool hasKey;
74 SECItem *friendlyName; /* UTF-8 string */
75 SECAlgorithmID *shroudAlg;
76 };
77
78
79 SEC_BEGIN_PROTOS
80
81 SEC_PKCS12SafeInfo *
82 SEC_PKCS12CreatePubKeyEncryptedSafe(SEC_PKCS12ExportContext *p12ctxt,
83 CERTCertDBHandle *certDb,
84 CERTCertificate *signer,
85 CERTCertificate **recipients,
86 SECOidTag algorithm, int keysize);
87
88 extern SEC_PKCS12SafeInfo *
89 SEC_PKCS12CreatePasswordPrivSafe(SEC_PKCS12ExportContext *p12ctxt,
90 SECItem *pwitem, SECOidTag privAlg);
91
92 extern SEC_PKCS12SafeInfo *
93 SEC_PKCS12CreateUnencryptedSafe(SEC_PKCS12ExportContext *p12ctxt);
94
95 extern SECStatus
96 SEC_PKCS12AddPasswordIntegrity(SEC_PKCS12ExportContext *p12ctxt,
97 SECItem *pwitem, SECOidTag integAlg);
98 extern SECStatus
99 SEC_PKCS12AddPublicKeyIntegrity(SEC_PKCS12ExportContext *p12ctxt,
100 CERTCertificate *cert, CERTCertDBHandle *certDb,
101 SECOidTag algorithm, int keySize);
102
103 extern SEC_PKCS12ExportContext *
104 SEC_PKCS12CreateExportContext(SECKEYGetPasswordKey pwfn, void *pwfnarg,
105 PK11SlotInfo *slot, void *wincx);
106
107 extern SECStatus
108 SEC_PKCS12AddCert(SEC_PKCS12ExportContext *p12ctxt,
109 SEC_PKCS12SafeInfo *safe, void *nestedDest,
110 CERTCertificate *cert, CERTCertDBHandle *certDb,
111 SECItem *keyId, PRBool includeCertChain);
112
113 extern SECStatus
114 SEC_PKCS12AddKeyForCert(SEC_PKCS12ExportContext *p12ctxt,
115 SEC_PKCS12SafeInfo *safe,
116 void *nestedDest, CERTCertificate *cert,
117 PRBool shroudKey, SECOidTag algorithm, SECItem *pwitem,
118 SECItem *keyId, SECItem *nickName);
119
120 extern SECStatus
121 SEC_PKCS12AddCertOrChainAndKey(SEC_PKCS12ExportContext *p12ctxt,
122 void *certSafe, void *certNestedDest,
123 CERTCertificate *cert, CERTCertDBHandle *certDb,
124 void *keySafe, void *keyNestedDest, PRBool shroudKey,
125 SECItem *pwitem, SECOidTag algorithm,
126 PRBool includeCertChain);
127
128
129 extern SECStatus
130 SEC_PKCS12AddCertAndKey(SEC_PKCS12ExportContext *p12ctxt,
131 void *certSafe, void *certNestedDest,
132 CERTCertificate *cert, CERTCertDBHandle *certDb,
133 void *keySafe, void *keyNestedDest,
134 PRBool shroudKey, SECItem *pwitem, SECOidTag algorithm);
135
136 extern void *
137 SEC_PKCS12CreateNestedSafeContents(SEC_PKCS12ExportContext *p12ctxt,
138 void *baseSafe, void *nestedDest);
139
140 extern SECStatus
141 SEC_PKCS12Encode(SEC_PKCS12ExportContext *p12exp,
142 SEC_PKCS12EncoderOutputCallback output, void *outputarg);
143
144 extern void
145 SEC_PKCS12DestroyExportContext(SEC_PKCS12ExportContext *p12exp);
146
147 extern SEC_PKCS12DecoderContext *
148 SEC_PKCS12DecoderStart(SECItem *pwitem, PK11SlotInfo *slot, void *wincx,
149 digestOpenFn dOpen, digestCloseFn dClose,
150 digestIOFn dRead, digestIOFn dWrite, void *dArg);
151
152 extern SECStatus
153 SEC_PKCS12DecoderSetTargetTokenCAs(SEC_PKCS12DecoderContext *p12dcx,
154 SECPKCS12TargetTokenCAs tokenCAs);
155
156 extern SECStatus
157 SEC_PKCS12DecoderUpdate(SEC_PKCS12DecoderContext *p12dcx, unsigned char *data,
158 unsigned long len);
159
160 extern void
161 SEC_PKCS12DecoderFinish(SEC_PKCS12DecoderContext *p12dcx);
162
163 extern SECStatus
164 SEC_PKCS12DecoderVerify(SEC_PKCS12DecoderContext *p12dcx);
165
166 extern SECStatus
167 SEC_PKCS12DecoderValidateBags(SEC_PKCS12DecoderContext *p12dcx,
168 SEC_PKCS12NicknameCollisionCallback nicknameCb);
169
170 extern SECStatus
171 SEC_PKCS12DecoderImportBags(SEC_PKCS12DecoderContext *p12dcx);
172
173 CERTCertList *
174 SEC_PKCS12DecoderGetCerts(SEC_PKCS12DecoderContext *p12dcx);
175
176 SECStatus
177 SEC_PKCS12DecoderIterateInit(SEC_PKCS12DecoderContext *p12dcx);
178
179 SECStatus
180 SEC_PKCS12DecoderIterateNext(SEC_PKCS12DecoderContext *p12dcx,
181 const SEC_PKCS12DecoderItem **ipp);
182
183 SEC_END_PROTOS
184
185 #endif

mercurial