LCOV - code coverage report
Current view: top level - waltz/tls - fd_tls_proto.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 102 0.0 %
Date: 2026-10-22 18:10:43 Functions: 0 434 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_waltz_tls_fd_tls_proto_h
       2             : #define HEADER_fd_src_waltz_tls_fd_tls_proto_h
       3             : 
       4             : /* fd_tls_proto.h declares various TLS v1.3 data structures and provides
       5             :    internal APIs to decode and encode them from/to wire format.
       6             : 
       7             :    Most encodings in TLS v1.3 are laid out dynamically and cannot be
       8             :    represented with packed C structs, such as variable-length lists and
       9             :    "unions" (fields that may hold one of multiple data types).  For this
      10             :    dynamic kind of data, fd_tls_proto declares custom structs and
      11             :    provides an encode/decode API.
      12             : 
      13             :    A small number of type encodings are laid out statically.  For these,
      14             :    a packed C struct and a "bswap" (endianness conversion) function is
      15             :    provided. */
      16             : 
      17             : #include "../fd_waltz_base.h"
      18             : #include <stddef.h>
      19             : 
      20             : /* TLS Extensions *****************************************************/
      21             : 
      22             : struct __attribute__((packed)) fd_tls_ext_hdr {
      23             :   ushort type;
      24             :   ushort sz;
      25             : };
      26             : 
      27             : typedef struct fd_tls_ext_hdr fd_tls_ext_hdr_t;
      28             : 
      29             : /* Supported TLS versions (RFC 8446)
      30             :    Type: FD_TLS_EXT_TYPE_SUPPORTED_VERSIONS */
      31             : 
      32             : struct fd_tls_ext_supported_versions {
      33             :   uchar tls13 : 1;
      34             : };
      35             : 
      36             : typedef struct fd_tls_ext_supported_versions fd_tls_ext_supported_versions_t;
      37             : 
      38             : /* Server name indication (RFC 6066)
      39             :    Type: FD_TLS_EXT_TYPE_SERVER_NAME (0) */
      40             : 
      41             : struct fd_tls_ext_server_name {
      42             :   ushort host_name_len;    /* Length of name cstr (excluding NUL) */
      43             :   char   host_name[ 254 ]; /* Name cstr */
      44             : };
      45             : 
      46             : typedef struct fd_tls_ext_server_name fd_tls_ext_server_name_t;
      47             : 
      48             : /* Supported ECDHE groups (RFC 8422, 7919)
      49             :    Type: FD_TLS_EXT_TYPE_SUPPORTED_GROUPS */
      50             : 
      51             : struct fd_tls_ext_supported_groups {
      52             :   uchar x25519 : 1;
      53             : };
      54             : 
      55             : typedef struct fd_tls_ext_supported_groups fd_tls_ext_supported_groups_t;
      56             : 
      57             : /* Supported signature schemes (RFC 8446)
      58             :    Type: FD_TLS_EXT_TYPE_SIGNATURE_ALGORITHMS */
      59             : 
      60             : struct fd_tls_ext_signature_algorithms {
      61             :   uchar ed25519                : 1;
      62             :   uchar ecdsa_secp256r1_sha256 : 1;
      63             :   uchar ecdsa_secp384r1_sha384 : 1;
      64             :   uchar rsa_pkcs1_sha256       : 1;
      65             :   uchar rsa_pkcs1_sha384       : 1;
      66             :   uchar rsa_pkcs1_sha512       : 1;
      67             :   uchar rsa_pss_rsae_sha256    : 1;
      68             :   uchar rsa_pss_rsae_sha384    : 1;
      69             :   uchar rsa_pss_rsae_sha512    : 1;
      70             : };
      71             : 
      72             : typedef struct fd_tls_ext_signature_algorithms fd_tls_ext_signature_algorithms_t;
      73             : 
      74             : struct fd_tls_key_share {
      75             :   uchar has_x25519 : 1;
      76             :   uchar x25519[ 32 ];
      77             : };
      78             : 
      79             : typedef struct fd_tls_key_share fd_tls_key_share_t;
      80             : 
      81             : /* fd_tls_ext_opaque_t holds a pointer to opaque serialized extension
      82             :    data.  Lifetime of buf depends on context -- Look for documentation
      83             :    in usages of this structure.
      84             : 
      85             :    This structure can have 3 subtly different meanings:
      86             :      (!!buf) & (!!bufsz)   Extension present, non-zero sz
      87             :      (!!buf) & ( !bufsz)   Extension present, zero sz
      88             :      ( !buf) & ( !bufsz)   Extension absent
      89             : 
      90             :    Notably,
      91             :      (!buf  )  ... implies extension is absent
      92             :      (!bufsz)  ... implies extension is absent or zero sz */
      93             : 
      94             : struct fd_tls_ext_opaque {
      95             :   uchar const * buf;
      96             :   ulong         bufsz;
      97             : };
      98             : 
      99             : typedef struct fd_tls_ext_opaque fd_tls_ext_opaque_t;
     100             : typedef struct fd_tls_ext_opaque fd_tls_ext_quic_tp_t;
     101             : typedef struct fd_tls_ext_opaque fd_tls_ext_alpn_t;
     102             : 
     103             : /* TLS Messages *******************************************************/
     104             : 
     105             : /* fd_tls_u24_t is a 24-bit / 3 byte big-endian integer.
     106             :    Matches wire representation. */
     107             : 
     108             : struct fd_tls_u24 { uchar v[3]; };
     109             : typedef struct fd_tls_u24 fd_tls_u24_t;
     110             : 
     111             : /* fd_tls_msg_hdr_t is the header that all message types share. */
     112             : 
     113             : struct __attribute__((packed)) fd_tls_msg_hdr {
     114             :   uchar        type;   /* FD_TLS_MSG_{...} */
     115             :   fd_tls_u24_t sz;     /* Byte size of fields following this header */
     116             : };
     117             : 
     118             : typedef struct fd_tls_msg_hdr fd_tls_msg_hdr_t;
     119             : 
     120             : /* fd_tls_client_hello_t describes a TLS v1.3 ClientHello (RFC 8446,
     121             :    Section 4.1.2). */
     122             : 
     123             : struct fd_tls_client_hello {
     124             :   uchar random[ 32 ];
     125             : 
     126             :   struct {
     127             :     uchar aes_128_gcm_sha256 : 1;
     128             :     /* Add more cipher suites here */
     129             :   } cipher_suites;
     130             : 
     131             :   fd_tls_ext_opaque_t session_id;
     132             : 
     133             :   fd_tls_ext_supported_versions_t   supported_versions;
     134             :   fd_tls_ext_server_name_t          server_name;
     135             :   fd_tls_ext_supported_groups_t     supported_groups;
     136             :   fd_tls_ext_signature_algorithms_t signature_algorithms;
     137             :   fd_tls_ext_signature_algorithms_t signature_algorithms_cert;
     138             :   fd_tls_key_share_t                key_share;
     139             :   fd_tls_ext_quic_tp_t              quic_tp;
     140             :   fd_tls_ext_alpn_t                 alpn;
     141             : };
     142             : 
     143             : typedef struct fd_tls_client_hello fd_tls_client_hello_t;
     144             : 
     145             : /* fd_tls_server_hello_t describes a TLS v1.3 ServerHello (RFC 8446,
     146             :    Section 4.1.3). */
     147             : 
     148             : struct fd_tls_server_hello {
     149             :   uchar  random[ 32 ];
     150             :   ushort cipher_suite;
     151             : 
     152             :   fd_tls_ext_opaque_t session_id;
     153             :   fd_tls_key_share_t  key_share;
     154             : };
     155             : 
     156             : typedef struct fd_tls_server_hello fd_tls_server_hello_t;
     157             : 
     158             : /* fd_tls_enc_ext_t describes a TLS v1.3 EncryptedExtensions message
     159             :    (RFC 8446, Section 4.3.1). */
     160             : 
     161             : struct fd_tls_enc_ext {
     162             :   fd_tls_ext_quic_tp_t quic_tp;
     163             :   fd_tls_ext_alpn_t    alpn;
     164             :   uint                 server_name:1;
     165             : };
     166             : 
     167             : typedef struct fd_tls_enc_ext fd_tls_enc_ext_t;
     168             : 
     169             : /* fd_tls_cert_verify_t describes a CertificateVerify (RFC 8446, Section
     170             :    4.4.3).  Supports Ed25519 (64 byte sig), ECDSA-P256 (DER encoded,
     171             :    up to 73 bytes), and RSA-PSS (modulus size, up to 512 bytes). */
     172             : 
     173             : #define FD_TLS_CV_SIG_SZ_MAX (512UL)
     174             : 
     175             : struct fd_tls_cert_verify {
     176             :   ushort algorithm;      /* FD_TLS_SIGNATURE_{...} */
     177             :   ushort signature_len;
     178             :   uchar  signature[ FD_TLS_CV_SIG_SZ_MAX ];
     179             : };
     180             : 
     181             : typedef struct fd_tls_cert_verify fd_tls_cert_verify_t;
     182             : 
     183             : /* fd_tls_finished_t matches the wire representation of Finished (RFC
     184             :    8446, Section 4.4.4).  Only supports TLS cipher suites with 32 byte
     185             :    hash output size. */
     186             : 
     187             : struct __attribute__((packed)) fd_tls_finished {
     188             :   uchar verify[ 32 ];
     189             : };
     190             : 
     191             : typedef struct fd_tls_finished fd_tls_finished_t;
     192             : 
     193             : /* Enums **************************************************************/
     194             : 
     195             : /* TLS Legacy Version field */
     196             : 
     197           0 : #define FD_TLS_VERSION_TLS12 ((ushort)0x0303)
     198             : #define FD_TLS_VERSION_TLS13 ((ushort)0x0304)
     199             : 
     200             : /* TLS cipher suite IDs */
     201             : 
     202           0 : #define FD_TLS_CIPHER_SUITE_AES_128_GCM_SHA256 ((ushort)0x1301)
     203             : 
     204             : /* TLS extension IDs */
     205             : 
     206           0 : #define FD_TLS_EXT_SERVER_NAME               ((ushort) 0)
     207           0 : #define FD_TLS_EXT_SUPPORTED_GROUPS          ((ushort)10)
     208           0 : #define FD_TLS_EXT_SIGNATURE_ALGORITHMS      ((ushort)13)
     209           0 : #define FD_TLS_EXT_ALPN                      ((ushort)16)
     210           0 : #define FD_TLS_EXT_CLIENT_CERT_TYPE          ((ushort)19)
     211           0 : #define FD_TLS_EXT_SERVER_CERT_TYPE          ((ushort)20)
     212           0 : #define FD_TLS_EXT_SUPPORTED_VERSIONS        ((ushort)43)
     213           0 : #define FD_TLS_EXT_SIGNATURE_ALGORITHMS_CERT ((ushort)50)
     214           0 : #define FD_TLS_EXT_KEY_SHARE                 ((ushort)51)
     215           0 : #define FD_TLS_EXT_QUIC_TRANSPORT_PARAMS     ((ushort)57)
     216             : 
     217             : /* TLS Alert Protocol */
     218             : 
     219           0 : #define FD_TLS_ALERT_CLOSE_NOTIFY                    ((uchar)  0)
     220           0 : #define FD_TLS_ALERT_UNEXPECTED_MESSAGE              ((uchar) 10)
     221           0 : #define FD_TLS_ALERT_BAD_RECORD_MAC                  ((uchar) 20)
     222           0 : #define FD_TLS_ALERT_RECORD_OVERFLOW                 ((uchar) 22)
     223           0 : #define FD_TLS_ALERT_HANDSHAKE_FAILURE               ((uchar) 40)
     224           0 : #define FD_TLS_ALERT_BAD_CERTIFICATE                 ((uchar) 42)
     225           0 : #define FD_TLS_ALERT_UNSUPPORTED_CERTIFICATE         ((uchar) 43)
     226           0 : #define FD_TLS_ALERT_CERTIFICATE_REVOKED             ((uchar) 44)
     227           0 : #define FD_TLS_ALERT_CERTIFICATE_EXPIRED             ((uchar) 45)
     228           0 : #define FD_TLS_ALERT_CERTIFICATE_UNKNOWN             ((uchar) 46)
     229           0 : #define FD_TLS_ALERT_ILLEGAL_PARAMETER               ((uchar) 47)
     230           0 : #define FD_TLS_ALERT_UNKNOWN_CA                      ((uchar) 48)
     231           0 : #define FD_TLS_ALERT_ACCESS_DENIED                   ((uchar) 49)
     232           0 : #define FD_TLS_ALERT_DECODE_ERROR                    ((uchar) 50)
     233           0 : #define FD_TLS_ALERT_DECRYPT_ERROR                   ((uchar) 51)
     234           0 : #define FD_TLS_ALERT_PROTOCOL_VERSION                ((uchar) 70)
     235           0 : #define FD_TLS_ALERT_INSUFFICIENT_SECURITY           ((uchar) 71)
     236           0 : #define FD_TLS_ALERT_INTERNAL_ERROR                  ((uchar) 80)
     237           0 : #define FD_TLS_ALERT_INAPPROPRIATE_FALLBACK          ((uchar) 86)
     238           0 : #define FD_TLS_ALERT_USER_CANCELED                   ((uchar) 90)
     239           0 : #define FD_TLS_ALERT_MISSING_EXTENSION               ((uchar)109)
     240           0 : #define FD_TLS_ALERT_UNSUPPORTED_EXTENSION           ((uchar)110)
     241           0 : #define FD_TLS_ALERT_UNRECOGNIZED_NAME               ((uchar)112)
     242           0 : #define FD_TLS_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE ((uchar)113)
     243           0 : #define FD_TLS_ALERT_UNKNOWN_PSK_IDENTITY            ((uchar)115)
     244           0 : #define FD_TLS_ALERT_CERTIFICATE_REQUIRED            ((uchar)116)
     245           0 : #define FD_TLS_ALERT_NO_APPLICATION_PROTOCOL         ((uchar)120)
     246             : 
     247             : /* TLS server_name extension */
     248             : 
     249           0 : #define FD_TLS_SERVER_NAME_TYPE_DNS ((uchar)0)  /* RFC 6066 */
     250             : 
     251             : /* TLS signature scheme IDs */
     252             : 
     253           0 : #define FD_TLS_SIGNATURE_RSA_PKCS1_SHA256       ((ushort)0x0401)
     254           0 : #define FD_TLS_SIGNATURE_ECDSA_SECP256R1_SHA256 ((ushort)0x0403)
     255           0 : #define FD_TLS_SIGNATURE_RSA_PKCS1_SHA384       ((ushort)0x0501)
     256           0 : #define FD_TLS_SIGNATURE_ECDSA_SECP384R1_SHA384 ((ushort)0x0503)
     257           0 : #define FD_TLS_SIGNATURE_RSA_PKCS1_SHA512       ((ushort)0x0601)
     258           0 : #define FD_TLS_SIGNATURE_RSA_PSS_RSAE_SHA256    ((ushort)0x0804)
     259           0 : #define FD_TLS_SIGNATURE_RSA_PSS_RSAE_SHA384    ((ushort)0x0805)
     260           0 : #define FD_TLS_SIGNATURE_RSA_PSS_RSAE_SHA512    ((ushort)0x0806)
     261           0 : #define FD_TLS_SIGNATURE_ED25519                ((ushort)0x0807)
     262             : 
     263             : /* TLS supported_groups extension */
     264             : 
     265             : #define FD_TLS_GROUP_SECP256R1 ((ushort)23)
     266           0 : #define FD_TLS_GROUP_X25519    ((ushort)29)
     267             : 
     268             : /* TLS supported_versions extension */
     269             : 
     270           0 : #define FD_TLS_VERSION_TLS13 ((ushort)0x0304)
     271             : 
     272             : /* TLS key_share extension */
     273             : 
     274             : #define FD_TLS_KEY_SHARE_TYPE_X25519 ((ushort)29)
     275             : 
     276             : /* TLS v1.3 message types */
     277             : 
     278           0 : #define FD_TLS_MSG_CLIENT_HELLO       ((uchar)  1)
     279           0 : #define FD_TLS_MSG_SERVER_HELLO       ((uchar)  2)
     280           0 : #define FD_TLS_MSG_NEW_SESSION_TICKET ((uchar)  4)
     281           0 : #define FD_TLS_MSG_ENCRYPTED_EXT      ((uchar)  8)
     282           0 : #define FD_TLS_MSG_CERT               ((uchar) 11)
     283           0 : #define FD_TLS_MSG_CERT_REQ           ((uchar) 13)
     284           0 : #define FD_TLS_MSG_CERT_VERIFY        ((uchar) 15)
     285           0 : #define FD_TLS_MSG_FINISHED           ((uchar) 20)
     286           0 : #define FD_TLS_MSG_KEY_UPDATE            ((uchar) 24)
     287             : 
     288             : /* Serialization related **********************************************/
     289             : 
     290             : /* ### Decode functions
     291             : 
     292             :    Most deserializers follow the same prototype:
     293             : 
     294             :      long
     295             :      fd_tls_decode_TYPE( TYPE_t * out,
     296             :                          void *   wire,
     297             :                          ulong    wire_sz );
     298             : 
     299             :    Consumes bytes of the provided and populates the data structure
     300             :    pointed to by out.  out must be zero-initialized, as the decoder does
     301             :    promise to fill in all fields.  wire points to the first byte of the
     302             :    encoded payload that may span up to wire_sz bytes.  Returns number of
     303             :    bytes read from wire on success.  On failure, returns a negated TLS
     304             :    error code.  (Typically DECODE_ERROR alert)
     305             : 
     306             :    wire (input) may get mangled for endianness conversion.  Thus, decode
     307             :    may not be called twice on the same input buffer.
     308             : 
     309             :    ### Encode functions
     310             : 
     311             :    Most serializers follow the same prototype:
     312             : 
     313             :      long
     314             :      fd_tls_encode_TYPE( TYPE_t const * in,
     315             :                          void *         wire,
     316             :                          ulong          wire_sz );
     317             : 
     318             :    Writes bytes containing serialized version of data structure pointed
     319             :    to by in.  wire points to the first byte of the buffer to fill.
     320             :    wire_sz is the size of that buffer.  Returns number of bytes written
     321             :    on success (can be 0).  On failure, returns a negated TLS error code. */
     322             : 
     323             : FD_PROTOTYPES_BEGIN
     324             : 
     325             : /* Methods for static layout types */
     326             : 
     327             : /* Macro STATIC_SERDE defines decode/encode implementations for structs
     328             :    that match their wire encoding */
     329             : 
     330             : #define STATIC_SERDE( NAME, TYPE_T )                                   \
     331             :   static inline long                                                   \
     332             :   fd_tls_decode_##NAME( TYPE_T *      out,                             \
     333             :                         uchar const * wire,                            \
     334           0 :                         ulong         wire_sz ) {                      \
     335           0 :     if( FD_UNLIKELY( wire_sz < sizeof(TYPE_T) ) )                      \
     336           0 :       return -(long)FD_TLS_ALERT_DECODE_ERROR;                         \
     337           0 :     memcpy( out, wire, sizeof(TYPE_T) );                               \
     338           0 :     fd_tls_##NAME##_bswap( out );                                      \
     339           0 :     return (long)sizeof(TYPE_T);                                       \
     340           0 :   }                                                                    \
     341             :   static inline long                                                   \
     342             :   fd_tls_encode_##NAME ( TYPE_T const * in,                            \
     343             :                          void *         wire,                          \
     344           0 :                          ulong          wire_sz ) {                    \
     345           0 :     if( FD_UNLIKELY( wire_sz < sizeof(TYPE_T) ) )                      \
     346           0 :       return -(long)FD_TLS_ALERT_DECODE_ERROR;                         \
     347           0 :     TYPE_T * out = (TYPE_T *)wire;                                     \
     348           0 :     memcpy( out, in, sizeof(TYPE_T) );                                 \
     349           0 :     fd_tls_##NAME##_bswap( out );                                      \
     350           0 :     return (long)sizeof(TYPE_T);                                       \
     351           0 :   }
     352             : 
     353             : /* End of STATIC_SERDE macro */
     354             : 
     355             : /* Static serialization methods for fd_tls_u24_t */
     356             : 
     357             : static inline fd_tls_u24_t
     358           0 : fd_tls_u24_bswap( fd_tls_u24_t x ) {
     359           0 :   fd_tls_u24_t ret = {{ x.v[2], x.v[1], x.v[0] }};
     360           0 :   return ret;
     361           0 : }
     362             : 
     363             : static inline uint
     364           0 : fd_tls_u24_to_uint( fd_tls_u24_t x ) {
     365           0 :   return fd_uint_load_3( x.v );
     366           0 : }
     367             : 
     368             : static inline fd_tls_u24_t
     369           0 : fd_uint_to_tls_u24( uint x ) {
     370           0 :   fd_tls_u24_t ret = {{ (uchar)( x     &0xffU),
     371           0 :                         (uchar)((x>> 8)&0xffU),
     372           0 :                         (uchar)((x>>16)&0xffU) }};
     373           0 :   return ret;
     374           0 : }
     375             : 
     376             : /* Static serde methods for fd_tls_ext_hdr_t */
     377             : 
     378             : static inline void
     379           0 : fd_tls_ext_hdr_bswap( fd_tls_ext_hdr_t * x ) {
     380           0 :   x->type = fd_ushort_bswap( x->type );
     381           0 :   x->sz   = fd_ushort_bswap( x->sz );
     382           0 : }
     383             : 
     384             : STATIC_SERDE( ext_hdr, fd_tls_ext_hdr_t )
     385             : 
     386             : /* Static serde methods for fd_tls_msg_hdr_t */
     387             : 
     388             : static inline void
     389           0 : fd_tls_msg_hdr_bswap( fd_tls_msg_hdr_t * x ) {
     390           0 :   x->sz = fd_tls_u24_bswap( x->sz );
     391           0 : }
     392             : 
     393             : STATIC_SERDE( msg_hdr, fd_tls_msg_hdr_t )
     394             : 
     395             : /* Static serde methods for fd_tls_finished_t */
     396             : 
     397           0 : static inline void fd_tls_finished_bswap( fd_tls_finished_t * x FD_FN_UNUSED ) {}
     398             : 
     399             : STATIC_SERDE( finished, fd_tls_finished_t )
     400             : 
     401             : /* Methods for dynamic layout types */
     402             : 
     403             : long
     404             : fd_tls_decode_client_hello( fd_tls_client_hello_t * out,
     405             :                             uchar const *           wire,
     406             :                             ulong                   wire_sz );
     407             : 
     408             : long
     409             : fd_tls_encode_client_hello( fd_tls_client_hello_t const * in,
     410             :                             uchar *                       wire,
     411             :                             ulong                         wire_sz );
     412             : 
     413             : long
     414             : fd_tls_decode_server_hello( fd_tls_server_hello_t * out,
     415             :                             uchar const *           wire,
     416             :                             ulong                   wire_sz );
     417             : 
     418             : long
     419             : fd_tls_encode_server_hello( fd_tls_server_hello_t const * in,
     420             :                             uchar *                       wire,
     421             :                             ulong                         wire_sz );
     422             : 
     423             : long
     424             : fd_tls_encode_hello_retry_request( fd_tls_server_hello_t const * in,
     425             :                                    uchar *                       wire,
     426             :                                    ulong                         wire_sz );
     427             : 
     428             : long
     429             : fd_tls_decode_enc_ext( fd_tls_enc_ext_t * out,
     430             :                        uchar const *            wire,
     431             :                        ulong                    wire_sz );
     432             : 
     433             : long
     434             : fd_tls_encode_enc_ext( fd_tls_enc_ext_t const * in,
     435             :                        uchar *                        wire,
     436             :                        ulong                          wire_sz );
     437             : 
     438             : long
     439             : fd_tls_encode_cert_x509( uchar const * x509,
     440             :                          ulong         x509_sz,
     441             :                          uchar *       wire,
     442             :                          ulong         wire_sz );
     443             : 
     444             : long
     445             : fd_tls_decode_cert_req( fd_tls_ext_signature_algorithms_t * out,
     446             :                         uchar const *                       wire,
     447             :                         ulong                               wire_sz );
     448             : 
     449             : long
     450             : fd_tls_decode_cert_verify( fd_tls_cert_verify_t * out,
     451             :                            uchar const *          wire,
     452             :                            ulong                  wire_sz );
     453             : 
     454             : long
     455             : fd_tls_encode_cert_verify( fd_tls_cert_verify_t const * in,
     456             :                            uchar *                      wire,
     457             :                            ulong                        wire_sz );
     458             : 
     459             : static inline void
     460           0 : fd_tls_cert_verify_bswap( fd_tls_cert_verify_t * x ) {
     461           0 :   x->algorithm = fd_ushort_bswap( x->algorithm );
     462           0 : }
     463             : 
     464             : long
     465             : fd_tls_decode_ext_server_name( fd_tls_ext_server_name_t * out,
     466             :                                uchar const *              wire,
     467             :                                ulong                      wire_sz );
     468             : 
     469             : long
     470             : fd_tls_decode_ext_supported_groups( fd_tls_ext_supported_groups_t * out,
     471             :                                     uchar const *                   wire,
     472             :                                     ulong                           wire_sz );
     473             : 
     474             : long
     475             : fd_tls_decode_ext_supported_versions( fd_tls_ext_supported_versions_t * out,
     476             :                                       uchar const *                     wire,
     477             :                                       ulong                             wire_sz );
     478             : 
     479             : long
     480             : fd_tls_decode_ext_signature_algorithms( fd_tls_ext_signature_algorithms_t * out,
     481             :                                         uchar const *                       wire,
     482             :                                         ulong                               wire_sz );
     483             : 
     484             : long
     485             : fd_tls_decode_key_share( fd_tls_key_share_t * out,
     486             :                          uchar const *        wire,
     487             :                          ulong                wire_sz );
     488             : 
     489             : long
     490             : fd_tls_decode_key_share_list( fd_tls_key_share_t * out,
     491             :                               uchar const *        wire,
     492             :                               ulong                wire_sz );
     493             : 
     494             : /* fd_tls_decode_ext_opaque is special:
     495             :    out->{buf,buf_sz} will be set to {wire,wire_sz}.
     496             :    i.e. lifetime of out->quic_tp is that of wire. */
     497             : 
     498             : long
     499             : fd_tls_decode_ext_opaque( fd_tls_ext_opaque_t * const out,
     500             :                           uchar const *         const wire,
     501             :                           ulong                       wire_sz );
     502             : 
     503             : static inline long
     504             : fd_tls_decode_ext_quic_tp( fd_tls_ext_quic_tp_t * const out,
     505             :                            uchar const *          const wire,
     506           0 :                            ulong                        wire_sz ) {
     507           0 :   return fd_tls_decode_ext_opaque( out, wire, wire_sz );
     508           0 : }
     509             : 
     510             : long
     511             : fd_tls_decode_ext_alpn( fd_tls_ext_alpn_t * const out,
     512             :                         uchar const *       const wire,
     513             :                         ulong                     wire_sz );
     514             : 
     515             : long
     516             : fd_tls_encode_ext_alpn( fd_tls_ext_alpn_t const * in,
     517             :                         uchar *                   wire,
     518             :                         ulong                     wire_sz );
     519             : 
     520             : /* fd_tls_extract_cert_pubkey validates the initial-handshake Certificate
     521             :    envelope and extracts its leaf public key.  Requires an empty request
     522             :    context and a nonempty, exactly framed certificate_list.  Rejects
     523             :    CertificateEntry extensions, which our CH and CR do not solicit.
     524             :    Does not authenticate the X.509 chain or establish trust. */
     525             : 
     526             : struct fd_tls_extract_cert_pubkey_res {
     527             :   uchar const * pubkey;      /* see fd_x509_cert_info_t.pubkey */
     528             :   ulong         pubkey_len;
     529             :   uchar         key_type;    /* FD_TLS_KEY_{...} */
     530             :   uint          alert;
     531             :   ushort        reason;
     532             : };
     533             : 
     534             : typedef struct fd_tls_extract_cert_pubkey_res fd_tls_extract_cert_pubkey_res_t;
     535             : 
     536             : fd_tls_extract_cert_pubkey_res_t
     537             : fd_tls_extract_cert_pubkey( uchar const * cert,
     538             :                             ulong         cert_sz );
     539             : 
     540             : FD_PROTOTYPES_END
     541             : 
     542             : #undef STATIC_SERDE
     543             : 
     544             : #endif /* HEADER_fd_src_waltz_tls_fd_tls_proto_h */

Generated by: LCOV version 1.14