Overview / Security & product

updater

Signed update channel: Ed25519 over a manifest, plus SHA-256 per artifact and per file. It creates no threads and opens no sockets on its own. Networking comes in through interfaces, and everything advances through <code>Tick</code>.

Optional module: turn it on with -DETHEREAL_UPDATER=ONInclude #include <ethereal/cpp/updater/apply.hpp>C layer

apply.hpp

#include <ethereal/cpp/updater/apply.hpp>

The apply layer: puts the new files in place without ever leaving the install halfway.

The spec: "apply is where updaters corrupt installs". Hence the rule over everything: at any instant, if power fails, the next start leaves the install whole, all old or all new.

1. Stage. The package (decompressed as a stream) is written to '<staging>/stage/<path>'. Each file must be in the SIGNED list, once, and have the signed hash. The install has not been touched yet. 2. Prepare. The journal ('<install>/.etl-update/journal') goes to "P", with each file and whether it already existed. It is always written through '.tmp' + 'fsync' + 'rename'. 3. Swap. Each file that existed goes to '.etl-update/backup/<path>', and the new one comes from the staging area into place. Only 'rename's: atomic, one by one. 4. Applied. The journal goes to "C" (waiting for confirmation). The backups stay.

  • A start that finds "P" UNDOES (the backup comes back, the new file of a path that did not exist goes away). One that finds "R" (halfway through a rollback) finishes the rollback. Each step can be redone: repeating it after another failure gives the same result.
  • 'ConfirmHealthy' goes to "K" (confirmed), deletes the backups and the journal. A start that finds "K" finishes the cleanup, and never rolls back, because the backups may already be gone.
  • 'NotifyLaunch' counts the starts without confirmation. Past the limit, it ROLLS BACK. This is the seam with the health check: a version that always crashes never gets confirmed.

Files that go away. On confirmation, the list of the release is kept in '.etl-update/installed' (the record of what the updater put there). On the next apply, a path that was in the record and is no longer in the new list GOES AWAY, the same way as the backups: it moves to '.etl-update/backup', enters the journal ("drop"), and a rollback puts it back. Without a record (the first update of an install made by an installer) nothing goes away: the updater only deletes what it put there itself. Folders left empty stay.

What the failure model assumes, stated: that a 'rename' or an 'unlink' that returned success survives a power loss (the file system logs folder operations, 'SyncDir' is the 'fsync' of the folder, and on Windows 'MOVEFILE_WRITE_THROUGH'), and that the DATA of a file only survives after 'Sync'. The test injects a power loss at each operation and throws away what was not synced.

struct

SInstallParams

Ethereal::Updater#
C++
struct   SInstallParams   final
{
    /// @brief  Null: the OS one.
    IFileSystem *        pFileSystem = nullptr;

    /// @brief  The folder being updated (UTF-8). The journal and the backups live
    ///             in '<install>/.etl-update'.
    const ETL_CHAR *    pInstallDir = nullptr;

    /// @brief  Where staging happens (UTF-8). The new files go to '<staging>/stage'.
    ///             It must be on the same volume as the install: the atomic 'rename'
    ///             does not cross volumes.
    const ETL_CHAR *    pStagingDir = nullptr;

    /// @brief  To check the staging area again in 'ApplyStaged'.
    IHasher *            pHasher = nullptr;

    /// @brief  How many starts without 'ConfirmHealthy' before rolling back.
    ETL_UINT32            uMaxUnconfirmedLaunches = 3u;
};

Where the install and the staging area live, and through which file system.

enum

EInstallState

Ethereal::Updater#
C++
enum class   EInstallState : ETL_UINT8
{
    /// @brief  Nothing pending.
    eClean = 0,

    /// @brief  A staged release is waiting for 'ApplyStaged'.
    eStaged,

    /// @brief  Applied, waiting for 'ConfirmHealthy'.
    ePendingConfirmation
};

What the start found.

struct

SSignedFiles

Ethereal::Updater#
C++
struct   SSignedFiles   final
{
    /// @brief  The embedded list.
    std::span< const SFileEntry >    Inline;

    /// @brief  Number of files of the list in the package.
    ETL_UINT32                        uListCount = 0u;

    /// @brief  32 bytes: hash of the list in the package.
    const ETL_UINT8 *                pListHash = nullptr;
};

What the manifest signed about the files of an artifact: the embedded list, OR the count and the hash of the list that comes in the package ('filelist.hpp').

class

CStagingJob

Ethereal::Updater#

The staging job: reads the artifact, decompresses, checks and writes the staging area.

class CStagingJob final

In pieces: each 'Step' reads at most the budget it is given, so the Tick of CUpdater never blocks on a gigabyte artifact. The buffers and the decompressor are members (~170 KB): the object lives on the heap.

constructor

CStagingJob

#
CStagingJob() noexcept;

Default constructor.

function

Begin

#
EStatus Begin( const SInstallParams & Params, const ETL_CHAR * pArtifactPath, ECompression eCompression, const SSignedFiles & Signed, IHasher * pHasher, ETL_UINT64 uArtifactSize ) noexcept;

Prepares the job.

Params
Install and staging folders.
pArtifactPath
The downloaded artifact.
eCompression
Compression of the artifact.
Signed
What the manifest SIGNED about the files.
pHasher
Hash of the files.
uArtifactSize
Size of the artifact, for the decompression bomb limit.
eOk, eInvalidArgument, eNotImplemented (compression not supported), or the file system error.
function

Step

#
EStatus Step( ETL_UINT64 uBudget ) noexcept;

Advances up to uBudget bytes of the artifact.

uBudget
Bytes of the artifact to read in this call.
'ePending' while there is work, 'eOk' when all signed files are staged and checked, or the error.
function

Abort

#
void Abort() noexcept;

Closes what is open (the staging area stays, the install was not touched).

function

Files

#
std::span< const SFileRecord > Files() const noexcept

The signed list, sorted by path (the embedded one, or the one that came in the package and matched). Complete when 'Step' returned 'eOk'.

function

CommitStaged

Ethereal::Updater#
EStatus CommitStaged( const SInstallParams & Params, std::span< const SFileRecord > Signed ) noexcept;

Swaps the staged files now (the 'eRenameReplace' strategy).

The files the record has and the new list does not go away (reversibly).

Params
Install and staging folders.
Signed
The signed list.
eOk, eWrongState when another transaction is unfinished, or the error.
function

MarkStaged

Ethereal::Updater#
EStatus MarkStaged( const SInstallParams & Params, std::span< const SFileRecord > Signed ) noexcept;

Leaves the staging area marked for the next start ('eOnNextLaunch' and the helper).

Params
Install and staging folders.
Signed
The signed list.
eOk, eWrongState or the error.
function

ApplyStaged

Ethereal::Updater#
EStatus ApplyStaged( const SInstallParams & Params ) noexcept;

At start (or in the helper): checks the staging area again and swaps it.

function

RecoverInstall

Ethereal::Updater#
EStatus RecoverInstall( const SInstallParams & Params, EInstallState * pState, bool * pRolledBack ) noexcept;

At start, BEFORE loading the rest: finishes or undoes what was left halfway.

Params
Install and staging folders.
pState
Receives what the start found.
pRolledBack
Receives true when an interrupted apply was undone. May be null.
eOk or the error.
function

NotifyLaunch

Ethereal::Updater#
EStatus NotifyLaunch( const SInstallParams & Params, bool * pRolledBack ) noexcept;

Counts a start without confirmation. Past the limit, rolls back.

Params
Install and staging folders.
pRolledBack
Receives true when it rolled back. May be null.
eOk or the error.
function

ConfirmHealthy

Ethereal::Updater#
EStatus ConfirmHealthy( const SInstallParams & Params ) noexcept;

The new version started fine: the backups go away.

function

RollbackInstall

Ethereal::Updater#
EStatus RollbackInstall( const SInstallParams & Params ) noexcept;

Goes back to the previous version (only before confirmation).

delta.hpp

