wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
cert.h File Reference

RFC 8446 4.4.2/4.4.3: the Certificate and CertificateVerify handshake messages. More...

Go to the source code of this file.

Data Structures

struct  tls_cert_entry
 A view of one CertificateEntry's cert_data within the message buffer. More...
struct  tls_cert_chain_out
 Destination for tls_cert_chain: entries[0..cap-1] and the count actually written. More...

Macros

#define TLS_CERT_CHAIN_MAX   10
 Longest certificate_list this SDK walks (leaf + up to 9 issuers — public web chains are typically 2-3 entries, but quic-interop-runner's amplificationlimit case deliberately serves a 9-certificate chain to inflate the server's Handshake flight for its RFC 9000 8.1 anti-amplification check; matches WIRED_CERTRELOAD_CHAIN_MAX).
#define TLS_SCHEME_ED25519   0x0807
 RFC 8446 4.2.3: the ed25519 SignatureScheme code point.

Functions

int tls_cert_parse (wired_span buf, wired_span *context, tls_cert_entry *first)
 Parse a Certificate message body (after the handshake header).
int tls_cert_chain (wired_span buf, wired_span *context, const tls_cert_chain_out *out)
 Parse a Certificate message body (after the handshake header) and view EVERY CertificateEntry's cert_data into out->entries[0..out->cap-1], leaf first.
int tls_certverify_parse (wired_span buf, u16 *scheme, wired_span *sig)
 Parse a CertificateVerify body: a 2-byte SignatureScheme then a 2-byte-length-prefixed signature.
int tls_certverify_ed25519 (wired_span sig, const u8 transcript_hash[32], const u8 pubkey[32])
 Verify a server's CertificateVerify Ed25519 signature (RFC 8446 4.4.3).

Detailed Description

RFC 8446 4.4.2/4.4.3: the Certificate and CertificateVerify handshake messages.

Certificate carries a request context and a chain of entries, each an opaque cert_data (X.509, not parsed here) plus extensions. CertificateVerify carries a SignatureScheme and the signature over the handshake transcript.

Function Documentation

◆ tls_cert_chain()

int tls_cert_chain ( wired_span buf,
wired_span * context,
const tls_cert_chain_out * out )

Parse a Certificate message body (after the handshake header) and view EVERY CertificateEntry's cert_data into out->entries[0..out->cap-1], leaf first.

Sets *out->count.

Parameters
bufthe Certificate message body
contextreceives the certificate_request_context view
outdestination entry views and count
Returns
1 on success; 0 on truncation, trailing garbage, or more than cap entries (fail closed).

◆ tls_cert_parse()

int tls_cert_parse ( wired_span buf,
wired_span * context,
tls_cert_entry * first )

Parse a Certificate message body (after the handshake header).

Sets the request context view and the first CertificateEntry's cert_data. Only the first entry (the end-entity certificate) is exposed; the rest of the chain is skipped over.

Parameters
bufthe Certificate message body
contextreceives the certificate_request_context view
firstreceives the first CertificateEntry's cert_data view
Returns
1 on success, 0 on truncation.

◆ tls_certverify_ed25519()

int tls_certverify_ed25519 ( wired_span sig,
const u8 transcript_hash[32],
const u8 pubkey[32] )

Verify a server's CertificateVerify Ed25519 signature (RFC 8446 4.4.3).

The signed content is 64 octets of 0x20, the context string "TLS 1.3, server CertificateVerify", a 0x00 separator, then the transcript hash.

Parameters
sigthe signature from the CertificateVerify message
transcript_hashthe handshake transcript hash
pubkeythe server's Ed25519 public key (from its certificate)
Returns
1 if the signature verifies.

◆ tls_certverify_parse()

int tls_certverify_parse ( wired_span buf,
u16 * scheme,
wired_span * sig )

Parse a CertificateVerify body: a 2-byte SignatureScheme then a 2-byte-length-prefixed signature.

Parameters
bufthe CertificateVerify message body
schemereceives the SignatureScheme code point
sigreceives the signature view
Returns
1 on success, 0 on truncation.