summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/asn1.h
blob: 7ac10862666fcfd950d35a4da71b67985853c1a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef _IPXE_ASN1_H
#define _IPXE_ASN1_H

/** @file
 *
 * ASN.1 encoding
 *
 */

FILE_LICENCE ( GPL2_OR_LATER );

#define ASN1_INTEGER 0x02
#define ASN1_BIT_STRING 0x03
#define ASN1_OCTET_STRING 0x04
#define ASN1_NULL 0x05
#define ASN1_OID 0x06
#define ASN1_SEQUENCE 0x30
#define ASN1_IP_ADDRESS 0x40
#define ASN1_EXPLICIT_TAG 0xa0

/**
 * A DER-encoded ASN.1 object cursor
 */
struct asn1_cursor {
	/** Start of data */
	void *data;
	/** Length of data */
	size_t len;
};

/**
 * Invalidate ASN.1 object cursor
 *
 * @v cursor		ASN.1 object cursor
 */
static inline __attribute__ (( always_inline )) void
asn1_invalidate_cursor ( struct asn1_cursor *cursor ) {
	cursor->len = 0;
}

extern int asn1_enter ( struct asn1_cursor *cursor, unsigned int type );
extern int asn1_skip_if_exists ( struct asn1_cursor *cursor,
				 unsigned int type );
extern int asn1_skip ( struct asn1_cursor *cursor, unsigned int type );

#endif /* _IPXE_ASN1_H */