iPXE
asn1.h
Go to the documentation of this file.
1 #ifndef _IPXE_ASN1_H
2 #define _IPXE_ASN1_H
3 
4 /** @file
5  *
6  * ASN.1 encoding
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stddef.h>
13 #include <stdint.h>
14 #include <assert.h>
15 #include <time.h>
16 #include <ipxe/tables.h>
17 
18 /** An ASN.1 object cursor */
19 struct asn1_cursor {
20  /** Start of data */
21  const void *data;
22  /** Length of data */
23  size_t len;
24 };
25 
26 /** An ASN.1 object builder */
27 struct asn1_builder {
28  /** Data
29  *
30  * This is always dynamically allocated. If @c data is NULL
31  * while @len is non-zero, this indicates that a memory
32  * allocation error has occurred during the building process.
33  */
34  void *data;
35  /** Length of data */
36  size_t len;
37 };
38 
39 /** Maximum (viable) length of ASN.1 length
40  *
41  * While in theory unlimited, this length is sufficient to contain a
42  * size_t.
43  */
44 #define ASN1_MAX_LEN_LEN ( 1 + sizeof ( size_t ) )
45 
46 /** An ASN.1 header */
48  /** Type */
50  /** Length (encoded) */
52 } __attribute__ (( packed ));
53 
54 /** ASN.1 end */
55 #define ASN1_END 0x00
56 
57 /** ASN.1 boolean */
58 #define ASN1_BOOLEAN 0x01
59 
60 /** ASN.1 integer */
61 #define ASN1_INTEGER 0x02
62 
63 /** ASN.1 bit string */
64 #define ASN1_BIT_STRING 0x03
65 
66 /** ASN.1 octet string */
67 #define ASN1_OCTET_STRING 0x04
68 
69 /** ASN.1 null */
70 #define ASN1_NULL 0x05
71 
72 /** ASN.1 object identifier */
73 #define ASN1_OID 0x06
74 
75 /** ASN.1 enumeration */
76 #define ASN1_ENUMERATED 0x0a
77 
78 /** ASN.1 UTC time */
79 #define ASN1_UTC_TIME 0x17
80 
81 /** ASN.1 generalized time */
82 #define ASN1_GENERALIZED_TIME 0x18
83 
84 /** ASN.1 sequence */
85 #define ASN1_SEQUENCE 0x30
86 
87 /** ASN.1 set */
88 #define ASN1_SET 0x31
89 
90 /** ASN.1 implicit tag */
91 #define ASN1_IMPLICIT_TAG( number) ( 0x80 | (number) )
92 
93 /** ASN.1 explicit tag */
94 #define ASN1_EXPLICIT_TAG( number) ( 0xa0 | (number) )
95 
96 /** ASN.1 "any tag" magic value */
97 #define ASN1_ANY -1U
98 
99 /** Initial OID byte */
100 #define ASN1_OID_INITIAL( first, second ) ( ( (first) * 40 ) + (second) )
101 
102 /** Single-byte OID value
103  *
104  * Valid for values up to 127
105  */
106 #define ASN1_OID_SINGLE( value ) ( (value) & 0x7f )
107 
108 /** Double-byte OID value
109  *
110  * Valid for values up to 16383
111  */
112 #define ASN1_OID_DOUBLE( value ) \
113  ( 0x80 | ( ( (value) >> 7 ) & 0x7f ) ), ASN1_OID_SINGLE ( (value) )
114 
115 /** Double-byte OID value
116  *
117  * Valid for values up to 2097151
118  */
119 #define ASN1_OID_TRIPLE( value ) \
120  ( 0x80 | ( ( (value) >> 14 ) & 0x7f ) ), ASN1_OID_DOUBLE ( (value) )
121 
122 /** ASN.1 OID for rsaEncryption (1.2.840.113549.1.1.1) */
123 #define ASN1_OID_RSAENCRYPTION \
124  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
125  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
126  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 1 )
127 
128 /** ASN.1 OID for md5WithRSAEncryption (1.2.840.113549.1.1.4) */
129 #define ASN1_OID_MD5WITHRSAENCRYPTION \
130  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
131  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
132  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 4 )
133 
134 /** ASN.1 OID for sha1WithRSAEncryption (1.2.840.113549.1.1.5) */
135 #define ASN1_OID_SHA1WITHRSAENCRYPTION \
136  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
137  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
138  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 )
139 
140 /** ASN.1 OID for sha256WithRSAEncryption (1.2.840.113549.1.1.11) */
141 #define ASN1_OID_SHA256WITHRSAENCRYPTION \
142  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
143  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
144  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 11 )
145 
146 /** ASN.1 OID for sha384WithRSAEncryption (1.2.840.113549.1.1.12) */
147 #define ASN1_OID_SHA384WITHRSAENCRYPTION \
148  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
149  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
150  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 12 )
151 
152 /** ASN.1 OID for sha512WithRSAEncryption (1.2.840.113549.1.1.13) */
153 #define ASN1_OID_SHA512WITHRSAENCRYPTION \
154  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
155  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
156  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 13 )
157 
158 /** ASN.1 OID for sha224WithRSAEncryption (1.2.840.113549.1.1.14) */
159 #define ASN1_OID_SHA224WITHRSAENCRYPTION \
160  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
161  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
162  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 14 )
163 
164 /** ASN.1 OID for id-md4 (1.2.840.113549.2.4) */
165 #define ASN1_OID_MD4 \
166  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
167  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 2 ), \
168  ASN1_OID_SINGLE ( 4 )
169 
170 /** ASN.1 OID for id-md5 (1.2.840.113549.2.5) */
171 #define ASN1_OID_MD5 \
172  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
173  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 2 ), \
174  ASN1_OID_SINGLE ( 5 )
175 
176 /** ASN.1 OID for id-sha1 (1.3.14.3.2.26) */
177 #define ASN1_OID_SHA1 \
178  ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 14 ), \
179  ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 2 ), \
180  ASN1_OID_SINGLE ( 26 )
181 
182 /** ASN.1 OID for id-sha256 (2.16.840.1.101.3.4.2.1) */
183 #define ASN1_OID_SHA256 \
184  ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
185  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
186  ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
187  ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 1 )
188 
189 /** ASN.1 OID for id-sha384 (2.16.840.1.101.3.4.2.2) */
190 #define ASN1_OID_SHA384 \
191  ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
192  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
193  ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
194  ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 2 )
195 
196 /** ASN.1 OID for id-sha512 (2.16.840.1.101.3.4.2.3) */
197 #define ASN1_OID_SHA512 \
198  ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
199  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
200  ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
201  ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 3 )
202 
203 /** ASN.1 OID for id-sha224 (2.16.840.1.101.3.4.2.4) */
204 #define ASN1_OID_SHA224 \
205  ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
206  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
207  ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
208  ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 4 )
209 
210 /** ASN.1 OID for id-sha512-224 (2.16.840.1.101.3.4.2.5) */
211 #define ASN1_OID_SHA512_224 \
212  ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
213  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
214  ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
215  ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 5 )
216 
217 /** ASN.1 OID for id-sha512-256 (2.16.840.1.101.3.4.2.6) */
218 #define ASN1_OID_SHA512_256 \
219  ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
220  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
221  ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
222  ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 6 )
223 
224 /** ASN.1 OID for commonName (2.5.4.3) */
225 #define ASN1_OID_COMMON_NAME \
226  ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 4 ), \
227  ASN1_OID_SINGLE ( 3 )
228 
229 /** ASN.1 OID for id-ce-keyUsage (2.5.29.15) */
230 #define ASN1_OID_KEYUSAGE \
231  ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \
232  ASN1_OID_SINGLE ( 15 )
233 
234 /** ASN.1 OID for id-ce-basicConstraints (2.5.29.19) */
235 #define ASN1_OID_BASICCONSTRAINTS \
236  ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \
237  ASN1_OID_SINGLE ( 19 )
238 
239 /** ASN.1 OID for id-ce-extKeyUsage (2.5.29.37) */
240 #define ASN1_OID_EXTKEYUSAGE \
241  ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \
242  ASN1_OID_SINGLE ( 37 )
243 
244 /** ASN.1 OID for id-kp-codeSigning (1.3.6.1.5.5.7.3.3) */
245 #define ASN1_OID_CODESIGNING \
246  ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \
247  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
248  ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
249  ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 3 )
250 
251 /** ASN.1 OID for pkcs-signedData (1.2.840.113549.1.7.2) */
252 #define ASN1_OID_SIGNEDDATA \
253  ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
254  ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
255  ASN1_OID_SINGLE ( 7 ), ASN1_OID_SINGLE ( 2 )
256 
257 /** ASN.1 OID for id-pe-authorityInfoAccess (1.3.6.1.5.5.7.1.1) */
258 #define ASN1_OID_AUTHORITYINFOACCESS \
259  ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \
260  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
261  ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
262  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 1 )
263 
264 /** ASN.1 OID for id-ad-ocsp (1.3.6.1.5.5.7.48.1) */
265 #define ASN1_OID_OCSP \
266  ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \
267  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
268  ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
269  ASN1_OID_SINGLE ( 48 ), ASN1_OID_SINGLE ( 1 )
270 
271 /** ASN.1 OID for id-pkix-ocsp-basic ( 1.3.6.1.5.5.7.48.1.1) */
272 #define ASN1_OID_OCSP_BASIC \
273  ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \
274  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
275  ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
276  ASN1_OID_SINGLE ( 48 ), ASN1_OID_SINGLE ( 1 ), \
277  ASN1_OID_SINGLE ( 1 )
278 
279 /** ASN.1 OID for id-kp-OCSPSigning (1.3.6.1.5.5.7.3.9) */
280 #define ASN1_OID_OCSPSIGNING \
281  ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \
282  ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
283  ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
284  ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 9 )
285 
286 /** ASN.1 OID for id-ce-subjectAltName (2.5.29.17) */
287 #define ASN1_OID_SUBJECTALTNAME \
288  ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \
289  ASN1_OID_SINGLE ( 17 )
290 
291 /** Define an ASN.1 cursor containing an OID */
292 #define ASN1_OID_CURSOR( oid_value ) { \
293  .data = oid_value, \
294  .len = sizeof ( oid_value ), \
295  }
296 
297 /** An ASN.1 OID-identified algorithm */
299  /** Name */
300  const char *name;
301  /** Object identifier */
302  struct asn1_cursor oid;
303  /** Public-key algorithm (if applicable) */
305  /** Digest algorithm (if applicable) */
307 };
308 
309 /** ASN.1 OID-identified algorithms */
310 #define ASN1_ALGORITHMS __table ( struct asn1_algorithm, "asn1_algorithms" )
311 
312 /** Declare an ASN.1 OID-identified algorithm */
313 #define __asn1_algorithm __table_entry ( ASN1_ALGORITHMS, 01 )
314 
315 /** An ASN.1 bit string */
317  /** Data */
318  const void *data;
319  /** Length */
320  size_t len;
321  /** Unused bits at end of data */
322  unsigned int unused;
323 } __attribute__ (( packed ));
324 
325 /**
326  * Invalidate ASN.1 object cursor
327  *
328  * @v cursor ASN.1 object cursor
329  */
330 static inline __attribute__ (( always_inline )) void
332  cursor->len = 0;
333 }
334 
335 /**
336  * Extract ASN.1 type
337  *
338  * @v cursor ASN.1 object cursor
339  * @ret type Type, or ASN1_END if cursor is invalid
340  */
341 static inline __attribute__ (( always_inline )) unsigned int
342 asn1_type ( const struct asn1_cursor *cursor ) {
343  const uint8_t *type = cursor->data;
344 
345  return ( ( cursor->len >= sizeof ( *type ) ) ? *type : ASN1_END );
346 }
347 
348 /**
349  * Get cursor for built object
350  *
351  * @v builder ASN.1 object builder
352  * @ret cursor ASN.1 object cursor
353  */
354 static inline __attribute__ (( always_inline )) struct asn1_cursor *
355 asn1_built ( struct asn1_builder *builder ) {
356  union {
357  struct asn1_builder builder;
358  struct asn1_cursor cursor;
359  } *u = container_of ( builder, typeof ( *u ), builder );
360 
361  /* Sanity check */
362  linker_assert ( ( ( const void * ) &u->builder.data ) ==
363  &u->cursor.data, asn1_builder_cursor_data_mismatch );
364  linker_assert ( &u->builder.len == &u->cursor.len,
365  asn1_builder_cursor_len_mismatch );
366 
367  return &u->cursor;
368 }
369 
370 extern int asn1_start ( struct asn1_cursor *cursor, unsigned int type,
371  size_t extra );
372 extern int asn1_enter ( struct asn1_cursor *cursor, unsigned int type );
373 extern int asn1_skip_if_exists ( struct asn1_cursor *cursor,
374  unsigned int type );
375 extern int asn1_skip ( struct asn1_cursor *cursor, unsigned int type );
376 extern int asn1_shrink ( struct asn1_cursor *cursor, unsigned int type );
377 extern int asn1_enter_any ( struct asn1_cursor *cursor );
378 extern int asn1_skip_any ( struct asn1_cursor *cursor );
379 extern int asn1_shrink_any ( struct asn1_cursor *cursor );
380 extern int asn1_boolean ( const struct asn1_cursor *cursor );
381 extern int asn1_integer ( const struct asn1_cursor *cursor, int *value );
382 extern int asn1_bit_string ( const struct asn1_cursor *cursor,
383  struct asn1_bit_string *bits );
384 extern int asn1_integral_bit_string ( const struct asn1_cursor *cursor,
385  struct asn1_bit_string *bits );
386 extern int asn1_compare ( const struct asn1_cursor *cursor1,
387  const struct asn1_cursor *cursor2 );
388 extern int asn1_algorithm ( const struct asn1_cursor *cursor,
389  struct asn1_algorithm **algorithm );
390 extern int asn1_pubkey_algorithm ( const struct asn1_cursor *cursor,
391  struct asn1_algorithm **algorithm );
392 extern int asn1_digest_algorithm ( const struct asn1_cursor *cursor,
393  struct asn1_algorithm **algorithm );
394 extern int asn1_signature_algorithm ( const struct asn1_cursor *cursor,
395  struct asn1_algorithm **algorithm );
396 extern int asn1_generalized_time ( const struct asn1_cursor *cursor,
397  time_t *time );
398 extern int asn1_grow ( struct asn1_builder *builder, size_t extra );
399 extern int asn1_prepend_raw ( struct asn1_builder *builder, const void *data,
400  size_t len );
401 extern int asn1_prepend ( struct asn1_builder *builder, unsigned int type,
402  const void *data, size_t len );
403 extern int asn1_wrap ( struct asn1_builder *builder, unsigned int type );
404 
405 #endif /* _IPXE_ASN1_H */
#define __attribute__(x)
Definition: compiler.h:10
const void * data
Data.
Definition: asn1.h:318
An ASN.1 OID-identified algorithm.
Definition: asn1.h:298
void * data
Data.
Definition: asn1.h:34
int asn1_digest_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
Parse ASN.1 OID-identified digest algorithm.
Definition: asn1.c:539
int asn1_generalized_time(const struct asn1_cursor *cursor, time_t *time)
Parse ASN.1 GeneralizedTime.
Definition: asn1.c:603
#define ASN1_END
ASN.1 end.
Definition: asn1.h:55
int asn1_boolean(const struct asn1_cursor *cursor)
Parse value of ASN.1 boolean.
Definition: asn1.c:296
uint8_t type
Type.
Definition: ena.h:16
const void * data
Start of data.
Definition: asn1.h:21
int asn1_skip(struct asn1_cursor *cursor, unsigned int type)
Skip ASN.1 object.
Definition: asn1.c:218
int asn1_prepend_raw(struct asn1_builder *builder, const void *data, size_t len)
Prepend raw data to ASN.1 builder.
Definition: asn1.c:775
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:160
uint8_t length[ASN1_MAX_LEN_LEN]
Length (encoded)
Definition: asn1.h:51
static unsigned int asn1_type(const struct asn1_cursor *cursor)
Extract ASN.1 type.
Definition: asn1.h:342
int asn1_integral_bit_string(const struct asn1_cursor *cursor, struct asn1_bit_string *bits)
Parse ASN.1 bit string that must be an integral number of bytes.
Definition: asn1.c:414
uint8_t type
Type.
Definition: asn1.h:49
int asn1_shrink(struct asn1_cursor *cursor, unsigned int type)
Shrink ASN.1 cursor to fit object.
Definition: asn1.c:240
size_t len
Length of data.
Definition: asn1.h:23
int asn1_skip_if_exists(struct asn1_cursor *cursor, unsigned int type)
Skip ASN.1 object if present.
Definition: asn1.c:187
struct pubkey_algorithm * pubkey
Public-key algorithm (if applicable)
Definition: asn1.h:304
int asn1_shrink_any(struct asn1_cursor *cursor)
Shrink ASN.1 object of any type.
Definition: asn1.c:286
int asn1_prepend(struct asn1_builder *builder, unsigned int type, const void *data, size_t len)
Prepend data to ASN.1 builder.
Definition: asn1.c:798
Assertions.
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
int asn1_pubkey_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
Parse ASN.1 OID-identified public-key algorithm.
Definition: asn1.c:513
#define ASN1_MAX_LEN_LEN
Maximum (viable) length of ASN.1 length.
Definition: asn1.h:44
int asn1_compare(const struct asn1_cursor *cursor1, const struct asn1_cursor *cursor2)
Compare two ASN.1 objects.
Definition: asn1.c:443
unsigned int unused
Unused bits at end of data.
Definition: asn1.h:322
int asn1_wrap(struct asn1_builder *builder, unsigned int type)
Wrap ASN.1 builder.
Definition: asn1.c:825
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
int asn1_signature_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
Parse ASN.1 OID-identified signature algorithm.
Definition: asn1.c:565
static void asn1_invalidate_cursor(struct asn1_cursor *cursor)
Invalidate ASN.1 object cursor.
Definition: asn1.h:331
size_t len
Length.
Definition: asn1.h:320
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
An ASN.1 object builder.
Definition: asn1.h:27
int asn1_bit_string(const struct asn1_cursor *cursor, struct asn1_bit_string *bits)
Parse ASN.1 bit string.
Definition: asn1.c:359
unsigned char uint8_t
Definition: stdint.h:10
struct asn1_cursor oid
Object identifier.
Definition: asn1.h:302
int asn1_integer(const struct asn1_cursor *cursor, int *value)
Parse value of ASN.1 integer.
Definition: asn1.c:320
int asn1_start(struct asn1_cursor *cursor, unsigned int type, size_t extra)
Start parsing ASN.1 object.
Definition: asn1.c:98
int asn1_skip_any(struct asn1_cursor *cursor)
Skip ASN.1 object of any type.
Definition: asn1.c:276
An ASN.1 header.
Definition: asn1.h:47
u16 algorithm
Authentication algorithm (Open System or Shared Key)
Definition: ieee80211.h:1030
const char * name
Name.
Definition: asn1.h:300
static volatile void * bits
Definition: bitops.h:27
uint32_t len
Length.
Definition: ena.h:14
struct digest_algorithm * digest
Digest algorithm (if applicable)
Definition: asn1.h:306
int asn1_grow(struct asn1_builder *builder, size_t extra)
Grow ASN.1 builder.
Definition: asn1.c:742
int asn1_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
Parse ASN.1 OID-identified algorithm.
Definition: asn1.c:478
A message digest algorithm.
Definition: crypto.h:16
Linker tables.
static struct asn1_cursor * asn1_built(struct asn1_builder *builder)
Get cursor for built object.
Definition: asn1.h:355
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
union @16 u
int64_t time_t
Seconds since the Epoch.
Definition: time.h:18
Time source.
uint64_t time
Current time.
Definition: ntlm.h:20
#define linker_assert(condition, error_symbol)
Assert a condition at link-time.
Definition: assert.h:68
size_t len
Length of data.
Definition: asn1.h:36
An ASN.1 object cursor.
Definition: asn1.h:19
A public key algorithm.
Definition: crypto.h:94
An ASN.1 bit string.
Definition: asn1.h:316
int asn1_enter_any(struct asn1_cursor *cursor)
Enter ASN.1 object of any type.
Definition: asn1.c:266