asn1.h
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 880 行 · 第 1/2 页
H
880 行
/* * 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 ASN1_H#define ASN1_H#ifdef DEBUGstatic const char ASN1_CVS_ID[] = "@(#) $RCSfile: asn1.h,v $ $Revision: 1.1 $ $Date: 2000/03/31 19:54:58 $ $Name: NSS_3_1_1_RTM $";#endif /* DEBUG *//* * asn1.h * * This file contains the ASN.1 encoder/decoder routines available * internally within NSS. It's not clear right now if this file * will be folded into base.h or something, I just needed to get this * going. At the moment, most of these routines wrap the old SEC_ASN1 * calls. */#ifndef ASN1T_H#include "asn1t.h"#endif /* ASN1T_H */#ifndef BASE_H#include "base.h"#endif /* BASE_H */PR_BEGIN_EXTERN_C/* * nssASN1Decoder * * ... description here ... * * nssASN1Decoder_Create (Factory/Constructor) * nssASN1Decoder_Update * nssASN1Decoder_Finish (Destructor) * nssASN1Decoder_SetFilter * nssASN1Decoder_GetFilter * nssASN1Decoder_SetNotify * nssASN1Decoder_GetNotify * * Debug builds only: * * nssASN1Decoder_verify * * Related functions that aren't type methods: * * nssASN1_Decode * nssASN1_DecodeBER *//* * nssASN1Decoder_Create * * This routine creates an ASN.1 Decoder, which will use the specified * template to decode a datastream into the specified destination * structure. If the optional arena argument is non-NULL, blah blah * blah. XXX fgmr Should we include an nssASN1EncodingType argument, * as a hint? Or is each encoding distinctive? This routine may * return NULL upon error, in which case an error will have been * placed upon the error stack. * * The error may be one of the following values: * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * NSS_ERROR_INVALID_POINTER * ... * * Return value: * NULL upon error * A pointer to an ASN.1 Decoder upon success. */NSS_EXTERN nssASN1Decoder *nssASN1Decoder_Create( NSSArena *arenaOpt, void *destination, const nssASN1Template template[]);extern const NSSError NSS_ERROR_NO_MEMORY;extern const NSSError NSS_ERROR_INVALID_ARENA;extern const NSSError NSS_ERROR_INVALID_POINTER;/* * nssASN1Decoder_Update * * This routine feeds data to the decoder. In the event of an error, * it will place an error on the error stack and return PR_FAILURE. * * The error may be one of the following values: * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_POINTER * NSS_ERROR_INVALID_ASN1DECODER * NSS_ERROR_INVALID_BER * ... * * Return value: * PR_FAILURE upon error * PR_SUCCESS upon success. */NSS_EXTERN PRStatusnssASN1Decoder_Update( nssASN1Decoder *decoder, const void *data, PRUint32 amount);extern const NSSError NSS_ERROR_NO_MEMORY;extern const NSSError NSS_ERROR_INVALID_ASN1DECODER;extern const NSSError NSS_ERROR_INVALID_BER;/* * nssASN1Decoder_Finish * * This routine finishes the decoding and destroys the decoder. * In the event of an error, it will place an error on the error * stack and return PR_FAILURE. * * The error may be one of the following values: * NSS_ERROR_INVALID_ASN1DECODER * * Return value: * PR_FAILURE upon error * PR_SUCCESS upon success */NSS_EXTERN PRStatusnssASN1Decoder_Finish( nssASN1Decoder *decoder);extern const NSSError NSS_ERROR_INVALID_ASN1DECODER;/* * nssASN1Decoder_SetFilter * * This routine registers a callback filter routine with the decoder, * which will be called blah blah blah. The specified argument will * be passed as-is to the filter routine. The routine pointer may * be NULL, in which case no filter callback will be called. If the * noStore boolean is PR_TRUE, then decoded fields will not be stored * in the destination structure specified when the decoder was * created. This routine returns a PRStatus value; in the event of * an error, it will place an error on the error stack and return * PR_FAILURE. * * The error may be one of the following values: * NSS_ERROR_INVALID_ASN1DECODER * * Return value: * PR_FAILURE upon error * PR_SUCCESS upon success */NSS_EXTERN PRStatusnssASN1Decoder_SetFilter( nssASN1Decoder *decoder, nssASN1DecoderFilterFunction *callback, void *argument, PRBool noStore);extern const NSSError NSS_ERROR_INVALID_ASN1DECODER;/* * nssASN1Decoder_GetFilter * * If the optional pCallbackOpt argument to this routine is non-null, * then the pointer to any callback function established for this * decoder with nssASN1Decoder_SetFilter will be stored at the * location indicated by it. If the optional pArgumentOpt * pointer is non-null, the filter's closure argument will be stored * there. If the optional pNoStoreOpt pointer is non-null, the * noStore value specified when setting the filter will be stored * there. This routine returns a PRStatus value; in the event of * an error it will place an error on the error stack and return * PR_FAILURE. * * The error may be one of the following values: * NSS_ERROR_INVALID_ASN1DECODER * * Return value: * PR_FAILURE upon error * PR_SUCCESS upon success */NSS_EXTERN PRStatusnssASN1Decoder_GetFilter( nssASN1Decoder *decoder, nssASN1DecoderFilterFunction **pCallbackOpt, void **pArgumentOpt, PRBool *pNoStoreOpt);extern const NSSError NSS_ERROR_INVALID_ASN1DECODER;/* * nssASN1Decoder_SetNotify * * This routine registers a callback notify routine with the decoder, * which will be called whenever.. The specified argument will be * passed as-is to the notify routine. The routine pointer may be * NULL, in which case no notify routine will be called. This routine * returns a PRStatus value; in the event of an error it will place * an error on the error stack and return PR_FAILURE. * * The error may be one of the following values: * NSS_ERROR_INVALID_ASN1DECODER * * Return value: * PR_FAILURE upon error * PR_SUCCESS upon success */NSS_EXTERN PRStatusnssASN1Decoder_SetNotify( nssASN1Decoder *decoder, nssASN1NotifyFunction *callback, void *argument);extern const NSSError NSS_ERROR_INVALID_ASN1DECODER;/* * nssASN1Decoder_GetNotify * * If the optional pCallbackOpt argument to this routine is non-null, * then the pointer to any callback function established for this * decoder with nssASN1Decoder_SetNotify will be stored at the * location indicated by it. If the optional pArgumentOpt pointer is * non-null, the filter's closure argument will be stored there. * This routine returns a PRStatus value; in the event of an error it * will place an error on the error stack and return PR_FAILURE. * * The error may be one of the following values: * NSS_ERROR_INVALID_ASN1DECODER * * Return value: * PR_FAILURE upon error * PR_SUCCESS upon success */NSS_EXTERN PRStatusnssASN1Decoder_GetNotify( nssASN1Decoder *decoder, nssASN1NotifyFunction **pCallbackOpt, void **pArgumentOpt);extern const NSSError NSS_ERROR_INVALID_ASN1DECODER;/* * nssASN1Decoder_verify * * This routine is only available in debug builds. * * If the specified pointer is a valid pointer to an nssASN1Decoder * 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_ASN1DECODER * * Return value: * PR_FAILURE upon error * PR_SUCCESS upon success */#ifdef DEBUGNSS_EXTERN PRStatusnssASN1Decoder_verify( nssASN1Decoder *decoder);extern const NSSError NSS_ERROR_INVALID_ASN1DECODER;#endif /* DEBUG *//* * nssASN1_Decode * * This routine will decode the specified data into the specified * destination structure, as specified by the specified template. * This routine returns a PRStatus value; in the event of an error * it will place an error on the error stack and return PR_FAILURE. * * The error may be one of the following values: * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * NSS_ERROR_INVALID_POINTER * NSS_ERROR_INVALID_BER * * Return value: * PR_FAILURE upon error * PR_SUCCESS upon success */NSS_EXTERN PRStatusnssASN1_Decode( NSSArena *arenaOpt, void *destination, const nssASN1Template template[], const void *berData, PRUint32 amount);extern const NSSError NSS_ERROR_NO_MEMORY;extern const NSSError NSS_ERROR_INVALID_ARENA;extern const NSSError NSS_ERROR_INVALID_POINTER;extern const NSSError NSS_ERROR_INVALID_BER;/* * nssASN1_DecodeBER * * This routine will decode the data in the specified NSSBER * into the destination structure, as specified by the template. * This routine returns a PRStatus value; in the event of an error * it will place an error on the error stack and return PR_FAILURE. * * The error may be one of the following values: * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * NSS_ERROR_INVALID_POINTER * NSS_ERROR_INVALID_NSSBER * NSS_ERROR_INVALID_BER * * Return value: * PR_FAILURE upon error * PR_SUCCESS upon success */NSS_EXTERN PRStatusnssASN1_DecodeBER( NSSArena *arenaOpt, void *destination, const nssASN1Template template[], const NSSBER *data);extern const NSSError NSS_ERROR_NO_MEMORY;extern const NSSError NSS_ERROR_INVALID_ARENA;extern const NSSError NSS_ERROR_INVALID_POINTER;extern const NSSError NSS_ERROR_INVALID_BER;/* * nssASN1Encoder * * ... description here ... * * nssASN1Encoder_Create (Factory/Constructor) * nssASN1Encoder_Update * nssASN1Encoder_Finish (Destructor) * nssASN1Encoder_SetNotify * nssASN1Encoder_GetNotify * nssASN1Encoder_SetStreaming * nssASN1Encoder_GetStreaming * nssASN1Encoder_SetTakeFromBuffer * nssASN1Encoder_GetTakeFromBuffer * * Debug builds only: * * nssASN1Encoder_verify * * Related functions that aren't type methods: * * nssASN1_Encode * nssASN1_EncodeItem *//* * nssASN1Encoder_Create * * This routine creates an ASN.1 Encoder, blah blah blah. This * may return NULL upon error, in which case an error will have been * placed on the error stack. * * The error may be one of the following values: * NSS_ERROR_NO_MEMORY * NSS_ERROR_INVALID_ARENA * NSS_ERROR_INVALID_POINTER * NSS_ERROR_ENCODING_NOT_SUPPORTED * ... * * Return value: * NULL upon error * A pointer to an ASN.1 Encoder upon success */NSS_EXTERN nssASN1Encoder *nssASN1Encoder_Create( const void *source, const nssASN1Template template[], NSSASN1EncodingType encoding, nssASN1EncoderWriteFunction *sink, void *argument);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?