Skip to content

Commit 6a1709d

Browse files
committed
Merge FEATURE-ci-windows-entropy: Preserve CNG success without optional macro
2 parents a68ba47 + 6b5cfa4 commit 6a1709d

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# FEATURE-ci-windows-entropy: portable Windows CNG success status
2+
3+
Status: Complete (local implementation, Groundwork validation and finalization). Native
4+
Windows execution remains CI / v3 PR owned. Base: `v3` at
5+
`a68ba478e967988331c167af102189c905b6fe95`.
6+
7+
Windows CI run39948363870 job120396472238 checked out that same base and failed
8+
compiling actual `src/detail/entropy_sys.cpp` because `STATUS_SUCCESS` was
9+
undeclared. This native compiler failure is the accepted RED. A task-local
10+
probe compiling the actual Windows source with only the documented CNG API
11+
boundary doubled reproduced the same error before the change.
12+
13+
The Windows draw now compares against `NTSTATUS{0}`, documented by Microsoft's
14+
[NTSTATUS values](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55)
15+
as STATUS_SUCCESS. The [BCryptGenRandom contract](https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom)
16+
supplies NTSTATUS and identifies STATUS_SUCCESS as success. Exact-zero
17+
acceptance remains deliberate: Microsoft's generic
18+
[NT_SUCCESS predicate](https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values)
19+
would also accept additional positive and informational statuses.
20+
21+
Action items:
22+
23+
- [x] Create isolated worktree from v3 using Groundwork's identity helper;
24+
preserve bauth and other unrelated work.
25+
- [x] Retain source-bound native compiler RED and read official Microsoft docs.
26+
- [x] Replace only the unavailable macro with a typed documented equivalent;
27+
preserve exact-zero success, provider, buffer/count, RNG flag and fill policy.
28+
- [x] Apply doubt-driven checks for widened status acceptance, parameter or
29+
fallback changes, and empty/error/all-zero handling before commit.
30+
- [x] Run existing focused real OS entropy tests and a bounded actual-source
31+
API boundary probe; retain raw evidence without adding a public test seam.
32+
- [x] Run changed-file cpplint and diff checks.
33+
- [x] Retain commands, logs, docs and doubts at root
34+
`.debug/FEATURE-ci-windows-entropy/`.
35+
- [x] Caller: Groundwork validation and local finalization into v3; four reviewers approved with zero findings.
36+
- [ ] CI / v3 PR: genuine native Windows SDK compilation/execution.
37+
38+
Local verification: the unchanged Linux entropy executable passes 5 tests and
39+
21 checks against production `entropy_sys.cpp` (the conditional single-byte
40+
zero path accounts for baseline's 20 checks). Compilation uses Clang18,
41+
C++20 and `-Wall -Wextra -Werror` without warnings. The boundary probe passes
42+
zero plus eight nonzero status cases spanning positive, informational, warning
43+
and error ranges; it checks exact null algorithm, output pointer/count, flag2,
44+
one call per nonempty fill, bounds, no call for empty fill and unchanged error
45+
messages including all-zero rejection. This is API boundary evidence only,
46+
not genuine Windows SDK/ABI, cryptographic RNG or runtime proof. No Windows
47+
compiler/SDK is installed locally; that check stays pending in CI under
48+
AGENTS.md, without blocking local completion.
49+
50+
No new production headers, dependencies, test-only API, RNG primitive, fallback
51+
or generic testing framework were added. Scratch probe files are uncommitted.
52+
No broad baseline, unrelated Linux investigation, audit-policy repair,
53+
validation loop, merge or publication was performed.
54+
55+
Project notes: Autotools/C++20 normally uses `./bootstrap`, out-of-tree configure
56+
and make; this bounded task directly compiled the existing custom Littletest
57+
`test/unit/entropy_sys_test.cpp` with actual `src/detail/entropy_sys.cpp`,
58+
`-DHTTPSERVER_COMPILATION -Isrc -Itest`. The outcome header is self-contained;
59+
no extra production dependencies are needed for this executable. Changed-file
60+
cpplint uses root CPPLINT.cfg. Groundwork resolved branch/path verbatim; Git
61+
metadata mutation required the existing sandbox escalation.

‎src/detail/entropy_sys.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
namespace httpserver::detail::entropy {
55
#if defined(_WIN32)
66
bool draw_via_bcrypt(std::byte* out, std::size_t count) noexcept {
7-
return ::BCryptGenRandom(nullptr, reinterpret_cast<PUCHAR>(out), static_cast<ULONG>(count), BCRYPT_USE_SYSTEM_PREFERRED_RNG) == STATUS_SUCCESS;
7+
// MS-ERREF defines STATUS_SUCCESS as zero; avoid depending on ntstatus.h.
8+
return ::BCryptGenRandom(nullptr, reinterpret_cast<PUCHAR>(out), static_cast<ULONG>(count), BCRYPT_USE_SYSTEM_PREFERRED_RNG) == NTSTATUS{0};
89
}
910
#endif
1011

0 commit comments

Comments
 (0)