|
wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
|
RFC 7468 2-3: textual (PEM) encoding of DER structures. More...
Go to the source code of this file.
Functions | |
| int | wired_pem_next (wired_span text, usz *at, wired_span *label, wired_obuf *der) |
| Decode the next PEM block of text at or after *at. | |
RFC 7468 2-3: textual (PEM) encoding of DER structures.
A PEM text is a sequence of "-----BEGIN <label>-----" / "-----END <label>-----" blocks whose body is base64 (RFC 4648 4) of the DER bytes; anything outside the markers (comment lines, openssl x509 -text dumps) is ignored. The one entry point walks the text block by block so a fullchain file decodes with repeated calls.
| int wired_pem_next | ( | wired_span | text, |
| usz * | at, | ||
| wired_span * | label, | ||
| wired_obuf * | der ) |
Decode the next PEM block of text at or after *at.
Scans forward from *at for a "-----BEGIN <label>-----" line, base64-decodes the body up to the matching "-----END " line into der (appending at der->len, RFC 4648 4: =/== padding honored, CR/LF skipped), and advances *at past the END line so the following call returns the next block. label receives a view of the bytes between "BEGIN " and the closing dashes (e.g. "CERTIFICATE"), borrowed from text.
der is a caller-owned output buffer (see obuf_of): the caller retains ownership and der->p must have room for the decoded bytes, this call only appends and advances der->len, it never allocates or frees.
| text | the whole PEM text (borrowed; must outlive label) |
| at | scan cursor into text; advanced past the decoded block |
| label | receives the block's label as a view into text |
| der | receives the decoded DER bytes; the callee advances der->len |