nsspkix.h
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 3,005 行 · 第 1/5 页
H
3,005 行
/* * 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 NSSPKIX_H#define NSSPKIX_H#ifdef DEBUGstatic const char NSSPKIX_CVS_ID[] = "@(#) $Source: /cvsroot/mozilla/security/nss/lib/pkix/include/nsspkix.h,v $ $Revision: 1.1 $ $Date: 2000/03/31 19:02:06 $ $Name: NSS_3_1_1_RTM $";#endif /* DEBUG *//* * nsspkix.h * * This file contains the prototypes for the public methods defined * for the PKIX part-1 objects. */#ifndef NSSPKIXT_H#include "nsspkixt.h"#endif /* NSSPKIXT_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 public 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 * *//* * 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);/* * 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 public 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 *//* * NSSPKIXAttributeTypeAndValue_Decode * * * * The error may be one of the following values: * NSS_ERROR_INVALID_BER * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * * Return value: * A valid pointer to an NSSPKIXAttributeTypeAndValue upon success * NULL upon failure */NSS_EXTERN NSSPKIXAttributeTypeAndValue *NSSPKIXAttributeTypeAndValue_Decode( NSSArena *arenaOpt, NSSBER *ber);/* * NSSPKIXAttributeTypeAndValue_CreateFromUTF8 * * * * The error may be one of the following values: * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * NSS_ERROR_INVALID_STRING * NSS_ERROR_UNKNOWN_ATTRIBUTE * * Return value: * A valid pointer to an NSSPKIXAttributeTypeAndValue upon success * NULL upon failure */NSS_EXTERN NSSPKIXAttributeTypeAndValue *NSSPKIXAttributeTypeAndValue_CreateFromUTF8( NSSArena *arenaOpt, NSSUTF8 *string
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?