/* * x509_ed25519.h -- extract a raw Ed25519 public key from a DER-encoded * X.509 certificate's SubjectPublicKeyInfo (RFC 8410). * * Deliberately NOT a general ASN.1/X.509 parser (Milestone 6 decision, * FABRIC-2.md): walks exactly as far into the DER structure as needed * to reach SubjectPublicKeyInfo, verifies its AlgorithmIdentifier OID is * Ed25519 (1.3.101.112) and rejects anything else, then returns the raw * 32-byte key from the trailing BIT STRING. No signature verification, * no chain validation, no extension parsing -- this only answers "what * public key does this cert claim to hold," matching exactly what * ed25519_verify() needs as input. * * Freestanding C99, no libc beyond memcmp/memcpy (already provided by * src/starkernel/vm/host/shim.c in the kernel build). */ #ifndef STARKERNEL_X509_ED25519_H #define STARKERNEL_X509_ED25519_H #include #include /* Returns 0 on success (pubkey_out[32] filled), -1 on any malformed * encoding, unexpected structure, or non-Ed25519 algorithm. Never * faults on malformed input -- every DER length/tag is bounds-checked * against der_len before use. */ int x509_extract_ed25519_pubkey(const uint8_t *der, size_t der_len, uint8_t pubkey_out[32]); #endif /* STARKERNEL_X509_ED25519_H */