security/nss/lib/pkcs12/p12.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     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/. */
     6 #ifndef _P12_H_
     7 #define _P12_H_
     9 #include "secoid.h"
    10 #include "key.h"
    11 #include "secpkcs7.h"
    12 #include "p12t.h"
    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);
    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);
    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;
    58 struct sec_PKCS12PasswordModeInfo {
    59     SECItem	*password;
    60     SECOidTag	algorithm;
    61 };
    63 struct sec_PKCS12PublicKeyModeInfo {
    64     CERTCertificate	*cert;
    65     CERTCertDBHandle *certDb;
    66     SECOidTag	algorithm;
    67     int keySize;
    68 };
    70 struct SEC_PKCS12DecoderItemStr {
    71     SECItem *der;
    72     SECOidTag type;
    73     PRBool hasKey;
    74     SECItem *friendlyName;      /* UTF-8 string */
    75     SECAlgorithmID *shroudAlg;
    76 };
    79 SEC_BEGIN_PROTOS
    81 SEC_PKCS12SafeInfo *
    82 SEC_PKCS12CreatePubKeyEncryptedSafe(SEC_PKCS12ExportContext *p12ctxt,
    83 				    CERTCertDBHandle *certDb,
    84 				    CERTCertificate *signer,
    85 				    CERTCertificate **recipients,
    86 				    SECOidTag algorithm, int keysize);
    88 extern SEC_PKCS12SafeInfo *
    89 SEC_PKCS12CreatePasswordPrivSafe(SEC_PKCS12ExportContext *p12ctxt, 
    90 				 SECItem *pwitem, SECOidTag privAlg);
    92 extern SEC_PKCS12SafeInfo *
    93 SEC_PKCS12CreateUnencryptedSafe(SEC_PKCS12ExportContext *p12ctxt);
    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);
   103 extern SEC_PKCS12ExportContext *
   104 SEC_PKCS12CreateExportContext(SECKEYGetPasswordKey pwfn, void *pwfnarg,  
   105 			      PK11SlotInfo *slot, void *wincx);
   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);
   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);
   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);
   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);
   136 extern void *
   137 SEC_PKCS12CreateNestedSafeContents(SEC_PKCS12ExportContext *p12ctxt,
   138 				   void *baseSafe, void *nestedDest);
   140 extern SECStatus
   141 SEC_PKCS12Encode(SEC_PKCS12ExportContext *p12exp, 
   142 		 SEC_PKCS12EncoderOutputCallback output, void *outputarg);
   144 extern void
   145 SEC_PKCS12DestroyExportContext(SEC_PKCS12ExportContext *p12exp);
   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);
   152 extern SECStatus
   153 SEC_PKCS12DecoderSetTargetTokenCAs(SEC_PKCS12DecoderContext *p12dcx,
   154                 		   SECPKCS12TargetTokenCAs tokenCAs);
   156 extern SECStatus
   157 SEC_PKCS12DecoderUpdate(SEC_PKCS12DecoderContext *p12dcx, unsigned char *data,
   158 			unsigned long len);
   160 extern void
   161 SEC_PKCS12DecoderFinish(SEC_PKCS12DecoderContext *p12dcx);
   163 extern SECStatus
   164 SEC_PKCS12DecoderVerify(SEC_PKCS12DecoderContext *p12dcx);
   166 extern SECStatus
   167 SEC_PKCS12DecoderValidateBags(SEC_PKCS12DecoderContext *p12dcx,
   168 			      SEC_PKCS12NicknameCollisionCallback nicknameCb);
   170 extern SECStatus
   171 SEC_PKCS12DecoderImportBags(SEC_PKCS12DecoderContext *p12dcx);
   173 CERTCertList *
   174 SEC_PKCS12DecoderGetCerts(SEC_PKCS12DecoderContext *p12dcx);
   176 SECStatus
   177 SEC_PKCS12DecoderIterateInit(SEC_PKCS12DecoderContext *p12dcx);
   179 SECStatus
   180 SEC_PKCS12DecoderIterateNext(SEC_PKCS12DecoderContext *p12dcx,
   181                              const SEC_PKCS12DecoderItem **ipp);
   183 SEC_END_PROTOS
   185 #endif

mercurial