crmf.h
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 1,780 行 · 第 1/5 页
H
1,780 行
/* -*- Mode: C; tab-width: 8 -*-*//* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the Netscape security libraries. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1994-2000 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. */#ifndef _CRMF_H_#define _CRMF_H_#include "seccomon.h"#include "cert.h"#include "crmft.h"#include "secoid.h"#include "secpkcs7.h"SEC_BEGIN_PROTOS/* * FUNCTION: CRMF_EncodeCertReqMsg * INPUTS: * inCertReqMsg * The Certificate Request Message to be encoded. * fn * A Callback function that the ASN1 encoder calls whenever * the encoder wants to write out some DER encoded bytes. * arg * An opaque pointer that gets passed to the function fn * OUTPUT: * The function fn will be called multiple times. Look at the * comments in crmft.h where the CRMFEncoderOutputCallback type is * defined for information on proper behavior of the function fn. * RETURN: * SECSuccess if encoding was successful. Any other return value * indicates an error occurred during encoding. */extern SECStatus CRMF_EncodeCertReqMsg (CRMFCertReqMsg *inCertReqMsg, CRMFEncoderOutputCallback fn, void *arg);/* * FUNCTION: CRMF_EncoderCertRequest * INPUTS: * inCertReq * The Certificate Request to be encoded. * fn * A Callback function that the ASN1 encoder calls whenever * the encoder wants to write out some DER encoded bytes. * arg * An opaque pointer that gets passed to the function fn. * OUTPUT: * The function fn will be called, probably multiple times whenever * the ASN1 encoder wants to write out DER-encoded bytes. Look at the * comments in crmft.h where the CRMFEncoderOuputCallback type is * defined for information on proper behavior of the funciton fn. * RETURN: * SECSuccess if encoding was successful. Any other return value * indicates an error occured during encoding. */extern SECStatus CRMF_EncodeCertRequest (CRMFCertRequest *inCertReq, CRMFEncoderOutputCallback fn, void *arg);/* * FUNCTION: CRMF_EncodeCertReqMessages * INPUTS: * inCertReqMsgs * An array of pointers to the Certificate Request Messages * to encode. The user must place a NULL pointer in the index * after the last message to be encoded. When the library runs * into the NULL pointer, the library assumes there are no more * messages to encode. * fn * A Callback function that the ASN1 encoder calls whenever * the encoder wants to write out some DER encoded byts. * arg * An opaque pointer that gets passed to the function fn. * * NOTES: * The parameter inCertReqMsgs needs to be an array with a NULL pointer * to signal the end of messages. An array in the form of * {m1, m2, m3, NULL, m4, ...} will only encode the messages m1, m2, and * m3. All messages from m4 on will not be looked at by the library. * * OUTPUT: * The function fn will be called, probably multiple times. Look at the * comments in crmft.h where the CRMFEncoderOuputCallback type is * defined for information on proper behavior of the funciton fn. * * RETURN: * SECSuccess if encoding the Certificate Request Messages was successful. * Any other return value indicates an error occurred while encoding the * certificate request messages. */extern SECStatus CRMF_EncodeCertReqMessages(CRMFCertReqMsg **inCertReqMsgs, CRMFEncoderOutputCallback fn, void *arg);/* * FUNCTION: CRMF_CreateCertReqMsg * INPUTS: * NONE * OUTPUT: * An empty CRMF Certificate Request Message. * Before encoding this message, the user must set * the ProofOfPossession field and the certificate * request which are necessary for the full message. * After the user no longer needs this CertReqMsg, * the user must call CRMF_DestroyCertReqMsg to free * all memory associated with the Certificate Request * Message. * RETURN: * A pointer to a Certificate Request Message. The user * must pass the return value of this function to * CRMF_DestroyCertReqMsg after the Certificate Request * Message is no longer necessary. */extern CRMFCertReqMsg* CRMF_CreateCertReqMsg(void);/* * FUNCTION: CRMF_DestroyCertReqMsg * INPUTS: * inCertReqMsg * The Certificate Request Message to destroy. * NOTES: * This function frees all the memory used for the Certificate * Request Message and all the memory used in making copies of * fields of elelments of the message, eg. the Proof Of Possession * filed and the Cetificate Request. * RETURN: * SECSuccess if destruction was successful. Any other return value * indicates an error while trying to free the memory associated * with inCertReqMsg. * */extern SECStatus CRMF_DestroyCertReqMsg(CRMFCertReqMsg *inCertReqMsg);/* * FUNCTION: CRMF_CertReqMsgSetCertRequest * INPUTS: * inCertReqMsg * The Certificate Request Message that the function will set * the certificate request for. * inCertReq * The Certificate Request that will be added to the Certificate * Request Message. * NOTES: * This function will make a copy of the Certificate Request passed in * and store it as part of the Certificate Request Message. Therefore, * the user must not call this function until the Certificate Request * has been fully built and is ready to be encoded. * RETURN: * SECSuccess * If copying the Certificate as a member of the Certificate * request message was successful. * Any other return value indicates a failure to copy the Certificate * Request and make it a part of the Certificate Request Message. */extern SECStatus CRMF_CertReqMsgSetCertRequest(CRMFCertReqMsg *inCertReqMsg, CRMFCertRequest *inCertReq);/* * FUNCTION: CRMF_CreateCertRequest * INPUTS: * inRequestID * The ID that will be associated with this certificate request. * OUTPUTS: * A certificate request which only has the requestID set. * NOTES: * The user must call the function CRMF_DestroyCertRequest when * the returned value is no longer needed. This is usually the * case after fully constructing the Certificate Request and then * calling the function CRMF_CertReqMsgSetCertRequest. * RETURN: * A pointer to the new Certificate Request. A NULL return value * indicates an error in creating the Certificate Request. */extern CRMFCertRequest *CRMF_CreateCertRequest (long inRequestID);/* * FUNCTION: CRMF_DestroyCertRequest * INPUTS: * inCertReq * The Certificate Request that will be destroyed. * RETURN: * SECSuccess * If freeing the memory associated with the certificate request * was successful. * Any other return value indicates an error while trying to free the * memory. */extern SECStatus CRMF_DestroyCertRequest (CRMFCertRequest *inCertReq);/* * FUNCTION: CRMF_CreateCertExtension * INPUTS: * id * The SECOidTag to associate with this CertExtension. This must * correspond to a valid Certificate Extension, if not the function * will fail. * isCritical * A boolean value stating if the extension value is crtical. PR_TRUE * means the value is crtical. PR_FALSE indicates the value is not * critical. * data * This is the data associated with the extension. The user of the * library is responsible for making sure the value passed in is a * valid interpretation of the certificate extension. * NOTES: * Use this function to create CRMFCertExtension Structures which will * then be passed to CRMF_AddFieldToCertTemplate as part of the * CRMFCertCreationInfo.extensions The user must call * CRMF_DestroyCertExtension after the extension has been added to a certifcate * and the extension is no longer needed. * * RETURN: * A pointer to a newly created CertExtension. A return value of NULL * indicates the id passed in was an invalid certificate extension. */extern CRMFCertExtension *CRMF_CreateCertExtension(SECOidTag id, PRBool isCritical, SECItem *data);/* * FUNCTION: CMRF_DestroyCertExtension * INPUTS: * inExtension * The Cert Extension to destroy * NOTES: * Destroy a structure allocated by CRMF_CreateCertExtension. * * RETURN: * SECSuccess if freeing the memory associated with the certificate extension * was successful. Any other error indicates an error while freeing the * memory. */extern SECStatus CRMF_DestroyCertExtension(CRMFCertExtension *inExtension);/* * FUNCTION: CRMF_CertRequestSetTemplateField * INPUTS: * inCertReq * The Certificate Request to operate on. * inTemplateField * An enumeration that indicates which field of the Certificate * template to add. * data * A generic pointer that will be type cast according to the * table under NOTES and used as the key for adding to the * certificate template; * NOTES: * * Below is a table that tells what type to pass in as data * depending on the template field one wants to set. * * Look in crmft.h for the definition of CRMFCertTemplateField. * * In all cases, the library makes copies of the data passed in. * * CRMFCertTemplateField Type of data What data means * --------------------- ------------ --------------- * crmfVersion long * The version of * the certificate * to be created. * * crmfSerialNumber long * The serial number * for the cert to be * created. * * crmfSigningAlg SECAlgorithm * The ASN.1 object ID for * the algorithm used in encoding * the certificate. * * crmfIssuer CERTName * Certificate Library * representation of the ASN1 type * Name from X.509 * * crmfValidity CRMFValidityCreationInfo * At least one of the two * fields in the structure must * be present. A NULL pointer * in the structure indicates * that member should not be * added. * * crmfSubject CERTName * Certificate Library * representation of the ASN1 type * Name from X.509 * * crmfPublicKey CERTSubjectPublicKeyInfo * The public key info for the * certificate being requested. * * crmfIssuerUID SECItem * A bit string representation * of the issuer UID. NOTE: The * length is the number of bits * and not the number of bytes. * * crmfSubjectUID SECItem* A bit string representation * of the subject UID. NOTE: The * length is the number of bits * and not the number of bytes. * * crmfExtension CRMFCertExtCreationInfo * A pointer to the structure * populated with an array of * of certificate extensions * and an integer that tells * how many elements are in the * array. Look in crmft.h for * the definition of * CRMFCertExtCreationInfo * RETURN: * SECSuccess if adding the desired field to the template was successful. * Any other return value indicates failure when trying to add the field * to the template. * */extern SECStatus CRMF_CertRequestSetTemplateField(CRMFCertRequest *inCertReq, CRMFCertTemplateField inTemplateField, void *data);/* * FUNCTION: CRMF_CertRequestIsFieldPresent * INPUTS: * inCertReq * The certificate request to operate on. * inTemplateField
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?