security/nss/lib/crmf/crmf.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
michael@0 7 #ifndef _CRMF_H_
michael@0 8 #define _CRMF_H_
michael@0 9
michael@0 10 #include "seccomon.h"
michael@0 11 #include "cert.h"
michael@0 12 #include "crmft.h"
michael@0 13 #include "secoid.h"
michael@0 14 #include "secpkcs7.h"
michael@0 15
michael@0 16 SEC_BEGIN_PROTOS
michael@0 17
michael@0 18 /*
michael@0 19 * FUNCTION: CRMF_EncodeCertReqMsg
michael@0 20 * INPUTS:
michael@0 21 * inCertReqMsg
michael@0 22 * The Certificate Request Message to be encoded.
michael@0 23 * fn
michael@0 24 * A Callback function that the ASN1 encoder calls whenever
michael@0 25 * the encoder wants to write out some DER encoded bytes.
michael@0 26 * arg
michael@0 27 * An opaque pointer that gets passed to the function fn
michael@0 28 * OUTPUT:
michael@0 29 * The function fn will be called multiple times. Look at the
michael@0 30 * comments in crmft.h where the CRMFEncoderOutputCallback type is
michael@0 31 * defined for information on proper behavior of the function fn.
michael@0 32 * RETURN:
michael@0 33 * SECSuccess if encoding was successful. Any other return value
michael@0 34 * indicates an error occurred during encoding.
michael@0 35 */
michael@0 36 extern SECStatus
michael@0 37 CRMF_EncodeCertReqMsg (CRMFCertReqMsg *inCertReqMsg,
michael@0 38 CRMFEncoderOutputCallback fn,
michael@0 39 void *arg);
michael@0 40
michael@0 41 /*
michael@0 42 * FUNCTION: CRMF_EncoderCertRequest
michael@0 43 * INPUTS:
michael@0 44 * inCertReq
michael@0 45 * The Certificate Request to be encoded.
michael@0 46 * fn
michael@0 47 * A Callback function that the ASN1 encoder calls whenever
michael@0 48 * the encoder wants to write out some DER encoded bytes.
michael@0 49 * arg
michael@0 50 * An opaque pointer that gets passed to the function fn.
michael@0 51 * OUTPUT:
michael@0 52 * The function fn will be called, probably multiple times whenever
michael@0 53 * the ASN1 encoder wants to write out DER-encoded bytes. Look at the
michael@0 54 * comments in crmft.h where the CRMFEncoderOutputCallback type is
michael@0 55 * defined for information on proper behavior of the function fn.
michael@0 56 * RETURN:
michael@0 57 * SECSuccess if encoding was successful. Any other return value
michael@0 58 * indicates an error occurred during encoding.
michael@0 59 */
michael@0 60 extern SECStatus CRMF_EncodeCertRequest (CRMFCertRequest *inCertReq,
michael@0 61 CRMFEncoderOutputCallback fn,
michael@0 62 void *arg);
michael@0 63 /*
michael@0 64 * FUNCTION: CRMF_EncodeCertReqMessages
michael@0 65 * INPUTS:
michael@0 66 * inCertReqMsgs
michael@0 67 * An array of pointers to the Certificate Request Messages
michael@0 68 * to encode. The user must place a NULL pointer in the index
michael@0 69 * after the last message to be encoded. When the library runs
michael@0 70 * into the NULL pointer, the library assumes there are no more
michael@0 71 * messages to encode.
michael@0 72 * fn
michael@0 73 * A Callback function that the ASN1 encoder calls whenever
michael@0 74 * the encoder wants to write out some DER encoded byts.
michael@0 75 * arg
michael@0 76 * An opaque pointer that gets passed to the function fn.
michael@0 77 *
michael@0 78 * NOTES:
michael@0 79 * The parameter inCertReqMsgs needs to be an array with a NULL pointer
michael@0 80 * to signal the end of messages. An array in the form of
michael@0 81 * {m1, m2, m3, NULL, m4, ...} will only encode the messages m1, m2, and
michael@0 82 * m3. All messages from m4 on will not be looked at by the library.
michael@0 83 *
michael@0 84 * OUTPUT:
michael@0 85 * The function fn will be called, probably multiple times. Look at the
michael@0 86 * comments in crmft.h where the CRMFEncoderOutputCallback type is
michael@0 87 * defined for information on proper behavior of the function fn.
michael@0 88 *
michael@0 89 * RETURN:
michael@0 90 * SECSuccess if encoding the Certificate Request Messages was successful.
michael@0 91 * Any other return value indicates an error occurred while encoding the
michael@0 92 * certificate request messages.
michael@0 93 */
michael@0 94 extern SECStatus
michael@0 95 CRMF_EncodeCertReqMessages(CRMFCertReqMsg **inCertReqMsgs,
michael@0 96 CRMFEncoderOutputCallback fn,
michael@0 97 void *arg);
michael@0 98
michael@0 99
michael@0 100 /*
michael@0 101 * FUNCTION: CRMF_CreateCertReqMsg
michael@0 102 * INPUTS:
michael@0 103 * NONE
michael@0 104 * OUTPUT:
michael@0 105 * An empty CRMF Certificate Request Message.
michael@0 106 * Before encoding this message, the user must set
michael@0 107 * the ProofOfPossession field and the certificate
michael@0 108 * request which are necessary for the full message.
michael@0 109 * After the user no longer needs this CertReqMsg,
michael@0 110 * the user must call CRMF_DestroyCertReqMsg to free
michael@0 111 * all memory associated with the Certificate Request
michael@0 112 * Message.
michael@0 113 * RETURN:
michael@0 114 * A pointer to a Certificate Request Message. The user
michael@0 115 * must pass the return value of this function to
michael@0 116 * CRMF_DestroyCertReqMsg after the Certificate Request
michael@0 117 * Message is no longer necessary.
michael@0 118 */
michael@0 119 extern CRMFCertReqMsg* CRMF_CreateCertReqMsg(void);
michael@0 120
michael@0 121 /*
michael@0 122 * FUNCTION: CRMF_DestroyCertReqMsg
michael@0 123 * INPUTS:
michael@0 124 * inCertReqMsg
michael@0 125 * The Certificate Request Message to destroy.
michael@0 126 * NOTES:
michael@0 127 * This function frees all the memory used for the Certificate
michael@0 128 * Request Message and all the memory used in making copies of
michael@0 129 * fields of elelments of the message, eg. the Proof Of Possession
michael@0 130 * filed and the Cetificate Request.
michael@0 131 * RETURN:
michael@0 132 * SECSuccess if destruction was successful. Any other return value
michael@0 133 * indicates an error while trying to free the memory associated
michael@0 134 * with inCertReqMsg.
michael@0 135 *
michael@0 136 */
michael@0 137 extern SECStatus CRMF_DestroyCertReqMsg(CRMFCertReqMsg *inCertReqMsg);
michael@0 138
michael@0 139 /*
michael@0 140 * FUNCTION: CRMF_CertReqMsgSetCertRequest
michael@0 141 * INPUTS:
michael@0 142 * inCertReqMsg
michael@0 143 * The Certificate Request Message that the function will set
michael@0 144 * the certificate request for.
michael@0 145 * inCertReq
michael@0 146 * The Certificate Request that will be added to the Certificate
michael@0 147 * Request Message.
michael@0 148 * NOTES:
michael@0 149 * This function will make a copy of the Certificate Request passed in
michael@0 150 * and store it as part of the Certificate Request Message. Therefore,
michael@0 151 * the user must not call this function until the Certificate Request
michael@0 152 * has been fully built and is ready to be encoded.
michael@0 153 * RETURN:
michael@0 154 * SECSuccess
michael@0 155 * If copying the Certificate as a member of the Certificate
michael@0 156 * request message was successful.
michael@0 157 * Any other return value indicates a failure to copy the Certificate
michael@0 158 * Request and make it a part of the Certificate Request Message.
michael@0 159 */
michael@0 160 extern SECStatus CRMF_CertReqMsgSetCertRequest(CRMFCertReqMsg *inCertReqMsg,
michael@0 161 CRMFCertRequest *inCertReq);
michael@0 162
michael@0 163 /*
michael@0 164 * FUNCTION: CRMF_CreateCertRequest
michael@0 165 * INPUTS:
michael@0 166 * inRequestID
michael@0 167 * The ID that will be associated with this certificate request.
michael@0 168 * OUTPUTS:
michael@0 169 * A certificate request which only has the requestID set.
michael@0 170 * NOTES:
michael@0 171 * The user must call the function CRMF_DestroyCertRequest when
michael@0 172 * the returned value is no longer needed. This is usually the
michael@0 173 * case after fully constructing the Certificate Request and then
michael@0 174 * calling the function CRMF_CertReqMsgSetCertRequest.
michael@0 175 * RETURN:
michael@0 176 * A pointer to the new Certificate Request. A NULL return value
michael@0 177 * indicates an error in creating the Certificate Request.
michael@0 178 */
michael@0 179 extern CRMFCertRequest *CRMF_CreateCertRequest (PRUint32 inRequestID);
michael@0 180
michael@0 181 /*
michael@0 182 * FUNCTION: CRMF_DestroyCertRequest
michael@0 183 * INPUTS:
michael@0 184 * inCertReq
michael@0 185 * The Certificate Request that will be destroyed.
michael@0 186 * RETURN:
michael@0 187 * SECSuccess
michael@0 188 * If freeing the memory associated with the certificate request
michael@0 189 * was successful.
michael@0 190 * Any other return value indicates an error while trying to free the
michael@0 191 * memory.
michael@0 192 */
michael@0 193 extern SECStatus CRMF_DestroyCertRequest (CRMFCertRequest *inCertReq);
michael@0 194
michael@0 195 /*
michael@0 196 * FUNCTION: CRMF_CreateCertExtension
michael@0 197 * INPUTS:
michael@0 198 * id
michael@0 199 * The SECOidTag to associate with this CertExtension. This must
michael@0 200 * correspond to a valid Certificate Extension, if not the function
michael@0 201 * will fail.
michael@0 202 * isCritical
michael@0 203 * A boolean value stating if the extension value is crtical. PR_TRUE
michael@0 204 * means the value is crtical. PR_FALSE indicates the value is not
michael@0 205 * critical.
michael@0 206 * data
michael@0 207 * This is the data associated with the extension. The user of the
michael@0 208 * library is responsible for making sure the value passed in is a
michael@0 209 * valid interpretation of the certificate extension.
michael@0 210 * NOTES:
michael@0 211 * Use this function to create CRMFCertExtension Structures which will
michael@0 212 * then be passed to CRMF_AddFieldToCertTemplate as part of the
michael@0 213 * CRMFCertCreationInfo.extensions The user must call
michael@0 214 * CRMF_DestroyCertExtension after the extension has been added to a certifcate
michael@0 215 * and the extension is no longer needed.
michael@0 216 *
michael@0 217 * RETURN:
michael@0 218 * A pointer to a newly created CertExtension. A return value of NULL
michael@0 219 * indicates the id passed in was an invalid certificate extension.
michael@0 220 */
michael@0 221 extern CRMFCertExtension *CRMF_CreateCertExtension(SECOidTag id,
michael@0 222 PRBool isCritical,
michael@0 223 SECItem *data);
michael@0 224
michael@0 225 /*
michael@0 226 * FUNCTION: CMRF_DestroyCertExtension
michael@0 227 * INPUTS:
michael@0 228 * inExtension
michael@0 229 * The Cert Extension to destroy
michael@0 230 * NOTES:
michael@0 231 * Destroy a structure allocated by CRMF_CreateCertExtension.
michael@0 232 *
michael@0 233 * RETURN:
michael@0 234 * SECSuccess if freeing the memory associated with the certificate extension
michael@0 235 * was successful. Any other error indicates an error while freeing the
michael@0 236 * memory.
michael@0 237 */
michael@0 238 extern SECStatus CRMF_DestroyCertExtension(CRMFCertExtension *inExtension);
michael@0 239
michael@0 240 /*
michael@0 241 * FUNCTION: CRMF_CertRequestSetTemplateField
michael@0 242 * INPUTS:
michael@0 243 * inCertReq
michael@0 244 * The Certificate Request to operate on.
michael@0 245 * inTemplateField
michael@0 246 * An enumeration that indicates which field of the Certificate
michael@0 247 * template to add.
michael@0 248 * data
michael@0 249 * A generic pointer that will be type cast according to the
michael@0 250 * table under NOTES and used as the key for adding to the
michael@0 251 * certificate template;
michael@0 252 * NOTES:
michael@0 253 *
michael@0 254 * Below is a table that tells what type to pass in as data
michael@0 255 * depending on the template field one wants to set.
michael@0 256 *
michael@0 257 * Look in crmft.h for the definition of CRMFCertTemplateField.
michael@0 258 *
michael@0 259 * In all cases, the library makes copies of the data passed in.
michael@0 260 *
michael@0 261 * CRMFCertTemplateField Type of data What data means
michael@0 262 * --------------------- ------------ ---------------
michael@0 263 * crmfVersion long * The version of
michael@0 264 * the certificate
michael@0 265 * to be created.
michael@0 266 *
michael@0 267 * crmfSerialNumber long * The serial number
michael@0 268 * for the cert to be
michael@0 269 * created.
michael@0 270 *
michael@0 271 * crmfSigningAlg SECAlgorithm * The ASN.1 object ID for
michael@0 272 * the algorithm used in encoding
michael@0 273 * the certificate.
michael@0 274 *
michael@0 275 * crmfIssuer CERTName * Certificate Library
michael@0 276 * representation of the ASN1 type
michael@0 277 * Name from X.509
michael@0 278 *
michael@0 279 * crmfValidity CRMFValidityCreationInfo * At least one of the two
michael@0 280 * fields in the structure must
michael@0 281 * be present. A NULL pointer
michael@0 282 * in the structure indicates
michael@0 283 * that member should not be
michael@0 284 * added.
michael@0 285 *
michael@0 286 * crmfSubject CERTName * Certificate Library
michael@0 287 * representation of the ASN1 type
michael@0 288 * Name from X.509
michael@0 289 *
michael@0 290 * crmfPublicKey CERTSubjectPublicKeyInfo * The public key info for the
michael@0 291 * certificate being requested.
michael@0 292 *
michael@0 293 * crmfIssuerUID SECItem * A bit string representation
michael@0 294 * of the issuer UID. NOTE: The
michael@0 295 * length is the number of bits
michael@0 296 * and not the number of bytes.
michael@0 297 *
michael@0 298 * crmfSubjectUID SECItem* A bit string representation
michael@0 299 * of the subject UID. NOTE: The
michael@0 300 * length is the number of bits
michael@0 301 * and not the number of bytes.
michael@0 302 *
michael@0 303 * crmfExtension CRMFCertExtCreationInfo * A pointer to the structure
michael@0 304 * populated with an array of
michael@0 305 * of certificate extensions
michael@0 306 * and an integer that tells
michael@0 307 * how many elements are in the
michael@0 308 * array. Look in crmft.h for
michael@0 309 * the definition of
michael@0 310 * CRMFCertExtCreationInfo
michael@0 311 * RETURN:
michael@0 312 * SECSuccess if adding the desired field to the template was successful.
michael@0 313 * Any other return value indicates failure when trying to add the field
michael@0 314 * to the template.
michael@0 315 *
michael@0 316 */
michael@0 317 extern SECStatus
michael@0 318 CRMF_CertRequestSetTemplateField(CRMFCertRequest *inCertReq,
michael@0 319 CRMFCertTemplateField inTemplateField,
michael@0 320 void *data);
michael@0 321
michael@0 322 /*
michael@0 323 * FUNCTION: CRMF_CertRequestIsFieldPresent
michael@0 324 * INPUTS:
michael@0 325 * inCertReq
michael@0 326 * The certificate request to operate on.
michael@0 327 * inTemplateField
michael@0 328 * The enumeration for the template field the user wants to query
michael@0 329 * about.
michael@0 330 * NOTES:
michael@0 331 * This function checks to see if the the field associated with inTemplateField
michael@0 332 * enumeration is already present in the certificate request passed in.
michael@0 333 *
michael@0 334 * RETURN:
michael@0 335 * The function returns PR_TRUE if the field associated with inTemplateField
michael@0 336 * is already present in the certificate request. If the field is not present
michael@0 337 * the function returns PR_FALSE.
michael@0 338 */
michael@0 339 extern PRBool
michael@0 340 CRMF_CertRequestIsFieldPresent(CRMFCertRequest *inCertReq,
michael@0 341 CRMFCertTemplateField inTemplateField);
michael@0 342
michael@0 343 /*
michael@0 344 * FUNCTION: CRMF_CertRequestIsControlPresent
michael@0 345 * INPUTS:
michael@0 346 * inCertReq
michael@0 347 * The certificate request to operate on.
michael@0 348 * inControlType
michael@0 349 * The type of control to look for.
michael@0 350 * NOTES:
michael@0 351 * This function looks at the control present in the certificate request
michael@0 352 * and returns PR_TRUE iff a control of type inControlType already exists.
michael@0 353 * The CRMF draft does not explicitly state that two controls of the same
michael@0 354 * type can not exist within the same request. So the library will not
michael@0 355 * cause an error if you try to add a control and one of the same type
michael@0 356 * already exists. It is up to the application to ensure that multiple
michael@0 357 * controls of the same type do not exist, if that is the desired behavior
michael@0 358 * by the application.
michael@0 359 *
michael@0 360 * RETURN:
michael@0 361 * The function returns PR_TRUE if a control of type inControlType already
michael@0 362 * exists in the certificate request. If a control of type inControlType
michael@0 363 * does not exist, the function will return PR_FALSE.
michael@0 364 */
michael@0 365 extern PRBool
michael@0 366 CRMF_CertRequestIsControlPresent(CRMFCertRequest *inCertReq,
michael@0 367 CRMFControlType inControlType);
michael@0 368
michael@0 369
michael@0 370 /*
michael@0 371 * FUNCTION: CRMF_CertRequestSetRegTokenControl
michael@0 372 * INPUTS:
michael@0 373 * inCertReq
michael@0 374 * The Certificate Request to operate on.
michael@0 375 * value
michael@0 376 * The UTF8 value which will be the Registration Token Control
michael@0 377 * for this Certificate Request.
michael@0 378 * NOTES:
michael@0 379 * The library does no verification that the value passed in is
michael@0 380 * a valid UTF8 value. The caller must make sure of this in order
michael@0 381 * to get an encoding that is valid. The library will ultimately
michael@0 382 * encode this value as it was passed in.
michael@0 383 * RETURN:
michael@0 384 * SECSucces on successful addition of the Registration Token Control.
michael@0 385 * Any other return value indicates an unsuccessful attempt to add the
michael@0 386 * control.
michael@0 387 *
michael@0 388 */
michael@0 389 extern SECStatus CRMF_CertRequestSetRegTokenControl(CRMFCertRequest *inCertReq,
michael@0 390 SECItem *value);
michael@0 391
michael@0 392 /*
michael@0 393 * FUNCTION: CRMF_CertRequestSetAuthenticatorControl
michael@0 394 * INPUTS:
michael@0 395 * inCertReq
michael@0 396 * The Certificate Request to operate on.
michael@0 397 * value
michael@0 398 * The UTF8 value that will become the Authenticator Control
michael@0 399 * for the passed in Certificate Request.
michael@0 400 * NOTES:
michael@0 401 * The library does no verification that the value passed in is
michael@0 402 * a valid UTF8 value. The caller must make sure of this in order
michael@0 403 * to get an encoding that is valid. The library will ultimately
michael@0 404 * encode this value as it was passed in.
michael@0 405 * RETURN:
michael@0 406 * SECSucces on successful addition of the Authenticator Control.
michael@0 407 * Any other return value indicates an unsuccessful attempt to add the
michael@0 408 * control.
michael@0 409 */
michael@0 410 extern SECStatus
michael@0 411 CRMF_CertRequestSetAuthenticatorControl (CRMFCertRequest *inCertReq,
michael@0 412 SECItem *value);
michael@0 413
michael@0 414 /*
michael@0 415 * FUNCTION: CRMF_CreateEncryptedKeyWithencryptedValue
michael@0 416 * INPUTS:
michael@0 417 * inPrivKey
michael@0 418 * This is the private key associated with a certificate that is
michael@0 419 * being requested. This structure will eventually wind up as
michael@0 420 * a part of the PKIArchiveOptions Control.
michael@0 421 * inCACert
michael@0 422 * This is the certificate for the CA that will be receiving the
michael@0 423 * certificate request for the private key passed in.
michael@0 424 * OUTPUT:
michael@0 425 * A CRMFEncryptedKey that can ultimately be used as part of the
michael@0 426 * PKIArchiveOptions Control.
michael@0 427 *
michael@0 428 * RETURN:
michael@0 429 * A pointer to a CRMFEncyptedKey. A NULL return value indicates an erro
michael@0 430 * during the creation of the encrypted key.
michael@0 431 */
michael@0 432 extern CRMFEncryptedKey*
michael@0 433 CRMF_CreateEncryptedKeyWithEncryptedValue(SECKEYPrivateKey *inPrivKey,
michael@0 434 CERTCertificate *inCACert);
michael@0 435
michael@0 436 /*
michael@0 437 * FUNCTION: CRMF_DestroyEncryptedKey
michael@0 438 * INPUTS:
michael@0 439 * inEncrKey
michael@0 440 * The CRMFEncryptedKey to be destroyed.
michael@0 441 * NOTES:
michael@0 442 * Frees all memory associated with the CRMFEncryptedKey passed in.
michael@0 443 * RETURN:
michael@0 444 * SECSuccess if freeing the memory was successful. Any other return
michael@0 445 * value indicates an error while freeig the memroy.
michael@0 446 */
michael@0 447 extern SECStatus CRMF_DestroyEncryptedKey(CRMFEncryptedKey *inEncrKey);
michael@0 448
michael@0 449 /*
michael@0 450 * FUNCTION: CRMF_CreatePKIArchiveOptions
michael@0 451 * INPUTS:
michael@0 452 * inType
michael@0 453 * An enumeration value indicating which option for
michael@0 454 * PKIArchiveOptions to use.
michael@0 455 * data
michael@0 456 * A pointer that will be type-cast and de-referenced according
michael@0 457 * to the table under NOTES.
michael@0 458 * NOTES:
michael@0 459 * A table listing what should be passed in as data
michael@0 460 * ------------------------------------------------
michael@0 461 *
michael@0 462 * inType data
michael@0 463 * ------ ----
michael@0 464 * crmfEncryptedPrivateKey CRMFEncryptedKey*
michael@0 465 * crmfKeyGenParameters SECItem*(This needs to be an octet string)
michael@0 466 * crmfArchiveRemGenPrivKey PRBool*
michael@0 467 *
michael@0 468 * RETURN:
michael@0 469 * A pointer the a CRMFPKIArchiveOptions that can be added to a Certificate
michael@0 470 * Request. A NULL pointer indicates an error occurred while creating
michael@0 471 * the CRMFPKIArchiveOptions Structure.
michael@0 472 */
michael@0 473 extern CRMFPKIArchiveOptions*
michael@0 474 CRMF_CreatePKIArchiveOptions(CRMFPKIArchiveOptionsType inType,
michael@0 475 void *data);
michael@0 476 /*
michael@0 477 * FUNCTION: CRMF_DestroyPKIArchiveOptions
michael@0 478 * INPUTS:
michael@0 479 * inArchOpt
michael@0 480 * A pointer to the CRMFPKIArchiveOptions structure to free.
michael@0 481 * NOTES:
michael@0 482 * Will free all memory associated with 'inArchOpt'.
michael@0 483 * RETURN:
michael@0 484 * SECSuccess if successful in freeing the memory used by 'inArchOpt'
michael@0 485 * Any other return value indicates an error while freeing the memory.
michael@0 486 */
michael@0 487 extern SECStatus
michael@0 488 CRMF_DestroyPKIArchiveOptions(CRMFPKIArchiveOptions *inArchOpt);
michael@0 489
michael@0 490 /*
michael@0 491 * FUNCTION: CRMF_CertRequestSetPKIArchiveOptions
michael@0 492 * INPUTS:
michael@0 493 * inCertReq
michael@0 494 * The Certificate Request to add the the options to.
michael@0 495 * inOptions
michael@0 496 * The Archive Options to add to the Certificate Request.
michael@0 497 * NOTES:
michael@0 498 * Adds the PKIArchiveOption to the Certificate Request. This is what
michael@0 499 * enables Key Escrow to take place through CRMF. The library makes
michael@0 500 * its own copy of the information.
michael@0 501 * RETURN:
michael@0 502 * SECSuccess if successful in adding the ArchiveOptions to the Certificate
michael@0 503 * request. Any other return value indicates an error when trying to add
michael@0 504 * the Archive Options to the Certificate Request.
michael@0 505 */
michael@0 506 extern SECStatus
michael@0 507 CRMF_CertRequestSetPKIArchiveOptions(CRMFCertRequest *inCertReq,
michael@0 508 CRMFPKIArchiveOptions *inOptions);
michael@0 509
michael@0 510 /*
michael@0 511 * FUNCTION: CRMF_CertReqMsgGetPOPType
michael@0 512 * INPUTS:
michael@0 513 * inCertReqMsg
michael@0 514 * The Certificate Request Message to operate on.
michael@0 515 * NOTES:
michael@0 516 * Returns an enumeration value indicating the method of Proof
michael@0 517 * of Possession that was used for the passed in Certificate Request
michael@0 518 * Message.
michael@0 519 * RETURN:
michael@0 520 * An enumeration indicating what method for Proof Of Possession is
michael@0 521 * being used in this Certificate Request Message. Look in the file
michael@0 522 * crmft.h for the definition of CRMFPOPChoice for the possible return
michael@0 523 * values.
michael@0 524 */
michael@0 525 extern CRMFPOPChoice CRMF_CertReqMsgGetPOPType(CRMFCertReqMsg *inCertReqMsg);
michael@0 526
michael@0 527 /*
michael@0 528 * FUNCTION: CRMF_CertReqMsgSetRAVerifiedPOP
michael@0 529 * INPUT:
michael@0 530 * InCertReqMsg
michael@0 531 * The Certificate Request Message to operate on.
michael@0 532 * NOTES:
michael@0 533 * This function will set the method of Proof Of Possession to
michael@0 534 * crmfRAVerified which means the RA has already verified the
michael@0 535 * requester does possess the private key.
michael@0 536 * RETURN:
michael@0 537 * SECSuccess if adding RAVerified to the message is successful.
michael@0 538 * Any other message indicates an error while trying to add RAVerified
michael@0 539 * as the Proof of Possession.
michael@0 540 */
michael@0 541 extern SECStatus CRMF_CertReqMsgSetRAVerifiedPOP(CRMFCertReqMsg *inCertReqMsg);
michael@0 542
michael@0 543 /*
michael@0 544 * FUNCTION: CRMF_CertReqMsgSetSignaturePOP
michael@0 545 * INPUT:
michael@0 546 * inCertReqMsg
michael@0 547 * The Certificate Request Message to add the SignaturePOP to.
michael@0 548 * inPrivKey
michael@0 549 * The Private Key which corresponds to the the Certificate Request
michael@0 550 * Message.
michael@0 551 * inPubKey
michael@0 552 * The Public Key which corresponds to the Private Key passed in.
michael@0 553 * inCertForInput
michael@0 554 * A Certificate that in the future may be used to create
michael@0 555 * POPOSigningKeyInput.
michael@0 556 * fn
michael@0 557 * A callback for retrieving a password which may be used in the
michael@0 558 * future to generate POPOSigningKeyInput.
michael@0 559 * arg
michael@0 560 * An opaque pointer that would be passed to fn whenever it is
michael@0 561 * called.
michael@0 562 * NOTES:
michael@0 563 * Adds Proof Of Possession to the CertRequest using the signature field
michael@0 564 * of the ProofOfPossession field. NOTE: In order to use this option,
michael@0 565 * the certificate template must contain the publicKey at the very minimum.
michael@0 566 *
michael@0 567 * If you don't want the function to generate POPOSigningKeyInput, then
michael@0 568 * make sure the cert template already contains the subject and public key
michael@0 569 * values. Currently creating POPOSigningKeyInput is not supported, so
michael@0 570 * a Message passed to this function must have the publicKey and the subject
michael@0 571 * as part of the template
michael@0 572 *
michael@0 573 * This will take care of creating the entire POPOSigningKey structure
michael@0 574 * that will become part of the message.
michael@0 575 *
michael@0 576 * inPrivKey is the key to be used in the signing operation when creating
michael@0 577 * POPOSigningKey structure. This should be the key corresponding to
michael@0 578 * the certificate being requested.
michael@0 579 *
michael@0 580 * inCertForInput will be used if POPOSigningKeyInput needs to be generated.
michael@0 581 * It will be used in generating the authInfo.sender field. If the parameter
michael@0 582 * is not passed in then authInfo.publicKeyMAC will be generated instead.
michael@0 583 * If passed in, this certificate needs to be a valid certificate.
michael@0 584 *
michael@0 585 * The last 3 arguments are for future compatibility in case we ever want to
michael@0 586 * support generating POPOSigningKeyInput. Pass in NULL for all 3 if you
michael@0 587 * definitely don't want the function to even try to generate
michael@0 588 * POPOSigningKeyInput. If you try to use POPOSigningKeyInput, the function
michael@0 589 * will fail.
michael@0 590 *
michael@0 591 * RETURN:
michael@0 592 * SECSuccess if adding the Signature Proof Of Possession worked.
michael@0 593 * Any other return value indicates an error in trying to add
michael@0 594 * the Signature Proof Of Possession.
michael@0 595 */
michael@0 596 extern SECStatus
michael@0 597 CRMF_CertReqMsgSetSignaturePOP(CRMFCertReqMsg *inCertReqMsg,
michael@0 598 SECKEYPrivateKey *inPrivKey,
michael@0 599 SECKEYPublicKey *inPubKey,
michael@0 600 CERTCertificate *inCertForInput,
michael@0 601 CRMFMACPasswordCallback fn,
michael@0 602 void *arg);
michael@0 603
michael@0 604 /*
michael@0 605 * FUNCTION: CRMF_CertReqMsgSetKeyEnciphermentPOP
michael@0 606 * INPUTS:
michael@0 607 * inCertReqMsg
michael@0 608 * The Certificate Request Message to operate on.
michael@0 609 * inKeyChoice
michael@0 610 * An enumeration indicating which POPOPrivKey Choice to use
michael@0 611 * in constructing the KeyEnciphermentPOP.
michael@0 612 * subseqMess
michael@0 613 * This parameter must be provided iff inKeyChoice is
michael@0 614 * crmfSubsequentMessage. This details how the RA is to respond
michael@0 615 * in order to perform Proof Of Possession. Look in crmft.h under
michael@0 616 * the definition of CRMFSubseqMessOptions for possible values.
michael@0 617 * encPrivKey
michael@0 618 * This parameter only needs to be provided if inKeyChoice is
michael@0 619 * crmfThisMessage. The item should contain the encrypted private
michael@0 620 * key.
michael@0 621 *
michael@0 622 * NOTES:
michael@0 623 * Adds Proof Of Possession using the keyEncipherment field of
michael@0 624 * ProofOfPossession.
michael@0 625 *
michael@0 626 * The function looks at the the inKeyChoice parameter and interprets it in
michael@0 627 * in the following manner.
michael@0 628 *
michael@0 629 * If a parameter is not mentioned under interpretation, the function will not
michael@0 630 * look at its value when implementing that case.
michael@0 631 *
michael@0 632 * inKeyChoice Interpretation
michael@0 633 * ----------- --------------
michael@0 634 * crmfThisMessage This options requires that the encrypted private key
michael@0 635 * be included in the thisMessage field of POPOPrivKey.
michael@0 636 * We don't support this yet, so any clients who want
michael@0 637 * to use this feature have to implement a wrapping
michael@0 638 * function and agree with the server on how to properly
michael@0 639 * wrap the key. That encrypted key must be passed in
michael@0 640 * as the encPrivKey parameter.
michael@0 641 *
michael@0 642 * crmfSubequentMessage Must pass in a value for subseqMess. The value must
michael@0 643 * be either CRMFEncrCert or CRMFChallengeResp. The
michael@0 644 * parameter encPrivKey will not be looked at in this
michael@0 645 * case.
michael@0 646 *
michael@0 647 * crmfDHMAC This is not a valid option for this function. Passing
michael@0 648 * in this value will result in the function returning
michael@0 649 * SECFailure.
michael@0 650 * RETURN:
michael@0 651 * SECSuccess if adding KeyEnciphermentPOP was successful. Any other return
michael@0 652 * value indicates an error in adding KeyEnciphermentPOP.
michael@0 653 */
michael@0 654 extern SECStatus
michael@0 655 CRMF_CertReqMsgSetKeyEnciphermentPOP(CRMFCertReqMsg *inCertReqMsg,
michael@0 656 CRMFPOPOPrivKeyChoice inKeyChoice,
michael@0 657 CRMFSubseqMessOptions subseqMess,
michael@0 658 SECItem *encPrivKey);
michael@0 659
michael@0 660 /*
michael@0 661 * FUNCTION: CRMF_CertReqMsgSetKeyAgreementPOP
michael@0 662 * INPUTS:
michael@0 663 * inCertReqMsg
michael@0 664 * The Certificate Request Message to operate on.
michael@0 665 * inKeyChoice
michael@0 666 * An enumeration indicating which POPOPrivKey Choice to use
michael@0 667 * in constructing the KeyAgreementPOP.
michael@0 668 * subseqMess
michael@0 669 * This parameter must be provided iff inKeyChoice is
michael@0 670 * crmfSubsequentMessage. This details how the RA is to respond
michael@0 671 * in order to perform Proof Of Possession. Look in crmft.h under
michael@0 672 * the definition of CRMFSubseqMessOptions for possible values.
michael@0 673 * encPrivKey
michael@0 674 * This parameter only needs to be provided if inKeyChoice is
michael@0 675 * crmfThisMessage. The item should contain the encrypted private
michael@0 676 * key.
michael@0 677 * Adds Proof Of Possession using the keyAgreement field of
michael@0 678 * ProofOfPossession.
michael@0 679 *
michael@0 680 * The function looks at the the inKeyChoice parameter and interprets it in
michael@0 681 * in the following manner.
michael@0 682 *
michael@0 683 * If a parameter is not mentioned under interpretation, the function will not
michael@0 684 * look at its value when implementing that case.
michael@0 685 *
michael@0 686 * inKeyChoice Interpretation
michael@0 687 * ----------- --------------
michael@0 688 * crmfThisMessage This options requires that the encrypted private key
michael@0 689 * be included in the thisMessage field of POPOPrivKey.
michael@0 690 * We don't support this yet, so any clients who want
michael@0 691 * to use this feature have to implement a wrapping
michael@0 692 * function and agree with the server on how to properly
michael@0 693 * wrap the key. That encrypted key must be passed in
michael@0 694 * as the encPrivKey parameter.
michael@0 695 *
michael@0 696 * crmfSubequentMessage Must pass in a value for subseqMess. The value must
michael@0 697 * be either crmfEncrCert or crmfChallengeResp. The
michael@0 698 * parameter encPrivKey will not be looked at in this
michael@0 699 * case.
michael@0 700 *
michael@0 701 * crmfDHMAC This option is not supported.
michael@0 702 */
michael@0 703 extern SECStatus
michael@0 704 CRMF_CertReqMsgSetKeyAgreementPOP(CRMFCertReqMsg *inCertReqMsg,
michael@0 705 CRMFPOPOPrivKeyChoice inKeyChoice,
michael@0 706 CRMFSubseqMessOptions subseqMess,
michael@0 707 SECItem *encPrivKey);
michael@0 708
michael@0 709 /*
michael@0 710 * FUNCTION: CRMF_CreateCertReqMsgFromDER
michael@0 711 * INPUTS:
michael@0 712 * buf
michael@0 713 * A buffer to the DER-encoded Certificate Request Message.
michael@0 714 * len
michael@0 715 * The length in bytes of the buffer 'buf'
michael@0 716 * NOTES:
michael@0 717 * This function passes the buffer to the ASN1 decoder and creates a
michael@0 718 * CRMFCertReqMsg structure. Do not try adding any fields to a message
michael@0 719 * returned from this function. Specifically adding more Controls or
michael@0 720 * Extensions may cause your program to crash.
michael@0 721 *
michael@0 722 * RETURN:
michael@0 723 * A pointer to the Certificate Request Message structure. A NULL return
michael@0 724 * value indicates the library was unable to parse the DER.
michael@0 725 */
michael@0 726 extern CRMFCertReqMsg* CRMF_CreateCertReqMsgFromDER(const char *buf, long len);
michael@0 727
michael@0 728 /*
michael@0 729 * FUNCTION: CRMF_CreateCertReqMessagesFromDER
michael@0 730 * INPUTS:
michael@0 731 * buf
michael@0 732 * A buffer to the DER-encoded Certificate Request Messages.
michael@0 733 * len
michael@0 734 * The length in bytes of buf
michael@0 735 * NOTES:
michael@0 736 * This function passes the buffer to the ASN1 decoder and creates a
michael@0 737 * CRMFCertReqMessages structure. Do not try adding any fields to a message
michael@0 738 * derived from this function. Specifically adding more Controls or
michael@0 739 * Extensions may cause your program to crash.
michael@0 740 * The user must call CRMF_DestroyCertReqMessages after the return value is
michael@0 741 * no longer needed, ie when all individual messages have been extracted.
michael@0 742 *
michael@0 743 * RETURN:
michael@0 744 * A pointer to the Certificate Request Messages structure. A NULL return
michael@0 745 * value indicates the library was unable to parse the DER.
michael@0 746 */
michael@0 747 extern CRMFCertReqMessages*
michael@0 748 CRMF_CreateCertReqMessagesFromDER(const char *buf, long len);
michael@0 749
michael@0 750 /*
michael@0 751 * FUNCTION: CRMF_DestroyCertReqMessages
michael@0 752 * INPUTS
michael@0 753 * inCertReqMsgs
michael@0 754 * The Messages to destroy.
michael@0 755 * RETURN:
michael@0 756 * SECSuccess if freeing the memory was done successfully. Any other
michael@0 757 * return value indicates an error in freeing up memory.
michael@0 758 */
michael@0 759 extern SECStatus
michael@0 760 CRMF_DestroyCertReqMessages(CRMFCertReqMessages *inCertReqMsgs);
michael@0 761
michael@0 762 /*
michael@0 763 * FUNCTION: CRMF_CertReqMessagesGetNumMessages
michael@0 764 * INPUTS:
michael@0 765 * inCertReqMsgs
michael@0 766 * The Request Messages to operate on.
michael@0 767 * RETURN:
michael@0 768 * The number of messages contained in the in the Request Messages
michael@0 769 * strucure.
michael@0 770 */
michael@0 771 extern int
michael@0 772 CRMF_CertReqMessagesGetNumMessages(CRMFCertReqMessages *inCertReqMsgs);
michael@0 773
michael@0 774 /*
michael@0 775 * FUNCTION: CRMF_CertReqMessagesGetCertReqMsgAtIndex
michael@0 776 * INPUTS:
michael@0 777 * inReqMsgs
michael@0 778 * The Certificate Request Messages to operate on.
michael@0 779 * index
michael@0 780 * The index of the single message the user wants a copy of.
michael@0 781 * NOTES:
michael@0 782 * This function returns a copy of the request messages stored at the
michael@0 783 * index corresponding to the parameter 'index'. Indexing of the messages
michael@0 784 * is done in the same manner as a C array. Meaning the valid index are
michael@0 785 * 0...numMessages-1. User must call CRMF_DestroyCertReqMsg when done using
michael@0 786 * the return value of this function.
michael@0 787 *
michael@0 788 * RETURN:
michael@0 789 * SECSuccess if copying the message at the requested index was successful.
michael@0 790 * Any other return value indicates an invalid index or error while copying
michael@0 791 * the single request message.
michael@0 792 */
michael@0 793 extern CRMFCertReqMsg*
michael@0 794 CRMF_CertReqMessagesGetCertReqMsgAtIndex(CRMFCertReqMessages *inReqMsgs,
michael@0 795 int index);
michael@0 796
michael@0 797
michael@0 798 /*
michael@0 799 * FUNCTION: CRMF_CertReqMsgGetID
michael@0 800 * INPUTS:
michael@0 801 * inCertReqMsg
michael@0 802 * The Certificate Request Message to get the ID from.
michael@0 803 * destID
michael@0 804 * A pointer to where the library can place the ID of the Message.
michael@0 805 * RETURN:
michael@0 806 * SECSuccess if the function was able to retrieve the ID and place it
michael@0 807 * at *destID. Any other return value indicates an error meaning the value
michael@0 808 * in *destId is un-reliable and should not be used by the caller of this
michael@0 809 * function.
michael@0 810 *
michael@0 811 */
michael@0 812 extern SECStatus CRMF_CertReqMsgGetID(CRMFCertReqMsg *inCertReqMsg,
michael@0 813 long *destID);
michael@0 814
michael@0 815 /*
michael@0 816 * FUNCTION: CRMF_DoesRequestHaveField
michael@0 817 * INPUTS:
michael@0 818 * inCertReq
michael@0 819 * The Certificate Request to operate on.
michael@0 820 * inField
michael@0 821 * An enumeration indicating which filed of the certificate template
michael@0 822 * to look for.
michael@0 823 * NOTES:
michael@0 824 * All the fields in a certificate template are optional. This function
michael@0 825 * checks to see if the requested field is present. Look in crmft.h at the
michael@0 826 * definition of CRMFCertTemplateField for possible values for possible
michael@0 827 * querying.
michael@0 828 *
michael@0 829 * RETURN:
michael@0 830 * PR_TRUE iff the field corresponding to 'inField' has been specified as part
michael@0 831 * of 'inCertReq'
michael@0 832 * PR_FALSE iff the field corresponding to 'inField' has not been speicified
michael@0 833 * as part of 'inCertReq'
michael@0 834 *
michael@0 835 */
michael@0 836 extern PRBool CRMF_DoesRequestHaveField(CRMFCertRequest *inCertReq,
michael@0 837 CRMFCertTemplateField inField);
michael@0 838
michael@0 839 /*
michael@0 840 * FUNCTION: CRMF_CertReqMsgGetCertRequest
michael@0 841 * INPUTS:
michael@0 842 * inCertReqMsg
michael@0 843 * The Certificate Request Message to operate on.
michael@0 844 * NOTES:
michael@0 845 * This function returns a copy of the Certificate Request to the user.
michael@0 846 * The user can keep adding to this request and then making it a part
michael@0 847 * of another message. After the user no longer wants to use the
michael@0 848 * returned request, the user must call CRMF_DestroyCertRequest and
michael@0 849 * pass it the request returned by this function.
michael@0 850 * RETURN:
michael@0 851 * A pointer to a copy of the certificate request contained by the message.
michael@0 852 * A NULL return value indicates an error occurred while copying the
michael@0 853 * certificate request.
michael@0 854 */
michael@0 855 extern CRMFCertRequest *
michael@0 856 CRMF_CertReqMsgGetCertRequest(CRMFCertReqMsg *inCertReqMsg);
michael@0 857
michael@0 858 /*
michael@0 859 * FUNCTION: CRMF_CertRequestGetCertTemplateVersion
michael@0 860 * INPUTS:
michael@0 861 * inCertReq
michael@0 862 * The Certificate Request to operate on.
michael@0 863 * version
michael@0 864 * A pointer to where the library can store the version contatined
michael@0 865 * in the certificate template within the certifcate request.
michael@0 866 * RETURN:
michael@0 867 * SECSuccess if the Certificate template contains the version field. In
michael@0 868 * this case, *version will hold the value of the certificate template
michael@0 869 * version.
michael@0 870 * SECFailure indicates that version field was not present as part of
michael@0 871 * of the certificate template.
michael@0 872 */
michael@0 873 extern SECStatus
michael@0 874 CRMF_CertRequestGetCertTemplateVersion(CRMFCertRequest *inCertReq,
michael@0 875 long *version);
michael@0 876
michael@0 877 /*
michael@0 878 * FUNCTION: CRMF_CertRequestGetCertTemplateSerialNumber
michael@0 879 * INPUTS:
michael@0 880 * inCertReq
michael@0 881 * The certificate request to operate on.
michael@0 882 * serialNumber
michael@0 883 * A pointer where the library can put the serial number contained
michael@0 884 * in the certificate request's certificate template.
michael@0 885 * RETURN:
michael@0 886 * If a serial number exists in the CertTemplate of the request, the function
michael@0 887 * returns SECSuccess and the value at *serialNumber contains the serial
michael@0 888 * number.
michael@0 889 * If no serial number is present, then the function returns SECFailure and
michael@0 890 * the value at *serialNumber is un-changed.
michael@0 891 */
michael@0 892 extern SECStatus
michael@0 893 CRMF_CertRequestGetCertTemplateSerialNumber(CRMFCertRequest *inCertReq,
michael@0 894 long *serialNumber);
michael@0 895
michael@0 896 /*
michael@0 897 * FUNCTION: CRMF_CertRequestGetCertTemplateSigningAlg
michael@0 898 * INPUT:
michael@0 899 * inCertReq
michael@0 900 * The Certificate Request to operate on.
michael@0 901 * destAlg
michael@0 902 * A Pointer to where the library can place a copy of the signing alg
michael@0 903 * used in the cert request's cert template.
michael@0 904 * RETURN:
michael@0 905 * If the signingAlg is present in the CertRequest's CertTemplate, then
michael@0 906 * the function returns SECSuccess and places a copy of sigingAlg in
michael@0 907 * *destAlg.
michael@0 908 * If no signingAlg is present, then the function returns SECFailure and
michael@0 909 * the value at *destAlg is un-changed
michael@0 910 */
michael@0 911 extern SECStatus
michael@0 912 CRMF_CertRequestGetCertTemplateSigningAlg(CRMFCertRequest *inCertReq,
michael@0 913 SECAlgorithmID *destAlg);
michael@0 914 /*
michael@0 915 * FUNCTION: CRMF_CertRequestGetCertTemplateIssuer
michael@0 916 * INPUTS:
michael@0 917 * inCertReq
michael@0 918 * The Certificate Request to operate on.
michael@0 919 * destIssuer
michael@0 920 * A pointer to where the library can place a copy of the cert
michael@0 921 * request's cert template issuer field.
michael@0 922 * RETURN:
michael@0 923 * If the issuer is present in the cert request cert template, the function
michael@0 924 * returns SECSuccess and places a copy of the issuer in *destIssuer.
michael@0 925 * If there is no issuer present, the function returns SECFailure and the
michael@0 926 * value at *destIssuer is unchanged.
michael@0 927 */
michael@0 928 extern SECStatus
michael@0 929 CRMF_CertRequestGetCertTemplateIssuer(CRMFCertRequest *inCertReq,
michael@0 930 CERTName *destIssuer);
michael@0 931
michael@0 932 /*
michael@0 933 * FUNCTION: CRMF_CertRequestGetCertTemplateValidity
michael@0 934 * INPUTS:
michael@0 935 * inCertReq
michael@0 936 * The Certificate Request to operate on.
michael@0 937 * destValdity
michael@0 938 * A pointer to where the library can place a copy of the validity
michael@0 939 * info in the cert request cert template.
michael@0 940 * NOTES:
michael@0 941 * Pass the pointer to
michael@0 942 * RETURN:
michael@0 943 * If there is an OptionalValidity field, the function will return SECSuccess
michael@0 944 * and place the appropriate values in *destValidity->notBefore and
michael@0 945 * *destValidity->notAfter. (Each field is optional, but at least one will
michael@0 946 * be present if the function returns SECSuccess)
michael@0 947 *
michael@0 948 * If there is no OptionalValidity field, the function will return SECFailure
michael@0 949 * and the values at *destValidity will be un-changed.
michael@0 950 */
michael@0 951 extern SECStatus
michael@0 952 CRMF_CertRequestGetCertTemplateValidity(CRMFCertRequest *inCertReq,
michael@0 953 CRMFGetValidity *destValidity);
michael@0 954 /*
michael@0 955 * FUNCTION: CRMF_DestroyGetValidity
michael@0 956 * INPUTS:
michael@0 957 * inValidity
michael@0 958 * A pointer to the memroy to be freed.
michael@0 959 * NOTES:
michael@0 960 * The function will free the memory allocated by the function
michael@0 961 * CRMF_CertRequestGetCertTemplateValidity. That means only memory pointed
michael@0 962 * to within the CRMFGetValidity structure. Since
michael@0 963 * CRMF_CertRequestGetCertTemplateValidity does not allocate memory for the
michael@0 964 * structure passed into it, it will not free it. Meaning this function will
michael@0 965 * free the memory at inValidity->notBefore and inValidity->notAfter, but not
michael@0 966 * the memory directly at inValdity.
michael@0 967 *
michael@0 968 * RETURN:
michael@0 969 * SECSuccess if freeing the memory was successful. Any other return value
michael@0 970 * indicates an error while freeing the memory.
michael@0 971 */
michael@0 972 extern SECStatus
michael@0 973 CRMF_DestroyGetValidity(CRMFGetValidity *inValidity);
michael@0 974
michael@0 975 /*
michael@0 976 * FUNCTION: CRMF_CertRequestGetCertTemplateSubject
michael@0 977 * INPUTS:
michael@0 978 * inCertReq
michael@0 979 * The Certificate Request to operate on.
michael@0 980 * destSubject
michael@0 981 * A pointer to where the library can place a copy of the subject
michael@0 982 * contained in the request's cert template.
michael@0 983 * RETURN:
michael@0 984 * If there is a subject in the CertTemplate, then the function returns
michael@0 985 * SECSuccess and a copy of the subject is placed in *destSubject.
michael@0 986 *
michael@0 987 * If there is no subject, the function returns SECFailure and the values at
michael@0 988 * *destSubject is unchanged.
michael@0 989 */
michael@0 990 extern SECStatus
michael@0 991 CRMF_CertRequestGetCertTemplateSubject (CRMFCertRequest *inCertReq,
michael@0 992 CERTName *destSubject);
michael@0 993
michael@0 994 /*
michael@0 995 * FUNCTION: CRMF_CertRequestGetCertTemplatePublicKey
michael@0 996 * INPUTS:
michael@0 997 * inCertReq
michael@0 998 * The Cert request to operate on.
michael@0 999 * destPublicKey
michael@0 1000 * A pointer to where the library can place a copy of the request's
michael@0 1001 * cert template public key.
michael@0 1002 * RETURN:
michael@0 1003 * If there is a publicKey parameter in the CertRequest, the function returns
michael@0 1004 * SECSuccess, and places a copy of the publicKey in *destPublicKey.
michael@0 1005 *
michael@0 1006 * If there is no publicKey, the function returns SECFailure and the value
michael@0 1007 * at *destPublicKey is un-changed.
michael@0 1008 */
michael@0 1009 extern SECStatus
michael@0 1010 CRMF_CertRequestGetCertTemplatePublicKey(CRMFCertRequest *inCertReq,
michael@0 1011 CERTSubjectPublicKeyInfo *destPublicKey);
michael@0 1012
michael@0 1013 /*
michael@0 1014 * FUNCTION: CRMF_CertRequestGetCertTemplateIssuerUID
michael@0 1015 * INPUTS:
michael@0 1016 * inCertReq
michael@0 1017 * The Cert request to operate on.
michael@0 1018 * destIssuerUID
michael@0 1019 * A pointer to where the library can store a copy of the request's
michael@0 1020 * cert template destIssuerUID.
michael@0 1021 *
michael@0 1022 * NOTES:
michael@0 1023 * destIssuerUID is a bit string and will be returned in a SECItem as
michael@0 1024 * a bit string. Meaning the len field contains the number of valid bits as
michael@0 1025 * opposed to the number of bytes allocated.
michael@0 1026 *
michael@0 1027 * RETURN:
michael@0 1028 * If the CertTemplate has an issuerUID, the function returns SECSuccess and
michael@0 1029 * places a copy of the issuerUID in *destIssuerUID.
michael@0 1030 *
michael@0 1031 * If there is no issuerUID, the function returns SECFailure and the value
michael@0 1032 * *destIssuerUID is unchanged.
michael@0 1033 */
michael@0 1034 extern SECStatus
michael@0 1035 CRMF_CertRequestGetCertTemplateIssuerUID(CRMFCertRequest *inCertReq,
michael@0 1036 SECItem *destIssuerUID);
michael@0 1037
michael@0 1038 /*
michael@0 1039 * FUNCTION: CRMF_CertRequestGetCertTemplateSubjectUID
michael@0 1040 * inCertReq
michael@0 1041 * The Cert request to operate on.
michael@0 1042 * destSubjectUID
michael@0 1043 * A pointer to where the library can store a copy of the request's
michael@0 1044 * cert template destIssuerUID.
michael@0 1045 *
michael@0 1046 * NOTES:
michael@0 1047 * destSubjectUID is a bit string and will be returned in a SECItem as
michael@0 1048 * a bit string. Meaning the len field contains the number of valid bits as
michael@0 1049 * opposed to the number of bytes allocated.
michael@0 1050 *
michael@0 1051 * RETURN:
michael@0 1052 * If the CertTemplate has an issuerUID, the function returns SECSuccess and
michael@0 1053 * places a copy of the issuerUID in *destIssuerUID.
michael@0 1054 *
michael@0 1055 * If there is no issuerUID, the function returns SECSuccess and the value
michael@0 1056 * *destIssuerUID is unchanged.
michael@0 1057 */
michael@0 1058 extern SECStatus CRMF_GetCertTemplateSubjectUID(CRMFCertRequest *inCertReq,
michael@0 1059 SECItem *destSubjectUID);
michael@0 1060
michael@0 1061 /*
michael@0 1062 * FUNCTION: CRMF_CertRequestGetNumberOfExtensions
michael@0 1063 * INPUTS:
michael@0 1064 * inCertReq
michael@0 1065 * The cert request to operate on.
michael@0 1066 * RETURN:
michael@0 1067 * Returns the number of extensions contained by the Cert Request.
michael@0 1068 */
michael@0 1069 extern int CRMF_CertRequestGetNumberOfExtensions(CRMFCertRequest *inCertReq);
michael@0 1070
michael@0 1071 /*
michael@0 1072 * FUNCTION: CRMF_CertRequestGetExtensionAtIndex
michael@0 1073 * INPUTS:
michael@0 1074 * inCertReq
michael@0 1075 * The Certificate request to operate on.
michael@0 1076 * index
michael@0 1077 * The index of the extension array whihc the user wants to access.
michael@0 1078 * NOTES:
michael@0 1079 * This function retrieves the extension at the index corresponding to the
michael@0 1080 * parameter "index" indicates. Indexing is done like a C array.
michael@0 1081 * (0 ... numElements-1)
michael@0 1082 *
michael@0 1083 * Call CRMF_DestroyCertExtension when done using the return value.
michael@0 1084 *
michael@0 1085 * RETURN:
michael@0 1086 * A pointer to a copy of the extension at the desired index. A NULL
michael@0 1087 * return value indicates an invalid index or an error while copying
michael@0 1088 * the extension.
michael@0 1089 */
michael@0 1090 extern CRMFCertExtension *
michael@0 1091 CRMF_CertRequestGetExtensionAtIndex(CRMFCertRequest *inCertReq,
michael@0 1092 int index);
michael@0 1093 /*
michael@0 1094 * FUNCTION: CRMF_CertExtensionGetOidTag
michael@0 1095 * INPUTS:
michael@0 1096 * inExtension
michael@0 1097
michael@0 1098 * The extension to operate on.
michael@0 1099 * RETURN:
michael@0 1100 * Returns the SECOidTag associated with the cert extension passed in.
michael@0 1101 */
michael@0 1102 extern SECOidTag CRMF_CertExtensionGetOidTag(CRMFCertExtension *inExtension);
michael@0 1103
michael@0 1104 /*
michael@0 1105 * FUNCTION: CRMF_CertExtensionGetIsCritical
michael@0 1106 * INPUT:
michael@0 1107 * inExt
michael@0 1108 * The cert extension to operate on.
michael@0 1109 *
michael@0 1110 * RETURN:
michael@0 1111 * PR_TRUE if the extension is critical.
michael@0 1112 * PR_FALSE if the extension is not critical.
michael@0 1113 */
michael@0 1114 extern PRBool CRMF_CertExtensionGetIsCritical(CRMFCertExtension *inExt);
michael@0 1115
michael@0 1116 /*
michael@0 1117 * FUNCTION: CRMF_CertExtensionGetValue
michael@0 1118 * INPUT:
michael@0 1119 * inExtension
michael@0 1120 * The extension to operate on.
michael@0 1121 * NOTES:
michael@0 1122 * Caller is responsible for freeing the memory associated with the return
michael@0 1123 * value. Call SECITEM_FreeItem(retVal, PR_TRUE) when done using the return
michael@0 1124 * value.
michael@0 1125 *
michael@0 1126 * RETURN:
michael@0 1127 * A pointer to an item containig the value for the certificate extension.
michael@0 1128 * A NULL return value indicates an error in copying the information.
michael@0 1129 */
michael@0 1130 extern SECItem* CRMF_CertExtensionGetValue(CRMFCertExtension *inExtension);
michael@0 1131
michael@0 1132 /*
michael@0 1133 * FUNCTION: CRMF_CertReqMsgGetPOPOSigningKey
michael@0 1134 * INPUTS:
michael@0 1135 * inCertReqMsg
michael@0 1136 * The certificate request message to operate on.
michael@0 1137 * destKey
michael@0 1138 * A pointer to where the library can place a pointer to
michael@0 1139 * a copy of the Proof Of Possession Signing Key used
michael@0 1140 * by the message.
michael@0 1141 *
michael@0 1142 * RETURN:
michael@0 1143 * Get the POPOSigningKey associated with this CRMFCertReqMsg.
michael@0 1144 * If the CertReqMsg does not have a pop, the function returns
michael@0 1145 * SECFailure and the value at *destKey is un-changed..
michael@0 1146 *
michael@0 1147 * If the CertReqMsg does have a pop, then the CertReqMsg's
michael@0 1148 * POPOSigningKey will be placed at *destKey.
michael@0 1149 */
michael@0 1150 extern SECStatus
michael@0 1151 CRMF_CertReqMsgGetPOPOSigningKey(CRMFCertReqMsg *inCertReqMsg,
michael@0 1152 CRMFPOPOSigningKey **destKey);
michael@0 1153
michael@0 1154 /*
michael@0 1155 * FUNCTION: CRMF_DestroyPOPOSigningKey
michael@0 1156 * INPUTS:
michael@0 1157 * inKey
michael@0 1158 * The signing key to free.
michael@0 1159 *
michael@0 1160 * RETURN:
michael@0 1161 * SECSuccess if freeing the memory was successful. Any other return value
michael@0 1162 * indicates an error while freeing memory.
michael@0 1163 */
michael@0 1164 extern SECStatus CRMF_DestroyPOPOSigningKey (CRMFPOPOSigningKey *inKey);
michael@0 1165
michael@0 1166 /*
michael@0 1167 * FUNCTION: CRMF_POPOSigningKeyGetAlgID
michael@0 1168 * INPUTS:
michael@0 1169 * inSignKey
michael@0 1170 * The Signing Key to operate on.
michael@0 1171 * RETURN:
michael@0 1172 * Return the algorithmID used by the CRMFPOPOSigningKey. User must
michael@0 1173 * call SECOID_DestroyAlgorithmID(destID, PR_TRUE) when done using the
michael@0 1174 * return value.
michael@0 1175 */
michael@0 1176 extern SECAlgorithmID*
michael@0 1177 CRMF_POPOSigningKeyGetAlgID(CRMFPOPOSigningKey *inSignKey);
michael@0 1178
michael@0 1179 /*
michael@0 1180 * FUNCTION: CRMF_POPOSigningKeyGetSignature
michael@0 1181 * INPUTS:
michael@0 1182 * inSignKey
michael@0 1183 * The Signing Key to operate on.
michael@0 1184 *
michael@0 1185 * RETURN:
michael@0 1186 * Get the actual signature stored away in the CRMFPOPOSigningKey. SECItem
michael@0 1187 * returned is a BIT STRING, so the len field is the number of bits as opposed
michael@0 1188 * to the total number of bytes allocatd. User must call
michael@0 1189 * SECITEM_FreeItem(retVal,PR_TRUE) when done using the return value.
michael@0 1190 */
michael@0 1191 extern SECItem* CRMF_POPOSigningKeyGetSignature(CRMFPOPOSigningKey *inSignKey);
michael@0 1192
michael@0 1193 /*
michael@0 1194 * FUNCTION: CRMF_POPOSigningKeyGetInput
michael@0 1195 * INPUTS:
michael@0 1196 * inSignKey
michael@0 1197 * The Signing Key to operate on.
michael@0 1198 * NOTES:
michael@0 1199 * This function will return the der encoded input that was read in while
michael@0 1200 * decoding. The API does not support this option when creating, so you
michael@0 1201 * cannot add this field.
michael@0 1202 *
michael@0 1203 * RETURN:
michael@0 1204 * Get the poposkInput that is part of the of the POPOSigningKey. If the
michael@0 1205 * optional field is not part of the POPOSigningKey, the function returns
michael@0 1206 * NULL.
michael@0 1207 *
michael@0 1208 * If the optional field is part of the POPOSingingKey, the function will
michael@0 1209 * return a copy of the der encoded poposkInput.
michael@0 1210 */
michael@0 1211 extern SECItem* CRMF_POPOSigningKeyGetInput(CRMFPOPOSigningKey *inSignKey);
michael@0 1212
michael@0 1213 /*
michael@0 1214 * FUNCTION: CRMF_CertReqMsgGetPOPKeyEncipherment
michael@0 1215 * INPUTS:
michael@0 1216 * inCertReqMsg
michael@0 1217 * The certificate request message to operate on.
michael@0 1218 * destKey
michael@0 1219 * A pointer to where the library can place a pointer to a
michael@0 1220 * copy of the POPOPrivKey representing Key Encipherment
michael@0 1221 * Proof of Possession.
michael@0 1222 *NOTES:
michael@0 1223 * This function gets the POPOPrivKey associated with this CRMFCertReqMsg
michael@0 1224 * for Key Encipherment.
michael@0 1225 *
michael@0 1226 * RETURN:
michael@0 1227 * If the CertReqMsg did not use Key Encipherment for Proof Of Possession, the
michael@0 1228 * function returns SECFailure and the value at *destKey is un-changed.
michael@0 1229 *
michael@0 1230 * If the CertReqMsg did use Key Encipherment for ProofOfPossession, the
michael@0 1231 * function returns SECSuccess and places the POPOPrivKey representing the
michael@0 1232 * Key Encipherment Proof Of Possessin at *destKey.
michael@0 1233 */
michael@0 1234 extern SECStatus
michael@0 1235 CRMF_CertReqMsgGetPOPKeyEncipherment(CRMFCertReqMsg *inCertReqMsg,
michael@0 1236 CRMFPOPOPrivKey **destKey);
michael@0 1237
michael@0 1238 /*
michael@0 1239 * FUNCTION: CRMF_CertReqMsgGetPOPKeyAgreement
michael@0 1240 * INPUTS:
michael@0 1241 * inCertReqMsg
michael@0 1242 * The certificate request message to operate on.
michael@0 1243 * destKey
michael@0 1244 * A pointer to where the library can place a pointer to a
michael@0 1245 * copy of the POPOPrivKey representing Key Agreement
michael@0 1246 * Proof of Possession.
michael@0 1247 * NOTES:
michael@0 1248 * This function gets the POPOPrivKey associated with this CRMFCertReqMsg for
michael@0 1249 * Key Agreement.
michael@0 1250 *
michael@0 1251 * RETURN:
michael@0 1252 * If the CertReqMsg used Key Agreement for Proof Of Possession, the
michael@0 1253 * function returns SECSuccess and the POPOPrivKey for Key Agreement
michael@0 1254 * is placed at *destKey.
michael@0 1255 *
michael@0 1256 * If the CertReqMsg did not use Key Agreement for Proof Of Possession, the
michael@0 1257 * function return SECFailure and the value at *destKey is unchanged.
michael@0 1258 */
michael@0 1259 extern SECStatus
michael@0 1260 CRMF_CertReqMsgGetPOPKeyAgreement(CRMFCertReqMsg *inCertReqMsg,
michael@0 1261 CRMFPOPOPrivKey **destKey);
michael@0 1262
michael@0 1263 /*
michael@0 1264 * FUNCTION: CRMF_DestroyPOPOPrivKey
michael@0 1265 * INPUTS:
michael@0 1266 * inPrivKey
michael@0 1267 * The POPOPrivKey to destroy.
michael@0 1268 * NOTES:
michael@0 1269 * Destroy a structure allocated by CRMF_GetPOPKeyEncipherment or
michael@0 1270 * CRMF_GetPOPKeyAgreement.
michael@0 1271 *
michael@0 1272 * RETURN:
michael@0 1273 * SECSuccess on successful destruction of the POPOPrivKey.
michael@0 1274 * Any other return value indicates an error in freeing the
michael@0 1275 * memory.
michael@0 1276 */
michael@0 1277 extern SECStatus CRMF_DestroyPOPOPrivKey(CRMFPOPOPrivKey *inPrivKey);
michael@0 1278
michael@0 1279 /*
michael@0 1280 * FUNCTION: CRMF_POPOPrivKeyGetChoice
michael@0 1281 * INPUT:
michael@0 1282 * inKey
michael@0 1283 * The POPOPrivKey to operate on.
michael@0 1284 * RETURN:
michael@0 1285 * Returns which choice was used in constructing the POPPOPrivKey. Look at
michael@0 1286 * the definition of CRMFPOPOPrivKeyChoice in crmft.h for the possible return
michael@0 1287 * values.
michael@0 1288 */
michael@0 1289 extern CRMFPOPOPrivKeyChoice CRMF_POPOPrivKeyGetChoice(CRMFPOPOPrivKey *inKey);
michael@0 1290
michael@0 1291 /*
michael@0 1292 * FUNCTION: CRMF_POPOPrivKeyGetThisMessage
michael@0 1293 * INPUTS:
michael@0 1294 * inKey
michael@0 1295 * The POPOPrivKey to operate on.
michael@0 1296 * destString
michael@0 1297 * A pointer to where the library can place a copy of the This Message
michael@0 1298 * field stored in the POPOPrivKey
michael@0 1299 *
michael@0 1300 * RETURN:
michael@0 1301 * Returns the field thisMessage from the POPOPrivKey.
michael@0 1302 * If the POPOPrivKey did not use the field thisMessage, the function
michael@0 1303 * returns SECFailure and the value at *destString is unchanged.
michael@0 1304 *
michael@0 1305 * If the POPOPrivKey did use the field thisMessage, the function returns
michael@0 1306 * SECSuccess and the BIT STRING representing thisMessage is placed
michael@0 1307 * at *destString. BIT STRING representation means the len field is the
michael@0 1308 * number of valid bits as opposed to the total number of bytes.
michael@0 1309 */
michael@0 1310 extern SECStatus CRMF_POPOPrivKeyGetThisMessage(CRMFPOPOPrivKey *inKey,
michael@0 1311 SECItem *destString);
michael@0 1312
michael@0 1313 /*
michael@0 1314 * FUNCTION: CRMF_POPOPrivKeyGetSubseqMess
michael@0 1315 * INPUTS:
michael@0 1316 * inKey
michael@0 1317 * The POPOPrivKey to operate on.
michael@0 1318 * destOpt
michael@0 1319 * A pointer to where the library can place the value of the
michael@0 1320 * Subsequent Message option used by POPOPrivKey.
michael@0 1321 *
michael@0 1322 * RETURN:
michael@0 1323 * Retrieves the field subsequentMessage from the POPOPrivKey.
michael@0 1324 * If the POPOPrivKey used the subsequentMessage option, the function
michael@0 1325 * returns SECSuccess and places the appropriate enumerated value at
michael@0 1326 * *destMessageOption.
michael@0 1327 *
michael@0 1328 * If the POPOPrivKey did not use the subsequenMessage option, the function
michael@0 1329 * returns SECFailure and the value at *destOpt is un-changed.
michael@0 1330 */
michael@0 1331 extern SECStatus CRMF_POPOPrivKeyGetSubseqMess(CRMFPOPOPrivKey *inKey,
michael@0 1332 CRMFSubseqMessOptions *destOpt);
michael@0 1333
michael@0 1334 /*
michael@0 1335 * FUNCTION: CRMF_POPOPrivKeyGetDHMAC
michael@0 1336 * INPUTS:
michael@0 1337 * inKey
michael@0 1338 * The POPOPrivKey to operate on.
michael@0 1339 * destMAC
michael@0 1340 * A pointer to where the library can place a copy of the dhMAC
michael@0 1341 * field of the POPOPrivKey.
michael@0 1342 *
michael@0 1343 * NOTES:
michael@0 1344 * Returns the field dhMAC from the POPOPrivKey. The populated SECItem
michael@0 1345 * is in BIT STRING format.
michael@0 1346 *
michael@0 1347 * RETURN:
michael@0 1348 * If the POPOPrivKey used the dhMAC option, the function returns SECSuccess
michael@0 1349 * and the BIT STRING for dhMAC will be placed at *destMAC. The len field in
michael@0 1350 * destMAC (ie destMAC->len) will be the valid number of bits as opposed to
michael@0 1351 * the number of allocated bytes.
michael@0 1352 *
michael@0 1353 * If the POPOPrivKey did not use the dhMAC option, the function returns
michael@0 1354 * SECFailure and the value at *destMAC is unchanged.
michael@0 1355 *
michael@0 1356 */
michael@0 1357 extern SECStatus CRMF_POPOPrivKeyGetDHMAC(CRMFPOPOPrivKey *inKey,
michael@0 1358 SECItem *destMAC);
michael@0 1359
michael@0 1360 /*
michael@0 1361 * FUNCTION: CRMF_CertRequestGetNumControls
michael@0 1362 * INPUTS:
michael@0 1363 * inCertReq
michael@0 1364 * The Certificate Request to operate on.
michael@0 1365 * RETURN:
michael@0 1366 * Returns the number of Controls registered with this CertRequest.
michael@0 1367 */
michael@0 1368 extern int CRMF_CertRequestGetNumControls (CRMFCertRequest *inCertReq);
michael@0 1369
michael@0 1370 /*
michael@0 1371 * FUNCTION: CRMF_CertRequestGetControlAtIndex
michael@0 1372 * INPUTS:
michael@0 1373 * inCertReq
michael@0 1374 * The certificate request to operate on.
michael@0 1375 * index
michael@0 1376 * The index of the control the user wants a copy of.
michael@0 1377 * NOTES:
michael@0 1378 * Function retrieves the Control at located at index. The Controls
michael@0 1379 * are numbered like a traditional C array (0 ... numElements-1)
michael@0 1380 *
michael@0 1381 * RETURN:
michael@0 1382 * Returns a copy of the control at the index specified. This is a copy
michael@0 1383 * so the user must call CRMF_DestroyControl after the return value is no
michael@0 1384 * longer needed. A return value of NULL indicates an error while copying
michael@0 1385 * the control or that the index was invalid.
michael@0 1386 */
michael@0 1387 extern CRMFControl*
michael@0 1388 CRMF_CertRequestGetControlAtIndex(CRMFCertRequest *inCertReq,
michael@0 1389 int index);
michael@0 1390
michael@0 1391 /*
michael@0 1392 * FUNCTION: CRMF_DestroyControl
michael@0 1393 * INPUTS:
michael@0 1394 * inControl
michael@0 1395 * The Control to destroy.
michael@0 1396 * NOTES:
michael@0 1397 * Destroy a CRMFControl allocated by CRMF_GetControlAtIndex.
michael@0 1398 *
michael@0 1399 * RETURN:
michael@0 1400 * SECSuccess if freeing the memory was successful. Any other return
michael@0 1401 * value indicates an error while freeing the memory.
michael@0 1402 */
michael@0 1403 extern SECStatus CRMF_DestroyControl(CRMFControl *inControl);
michael@0 1404
michael@0 1405 /*
michael@0 1406 * FUNCTION: CRMF_ControlGetControlType
michael@0 1407 * INPUTS:
michael@0 1408 * inControl
michael@0 1409 * The control to operate on.
michael@0 1410 * NOTES:
michael@0 1411 * The function returns an enumertion which indicates the type of control
michael@0 1412 * 'inControl'.
michael@0 1413 *
michael@0 1414 * RETURN:
michael@0 1415 * Look in crmft.h at the definition of the enumerated type CRMFControlType
michael@0 1416 * for the possible return values.
michael@0 1417 */
michael@0 1418 extern CRMFControlType CRMF_ControlGetControlType(CRMFControl *inControl);
michael@0 1419
michael@0 1420 /*
michael@0 1421 * FUNCTION: CRMF_ControlGetRegTokenControlValue
michael@0 1422 * INPUTS:
michael@0 1423 * inControl
michael@0 1424 * The Control to operate on.
michael@0 1425 * NOTES:
michael@0 1426 * The user must call SECITEM_FreeItem passing in the return value
michael@0 1427 * after the returnvalue is no longer needed.
michael@0 1428
michael@0 1429 * RETURN:
michael@0 1430 * Return the value for a Registration Token Control.
michael@0 1431 * The SECItem returned should be in UTF8 format. A NULL
michael@0 1432 * return value indicates there was no Registration Control associated
michael@0 1433 * with the Control.
michael@0 1434 * (This library will not verify format. It assumes the client properly
michael@0 1435 * formatted the strings when adding it or the message decoded was properly
michael@0 1436 * formatted. The library will just give back the bytes it was given.)
michael@0 1437 */
michael@0 1438 extern SECItem* CRMF_ControlGetRegTokenControlValue(CRMFControl *inControl);
michael@0 1439
michael@0 1440 /*
michael@0 1441 * FUNCTION: CRMF_ControlGetAuthenticatorControlValue
michael@0 1442 * INPUTS:
michael@0 1443 * inControl
michael@0 1444 * The Control to operate on.
michael@0 1445 * NOTES:
michael@0 1446 * The user must call SECITEM_FreeItem passing in the return value
michael@0 1447 * after the returnvalue is no longer needed.
michael@0 1448 *
michael@0 1449 * RETURN:
michael@0 1450 * Return the value for the Authenticator Control.
michael@0 1451 * The SECItem returned should be in UTF8 format. A NULL
michael@0 1452 * return value indicates there was no Authenticator Control associated
michael@0 1453 * with the CRMFControl..
michael@0 1454 * (This library will not verify format. It assumes the client properly
michael@0 1455 * formatted the strings when adding it or the message decoded was properly
michael@0 1456 * formatted. The library will just give back the bytes it was given.)
michael@0 1457 */
michael@0 1458 extern SECItem* CRMF_ControlGetAuthicatorControlValue(CRMFControl *inControl);
michael@0 1459
michael@0 1460 /*
michael@0 1461 * FUNCTION: CRMF_ControlGetPKIArchiveOptions
michael@0 1462 * INPUTS:inControl
michael@0 1463 * The Control tooperate on.
michael@0 1464 * NOTES:
michael@0 1465 * This function returns a copy of the PKIArchiveOptions. The user must call
michael@0 1466 * the function CRMF_DestroyPKIArchiveOptions when the return value is no
michael@0 1467 * longer needed.
michael@0 1468 *
michael@0 1469 * RETURN:
michael@0 1470 * Get the PKIArchiveOptions associated with the Control. A return
michael@0 1471 * value of NULL indicates the Control was not a PKIArchiveOptions
michael@0 1472 * Control.
michael@0 1473 */
michael@0 1474 extern CRMFPKIArchiveOptions*
michael@0 1475 CRMF_ControlGetPKIArchiveOptions(CRMFControl *inControl);
michael@0 1476
michael@0 1477 /*
michael@0 1478 * FUNCTION: CMRF_DestroyPKIArchiveOptions
michael@0 1479 * INPUTS:
michael@0 1480 * inOptions
michael@0 1481 * The ArchiveOptions to destroy.
michael@0 1482 * NOTE:
michael@0 1483 * Destroy the CRMFPKIArchiveOptions structure.
michael@0 1484 *
michael@0 1485 * RETURN:
michael@0 1486 * SECSuccess if successful in freeing all the memory associated with
michael@0 1487 * the PKIArchiveOptions. Any other return value indicates an error while
michael@0 1488 * freeing the PKIArchiveOptions.
michael@0 1489 */
michael@0 1490 extern SECStatus
michael@0 1491 CRMF_DestroyPKIArchiveOptions(CRMFPKIArchiveOptions *inOptions);
michael@0 1492
michael@0 1493 /*
michael@0 1494 * FUNCTION: CRMF_PKIArchiveOptionsGetOptionType
michael@0 1495 * INPUTS:
michael@0 1496 * inOptions
michael@0 1497 * The PKIArchiveOptions to operate on.
michael@0 1498 * RETURN:
michael@0 1499 * Returns the choice used for the PKIArchiveOptions. Look at the definition
michael@0 1500 * of CRMFPKIArchiveOptionsType in crmft.h for possible return values.
michael@0 1501 */
michael@0 1502 extern CRMFPKIArchiveOptionsType
michael@0 1503 CRMF_PKIArchiveOptionsGetOptionType(CRMFPKIArchiveOptions *inOptions);
michael@0 1504
michael@0 1505 /*
michael@0 1506 * FUNCTION: CRMF_PKIArchiveOptionsGetEncryptedPrivKey
michael@0 1507 * INPUTS:
michael@0 1508 * inOpts
michael@0 1509 * The PKIArchiveOptions to operate on.
michael@0 1510 *
michael@0 1511 * NOTES:
michael@0 1512 * The user must call CRMF_DestroyEncryptedKey when done using this return
michael@0 1513 * value.
michael@0 1514 *
michael@0 1515 * RETURN:
michael@0 1516 * Get the encryptedPrivKey field of the PKIArchiveOptions structure.
michael@0 1517 * A return value of NULL indicates that encryptedPrivKey was not used as
michael@0 1518 * the choice for this PKIArchiveOptions.
michael@0 1519 */
michael@0 1520 extern CRMFEncryptedKey*
michael@0 1521 CRMF_PKIArchiveOptionsGetEncryptedPrivKey(CRMFPKIArchiveOptions *inOpts);
michael@0 1522
michael@0 1523 /*
michael@0 1524 * FUNCTION: CRMF_EncryptedKeyGetChoice
michael@0 1525 * INPUTS:
michael@0 1526 * inEncrKey
michael@0 1527 * The EncryptedKey to operate on.
michael@0 1528 *
michael@0 1529 * NOTES:
michael@0 1530 * Get the choice used for representing the EncryptedKey.
michael@0 1531 *
michael@0 1532 * RETURN:
michael@0 1533 * Returns the Choice used in representing the EncryptedKey. Look in
michael@0 1534 * crmft.h at the definition of CRMFEncryptedKeyChoice for possible return
michael@0 1535 * values.
michael@0 1536 */
michael@0 1537 extern CRMFEncryptedKeyChoice
michael@0 1538 CRMF_EncryptedKeyGetChoice(CRMFEncryptedKey *inEncrKey);
michael@0 1539
michael@0 1540
michael@0 1541 /*
michael@0 1542 * FUNCTION: CRMF_EncryptedKeyGetEncryptedValue
michael@0 1543 * INPUTS:
michael@0 1544 * inKey
michael@0 1545 * The EncryptedKey to operate on.
michael@0 1546 *
michael@0 1547 * NOTES:
michael@0 1548 * The user must call CRMF_DestroyEncryptedValue passing in
michael@0 1549 * CRMF_GetEncryptedValue's return value.
michael@0 1550 *
michael@0 1551 * RETURN:
michael@0 1552 * A pointer to a copy of the EncryptedValue contained as a member of
michael@0 1553 * the EncryptedKey.
michael@0 1554 */
michael@0 1555 extern CRMFEncryptedValue*
michael@0 1556 CRMF_EncryptedKeyGetEncryptedValue(CRMFEncryptedKey *inKey);
michael@0 1557
michael@0 1558 /*
michael@0 1559 * FUNCTION: CRMF_DestroyEncryptedValue
michael@0 1560 * INPUTS:
michael@0 1561 * inEncrValue
michael@0 1562 * The EncryptedValue to destroy.
michael@0 1563 *
michael@0 1564 * NOTES:
michael@0 1565 * Free up all memory associated with 'inEncrValue'.
michael@0 1566 *
michael@0 1567 * RETURN:
michael@0 1568 * SECSuccess if freeing up the memory associated with the EncryptedValue
michael@0 1569 * is successful. Any other return value indicates an error while freeing the
michael@0 1570 * memory.
michael@0 1571 */
michael@0 1572 extern SECStatus CRMF_DestroyEncryptedValue(CRMFEncryptedValue *inEncrValue);
michael@0 1573
michael@0 1574 /*
michael@0 1575 * FUNCTION: CRMF_EncryptedValueGetEncValue
michael@0 1576 * INPUTS:
michael@0 1577 * inEncValue
michael@0 1578 * The EncryptedValue to operate on.
michael@0 1579 * NOTES:
michael@0 1580 * Function retrieves the encValue from an EncryptedValue structure.
michael@0 1581 *
michael@0 1582 * RETURN:
michael@0 1583 * A poiner to a SECItem containing the encValue of the EncryptedValue
michael@0 1584 * structure. The return value is in BIT STRING format, meaning the
michael@0 1585 * len field of the return structure represents the number of valid bits
michael@0 1586 * as opposed to the allocated number of bytes.
michael@0 1587 * ANULL return value indicates an error in copying the encValue field.
michael@0 1588 */
michael@0 1589 extern SECItem* CRMF_EncryptedValueGetEncValue(CRMFEncryptedValue *inEncValue);
michael@0 1590
michael@0 1591 /*
michael@0 1592 * FUNCTION: CRMF_EncryptedValueGetIntendedAlg
michael@0 1593 * INPUTS
michael@0 1594 * inEncValue
michael@0 1595 * The EncryptedValue to operate on.
michael@0 1596 * NOTES:
michael@0 1597 * Retrieve the IntendedAlg field from the EncryptedValue structure.
michael@0 1598 * Call SECOID_DestroyAlgorithmID (destAlgID, PR_TRUE) after done using
michael@0 1599 * the return value. When present, this alogorithm is the alogrithm for
michael@0 1600 * which the private key will be used.
michael@0 1601 *
michael@0 1602 * RETURN:
michael@0 1603 * A Copy of the intendedAlg field. A NULL return value indicates the
michael@0 1604 * optional field was not present in the structure.
michael@0 1605 */
michael@0 1606 extern SECAlgorithmID*
michael@0 1607 CRMF_EncryptedValueGetIntendedAlg(CRMFEncryptedValue *inEncValue);
michael@0 1608
michael@0 1609
michael@0 1610 /*
michael@0 1611 * FUNCTION: CRMF_EncryptedValueGetSymmAlg
michael@0 1612 * INPUTS
michael@0 1613 * inEncValue
michael@0 1614 * The EncryptedValue to operate on.
michael@0 1615 * NOTES:
michael@0 1616 * Retrieve the symmAlg field from the EncryptedValue structure.
michael@0 1617 * Call SECOID_DestroyAlgorithmID (destAlgID, PR_TRUE) after done using
michael@0 1618 * the return value. When present, this is algorithm used to
michael@0 1619 * encrypt the encValue of the EncryptedValue.
michael@0 1620 *
michael@0 1621 * RETURN:
michael@0 1622 * A Copy of the symmAlg field. A NULL return value indicates the
michael@0 1623 * optional field was not present in the structure.
michael@0 1624 */
michael@0 1625 extern SECAlgorithmID*
michael@0 1626 CRMF_EncryptedValueGetSymmAlg(CRMFEncryptedValue *inEncValue);
michael@0 1627
michael@0 1628
michael@0 1629 /*
michael@0 1630 * FUNCTION: CRMF_EncryptedValueGetKeyAlg
michael@0 1631 * INPUTS
michael@0 1632 * inEncValue
michael@0 1633 * The EncryptedValue to operate on.
michael@0 1634 * NOTES:
michael@0 1635 * Retrieve the keyAlg field from the EncryptedValue structure.
michael@0 1636 * Call SECOID_DestroyAlgorithmID (destAlgID, PR_TRUE) after done using
michael@0 1637 * the return value. When present, this is the algorithm used to encrypt
michael@0 1638 * the symmetric key in the encSymmKey field of the EncryptedValue structure.
michael@0 1639 *
michael@0 1640 * RETURN:
michael@0 1641 * A Copy of the keyAlg field. A NULL return value indicates the
michael@0 1642 * optional field was not present in the structure.
michael@0 1643 */
michael@0 1644 extern SECAlgorithmID*
michael@0 1645 CRMF_EncryptedValueGetKeyAlg(CRMFEncryptedValue *inEncValue);
michael@0 1646
michael@0 1647 /*
michael@0 1648 * FUNCTION: CRMF_EncryptedValueGetValueHint
michael@0 1649 * INPUTS:
michael@0 1650 * inEncValue
michael@0 1651 * The EncryptedValue to operate on.
michael@0 1652 *
michael@0 1653 * NOTES:
michael@0 1654 * Return a copy of the der-encoded value hint.
michael@0 1655 * User must call SECITEM_FreeItem(retVal, PR_TRUE) when done using the
michael@0 1656 * return value. When, present, this is a value that the client which
michael@0 1657 * originally issued a certificate request can use to reproduce any data
michael@0 1658 * it wants. The RA does not know how to interpret this data.
michael@0 1659 *
michael@0 1660 * RETURN:
michael@0 1661 * A copy of the valueHint field of the EncryptedValue. A NULL return
michael@0 1662 * value indicates the optional valueHint field is not present in the
michael@0 1663 * EncryptedValue.
michael@0 1664 */
michael@0 1665 extern SECItem*
michael@0 1666 CRMF_EncryptedValueGetValueHint(CRMFEncryptedValue *inEncValue);
michael@0 1667
michael@0 1668 /*
michael@0 1669 * FUNCTION: CRMF_EncrypteValueGetEncSymmKey
michael@0 1670 * INPUTS:
michael@0 1671 * inEncValue
michael@0 1672 * The EncryptedValue to operate on.
michael@0 1673 *
michael@0 1674 * NOTES:
michael@0 1675 * Return a copy of the encSymmKey field. This field is the encrypted
michael@0 1676 * symmetric key that the client uses in doing Public Key wrap of a private
michael@0 1677 * key. When present, this is the symmetric key that was used to wrap the
michael@0 1678 * private key. (The encrypted private key will be stored in encValue
michael@0 1679 * of the same EncryptedValue structure.) The user must call
michael@0 1680 * SECITEM_FreeItem(retVal, PR_TRUE) when the return value is no longer
michael@0 1681 * needed.
michael@0 1682 *
michael@0 1683 * RETURN:
michael@0 1684 * A copy of the optional encSymmKey field of the EncryptedValue structure.
michael@0 1685 * The return value will be in BIT STRING format, meaning the len field will
michael@0 1686 * be the number of valid bits as opposed to the number of bytes. A return
michael@0 1687 * value of NULL means the optional encSymmKey field was not present in
michael@0 1688 * the EncryptedValue structure.
michael@0 1689 */
michael@0 1690 extern SECItem*
michael@0 1691 CRMF_EncryptedValueGetEncSymmKey(CRMFEncryptedValue *inEncValue);
michael@0 1692
michael@0 1693 /*
michael@0 1694 * FUNCTION: CRMF_PKIArchiveOptionsGetKeyGenParameters
michael@0 1695 * INPUTS:
michael@0 1696 * inOptions
michael@0 1697 * The PKiArchiveOptions to operate on.
michael@0 1698 *
michael@0 1699 * NOTES:
michael@0 1700 * User must call SECITEM_FreeItem(retVal, PR_TRUE) after the return
michael@0 1701 * value is no longer needed.
michael@0 1702 *
michael@0 1703 * RETURN:
michael@0 1704 * Get the keyGenParameters field of the PKIArchiveOptions.
michael@0 1705 * A NULL return value indicates that keyGenParameters was not
michael@0 1706 * used as the choice for this PKIArchiveOptions.
michael@0 1707 *
michael@0 1708 * The SECItem returned is in BIT STRING format (ie, the len field indicates
michael@0 1709 * number of valid bits as opposed to allocated number of bytes.)
michael@0 1710 */
michael@0 1711 extern SECItem*
michael@0 1712 CRMF_PKIArchiveOptionsGetKeyGenParameters(CRMFPKIArchiveOptions *inOptions);
michael@0 1713
michael@0 1714 /*
michael@0 1715 * FUNCTION: CRMF_PKIArchiveOptionsGetArchiveRemGenPrivKey
michael@0 1716 * INPUTS:
michael@0 1717 * inOpt
michael@0 1718 * The PKIArchiveOptions to operate on.
michael@0 1719 * destVal
michael@0 1720 * A pointer to where the library can place the value for
michael@0 1721 * arciveRemGenPrivKey
michael@0 1722 * RETURN:
michael@0 1723 * If the PKIArchiveOptions used the archiveRemGenPrivKey field, the
michael@0 1724 * function returns SECSuccess and fills the value at *destValue with either
michael@0 1725 * PR_TRUE or PR_FALSE, depending on what the PKIArchiveOptions has as a
michael@0 1726 * value.
michael@0 1727 *
michael@0 1728 * If the PKIArchiveOptions does not use the archiveRemGenPrivKey field, the
michael@0 1729 * function returns SECFailure and the value at *destValue is unchanged.
michael@0 1730 */
michael@0 1731 extern SECStatus
michael@0 1732 CRMF_PKIArchiveOptionsGetArchiveRemGenPrivKey(CRMFPKIArchiveOptions *inOpt,
michael@0 1733 PRBool *destVal);
michael@0 1734
michael@0 1735 /* Helper functions that can be used by other libraries. */
michael@0 1736 /*
michael@0 1737 * A quick helper function to get the best wrap mechanism.
michael@0 1738 */
michael@0 1739 extern CK_MECHANISM_TYPE CRMF_GetBestWrapPadMechanism(PK11SlotInfo *slot);
michael@0 1740
michael@0 1741 /*
michael@0 1742 * A helper function to get a randomly generated IV from a mechanism
michael@0 1743 * type.
michael@0 1744 */
michael@0 1745 extern SECItem* CRMF_GetIVFromMechanism(CK_MECHANISM_TYPE mechType);
michael@0 1746
michael@0 1747 SEC_END_PROTOS
michael@0 1748 #endif /*_CRMF_H_*/
michael@0 1749
michael@0 1750

mercurial