pkix.h
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 2,998 行 · 第 1/5 页
H
2,998 行
/* * 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 PKIX_H#define PKIX_H#ifdef DEBUGstatic const char PKIX_CVS_ID[] = "@(#) $Source: /cvsroot/mozilla/security/nss/lib/pkix/include/pkix.h,v $ $Revision: 1.1 $ $Date: 2000/03/31 19:02:56 $ $Name: NSS_3_1_1_RTM $";#endif /* DEBUG *//* * pkix.h * * This file contains the prototypes for the private methods defined * for the PKIX part-1 objects. */#ifndef NSSPKIX_H#include "nsspkix.h"#endif /* NSSPKIX_H */#ifndef PKIXT_H#include "pkixt.h"#endif /* PKIXT_H */#ifndef ASN1T_H#include "asn1t.h"#endif /* ASN1T_H */PR_BEGIN_EXTERN_C/* * Attribute * * -- fgmr comments -- * * From RFC 2459: * * Attribute ::= SEQUENCE { * type AttributeType, * values SET OF AttributeValue * -- at least one value is required -- } * * The private calls for the type: * * nssPKIXAttribute_Decode * nssPKIXAttribute_Create * nssPKIXAttribute_CreateFromArray * nssPKIXAttribute_Destroy * nssPKIXAttribute_Encode * nssPKIXAttribute_GetType * nssPKIXAttribute_SetType * nssPKIXAttribute_GetValueCount * nssPKIXAttribute_GetValues * nssPKIXAttribute_SetValues * nssPKIXAttribute_GetValue * nssPKIXAttribute_SetValue * nssPKIXAttribute_AddValue * nssPKIXAttribute_RemoveValue * nssPKIXAttribute_FindValue * nssPKIXAttribute_Equal * nssPKIXAttribute_Duplicate * * In debug builds, the following call is available: * * nssPKIXAttribute_verifyPointer *//* * nssPKIXAttribute_template * * */extern const nssASN1Template nssPKIXAttribute_template[];/* * nssPKIXAttribute_Decode * * This routine creates an NSSPKIXAttribute by decoding a BER- * or DER-encoded Attribute as defined in RFC 2459. This * routine may return NULL upon error, in which case it will * have created an error stack. If the optional arena argument * is non-NULL, that arena will be used for the required memory. * * The error may be one of the following values: * NSS_ERROR_INVALID_BER * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * NSS_ERROR_INVALID_ITEM * * Return value: * A valid pointer to an NSSPKIXAttribute upon success * NULL upon failure. */NSS_EXTERN NSSPKIXAttribute *nssPKIXAttribute_Decode( NSSArena *arenaOpt, NSSBER *ber);/* * nssPKIXAttribute_Create * * This routine creates an NSSPKIXAttribute from specified components. * This routine may return NULL upon error, in which case it will have * created an error stack. If the optional arena argument is non-NULL, * that arena will be used for the required memory. There must be at * least one attribute value specified. The final argument must be * NULL, to indicate the end of the set of attribute values. * * The error may be one of the following values: * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * NSS_ERROR_INVALID_OID * NSS_ERROR_INVALID_ITEM * * Return value: * A valid pointer to an NSSPKIXAttribute upon success * NULL upon failure. */NSS_EXTERN NSSPKIXAttribute *nssPKIXAttribute_Create( NSSArena *arenaOpt, NSSPKIXAttributeType *typeOid, NSSPKIXAttributeValue *value1, ...);/* * nssPKIXAttribute_CreateFromArray * * This routine creates an NSSPKIXAttribute from specified components. * This routine may return NULL upon error, in which case it will have * created an error stack. If the optional arena argument is non-NULL, * that arena will be used for the required memory. There must be at * least one attribute value specified. The final argument must be * NULL, to indicate the end of the set of attribute values. * * The error may be one of the following values: * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * NSS_ERROR_INVALID_OID * NSS_ERROR_INVALID_ITEM * * Return value: * A valid pointer to an NSSPKIXAttribute upon success * NULL upon failure. */NSS_EXTERN NSSPKIXAttribute *nssPKIXAttribute_CreateFromArray( NSSArena *arenaOpt, NSSPKIXAttributeType *typeOid, PRUint32 count, NSSPKIXAttributeValue values[]);/* * nssPKIXAttribute_Destroy * * This routine destroys an NSSPKIXAttribute. It should be called on * all such objects created without an arena. It does not need to be * called for objects created with an arena, but it may be. This * routine returns a PRStatus value. Upon error, it will create an * error stack and return PR_FAILURE. * * The error value may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * * Return value: * PR_SUCCESS upon success * PR_FAILURE upon failure */NSS_EXTERN PRStatusnssPKIXAttribute_Destroy( NSSPKIXAttribute *attribute);/* * nssPKIXAttribute_Encode * * This routine returns the BER encoding of the specified * NSSPKIXAttribute. {usual rules about itemOpt and arenaOpt} * This routine indicates an error (NSS_ERROR_INVALID_DATA) * if there are no attribute values (i.e., the last one was removed). * * The error value may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_INVALID_ARENA * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_DATA * * Return value: * A valid NSSBER pointer upon success * NULL upon failure */NSS_EXTERN NSSBER *nssPKIXAttribute_Encode( NSSPKIXAttribute *attribute, NSSASN1EncodingType encoding, NSSBER *rvOpt, NSSArena *arenaOpt);/* * nssPKIXAttribute_GetType * * This routine returns the attribute type oid of the specified * NSSPKIXAttribute. * * The error value may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_NO_MEMORY * * Return value: * A valid NSSPKIXAttributeType pointer upon success * NULL upon failure. */NSS_EXTERN NSSPKIXAttributeType *nssPKIXAttribute_GetType( NSSPKIXAttribute *attribute);/* * nssPKIXAttribute_SetType * * This routine sets the attribute type oid of the indicated * NSSPKIXAttribute to the specified value. Since attributes * may be application-defined, no checking can be done on * either the correctness of the attribute type oid value nor * the suitability of the set of attribute values. * * The error value may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_INVALID_OID * * Return value: * PR_SUCCESS upon success * PR_FAILURE upon failure */NSS_EXTERN PRStatusnssPKIXAttribute_SetType( NSSPKIXAttribute *attribute, NSSPKIXAttributeType *attributeType);/* * nssPKIXAttribute_GetValueCount * * This routine returns the number of attribute values present in * the specified NSSPKIXAttribute. This routine returns a PRInt32. * Upon error, this routine returns -1. This routine indicates an * error if the number of values cannot be expressed as a PRInt32. * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_VALUE_OUT_OF_RANGE * * Return value: * Nonnegative integer upon success * -1 upon failure. */NSS_EXTERN PRInt32nssPKIXAttribute_GetValueCount( NSSPKIXAttribute *attribute);/* * nssPKIXAttribute_GetValues * * This routine returns all of the attribute values in the specified * NSSPKIXAttribute. If the optional pointer to an array of NSSItems * is non-null, then that array will be used and returned; otherwise, * an array will be allocated and returned. If the limit is nonzero * (which is must be if the specified array is nonnull), then an * error is indicated if it is smaller than the value count. * {arenaOpt} * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_INVALID_ARENA * NSS_ERROR_NO_MEMORY * NSS_ERROR_ARRAY_TOO_SMALL * * Return value: * A valid pointer to an array of NSSItem's upon success * NULL upon failure. */NSS_EXTERN NSSPKIXAttributeValue *nssPKIXAttribute_GetValues( NSSPKIXAttribute *attribute, NSSPKIXAttributeValue rvOpt[], PRInt32 limit, NSSArena *arenaOpt);/* * nssPKIXAttribute_SetValues * * This routine sets all of the values of the specified * NSSPKIXAttribute to the values in the specified NSSItem array. * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_INVALID_POINTER * NSS_ERROR_ARRAY_TOO_SMALL * * Return value: * PR_SUCCESS upon success * PR_FAILURE upon failure */NSS_EXTERN PRStatusnssPKIXAttribute_SetValues( NSSPKIXAttribute *attribute, NSSPKIXAttributeValue values[], PRInt32 count);/* * nssPKIXAttribute_GetValue * * This routine returns the i'th attribute value of the set of * values in the specified NSSPKIXAttribute. Although the set * is unordered, an arbitrary ordering will be maintained until * the data in the attribute is changed. {usual comments about * itemOpt and arenaOpt} * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_VALUE_OUT_OF_RANGE * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * * Return value: * A valid pointer to an NSSPKIXAttributeValue upon success * NULL upon failure */NSS_EXTERN NSSPKIXAttributeValue *nssPKIXAttribute_GetValue( NSSPKIXAttribute *attribute, PRInt32 i, NSSPKIXAttributeValue *itemOpt, NSSArena *arenaOpt);/* * nssPKIXAttribute_SetValue * * This routine sets the i'th attribute value {blah blah; copies * memory contents over..} * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_VALUE_OUT_OF_RANGE * NSS_ERROR_INVALID_ITEM * NSS_ERROR_NO_MEMORY * * Return value: * PR_SUCCESS upon success * PR_FAILURE upon failure */NSS_EXTERN PRStatusnssPKIXAttribute_SetValue( NSSPKIXAttribute *attribute, PRInt32 i, NSSPKIXAttributeValue *value);/* * nssPKIXAttribute_AddValue * * This routine adds the specified attribute value to the set in * the specified NSSPKIXAttribute. * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_INVALID_ITEM * NSS_ERROR_NO_MEMORY * * Return value: * PR_SUCCESS upon success * PR_FAILURE upon failure */NSS_EXTERN PRStatusnssPKIXAttribute_AddValue( NSSPKIXAttribute *attribute, NSSPKIXAttributeValue *value); /* * nssPKIXAttribute_RemoveValue * * This routine removes the i'th attribute value of the set in the * specified NSSPKIXAttribute. An attempt to remove the last value * will fail. * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_VALUE_OUT_OF_RANGE * NSS_ERROR_AT_MINIMUM * * Return value: * PR_SUCCESS upon success * PR_FAILURE upon failure */NSS_EXTERN PRStatusnssPKIXAttribute_RemoveValue( NSSPKIXAttribute *attribute, PRInt32 i);/* * nssPKIXAttribute_FindValue * * This routine searches the set of attribute values in the specified * NSSPKIXAttribute for the provided data. If an exact match is found, * then that value's index is returned. If an exact match is not * found, -1 is returned. If there is more than one exact match, one * index will be returned. {notes about unorderdness of SET, etc} * If the index may not be represented as an integer, an error is * indicated. * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_INVALID_ITEM * NSS_ERROR_NOT_FOUND * NSS_ERROR_VALUE_OUT_OF_RANGE * * Return value * The index of the specified attribute value upon success * -1 upon failure. */NSS_EXTERN PRInt32nssPKIXAttribute_FindValue( NSSPKIXAttribute *attribute, NSSPKIXAttributeValue *attributeValue);/* * nssPKIXAttribute_Equal * * This routine compares two NSSPKIXAttribute's for equality. * It returns PR_TRUE if they are equal, PR_FALSE otherwise. * This routine also returns PR_FALSE upon error; if you're * that worried about it, check for an error stack. * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * * Return value: * PR_TRUE if the two objects have equal values * PR_FALSE otherwise * PR_FALSE upon error */NSS_EXTERN PRBoolnssPKIXAttribute_Equal( NSSPKIXAttribute *one, NSSPKIXAttribute *two, PRStatus *statusOpt);/* * nssPKIXAttribute_Duplicate * * This routine duplicates an NSSPKIXAttribute. {arenaOpt} * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * NSS_ERROR_INVALID_ARENA * NSS_ERROR_NO_MEMORY * * Return value: * A valid pointer to an NSSPKIXAttribute upon success * NULL upon failure. */NSS_EXTERN NSSPKIXAttribute *nssPKIXAttribute_Duplicate( NSSPKIXAttribute *attribute, NSSArena *arenaOpt);#ifdef DEBUG/* * nssPKIXAttribute_verifyPointer * * This method is only present in debug builds. * * If the specified pointer is a valid pointer to an NSSPKIXAttribute * object, this routine will return PR_SUCCESS. Otherwise, it will * put an error on the error stack and return PR_FAILURE. * * The error may be one of the following values: * NSS_ERROR_INVALID_PKIX_ATTRIBUTE * * Return value: * PR_SUCCESS if the pointer is valid * PR_FAILURE if it isn't */NSS_EXTERN PRStatusnssPKIXAttribute_verifyPointer( NSSPKIXAttribute *p);#endif /* DEBUG *//* * AttributeTypeAndValue * * This structure contains an attribute type (indicated by an OID), * and the type-specific value. RelativeDistinguishedNames consist * of a set of these. These are distinct from Attributes (which have * SET of values), from AttributeDescriptions (which have qualifiers * on the types), and from AttributeValueAssertions (which assert a * a value comparison under some matching rule). * * From RFC 2459: * * AttributeTypeAndValue ::= SEQUENCE { * type AttributeType, * value AttributeValue } * * The private calls for the type: * * nssPKIXAttributeTypeAndValue_Decode * nssPKIXAttributeTypeAndValue_CreateFromUTF8 * nssPKIXAttributeTypeAndValue_Create * nssPKIXAttributeTypeAndValue_Destroy * nssPKIXAttributeTypeAndValue_Encode * nssPKIXAttributeTypeAndValue_GetUTF8Encoding * nssPKIXAttributeTypeAndValue_GetType * nssPKIXAttributeTypeAndValue_SetType * nssPKIXAttributeTypeAndValue_GetValue * nssPKIXAttributeTypeAndValue_SetValue * nssPKIXAttributeTypeAndValue_Equal * nssPKIXAttributeTypeAndValue_Duplicate
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?