Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ add_executable(baseline
${APP_DIR}/storage/SemihostingDisk.c
${APP_DIR}/syslog/Syslog.c
${APP_DIR}/syslog/SyslogFields.c
${APP_DIR}/syslog/SyslogPipelineSd.c
${APP_DIR}/syslog/SyslogErrorHandler.c
$<TARGET_OBJECTS:baseline_upstream>
)
Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ It builds on a baseline that simulates the sort of device you might be adding th
measures itself: see [docs/baseline.md](docs/baseline.md) for what the baseline is, how the
figures are made, and how to run it.

## This stage — HMAC at rest
## This stage — Private SD-ELEMENT

Stored records are sealed with HMAC-SHA256 instead of a CRC-16. An edit made on the volume no
longer verifies, so the spool becomes tamper-evident rather than merely checked for corruption.
RFC 5424 records carry structured data: named groups of key/value pairs a collector parses rather
than pattern-matches out of the message text. Everything used so far has been standard elements,
which mean the same on any device. This stage defines one of our own — which is where a product
says what only it knows, and `app/syslog/SyslogPipelineSd.c` is all it takes to write one.

The key is the device's own, fetched from its provisioned key store for each seal and each verify
rather than held by the logger.
`logPipeline@32473` reports the protection the record's own path was under: `transport="tls"`,
`atRest="hmac-sha256"`, under our IANA enterprise number so a private name cannot collide with
anyone else's. A collector can confirm that rather than assume it, and alert on a device whose
pipeline has weakened.

<!-- STAGE-COST:START (generated by scripts/gen-cost-table.py — do not edit by hand) -->

**Cost above baseline: Flash +13,424 B, RAM +35,684 B.**
**Cost above baseline: Flash +13,548 B, RAM +35,688 B.**

<!-- STAGE-COST:END -->

Expand Down Expand Up @@ -51,6 +55,7 @@ committed as [`run-report.md`](run-report.md), and rewritten by every stage.
| Origin address | the device's own address in the record, which a relay or NAT between it and the collector cannot rewrite | +12,388 | +7,384 |
| TLS | a collector the device authenticates, and records no longer readable on the wire | +13,076 | +35,664 |
| HMAC at rest | stored records that cannot be edited undetected, not merely checked for corruption | +13,424 | +35,684 |
| Private SD-ELEMENT | a record that states the protection its own log pipeline was under | +13,548 | +35,688 |

*Deltas are bytes above the baseline, which is itself Flash 350,308 B, RAM 111,192 B.*

Expand Down
4 changes: 3 additions & 1 deletion app/syslog/Syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "SolidSyslogTimeQualitySd.h"
#include "SyslogEnterprise.h"
#include "SyslogFields.h"
#include "SyslogPipelineSd.h"

#include "lwip/ip4_addr.h"
#include "lwip/tcpip.h"
Expand Down Expand Up @@ -69,7 +70,7 @@ static struct SolidSyslog* s_logger = NULL;
static uint8_t s_ring[SOLIDSYSLOG_CIRCULAR_BUFFER_RING_BYTES(SYSLOG_BUFFER_RECORDS)];

/* The logger reads these on every record, so they outlive Syslog_Start. */
static struct SolidSyslogStructuredData* s_sd[3];
static struct SolidSyslogStructuredData* s_sd[4];

/* One reading at boot, then free-running on the tick — enough to stamp a record,
* not synchronisation. */
Expand Down Expand Up @@ -182,6 +183,7 @@ void Syslog_Start(void)
.GetIpAt = SyslogOriginIpAt,
};
s_sd[2] = SolidSyslogOriginSd_Create(&originConfig);
s_sd[3] = SyslogPipelineSd_Get();

struct SolidSyslogMbedTlsHmacSha256PolicyConfig hmacConfig = {.GetKey = SyslogStoreKey};