#include <ethereal/cpp/updater/delta.hpp>

Binary deltas: a new file described as differences over the old one.

The idea is the one of bsdiff (Colin Percival, 2003). The suffixes of the old file are sorted, and the new file is scanned looking for the longest match at each point. What is reused goes as a byte by byte DIFFERENCE (almost all zeros when only addresses changed, which compresses well). What is really new goes as EXTRA.

"ETLUDLT1" u64 size of the new file u64 control: raw size, compressed size u64 differences: raw size, compressed size u64 extra: raw size, compressed size the three blocks, each one in raw deflate

The control block is a list of triples (i64 little endian): copy with difference X bytes (new[i] = old[j] + diff[i]), append Y bytes of extra, and skip Z in the old file.

The applier does not trust the patch. Each triple is checked against the declared sizes before use, an old byte outside the file counts as zero (the bsdiff rule, without reading outside), and at the end the new file must have exactly the declared size. The apply layer also checks the hash of the SOURCE before (a delta over unexpected bytes silently gives garbage) and the hash of the result after, against the signed one. Covered by the fuzzer.

Memory: the old file, the patch and the new file live in memory while applying, because bsdiff jumps around the old file. The limit per file is 'DELTA_MAX_FILE' (512 MiB). Above that, the full file is published.

const

DELTA_MAX_FILE

Ethereal::Updater#
constexpr ETL_UINT64 DELTA_MAX_FILE = 512ull << 20;

Largest file (old or new) a delta covers.

function

BuildDelta

Ethereal::Updater#
EStatus BuildDelta( std::span< const ETL_UINT8 > Old, std::span< const ETL_UINT8 > New, std::vector< ETL_UINT8 > * pPatch ) noexcept;

Computes the delta from Old to New (publisher side).

Reserves about 9 times the size of the old file (the suffix sort). Deterministic: the same files give the same bytes.

Old
The old file.
New
The new file.
pPatch
Receives the patch.
eOk, eInvalidArgument, or eBufferTooSmall when out of memory.
function

ApplyDelta

Ethereal::Updater#
EStatus ApplyDelta( std::span< const ETL_UINT8 > Old, std::span< const ETL_UINT8 > Patch, ETL_UINT64 uMaxNew, std::vector< ETL_UINT8 > * pNew ) noexcept;

Applies Patch to Old.

Old
The old file.
Patch
The patch.
uMaxNew
Caps what a hostile patch can make the applier reserve.
pNew
Receives the new file.
EStatus::eMalformed on any inconsistency of the patch.

filelist.hpp

#include <ethereal/cpp/updater/filelist.hpp>

The signed file list, for artifacts that do not fit in the manifest.

The manifest is a network reply of fixed size in memory. It carries at most 16 files per artifact, with paths of up to 63 bytes. A larger artifact carries, instead of the list, the HASH and the COUNT of a list, and the list travels as the FIRST entry of the package ('.etl-files', kind 'eFileList'). The staging layer hashes it, checks it against what the manifest signed, and only then uses it as the signed list.

"ETLFL1\0\0" u32 count u32 reserved (0) per file, in STRICTLY increasing path order (bytes): u16 path length, the path (relative, '/' as separator) 32 bytes: the SHA-256 u32 POSIX mode

Canonical: the same list gives the same bytes (the publisher sorts), and the reader rejects what is not sorted, repeated, or has an unsafe path. Two encodings of the same list would be two hashes, and the manifest signs only one.

const

FILE_LIST_MAX_PATH

Ethereal::Updater#
constexpr ETL_UINT32 FILE_LIST_MAX_PATH = 256u;

Largest relative path of a file (with the terminator): 255 usable bytes.

const

FILE_LIST_MAX_FILES

Ethereal::Updater#
constexpr ETL_UINT32 FILE_LIST_MAX_FILES = 65536u;

How many files an artifact can have.

const

FILE_LIST_MAX_BYTES

Ethereal::Updater#
constexpr ETL_UINT64 FILE_LIST_MAX_BYTES = 16u + static_cast< ETL_UINT64 >( FILE_LIST_MAX_FILES ) * ( 2u + ( FILE_LIST_MAX_PATH - 1u ) + UPDATER_HASH_SIZE + 4u );

Largest size of an encoded list.

const

FILE_LIST_ENTRY_PATH

Ethereal::Updater#
constexpr const ETL_CHAR * FILE_LIST_ENTRY_PATH = ".etl-files";

Reserved path of the package entry that carries the list.

struct

SFileRecord

Ethereal::Updater#
C++
struct   SFileRecord   final
{
    /// @brief  Relative path, '/' as separator.
    ETL_CHAR    aPath[ FILE_LIST_MAX_PATH ] = {};

    /// @brief  SHA-256 of the contents.
    ETL_UINT8    aHash[ UPDATER_HASH_SIZE ] = {};

    /// @brief  POSIX permissions. Ignored on Windows.
    ETL_UINT32    uMode = 0u;
};

A signed file: path, hash and mode.

function

BuildFileList

Ethereal::Updater#
EStatus BuildFileList( std::span< const SFileRecord > Files, std::vector< ETL_UINT8 > * pOut ) noexcept;

Encodes the list in the canonical form (sorts a copy).

Files
The files.
pOut
Receives the encoded list.
EStatus::ePathEscape for an unsafe path, one too long, or the reserved one. EStatus::eInvalidArgument for a repeated path, an empty list or one with more than FILE_LIST_MAX_FILES.
function

ParseFileList

Ethereal::Updater#
EStatus ParseFileList( std::span< const ETL_UINT8 > Bytes, std::vector< SFileRecord > * pOut ) noexcept;

Reads an encoded list. Strict: only the canonical form passes.

Bytes
The encoded list.
pOut
Receives the files.
eOk, eMalformed, ePathEscape, eInvalidArgument or eBufferTooSmall.

filesystem.hpp

#include <ethereal/cpp/updater/filesystem.hpp>

The file system of the Updater, as a seam.

Why a seam: the spec says applying is where updaters break installs, and asks for fault injection at EVERY step, including a power loss in the middle of a write that has not reached the disk yet. That can only be tested if every operation goes through here. The test plugs in a file system that fails at step N (or that "loses power" and throws away what was not synced), and checks that the install stays whole, old or new, and never halfway.

Without a given seam, the OS one is used ('OsFileSystem'): POSIX with 'open'/'fsync'/'rename', and Windows with 'CreateFileW'/'FlushFileBuffers'/'MoveFileExW'. Paths are UTF-8 on both platforms.

const

UPDATER_MAX_PATH

Ethereal::Updater#
constexpr ETL_UINT32 UPDATER_MAX_PATH = 512u;

Maximum length of a path the Updater builds (UTF-8, with the terminator).

enum

EOpenMode

Ethereal::Updater#
C++
enum class   EOpenMode : ETL_UINT8
{
    /// @brief  Read. Fails with eNotFound when the file does not exist.
    eRead = 0,

    /// @brief  Write from scratch (creates or truncates).
    eWriteTruncate,

    /// @brief  Append at the end (creates when it does not exist).
    eAppend
};

How to open a file.

struct

IFileSystem

Ethereal::Updater#
C++
struct   IFileSystem
{
    ///
    /// Open
    ///
    /// @brief  Opens a file.
    ///
    /// @param pPath    UTF-8 path.
    /// @param eMode    How to open.
    /// @param ppFile    Receives the opaque file.
    ///
    /// @return  eOk, eNotFound, eIoError or eInvalidArgument.
    ///
    virtual EStatus Open( const ETL_CHAR * pPath, EOpenMode eMode, void ** ppFile ) ETL_NOEXCEPT = 0;

    /// @brief  Reads up to uCap bytes. Zero in pGot means end of file.
    ///
    virtual EStatus Read( void * pFile, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pGot ) ETL_NOEXCEPT = 0;

    /// @brief  Writes everything, or fails.
    ///
    virtual EStatus Write( void * pFile, const ETL_UINT8 * pData, ETL_UINT64 uSize ) ETL_NOEXCEPT = 0;

