First, the correct length for decoding should be computed with
/4*3 , not the other way round as when encoding.
But also, without padding, a string such as "Zg" is valid base64
(here, it's the character 'f', padded base64 would be "Zg==").
decodedLenUpperBound() returned 0 instead of 1 in that example.
Correctly fix the computation of the upper bound.
We should append TupleHashXOF's right_encode(0) marker directly
to the cSHAKE instance, not treat is as another tuple element.
The existing tests didn't catch this because they were using
TupleHash as a hash function, not as a XOF.
Without this change, on some targets (e.g. aarch64-freebsd),
calling `cmsg.data()` with `Iterator.message.header` as the
argument would result in compilation failures like:
error: expected type '*align(8) c.posix_cmsghdr', found '*c.posix_cmsghdr'
As with __zig_elf_auxv, we need a canonical location for __tls_get_addr (or
__tls_get_offset on s390x), and compiler-rt is the obvious place. But that also
means that moving all of std.os.linux.tls there just makes sense. I decided not
to namespace this under linux because it's expected that most of this code will
apply to the BSDs too.
The ABI that std now expects is:
extern fn __zig_elf_static_tls_init(phdrs: [*]elf.ElfN.Phdr, phnum: usize) void;
extern fn __zig_elf_static_tls_fill(area: [*]u8) usize;
extern var __zig_elf_static_tls: extern struct {
size: usize,
alignment: usize,
gdt_entry_number: usize,
};
Users can override all three weak symbols with strong symbols if they want to
provide their own ELF TLS implementation, which may be useful to do when doing
manual dynamic loading from a static executable. Note that __tls_get_addr (or
__tls_get_offset on s390x) must also be provided, per the ELF TLS specification.
This gets rid of the super confusing and (as far as I can tell) incorrect
getauxval logic in std.os.linux, and clarifies exactly who owns this state.
The ABI that std now expects is:
extern var __zig_elf_auxv: [*]std.elf.Auxv;
Users can technically override this weak symbol with a strong symbol if they
wish, although I see no particularly useful reason to do so.
It is now a compile error to use std.os.linux.getauxval if libc is linked,
whereas previously it would just give useless results in some cases. I consider
this to be strictly an improvement. Just use std.c.getauxval when linking libc,
which std already does correctly where it needs getauxval.
This code is expected to be further simplified once our baseline Linux version
allows implementing https://codeberg.org/ziglang/zig/issues/31290.
closes https://codeberg.org/ziglang/zig/issues/36203
On CPUs that don't support AES acceleration (and in environments
such as WebAssembly) we already use a generic bitsliced AES
implementation, via std.crypto.core.aes.
But AEGIS can be much faster by keeping the state bitsliced
(so we only set and extract the required bits to update the
state and get the keystream).
Rotating the state is also as simple as a 1-bit shift over the
entire bitsliced state.
This PR implements techniques described in
https://eprint.iacr.org/2026/1338 and makes AEGIS on CPUs without
AES acceleration 2x-3x faster.
On WebAssembly with SIMD, there's room for improvement (see
https://00f.net/2026/07/16/aes-with-simd-swizzles/) but that
requires swizzle operations that we don't support yet.
ios, tvos, visionos and watchos can't spawn processes, so their
null_file has no fd and spawnDarwin doesn't compile for them. The
vtable always references processReplace and the default panic handler
uses Threaded, so nearly every program for these targets failed to
compile. Fall back to posixExec there, as before 9fe0ebe108.
closes https://codeberg.org/ziglang/zig/issues/37061
Plain and Montgomery elements shouldn't compare equal just because
their limbs match.
Make eql require both the same limbs *and* the same form.
Also, comparison and parity checks don't make sense in Montgomery
form, so make sure the elements are in plain form for these operations.
Fix the plain-montgomery test by the way.
Use a buffer large enough for the field's full capacity.
For exponentiation with secret exponents, always encode the
exponents at the modulus public length, so that their length
doesn't act as a side channel.
And the public counterpart should use the exponent's public bit
length to include every byte needed for its highest set bit.
From https://lwn.net/Articles/828210/:
* powerpc64le supports IEEE128 long double libm/libc redirects when
using the -mabi=ieeelongdouble to compile C code on supported GCC
toolchains. It is recommended to use GCC 8 or newer when testing
this option.