Expand Down
12 changes: 8 additions & 4 deletions app/syslog/SyslogEnterprise.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/* This product's IANA Private Enterprise Number. It identifies the vendor, not
* the logger, so it lives on its own rather than beside any one element that
* carries it.
/* This product's IANA Private Enterprise Number, in the two forms RFC 5424 wants
* it: the number that makes a private SD-ID private, and the string origin's
* enterpriseId PARAM carries. Defined once and derived, so the two cannot drift.
*
* 32473 is reserved for documentation (RFC 5612). Register your own at
* https://www.iana.org/assignments/enterprise-numbers/ */
#ifndef APP_SYSLOG_ENTERPRISE_H
#define APP_SYSLOG_ENTERPRISE_H

#define SYSLOG_ENTERPRISE_ID "32473"
#define SYSLOG_ENTERPRISE_NUMBER 32473

#define SYSLOG_ENTERPRISE_STRINGIFY_(value) #value
#define SYSLOG_ENTERPRISE_STRINGIFY(value) SYSLOG_ENTERPRISE_STRINGIFY_(value)
#define SYSLOG_ENTERPRISE_ID SYSLOG_ENTERPRISE_STRINGIFY(SYSLOG_ENTERPRISE_NUMBER)

#endif /* APP_SYSLOG_ENTERPRISE_H */
30 changes: 30 additions & 0 deletions app/syslog/SyslogPipelineSd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* See SyslogPipelineSd.h. */

#include "SyslogPipelineSd.h"

#include "SyslogEnterprise.h"

#include "SolidSyslogSdElement.h"
#include "SolidSyslogSdValue.h"
#include "SolidSyslogStructuredDataDefinition.h"

/* A non-zero enterprise number is what makes the SD-ID private: _Begin emits
* "name@number" for one, a bare IANA "name" for 0. */
static void SyslogPipelineSd_Format(struct SolidSyslogStructuredData* base, struct SolidSyslogSdElement* element)
{
(void) base;

SolidSyslogSdElement_Begin(element, "logPipeline", SYSLOG_ENTERPRISE_NUMBER);
SolidSyslogSdValue_String(SolidSyslogSdElement_Param(element, "transport"), "tls");
SolidSyslogSdValue_String(SolidSyslogSdElement_Param(element, "atRest"), "hmac-sha256");
SolidSyslogSdElement_End(element);
}

/* No _Create and no pool slot: the library never allocates an SD source, so a
* stateless one is a vtable this application owns. */
static struct SolidSyslogStructuredData s_pipelineSd = {SyslogPipelineSd_Format};

struct SolidSyslogStructuredData* SyslogPipelineSd_Get(void)
{
return &s_pipelineSd;
}
13 changes: 13 additions & 0 deletions app/syslog/SyslogPipelineSd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* A worked example of a private enterprise SD-ELEMENT — the part of RFC 5424
* structured data that is yours to define. The IANA elements say what any device
* can say; a private one says what only your product knows. This one reports the
* protection in force on the log pipeline itself. */
#ifndef APP_SYSLOG_PIPELINE_SD_H
#define APP_SYSLOG_PIPELINE_SD_H

struct SolidSyslogStructuredData;

/** The shared instance, for SolidSyslogConfig.Sd. Stateless, so never NULL. */
struct SolidSyslogStructuredData* SyslogPipelineSd_Get(void);

#endif /* APP_SYSLOG_PIPELINE_SD_H */
13 changes: 13 additions & 0 deletions measurements/pipeline-sd.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# pipeline-sd figures (bytes) — captured by scripts/run.sh (CAPTURE=1).
# The device reads measurements/Baseline.csv as its frozen baseline and reports current-minus-Baseline.
flash_text,363208
flash_data,648
static_bss,146232
heap_used,4440
mbedtls_peak,36096
mbedtls_free,18176
lwip_mem_free,7576
lwip_pbufs_free,14
stack_log,832
stack_service,3852
stack_harness,2848
1 change: 1 addition & 0 deletions measurements/stages.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ buffer-halve Smaller ring most of the cap rise given back, now the store rather
origin-ip Origin address the device's own address in the record, which a relay or NAT between it and the collector cannot rewrite
tls TLS a collector the device authenticates, and records no longer readable on the wire
hmac HMAC at rest stored records that cannot be edited undetected, not merely checked for corruption
pipeline-sd Private SD-ELEMENT a record that states the protection its own log pipeline was under
22 changes: 11 additions & 11 deletions run-report.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# solid-syslog-example — run (hmac)
# solid-syslog-example — run (pipeline-sd)

