asn1.h

Go to the documentation of this file.
00001 #ifndef PRO_ASN1_H
00002 #define PRO_ASN1_H
00003 
00004 /*
00005  * Copyright 1998-2007 by egnite Software GmbH
00006  * Copyright 1988, 1989, 1991, 1992 by Carnegie Mellon University
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  * 3. Neither the name of the copyright holders nor the names of
00018  *    contributors may be used to endorse or promote products derived
00019  *    from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00028  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00029  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00030  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00031  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * For additional information see http://www.ethernut.de/
00035  */
00036 
00046 #include <sys/types.h>
00047 
00048 #ifndef MAX_OID_LEN
00049 #define MAX_OID_LEN     32
00050 #endif
00051 
00052 #define MAX_SUBID   0xFFFFFFFF
00053 
00054 #define MIN_OID_LEN     2
00055 
00056 #define ASN_BOOLEAN     0x01
00057 #define ASN_INTEGER     0x02
00058 #define ASN_BIT_STR     0x03
00059 #define ASN_OCTET_STR   0x04
00060 #define ASN_NULL        0x05
00061 #define ASN_OBJECT_ID   0x06
00062 #define ASN_SEQUENCE    0x10
00063 #define ASN_SET         0x11
00064 
00065 #define ASN_UNIVERSAL   0x00
00066 #define ASN_APPLICATION 0x40
00067 #define ASN_CONTEXT     0x80
00068 #define ASN_PRIVATE     0xC0
00069 
00070 #define ASN_PRIMITIVE   0x00
00071 #define ASN_CONSTRUCTOR 0x20
00072 
00073 #define ASN_LONG_LEN        0x80
00074 #define ASN_EXTENSION_ID    0x1F
00075 
00076 /* RFC 1157. */
00077 #define ASN_IPADDRESS   (ASN_APPLICATION | 0)
00078 #define ASN_COUNTER     (ASN_APPLICATION | 1)
00079 #define ASN_GAUGE       (ASN_APPLICATION | 2)
00080 #define ASN_UNSIGNED    (ASN_APPLICATION | 2)
00081 #define ASN_TIMETICKS   (ASN_APPLICATION | 3)
00082 #define ASN_OPAQUE      (ASN_APPLICATION | 4)
00083 
00084 /*RFC 1442. */ 
00085 #define ASN_NSAP        (ASN_APPLICATION | 5)
00086 #define ASN_COUNTER64   (ASN_APPLICATION | 6)
00087 #define ASN_UINTEGER    (ASN_APPLICATION | 7)
00088 
00089 #define ACL_RONLY       0xAAAA  /* read access for everyone */
00090 #define ACL_RWRITE      0xAABA  /* add write access for community private */
00091 #define ACL_NOACCESS    0x0000  /* no access for anybody */
00092 
00093 #define ASN_BIT8        0x80
00094 
00095 typedef u_long OID;
00096 
00097 /* 
00098  * Internal 64 bit representation.
00099  */
00100 typedef struct {
00101     u_long high;
00102     u_long low;
00103 } UNSIGNED64;
00104 
00105 extern const u_char *AsnHeaderParse(const u_char *, size_t *, u_char *);
00106 extern u_char *AsnHeaderBuild(u_char *, size_t *, u_char, size_t);
00107 
00108 extern const u_char * AsnSequenceParse(const u_char *, size_t *, u_char);
00109 extern u_char *AsnSequenceBuild(u_char *, size_t *, u_char, size_t);
00110 
00111 extern const u_char *AsnIntegerParse(const u_char *, size_t *, u_char *, long *);
00112 extern u_char *AsnIntegerBuild(u_char *, size_t *, u_char, long *);
00113 
00114 extern const u_char *AsnUnsignedParse(const u_char *, size_t *, u_char *, u_long *);
00115 extern u_char *AsnUnsignedBuild(u_char *, size_t *, u_char, u_long *);
00116 
00117 extern const u_char *AsnOctetStringParse(const u_char *, size_t *, u_char *, u_char *, size_t *);
00118 extern u_char *AsnOctetStringBuild(u_char *, size_t *, u_char, const u_char *, size_t);
00119 
00120 extern const u_char *AsnOidParse(const u_char *, size_t *, u_char *, OID *, size_t *);
00121 extern u_char *AsnOidBuild(u_char *, size_t *, u_char, const OID *, size_t);
00122 
00123 extern const u_char *AsnNullParse(const u_char *, size_t *, u_char *);
00124 extern u_char *AsnNullBuild(u_char *, size_t *, u_char);
00125 
00126 extern const u_char *AsnBitStringParse(const u_char *, size_t *, u_char *, u_char *, size_t *);
00127 extern u_char *AsnBitStringBuild(u_char *, size_t *, u_char, const u_char *, size_t);
00128 
00129 extern const u_char *AsnUnsigned64Parse(const u_char *, size_t *, u_char *, UNSIGNED64 *);
00130 extern u_char *AsnUnsigned64Build(u_char *, size_t *, u_char, const UNSIGNED64 *);
00131 
00132 
00133 #endif

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/