security/nss/lib/pkcs12/p12.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/pkcs12/p12.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,185 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +
     1.9 +#ifndef _P12_H_
    1.10 +#define _P12_H_
    1.11 +
    1.12 +#include "secoid.h"
    1.13 +#include "key.h"
    1.14 +#include "secpkcs7.h"
    1.15 +#include "p12t.h"
    1.16 +
    1.17 +typedef int (PR_CALLBACK * PKCS12OpenFunction)(void *arg);
    1.18 +typedef int (PR_CALLBACK * PKCS12ReadFunction)(void *arg,
    1.19 +                                               unsigned char *buffer, 
    1.20 +                                               unsigned int *lenRead,
    1.21 +                                               unsigned int maxLen);
    1.22 +typedef int (PR_CALLBACK * PKCS12WriteFunction)(void *arg,
    1.23 +                                                unsigned char *buffer, 
    1.24 +                                                unsigned int *bufLen,
    1.25 +                                                unsigned int *lenWritten);
    1.26 +typedef int (PR_CALLBACK * PKCS12CloseFunction)(void *arg);
    1.27 +typedef SECStatus (PR_CALLBACK * PKCS12UnicodeConvertFunction)(
    1.28 +                                 PLArenaPool *arena,
    1.29 +                                 SECItem *dest, SECItem *src,
    1.30 +                                 PRBool toUnicode,
    1.31 +                                 PRBool swapBytes);
    1.32 +typedef void (PR_CALLBACK * SEC_PKCS12EncoderOutputCallback)(
    1.33 +                            void *arg, const char *buf,
    1.34 +                            unsigned long len);
    1.35 +typedef void (PR_CALLBACK * SEC_PKCS12DecoderOutputCallback)(
    1.36 +                            void *arg, const char *buf,
    1.37 +                            unsigned long len);
    1.38 +/*
    1.39 + * In NSS 3.12 or later, 'arg' actually points to a CERTCertificate,
    1.40 + * the 'leafCert' variable in sec_pkcs12_validate_cert in p12d.c. 
    1.41 + * See r1.35 of p12d.c ("Patch 2" in bug 321584).
    1.42 + */
    1.43 +typedef SECItem * (PR_CALLBACK * SEC_PKCS12NicknameCollisionCallback)(
    1.44 +                                 SECItem *old_nickname,
    1.45 +                                 PRBool *cancel,
    1.46 +                                 void *arg);
    1.47 +
    1.48 +
    1.49 +
    1.50 +
    1.51 +typedef SECStatus (PR_CALLBACK *digestOpenFn)(void *arg, PRBool readData);
    1.52 +typedef SECStatus (PR_CALLBACK *digestCloseFn)(void *arg, PRBool removeFile);
    1.53 +typedef int (PR_CALLBACK *digestIOFn)(void *arg, unsigned char *buf, 
    1.54 +                                      unsigned long len);
    1.55 +
    1.56 +typedef struct SEC_PKCS12ExportContextStr SEC_PKCS12ExportContext;
    1.57 +typedef struct SEC_PKCS12SafeInfoStr SEC_PKCS12SafeInfo;
    1.58 +typedef struct SEC_PKCS12DecoderContextStr SEC_PKCS12DecoderContext;
    1.59 +typedef struct SEC_PKCS12DecoderItemStr SEC_PKCS12DecoderItem;
    1.60 +
    1.61 +struct sec_PKCS12PasswordModeInfo {
    1.62 +    SECItem	*password;
    1.63 +    SECOidTag	algorithm;
    1.64 +};
    1.65 +
    1.66 +struct sec_PKCS12PublicKeyModeInfo {
    1.67 +    CERTCertificate	*cert;
    1.68 +    CERTCertDBHandle *certDb;
    1.69 +    SECOidTag	algorithm;
    1.70 +    int keySize;
    1.71 +};
    1.72 +
    1.73 +struct SEC_PKCS12DecoderItemStr {
    1.74 +    SECItem *der;
    1.75 +    SECOidTag type;
    1.76 +    PRBool hasKey;
    1.77 +    SECItem *friendlyName;      /* UTF-8 string */
    1.78 +    SECAlgorithmID *shroudAlg;
    1.79 +};
    1.80 +    
    1.81 +
    1.82 +SEC_BEGIN_PROTOS
    1.83 +
    1.84 +SEC_PKCS12SafeInfo *
    1.85 +SEC_PKCS12CreatePubKeyEncryptedSafe(SEC_PKCS12ExportContext *p12ctxt,
    1.86 +				    CERTCertDBHandle *certDb,
    1.87 +				    CERTCertificate *signer,
    1.88 +				    CERTCertificate **recipients,
    1.89 +				    SECOidTag algorithm, int keysize);
    1.90 +
    1.91 +extern SEC_PKCS12SafeInfo *
    1.92 +SEC_PKCS12CreatePasswordPrivSafe(SEC_PKCS12ExportContext *p12ctxt, 
    1.93 +				 SECItem *pwitem, SECOidTag privAlg);
    1.94 +
    1.95 +extern SEC_PKCS12SafeInfo *
    1.96 +SEC_PKCS12CreateUnencryptedSafe(SEC_PKCS12ExportContext *p12ctxt);
    1.97 +
    1.98 +extern SECStatus
    1.99 +SEC_PKCS12AddPasswordIntegrity(SEC_PKCS12ExportContext *p12ctxt,
   1.100 +			       SECItem *pwitem, SECOidTag integAlg);
   1.101 +extern SECStatus
   1.102 +SEC_PKCS12AddPublicKeyIntegrity(SEC_PKCS12ExportContext *p12ctxt,
   1.103 +				CERTCertificate *cert, CERTCertDBHandle *certDb,
   1.104 +				SECOidTag algorithm, int keySize);
   1.105 +
   1.106 +extern SEC_PKCS12ExportContext *
   1.107 +SEC_PKCS12CreateExportContext(SECKEYGetPasswordKey pwfn, void *pwfnarg,  
   1.108 +			      PK11SlotInfo *slot, void *wincx);
   1.109 +
   1.110 +extern SECStatus
   1.111 +SEC_PKCS12AddCert(SEC_PKCS12ExportContext *p12ctxt, 
   1.112 +		  SEC_PKCS12SafeInfo *safe, void *nestedDest,
   1.113 +		  CERTCertificate *cert, CERTCertDBHandle *certDb,
   1.114 +		  SECItem *keyId, PRBool includeCertChain);
   1.115 +
   1.116 +extern SECStatus
   1.117 +SEC_PKCS12AddKeyForCert(SEC_PKCS12ExportContext *p12ctxt, 
   1.118 +			SEC_PKCS12SafeInfo *safe, 
   1.119 +			void *nestedDest, CERTCertificate *cert,
   1.120 +			PRBool shroudKey, SECOidTag algorithm, SECItem *pwitem,
   1.121 +			SECItem *keyId, SECItem *nickName);
   1.122 +
   1.123 +extern SECStatus
   1.124 +SEC_PKCS12AddCertOrChainAndKey(SEC_PKCS12ExportContext *p12ctxt, 
   1.125 +			void *certSafe, void *certNestedDest, 
   1.126 +			CERTCertificate *cert, CERTCertDBHandle *certDb,
   1.127 +			void *keySafe, void *keyNestedDest, PRBool shroudKey, 
   1.128 +			SECItem *pwitem, SECOidTag algorithm,
   1.129 +			PRBool includeCertChain);
   1.130 +
   1.131 +
   1.132 +extern SECStatus
   1.133 +SEC_PKCS12AddCertAndKey(SEC_PKCS12ExportContext *p12ctxt, 
   1.134 +			void *certSafe, void *certNestedDest, 
   1.135 +			CERTCertificate *cert, CERTCertDBHandle *certDb,
   1.136 +			void *keySafe, void *keyNestedDest, 
   1.137 +			PRBool shroudKey, SECItem *pwitem, SECOidTag algorithm);
   1.138 +
   1.139 +extern void *
   1.140 +SEC_PKCS12CreateNestedSafeContents(SEC_PKCS12ExportContext *p12ctxt,
   1.141 +				   void *baseSafe, void *nestedDest);
   1.142 +
   1.143 +extern SECStatus
   1.144 +SEC_PKCS12Encode(SEC_PKCS12ExportContext *p12exp, 
   1.145 +		 SEC_PKCS12EncoderOutputCallback output, void *outputarg);
   1.146 +
   1.147 +extern void
   1.148 +SEC_PKCS12DestroyExportContext(SEC_PKCS12ExportContext *p12exp);
   1.149 +
   1.150 +extern SEC_PKCS12DecoderContext *
   1.151 +SEC_PKCS12DecoderStart(SECItem *pwitem, PK11SlotInfo *slot, void *wincx,
   1.152 +		       digestOpenFn dOpen, digestCloseFn dClose,
   1.153 +		       digestIOFn dRead, digestIOFn dWrite, void *dArg);
   1.154 +
   1.155 +extern SECStatus
   1.156 +SEC_PKCS12DecoderSetTargetTokenCAs(SEC_PKCS12DecoderContext *p12dcx,
   1.157 +                		   SECPKCS12TargetTokenCAs tokenCAs);
   1.158 +
   1.159 +extern SECStatus
   1.160 +SEC_PKCS12DecoderUpdate(SEC_PKCS12DecoderContext *p12dcx, unsigned char *data,
   1.161 +			unsigned long len);
   1.162 +
   1.163 +extern void
   1.164 +SEC_PKCS12DecoderFinish(SEC_PKCS12DecoderContext *p12dcx);
   1.165 +
   1.166 +extern SECStatus
   1.167 +SEC_PKCS12DecoderVerify(SEC_PKCS12DecoderContext *p12dcx);
   1.168 +
   1.169 +extern SECStatus
   1.170 +SEC_PKCS12DecoderValidateBags(SEC_PKCS12DecoderContext *p12dcx,
   1.171 +			      SEC_PKCS12NicknameCollisionCallback nicknameCb);
   1.172 +
   1.173 +extern SECStatus
   1.174 +SEC_PKCS12DecoderImportBags(SEC_PKCS12DecoderContext *p12dcx);
   1.175 +
   1.176 +CERTCertList *
   1.177 +SEC_PKCS12DecoderGetCerts(SEC_PKCS12DecoderContext *p12dcx);
   1.178 +
   1.179 +SECStatus
   1.180 +SEC_PKCS12DecoderIterateInit(SEC_PKCS12DecoderContext *p12dcx);
   1.181 +
   1.182 +SECStatus
   1.183 +SEC_PKCS12DecoderIterateNext(SEC_PKCS12DecoderContext *p12dcx,
   1.184 +                             const SEC_PKCS12DecoderItem **ipp);
   1.185 +
   1.186 +SEC_END_PROTOS
   1.187 +
   1.188 +#endif

mercurial