#./fio-stl/157 pem.h
8 public symbols.
#Types
#fio_pem_key_type_e
c
typedef enum {
FIO_PEM_KEY_UNKNOWN = 0,
FIO_PEM_KEY_RSA = 1,
FIO_PEM_KEY_ECDSA_P256 = 2,
FIO_PEM_KEY_ED25519 = 3,
} fio_pem_key_type_ePrivate key algorithm types
Symbol type: type
#fio_pem_s
c
typedef struct {
const uint8_t *der; /**< Pointer to decoded DER data */
size_t der_len; /**< Length of DER data */
const char *label; /**< PEM label (e.g., "CERTIFICATE", "PRIVATE KEY") */
size_t label_len; /**< Length of label */
} fio_pem_sParsed PEM block
Symbol type: type
#fio_pem_private_key_s
c
typedef struct {
fio_pem_key_type_e type;
union {
struct {
uint8_t n[FIO_RSA_MAX_BYTES]; /**< RSA modulus (big-endian) */
size_t n_len;
uint8_t e[FIO_RSA_MAX_BYTES]; /**< RSA public exponent (big-endian) */
size_t e_len;
uint8_t d[FIO_RSA_MAX_BYTES]; /**< RSA private exponent (big-endian) */
size_t d_len;
uint8_t p[FIO_RSA_MAX_BYTES]; /**< RSA prime p (optional) */
size_t p_len;
uint8_t q[FIO_RSA_MAX_BYTES]; /**< RSA prime q (optional) */
size_t q_len;
uint8_t dP[FIO_RSA_MAX_BYTES]; /**< d mod (p-1) (optional) */
size_t dP_len;
uint8_t dQ[FIO_RSA_MAX_BYTES]; /**< d mod (q-1) (optional) */
size_t dQ_len;
uint8_t qInv[FIO_RSA_MAX_BYTES]; /**< q^-1 mod p (optional) */
size_t qInv_len;
} rsa;
struct {
uint8_t private_key[32]; /**< P-256 scalar (32 bytes) */
uint8_t public_key[65]; /**< Uncompressed point (optional, can derive) */
int has_public_key; /**< 1 if public_key is populated */
} ecdsa_p256;
struct {
uint8_t private_key[32]; /**< Ed25519 seed (32 bytes) */
uint8_t public_key[32]; /**< Ed25519 public key (optional) */
int has_public_key; /**< 1 if public_key is populated */
} ed25519;
};
} fio_pem_private_key_sParsed private key structure
Symbol type: type
#Functions
#fio_pem_parse
c
size_t fio_pem_parse(fio_pem_s *out, uint8_t *der_buf, size_t der_buf_len, const char *pem_data, size_t pem_len)Parse a single PEM block from data.
Finds the next -----BEGIN
Parameters:
out- Output structure to fill with parsed PEM block infoder_buf- Buffer to store decoded DER data (caller-provided)der_buf_len- Size of der_bufpem_data- PEM-encoded datapem_len- Length of PEM data
Returns:
- Number of bytes consumed from pem_data, or 0 on error
Symbol type: function
#fio_pem_parse_certificate
c
int fio_pem_parse_certificate(fio_x509_cert_s *cert, const char *pem_data, size_t pem_len)Parse certificate from PEM file content.
Handles "CERTIFICATE" label and parses the X.509 certificate.
Parameters:
cert- Output certificate structure (from fio_x509.h)pem_data- PEM-encoded certificate datapem_len- Length of PEM data
Returns:
- 0 on success, -1 on error
Symbol type: function
#fio_pem_parse_private_key
c
int fio_pem_parse_private_key(fio_pem_private_key_s *key, const char *pem_data, size_t pem_len)Parse private key from PEM file content.
Supports:
- "PRIVATE KEY" (PKCS#8 PrivateKeyInfo)
- "RSA PRIVATE KEY" (PKCS#1 RSAPrivateKey)
- "EC PRIVATE KEY" (SEC1 ECPrivateKey)
Parameters:
key- Output private key structurepem_data- PEM-encoded private key datapem_len- Length of PEM data
Returns:
- 0 on success, -1 on error
Symbol type: function
#fio_pem_get_certificate_der
c
size_t fio_pem_get_certificate_der(uint8_t *der_out, size_t der_out_len, const char *pem_data, size_t pem_len)Get the DER-encoded certificate from PEM data.
This is a convenience function that extracts just the DER bytes without parsing the X.509 structure.
Parameters:
der_out- Output buffer for DER datader_out_len- Size of output bufferpem_data- PEM-encoded certificate datapem_len- Length of PEM data
Returns:
- Length of DER data written, or 0 on error
Symbol type: function
#fio_pem_private_key_clear
c
inline void fio_pem_private_key_clear(fio_pem_private_key_s *key)Securely clear a private key structure.
Parameters:
key- Private key to clear
Symbol type: function