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