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 | * These functions to be implemented in the future if the features |
michael@0 | 7 | * which these functions would implement wind up being needed. |
michael@0 | 8 | */ |
michael@0 | 9 | |
michael@0 | 10 | /* |
michael@0 | 11 | * Use this function to create the CRMFSinglePubInfo* variables that will |
michael@0 | 12 | * populate the inPubInfoArray parameter for the function |
michael@0 | 13 | * CRMF_CreatePKIPublicationInfo. |
michael@0 | 14 | * |
michael@0 | 15 | * "inPubMethod" specifies which publication method will be used |
michael@0 | 16 | * "pubLocation" is a representation of the location where |
michael@0 | 17 | */ |
michael@0 | 18 | extern CRMFSinglePubInfo* |
michael@0 | 19 | CRMF_CreateSinglePubInfo(CRMFPublicationMethod inPubMethod, |
michael@0 | 20 | CRMFGeneralName *pubLocation); |
michael@0 | 21 | |
michael@0 | 22 | /* |
michael@0 | 23 | * Create a PKIPublicationInfo that can later be passed to the function |
michael@0 | 24 | * CRMFAddPubInfoControl. |
michael@0 | 25 | */ |
michael@0 | 26 | extern CRMFPKIPublicationInfo * |
michael@0 | 27 | CRMF_CreatePKIPublicationInfo(CRMFPublicationAction inAction, |
michael@0 | 28 | CRMFSinglePubInfo **inPubInfoArray, |
michael@0 | 29 | int numPubInfo); |
michael@0 | 30 | |
michael@0 | 31 | /* |
michael@0 | 32 | * Only call this function on a CRMFPublicationInfo that was created by |
michael@0 | 33 | * CRMF_CreatePKIPublicationInfo that was passed in NULL for arena. |
michael@0 | 34 | */ |
michael@0 | 35 | |
michael@0 | 36 | extern SECStatus |
michael@0 | 37 | CRMF_DestroyPKIPublicationInfo(CRMFPKIPublicationInfo *inPubInfo); |
michael@0 | 38 | |
michael@0 | 39 | extern SECStatus CRMF_AddPubInfoControl(CRMFCertRequest *inCertReq, |
michael@0 | 40 | CRMFPKIPublicationInfo *inPubInfo); |
michael@0 | 41 | |
michael@0 | 42 | /* |
michael@0 | 43 | * This is to create a Cert ID Control which can later be added to |
michael@0 | 44 | * a certificate request. |
michael@0 | 45 | */ |
michael@0 | 46 | extern CRMFCertID* CRMF_CreateCertID(CRMFGeneralName *issuer, |
michael@0 | 47 | long serialNumber); |
michael@0 | 48 | |
michael@0 | 49 | extern SECStatus CRMF_DestroyCertID(CRMFCertID* certID); |
michael@0 | 50 | |
michael@0 | 51 | extern SECStatus CRMF_AddCertIDControl(CRMFCertRequest *inCertReq, |
michael@0 | 52 | CRMFCertID *certID); |
michael@0 | 53 | |
michael@0 | 54 | extern SECStatus |
michael@0 | 55 | CRMF_AddProtocolEncryptioKeyControl(CRMFCertRequest *inCertReq, |
michael@0 | 56 | CERTSubjectPublicKeyInfo *spki); |
michael@0 | 57 | |
michael@0 | 58 | /* |
michael@0 | 59 | * Add the ASCII Pairs Registration Info to the Certificate Request. |
michael@0 | 60 | * The SECItem must be an OCTET string representation. |
michael@0 | 61 | */ |
michael@0 | 62 | extern SECStatus |
michael@0 | 63 | CRMF_AddUTF8PairsRegInfo(CRMFCertRequest *inCertReq, |
michael@0 | 64 | SECItem *asciiPairs); |
michael@0 | 65 | |
michael@0 | 66 | /* |
michael@0 | 67 | * This takes a CertRequest and adds it to another CertRequest. |
michael@0 | 68 | */ |
michael@0 | 69 | extern SECStatus |
michael@0 | 70 | CRMF_AddCertReqToRegInfo(CRMFCertRequest *certReqToAddTo, |
michael@0 | 71 | CRMFCertRequest *certReqBeingAdded); |
michael@0 | 72 | |
michael@0 | 73 | /* |
michael@0 | 74 | * Returns which option was used for the authInfo field of POPOSigningKeyInput |
michael@0 | 75 | */ |
michael@0 | 76 | extern CRMFPOPOSkiInputAuthChoice |
michael@0 | 77 | CRMF_GetSignKeyInputAuthChoice(CRMFPOPOSigningKeyInput *inKeyInput); |
michael@0 | 78 | |
michael@0 | 79 | /* |
michael@0 | 80 | * Gets the PKMACValue associated with the POPOSigningKeyInput. |
michael@0 | 81 | * If the POPOSigningKeyInput did not use authInfo.publicKeyMAC |
michael@0 | 82 | * the function returns SECFailure and the value at *destValue is unchanged. |
michael@0 | 83 | * |
michael@0 | 84 | * If the POPOSigningKeyInput did use authInfo.publicKeyMAC, the function |
michael@0 | 85 | * returns SECSuccess and places the PKMACValue at *destValue. |
michael@0 | 86 | */ |
michael@0 | 87 | extern SECStatus |
michael@0 | 88 | CRMF_GetSignKeyInputPKMACValue(CRMFPOPOSigningKeyInput *inKeyInput, |
michael@0 | 89 | CRMFPKMACValue **destValue); |
michael@0 | 90 | /* |
michael@0 | 91 | * Gets the SubjectPublicKeyInfo from the POPOSigningKeyInput |
michael@0 | 92 | */ |
michael@0 | 93 | extern CERTSubjectPublicKeyInfo * |
michael@0 | 94 | CRMF_GetSignKeyInputPublicKey(CRMFPOPOSigningKeyInput *inKeyInput); |
michael@0 | 95 | |
michael@0 | 96 | |
michael@0 | 97 | /* |
michael@0 | 98 | * Return the value for the PKIPublicationInfo Control. |
michael@0 | 99 | * A return value of NULL indicates that the Control was |
michael@0 | 100 | * not a PKIPublicationInfo Control. Call |
michael@0 | 101 | * CRMF_DestroyPKIPublicationInfo on the return value when done |
michael@0 | 102 | * using the pointer. |
michael@0 | 103 | */ |
michael@0 | 104 | extern CRMFPKIPublicationInfo* CRMF_GetPKIPubInfo(CRMFControl *inControl); |
michael@0 | 105 | |
michael@0 | 106 | /* |
michael@0 | 107 | * Free up a CRMFPKIPublicationInfo structure. |
michael@0 | 108 | */ |
michael@0 | 109 | extern SECStatus |
michael@0 | 110 | CRMF_DestroyPKIPublicationInfo(CRMFPKIPublicationInfo *inPubInfo); |
michael@0 | 111 | |
michael@0 | 112 | /* |
michael@0 | 113 | * Get the choice used for action in this PKIPublicationInfo. |
michael@0 | 114 | */ |
michael@0 | 115 | extern CRMFPublicationAction |
michael@0 | 116 | CRMF_GetPublicationAction(CRMFPKIPublicationInfo *inPubInfo); |
michael@0 | 117 | |
michael@0 | 118 | /* |
michael@0 | 119 | * Get the number of pubInfos are stored in the PKIPubicationInfo. |
michael@0 | 120 | */ |
michael@0 | 121 | extern int CRMF_GetNumPubInfos(CRMFPKIPublicationInfo *inPubInfo); |
michael@0 | 122 | |
michael@0 | 123 | /* |
michael@0 | 124 | * Get the pubInfo at index for the given PKIPubicationInfo. |
michael@0 | 125 | * Indexing is done like a traditional C Array. (0 .. numElements-1) |
michael@0 | 126 | */ |
michael@0 | 127 | extern CRMFSinglePubInfo* |
michael@0 | 128 | CRMF_GetPubInfoAtIndex(CRMFPKIPublicationInfo *inPubInfo, |
michael@0 | 129 | int index); |
michael@0 | 130 | |
michael@0 | 131 | /* |
michael@0 | 132 | * Destroy the CRMFSinglePubInfo. |
michael@0 | 133 | */ |
michael@0 | 134 | extern SECStatus CRMF_DestroySinglePubInfo(CRMFSinglePubInfo *inPubInfo); |
michael@0 | 135 | |
michael@0 | 136 | /* |
michael@0 | 137 | * Get the pubMethod used by the SinglePubInfo. |
michael@0 | 138 | */ |
michael@0 | 139 | extern CRMFPublicationMethod |
michael@0 | 140 | CRMF_GetPublicationMethod(CRMFSinglePubInfo *inPubInfo); |
michael@0 | 141 | |
michael@0 | 142 | /* |
michael@0 | 143 | * Get the pubLocation associated with the SinglePubInfo. |
michael@0 | 144 | * A NULL return value indicates there was no pubLocation associated |
michael@0 | 145 | * with the SinglePuInfo. |
michael@0 | 146 | */ |
michael@0 | 147 | extern CRMFGeneralName* CRMF_GetPubLocation(CRMFSinglePubInfo *inPubInfo); |
michael@0 | 148 | |
michael@0 | 149 | /* |
michael@0 | 150 | * Get the authInfo.sender field out of the POPOSigningKeyInput. |
michael@0 | 151 | * If the POPOSigningKeyInput did not use the authInfo the function |
michael@0 | 152 | * returns SECFailure and the value at *destName is unchanged. |
michael@0 | 153 | * |
michael@0 | 154 | * If the POPOSigningKeyInput did use authInfo.sender, the function returns |
michael@0 | 155 | * SECSuccess and puts the authInfo.sender at *destName/ |
michael@0 | 156 | */ |
michael@0 | 157 | extern SECStatus CRMF_GetSignKeyInputSender(CRMFPOPOSigningKeyInput *keyInput, |
michael@0 | 158 | CRMFGeneralName **destName); |
michael@0 | 159 | |
michael@0 | 160 | /**************** CMMF Functions that need to be added. **********************/ |
michael@0 | 161 | |
michael@0 | 162 | /* |
michael@0 | 163 | * FUNCTION: CMMF_POPODecKeyChallContentSetNextChallenge |
michael@0 | 164 | * INPUTS: |
michael@0 | 165 | * inDecKeyChall |
michael@0 | 166 | * The CMMFPOPODecKeyChallContent to operate on. |
michael@0 | 167 | * inRandom |
michael@0 | 168 | * The random number to use when generating the challenge, |
michael@0 | 169 | * inSender |
michael@0 | 170 | * The GeneralName representation of the sender of the challenge. |
michael@0 | 171 | * inPubKey |
michael@0 | 172 | * The public key to use when encrypting the challenge. |
michael@0 | 173 | * NOTES: |
michael@0 | 174 | * This function adds a challenge to the end of the list of challenges |
michael@0 | 175 | * contained by 'inDecKeyChall'. Refer to the CMMF draft on how the |
michael@0 | 176 | * the random number passed in and the sender's GeneralName are used |
michael@0 | 177 | * to generate the challenge and witness fields of the challenge. This |
michael@0 | 178 | * library will use SHA1 as the one-way function for generating the |
michael@0 | 179 | * witess field of the challenge. |
michael@0 | 180 | * |
michael@0 | 181 | * RETURN: |
michael@0 | 182 | * SECSuccess if generating the challenge and adding to the end of list |
michael@0 | 183 | * of challenges was successful. Any other return value indicates an error |
michael@0 | 184 | * while trying to generate the challenge. |
michael@0 | 185 | */ |
michael@0 | 186 | extern SECStatus |
michael@0 | 187 | CMMF_POPODecKeyChallContentSetNextChallenge |
michael@0 | 188 | (CMMFPOPODecKeyChallContent *inDecKeyChall, |
michael@0 | 189 | long inRandom, |
michael@0 | 190 | CERTGeneralName *inSender, |
michael@0 | 191 | SECKEYPublicKey *inPubKey); |
michael@0 | 192 | |
michael@0 | 193 | /* |
michael@0 | 194 | * FUNCTION: CMMF_POPODecKeyChallContentGetNumChallenges |
michael@0 | 195 | * INPUTS: |
michael@0 | 196 | * inKeyChallCont |
michael@0 | 197 | * The CMMFPOPODecKeyChallContent to operate on. |
michael@0 | 198 | * RETURN: |
michael@0 | 199 | * This function returns the number of CMMFChallenges are contained in |
michael@0 | 200 | * the CMMFPOPODecKeyChallContent structure. |
michael@0 | 201 | */ |
michael@0 | 202 | extern int CMMF_POPODecKeyChallContentGetNumChallenges |
michael@0 | 203 | (CMMFPOPODecKeyChallContent *inKeyChallCont); |
michael@0 | 204 | |
michael@0 | 205 | /* |
michael@0 | 206 | * FUNCTION: CMMF_ChallengeGetRandomNumber |
michael@0 | 207 | * INPUTS: |
michael@0 | 208 | * inChallenge |
michael@0 | 209 | * The CMMFChallenge to operate on. |
michael@0 | 210 | * inDest |
michael@0 | 211 | * A pointer to a user supplied buffer where the library |
michael@0 | 212 | * can place a copy of the random integer contatained in the |
michael@0 | 213 | * challenge. |
michael@0 | 214 | * NOTES: |
michael@0 | 215 | * This function returns the value held in the decrypted Rand structure |
michael@0 | 216 | * corresponding to the random integer. The user must call |
michael@0 | 217 | * CMMF_ChallengeDecryptWitness before calling this function. Call |
michael@0 | 218 | * CMMF_ChallengeIsDecrypted to find out if the challenge has been |
michael@0 | 219 | * decrypted. |
michael@0 | 220 | * |
michael@0 | 221 | * RETURN: |
michael@0 | 222 | * SECSuccess indicates the witness field has been previously decrypted |
michael@0 | 223 | * and the value for the random integer was successfully placed at *inDest. |
michael@0 | 224 | * Any other return value indicates an error and that the value at *inDest |
michael@0 | 225 | * is not a valid value. |
michael@0 | 226 | */ |
michael@0 | 227 | extern SECStatus CMMF_ChallengeGetRandomNumber(CMMFChallenge *inChallenge, |
michael@0 | 228 | long *inDest); |
michael@0 | 229 | |
michael@0 | 230 | /* |
michael@0 | 231 | * FUNCTION: CMMF_ChallengeGetSender |
michael@0 | 232 | * INPUTS: |
michael@0 | 233 | * inChallenge |
michael@0 | 234 | * the CMMFChallenge to operate on. |
michael@0 | 235 | * NOTES: |
michael@0 | 236 | * This function returns the value held in the decrypted Rand structure |
michael@0 | 237 | * corresponding to the sender. The user must call |
michael@0 | 238 | * CMMF_ChallengeDecryptWitness before calling this function. Call |
michael@0 | 239 | * CMMF_ChallengeIsDecrypted to find out if the witness field has been |
michael@0 | 240 | * decrypted. The user must call CERT_DestroyGeneralName after the return |
michael@0 | 241 | * value is no longer needed. |
michael@0 | 242 | * |
michael@0 | 243 | * RETURN: |
michael@0 | 244 | * A pointer to a copy of the sender CERTGeneralName. A return value of |
michael@0 | 245 | * NULL indicates an error in trying to copy the information or that the |
michael@0 | 246 | * witness field has not been decrypted. |
michael@0 | 247 | */ |
michael@0 | 248 | extern CERTGeneralName* CMMF_ChallengeGetSender(CMMFChallenge *inChallenge); |
michael@0 | 249 | |
michael@0 | 250 | /* |
michael@0 | 251 | * FUNCTION: CMMF_ChallengeGetAlgId |
michael@0 | 252 | * INPUTS: |
michael@0 | 253 | * inChallenge |
michael@0 | 254 | * The CMMFChallenge to operate on. |
michael@0 | 255 | * inDestAlgId |
michael@0 | 256 | * A pointer to memory where a pointer to a copy of the algorithm |
michael@0 | 257 | * id can be placed. |
michael@0 | 258 | * NOTES: |
michael@0 | 259 | * This function retrieves the one way function algorithm identifier |
michael@0 | 260 | * contained within the CMMFChallenge if the optional field is present. |
michael@0 | 261 | * |
michael@0 | 262 | * RETURN: |
michael@0 | 263 | * SECSucces indicates the function was able to place a pointer to a copy of |
michael@0 | 264 | * the alogrithm id at *inAlgId. If the value at *inDestAlgId is NULL, |
michael@0 | 265 | * that means there was no algorithm identifier present in the |
michael@0 | 266 | * CMMFChallenge. Any other return value indicates the function was not |
michael@0 | 267 | * able to make a copy of the algorithm identifier. In this case the value |
michael@0 | 268 | * at *inDestAlgId is not valid. |
michael@0 | 269 | */ |
michael@0 | 270 | extern SECStatus CMMF_ChallengeGetAlgId(CMMFChallenge *inChallenge, |
michael@0 | 271 | SECAlgorithmID *inAlgId); |
michael@0 | 272 | |
michael@0 | 273 | /* |
michael@0 | 274 | * FUNCTION: CMMF_DestroyChallenge |
michael@0 | 275 | * INPUTS: |
michael@0 | 276 | * inChallenge |
michael@0 | 277 | * The CMMFChallenge to free up. |
michael@0 | 278 | * NOTES: |
michael@0 | 279 | * This function frees up all the memory associated with the CMMFChallenge |
michael@0 | 280 | * passed in. |
michael@0 | 281 | * RETURN: |
michael@0 | 282 | * SECSuccess if freeing all the memory associated with the CMMFChallenge |
michael@0 | 283 | * passed in is successful. Any other return value indicates an error |
michael@0 | 284 | * while freeing the memory. |
michael@0 | 285 | */ |
michael@0 | 286 | extern SECStatus CMMF_DestroyChallenge (CMMFChallenge *inChallenge); |
michael@0 | 287 | |
michael@0 | 288 | /* |
michael@0 | 289 | * FUNCTION: CMMF_DestroyPOPODecKeyRespContent |
michael@0 | 290 | * INPUTS: |
michael@0 | 291 | * inDecKeyResp |
michael@0 | 292 | * The CMMFPOPODecKeyRespContent structure to free. |
michael@0 | 293 | * NOTES: |
michael@0 | 294 | * This function frees up all the memory associate with the |
michael@0 | 295 | * CMMFPOPODecKeyRespContent. |
michael@0 | 296 | * |
michael@0 | 297 | * RETURN: |
michael@0 | 298 | * SECSuccess if freeint up all the memory associated with the |
michael@0 | 299 | * CMMFPOPODecKeyRespContent structure is successful. Any other |
michael@0 | 300 | * return value indicates an error while freeing the memory. |
michael@0 | 301 | */ |
michael@0 | 302 | extern SECStatus |
michael@0 | 303 | CMMF_DestroyPOPODecKeyRespContent(CMMFPOPODecKeyRespContent *inDecKeyResp); |
michael@0 | 304 | |
michael@0 | 305 | /* |
michael@0 | 306 | * FUNCTION: CMMF_ChallengeDecryptWitness |
michael@0 | 307 | * INPUTS: |
michael@0 | 308 | * inChallenge |
michael@0 | 309 | * The CMMFChallenge to operate on. |
michael@0 | 310 | * inPrivKey |
michael@0 | 311 | * The private key to use to decrypt the witness field. |
michael@0 | 312 | * NOTES: |
michael@0 | 313 | * This function uses the private key to decrypt the challenge field |
michael@0 | 314 | * contained in the CMMFChallenge. Make sure the private key matches the |
michael@0 | 315 | * public key that was used to encrypt the witness. The creator of |
michael@0 | 316 | * the challenge will most likely be an RA that has the public key |
michael@0 | 317 | * from a Cert request. So the private key should be the private key |
michael@0 | 318 | * associated with public key in that request. This function will also |
michael@0 | 319 | * verify the witness field of the challenge. |
michael@0 | 320 | * |
michael@0 | 321 | * RETURN: |
michael@0 | 322 | * SECSuccess if decrypting the witness field was successful. This does |
michael@0 | 323 | * not indicate that the decrypted data is valid, since the private key |
michael@0 | 324 | * passed in may not be the actual key needed to properly decrypt the |
michael@0 | 325 | * witness field. Meaning that there is a decrypted structure now, but |
michael@0 | 326 | * may be garbage because the private key was incorrect. |
michael@0 | 327 | * Any other return value indicates the function could not complete the |
michael@0 | 328 | * decryption process. |
michael@0 | 329 | */ |
michael@0 | 330 | extern SECStatus CMMF_ChallengeDecryptWitness(CMMFChallenge *inChallenge, |
michael@0 | 331 | SECKEYPrivateKey *inPrivKey); |
michael@0 | 332 | |
michael@0 | 333 | /* |
michael@0 | 334 | * FUNCTION: CMMF_ChallengeIsDecrypted |
michael@0 | 335 | * INPUTS: |
michael@0 | 336 | * inChallenge |
michael@0 | 337 | * The CMMFChallenge to operate on. |
michael@0 | 338 | * RETURN: |
michael@0 | 339 | * This is a predicate function that returns PR_TRUE if the decryption |
michael@0 | 340 | * process has already been performed. The function return PR_FALSE if |
michael@0 | 341 | * the decryption process has not been performed yet. |
michael@0 | 342 | */ |
michael@0 | 343 | extern PRBool CMMF_ChallengeIsDecrypted(CMMFChallenge *inChallenge); |
michael@0 | 344 | |
michael@0 | 345 | /* |
michael@0 | 346 | * FUNCTION: CMMF_DestroyPOPODecKeyChallContent |
michael@0 | 347 | * INPUTS: |
michael@0 | 348 | * inDecKeyCont |
michael@0 | 349 | * The CMMFPOPODecKeyChallContent to free |
michael@0 | 350 | * NOTES: |
michael@0 | 351 | * This function frees up all the memory associated with the |
michael@0 | 352 | * CMMFPOPODecKeyChallContent |
michael@0 | 353 | * RETURN: |
michael@0 | 354 | * SECSuccess if freeing up all the memory associatd with the |
michael@0 | 355 | * CMMFPOPODecKeyChallContent is successful. Any other return value |
michael@0 | 356 | * indicates an error while freeing the memory. |
michael@0 | 357 | * |
michael@0 | 358 | */ |
michael@0 | 359 | extern SECStatus |
michael@0 | 360 | CMMF_DestroyPOPODecKeyChallContent (CMMFPOPODecKeyChallContent *inDecKeyCont); |
michael@0 | 361 |