security/nss/lib/crmf/cmmf.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C; tab-width: 8 -*-*/
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef _CMMF_H_
michael@0 7 #define _CMMF_H_
michael@0 8 /*
michael@0 9 * These are the functions exported by the security library for
michael@0 10 * implementing Certificate Management Message Formats (CMMF).
michael@0 11 *
michael@0 12 * This API is designed against July 1998 CMMF draft. Please read this
michael@0 13 * draft before trying to use this API in an application that use CMMF.
michael@0 14 */
michael@0 15 #include "seccomon.h"
michael@0 16 #include "cmmft.h"
michael@0 17 #include "crmf.h"
michael@0 18
michael@0 19 SEC_BEGIN_PROTOS
michael@0 20
michael@0 21 /******************* Creation Functions *************************/
michael@0 22
michael@0 23 /*
michael@0 24 * FUNCTION: CMMF_CreateCertRepContent
michael@0 25 * INPUTS:
michael@0 26 * NONE
michael@0 27 * NOTES:
michael@0 28 * This function will create an empty CMMFCertRepContent Structure.
michael@0 29 * The client of the library must set the CMMFCertResponses.
michael@0 30 * Call CMMF_CertRepContentSetCertResponse to accomplish this task.
michael@0 31 * If the client of the library also wants to include the chain of
michael@0 32 * CA certs required to make the certificates in CMMFCertResponse valid,
michael@0 33 * then the user must also set the caPubs field of CMMFCertRepContent.
michael@0 34 * Call CMMF_CertRepContentSetCAPubs to accomplish this. After setting
michael@0 35 * the desired fields, the user can then call CMMF_EncodeCertRepContent
michael@0 36 * to DER-encode the CertRepContent.
michael@0 37 * RETURN:
michael@0 38 * A pointer to the CMMFCertRepContent. A NULL return value indicates
michael@0 39 * an error in allocating memory or failure to initialize the structure.
michael@0 40 */
michael@0 41 extern CMMFCertRepContent* CMMF_CreateCertRepContent(void);
michael@0 42
michael@0 43 /*
michael@0 44 * FUNCTION: CMMF_CreateCertRepContentFromDER
michael@0 45 * INPUTS
michael@0 46 * db
michael@0 47 * The certificate database where the certificates will be placed.
michael@0 48 * The certificates will be placed in the temporary database associated
michael@0 49 * with the handle.
michael@0 50 * buf
michael@0 51 * A buffer to the DER-encoded CMMFCertRepContent
michael@0 52 * len
michael@0 53 * The length in bytes of the buffer 'buf'
michael@0 54 * NOTES:
michael@0 55 * This function passes the buffer to the ASN1 decoder and creates a
michael@0 56 * CMMFCertRepContent structure. The user must call
michael@0 57 * CMMF_DestroyCertRepContent after the return value is no longer needed.
michael@0 58 *
michael@0 59 * RETURN:
michael@0 60 * A pointer to the CMMFCertRepContent structure. A NULL return
michael@0 61 * value indicates the library was unable to parse the DER.
michael@0 62 */
michael@0 63 extern CMMFCertRepContent*
michael@0 64 CMMF_CreateCertRepContentFromDER(CERTCertDBHandle *db,
michael@0 65 const char *buf,
michael@0 66 long len);
michael@0 67
michael@0 68 /*
michael@0 69 * FUNCTION: CMMF_CreateCertResponse
michael@0 70 * INPUTS:
michael@0 71 * inCertReqId
michael@0 72 * The Certificate Request Id this response is for.
michael@0 73 * NOTES:
michael@0 74 * This creates a CMMFCertResponse. This response should correspond
michael@0 75 * to a request that was received via CRMF. From the CRMF message you
michael@0 76 * can get the Request Id to pass in as inCertReqId, in essence binding
michael@0 77 * a CMRFCertRequest message to the CMMFCertResponse created by this
michael@0 78 * function. If no requuest id is associated with the response to create
michael@0 79 * then the user should pass in -1 for 'inCertReqId'.
michael@0 80 *
michael@0 81 * RETURN:
michael@0 82 * A pointer to the new CMMFCertResponse corresponding to the request id
michael@0 83 * passed in. A NULL return value indicates an error while trying to
michael@0 84 * create the CMMFCertResponse.
michael@0 85 */
michael@0 86 extern CMMFCertResponse* CMMF_CreateCertResponse(long inCertReqId);
michael@0 87
michael@0 88 /*
michael@0 89 * FUNCTION: CMMF_CreateKeyRecRepContent
michael@0 90 * INPUTS:
michael@0 91 * NONE
michael@0 92 * NOTES:
michael@0 93 * This function creates a new empty CMMFKeyRecRepContent structure.
michael@0 94 * At the very minimum, the user must call
michael@0 95 * CMMF_KeyRecRepContentSetPKIStatusInfoStatus field to have an
michael@0 96 * encodable structure. Depending on what the response is, the user may
michael@0 97 * have to set other fields as well to properly build up the structure so
michael@0 98 * that it can be encoded. Refer to the CMMF draft for how to properly
michael@0 99 * set up a CMMFKeyRecRepContent. This is the structure that an RA returns
michael@0 100 * to an end entity when doing key recovery.
michael@0 101
michael@0 102 * The user must call CMMF_DestroyKeyRecRepContent when the return value
michael@0 103 * is no longer needed.
michael@0 104 * RETURN:
michael@0 105 * A pointer to the empty CMMFKeyRecRepContent. A return value of NULL
michael@0 106 * indicates an error in allocating memory or initializing the structure.
michael@0 107 */
michael@0 108 extern CMMFKeyRecRepContent *CMMF_CreateKeyRecRepContent(void);
michael@0 109
michael@0 110 /*
michael@0 111 * FUNCTION: CMMF_CreateKeyRecRepContentFromDER
michael@0 112 * INPUTS:
michael@0 113 * db
michael@0 114 * The handle for the certificate database where the decoded
michael@0 115 * certificates will be placed. The decoded certificates will
michael@0 116 * be placed in the temporary database associated with the
michael@0 117 * handle.
michael@0 118 * buf
michael@0 119 * A buffer contatining the DER-encoded CMMFKeyRecRepContent
michael@0 120 * len
michael@0 121 * The length in bytes of the buffer 'buf'
michael@0 122 * NOTES
michael@0 123 * This function passes the buffer to the ASN1 decoder and creates a
michael@0 124 * CMMFKeyRecRepContent structure.
michael@0 125 *
michael@0 126 * RETURN:
michael@0 127 * A pointer to the CMMFKeyRecRepContent structure. A NULL return
michael@0 128 * value indicates the library was unable to parse the DER.
michael@0 129 */
michael@0 130 extern CMMFKeyRecRepContent*
michael@0 131 CMMF_CreateKeyRecRepContentFromDER(CERTCertDBHandle *db,
michael@0 132 const char *buf,
michael@0 133 long len);
michael@0 134
michael@0 135 /*
michael@0 136 * FUNCTION: CMMF_CreatePOPODecKeyChallContent
michael@0 137 * INPUTS:
michael@0 138 * NONE
michael@0 139 * NOTES:
michael@0 140 * This function creates an empty CMMFPOPODecKeyChallContent. The user
michael@0 141 * must add the challenges individually specifying the random number to
michael@0 142 * be used and the public key to be used when creating each individual
michael@0 143 * challenge. User can accomplish this by calling the function
michael@0 144 * CMMF_POPODecKeyChallContentSetNextChallenge.
michael@0 145 * RETURN:
michael@0 146 * A pointer to a CMMFPOPODecKeyChallContent structure. Ther user can
michael@0 147 * then call CMMF_EncodePOPODecKeyChallContent passing in the return
michael@0 148 * value from this function after setting all of the challenges. A
michael@0 149 * return value of NULL indicates an error while creating the
michael@0 150 * CMMFPOPODecKeyChallContent structure.
michael@0 151 */
michael@0 152 extern CMMFPOPODecKeyChallContent*
michael@0 153 CMMF_CreatePOPODecKeyChallContent(void);
michael@0 154
michael@0 155 /*
michael@0 156 * FUNCTION: CMMF_CreatePOPODecKeyChallContentFromDER
michael@0 157 * INPUTS
michael@0 158 * buf
michael@0 159 * A buffer containing the DER-encoded CMMFPOPODecKeyChallContent
michael@0 160 * len
michael@0 161 * The length in bytes of the buffer 'buf'
michael@0 162 * NOTES:
michael@0 163 * This function passes the buffer to the ASN1 decoder and creates a
michael@0 164 * CMMFPOPODecKeyChallContent structure.
michael@0 165 *
michael@0 166 * RETURN:
michael@0 167 * A pointer to the CMMFPOPODecKeyChallContent structure. A NULL return
michael@0 168 * value indicates the library was unable to parse the DER.
michael@0 169 */
michael@0 170 extern CMMFPOPODecKeyChallContent*
michael@0 171 CMMF_CreatePOPODecKeyChallContentFromDER(const char *buf, long len);
michael@0 172
michael@0 173 /*
michael@0 174 * FUNCTION: CMMF_CreatePOPODecKeyRespContentFromDER
michael@0 175 * INPUTS:
michael@0 176 * buf
michael@0 177 * A buffer contatining the DER-encoded CMMFPOPODecKeyRespContent
michael@0 178 * len
michael@0 179 * The length in bytes of the buffer 'buf'
michael@0 180 * NOTES
michael@0 181 * This function passes the buffer to the ASN1 decoder and creates a
michael@0 182 * CMMFPOPODecKeyRespContent structure.
michael@0 183 *
michael@0 184 * RETURN:
michael@0 185 * A pointer to the CMMFPOPODecKeyRespContent structure. A NULL return
michael@0 186 * value indicates the library was unable to parse the DER.
michael@0 187 */
michael@0 188 extern CMMFPOPODecKeyRespContent*
michael@0 189 CMMF_CreatePOPODecKeyRespContentFromDER(const char *buf, long len);
michael@0 190
michael@0 191 /************************** Set Functions *************************/
michael@0 192
michael@0 193 /*
michael@0 194 * FUNCTION: CMMF_CertRepContentSetCertResponses
michael@0 195 * INPUTS:
michael@0 196 * inCertRepContent
michael@0 197 * The CMMFCertRepContent to operate on.
michael@0 198 * inCertResponses
michael@0 199 * An array of pointers to CMMFCertResponse structures to
michael@0 200 * add to the CMMFCertRepContent structure.
michael@0 201 * inNumResponses
michael@0 202 * The length of the array 'inCertResponses'
michael@0 203 * NOTES:
michael@0 204 * This function will add the CMMFCertResponse structure to the
michael@0 205 * CMMFCertRepContent passed in. The CMMFCertResponse field of
michael@0 206 * CMMFCertRepContent is required, so the client must call this function
michael@0 207 * before calling CMMF_EncodeCertRepContent. If the user calls
michael@0 208 * CMMF_EncodeCertRepContent before calling this function,
michael@0 209 * CMMF_EncodeCertRepContent will fail.
michael@0 210 *
michael@0 211 * RETURN:
michael@0 212 * SECSuccess if adding the CMMFCertResponses to the CMMFCertRepContent
michael@0 213 * structure was successful. Any other return value indicates an error
michael@0 214 * while trying to add the CMMFCertResponses.
michael@0 215 */
michael@0 216 extern SECStatus
michael@0 217 CMMF_CertRepContentSetCertResponses(CMMFCertRepContent *inCertRepContent,
michael@0 218 CMMFCertResponse **inCertResponses,
michael@0 219 int inNumResponses);
michael@0 220
michael@0 221 /*
michael@0 222 * FUNCTION: CMMF_CertRepContentSetCAPubs
michael@0 223 * INPUTS:
michael@0 224 * inCertRepContent
michael@0 225 * The CMMFCertRepContent to operate on.
michael@0 226 * inCAPubs
michael@0 227 * The certificate list which makes up the chain of CA certificates
michael@0 228 * required to make the issued cert valid.
michael@0 229 * NOTES:
michael@0 230 * This function will set the the certificates in the CA chain as part
michael@0 231 * of the CMMFCertRepContent. This field is an optional member of the
michael@0 232 * CMMFCertRepContent structure, so the client is not required to call
michael@0 233 * this function before calling CMMF_EncodeCertRepContent.
michael@0 234 *
michael@0 235 * RETURN:
michael@0 236 * SECSuccess if adding the 'inCAPubs' to the CERTRepContent was successful.
michael@0 237 * Any other return value indicates an error while adding 'inCAPubs' to the
michael@0 238 * CMMFCertRepContent structure.
michael@0 239 *
michael@0 240 */
michael@0 241 extern SECStatus
michael@0 242 CMMF_CertRepContentSetCAPubs (CMMFCertRepContent *inCertRepContent,
michael@0 243 CERTCertList *inCAPubs);
michael@0 244
michael@0 245 /*
michael@0 246 * FUNCTION: CMMF_CertResponseSetPKIStatusInfoStatus
michael@0 247 * INPUTS:
michael@0 248 * inCertResp
michael@0 249 * The CMMFCertResponse to operate on.
michael@0 250 * inPKIStatus
michael@0 251 * The value to set for the PKIStatusInfo.status field.
michael@0 252 * NOTES:
michael@0 253 * This function will set the CertResponse.status.status field of
michael@0 254 * the CMMFCertResponse structure. (View the definition of CertResponse
michael@0 255 * in the CMMF draft to see exactly which value this talks about.) This
michael@0 256 * field is a required member of the structure, so the user must call this
michael@0 257 * function in order to have a CMMFCertResponse that can be encoded.
michael@0 258 *
michael@0 259 * RETURN:
michael@0 260 * SECSuccess if setting the field with the passed in value was successful.
michael@0 261 * Any other return value indicates an error while trying to set the field.
michael@0 262 */
michael@0 263 extern SECStatus
michael@0 264 CMMF_CertResponseSetPKIStatusInfoStatus (CMMFCertResponse *inCertResp,
michael@0 265 CMMFPKIStatus inPKIStatus);
michael@0 266
michael@0 267 /*
michael@0 268 * FUNCTION: CMMF_CertResponseSetCertificate
michael@0 269 * INPUTS:
michael@0 270 * inCertResp
michael@0 271 * The CMMFCertResponse to operate on.
michael@0 272 * inCertificate
michael@0 273 * The certificate to add to the
michael@0 274 * CertResponse.CertifiedKeyPair.certOrEncCert.certificate field.
michael@0 275 * NOTES:
michael@0 276 * This function will take the certificate and make it a member of the
michael@0 277 * CMMFCertResponse. The certificate should be the actual certificate
michael@0 278 * being issued via the response.
michael@0 279 *
michael@0 280 * RETURN:
michael@0 281 * SECSuccess if adding the certificate to the response was successful.
michael@0 282 * Any other return value indicates an error in adding the certificate to
michael@0 283 * the CertResponse.
michael@0 284 */
michael@0 285 extern SECStatus
michael@0 286 CMMF_CertResponseSetCertificate (CMMFCertResponse *inCertResp,
michael@0 287 CERTCertificate *inCertificate);
michael@0 288
michael@0 289 /*
michael@0 290 * FUNCTION: CMMF_KeyRecRepContentSetPKIStatusInfoStatus
michael@0 291 * INPUTS:
michael@0 292 * inKeyRecRep
michael@0 293 * The CMMFKeyRecRepContent to operate on.
michael@0 294 * inPKIStatus
michael@0 295 * The value to set the PKIStatusInfo.status field to.
michael@0 296 * NOTES:
michael@0 297 * This function sets the only required field for the KeyRecRepContent.
michael@0 298 * In most cases, the user will set this field and other fields of the
michael@0 299 * structure to properly create the CMMFKeyRecRepContent structure.
michael@0 300 * Refer to the CMMF draft to see which fields need to be set in order
michael@0 301 * to create the desired CMMFKeyRecRepContent.
michael@0 302 *
michael@0 303 * RETURN:
michael@0 304 * SECSuccess if setting the PKIStatusInfo.status field was successful.
michael@0 305 * Any other return value indicates an error in setting the field.
michael@0 306 */
michael@0 307 extern SECStatus
michael@0 308 CMMF_KeyRecRepContentSetPKIStatusInfoStatus(CMMFKeyRecRepContent *inKeyRecRep,
michael@0 309 CMMFPKIStatus inPKIStatus);
michael@0 310
michael@0 311 /*
michael@0 312 * FUNCTION: CMMF_KeyRecRepContentSetNewSignCert
michael@0 313 * INPUTS:
michael@0 314 * inKeyRecRep
michael@0 315 * The CMMFKeyRecRepContent to operate on.
michael@0 316 * inNewSignCert
michael@0 317 * The new signing cert to add to the CMMFKeyRecRepContent structure.
michael@0 318 * NOTES:
michael@0 319 * This function sets the new signeing cert in the CMMFKeyRecRepContent
michael@0 320 * structure.
michael@0 321 *
michael@0 322 * RETURN:
michael@0 323 * SECSuccess if setting the new signing cert was successful. Any other
michael@0 324 * return value indicates an error occurred while trying to add the
michael@0 325 * new signing certificate.
michael@0 326 */
michael@0 327 extern SECStatus
michael@0 328 CMMF_KeyRecRepContentSetNewSignCert(CMMFKeyRecRepContent *inKeyRecRep,
michael@0 329 CERTCertificate *inNewSignCert);
michael@0 330
michael@0 331 /*
michael@0 332 * FUNCTION: CMMF_KeyRecRepContentSetCACerts
michael@0 333 * INPUTS:
michael@0 334 * inKeyRecRep
michael@0 335 * The CMMFKeyRecRepContent to operate on.
michael@0 336 * inCACerts
michael@0 337 * The list of CA certificates required to construct a valid
michael@0 338 * certificate chain with the certificates that will be returned
michael@0 339 * to the end user via this KeyRecRepContent.
michael@0 340 * NOTES:
michael@0 341 * This function sets the caCerts that are required to form a chain with the
michael@0 342 * end entity certificates that are being re-issued in this
michael@0 343 * CMMFKeyRecRepContent structure.
michael@0 344 *
michael@0 345 * RETURN:
michael@0 346 * SECSuccess if adding the caCerts was successful. Any other return value
michael@0 347 * indicates an error while tring to add the caCerts.
michael@0 348 */
michael@0 349 extern SECStatus
michael@0 350 CMMF_KeyRecRepContentSetCACerts(CMMFKeyRecRepContent *inKeyRecRep,
michael@0 351 CERTCertList *inCACerts);
michael@0 352
michael@0 353 /*
michael@0 354 * FUNCTION: CMMF_KeyRecRepContentSetCertifiedKeyPair
michael@0 355 * INPUTS:
michael@0 356 * inKeyRecRep
michael@0 357 * The CMMFKeyRecRepContent to operate on.
michael@0 358 * inCert
michael@0 359 * The certificate to add to the CMMFKeyRecRepContent structure.
michael@0 360 * inPrivKey
michael@0 361 * The private key associated with the certificate above passed in.
michael@0 362 * inPubKey
michael@0 363 * The public key to use for wrapping the private key.
michael@0 364 * NOTES:
michael@0 365 * This function adds another certificate-key pair to the
michael@0 366 * CMMFKeyRecRepcontent structure. There may be more than one
michael@0 367 * certificate-key pair in the structure, so the user must call this
michael@0 368 * function multiple times to add more than one cert-key pair.
michael@0 369 *
michael@0 370 * RETURN:
michael@0 371 * SECSuccess if adding the certified key pair was successful. Any other
michael@0 372 * return value indicates an error in adding certified key pair to
michael@0 373 * CMMFKeyRecRepContent structure.
michael@0 374 */
michael@0 375 extern SECStatus
michael@0 376 CMMF_KeyRecRepContentSetCertifiedKeyPair(CMMFKeyRecRepContent *inKeyRecRep,
michael@0 377 CERTCertificate *inCert,
michael@0 378 SECKEYPrivateKey *inPrivKey,
michael@0 379 SECKEYPublicKey *inPubKey);
michael@0 380
michael@0 381 /*
michael@0 382 * FUNCTION: CMMF_POPODecKeyChallContentSetNextChallenge
michael@0 383 * INPUTS:
michael@0 384 * inDecKeyChall
michael@0 385 * The CMMFPOPODecKeyChallContent to operate on.
michael@0 386 * inRandom
michael@0 387 * The random number to use when generating the challenge,
michael@0 388 * inSender
michael@0 389 * The GeneralName representation of the sender of the challenge.
michael@0 390 * inPubKey
michael@0 391 * The public key to use when encrypting the challenge.
michael@0 392 * passwdArg
michael@0 393 * This value will be passed to the function used for getting a
michael@0 394 * password. The password for getting a password should be registered
michael@0 395 * by calling PK11_SetPasswordFunc before this function is called.
michael@0 396 * If no password callback is registered and the library needs to
michael@0 397 * authenticate to the slot for any reason, this function will fail.
michael@0 398 * NOTES:
michael@0 399 * This function adds a challenge to the end of the list of challenges
michael@0 400 * contained by 'inDecKeyChall'. Refer to the CMMF draft on how the
michael@0 401 * the random number passed in and the sender's GeneralName are used
michael@0 402 * to generate the challenge and witness fields of the challenge. This
michael@0 403 * library will use SHA1 as the one-way function for generating the
michael@0 404 * witess field of the challenge.
michael@0 405 *
michael@0 406 * RETURN:
michael@0 407 * SECSuccess if generating the challenge and adding to the end of list
michael@0 408 * of challenges was successful. Any other return value indicates an error
michael@0 409 * while trying to generate the challenge.
michael@0 410 */
michael@0 411 extern SECStatus
michael@0 412 CMMF_POPODecKeyChallContentSetNextChallenge
michael@0 413 (CMMFPOPODecKeyChallContent *inDecKeyChall,
michael@0 414 long inRandom,
michael@0 415 CERTGeneralName *inSender,
michael@0 416 SECKEYPublicKey *inPubKey,
michael@0 417 void *passwdArg);
michael@0 418
michael@0 419
michael@0 420 /************************** Encoding Functions *************************/
michael@0 421
michael@0 422 /*
michael@0 423 * FUNCTION: CMMF_EncodeCertRepContent
michael@0 424 * INPUTS:
michael@0 425 * inCertRepContent
michael@0 426 * The CMMFCertRepContent to DER-encode.
michael@0 427 * inCallback
michael@0 428 * A callback function that the ASN1 encoder will call whenever it
michael@0 429 * wants to write out DER-encoded bytes. Look at the defintion of
michael@0 430 * CRMFEncoderOutputCallback in crmft.h for a description of the
michael@0 431 * parameters to the function.
michael@0 432 * inArg
michael@0 433 * An opaque pointer to a user-supplied argument that will be passed
michael@0 434 * to the callback funtion whenever the function is called.
michael@0 435 * NOTES:
michael@0 436 * The CMMF library will use the same DER-encoding scheme as the CRMF
michael@0 437 * library. In other words, when reading CRMF comments that pertain to
michael@0 438 * encoding, those comments apply to the CMMF libray as well.
michael@0 439 * The callback function will be called multiple times, each time supplying
michael@0 440 * the next chunk of DER-encoded bytes. The user must concatenate the
michael@0 441 * output of each successive call to the callback in order to get the
michael@0 442 * entire DER-encoded CMMFCertRepContent structure.
michael@0 443 *
michael@0 444 * RETURN:
michael@0 445 * SECSuccess if encoding the CMMFCertRepContent was successful. Any
michael@0 446 * other return value indicates an error while decoding the structure.
michael@0 447 */
michael@0 448 extern SECStatus
michael@0 449 CMMF_EncodeCertRepContent (CMMFCertRepContent *inCertRepContent,
michael@0 450 CRMFEncoderOutputCallback inCallback,
michael@0 451 void *inArg);
michael@0 452
michael@0 453 /*
michael@0 454 * FUNCTION: CMMF_EncodeKeyRecRepContent
michael@0 455 * INPUTS:
michael@0 456 * inKeyRecRep
michael@0 457 * The CMMFKeyRepContent to DER-encode.
michael@0 458 * inCallback
michael@0 459 * A callback function that the ASN1 encoder will call whenever it
michael@0 460 * wants to write out DER-encoded bytes. Look at the defintion of
michael@0 461 * CRMFEncoderOutputCallback in crmft.h for a description of the
michael@0 462 * parameters to the function.
michael@0 463 * inArg
michael@0 464 * An opaque pointer to a user-supplied argument that will be passed
michael@0 465 * to the callback funtion whenever the function is called.
michael@0 466 * NOTES:
michael@0 467 * The CMMF library will use the same DER-encoding scheme as the CRMF
michael@0 468 * library. In other words, when reading CRMF comments that pertain to
michael@0 469 * encoding, those comments apply to the CMMF libray as well.
michael@0 470 * The callback function will be called multiple times, each time supplying
michael@0 471 * the next chunk of DER-encoded bytes. The user must concatenate the
michael@0 472 * output of each successive call to the callback in order to get the
michael@0 473 * entire DER-encoded CMMFCertRepContent structure.
michael@0 474 *
michael@0 475 * RETURN:
michael@0 476 * SECSuccess if encoding the CMMFKeyRecRepContent was successful. Any
michael@0 477 * other return value indicates an error while decoding the structure.
michael@0 478 */
michael@0 479 extern SECStatus
michael@0 480 CMMF_EncodeKeyRecRepContent(CMMFKeyRecRepContent *inKeyRecRep,
michael@0 481 CRMFEncoderOutputCallback inCallback,
michael@0 482 void *inArg);
michael@0 483
michael@0 484 /*
michael@0 485 * FUNCTION: CMMF_EncodePOPODecKeyChallContent
michael@0 486 * INPUTS:
michael@0 487 * inDecKeyChall
michael@0 488 * The CMMFDecKeyChallContent to operate on.
michael@0 489 * inCallback
michael@0 490 * A callback function that the ASN1 encoder will call whenever it
michael@0 491 * wants to write out DER-encoded bytes. Look at the defintion of
michael@0 492 * CRMFEncoderOutputCallback in crmft.h for a description of the
michael@0 493 * parameters to the function.
michael@0 494 * inArg
michael@0 495 * An opaque pointer to a user-supplied argument that will be passed
michael@0 496 * to the callback function whenever the function is called.
michael@0 497 * NOTES:
michael@0 498 * The CMMF library will use the same DER-encoding scheme as the CRMF
michael@0 499 * library. In other words, when reading CRMF comments that pertain to
michael@0 500 * encoding, those comments apply to the CMMF libray as well.
michael@0 501 * The callback function will be called multiple times, each time supplying
michael@0 502 * the next chunk of DER-encoded bytes. The user must concatenate the
michael@0 503 * output of each successive call to the callback in order to get the
michael@0 504 * entire DER-encoded CMMFCertRepContent structure.
michael@0 505 * The DER will be an encoding of the type POPODecKeyChallContents, which
michael@0 506 * is just a sequence of challenges.
michael@0 507 *
michael@0 508 * RETURN:
michael@0 509 * SECSuccess if encoding was successful. Any other return value indicates
michael@0 510 * an error in trying to encode the Challenges.
michael@0 511 */
michael@0 512 extern SECStatus
michael@0 513 CMMF_EncodePOPODecKeyChallContent(CMMFPOPODecKeyChallContent *inDecKeyChall,
michael@0 514 CRMFEncoderOutputCallback inCallback,
michael@0 515 void *inArg);
michael@0 516
michael@0 517 /*
michael@0 518 * FUNCTION: CMMF_EncodePOPODecKeyRespContent
michael@0 519 * INPUTS:
michael@0 520 * inDecodedRand
michael@0 521 * An array of integers to encode as the responses to
michael@0 522 * CMMFPOPODecKeyChallContent. The integers must be in the same order
michael@0 523 * as the challenges extracted from CMMFPOPODecKeyChallContent.
michael@0 524 * inNumRand
michael@0 525 * The number of random integers contained in the array 'inDecodedRand'
michael@0 526 * inCallback
michael@0 527 * A callback function that the ASN1 encoder will call whenever it
michael@0 528 * wants to write out DER-encoded bytes. Look at the defintion of
michael@0 529 * CRMFEncoderOutputCallback in crmft.h for a description of the
michael@0 530 * parameters to the function.
michael@0 531 * inArg
michael@0 532 * An opaque pointer to a user-supplied argument that will be passed
michael@0 533 * to the callback funtion whenever the function is called.
michael@0 534 * NOTES:
michael@0 535 * The CMMF library will use the same DER-encoding scheme as the CRMF
michael@0 536 * library. In other words, when reading CRMF comments that pertain to
michael@0 537 * encoding, those comments apply to the CMMF libray as well.
michael@0 538 * The callback function will be called multiple times, each time supplying
michael@0 539 * the next chunk of DER-encoded bytes. The user must concatenate the
michael@0 540 * output of each successive call to the callback in order to get the
michael@0 541 * entire DER-encoded POPODecKeyRespContent.
michael@0 542 *
michael@0 543 * RETURN:
michael@0 544 * SECSuccess if encoding was successful. Any other return value indicates
michael@0 545 * an error in trying to encode the Challenges.
michael@0 546 */
michael@0 547 extern SECStatus
michael@0 548 CMMF_EncodePOPODecKeyRespContent(long *inDecodedRand,
michael@0 549 int inNumRand,
michael@0 550 CRMFEncoderOutputCallback inCallback,
michael@0 551 void *inArg);
michael@0 552
michael@0 553 /*************** Accessor function ***********************************/
michael@0 554
michael@0 555 /*
michael@0 556 * FUNCTION: CMMF_CertRepContentGetCAPubs
michael@0 557 * INPUTS:
michael@0 558 * inCertRepContent
michael@0 559 * The CMMFCertRepContent to extract the caPubs from.
michael@0 560 * NOTES:
michael@0 561 * This function will return a copy of the list of certificates that
michael@0 562 * make up the chain of CA's required to make the cert issued valid.
michael@0 563 * The user must call CERT_DestroyCertList on the return value when
michael@0 564 * done using the return value.
michael@0 565 *
michael@0 566 * Only call this function on a CertRepContent that has been decoded.
michael@0 567 * The client must call CERT_DestroyCertList when the certificate list
michael@0 568 * is no longer needed.
michael@0 569 *
michael@0 570 * The certs in the list will not be in the temporary database. In order
michael@0 571 * to make these certificates a part of the permanent CA internal database,
michael@0 572 * the user must collect the der for all of these certs and call
michael@0 573 * CERT_ImportCAChain. Afterwards the certs will be part of the permanent
michael@0 574 * database.
michael@0 575 *
michael@0 576 * RETURN:
michael@0 577 * A pointer to the CERTCertList representing the CA chain associated
michael@0 578 * with the issued cert. A NULL return value indicates that no CA Pubs
michael@0 579 * were available in the CMMFCertRepContent structure.
michael@0 580 */
michael@0 581 extern CERTCertList*
michael@0 582 CMMF_CertRepContentGetCAPubs (CMMFCertRepContent *inCertRepContent);
michael@0 583
michael@0 584
michael@0 585 /*
michael@0 586 * FUNCTION: CMMF_CertRepContentGetNumResponses
michael@0 587 * INPUTS:
michael@0 588 * inCertRepContent
michael@0 589 * The CMMFCertRepContent to operate on.
michael@0 590 * NOTES:
michael@0 591 * This function will return the number of CertResponses that are contained
michael@0 592 * by the CMMFCertRepContent passed in.
michael@0 593 *
michael@0 594 * RETURN:
michael@0 595 * The number of CMMFCertResponses contained in the structure passed in.
michael@0 596 */
michael@0 597 extern int
michael@0 598 CMMF_CertRepContentGetNumResponses (CMMFCertRepContent *inCertRepContent);
michael@0 599
michael@0 600 /*
michael@0 601 * FUNCTION: CMMF_CertRepContentGetResponseAtIndex
michael@0 602 * INPUTS:
michael@0 603 * inCertRepContent
michael@0 604 * The CMMFCertRepContent to operate on.
michael@0 605 * inIndex
michael@0 606 * The index of the CMMFCertResponse the user wants a copy of.
michael@0 607 * NOTES:
michael@0 608 * This function creates a copy of the CMMFCertResponse at the index
michael@0 609 * corresponding to the parameter 'inIndex'. Indexing is done like a
michael@0 610 * traditional C array, ie the valid indexes are (0...numResponses-1).
michael@0 611 * The user must call CMMF_DestroyCertResponse after the return value is
michael@0 612 * no longer needed.
michael@0 613 *
michael@0 614 * RETURN:
michael@0 615 * A pointer to the CMMFCertResponse at the index corresponding to
michael@0 616 * 'inIndex'. A return value of NULL indicates an error in copying
michael@0 617 * the CMMFCertResponse.
michael@0 618 */
michael@0 619 extern CMMFCertResponse*
michael@0 620 CMMF_CertRepContentGetResponseAtIndex (CMMFCertRepContent *inCertRepContent,
michael@0 621 int inIndex);
michael@0 622
michael@0 623 /*
michael@0 624 * FUNCTION: CMMF_CertResponseGetCertReqId
michael@0 625 * INPUTS:
michael@0 626 * inCertResp
michael@0 627 * The CMMFCertResponse to operate on.
michael@0 628 * NOTES:
michael@0 629 * This function returns the CertResponse.certReqId from the
michael@0 630 * CMMFCertResponse structure passed in. If the return value is -1, that
michael@0 631 * means there is no associated certificate request with the CertResponse.
michael@0 632 * RETURN:
michael@0 633 * A long representing the id of the certificate request this
michael@0 634 * CMMFCertResponse corresponds to. A return value of -1 indicates an
michael@0 635 * error in extracting the value of the integer.
michael@0 636 */
michael@0 637 extern long CMMF_CertResponseGetCertReqId(CMMFCertResponse *inCertResp);
michael@0 638
michael@0 639 /*
michael@0 640 * FUNCTION: CMMF_CertResponseGetPKIStatusInfoStatus
michael@0 641 * INPUTS:
michael@0 642 * inCertResp
michael@0 643 * The CMMFCertResponse to operate on.
michael@0 644 * NOTES:
michael@0 645 * This function returns the CertResponse.status.status field of the
michael@0 646 * CMMFCertResponse structure.
michael@0 647 *
michael@0 648 * RETURN:
michael@0 649 * The enumerated value corresponding to the PKIStatus defined in the CMMF
michael@0 650 * draft. See the CMMF draft for the definition of PKIStatus. See crmft.h
michael@0 651 * for the definition of CMMFPKIStatus.
michael@0 652 */
michael@0 653 extern CMMFPKIStatus
michael@0 654 CMMF_CertResponseGetPKIStatusInfoStatus(CMMFCertResponse *inCertResp);
michael@0 655
michael@0 656 /*
michael@0 657 * FUNCTION: CMMF_CertResponseGetCertificate
michael@0 658 * INPUTS:
michael@0 659 * inCertResp
michael@0 660 * The Certificate Response to operate on.
michael@0 661 * inCertdb
michael@0 662 * This is the certificate database where the function will place the
michael@0 663 * newly issued certificate.
michael@0 664 * NOTES:
michael@0 665 * This function retrieves the CertResponse.certifiedKeyPair.certificate
michael@0 666 * from the CMMFCertResponse. The user will get a copy of that certificate
michael@0 667 * so the user must call CERT_DestroyCertificate when the return value is
michael@0 668 * no longer needed. The certificate returned will be in the temporary
michael@0 669 * certificate database.
michael@0 670 *
michael@0 671 * RETURN:
michael@0 672 * A pointer to a copy of the certificate contained within the
michael@0 673 * CMMFCertResponse. A return value of NULL indicates an error while trying
michael@0 674 * to make a copy of the certificate.
michael@0 675 */
michael@0 676 extern CERTCertificate*
michael@0 677 CMMF_CertResponseGetCertificate(CMMFCertResponse *inCertResp,
michael@0 678 CERTCertDBHandle *inCertdb);
michael@0 679
michael@0 680 /*
michael@0 681 * FUNCTION: CMMF_KeyRecRepContentGetPKIStatusInfoStatus
michael@0 682 * INPUTS:
michael@0 683 * inKeyRecRep
michael@0 684 * The CMMFKeyRecRepContent structure to operate on.
michael@0 685 * NOTES:
michael@0 686 * This function retrieves the KeyRecRepContent.status.status field of
michael@0 687 * the CMMFKeyRecRepContent structure.
michael@0 688 * RETURN:
michael@0 689 * The CMMFPKIStatus corresponding to the value held in the
michael@0 690 * CMMFKeyRecRepContent structure.
michael@0 691 */
michael@0 692 extern CMMFPKIStatus
michael@0 693 CMMF_KeyRecRepContentGetPKIStatusInfoStatus(CMMFKeyRecRepContent *inKeyRecRep);
michael@0 694
michael@0 695 /*
michael@0 696 * FUNCTION: CMMF_KeyRecRepContentGetNewSignCert
michael@0 697 * INPUTS:
michael@0 698 * inKeyRecRep
michael@0 699 * The CMMFKeyRecRepContent to operate on.
michael@0 700 * NOTES:
michael@0 701 * This function retrieves the KeyRecRepContent.newSignCert field of the
michael@0 702 * CMMFKeyRecRepContent structure. The user must call
michael@0 703 * CERT_DestroyCertificate when the return value is no longer needed. The
michael@0 704 * returned certificate will be in the temporary database. The user
michael@0 705 * must then place the certificate permanently in whatever token the
michael@0 706 * user determines is the proper destination. A return value of NULL
michael@0 707 * indicates the newSigCert field was not present.
michael@0 708 */
michael@0 709 extern CERTCertificate*
michael@0 710 CMMF_KeyRecRepContentGetNewSignCert(CMMFKeyRecRepContent *inKeyRecRep);
michael@0 711
michael@0 712 /*
michael@0 713 * FUNCTION: CMMF_KeyRecRepContentGetCACerts
michael@0 714 * INPUTS:
michael@0 715 * inKeyRecRep
michael@0 716 * The CMMFKeyRecRepContent to operate on.
michael@0 717 * NOTES:
michael@0 718 * This function returns a CERTCertList which contains all of the
michael@0 719 * certficates that are in the sequence KeyRecRepContent.caCerts
michael@0 720 * User must call CERT_DestroyCertList when the return value is no longer
michael@0 721 * needed. All of these certificates will be placed in the tempoaray
michael@0 722 * database.
michael@0 723 *
michael@0 724 * RETURN:
michael@0 725 * A pointer to the list of caCerts contained in the CMMFKeyRecRepContent
michael@0 726 * structure. A return value of NULL indicates the library was not able to
michael@0 727 * make a copy of the certifcates. This may be because there are no caCerts
michael@0 728 * included in the CMMFKeyRecRepContent strucure or an internal error. Call
michael@0 729 * CMMF_KeyRecRepContentHasCACerts to find out if there are any caCerts
michael@0 730 * included in 'inKeyRecRep'.
michael@0 731 */
michael@0 732 extern CERTCertList*
michael@0 733 CMMF_KeyRecRepContentGetCACerts(CMMFKeyRecRepContent *inKeyRecRep);
michael@0 734
michael@0 735 /*
michael@0 736 * FUNCTION: CMMF_KeyRecRepContentGetNumKeyPairs
michael@0 737 * INPUTS:
michael@0 738 * inKeyRecRep
michael@0 739 * The CMMFKeyRecRepContent to operate on.
michael@0 740 * RETURN:
michael@0 741 * This function returns the number of CMMFCertifiedKeyPair structures that
michael@0 742 * that are stored in the KeyRecRepContent structure.
michael@0 743 */
michael@0 744 extern int
michael@0 745 CMMF_KeyRecRepContentGetNumKeyPairs(CMMFKeyRecRepContent *inKeyRecRep);
michael@0 746
michael@0 747 /*
michael@0 748 * FUNCTION: CMMF_KeyRecRepContentGetCertKeyAtIndex
michael@0 749 * INPUTS:
michael@0 750 * inKeyRecRepContent
michael@0 751 * The CMMFKeyRecRepContent to operate on.
michael@0 752 * inIndex
michael@0 753 * The index of the desired CMMFCertifiedKeyPair
michael@0 754 * NOTES:
michael@0 755 * This function retrieves the CMMFCertifiedKeyPair structure at the index
michael@0 756 * 'inIndex'. Valid indexes are 0...(numKeyPairs-1) The user must call
michael@0 757 * CMMF_DestroyCertifiedKeyPair when the return value is no longer needed.
michael@0 758 *
michael@0 759 * RETURN:
michael@0 760 * A pointer to the Certified Key Pair at the desired index. A return value
michael@0 761 * of NULL indicates an error in extracting the Certified Key Pair at the
michael@0 762 * desired index.
michael@0 763 */
michael@0 764 extern CMMFCertifiedKeyPair*
michael@0 765 CMMF_KeyRecRepContentGetCertKeyAtIndex(CMMFKeyRecRepContent *inKeyRecRep,
michael@0 766 int inIndex);
michael@0 767
michael@0 768 /*
michael@0 769 * FUNCTION: CMMF_CertifiedKeyPairGetCertificate
michael@0 770 * INPUTS:
michael@0 771 * inCertKeyPair
michael@0 772 * The CMMFCertifiedKeyPair to operate on.
michael@0 773 * inCertdb
michael@0 774 * The database handle for the database you want this certificate
michael@0 775 * to wind up in.
michael@0 776 * NOTES:
michael@0 777 * This function retrieves the certificate at
michael@0 778 * CertifiedKeyPair.certOrEncCert.certificate
michael@0 779 * The user must call CERT_DestroyCertificate when the return value is no
michael@0 780 * longer needed. The user must import this certificate as a token object
michael@0 781 * onto PKCS#11 slot in order to make it a permanent object. The returned
michael@0 782 * certificate will be in the temporary database.
michael@0 783 *
michael@0 784 * RETURN:
michael@0 785 * A pointer to the certificate contained within the certified key pair.
michael@0 786 * A return value of NULL indicates an error in creating the copy of the
michael@0 787 * certificate.
michael@0 788 */
michael@0 789 extern CERTCertificate*
michael@0 790 CMMF_CertifiedKeyPairGetCertificate(CMMFCertifiedKeyPair *inCertKeyPair,
michael@0 791 CERTCertDBHandle *inCertdb);
michael@0 792
michael@0 793 /*
michael@0 794 * FUNCTION: CMMF_POPODecKeyChallContentGetNumChallenges
michael@0 795 * INPUTS:
michael@0 796 * inKeyChallCont
michael@0 797 * The CMMFPOPODecKeyChallContent to operate on.
michael@0 798 * RETURN:
michael@0 799 * This function returns the number of CMMFChallenges are contained in
michael@0 800 * the CMMFPOPODecKeyChallContent structure.
michael@0 801 */
michael@0 802 extern int CMMF_POPODecKeyChallContentGetNumChallenges
michael@0 803 (CMMFPOPODecKeyChallContent *inKeyChallCont);
michael@0 804
michael@0 805 /*
michael@0 806 * FUNCTION: CMMF_POPODecKeyChallContentGetPublicValue
michael@0 807 * ---------------------------------------------------
michael@0 808 * INPUTS:
michael@0 809 * inKeyChallCont
michael@0 810 * The CMMFPOPODecKeyChallContent to operate on.
michael@0 811 * inIndex
michael@0 812 * The index of the Challenge within inKeyChallCont to operate on.
michael@0 813 * Indexes start from 0, ie the Nth Challenge corresponds to index
michael@0 814 * N-1.
michael@0 815 * NOTES:
michael@0 816 * This function retrieves the public value stored away in the Challenge at
michael@0 817 * index inIndex of inKeyChallCont.
michael@0 818 * RETURN:
michael@0 819 * A pointer to a SECItem containing the public value. User must call
michael@0 820 * SECITEM_FreeItem on the return value when the value is no longer necessary.
michael@0 821 * A return value of NULL indicates an error while retrieving the public value.
michael@0 822 */
michael@0 823 extern SECItem* CMMF_POPODecKeyChallContentGetPublicValue
michael@0 824 (CMMFPOPODecKeyChallContent *inKeyChallCont,
michael@0 825 int inIndex);
michael@0 826
michael@0 827
michael@0 828 /*
michael@0 829 * FUNCTION: CMMF_POPODecKeyChallContentGetRandomNumber
michael@0 830 * INPUTS:
michael@0 831 * inChallContent
michael@0 832 * The CMMFPOPODecKeyChallContent to operate on.
michael@0 833 * inIndex
michael@0 834 * The index of the challenge to look at. Valid indexes are 0 through
michael@0 835 * (CMMF_POPODecKeyChallContentGetNumChallenges(inChallContent) - 1).
michael@0 836 * inDest
michael@0 837 * A pointer to a user supplied buffer where the library
michael@0 838 * can place a copy of the random integer contatained in the
michael@0 839 * challenge.
michael@0 840 * NOTES:
michael@0 841 * This function returns the value held in the decrypted Rand structure
michael@0 842 * corresponding to the random integer. The user must call
michael@0 843 * CMMF_POPODecKeyChallContentDecryptChallenge before calling this function. Call
michael@0 844 * CMMF_ChallengeIsDecrypted to find out if the challenge has been
michael@0 845 * decrypted.
michael@0 846 *
michael@0 847 * RETURN:
michael@0 848 * SECSuccess indicates the witness field has been previously decrypted
michael@0 849 * and the value for the random integer was successfully placed at *inDest.
michael@0 850 * Any other return value indicates an error and that the value at *inDest
michael@0 851 * is not a valid value.
michael@0 852 */
michael@0 853 extern SECStatus CMMF_POPODecKeyChallContentGetRandomNumber
michael@0 854 (CMMFPOPODecKeyChallContent *inKeyChallCont,
michael@0 855 int inIndex,
michael@0 856 long *inDest);
michael@0 857
michael@0 858 /*
michael@0 859 * FUNCTION: CMMF_POPODecKeyRespContentGetNumResponses
michael@0 860 * INPUTS:
michael@0 861 * inRespCont
michael@0 862 * The POPODecKeyRespContent to operate on.
michael@0 863 * RETURN:
michael@0 864 * This function returns the number of responses contained in inRespContent.
michael@0 865 */
michael@0 866 extern int
michael@0 867 CMMF_POPODecKeyRespContentGetNumResponses(CMMFPOPODecKeyRespContent *inRespCont);
michael@0 868
michael@0 869 /*
michael@0 870 * FUNCTION: CMMF_POPODecKeyRespContentGetResponse
michael@0 871 * INPUTS:
michael@0 872 * inRespCont
michael@0 873 * The POPODecKeyRespContent to operate on.
michael@0 874 * inIndex
michael@0 875 * The index of the response to retrieve.
michael@0 876 * The Nth response is at index N-1, ie the 1st response is at index 0,
michael@0 877 * the 2nd response is at index 1, and so on.
michael@0 878 * inDest
michael@0 879 * A pointer to a pre-allocated buffer where the library can put the
michael@0 880 * value of the response located at inIndex.
michael@0 881 * NOTES:
michael@0 882 * The function returns the response contained at index inIndex.
michael@0 883 * CMMFPOPODecKeyRespContent is a structure that the server will generally
michael@0 884 * get in response to a CMMFPOPODecKeyChallContent. The server will expect
michael@0 885 * to see the responses in the same order as it constructed them in
michael@0 886 * the CMMFPOPODecKeyChallContent structure.
michael@0 887 * RETURN:
michael@0 888 * SECSuccess if getting the response at the desired index was successful. Any
michael@0 889 * other return value indicates an errror.
michael@0 890 */
michael@0 891 extern SECStatus
michael@0 892 CMMF_POPODecKeyRespContentGetResponse (CMMFPOPODecKeyRespContent *inRespCont,
michael@0 893 int inIndex,
michael@0 894 long *inDest);
michael@0 895
michael@0 896 /************************* Destructor Functions ******************************/
michael@0 897
michael@0 898 /*
michael@0 899 * FUNCTION: CMMF_DestroyCertResponse
michael@0 900 * INPUTS:
michael@0 901 * inCertResp
michael@0 902 * The CMMFCertResponse to destroy.
michael@0 903 * NOTES:
michael@0 904 * This function frees all the memory associated with the CMMFCertResponse
michael@0 905 * passed in.
michael@0 906 * RETURN:
michael@0 907 * SECSuccess if freeing the memory was successful. Any other return value
michael@0 908 * indicates an error while freeing the memory.
michael@0 909 */
michael@0 910 extern SECStatus CMMF_DestroyCertResponse(CMMFCertResponse *inCertResp);
michael@0 911
michael@0 912 /*
michael@0 913 * FUNCTION: CMMF_DestroyCertRepContent
michael@0 914 * INPUTS:
michael@0 915 * inCertRepContent
michael@0 916 * The CMMFCertRepContent to destroy
michael@0 917 * NOTES:
michael@0 918 * This function frees the memory associated with the CMMFCertRepContent
michael@0 919 * passed in.
michael@0 920 * RETURN:
michael@0 921 * SECSuccess if freeing all the memory associated with the
michael@0 922 * CMMFCertRepContent passed in is successful. Any other return value
michael@0 923 * indicates an error while freeing the memory.
michael@0 924 */
michael@0 925 extern SECStatus
michael@0 926 CMMF_DestroyCertRepContent (CMMFCertRepContent *inCertRepContent);
michael@0 927
michael@0 928 /*
michael@0 929 * FUNCTION: CMMF_DestroyKeyRecRepContent
michael@0 930 * INPUTS:
michael@0 931 * inKeyRecRep
michael@0 932 * The CMMFKeyRecRepContent to destroy.
michael@0 933 * NOTES:
michael@0 934 * This function destroys all the memory associated with the
michael@0 935 * CMMFKeyRecRepContent passed in.
michael@0 936 *
michael@0 937 * RETURN:
michael@0 938 * SECSuccess if freeing all the memory is successful. Any other return
michael@0 939 * value indicates an error in freeing the memory.
michael@0 940 */
michael@0 941 extern SECStatus
michael@0 942 CMMF_DestroyKeyRecRepContent(CMMFKeyRecRepContent *inKeyRecRep);
michael@0 943
michael@0 944 /*
michael@0 945 * FUNCTION: CMMF_DestroyCertifiedKeyPair
michael@0 946 * INPUTS:
michael@0 947 * inCertKeyPair
michael@0 948 * The CMMFCertifiedKeyPair to operate on.
michael@0 949 * NOTES:
michael@0 950 * This function frees up all the memory associated with 'inCertKeyPair'
michael@0 951 *
michael@0 952 * RETURN:
michael@0 953 * SECSuccess if freeing all the memory associated with 'inCertKeyPair'
michael@0 954 * is successful. Any other return value indicates an error while trying
michael@0 955 * to free the memory.
michael@0 956 */
michael@0 957 extern SECStatus
michael@0 958 CMMF_DestroyCertifiedKeyPair(CMMFCertifiedKeyPair *inCertKeyPair);
michael@0 959
michael@0 960 /*
michael@0 961 * FUNCTION: CMMF_DestroyPOPODecKeyRespContent
michael@0 962 * INPUTS:
michael@0 963 * inDecKeyResp
michael@0 964 * The CMMFPOPODecKeyRespContent structure to free.
michael@0 965 * NOTES:
michael@0 966 * This function frees up all the memory associate with the
michael@0 967 * CMMFPOPODecKeyRespContent.
michael@0 968 *
michael@0 969 * RETURN:
michael@0 970 * SECSuccess if freeing up all the memory associated with the
michael@0 971 * CMMFPOPODecKeyRespContent structure is successful. Any other
michael@0 972 * return value indicates an error while freeing the memory.
michael@0 973 */
michael@0 974 extern SECStatus
michael@0 975 CMMF_DestroyPOPODecKeyRespContent(CMMFPOPODecKeyRespContent *inDecKeyResp);
michael@0 976
michael@0 977
michael@0 978 /************************** Miscellaneous Functions *************************/
michael@0 979
michael@0 980 /*
michael@0 981 * FUNCTION: CMMF_CertifiedKeyPairUnwrapPrivKey
michael@0 982 * INPUTS:
michael@0 983 * inCertKeyPair
michael@0 984 * The CMMFCertifiedKeyPair to operate on.
michael@0 985 * inPrivKey
michael@0 986 * The private key to use to un-wrap the private key
michael@0 987 * inNickName
michael@0 988 * This is the nickname that will be associated with the private key
michael@0 989 * to be unwrapped.
michael@0 990 * inSlot
michael@0 991 * The PKCS11 slot where the unwrapped private key should end up.
michael@0 992 * inCertdb
michael@0 993 * The Certificate database with which the new key will be associated.
michael@0 994 * destPrivKey
michael@0 995 * A pointer to memory where the library can place a pointer to the
michael@0 996 * private key after importing the key onto the specified slot.
michael@0 997 * wincx
michael@0 998 * An opaque pointer that the library will use in a callback function
michael@0 999 * to get the password if necessary.
michael@0 1000 *
michael@0 1001 * NOTES:
michael@0 1002 * This function uses the private key passed in to unwrap the private key
michael@0 1003 * contained within the CMMFCertifiedKeyPair structure. After this
michael@0 1004 * function successfully returns, the private key has been unwrapped and
michael@0 1005 * placed in the specified slot.
michael@0 1006 *
michael@0 1007 * RETURN:
michael@0 1008 * SECSuccess if unwrapping the private key was successful. Any other
michael@0 1009 * return value indicates an error while trying to un-wrap the private key.
michael@0 1010 */
michael@0 1011 extern SECStatus
michael@0 1012 CMMF_CertifiedKeyPairUnwrapPrivKey(CMMFCertifiedKeyPair *inKeyPair,
michael@0 1013 SECKEYPrivateKey *inPrivKey,
michael@0 1014 SECItem *inNickName,
michael@0 1015 PK11SlotInfo *inSlot,
michael@0 1016 CERTCertDBHandle *inCertdb,
michael@0 1017 SECKEYPrivateKey **destPrivKey,
michael@0 1018 void *wincx);
michael@0 1019
michael@0 1020 /*
michael@0 1021 * FUNCTION: CMMF_KeyRecRepContentHasCACerts
michael@0 1022 * INPUTS:
michael@0 1023 * inKeyRecRecp
michael@0 1024 * The CMMFKeyRecRepContent to operate on.
michael@0 1025 * RETURN:
michael@0 1026 * This function returns PR_TRUE if there are one or more certificates in
michael@0 1027 * the sequence KeyRecRepContent.caCerts within the CMMFKeyRecRepContent
michael@0 1028 * structure. The function will return PR_FALSE if there are 0 certificate
michael@0 1029 * in the above mentioned sequence.
michael@0 1030 */
michael@0 1031 extern PRBool
michael@0 1032 CMMF_KeyRecRepContentHasCACerts(CMMFKeyRecRepContent *inKeyRecRep);
michael@0 1033
michael@0 1034 /*
michael@0 1035 * FUNCTION: CMMF_POPODecKeyChallContDecryptChallenge
michael@0 1036 * INPUTS:
michael@0 1037 * inChalCont
michael@0 1038 * The CMMFPOPODecKeyChallContent to operate on.
michael@0 1039 * inIndex
michael@0 1040 * The index of the Challenge to operate on. The 1st Challenge is
michael@0 1041 * at index 0, the second at index 1 and so forth.
michael@0 1042 * inPrivKey
michael@0 1043 * The private key to use to decrypt the witness field.
michael@0 1044 * NOTES:
michael@0 1045 * This function uses the private key to decrypt the challenge field
michael@0 1046 * contained in the appropriate challenge. Make sure the private key matches
michael@0 1047 * the public key that was used to encrypt the witness. Use
michael@0 1048 * CMMF_POPODecKeyChallContentGetPublicValue to get the public value of
michael@0 1049 * the key used to encrypt the witness and then use that to determine the
michael@0 1050 * appropriate private key. This can be done by calling PK11_MakeIDFromPubKey
michael@0 1051 * and then passing that return value to PK11_FindKeyByKeyID. The creator of
michael@0 1052 * the challenge will most likely be an RA that has the public key
michael@0 1053 * from a Cert request. So the private key should be the private key
michael@0 1054 * associated with public key in that request. This function will also
michael@0 1055 * verify the witness field of the challenge. This function also verifies
michael@0 1056 * that the sender and witness hashes match within the challenge.
michael@0 1057 *
michael@0 1058 * RETURN:
michael@0 1059 * SECSuccess if decrypting the witness field was successful. This does
michael@0 1060 * not indicate that the decrypted data is valid, since the private key
michael@0 1061 * passed in may not be the actual key needed to properly decrypt the
michael@0 1062 * witness field. Meaning that there is a decrypted structure now, but
michael@0 1063 * may be garbage because the private key was incorrect.
michael@0 1064 * Any other return value indicates the function could not complete the
michael@0 1065 * decryption process.
michael@0 1066 */
michael@0 1067 extern SECStatus
michael@0 1068 CMMF_POPODecKeyChallContDecryptChallenge(CMMFPOPODecKeyChallContent *inChalCont,
michael@0 1069 int inIndex,
michael@0 1070 SECKEYPrivateKey *inPrivKey);
michael@0 1071
michael@0 1072 /*
michael@0 1073 * FUNCTION: CMMF_DestroyPOPODecKeyChallContent
michael@0 1074 * INPUTS:
michael@0 1075 * inDecKeyCont
michael@0 1076 * The CMMFPOPODecKeyChallContent to free
michael@0 1077 * NOTES:
michael@0 1078 * This function frees up all the memory associated with the
michael@0 1079 * CMMFPOPODecKeyChallContent
michael@0 1080 * RETURN:
michael@0 1081 * SECSuccess if freeing up all the memory associatd with the
michael@0 1082 * CMMFPOPODecKeyChallContent is successful. Any other return value
michael@0 1083 * indicates an error while freeing the memory.
michael@0 1084 *
michael@0 1085 */
michael@0 1086 extern SECStatus
michael@0 1087 CMMF_DestroyPOPODecKeyChallContent (CMMFPOPODecKeyChallContent *inDecKeyCont);
michael@0 1088
michael@0 1089 SEC_END_PROTOS
michael@0 1090 #endif /* _CMMF_H_ */

mercurial