ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
extension.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4#ifndef PROTOCORE_TRANSPORT_EXTENSION_H
5#define PROTOCORE_TRANSPORT_EXTENSION_H
6
7#include "protocore_config.h" // the entry point: protocore_types.h for the widths
8
10
11/**
12 * @file extension.h
13 * @brief RFC 8308 extension negotiation.
14 *
15 * @c work is bytes the CALLER holds. This module reads none of them: it carries nothing
16 * between calls, so there is no state to keep and nothing to wipe. The parameter is there so
17 * a caller drives every namespace the same way.
18 */
19
20// PROTOCORE_EXTENSION_BORROW - the bytes this module runs out of - is stated in protocore_config.h, which sums
21// it into its arena. Its size and its offset are each a static_assert, so a feature
22// combination that does not fit fails to compile rather than overrunning at run time.
23
24/**
25 * @brief Bytes an indicator name takes in a kex_algorithms list, with its separating comma.
26 *
27 * Both indicator names are the same length, so one bound covers either role.
28 */
29#define SSH_EXT_INFO_INDICATOR_MAX sizeof(",ext-info-s")
30
31/** @brief Dispatch table. Addressed by offset, so the layout is asserted below. */
32typedef struct
33{
34 const char *(*info_indicator)(uint8_t *, proto_bool);
35 int (*build)(uint8_t *, uint8_t *, size_t *, size_t);
37PROTOCORE_NS_LAYOUT(ExtensionNs, info_indicator, build);
38
39/**
40 * @brief The RFC 8308 sec 2.2 indicator name belonging to a role. .
41 * @param work PROTOCORE_EXTENSION_BORROW bytes the caller took. Not held past the call.
42 * @param client_role True for the client's indicator, false for the server's
43 * @return The const char *.
44 */
45const char *protocore_extension_info_indicator(uint8_t *work, proto_bool client_role);
46/**
47 * @brief Build SSH_MSG_EXT_INFO advertising server-sig-algs (RFC 8308). .
48 * @param work PROTOCORE_EXTENSION_BORROW bytes the caller took. Not held past the call.
49 * @param out Out
50 * @param len Len
51 * @param cap Cap
52 * @return The int.
53 */
54int protocore_extension_build(uint8_t *work, uint8_t *out, size_t *len, size_t cap);
55
56/** @brief Module namespace. */
59
61
62#endif // PROTOCORE_TRANSPORT_EXTENSION_H
const char * protocore_extension_info_indicator(uint8_t *work, proto_bool client_role)
The RFC 8308 sec 2.2 indicator name belonging to a role. .
PROTOCORE_NS ExtensionNs Extension PROTOCORE_UNUSED
Module namespace.
Definition extension.h:57
int protocore_extension_build(uint8_t *work, uint8_t *out, size_t *len, size_t cap)
Build SSH_MSG_EXT_INFO advertising server-sig-algs (RFC 8308). .
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
Definition extension.h:33
const char *(* info_indicator)(uint8_t *, proto_bool)
Definition extension.h:34
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
_Bool proto_bool
The truth value.
Definition types.h:64
#define PROTOCORE_END_DECLS
Definition types.h:97