## Device (self-measured)

Expand All @@ -10,14 +10,14 @@
[device] first record logged: yes
[report] --- SolidSyslog cost above baseline (simulated existing application) ---
[report] key,current,baseline,used_above_baseline
[report] flash_text,363088,349992,13096
[report] flash_data,644,316,328
[report] flash_text,363208,349992,13216
[report] flash_data,648,316,332
[report] static_bss,146232,110876,35356
[report] heap_used,4440,4440,0
[report] mbedtls_peak,36096,21332,14764
[report] mbedtls_free,18176,11436,6740
[report] lwip_mem_free,7576,7576,0
[report] lwip_pbufs_free,13,14,-1
[report] lwip_pbufs_free,14,14,0
[report] stack_log,832,120,712
[report] stack_service,3852,52,3800
[report] stack_harness,2848,2840,8
Expand All @@ -29,7 +29,7 @@

```text
text data bss dec hex filename
363080 652 146232 509964 7c80c /w/build/baseline-cross/baseline.elf
363200 656 146232 510088 7c888 /w/build/baseline-cross/baseline.elf
```

## Listeners (proved before the device ran)
Expand All @@ -47,21 +47,21 @@
## Collector (syslog-ng) received

```text
wire <134>1 2026-07-29T10:49:57.430000Z 10.0.2.15 solid-syslog-example - BOOT [meta sequenceId="1" sysUpTime="243"][timeQuality tzKnown="1" isSynced="0"][origin software="solid-syslog-example" swVersion="0.1.0" enterpriseId="32473" ip="10.0.2.15"] device started
parsed PRIORITY=134 TIMESTAMP=2026-07-29T10:49:57+00:00 HOSTNAME=10.0.2.15 APP_NAME=solid-syslog-example PROCID= MSGID=BOOT STRUCTURED_DATA=[meta sequenceId="1" sysUpTime="243"][timeQuality tzKnown="1" isSynced="0"][origin software="solid-syslog-example" swVersion="0.1.0" enterpriseId="32473" ip="10.0.2.15"] MSG=device started
wire <134>1 2026-07-29T10:57:51.850000Z 10.0.2.15 solid-syslog-example - BOOT [meta sequenceId="1" sysUpTime="385"][timeQuality tzKnown="1" isSynced="0"][origin software="solid-syslog-example" swVersion="0.1.0" enterpriseId="32473" ip="10.0.2.15"][logPipeline@32473 transport="tls" atRest="hmac-sha256"] device started
parsed PRIORITY=134 TIMESTAMP=2026-07-29T10:57:51+00:00 HOSTNAME=10.0.2.15 APP_NAME=solid-syslog-example PROCID= MSGID=BOOT STRUCTURED_DATA=[meta sequenceId="1" sysUpTime="385"][timeQuality tzKnown="1" isSynced="0"][origin software="solid-syslog-example" swVersion="0.1.0" enterpriseId="32473" ip="10.0.2.15"][logPipeline@32473 transport="tls" atRest="hmac-sha256"] MSG=device started
```

## Self-check (vs measurements/hmac.csv)
## Self-check (vs measurements/pipeline-sd.csv)

```text
OK flash_text: 363088 (expected 363088, Δ0)
OK flash_data: 644 (expected 644, Δ0)
OK flash_text: 363208 (expected 363208, Δ0)
OK flash_data: 648 (expected 648, Δ0)
OK static_bss: 146232 (expected 146232, Δ0)
OK heap_used: 4440 (expected 4440, Δ0)
OK mbedtls_peak: 36096 (expected 36096, Δ0)
OK mbedtls_free: 18176 (expected 18176, Δ0)
OK lwip_mem_free: 7576 (expected 7576, Δ0)
OK lwip_pbufs_free: 13 (expected 13, Δ0)
OK lwip_pbufs_free: 14 (expected 14, Δ0)
OK stack_log: 832 (expected 832, Δ0)
OK stack_service: 3852 (expected 3852, Δ0)
OK stack_harness: 2848 (expected 2848, Δ0)
Expand Down
Loading