iPXE
der.h File Reference

DER image format. More...

#include <stdint.h>
#include <ipxe/asn1.h>
#include <ipxe/image.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int der_asn1 (const void *data, size_t len, size_t offset, struct asn1_cursor **cursor)
 Extract ASN.1 object from DER data.
struct image_type der_image_type __image_type (PROBE_NORMAL)

Detailed Description

DER image format.

Definition in file der.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

References data, len, and offset.

◆ der_asn1()

int der_asn1 ( const void * data,
size_t len,
size_t offset,
struct asn1_cursor ** cursor )
extern

Extract ASN.1 object from DER data.

Parameters
dataDER data
lenLength of DER data
offsetOffset within data
cursorASN.1 cursor to fill in
Return values
nextOffset to next object, or negative error

The caller is responsible for eventually calling free() on the allocated ASN.1 cursor.

Definition at line 53 of file der.c.

54 {
55 size_t remaining;
56 void *raw;
57
58 /* Sanity check */
59 assert ( offset <= len );
60 remaining = ( len - offset );
61
62 /* Allocate cursor and data buffer */
63 *cursor = malloc ( sizeof ( **cursor ) + remaining );
64 if ( ! *cursor )
65 return -ENOMEM;
66 raw = ( ( ( void * ) *cursor ) + sizeof ( **cursor ) );
67
68 /* Populate cursor and data buffer */
69 (*cursor)->data = raw;
70 (*cursor)->len = remaining;
71 memcpy ( raw, ( data + offset ), remaining );
72
73 /* Shrink cursor */
74 asn1_shrink_any ( *cursor );
75
76 return ( offset + (*cursor)->len );
77}
__be32 raw[7]
Definition CIB_PRM.h:0
int asn1_shrink_any(struct asn1_cursor *cursor)
Shrink ASN.1 object of any type.
Definition asn1.c:300
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
uint16_t offset
Offset to command line.
Definition bzimage.h:3
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define ENOMEM
Not enough space.
Definition errno.h:535
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * malloc(size_t size)
Allocate memory.
Definition malloc.c:621

References asn1_shrink_any(), assert, data, ENOMEM, len, malloc(), memcpy(), offset, and raw.

Referenced by der_image_asn1(), and efisig_asn1().

◆ __image_type()

struct image_type der_image_type __image_type ( PROBE_NORMAL )
extern

References __image_type, and PROBE_NORMAL.