Commit graph

783 commits

Author SHA1 Message Date
Alex Rønne Petersen
b778826df5
std.crypto.argon2: disable kdf test
https://codeberg.org/ziglang/zig/issues/31402
2026-03-05 18:49:31 +01:00
Frank Denis
e8ca9229c8 Expose the elligator map for Curve25519
This is the same as for Edwards25519 without the y coordinate,
since it returns Montgomery coordinates, but it can be confusing
to call the Edwards25519 function while working on the
Curve25519 representation.

New protocols such as CPACE requires the map over Curve25519.
2026-02-23 13:04:58 +01:00
Andrew Kelley
54eb03cbf6 std.Io.Select: remove "outstanding" field
it is not fundamentally part of this abstraction
2026-02-20 16:42:37 -08:00
IntegratedQuantum
0bed4fb384 crypto: Allow arbitrary types for secureZeroes
also removed some related ptrCasts
2026-02-13 17:07:03 +01:00
Andrew Kelley
922ab8b8bc std: finish moving time to Io interface
Importantly, adds ability to get Clock resolution, which may be zero.
This allows error.Unexpected and error.ClockUnsupported to be removed
from timeout and clock reading error sets.
2026-02-02 23:02:31 -08:00
Andrew Kelley
e56563ce3f std.Io.File.MultiReader: implementation fixes 2026-01-30 22:03:14 -08:00
Frank Denis
8709f53d44 crypto.ff: allow seamless chaining regardless of representation (#30913)
Finite field elements can be in regular or Montgomery form, and
chaining different operations use to require manual and error-prone
conversions.

Now:

- `add`, `sub` and `mul` convert the second operand to match the
first operand's form
- `sq` and `pow` preserve the input's Montgomery form
- `toPrimitive` and `toBytes` return `UnexpectedRepresentation` if
the element is in Montgomery form, preventing incorrect serialization

This is fully backwards compatible and allows seamless chaining of
operations regardless of their representation.
2026-01-25 17:42:01 +01:00
Alex Rønne Petersen
9dd2716229
std.crypto.kangarootwelve: disable more flaky tests
https://codeberg.org/ziglang/zig/issues/30676
2026-01-13 09:19:08 +01:00
Frank Denis
be84d7cb9b Fix benchmarks after the randomness changes 2026-01-13 07:04:51 +01:00
nash1111
9a7f14354e crypto: correct checkHostName docs about wildcard matching 2026-01-10 22:11:52 +01:00
Andrew Kelley
721bdb6256 Merge pull request 'crypto.scrypt: accept an std.Io parameter instead of direct entropy' (#30738) from jedisct1/zig:scryptfixes into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30738
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-01-09 09:39:35 +01:00
Frank Denis
cd8f0aa4ca Add signerWithBaseNonce 2026-01-07 23:02:46 +01:00
Frank Denis
22380c78b1 crypto.ed25519.Signer: get an std.io parameter rather than entropy
This is consistent with what all other similar functions now do,
and is less dangerous.
2026-01-07 23:02:24 +01:00
Frank Denis
3ee092536e Allow the salt to be passed as a parameter in bcrypt 2026-01-07 22:44:37 +01:00
Frank Denis
4a29a6e432 Add scrypt.createWithSalt 2026-01-07 23:14:37 +01:00
Frank Denis
2153759a22 crypto.scrypt: accept an std.Io parameter instead of direct entropy
Safer, and consistent with what is being done in other similar
functions.
2026-01-07 23:01:38 +01:00
Andrew Kelley
006afece53 std.crypto.tls.Client.Options: expose entropy_len 2026-01-07 11:03:37 -08:00
Andrew Kelley
1f1381a866 update API usage of std.crypto.random to io.random 2026-01-07 11:03:36 -08:00
Andrew Kelley
816565dd07 std: move entropy to Io 2026-01-07 11:03:36 -08:00
mlugg
1bef876636 Merge pull request 'std.Thread: mask all signals before unmapping stack' (#30713) from detached-thread-exit-signal-race into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30713
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-01-07 01:11:25 +01:00
David Rubin
8b71ec6db7 crypto: correctly disallow non-digits in time
Previously these functions made the assumption that
when performing a  on the input digits,
there could be no collisions between the less
significant digits being larger than '9', and the
upper digits being small enough to get past the
 checks.

Now we perform a correct check across all of the
digits to ensure they're in between '0'-'9', at
a minimal cost, since all digits are checked in
parallel.
2026-01-06 23:37:43 +01:00
Kristoffer
9c55776d25 std.crypto: mem.trimLeft -> mem.trimStart 2026-01-06 23:28:01 +01:00
Matthew Lugg
be0a77efd2
std: re-enable some disabled tests
I believe these tests may have been flaky as a result of the bug fixed
in the previous commit. A big hint is that they were all crashing with
SIGSEGV with no stack trace. I suspect that some lingering SIGIOs from
cancelations were being delivered to a thread after its `munmap` call,
which was happening because the test runner called `Io.Threaded.deinit`
to cause all of the (detached) worker threads to exit.

If this passes, I'll re-run the x86_64-linux CI jobs on this commit a
few times before merge to try and be sure there are no lingering
failures.

Resolves: https://codeberg.org/ziglang/zig/issues/30096
Resolves: https://codeberg.org/ziglang/zig/issues/30592
Resolves: https://codeberg.org/ziglang/zig/issues/30682
2026-01-06 11:15:47 +00:00
Alex Rønne Petersen
9d08eba2e1
std.crypto.argon2: skip flaky argon2d test
https://codeberg.org/ziglang/zig/issues/30074
2026-01-06 10:02:09 +01:00
Alex Rønne Petersen
b0da914ae6
std.crypto.argon2: disable flaky phc format hasher test
https://codeberg.org/ziglang/zig/issues/30682
2026-01-06 10:01:16 +01:00
Gregory Mullen
29b9e24df7 add tls.ExtensionType.quic_transport_parameters = 57 2026-01-05 11:26:17 +01:00
Andrew Kelley
f28802a9c6 zig libc: fix subcommand
This branch regressed the child process "run" mechanism because it
didn't pass the correct stdin, stdout, stderr values to process.spawn

Fixed now.
2026-01-04 00:27:08 -08:00
Andrew Kelley
a0a982f0ea std.crypto.kangarootwelve: disable flaky test
tracked by #30676
2026-01-03 16:27:09 -08:00
Frank Denis
1baa127c65 crypto.edwards25519: optimize rejectLowOrder
Reject low-order points by checking projective coordinates directly
instead of using affine coordinates.

Equivalent, but saves CPU cycles (~254 field multiplications total
before, 3 field multiplications after).
2026-01-01 23:56:20 +01:00
Andrew Kelley
2adfd4d107 std.Io: fix and improve Group API
Rename `wait` to `await` to be consistent with Future API. The
convention here is that this set of functionality goes together:
* async/concurrent
* await/cancel

Also rename Select `wait` to `await` for the same reason.

`Group.await` now can return `error.Canceled`. Furthermore,
`Group.await` does not auto-propagate cancelation. Instead, users should
follow the pattern of `defer group.cancel(io);` after initialization,
and doing `try group.await(io);` at the end of the success path.
Advanced logic can choose to do something other than this pattern in the
event of cancelation.

Additionally, fixes a bug in `std.Io.Threaded` future await, in which it
swallowed an `error.Canceled`. Now if a task is canceled while awaiting
a future, after propagating the cancel request, it also recancels,
meaning that the awaiting task will properly detect its own cancelation
at the next cancelation point.

Furthermore, fixes a bug in the compiler where `error.Canceled` was
being swallowed in `dispatchPrelinkWork`.

Finally, fixes std.crypto code that inappropriately used
`catch unreachable` in response to cancelation without even so much as a
comment explaining why it was believed to be unreachable. Now, those
functions have `error.Canceled` in the error set and propagate
cancelation properly.

With this way of doing things, `Group.await` has a nice property: even if
all tasks in the group are CPU bound and without cancelation points, the
`Group.await` can still be canceled. In such case, the task that was
waiting for `await` wakes up with a chance to do some more resource
cleanup tasks, such as canceling more things, before entering the
deferred `Group.cancel` call at which point it has to suspend until the
canceled but uninterruptible CPU bound tasks complete.

closes #30601
2025-12-29 22:47:34 -08:00
Andrew Kelley
33e302d67a update remaining calls to std.Io.Threaded.init 2025-12-23 22:15:12 -08:00
Andrew Kelley
16bd2e137e compiler: fix most compilation errors from std.fs changes 2025-12-23 22:15:09 -08:00
Andrew Kelley
6484101f78 update occurences of std.fs.openDirAbsolute 2025-12-23 22:15:09 -08:00
Andrew Kelley
16f8af1b9a compiler: update various code to new fs API 2025-12-23 22:15:09 -08:00
Andrew Kelley
1dcfc8787e update all readFileAlloc() to accept Io instance 2025-12-23 22:15:08 -08:00
Andrew Kelley
264d714321 update all openDir() sites to accept io instance 2025-12-23 22:15:08 -08:00
Andrew Kelley
f53248a409 update all std.fs.cwd() to std.Io.Dir.cwd() 2025-12-23 22:15:08 -08:00
Andrew Kelley
9169983159 std.fs: migrate most of the API elsewhere 2025-12-23 22:15:08 -08:00
Andrew Kelley
8328de24f1 update all occurrences of openFile to receive an io instance 2025-12-23 22:15:08 -08:00
Andrew Kelley
dd1d15b72a update all occurrences of std.fs.Dir to std.Io.Dir 2025-12-23 22:15:08 -08:00
Andrew Kelley
3204fb7569 update all occurrences of std.fs.File to std.Io.File 2025-12-23 22:15:07 -08:00
Andrew Kelley
1b1fb7fab6 std.crypo.tls: delete unused import 2025-12-23 22:15:07 -08:00
Andrew Kelley
aafddc2ea1 update all occurrences of close() to close(io) 2025-12-23 22:15:07 -08:00
Alex Rønne Petersen
aa0249d74e Merge pull request 'std.ascii: rename indexOf functions to find' (#30101) from adria/zig:indexof-find into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30101
Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>
Reviewed-by: mlugg <mlugg@noreply.codeberg.org>
2025-12-22 12:50:46 +01:00
jedisct1
d27c804d9f Merge pull request 'crypto.mlkem: return J(z||c) on implicit rejection' (#30155) from jedisct1/zig:mlkemrej into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30155
2025-12-09 16:28:14 +01:00
Frank Denis
a0e9130b89 crypto.mlkem: return J(z||c) on implicit rejection
The ML-KEM decapsulation was returning z directly when implicit
rejection was triggered, but FIPS 203 specifies it should return
J(z || c) = SHAKE256(z || c).
2025-12-09 00:55:59 +01:00
David Rubin
ae21089b97
crypto: add missing sha2 arm early clobber 2025-12-09 00:41:23 +04:00
mlugg
dbb4c8d151 Merge pull request 'Remove things deprecated during the 0.15 release cycle' (#30018) from linus/zig:remove-deprecated-stuff into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30018
2025-12-06 08:51:15 +01:00
Adrià Arrufat
02c5f05e2f std: replace usages of std.mem.indexOf with std.mem.find 2025-12-05 14:31:27 +01:00
Frank Denis
6fe95c28cf Argon2: use the std.Io interface
Also reduce the memory required by tests.

4GB for every test is way too much and doesn't provide much benefits
in testing the algorithms.
2025-12-02 23:03:52 +01:00