    /// @brief  Takes what was written to the disk ('fsync' or 'FlushFileBuffers').
    ///
    virtual EStatus Sync( void * pFile ) ETL_NOEXCEPT = 0;

    /// @brief  Closes the file. A null file is ignored.
    ///
    virtual void Close( void * pFile ) ETL_NOEXCEPT = 0;

    /// @brief  The size. @ref EStatus::eNotFound when the file does not exist.
    ///
    virtual EStatus Size( const ETL_CHAR * pPath, ETL_UINT64 * pSize ) ETL_NOEXCEPT = 0;

    /// @brief  Renames atomically, replacing the destination when it exists.
    ///
    virtual EStatus Rename( const ETL_CHAR * pFrom, const ETL_CHAR * pTo ) ETL_NOEXCEPT = 0;

    /// @brief  Deletes a file. A missing file is not an error.
    ///
    virtual EStatus Remove( const ETL_CHAR * pPath ) ETL_NOEXCEPT = 0;

    /// @brief  Creates the folder and its parents. An existing folder is not an error.
    ///
    virtual EStatus MakeDirs( const ETL_CHAR * pPath ) ETL_NOEXCEPT = 0;

    /// @brief  Deletes an EMPTY folder. A missing folder is not an error.
    ///
    virtual EStatus RemoveDir( const ETL_CHAR * pPath ) ETL_NOEXCEPT = 0;

    /// @brief  Takes the folder entries to the disk (a 'rename' inside it). On
    ///          Windows 'MoveFileExW' with 'MOVEFILE_WRITE_THROUGH' already does
    ///          it, so this returns 'eOk'.
    ///
    virtual EStatus SyncDir( const ETL_CHAR * pPath ) ETL_NOEXCEPT = 0;

    /// @brief  Sets the POSIX permissions (the 'uMode' of the signed list). On
    ///          Windows, 'eOk' with no effect. This is what keeps a new binary
    ///          executable on Linux.
    ///
    virtual EStatus SetMode( const ETL_CHAR * pPath, ETL_UINT32 uMode ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~IFileSystem() = default;
};

The file system. Every operation the download and the apply layers do.

An open file is an opaque pointer of the implementation. 'Rename' replaces the destination atomically (it is the POSIX 'rename' and the Windows 'MoveFileExW(MOVEFILE_REPLACE_EXISTING)'). The apply layer depends on it to never leave a half written file in the right place.

function

OsFileSystem

Ethereal::Updater#
IFileSystem & OsFileSystem() noexcept;

The OS file system. A single instance, with no state.

manifest.hpp

#include <ethereal/cpp/updater/manifest.hpp>

The update manifest: versioned, canonical, signed.

A product surface that will outlive many releases. Two rules that are not negotiable (the same as in Licensing):

1. Canonical encoding. Fixed field order, fixed width little endian integers, fixed size strings. The customer CI generates manifests, and two encoders that differ in one byte are a signature failure waiting to happen.

2. Verify the signature FIRST, parse the payload AFTER. 'DecodeAndVerify' is the only door, and no payload byte is touched before the signature matches.

Fixed limits, no heap. The client verification path does not allocate. The manifest is small (the spec asks for < 4 KB in the "nothing new" reply). A real manifest of a huge catalog would be streamed in parts, which is the download layer, not this one.

const

MANIFEST_MAX_STR

Ethereal::Updater#
constexpr ETL_UINT32 MANIFEST_MAX_STR = 64u;

Length of a short string: product, channel, from version, OS.

const

MANIFEST_MAX_URL

Ethereal::Updater#
constexpr ETL_UINT32 MANIFEST_MAX_URL = 160u;

Length of a URL.

const

MANIFEST_MAX_RELEASES

Ethereal::Updater#
constexpr ETL_UINT32 MANIFEST_MAX_RELEASES = 4u;

Releases per manifest.

const

MANIFEST_MAX_ARTIFACTS

Ethereal::Updater#
constexpr ETL_UINT32 MANIFEST_MAX_ARTIFACTS = 4u;

Artifacts per release.

const

MANIFEST_MAX_URLS

Ethereal::Updater#
constexpr ETL_UINT32 MANIFEST_MAX_URLS = 3u;

URLs per artifact: primary plus mirrors.

const

MANIFEST_MAX_FILES

Ethereal::Updater#
constexpr ETL_UINT32 MANIFEST_MAX_FILES = 16u;

Files per artifact, in the EMBEDDED list.

const

MANIFEST_SCHEMA_VERSION

Ethereal::Updater#
constexpr ETL_UINT32 MANIFEST_SCHEMA_VERSION = 2u;

The newest schema this code reads and writes.

1: the file list is embedded in the artifact (up to 16, paths up to 63 bytes). 2: an artifact may instead sign the hash and the count of a list that travels in the package ('filelist.hpp'), without those limits. A manifest with a newer schema is rejected with EStatus::eSchemaTooNew.

struct

SUrl

Ethereal::Updater#
C++
struct   SUrl   final
{
    /// @brief  The URL text, null terminated.
    ETL_CHAR    aText[ MANIFEST_MAX_URL ] = {};
};

A URL, fixed size.

struct

SFileEntry

Ethereal::Updater#
C++
struct   SFileEntry   final
{
    /// @brief  Relative path.
    ETL_CHAR    aPath[ MANIFEST_MAX_STR ] = {};

    /// @brief  SHA-256 of the contents.
    ETL_UINT8    aHash[ UPDATER_HASH_SIZE ] = {};

    /// @brief  POSIX permissions. Ignored on Windows.
    ETL_UINT32    uMode = 0u;
};

A file inside the package: path, hash and mode.

struct

SArtifact

Ethereal::Updater#
C++
struct   SArtifact   final
{
    /// @brief  Target platform.
    EPlatform        ePlatform = EPlatform::eUnknown;

    /// @brief  Target architecture.
    EArch            eArch = EArch::eUnknown;

    /// @brief  Full file, delta or package.
    EArtifactKind    eKind = EArtifactKind::eFull;

    /// @brief  Compression of the download.
    ECompression    eCompression = ECompression::eNone;

    /// @brief  For deltas: the version it starts from.
    SVersion        FromVersion;

    /// @brief  Exact size, SIGNED. The download aborts when it is exceeded.
    ETL_UINT64        uSize = 0u;

    /// @brief  Hash of the download, SIGNED.
    ETL_UINT8        aHash[ UPDATER_HASH_SIZE ] = {};

    /// @brief  Number of URLs.
    ETL_UINT32        uUrlCount = 0u;

    /// @brief  Primary plus mirrors, tried in order.
    SUrl            aUrls[ MANIFEST_MAX_URLS ];

    /// @brief  Number of files in the embedded list.
    ETL_UINT32        uFileCount = 0u;

    /// @brief  Path, hash and mode of each package file (the embedded list).
    SFileEntry        aFiles[ MANIFEST_MAX_FILES ];

    /// @brief  (schema 2) Instead of the embedded list: how many files the list
    ///             that travels in the package carries. An artifact has one or the
    ///             other, never both.
    ETL_UINT32        uListCount = 0u;

    /// @brief  (schema 2) Hash of the list that travels in the package.
    ETL_UINT8        aListHash[ UPDATER_HASH_SIZE ] = {};
};

An artifact: a binary or a package for one platform and architecture.

struct

SRelease

Ethereal::Updater#
C++
struct   SRelease   final
{
    /// @brief  Release version.
    SVersion    Version;

    /// @brief  Build date, checked against the update window of the license.
    ETL_INT64    iReleaseEpoch = 0;

    /// @brief  Refuses to jump from older than this, forcing an intermediate step.
    SVersion    MinimumFromVersion;

    /// @brief  How urgent the release is.
    EUrgency    eUrgency = EUrgency::eOptional;

    /// @brief  Padding.
    ETL_UINT8    uPadding[ 3 ] = {};

    /// @brief  The staged rollout bucket, 0..100.
    ETL_UINT32    uRolloutPercent = 100u;

    /// @brief  Non zero when the release needs a restart.
    ETL_UINT8    bRequiresRestart = 0u;

    /// @brief  Non zero when the release needs elevation.
    ETL_UINT8    bRequiresElevation = 0u;

    /// @brief  Padding.
    ETL_UINT8    uPadding2[ 6 ] = {};

    /// @brief  Address of the release notes.
    ETL_CHAR    aReleaseNotesUrl[ MANIFEST_MAX_URL ] = {};

    /// @brief  Number of artifacts.
    ETL_UINT32    uArtifactCount = 0u;

    /// @brief  The artifacts, one per platform and architecture.
    SArtifact    aArtifacts[ MANIFEST_MAX_ARTIFACTS ];
};

An available release.

struct

SManifest

Ethereal::Updater#
C++
struct   SManifest   final
{
    /// @brief  'sizeof( SManifest )'.
    ETL_UINT32    iStructSize = sizeof( SManifest );

    /// @brief  Schema of the payload.
    ETL_UINT32    uSchemaVersion = 0u;

    /// @brief  Product id.
    ETL_CHAR    aProductId[ MANIFEST_MAX_STR ] = {};

    /// @brief  Channel.
    ETL_CHAR    aChannel[ MANIFEST_MAX_STR ] = {};

    /// @brief  Issue date, for freshness and anti-freeze.
    ETL_INT64    iIssuedAtUnix = 0;

    /// @brief  Expiry date. Zero means no expiry.
    ETL_INT64    iExpiresAtUnix = 0;

    /// @brief  Number of releases.
    ETL_UINT32    uReleaseCount = 0u;

    /// @brief  Which key signed, for key rotation.
    ETL_UINT32    uKeyId = 0u;

