Skip to content

feat: openkal.random on getentropy - #6

Merged
Sunrisepeak merged 3 commits into
mainfrom
feat/openkal-random
Aug 24, 2026
Merged

feat: openkal.random on getentropy#6
Sunrisepeak merged 3 commits into
mainfrom
feat/openkal-random

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

kal_random_fill loops on getentropy in 256-byte chunks, which is the kernel's cap on that call.

Deliberately not arc4random_buf: that lives in libSystem, which this backend does not call into. The syscall number came from the probe in numbers.yml, which both runners answered SYS_getentropy 500.

Declares openkal 0.7.0.

规范新增 `openkal.random`(mcpplibs/openkal#8),版本升到 0.7.0。

⚠️ CI 有一道版本同步门,而它的诊断说明了为什么必须一起改:

    this is openkal 0.7.0 and this implementation is written against
    openkal 0.6.0. Nothing is wrong with either; they are not in step.

⭐ 本包**不提供** `openkal.random`,而那不是偏离 —— 6.1 条规定实现提供一个
接口是全有或全无,不提供的接口作为链接期定义缺席。这里跟随的只是规范版本,
不是接口集合。
⭐ **号来自机器,不来自记忆。** `.github/workflows/numbers.yml` 从 SDK 自己的
`sys/syscall.h` 读出本实现用到的每一个号,在本仓库针对的两个 runner 上都读,
而两者都答 `SYS_getentropy 500`。那个 workflow 存在的理由正是:
一个凭记忆写下的号,在它出错的那天之前一直是对的。

⚠️ **不用 `arc4random_buf`**,虽然 libc++ 在这个系统上默认会去找它。
那个名字在 libSystem 里,而伸手进 libSystem 正是本后端要避免的 ——
它直接发这个内核的调用,`sys.h` 的注释记着这一点。`getentropy` 是底下那一层。

⚠️ **这个内核单次上限 256 字节。** 那是这个系统的限制而不是本接口的,
所以循环把它变成 `kal_random_fill` 承诺的「全有或全无」。

失败时缓冲区不恢复 —— 契约如此:失败的填充留下未指定内容而非原内容。
The branch carried 0.3.3, which is the version on `main` and the version
already in the index. Following openkal 0.7.0 changes what this package
declares, and on two of these repositories it also adds an interface, so
the content behind that number is no longer the content published under
it.

openkal takes a minor bump for a new interface and an implementation
following it takes a patch bump --- the shape of 0.5.2 → 0.6.0 with
0.5.2 → 0.5.3 beneath it.
@Sunrisepeak
Sunrisepeak merged commit 6dd6316 into main Aug 24, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant