55 return ( ( sep -
data ) + 1 );
106 size_t decoded_max_len;
118 DBGC (
data,
"PEM [%#zx,%#zx) missing BEGIN marker: %s\n",
128 DBGC (
data,
"PEM [%#zx,%#zx) missing END marker: %s\n",
132 encoded_len = (
end - begin );
136 encoded =
malloc ( encoded_len + 1 );
139 goto err_alloc_encoded;
141 memcpy ( encoded, (
data + begin ), encoded_len );
142 encoded[encoded_len] =
'\0';
146 *cursor =
malloc (
sizeof ( **cursor ) + decoded_max_len );
149 goto err_alloc_cursor;
151 decoded = ( ( (
void * ) *cursor ) +
sizeof ( **cursor ) );
154 decoded_len =
base64_decode ( encoded, decoded, decoded_max_len );
155 if ( decoded_len < 0 ) {
160 (*cursor)->data = decoded;
161 (*cursor)->len = decoded_len;
162 assert ( (*cursor)->len <= decoded_max_len );
199 DBGC (
image,
"PEM %s has no BEGIN marker: %s\n",
227 DBGC (
image,
"PEM %s could not extract ASN.1: %s\n",
struct arbelprm_rc_send_wqe rc
int pem_asn1(const void *data, size_t len, size_t offset, struct asn1_cursor **cursor)
Extract ASN.1 object from PEM data.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static int pem_marker(const void *data, size_t len, size_t offset, const char *marker)
Locate boundary marker line.
const void * data
Read-only data.
An executable image type.
#define ENOENT
No such file or directory.
static size_t pem_next(const void *data, size_t len, size_t offset)
Locate next line.
#define PROBE_NORMAL
Normal image probe priority.
int base64_decode(const char *encoded, void *data, size_t len)
Base64-decode string.
struct image_type pem_image_type __image_type(PROBE_NORMAL)
PEM image type.
char * name
Name of this image type.
void * memchr(const void *src, int character, size_t len)
Find character within a memory region.
#define ENOMEM
Not enough space.
static size_t base64_decoded_max_len(const char *encoded)
Calculate maximum length of base64-decoded string.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int pem_image_asn1(struct image *image, size_t offset, struct asn1_cursor **cursor)
Extract ASN.1 object from image.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
size_t len
Length of raw file image.
size_t strlen(const char *src)
Get length of string.
uint32_t next
Next descriptor address.
void * malloc(size_t size)
Allocate memory.
#define PEM_END
Post-encapsulation boundary marker.
uint32_t end
Ending offset.
uint8_t data[48]
Additional event data.
static int pem_image_probe(struct image *image)
Probe PEM image.
#define PEM_BEGIN
Pre-encapsulation boundary marker.
uint16_t offset
Offset to command line.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
#define NULL
NULL pointer (VOID *)
struct eth_slow_marker_tlv marker
Marker information.