iPXE
efi_siglist.h File Reference

PEM-encoded ASN.1 data. 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 efisig_asn1 (const void *data, size_t len, size_t offset, struct asn1_cursor **cursor)
 Extract ASN.1 object from EFI signature list.
struct image_type efisig_image_type __image_type (PROBE_NORMAL)

Detailed Description

PEM-encoded ASN.1 data.

Definition in file efi_siglist.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

References data, len, and offset.

◆ efisig_asn1()

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

Extract ASN.1 object from EFI signature list.

Parameters
dataEFI signature list
lenLength of EFI signature list
offsetOffset within image
cursorASN.1 cursor to fill in
Return values
nextOffset to next image, or negative error

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

Definition at line 144 of file efi_siglist.c.

145 {
146 const EFI_SIGNATURE_LIST *lhdr;
147 const EFI_SIGNATURE_DATA *dhdr;
148 int ( * asn1 ) ( const void *data, size_t len, size_t offset,
149 struct asn1_cursor **cursor );
150 size_t skip = offsetof ( typeof ( *dhdr ), SignatureData );
151 int next;
152 int rc;
153
154 /* Locate signature list entry */
155 if ( ( rc = efisig_find ( data, len, &offset, &lhdr, &dhdr ) ) != 0 )
156 goto err_entry;
157 len = ( offset + le32_to_cpu ( lhdr->SignatureSize ) );
158
159 /* Parse as PEM or DER based on first character */
160 asn1 = ( ( dhdr->SignatureData[0] == ASN1_SEQUENCE ) ?
161 der_asn1 : pem_asn1 );
162 DBGC2 ( data, "EFISIG [%#zx,%#zx) extracting %s\n", offset, len,
163 ( ( asn1 == der_asn1 ) ? "DER" : "PEM" ) );
164 next = asn1 ( data, len, ( offset + skip ), cursor );
165 if ( next < 0 ) {
166 rc = next;
167 DBGC ( data, "EFISIG [%#zx,%#zx) could not extract ASN.1: "
168 "%s\n", offset, len, strerror ( rc ) );
169 goto err_asn1;
170 }
171
172 /* Check that whole entry was consumed */
173 if ( ( ( unsigned int ) next ) != len ) {
174 DBGC ( data, "EFISIG [%#zx,%#zx) malformed data\n",
175 offset, len );
176 rc = -EINVAL;
177 goto err_whole;
178 }
179
180 return len;
181
182 err_whole:
183 free ( *cursor );
184 err_asn1:
185 err_entry:
186 return rc;
187}
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define ASN1_SEQUENCE
ASN.1 sequence.
Definition asn1.h:90
uint16_t offset
Offset to command line.
Definition bzimage.h:3
int der_asn1(const void *data, size_t len, size_t offset, struct asn1_cursor **cursor)
Extract ASN.1 object from DER data.
Definition der.c:53
uint32_t next
Next descriptor address.
Definition dwmac.h:11
ring len
Length.
Definition dwmac.h:226
static int efisig_find(const void *data, size_t len, size_t *start, const EFI_SIGNATURE_LIST **lhdr, const EFI_SIGNATURE_DATA **dhdr)
Find EFI signature list entry.
Definition efi_siglist.c:54
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define DBGC2(...)
Definition compiler.h:547
#define DBGC(...)
Definition compiler.h:530
#define EINVAL
Invalid argument.
Definition errno.h:472
#define le32_to_cpu(value)
Definition byteswap.h:114
int pem_asn1(const void *data, size_t len, size_t offset, struct asn1_cursor **cursor)
Extract ASN.1 object from PEM data.
Definition pem.c:104
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
#define offsetof(type, field)
Get offset of a field within a structure.
Definition stddef.h:25
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
The format of a signature database.
UINT8 SignatureData[1]
The format of the signature is defined by the SignatureType.
UINT32 SignatureSize
Size of each signature.
An ASN.1 object cursor.
Definition asn1.h:21

References ASN1_SEQUENCE, data, DBGC, DBGC2, der_asn1(), efisig_find(), EINVAL, free, le32_to_cpu, len, next, offset, offsetof, pem_asn1(), rc, EFI_SIGNATURE_DATA::SignatureData, EFI_SIGNATURE_LIST::SignatureSize, strerror(), and typeof().

Referenced by efi_cacert(), and efisig_image_asn1().

◆ __image_type()

struct image_type efisig_image_type __image_type ( PROBE_NORMAL )
extern

References __image_type, and PROBE_NORMAL.