    /// @brief  The releases.
    SRelease    aReleases[ MANIFEST_MAX_RELEASES ];
};

A parsed manifest.

function

CanonicalPayloadSize

Ethereal::Updater#
ETL_UINT64 CanonicalPayloadSize( const SManifest & Man ) noexcept;

Size of the canonical encoding of the payload of Man.

Variable length: it depends on how many releases, artifacts, mirrors and files the manifest carries. Lets the caller size the buffer before EncodePayload.

Man
The manifest.
The size in bytes.
function

EncodePayload

Ethereal::Updater#
EStatus EncodePayload( const SManifest & Man, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Writes the canonical payload. Writes no envelope and no signature.

Deterministic: the same manifest gives the same bytes on any platform and compiler. That is what makes the signature match on the other side, and what makes the packaging reproducible and auditable.

Man
The manifest.
pOut
Output buffer.
uCap
Size of pOut.
pWritten
Receives the number of bytes written.
eOk, eInvalidArgument or eBufferTooSmall.
function

DecodePayload

Ethereal::Updater#
EStatus DecodePayload( std::span< const ETL_UINT8 > In, SManifest * pOut ) noexcept;

Reads a canonical payload. Does NOT verify the signature. Only call after it matched.

In
The payload.
pOut
Receives the manifest.
eOk, eMalformed, eSchemaTooNew or eInvalidArgument.
function

WriteManifestFile

Ethereal::Updater#
EStatus WriteManifestFile( const SManifest & Man, const ETL_UINT8 * pSignature, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Serializes envelope, signature and payload into a binary file.

Man
The manifest.
pSignature
The 64 bytes of the signature over the canonical payload.
pOut
Output buffer.
uCap
Size of pOut.
pWritten
Receives the number of bytes written.
eOk, eInvalidArgument or eBufferTooSmall.
function

DecodeAndVerify

Ethereal::Updater#
EStatus DecodeAndVerify( std::span< const ETL_UINT8 > In, ISignatureVerifier * pVerifier, const ETL_UINT8 * pKeys, const ETL_UINT32 * pKeyIds, ETL_UINT32 uKeyCount, SManifest * pOut ) noexcept;

The right order, in a single function: verifies the signature, then parses.

Reads the envelope, picks the key by uKeyId, verifies the signature over the canonical payload, and only then parses. No payload byte is touched before the signature matches. This is structural: there is no other door.

In
The manifest file.
pVerifier
The signature verifier.
pKeys
The public keys, 32 bytes each.
pKeyIds
The id of each key.
uKeyCount
Number of keys.
pOut
Receives the manifest.
eOk, eMalformed, eSchemaTooNew, eUnknownKeyId, eBadSignature or eInvalidArgument.

package.hpp

#include <ethereal/cpp/updater/package.hpp>

The package of an artifact: the files the apply layer puts in place.

"ETLUPKG1" u32 entries u32 reserved (0) per entry: u16 path length, the path (relative, '/' as separator) u8 kind (0 = full file, 1 = patch over the installed file, 2 = the signed file list, only as the FIRST entry: see filelist.hpp), u8 0 u32 POSIX mode u64 data size (patch only) 32 bytes: the SHA-256 of the SOURCE file the data

All little endian. The whole artifact may come compressed (ECompression). The package is what comes out of the decompression.

The package is not trusted by itself. What files exist, with which hash and which mode, is said by the SIGNED list of the manifest. The package must carry exactly those paths, each one once, and each file that comes out of it must have the signed hash, or the apply layer does not touch the install. The path goes through 'IsSafeRelativePath' before anything else (zip-slip).

enum

EPackageEntryKind

Ethereal::Updater#
C++
enum class   EPackageEntryKind : ETL_UINT8
{
    /// @brief  The full file.
    eFile = 0,

    /// @brief  A patch (see 'delta.hpp') that, applied to the installed file
    ///             whose SHA-256 is the source one, gives the new file.
    ePatch = 1,

    /// @brief  The signed file list ('filelist.hpp'), at the reserved path
    ///             @ref FILE_LIST_ENTRY_PATH. Only valid as the first entry, and only
    ///             when the manifest signed its hash.
    eFileList = 2
};

What a package entry carries.

struct

SPackageFile

Ethereal::Updater#
C++
struct   SPackageFile   final
{
    /// @brief  Relative path.
    const ETL_CHAR *                pPath = nullptr;

    /// @brief  The entry data.
    std::span< const ETL_UINT8 >    Data;

    /// @brief  POSIX mode.
    ETL_UINT32                        uMode = 0644u;

    /// @brief  What the entry carries.
    EPackageEntryKind                eKind = EPackageEntryKind::eFile;

    /// @brief  32 bytes, patch only: hash of the source file.
    const ETL_UINT8 *                pSourceHash = nullptr;
};

An entry to put in the package (the publisher and the tests).

struct

SPackageEntryInfo

Ethereal::Updater#
C++
struct   SPackageEntryInfo   final
{
    /// @brief  Relative path, null terminated.
    ETL_CHAR            aPath[ FILE_LIST_MAX_PATH ] = {};

    /// @brief  What the entry carries.
    EPackageEntryKind    eKind = EPackageEntryKind::eFile;

    /// @brief  POSIX mode.
    ETL_UINT32            uMode = 0u;

    /// @brief  Data size.
    ETL_UINT64            uSize = 0u;

    /// @brief  Where the data starts (in the package in memory).
    ETL_UINT64            uOffset = 0u;

    /// @brief  Hash of the source file, patch only.
    ETL_UINT8            aSourceHash[ UPDATER_HASH_SIZE ] = {};
};

An entry read from the package.

const

PACKAGE_HEADER_SIZE

Ethereal::Updater#
constexpr ETL_UINT32 PACKAGE_HEADER_SIZE = 16u;

The 16 bytes of the package header.

const

PACKAGE_MAX_ENTRY_HEADER

Ethereal::Updater#
constexpr ETL_UINT32 PACKAGE_MAX_ENTRY_HEADER = 2u + FILE_LIST_MAX_PATH + 2u + 4u + 8u + UPDATER_HASH_SIZE;

The largest possible entry header.

const

PACKAGE_MAX_ENTRIES

Ethereal::Updater#
constexpr ETL_UINT32 PACKAGE_MAX_ENTRIES = FILE_LIST_MAX_FILES + 1u;

How many entries a package can have: the files and the list.

function

BuildPackage

Ethereal::Updater#
EStatus BuildPackage( std::span< const SPackageFile > Files, std::vector< ETL_UINT8 > * pOut ) noexcept;

Builds a package.

A path that is unsafe, repeated, or longer than FILE_LIST_MAX_PATH is rejected. An 'eFileList' entry is only accepted as the first one, at the reserved path.

Files
The entries.
pOut
Receives the package.
eOk, ePathEscape, eInvalidArgument or eBufferTooSmall.
function

ReadPackageIndex

Ethereal::Updater#
EStatus ReadPackageIndex( std::span< const ETL_UINT8 > Bytes, SPackageEntryInfo * pEntries, ETL_UINT32 uCap, ETL_UINT32 * pCount ) noexcept;

Reads the index of a package in memory, checking every path and size.

Only the shape. Nothing is checked against the manifest: that is the job of the apply layer, which has the signed list. Serves the publisher, the tools and the fuzzer.

Bytes
The package.
pEntries
Receives the entries. May be null when uCap is zero.
uCap
Size of pEntries.
pCount
Receives the number of entries.
eOk, eMalformed, ePathEscape, or eBufferTooSmall when uCap is too small.
class

CPackageStreamReader

Ethereal::Updater#

Reads the package as the bytes arrive, without holding it whole in memory.

class CPackageStreamReader final

Bytes are given with 'Feed'. It returns the entry headers and, between them, how many data bytes belong to the current entry. A small state machine, with a buffer the size of the largest header.

enum

EEvent

#
C++
enum class   EEvent : ETL_UINT8
{
    /// @brief  Consumed everything it was given. Send more.
    eNeedMore = 0,

    /// @brief  A complete header: see 'Entry()'.
    eEntry,

    /// @brief  'DataSize()' bytes from 'Data()' belong to the current entry.
    eData,

    /// @brief  No more entries (anything extra is an error).
    eEnd,

    /// @brief  Malformed. See 'Error()'.
    eError
};

What the reader has to say after a 'Feed'.

constructor

CPackageStreamReader

#
CPackageStreamReader() noexcept;

Default constructor.

function

Reset

#
void Reset() noexcept;

Starts over, for a new package.

function

Feed

#
EEvent Feed( std::span< const ETL_UINT8 > In ) noexcept;

Gives more bytes and returns the next event.

The bytes not consumed stay inside the reader for the next 'Feed' with an empty span. Use it like this: call 'Feed( piece )'. While it does not return 'eNeedMore', handle the event and call 'Feed( {} )' to continue in the same piece.

In
The new bytes, or an empty span to continue.
The next event.
function

Entry

#
const SPackageEntryInfo & Entry() const noexcept

The current entry, after 'eEntry'.

function

Data

#
const ETL_UINT8 * Data() const noexcept

The data bytes, after 'eData'.

function

DataSize

#
ETL_UINT64 DataSize() const noexcept

How many data bytes, after 'eData'.

function

EntryCount

#
ETL_UINT32 EntryCount() const noexcept

Number of entries declared by the package header.

function

Error

#
EStatus Error() const noexcept

The error, after 'eError'.

safety.hpp

#include <ethereal/cpp/updater/safety.hpp>

The mitigations spec 18 names one by one (section 2.3).

In a form that can be checked without a network or a live file system: pure functions, testable with a corpus. They are the security backbone of the module, and the rest is built on top of them.

  • Safe path (anti-zip-slip): the most commonly broken check in extraction.
  • Staged rollout bucket, stable between runs.
  • The version floor (anti-downgrade).
  • Manifest freshness (anti-freeze).
function

IsSafeRelativePath

Ethereal::Updater#
bool IsSafeRelativePath( const ETL_CHAR * pPath ) noexcept;

Whether a package path is safe to extract inside the staging root.

Rejects, by name: absolute path, any '..' segment, Windows drive root ('C:'), UNC ('\\server'), NTFS alternate data stream (the ':' in the middle), and the reserved Windows device names (CON, PRN, AUX, NUL, COM1..9, LPT1..9), with or without extension.

Backslash and slash both count as separator, because a package made on Windows carries '\\' and a Linux client has to reject it all the same. It does not normalize to "fix" anything: a suspect path is rejected, not repaired. Repairing would mean guessing the intent of an attacker.

pPath
The relative path as it comes in the package.
true only when the path surely stays inside the root.
function

RolloutBucket

Ethereal::Updater#
ETL_UINT32 RolloutBucket( const ETL_CHAR * pInstallId ) noexcept;

The bucket 0..99 of an install, for the staged rollout.

Stable between runs: it hashes the stable install id instead of drawing a number. A client cannot go in and out of the rollout on every check. The distribution is uniform over different ids, so "10%" really means one in ten.

pInstallId
The stable id (the same on every start of this install).
A number in [0, 99].
function

InRollout

Ethereal::Updater#
bool InRollout( const ETL_CHAR * pInstallId, ETL_UINT32 uRolloutPercent ) noexcept;

Whether this install is in a rollout of uRolloutPercent percent.

A bucket below the percent is in. One hundred percent is always in. Zero, never.

pInstallId
The stable id of the install.
uRolloutPercent
The rollout percent.
true when the install is in.
function

PassesVersionFloor

Ethereal::Updater#
bool PassesVersionFloor( const SVersion & Offered, const SVersion & Floor ) noexcept;

Whether the offered version is acceptable given the floor already seen.

The client never accepts a version below the highest one it has seen. An attacker who replays an old, validly signed manifest with a vulnerable version stops here. Only an explicit and deliberately uncomfortable operator command lowers the floor, and that is not this function.

Offered
The offered version.
Floor
The floor.
true when Offered >= Floor.
enum

EFreshness

Ethereal::Updater#
C++
enum class   EFreshness : ETL_UINT8
{
    /// @brief  Fresh.
    eFresh = 0,

    /// @brief  Past 'iExpiresAtUnix'.
    eExpired,

    /// @brief  Older (lower 'iIssuedAtUnix') than the last one seen.
    eStale
};

Why a manifest was rejected for freshness, if it was.

function

JudgeFreshness

Ethereal::Updater#
EFreshness JudgeFreshness( ETL_INT64 iIssuedAtUnix, ETL_INT64 iExpiresAtUnix, ETL_INT64 iLastSeenIssued, ETL_INT64 iNowUnix ) noexcept;

Judges the freshness of a manifest.

An attacker who serves an old manifest forever keeps the client from learning about a security fix. Two defenses: the manifest expires ('iExpiresAtUnix'), and one older than the last seen is rejected.

iIssuedAtUnix
When the manifest was issued (from the signed manifest itself).
iExpiresAtUnix
When it expires. Zero means "no expiry".
iLastSeenIssued
The 'iIssuedAtUnix' of the last accepted manifest. Zero for the first.
iNowUnix
Now.
eFresh, eExpired or eStale.

updater.hpp

#include <ethereal/cpp/updater/updater.hpp>

The update client: a state machine driven by 'Tick'.

The integrator owns the thread, the cadence and the lifetime. That is what makes the module usable in a game loop, a service loop, a GUI loop and a CLI alike.

The check path is complete: fetch the manifest, verify the signature first, parse, judge freshness, version floor, entitlement and rollout bucket, and pick the artifact of this platform. The first build of the module stopped there, with the download and apply calls returning 'eNotImplemented' so the state machine would not lie about what it does. The download and apply layers (atomic staging, journal, self replacement, deltas) were added on 2026-09-28. See the README.

struct

SUpdaterParams

Ethereal::Updater#
C++
struct   SUpdaterParams   final
{
    /// @brief  'sizeof( SUpdaterParams )'.
    ETL_UINT32        iStructSize = sizeof( SUpdaterParams );

    /// @brief  Number of public keys.
    ETL_UINT32        uKeyCount = 0u;

    /// @brief  Product this client follows. Compared with the manifest.
    ETL_CHAR        aProductId[ MANIFEST_MAX_STR ] = {};

    /// @brief  Channel this client follows. Compared with the manifest.
    ETL_CHAR        aChannel[ MANIFEST_MAX_STR ] = {};

    /// @brief  The version running now.
    SVersion        Current;

    /// @brief  The version floor already seen or installed (anti-downgrade).
    ///             Persisted by the integrator, comes in through here.
    SVersion        Floor;

    /// @brief  The 'iIssuedAtUnix' of the last accepted manifest (anti-freeze).
    ///             Zero for the first one. Persisted by the integrator.
    ETL_INT64        iLastSeenIssued = 0;

    /// @brief  The stable id of the install, for the staged rollout bucket.
    ETL_CHAR        aInstallId[ MANIFEST_MAX_STR ] = {};

    /// @brief  The manifest URL.
    ETL_CHAR        aManifestUrl[ MANIFEST_MAX_URL ] = {};

    /// @brief  The public keys, in order: uKeyCount * 32 bytes.
    const ETL_UINT8 *    pPublicKeys = nullptr;

    /// @brief  The id of each public key.
    const ETL_UINT32 *    pKeyIds = nullptr;

    /// @brief  The signature verifier. Required.
    ISignatureVerifier *    pVerifier = nullptr;

    /// @brief  The clock. Required.
    IClock *                pClock = nullptr;

    /// @brief  The manifest transport. Required.
    ITransport *            pTransport = nullptr;

    /// @brief  The entitlement. Optional.
    IEntitlement *            pEntitlement = nullptr;

    /// Download and apply (added on 2026-09-28). Only needed to download, the check only mode does not use them.

    /// @brief  The artifact transport (by ranges, without blocking the Tick).
    IDownloadTransport *    pDownload = nullptr;

    /// @brief  The incremental SHA-256. The Crypto glue provides one
    ///             ('Glue::CSha256UpdateHasher').
    IHasher *                pHasher = nullptr;

    /// @brief  The file system. Null: the OS one.
    IFileSystem *            pFileSystem = nullptr;

    /// @brief  Where the artifact is downloaded and staged (UTF-8).
    ETL_CHAR                aStagingDir[ UPDATER_MAX_PATH ] = {};

    /// @brief  Bandwidth limit, in bytes per second. Zero: no limit.
    ETL_UINT64                uMaxBytesPerSecond = 0u;

    /// @brief  Maximum work of one Tick, in bytes (the Tick never does more).
    ETL_UINT32                uBytesPerTick = 1u << 20;

    /// @brief  How many times each URL is tried before moving to the next mirror.
    ETL_UINT32                uRetriesPerUrl = 2u;

    /// @brief  The folder being updated (UTF-8). Must be on the same volume as the staging area.
    ETL_CHAR                aInstallDir[ UPDATER_MAX_PATH ] = {};

    /// @brief  How many starts without 'ConfirmHealthy' before rolling back (see 'apply.hpp').
    ETL_UINT32                uMaxUnconfirmedLaunches = 3u;
};

How to set up the client.

struct

SUpdateInfo

Ethereal::Updater#
C++
struct   SUpdateInfo   final
{
    /// @brief  'sizeof( SUpdateInfo )'.
    ETL_UINT32        iStructSize = sizeof( SUpdateInfo );

    /// @brief  Release version.
    SVersion        Version;

    /// @brief  Build date of the release.
    ETL_INT64        iReleaseEpoch = 0;

    /// @brief  How urgent the release is.
    EUrgency        eUrgency = EUrgency::eOptional;

    /// @brief  Non zero when the release needs a restart.
    ETL_UINT8        bRequiresRestart = 0u;

    /// @brief  Non zero when the release needs elevation.
    ETL_UINT8        bRequiresElevation = 0u;

    /// @brief  Padding.
    ETL_UINT8        uPadding[ 5 ] = {};

    /// @brief  Kind of the artifact chosen for this platform and architecture.
    EArtifactKind    eKind = EArtifactKind::eFull;

    /// @brief  Compression of the chosen artifact.
    ECompression    eCompression = ECompression::eNone;

    /// @brief  Signed size of the chosen artifact.
    ETL_UINT64        uSize = 0u;

    /// @brief  Signed hash of the chosen artifact.
    ETL_UINT8        aHash[ UPDATER_HASH_SIZE ] = {};

    /// @brief  First URL of the chosen artifact.
    ETL_CHAR        aPrimaryUrl[ MANIFEST_MAX_URL ] = {};

    /// @brief  Address of the release notes.
    ETL_CHAR        aReleaseNotesUrl[ MANIFEST_MAX_URL ] = {};
};

The newest release a check found.

class

CUpdater

Ethereal::Updater#

The update client.

class CUpdater final
constructor

CUpdater

#
CUpdater() noexcept;

Default constructor. Call Init before use.

function

Init

#
EStatus Init( const SUpdaterParams & Params ) noexcept;

Sets up the client.

A download in progress from a previous setup is closed. Its '.part' stays.

Params
Client parameters. The verifier, the clock, the transport and the keys are required.
eOk, eInvalidArgument, or eNotLicensed when the library is not licensed.
function

BeginCheck

#
EStatus BeginCheck() noexcept;

Arms a check. Starts no thread. Does not block.

function

Tick

#
EStatus Tick() noexcept;

Advances the work in progress. Called from the integrator loop.

function

State

#
EState State() const noexcept

Current state.

function

LastError

#
EStatus LastError() const noexcept

The last error status, when 'State()' is 'eFailed'.

function

GetAvailable

#
EStatus GetAvailable( SUpdateInfo * pOut ) const noexcept;

What the check found. EStatus::eNoUpdate when there is nothing newer.

function

AcceptedIssuedAt

#
ETL_INT64 AcceptedIssuedAt() const noexcept

The 'iIssuedAtUnix' of the accepted manifest, for the integrator to persist (anti-freeze). Zero when none was accepted.

function

Manifest

#
const SManifest & Manifest() const noexcept

The parsed manifest, for whoever wants the raw fields.

function

BeginDownload

#
EStatus BeginDownload( const SUpdateInfo & Info ) noexcept;

Arms the download of the artifact the check chose. Does not block: the work is done in 'Tick', in slices of 'uBytesPerTick'.

Resume: a '<hash>.part' left from a previous run is hashed again (in pieces, also in 'Tick') and the request continues from there. A mirror that fails 'uRetriesPerUrl' times moves to the next one, at the same byte. Going past the SIGNED size aborts ('eSizeExceeded') and deletes what came. At the end, the hash is checked against the signed one. Only then does the file become '<hash>.artifact' and the state 'eReadyToApply'.

'Tick' returns 'ePending' while there is work, 'eOk' when done.

Info
What the check chose (the hash is the identity).
eOk, eInvalidArgument, eWrongState, eBufferTooSmall, eIoError, or eNotLicensed when the library is not licensed.
function

DownloadedBytes

#
ETL_UINT64 DownloadedBytes() const noexcept

How many bytes of the artifact are already on disk and hashed.

function

ArtifactPath

#
const ETL_CHAR * ArtifactPath() const noexcept

Path of the downloaded and checked artifact (only in 'eReadyToApply').

function

BeginApply

#
EStatus BeginApply( EApplyStrategy eStrategy ) noexcept;

Arms the apply of the downloaded artifact. Does not block: the staging is done in 'Tick', in slices of 'uBytesPerTick'.

The staging checks each file against the SIGNED list and only then touches the install (see 'apply.hpp'). At the end, depending on eStrategy:

  • 'eRenameReplace': swaps now (the running executable is renamed, which Windows allows, and the backup goes away on 'ConfirmHealthy').
  • 'eOnNextLaunch' and 'eExternalHelper': leaves it staged. The next start, or the helper ('etl-update apply-staged'), calls 'ApplyStaged'.
  • 'eCheckOnly': nothing ('eOk' right away).
  • 'eOnReboot': 'eNotImplemented' (needs administrator, see the README).

The state ends in 'ePendingRestart'.

eStrategy
The apply strategy.
eOk, eNotImplemented, eInvalidArgument, eWrongState or the staging error.
function

InstallParams

#
SInstallParams InstallParams() const noexcept;

The install parameters, for the start calls (Recover, NotifyLaunch, ConfirmHealthy, ApplyStaged).

function

Cancel

#
EStatus Cancel() noexcept;

Goes back to 'eIdle' from any state, safely.

updater_common.hpp

#include <ethereal/cpp/updater/updater_common.hpp>

Shared types of the Updater module: versions, states and the seams.

An updater is a remote code execution channel built on purpose. Every design decision comes from that. If the signature check is wrong, in the wrong order, or can be skipped, the customer has shipped a backdoor to every machine running the product.

Asymmetric, Ed25519, over a signed manifest, plus a hash per artifact inside that manifest. The module does not link Crypto. It declares 'ISignatureVerifier' and gets the implementation through a glue. A build without 'ETL_UPDATER' has none of this, byte for byte.

The module starts no thread and opens no socket by itself. There is no ambient background updater. The integrator calls 'Tick' or starts a check. Cost at rest: zero.

struct

SVersion

Ethereal::Updater#
C++
struct   SVersion   final
{
    /// @brief  Major component.
    ETL_UINT32    uMajor = 0u;

    /// @brief  Minor component.
    ETL_UINT32    uMinor = 0u;

    /// @brief  Patch component.
    ETL_UINT32    uPatch = 0u;

    /// @brief  Build component.
    ETL_UINT32    uBuild = 0u;

    /// @brief  -1 when this < Other, 0 when equal, +1 when this > Other.
    ///
    ETL_API_NOIGN    int Compare( const SVersion & Other ) const ETL_NOEXCEPT;

    /// @brief  Comparison operators, all through Compare.
    ///
    bool operator<( const SVersion & o )  const ETL_NOEXCEPT { return Compare( o ) <  0; }
    bool operator>( const SVersion & o )  const ETL_NOEXCEPT { return Compare( o ) >  0; }
    bool operator<=( const SVersion & o ) const ETL_NOEXCEPT { return Compare( o ) <= 0; }
    bool operator>=( const SVersion & o ) const ETL_NOEXCEPT { return Compare( o ) >= 0; }
    bool operator==( const SVersion & o ) const ETL_NOEXCEPT { return Compare( o ) == 0; }
    bool operator!=( const SVersion & o ) const ETL_NOEXCEPT { return Compare( o ) != 0; }
};

A 'major.minor.patch.build' version, with a total order.

Four numeric components, not a semver string with pre-release tags. The comparison has to be total and cheap: the version floor (anti-downgrade) compares it on every check, and an order that depends on parsing "-rc.1" would be an attack surface in the wrong place.

function

ParseVersion

Ethereal::Updater#
bool ParseVersion( const ETL_CHAR * pText, SVersion * pOut ) noexcept;

Reads "2.1.0" or "2.1.0.345". Missing components are zero.

pText
The text.
pOut
Receives the version.
false when there is a character that is not a digit or a dot, or a number that is too large.
function

FormatVersion

Ethereal::Updater#
bool FormatVersion( const SVersion & Version, ETL_CHAR * pOut, ETL_UINT64 uCap ) noexcept;

Writes "major.minor.patch.build" (without the build when it is zero) to pOut.

Version
The version.
pOut
Output buffer.
uCap
Size of pOut. 24 bytes are always enough.
false when uCap is too small.
enum

EStatus

Ethereal::Updater#
C++
enum class   EStatus : ETL_UINT32
{
    /// @brief  Success.
    eOk = 0,

    /// @brief  A parameter is invalid.
    eInvalidArgument,

    /// @brief  The output buffer is too small.
    eBufferTooSmall,

    /// @brief  The manifest signature does not match. Nothing more is said.
    eBadSignature,

    /// @brief  The signing key is not one of the client keys.
    eUnknownKeyId,

    /// @brief  The bytes are not a manifest of this shape.
    eMalformed,

    /// @brief  Format newer than this client reads.
    eSchemaTooNew,

    /// @brief  The manifest is past its validity (anti-freeze).
    eExpired,

    /// @brief  The manifest is older than the last one seen (anti-freeze).
    eStale,

    /// @brief  The offered version is below the floor already seen (anti-downgrade).
    eDowngrade,

    /// @brief  Nothing newer than the current version.
    eNoUpdate,

    /// @brief  There is a newer version, but outside the paid update window.
    eNotEntitled,

    /// @brief  The manifest belongs to another product or channel.
    eWrongProduct,

    /// @brief  No artifact serves this platform and architecture.
    eUnsupportedPlatform,

    /// @brief  The size declared in the manifest was exceeded (anti-endless-data).
    eSizeExceeded,

    /// @brief  A package path leaves the staging root (anti-zip-slip).
    ePathEscape,

    /// @brief  The transport seam failed.
    eTransportError,

    /// @brief  Call out of order for the current state.
    eWrongState,

    /// @brief  The operation is still running. Call 'Tick'.
    ePending,

    /// @brief  The step is not implemented in this build of the module.
    eNotImplemented,

    /// @brief  The module was not compiled (no 'ETL_UPDATER').
    eNotCompiled,

    /// Download and apply layer (2026-09-28).

    /// @brief  The file or folder does not exist.
    eNotFound,

    /// @brief  The file system refused (write, sync, rename...).
    eIoError,

    /// @brief  The hash of what was downloaded (or of a package file) does not
    ///             match the signed one. What failed is deleted. Nothing is applied.
    eHashMismatch,

    /// @brief  The transport cannot resume midway (no range requests). The
    ///             download restarts from the beginning.
    eRangeUnsupported,

    /// @brief  The installed file is not the source the delta expects (the user
    ///             changed it, or the install is another version). CUpdater falls
    ///             back to the full artifact of the same release, if there is one:
    ///             the state goes back to 'eUpdateAvailable' and the next
    ///             'BeginDownload' downloads it.
    eDeltaSourceMismatch,

    /// @brief  Refused: no license of the Ethereal library was accepted and the
    ///             evaluation of this machine has ended, or the license passed was
    ///             refused (see Bundle::UnlockBundle). Distinct from eNotEntitled,
    ///             which is about the update window of the product being updated.
    eNotLicensed
};

Result of a call.

enum

EState

Ethereal::Updater#
C++
enum class   EState : ETL_UINT8
{
    /// @brief  Nothing running.
    eIdle = 0,

    /// @brief  Checking the manifest.
    eChecking,

    /// @brief  A newer release was found.
    eUpdateAvailable,

    /// @brief  Downloading the artifact.
    eDownloading,

    /// @brief  Checking the downloaded artifact.
    eVerifying,

    /// @brief  Staged and ready to apply.
    eReadyToApply,

    /// @brief  Applying.
    eApplying,

    /// @brief  Applied, waiting for a restart.
    ePendingRestart,

    /// @brief  The last operation failed.
    eFailed,

    /// @brief  The update was rolled back.
    eRolledBack
};

Where the state machine is.

enum

EUrgency

Ethereal::Updater#
C++
enum class   EUrgency : ETL_UINT8
{
    /// @brief  Optional, recommended, security fix and mandatory.
    eOptional = 0, eRecommended, eSecurity, eMandatory
};

How urgent a release is. Always advisory: the module never forces.

enum

EPlatform

Ethereal::Updater#
C++
enum class   EPlatform : ETL_UINT8
{
    /// @brief  Unknown, Windows, macOS and Linux.
    eUnknown = 0, eWindows, eMacOS, eLinux
};

Target platform of an artifact.

enum

EArch

Ethereal::Updater#
C++
enum class   EArch : ETL_UINT8
{
    /// @brief  Unknown, x64, ARM64, x86 and ARM32.
    eUnknown = 0, eX64, eArm64, eX86, eArm32
};

Target architecture of an artifact.

enum

EArtifactKind

Ethereal::Updater#
C++
enum class   EArtifactKind : ETL_UINT8
{
    /// @brief  Full file, binary delta and multi file package.
    eFull = 0, eDelta, ePackage
};

What an artifact is.

enum

ECompression

Ethereal::Updater#
C++
enum class   ECompression : ETL_UINT8
{
    /// @brief  None, zstd, deflate, gzip and LZMA.
    eNone = 0, eZstd, eDeflate, eGzip, eLzma
};

Compression of an artifact.

enum

EApplyStrategy

Ethereal::Updater#
C++
enum class   EApplyStrategy : ETL_UINT8
{
    /// @brief  Renames the running binary to '.old' and writes the new one over it.
    eRenameReplace = 0,

    /// @brief  A small helper binary applies with the app closed.
    eExternalHelper,

    /// @brief  Stages now, applies on the next launch before loading anything.
    eOnNextLaunch,

    /// @brief  'MoveFileEx' delayed until reboot, on Windows.
    eOnReboot,

    /// @brief  Only reports that there is an update. The integrator delivers it. First class.
    eCheckOnly
};

Apply strategy. See spec 18 section 5.

struct

ISignatureVerifier

Ethereal::Updater#
C++
struct   ISignatureVerifier
{
    ///
    /// Verify
    ///
    /// @brief  Checks a signature.
    ///
    /// @param Message        The signed bytes.
    /// @param Signature    The signature.
    /// @param PublicKey    The public key.
    ///
    /// @return  true when the signature is valid.
    ///
    virtual bool Verify( std::span< const std::uint8_t > Message,
                         std::span< const std::uint8_t > Signature,
                         std::span< const std::uint8_t > PublicKey ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~ISignatureVerifier() = default;
};

Checks a signature. Same shape as in Licensing. The module does not link Crypto, the glue does.

struct

IClock

Ethereal::Updater#
C++
struct   IClock
{
    /// @brief  Now, in Unix seconds.
    ///
    virtual ETL_INT64 NowUnix() ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~IClock() = default;
};

The clock. Comes from outside so the test bench can control it, and because the clock belongs to the integrator.

struct

IEntitlement

Ethereal::Updater#
C++
struct   IEntitlement
{
    ///
    /// CoversVersion
    ///
    /// @brief  Whether the license covers a release.
    ///
    /// @param Version            The release version.
    /// @param iReleaseEpoch    The release date, in Unix seconds.
    ///
    /// @return  true when covered.
    ///
    virtual bool CoversVersion( const SVersion & Version,
                                ETL_INT64 iReleaseEpoch ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~IEntitlement() = default;
};

Whether a version is covered by the license. Linked by the Licensing glue.

Optional. When given, the updater filters out releases outside the update window and reports "there is a newer version, but your window ended on <date>" instead of showing nothing. That message is a renewal request and should read as one.

struct

ITransport

Ethereal::Updater#
C++
struct   ITransport
{
    ///
    /// Fetch
    ///
    /// @brief  Fetches the resource pUrl into pOut, up to uCap bytes.
    ///
    /// @details  For the check layer. The resumable download of large
    ///            artifacts is another surface (streaming). This one serves
    ///            the manifest, which is small.
    ///
    /// @param pUrl            Resource address.
    /// @param pOut            Output buffer.
    /// @param uCap            Size of pOut.
    /// @param pWritten        Receives the number of bytes.
    ///
    /// @return  false on any network failure or when uCap was not enough.
    ///
    virtual bool Fetch( const ETL_CHAR * pUrl, ETL_UINT8 * pOut, ETL_UINT64 uCap,
                        ETL_UINT64 * pWritten ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~ITransport() = default;
};

Where the bytes come from. The module opens no socket. The integrator provides the transport.

struct

IDownloadTransport

Ethereal::Updater#
C++
struct   IDownloadTransport
{
    ///
    /// Open
    ///
    /// @brief  Opens pUrl from byte uOffset.
    ///
    /// @param pUrl        Resource address.
    /// @param uOffset    First byte wanted.
    ///
    /// @return  @ref EStatus::eOk: the next bytes start at uOffset.
    ///              @ref EStatus::eRangeUnsupported: cannot resume midway (only with
    ///              uOffset > 0, the Updater restarts from zero).
    ///              @ref EStatus::eTransportError: failed (retried, then the next
    ///              mirror).
    ///
    virtual EStatus Open( const ETL_CHAR * pUrl, ETL_UINT64 uOffset ) ETL_NOEXCEPT = 0;

    ///
    /// Read
    ///
    /// @brief  Reads what has already arrived, up to uCap bytes.
    ///
    /// @param pOut        Output buffer.
    /// @param uCap        Size of pOut.
    /// @param pGot        Receives the number of bytes read.
    /// @param pEnd        Receives true when the server finished sending the body.
    ///
    /// @return  eOk, or the transport error.
    ///
    virtual EStatus Read( ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pGot,
                          bool * pEnd ) ETL_NOEXCEPT = 0;

    /// @brief  Closes the request.
    ///
    virtual void Close() ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~IDownloadTransport() = default;
};

The artifact transport: a request from a given byte, read in pieces.

Does not block the Tick. 'Read' returns what has already arrived (zero bytes and no end means "nothing yet, come back on the next Tick"), and the Updater never asks for more than the budget of one Tick. A gigabyte artifact goes through a fixed buffer. None of it stays in memory.

A GET with 'Range: bytes=<uOffset>-' is the natural implementation in HTTP.

struct

IHasher

Ethereal::Updater#
C++
struct   IHasher
{
    /// @brief  Starts a new hash.
    ///
    virtual void Init() ETL_NOEXCEPT = 0;

    /// @brief  Adds bytes to the hash.
    ///
    virtual void Update( std::span< const std::uint8_t > Data ) ETL_NOEXCEPT = 0;

    /// @brief  Writes 32 bytes to pOut32.
    ///
    virtual void Final( std::uint8_t * pOut32 ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~IHasher() = default;
};

A content hash (SHA-256). Used by the download layer.

const

UPDATER_MAGIC

Ethereal::Updater#
constexpr ETL_UINT32 UPDATER_MAGIC = 0x554C5445u;

The 'ETLU' of the envelope ('ETLU' in little endian).

const

UPDATER_FORMAT_VERSION

Ethereal::Updater#
constexpr ETL_UINT16 UPDATER_FORMAT_VERSION = 1u;

Envelope format version.

const

UPDATER_SIGNATURE_SIZE

Ethereal::Updater#
constexpr ETL_UINT32 UPDATER_SIGNATURE_SIZE = 64u;

Ed25519 signature size.

const

UPDATER_PUBLIC_KEY_SIZE

Ethereal::Updater#
constexpr ETL_UINT32 UPDATER_PUBLIC_KEY_SIZE = 32u;

Ed25519 public key size.

const

UPDATER_HASH_SIZE

Ethereal::Updater#
constexpr ETL_UINT32 UPDATER_HASH_SIZE = 32u;

Hash size (SHA-256).

const

UPDATER_MAX_KEYS

Ethereal::Updater#
constexpr ETL_UINT32 UPDATER_MAX_KEYS = 4u;

Maximum number of trusted keys.

function

StatusName

Ethereal::Updater#
const ETL_CHAR * StatusName( EStatus eStatus ) noexcept;

Name of a status, for logs.

function

StateName

Ethereal::Updater#
const ETL_CHAR * StateName( EState eState ) noexcept;

Name of a state, for logs.

function

UrgencyName

Ethereal::Updater#
const ETL_CHAR * UrgencyName( EUrgency eUrgency ) noexcept;

Name of an urgency, for logs.

function

ThisPlatform

Ethereal::Updater#
EPlatform ThisPlatform() noexcept;

Platform of this build, for the artifact choice.

function

ThisArch

Ethereal::Updater#
EArch ThisArch() noexcept;

Architecture of this build, for the artifact choice.