iPXE
Functions
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)
 
int der_asn1 (const void *data, size_t len, size_t offset, struct asn1_cursor **cursor)
 Extract ASN.1 object from DER data. More...
 
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  )

◆ der_asn1()

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

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 52 of file der.c.

53  {
54  size_t remaining;
55  void *raw;
56 
57  /* Sanity check */
58  assert ( offset <= len );
59  remaining = ( len - offset );
60 
61  /* Allocate cursor and data buffer */
62  *cursor = malloc ( sizeof ( **cursor ) + remaining );
63  if ( ! *cursor )
64  return -ENOMEM;
65  raw = ( ( ( void * ) *cursor ) + sizeof ( **cursor ) );
66 
67  /* Populate cursor and data buffer */
68  (*cursor)->data = raw;
69  (*cursor)->len = remaining;
70  memcpy ( raw, ( data + offset ), remaining );
71 
72  /* Shrink cursor */
73  asn1_shrink_any ( *cursor );
74 
75  return ( offset + (*cursor)->len );
76 }
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
ring len
Length.
Definition: dwmac.h:231
int asn1_shrink_any(struct asn1_cursor *cursor)
Shrink ASN.1 object of any type.
Definition: asn1.c:312
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:620
uint8_t data[48]
Additional event data.
Definition: ena.h:22
__be32 raw[7]
Definition: CIB_PRM.h:28
uint16_t offset
Offset to command line.
Definition: bzimage.h:8

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  )