ber_der.h revision 56664548661c43ae04de4a32bce3510ed36aeaf9
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0(the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http:/ /www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright(C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* This is the header file for some Basic Encoding Rules and Distinguished
*/
#ifndef BER_DER_H
#define BER_DER_H
#include <kmfapi.h>
#define BER_BOOLEAN 1
#define BER_INTEGER 2
#define BER_BIT_STRING 3
#define BER_OCTET_STRING 4
#define BER_NULL 5
#define BER_OBJECT_IDENTIFIER 6
#define BER_ENUMERATED 10
#define BER_UTF8_STRING 12
#define BER_SEQUENCE 16
#define BER_SET 17
#define BER_PRINTABLE_STRING 19
#define BER_T61STRING 20
#define BER_IA5STRING 22
#define BER_UTCTIME 23
#define BER_GENTIME 24
#define BER_GENERALSTRING 27
#define BER_UNIVERSAL_STRING 28
#define BER_BMP_STRING 30
#define BER_CLASS_MASK 0xc0
#define BER_CLASS_UNIVERSAL 0x00
#define BER_CLASS_APPLICATION 0x40
#define BER_CLASS_CONTEXTSPECIFIC 0x80
#define BER_CLASS_PRIVATE 0xc0
#define BER_CONSTRUCTED 0x20
#define KMFBER_BIG_TAG_MASK 0x1f
#define KMFBER_MORE_TAG_MASK 0x80
#define KMFBER_DEFAULT 0xFFFFFFFF
#define KMFBER_ERROR 0xFFFFFFFF
#define KMFBER_END_OF_SEQORSET 0xfffffffe
#define KMFBER_OPT_REMAINING_BYTES 0x01
#define KMFBER_OPT_TOTAL_BYTES 0x02
#define KMFBER_OPT_USE_DER 0x04
#define KMFBER_OPT_TRANSLATE_STRINGS 0x08
#define KMFBER_OPT_BYTES_TO_WRITE 0x10
#define KMFBER_OPT_DEBUG_LEVEL 0x40
typedef long ber_slen_t; /* signed equivalent of ber_len_t */
typedef struct berelement BerElement;
typedef int (*BERTranslateProc)(char **, ber_uint_t *, int);
typedef struct berval {
char *bv_val;
} BerValue;
#define SAFEMEMCPY(d, s, n) memmove(d, s, n)
int kmfber_calc_taglen(ber_tag_t);
int kmfber_calc_lenlen(ber_int_t);
/*
* public decode routines
*/
void kmfber_bvfree(struct berval *);
void kmfber_bvecfree(struct berval **);
/*
* public encoding routines
*/
extern int kmfber_printf(BerElement *, const char *, ...);
/*
* miscellaneous public routines
*/
extern BerElement* kmfber_alloc(void);
extern BerElement* kmfder_alloc(void);
extern BerElement* kmfber_alloc_t(int);
extern void kmfber_reset(BerElement *, int);
KMF_X509_CERTIFICATE **);
KMF_DATA *);
KMF_X509_TBS_CERT **);
KMF_DATA **);
KMF_X509_SPKI **);
#endif /* BER_DER_H */