1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
19 * the Initial Developer. All Rights Reserved.
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
46 typedef int (PR_CALLBACK
* PKCS12OpenFunction
)(void *arg
);
47 typedef int (PR_CALLBACK
* PKCS12ReadFunction
)(void *arg
,
48 unsigned char *buffer
,
49 unsigned int *lenRead
,
51 typedef int (PR_CALLBACK
* PKCS12WriteFunction
)(void *arg
,
52 unsigned char *buffer
,
54 unsigned int *lenWritten
);
55 typedef int (PR_CALLBACK
* PKCS12CloseFunction
)(void *arg
);
56 typedef SECStatus (PR_CALLBACK
* PKCS12UnicodeConvertFunction
)(
58 SECItem
*dest
, SECItem
*src
,
61 typedef void (PR_CALLBACK
* SEC_PKCS12EncoderOutputCallback
)(
62 void *arg
, const char *buf
,
64 typedef void (PR_CALLBACK
* SEC_PKCS12DecoderOutputCallback
)(
65 void *arg
, const char *buf
,
67 typedef SECItem
* (PR_CALLBACK
* SEC_PKCS12NicknameCollisionCallback
)(
68 SECItem
*old_nickname
,
75 typedef SECStatus (PR_CALLBACK
*digestOpenFn
)(void *arg
, PRBool readData
);
76 typedef SECStatus (PR_CALLBACK
*digestCloseFn
)(void *arg
, PRBool removeFile
);
77 typedef int (PR_CALLBACK
*digestIOFn
)(void *arg
, unsigned char *buf
,
80 typedef struct SEC_PKCS12ExportContextStr SEC_PKCS12ExportContext
;
81 typedef struct SEC_PKCS12SafeInfoStr SEC_PKCS12SafeInfo
;
82 typedef struct SEC_PKCS12DecoderContextStr SEC_PKCS12DecoderContext
;
83 typedef struct SEC_PKCS12DecoderItemStr SEC_PKCS12DecoderItem
;
85 struct sec_PKCS12PasswordModeInfo
{
90 struct sec_PKCS12PublicKeyModeInfo
{
91 CERTCertificate
*cert
;
92 CERTCertDBHandle
*certDb
;
97 struct SEC_PKCS12DecoderItemStr
{
101 SECItem
*friendlyName
; /* UTF-8 string */
102 SECAlgorithmID
*shroudAlg
;
109 SEC_PKCS12CreatePubKeyEncryptedSafe(SEC_PKCS12ExportContext
*p12ctxt
,
110 CERTCertDBHandle
*certDb
,
111 CERTCertificate
*signer
,
112 CERTCertificate
**recipients
,
113 SECOidTag algorithm
, int keysize
);
115 extern SEC_PKCS12SafeInfo
*
116 SEC_PKCS12CreatePasswordPrivSafe(SEC_PKCS12ExportContext
*p12ctxt
,
117 SECItem
*pwitem
, SECOidTag privAlg
);
119 extern SEC_PKCS12SafeInfo
*
120 SEC_PKCS12CreateUnencryptedSafe(SEC_PKCS12ExportContext
*p12ctxt
);
123 SEC_PKCS12AddPasswordIntegrity(SEC_PKCS12ExportContext
*p12ctxt
,
124 SECItem
*pwitem
, SECOidTag integAlg
);
126 SEC_PKCS12AddPublicKeyIntegrity(SEC_PKCS12ExportContext
*p12ctxt
,
127 CERTCertificate
*cert
, CERTCertDBHandle
*certDb
,
128 SECOidTag algorithm
, int keySize
);
130 extern SEC_PKCS12ExportContext
*
131 SEC_PKCS12CreateExportContext(SECKEYGetPasswordKey pwfn
, void *pwfnarg
,
132 PK11SlotInfo
*slot
, void *wincx
);
135 SEC_PKCS12AddCert(SEC_PKCS12ExportContext
*p12ctxt
,
136 SEC_PKCS12SafeInfo
*safe
, void *nestedDest
,
137 CERTCertificate
*cert
, CERTCertDBHandle
*certDb
,
138 SECItem
*keyId
, PRBool includeCertChain
);
141 SEC_PKCS12AddKeyForCert(SEC_PKCS12ExportContext
*p12ctxt
,
142 SEC_PKCS12SafeInfo
*safe
,
143 void *nestedDest
, CERTCertificate
*cert
,
144 PRBool shroudKey
, SECOidTag algorithm
, SECItem
*pwitem
,
145 SECItem
*keyId
, SECItem
*nickName
);
148 SEC_PKCS12AddCertOrChainAndKey(SEC_PKCS12ExportContext
*p12ctxt
,
149 void *certSafe
, void *certNestedDest
,
150 CERTCertificate
*cert
, CERTCertDBHandle
*certDb
,
151 void *keySafe
, void *keyNestedDest
, PRBool shroudKey
,
152 SECItem
*pwitem
, SECOidTag algorithm
,
153 PRBool includeCertChain
);
157 SEC_PKCS12AddCertAndKey(SEC_PKCS12ExportContext
*p12ctxt
,
158 void *certSafe
, void *certNestedDest
,
159 CERTCertificate
*cert
, CERTCertDBHandle
*certDb
,
160 void *keySafe
, void *keyNestedDest
,
161 PRBool shroudKey
, SECItem
*pwitem
, SECOidTag algorithm
);
164 SEC_PKCS12CreateNestedSafeContents(SEC_PKCS12ExportContext
*p12ctxt
,
165 void *baseSafe
, void *nestedDest
);
168 SEC_PKCS12Encode(SEC_PKCS12ExportContext
*p12exp
,
169 SEC_PKCS12EncoderOutputCallback output
, void *outputarg
);
172 SEC_PKCS12DestroyExportContext(SEC_PKCS12ExportContext
*p12exp
);
174 extern SEC_PKCS12DecoderContext
*
175 SEC_PKCS12DecoderStart(SECItem
*pwitem
, PK11SlotInfo
*slot
, void *wincx
,
176 digestOpenFn dOpen
, digestCloseFn dClose
,
177 digestIOFn dRead
, digestIOFn dWrite
, void *dArg
);
180 SEC_PKCS12DecoderSetTargetTokenCAs(SEC_PKCS12DecoderContext
*p12dcx
,
181 SECPKCS12TargetTokenCAs tokenCAs
);
184 SEC_PKCS12DecoderUpdate(SEC_PKCS12DecoderContext
*p12dcx
, unsigned char *data
,
188 SEC_PKCS12DecoderFinish(SEC_PKCS12DecoderContext
*p12dcx
);
191 SEC_PKCS12DecoderVerify(SEC_PKCS12DecoderContext
*p12dcx
);
194 SEC_PKCS12DecoderValidateBags(SEC_PKCS12DecoderContext
*p12dcx
,
195 SEC_PKCS12NicknameCollisionCallback nicknameCb
);
198 SEC_PKCS12DecoderImportBags(SEC_PKCS12DecoderContext
*p12dcx
);
201 SEC_PKCS12DecoderGetCerts(SEC_PKCS12DecoderContext
*p12dcx
);
204 SEC_PKCS12DecoderIterateInit(SEC_PKCS12DecoderContext
*p12dcx
);
207 SEC_PKCS12DecoderIterateNext(SEC_PKCS12DecoderContext
*p12dcx
,
208 const SEC_PKCS12DecoderItem
**ipp
);