PageRenderTime 63ms CodeModel.GetById 42ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 1ms

/gecko_api/include/p12.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 209 lines | 136 code | 38 blank | 35 comment | 0 complexity | 2c2dc8cebcf1dd80bd3f4d41e20b0bae MD5 | raw file
  1/* ***** BEGIN LICENSE BLOCK *****
  2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3 *
  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/
  8 *
  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
 12 * License.
 13 *
 14 * The Original Code is the Netscape security libraries.
 15 *
 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.
 20 *
 21 * Contributor(s):
 22 *
 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.
 34 *
 35 * ***** END LICENSE BLOCK ***** */
 36
 37
 38#ifndef _P12_H_
 39#define _P12_H_
 40
 41#include "secoid.h"
 42#include "key.h"
 43#include "secpkcs7.h"
 44#include "p12t.h"
 45
 46typedef int (PR_CALLBACK * PKCS12OpenFunction)(void *arg);
 47typedef int (PR_CALLBACK * PKCS12ReadFunction)(void *arg,
 48                                               unsigned char *buffer, 
 49                                               unsigned int *lenRead,
 50                                               unsigned int maxLen);
 51typedef int (PR_CALLBACK * PKCS12WriteFunction)(void *arg,
 52                                                unsigned char *buffer, 
 53                                                unsigned int *bufLen,
 54                                                unsigned int *lenWritten);
 55typedef int (PR_CALLBACK * PKCS12CloseFunction)(void *arg);
 56typedef SECStatus (PR_CALLBACK * PKCS12UnicodeConvertFunction)(
 57                                 PRArenaPool *arena,
 58                                 SECItem *dest, SECItem *src,
 59                                 PRBool toUnicode,
 60                                 PRBool swapBytes);
 61typedef void (PR_CALLBACK * SEC_PKCS12EncoderOutputCallback)(
 62                            void *arg, const char *buf,
 63                            unsigned long len);
 64typedef void (PR_CALLBACK * SEC_PKCS12DecoderOutputCallback)(
 65                            void *arg, const char *buf,
 66                            unsigned long len);
 67typedef SECItem * (PR_CALLBACK * SEC_PKCS12NicknameCollisionCallback)(
 68                                 SECItem *old_nickname,
 69                                 PRBool *cancel,
 70                                 void *arg);
 71
 72
 73
 74
 75typedef SECStatus (PR_CALLBACK *digestOpenFn)(void *arg, PRBool readData);
 76typedef SECStatus (PR_CALLBACK *digestCloseFn)(void *arg, PRBool removeFile);
 77typedef int (PR_CALLBACK *digestIOFn)(void *arg, unsigned char *buf, 
 78                                      unsigned long len);
 79
 80typedef struct SEC_PKCS12ExportContextStr SEC_PKCS12ExportContext;
 81typedef struct SEC_PKCS12SafeInfoStr SEC_PKCS12SafeInfo;
 82typedef struct SEC_PKCS12DecoderContextStr SEC_PKCS12DecoderContext;
 83typedef struct SEC_PKCS12DecoderItemStr SEC_PKCS12DecoderItem;
 84
 85struct sec_PKCS12PasswordModeInfo {
 86    SECItem	*password;
 87    SECOidTag	algorithm;
 88};
 89
 90struct sec_PKCS12PublicKeyModeInfo {
 91    CERTCertificate	*cert;
 92    CERTCertDBHandle *certDb;
 93    SECOidTag	algorithm;
 94    int keySize;
 95};
 96
 97struct SEC_PKCS12DecoderItemStr {
 98    SECItem *der;
 99    SECOidTag type;
100    PRBool hasKey;
101    SECItem *friendlyName;      /* UTF-8 string */
102    SECAlgorithmID *shroudAlg;
103};
104    
105
106SEC_BEGIN_PROTOS
107
108SEC_PKCS12SafeInfo *
109SEC_PKCS12CreatePubKeyEncryptedSafe(SEC_PKCS12ExportContext *p12ctxt,
110				    CERTCertDBHandle *certDb,
111				    CERTCertificate *signer,
112				    CERTCertificate **recipients,
113				    SECOidTag algorithm, int keysize);
114
115extern SEC_PKCS12SafeInfo *
116SEC_PKCS12CreatePasswordPrivSafe(SEC_PKCS12ExportContext *p12ctxt, 
117				 SECItem *pwitem, SECOidTag privAlg);
118
119extern SEC_PKCS12SafeInfo *
120SEC_PKCS12CreateUnencryptedSafe(SEC_PKCS12ExportContext *p12ctxt);
121
122extern SECStatus
123SEC_PKCS12AddPasswordIntegrity(SEC_PKCS12ExportContext *p12ctxt,
124			       SECItem *pwitem, SECOidTag integAlg);
125extern SECStatus
126SEC_PKCS12AddPublicKeyIntegrity(SEC_PKCS12ExportContext *p12ctxt,
127				CERTCertificate *cert, CERTCertDBHandle *certDb,
128				SECOidTag algorithm, int keySize);
129
130extern SEC_PKCS12ExportContext *
131SEC_PKCS12CreateExportContext(SECKEYGetPasswordKey pwfn, void *pwfnarg,  
132			      PK11SlotInfo *slot, void *wincx);
133
134extern SECStatus
135SEC_PKCS12AddCert(SEC_PKCS12ExportContext *p12ctxt, 
136		  SEC_PKCS12SafeInfo *safe, void *nestedDest,
137		  CERTCertificate *cert, CERTCertDBHandle *certDb,
138		  SECItem *keyId, PRBool includeCertChain);
139
140extern SECStatus
141SEC_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);
146
147extern SECStatus
148SEC_PKCS12AddCertAndKey(SEC_PKCS12ExportContext *p12ctxt, 
149			void *certSafe, void *certNestedDest, 
150			CERTCertificate *cert, CERTCertDBHandle *certDb,
151			void *keySafe, void *keyNestedDest, 
152			PRBool shroudKey, SECItem *pwitem, SECOidTag algorithm);
153
154extern SECStatus
155SEC_PKCS12AddDERCertAndEncryptedKey(SEC_PKCS12ExportContext *p12ctxt, 
156			void *certSafe, void *certNestedDest, SECItem *derCert,
157			void *keySafe, void *keyNestedDest, 
158			SECKEYEncryptedPrivateKeyInfo *epki, char *nickname);
159
160extern void *
161SEC_PKCS12CreateNestedSafeContents(SEC_PKCS12ExportContext *p12ctxt,
162				   void *baseSafe, void *nestedDest);
163
164extern SECStatus
165SEC_PKCS12Encode(SEC_PKCS12ExportContext *p12exp, 
166		 SEC_PKCS12EncoderOutputCallback output, void *outputarg);
167
168extern void
169SEC_PKCS12DestroyExportContext(SEC_PKCS12ExportContext *p12exp);
170
171extern SEC_PKCS12DecoderContext *
172SEC_PKCS12DecoderStart(SECItem *pwitem, PK11SlotInfo *slot, void *wincx,
173		       digestOpenFn dOpen, digestCloseFn dClose,
174		       digestIOFn dRead, digestIOFn dWrite, void *dArg);
175
176extern SECStatus
177SEC_PKCS12DecoderSetTargetTokenCAs(SEC_PKCS12DecoderContext *p12dcx,
178                		   SECPKCS12TargetTokenCAs tokenCAs);
179
180extern SECStatus
181SEC_PKCS12DecoderUpdate(SEC_PKCS12DecoderContext *p12dcx, unsigned char *data,
182			unsigned long len);
183
184extern void
185SEC_PKCS12DecoderFinish(SEC_PKCS12DecoderContext *p12dcx);
186
187extern SECStatus
188SEC_PKCS12DecoderVerify(SEC_PKCS12DecoderContext *p12dcx);
189
190extern SECStatus
191SEC_PKCS12DecoderValidateBags(SEC_PKCS12DecoderContext *p12dcx,
192			      SEC_PKCS12NicknameCollisionCallback nicknameCb);
193
194extern SECStatus
195SEC_PKCS12DecoderImportBags(SEC_PKCS12DecoderContext *p12dcx);
196
197CERTCertList *
198SEC_PKCS12DecoderGetCerts(SEC_PKCS12DecoderContext *p12dcx);
199
200SECStatus
201SEC_PKCS12DecoderIterateInit(SEC_PKCS12DecoderContext *p12dcx);
202
203SECStatus
204SEC_PKCS12DecoderIterateNext(SEC_PKCS12DecoderContext *p12dcx,
205                             const SEC_PKCS12DecoderItem **ipp);
206
207SEC_END_PROTOS
208
209#endif