@zigc/lib 0.16.0 → 0.17.0-dev.135
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/c/fcntl.zig +6 -1
- package/c/inttypes.zig +0 -10
- package/c/math.zig +46 -122
- package/c/pthread.zig +57 -0
- package/c/search.zig +1 -27
- package/c/stdlib/drand48.zig +0 -57
- package/c/stdlib.zig +0 -100
- package/c/string.zig +20 -7
- package/c/strings.zig +0 -38
- package/c/unistd.zig +27 -26
- package/c/wchar.zig +10 -0
- package/c.zig +2 -2
- package/compiler/aro/aro/CodeGen.zig +5 -6
- package/compiler/aro/aro/Compilation.zig +17 -14
- package/compiler/aro/aro/Driver.zig +14 -13
- package/compiler/aro/aro/Parser.zig +20 -15
- package/compiler/aro/aro/Pragma.zig +3 -2
- package/compiler/aro/aro/Preprocessor.zig +9 -6
- package/compiler/aro/aro/pragmas/message.zig +3 -2
- package/compiler/aro/aro/text_literal.zig +3 -2
- package/compiler/aro/assembly_backend/x86_64.zig +4 -4
- package/compiler/build_runner.zig +0 -2
- package/compiler/reduce/Walk.zig +7 -7
- package/compiler/test_runner.zig +2 -2
- package/compiler/translate-c/Translator.zig +6 -2
- package/compiler/translate-c/main.zig +1 -1
- package/compiler_rt/cos.zig +0 -2
- package/compiler_rt/divmodei4.zig +40 -17
- package/compiler_rt/exp.zig +1 -6
- package/compiler_rt/exp2.zig +1 -6
- package/compiler_rt/exp_f128.zig +377 -0
- package/compiler_rt/fabs.zig +0 -2
- package/compiler_rt/fma.zig +0 -2
- package/compiler_rt/fmax.zig +0 -2
- package/compiler_rt/fmin.zig +0 -2
- package/compiler_rt/fmod.zig +0 -2
- package/compiler_rt/limb64.zig +876 -15
- package/compiler_rt/log.zig +0 -2
- package/compiler_rt/log10.zig +0 -2
- package/compiler_rt/log2.zig +0 -2
- package/compiler_rt/mulXi3.zig +1 -1
- package/compiler_rt/round.zig +0 -2
- package/compiler_rt/sin.zig +0 -2
- package/compiler_rt/sincos.zig +0 -2
- package/compiler_rt/sqrt.zig +0 -2
- package/compiler_rt/ssp.zig +1 -1
- package/compiler_rt/tan.zig +0 -2
- package/compiler_rt/trunc.zig +0 -2
- package/compiler_rt/udivmodei4.zig +28 -0
- package/fuzzer.zig +2 -0
- package/libc/include/aarch64-linux-any/asm/hwcap.h +1 -0
- package/libc/include/aarch64-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/any-linux-any/asm-generic/errno.h +2 -0
- package/libc/include/any-linux-any/asm-generic/unistd.h +4 -1
- package/libc/include/any-linux-any/drm/amdgpu_drm.h +20 -6
- package/libc/include/any-linux-any/drm/amdxdna_accel.h +8 -0
- package/libc/include/any-linux-any/drm/drm_fourcc.h +6 -6
- package/libc/include/any-linux-any/drm/panfrost_drm.h +75 -1
- package/libc/include/any-linux-any/drm/panthor_drm.h +154 -3
- package/libc/include/any-linux-any/drm/rocket_accel.h +74 -24
- package/libc/include/any-linux-any/drm/xe_drm.h +89 -6
- package/libc/include/any-linux-any/linux/android/binder.h +1 -1
- package/libc/include/any-linux-any/linux/bpf.h +28 -0
- package/libc/include/any-linux-any/linux/btrfs.h +1 -0
- package/libc/include/any-linux-any/linux/btrfs_tree.h +32 -2
- package/libc/include/any-linux-any/linux/dma-buf.h +1 -0
- package/libc/include/any-linux-any/linux/dpll.h +1 -0
- package/libc/include/any-linux-any/linux/elf.h +2 -0
- package/libc/include/any-linux-any/linux/ethtool.h +21 -5
- package/libc/include/any-linux-any/linux/fs.h +1 -0
- package/libc/include/any-linux-any/linux/hyperv.h +1 -1
- package/libc/include/any-linux-any/linux/idxd.h +134 -134
- package/libc/include/any-linux-any/linux/if_alg.h +1 -1
- package/libc/include/any-linux-any/linux/if_link.h +1 -0
- package/libc/include/any-linux-any/linux/input-event-codes.h +4 -0
- package/libc/include/any-linux-any/linux/io_uring/bpf_filter.h +68 -0
- package/libc/include/any-linux-any/linux/io_uring/query.h +5 -1
- package/libc/include/any-linux-any/linux/io_uring.h +33 -2
- package/libc/include/any-linux-any/linux/iommufd.h +39 -0
- package/libc/include/any-linux-any/linux/kfd_ioctl.h +13 -3
- package/libc/include/any-linux-any/linux/kfd_sysfs.h +2 -1
- package/libc/include/any-linux-any/linux/kvm.h +30 -6
- package/libc/include/any-linux-any/linux/landlock.h +22 -8
- package/libc/include/any-linux-any/linux/magic.h +1 -0
- package/libc/include/any-linux-any/linux/mempolicy.h +3 -0
- package/libc/include/any-linux-any/linux/mount.h +11 -2
- package/libc/include/any-linux-any/linux/mptcp_pm.h +1 -1
- package/libc/include/any-linux-any/linux/mshv.h +2 -0
- package/libc/include/any-linux-any/linux/netfilter_bridge.h +5 -4
- package/libc/include/any-linux-any/linux/netfilter_ipv4.h +4 -5
- package/libc/include/any-linux-any/linux/netfilter_ipv6.h +3 -4
- package/libc/include/any-linux-any/linux/nfs.h +1 -1
- package/libc/include/any-linux-any/linux/nfsd_netlink.h +1 -0
- package/libc/include/any-linux-any/linux/nilfs2_api.h +2 -2
- package/libc/include/any-linux-any/linux/nilfs2_ondisk.h +97 -66
- package/libc/include/any-linux-any/linux/nl80211.h +104 -3
- package/libc/include/any-linux-any/linux/pci.h +7 -0
- package/libc/include/any-linux-any/linux/pci_regs.h +65 -6
- package/libc/include/any-linux-any/linux/pcitest.h +1 -0
- package/libc/include/any-linux-any/linux/perf_event.h +24 -3
- package/libc/include/any-linux-any/linux/pkt_sched.h +1 -0
- package/libc/include/any-linux-any/linux/prctl.h +30 -0
- package/libc/include/any-linux-any/linux/rseq.h +62 -5
- package/libc/include/any-linux-any/linux/shm.h +0 -1
- package/libc/include/any-linux-any/linux/stddef.h +4 -0
- package/libc/include/any-linux-any/linux/sysctl.h +1 -2
- package/libc/include/any-linux-any/linux/taskstats.h +12 -1
- package/libc/include/any-linux-any/linux/tcp.h +23 -3
- package/libc/include/any-linux-any/linux/typelimits.h +8 -0
- package/libc/include/any-linux-any/linux/ublk_cmd.h +120 -1
- package/libc/include/any-linux-any/linux/v4l2-controls.h +63 -0
- package/libc/include/any-linux-any/linux/vbox_vmmdev_types.h +2 -2
- package/libc/include/any-linux-any/linux/vduse.h +80 -5
- package/libc/include/any-linux-any/linux/version.h +3 -3
- package/libc/include/any-linux-any/linux/vfio.h +4 -0
- package/libc/include/any-linux-any/linux/videodev2.h +3 -0
- package/libc/include/any-linux-any/linux/virtio_ring.h +1 -2
- package/libc/include/any-linux-any/linux/vmclock-abi.h +20 -0
- package/libc/include/any-linux-any/rdma/bnxt_re-abi.h +16 -0
- package/libc/include/any-linux-any/rdma/ib_user_ioctl_cmds.h +16 -0
- package/libc/include/any-linux-any/rdma/mana-abi.h +3 -0
- package/libc/include/any-linux-any/scsi/scsi_bsg_ufs.h +8 -9
- package/libc/include/any-linux-any/sound/sof/tokens.h +6 -0
- package/libc/include/arc-linux-any/asm/swab.h +0 -63
- package/libc/include/arc-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/arm-linux-any/asm/ptrace.h +0 -9
- package/libc/include/arm-linux-any/asm/unistd-eabi.h +1 -0
- package/libc/include/arm-linux-any/asm/unistd-oabi.h +1 -0
- package/libc/include/csky-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/hexagon-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/loongarch-linux-any/asm/hwcap.h +1 -0
- package/libc/include/loongarch-linux-any/asm/kvm.h +1 -0
- package/libc/include/loongarch-linux-any/asm/kvm_para.h +1 -0
- package/libc/include/loongarch-linux-any/asm/unistd_32.h +2 -0
- package/libc/include/loongarch-linux-any/asm/unistd_64.h +2 -0
- package/libc/include/m68k-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/mips-linux-any/asm/errno.h +2 -0
- package/libc/include/mips-linux-any/asm/unistd_n32.h +1 -0
- package/libc/include/mips-linux-any/asm/unistd_n64.h +1 -0
- package/libc/include/mips-linux-any/asm/unistd_o32.h +1 -0
- package/libc/include/powerpc-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/powerpc-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/riscv-linux-any/asm/hwprobe.h +4 -0
- package/libc/include/riscv-linux-any/asm/kvm.h +3 -0
- package/libc/include/riscv-linux-any/asm/ptrace.h +37 -0
- package/libc/include/riscv-linux-any/asm/sigcontext.h +1 -0
- package/libc/include/riscv-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/riscv-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/s390x-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/sparc-linux-any/asm/errno.h +2 -0
- package/libc/include/sparc-linux-any/asm/ioctls.h +4 -4
- package/libc/include/sparc-linux-any/asm/unistd_32.h +2 -0
- package/libc/include/sparc-linux-any/asm/unistd_64.h +2 -0
- package/libc/include/x86-linux-any/asm/auxvec.h +0 -4
- package/libc/include/x86-linux-any/asm/kvm.h +13 -8
- package/libc/include/x86-linux-any/asm/svm.h +16 -16
- package/libc/include/x86-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/x86-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/x86-linux-any/asm/unistd_x32.h +1 -0
- package/libc/include/xtensa-linux-any/asm/unistd_32.h +1 -0
- package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
- package/package.json +1 -1
- package/std/Build/Cache.zig +6 -6
- package/std/Build/Step/Compile.zig +0 -1
- package/std/Build/Step/Run.zig +2 -2
- package/std/Build/Step.zig +2 -4
- package/std/Build/WebServer.zig +2 -2
- package/std/Build.zig +0 -3
- package/std/Io/Dir.zig +7 -2
- package/std/Io/Dispatch.zig +3 -13
- package/std/Io/File/Writer.zig +8 -6
- package/std/Io/Reader.zig +8 -9
- package/std/Io/Semaphore.zig +112 -17
- package/std/Io/Terminal.zig +1 -1
- package/std/Io/Threaded.zig +171 -37
- package/std/Io/Uring.zig +13 -15
- package/std/Io/Writer.zig +46 -42
- package/std/Io/net.zig +11 -11
- package/std/Io.zig +90 -26
- package/std/SemanticVersion.zig +1 -1
- package/std/Target/Query.zig +2 -2
- package/std/Target.zig +50 -5
- package/std/array_hash_map.zig +9 -18
- package/std/builtin.zig +4 -0
- package/std/c/haiku.zig +3 -0
- package/std/c/serenity.zig +1 -6
- package/std/c.zig +89 -7
- package/std/compress/flate/Decompress.zig +2 -3
- package/std/compress/zstd/Decompress.zig +2 -4
- package/std/crypto/Certificate.zig +13 -1
- package/std/crypto/ascon.zig +75 -33
- package/std/crypto/codecs/asn1/Oid.zig +12 -1
- package/std/crypto/codecs/base64_hex_ct.zig +2 -4
- package/std/crypto/ml_kem.zig +2 -9
- package/std/crypto/tls/Client.zig +79 -4
- package/std/crypto/tls.zig +1 -1
- package/std/crypto.zig +1 -0
- package/std/debug/Pdb.zig +1 -1
- package/std/debug.zig +4 -3
- package/std/fmt.zig +8 -3
- package/std/fs/path.zig +6 -4
- package/std/heap/BufferFirstAllocator.zig +165 -0
- package/std/heap.zig +2 -126
- package/std/http/Client.zig +21 -24
- package/std/http.zig +3 -4
- package/std/json/Scanner.zig +2 -2
- package/std/os/emscripten.zig +1 -1
- package/std/os/linux/IoUring.zig +2 -0
- package/std/os/linux/aarch64.zig +41 -12
- package/std/os/linux/arc.zig +173 -0
- package/std/os/linux/arm.zig +41 -12
- package/std/os/linux/hexagon.zig +33 -11
- package/std/os/linux/loongarch32.zig +41 -13
- package/std/os/linux/loongarch64.zig +41 -12
- package/std/os/linux/m68k.zig +41 -13
- package/std/os/linux/mips.zig +67 -36
- package/std/os/linux/mips64.zig +60 -29
- package/std/os/linux/mipsn32.zig +60 -29
- package/std/os/linux/or1k.zig +41 -12
- package/std/os/linux/powerpc.zig +41 -12
- package/std/os/linux/powerpc64.zig +41 -12
- package/std/os/linux/riscv32.zig +41 -12
- package/std/os/linux/riscv64.zig +41 -12
- package/std/os/linux/s390x.zig +44 -7
- package/std/os/linux/sparc64.zig +83 -52
- package/std/os/linux/syscalls.zig +26 -1
- package/std/os/linux/thumb.zig +52 -36
- package/std/os/linux/x32.zig +41 -12
- package/std/os/linux/x86.zig +42 -13
- package/std/os/linux/x86_64.zig +41 -12
- package/std/os/linux.zig +412 -436
- package/std/os/uefi/tables/boot_services.zig +9 -8
- package/std/os.zig +41 -0
- package/std/process.zig +1 -1
- package/std/sort.zig +3 -3
- package/std/zig/Ast/Render.zig +3 -3
- package/std/zig/AstGen.zig +44 -98
- package/std/zig/AstRlAnnotate.zig +0 -11
- package/std/zig/BuiltinFn.zig +0 -32
- package/std/zig/LibCInstallation.zig +4 -3
- package/std/zig/Parse.zig +7 -7
- package/std/zig/WindowsSdk.zig +13 -13
- package/std/zig/Zir.zig +50 -63
- package/std/zig/ZonGen.zig +6 -5
- package/std/zig/llvm/Builder.zig +12 -12
- package/std/zig.zig +1 -10
- package/std/zip.zig +5 -5
- package/zig.h +340 -1
- package/libc/include/hexagon-linux-any/asm/signal.h +0 -29
- package/libc/include/s390x-linux-any/asm/tape390.h +0 -103
- package/libc/mingw/math/fdiml.c +0 -24
- package/libc/mingw/winpthreads/spinlock.c +0 -82
- package/libc/musl/src/linux/tee.c +0 -8
- package/libc/musl/src/math/fdimf.c +0 -10
- package/libc/musl/src/math/fdiml.c +0 -18
- package/libc/musl/src/string/strdup.c +0 -10
- package/libc/musl/src/string/strndup.c +0 -12
- package/libc/musl/src/string/wcsdup.c +0 -10
- package/libc/musl/src/thread/pthread_spin_destroy.c +0 -6
- package/libc/musl/src/thread/pthread_spin_init.c +0 -6
- package/libc/musl/src/thread/pthread_spin_lock.c +0 -8
- package/libc/musl/src/thread/pthread_spin_trylock.c +0 -7
- package/libc/musl/src/thread/pthread_spin_unlock.c +0 -7
- package/libc/musl/src/unistd/dup2.c +0 -20
- package/libc/musl/src/unistd/dup3.c +0 -26
- package/libc/wasi/thread-stub/pthread_spin_lock.c +0 -8
- package/libc/wasi/thread-stub/pthread_spin_trylock.c +0 -8
- package/libc/wasi/thread-stub/pthread_spin_unlock.c +0 -7
package/std/c.zig
CHANGED
|
@@ -3260,8 +3260,8 @@ pub const Sigaction = switch (native_os) {
|
|
|
3260
3260
|
|
|
3261
3261
|
/// signal handler
|
|
3262
3262
|
handler: extern union {
|
|
3263
|
-
handler: handler_fn,
|
|
3264
|
-
sigaction: sigaction_fn,
|
|
3263
|
+
handler: ?handler_fn,
|
|
3264
|
+
sigaction: ?sigaction_fn,
|
|
3265
3265
|
},
|
|
3266
3266
|
|
|
3267
3267
|
/// signal mask to apply
|
|
@@ -7898,6 +7898,20 @@ pub const Stat = switch (native_os) {
|
|
|
7898
7898
|
else => void,
|
|
7899
7899
|
};
|
|
7900
7900
|
|
|
7901
|
+
pub const pthread_spinlock_t = switch (native_os) {
|
|
7902
|
+
.openbsd => openbsd.pthread_spinlock_t,
|
|
7903
|
+
.freebsd => extern struct {
|
|
7904
|
+
inner: ?*anyopaque = null,
|
|
7905
|
+
},
|
|
7906
|
+
.netbsd => extern struct {
|
|
7907
|
+
pts_magic: c_uint,
|
|
7908
|
+
spin: pthread_spin_t,
|
|
7909
|
+
pts_flags: c_int,
|
|
7910
|
+
},
|
|
7911
|
+
.windows => isize,
|
|
7912
|
+
else => c_int,
|
|
7913
|
+
};
|
|
7914
|
+
|
|
7901
7915
|
pub const pthread_mutex_t = switch (native_os) {
|
|
7902
7916
|
.linux => extern struct {
|
|
7903
7917
|
data: [data_len]u8 align(@alignOf(usize)) = [_]u8{0} ** data_len,
|
|
@@ -10956,6 +10970,19 @@ pub extern "c" fn dn_expand(
|
|
|
10956
10970
|
length: c_int,
|
|
10957
10971
|
) c_int;
|
|
10958
10972
|
|
|
10973
|
+
pub const PTHREAD_PROCESS_PRIVATE: c_int = if (native_os.isDarwin())
|
|
10974
|
+
2
|
|
10975
|
+
else
|
|
10976
|
+
0;
|
|
10977
|
+
|
|
10978
|
+
pub const PTHREAD_PROCESS_SHARED: c_int = 1;
|
|
10979
|
+
|
|
10980
|
+
pub extern "c" fn pthread_spin_init(spin: *pthread_spinlock_t, pshared: c_int) c_int;
|
|
10981
|
+
pub extern "c" fn pthread_spin_lock(spin: *pthread_spinlock_t) c_int;
|
|
10982
|
+
pub extern "c" fn pthread_spin_unlock(spin: *pthread_spinlock_t) c_int;
|
|
10983
|
+
pub extern "c" fn pthread_spin_trylock(spin: *pthread_spinlock_t) c_int;
|
|
10984
|
+
pub extern "c" fn pthread_spin_destroy(spin: *pthread_spinlock_t) c_int;
|
|
10985
|
+
|
|
10959
10986
|
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = .{};
|
|
10960
10987
|
pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E;
|
|
10961
10988
|
pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E;
|
|
@@ -11102,6 +11129,64 @@ pub const ioctl = switch (native_os) {
|
|
|
11102
11129
|
else => private.ioctl,
|
|
11103
11130
|
};
|
|
11104
11131
|
|
|
11132
|
+
pub extern "c" fn bzero(s: *anyopaque, n: usize) void;
|
|
11133
|
+
|
|
11134
|
+
pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void;
|
|
11135
|
+
|
|
11136
|
+
pub extern "c" fn strncmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int;
|
|
11137
|
+
pub extern "c" fn strcasecmp(a: [*:0]const c_char, b: [*:0]const c_char) c_int;
|
|
11138
|
+
pub extern "c" fn strncasecmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int;
|
|
11139
|
+
pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char;
|
|
11140
|
+
pub extern "c" fn strndup(s: [*:0]const c_char, n: usize) ?[*:0]c_char;
|
|
11141
|
+
pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t;
|
|
11142
|
+
|
|
11143
|
+
pub extern "c" fn ffs(i: c_int) c_int;
|
|
11144
|
+
pub extern "c" fn ffsl(i: c_long) c_long;
|
|
11145
|
+
pub extern "c" fn ffsll(i: c_longlong) c_longlong;
|
|
11146
|
+
|
|
11147
|
+
pub extern "c" fn erand48(xsubi: *[3]c_ushort) f64;
|
|
11148
|
+
pub extern "c" fn jrand48(xsubi: *[3]c_ushort) c_long;
|
|
11149
|
+
pub extern "c" fn nrand48(xsubi: *[3]c_ushort) c_long;
|
|
11150
|
+
|
|
11151
|
+
pub extern "c" fn insque(element: *anyopaque, pred: ?*anyopaque) void;
|
|
11152
|
+
pub extern "c" fn remque(element: *anyopaque) void;
|
|
11153
|
+
|
|
11154
|
+
pub extern "c" fn imaxabs(a: intmax_t) intmax_t;
|
|
11155
|
+
pub extern "c" fn imaxdiv(a: intmax_t, b: intmax_t) imaxdiv_t;
|
|
11156
|
+
|
|
11157
|
+
pub extern "c" fn abs(a: c_int) c_int;
|
|
11158
|
+
pub extern "c" fn labs(a: c_long) c_long;
|
|
11159
|
+
pub extern "c" fn llabs(a: c_longlong) c_longlong;
|
|
11160
|
+
|
|
11161
|
+
pub extern "c" fn div(a: c_int, b: c_int) div_t;
|
|
11162
|
+
pub extern "c" fn ldiv(a: c_long, b: c_long) ldiv_t;
|
|
11163
|
+
pub extern "c" fn lldiv(a: c_longlong, b: c_longlong) lldiv_t;
|
|
11164
|
+
|
|
11165
|
+
pub extern "c" fn atoi(str: [*:0]const c_char) c_int;
|
|
11166
|
+
pub extern "c" fn atol(str: [*:0]const c_char) c_long;
|
|
11167
|
+
pub extern "c" fn atoll(str: [*:0]const c_char) c_longlong;
|
|
11168
|
+
|
|
11169
|
+
pub extern "c" fn bsearch(
|
|
11170
|
+
key: *const anyopaque,
|
|
11171
|
+
base: *const anyopaque,
|
|
11172
|
+
n: usize,
|
|
11173
|
+
size: usize,
|
|
11174
|
+
compare: *const fn (a: *const anyopaque, b: *const anyopaque) callconv(.c) c_int,
|
|
11175
|
+
) ?*anyopaque;
|
|
11176
|
+
|
|
11177
|
+
// Math
|
|
11178
|
+
pub extern "c" fn atan(x: f64) f64;
|
|
11179
|
+
pub extern "c" fn copysign(x: f64, y: f64) f64;
|
|
11180
|
+
pub extern "c" fn fdim(x: f64, y: f64) f64;
|
|
11181
|
+
pub extern "c" fn frexp(x: f64, e: *c_int) f64;
|
|
11182
|
+
pub extern "c" fn hypot(x: f64, y: f64) f64;
|
|
11183
|
+
pub extern "c" fn modff(x: f32, iptr: *f32) f32;
|
|
11184
|
+
pub extern "c" fn modf(x: f64, iptr: *f64) f64;
|
|
11185
|
+
pub extern "c" fn modfl(x: c_longdouble, iptr: *c_longdouble) c_longdouble;
|
|
11186
|
+
pub extern "c" fn rintf(x: f32) f32;
|
|
11187
|
+
pub extern "c" fn rint(x: f64) f64;
|
|
11188
|
+
pub extern "c" fn rintl(x: c_longdouble) c_longdouble;
|
|
11189
|
+
|
|
11105
11190
|
// OS-specific bits. These are protected from being used on the wrong OS by
|
|
11106
11191
|
// comptime assertions inside each OS-specific file.
|
|
11107
11192
|
|
|
@@ -11142,6 +11227,8 @@ pub const _kern_open_dir = haiku._kern_open_dir;
|
|
|
11142
11227
|
pub const _kern_read_dir = haiku._kern_read_dir;
|
|
11143
11228
|
pub const _kern_read_stat = haiku._kern_read_stat;
|
|
11144
11229
|
pub const _kern_rewind_dir = haiku._kern_rewind_dir;
|
|
11230
|
+
pub const readv_pos = haiku.readv_pos;
|
|
11231
|
+
pub const writev_pos = haiku.writev_pos;
|
|
11145
11232
|
pub const area_id = haiku.area_id;
|
|
11146
11233
|
pub const area_info = haiku.area_info;
|
|
11147
11234
|
pub const directory_which = haiku.directory_which;
|
|
@@ -11211,7 +11298,6 @@ pub const login_getcaptime = openbsd.login_getcaptime;
|
|
|
11211
11298
|
pub const login_getclass = openbsd.login_getclass;
|
|
11212
11299
|
pub const login_getstyle = openbsd.login_getstyle;
|
|
11213
11300
|
pub const pledge = openbsd.pledge;
|
|
11214
|
-
pub const pthread_spinlock_t = openbsd.pthread_spinlock_t;
|
|
11215
11301
|
pub const pw_dup = openbsd.pw_dup;
|
|
11216
11302
|
pub const setclasscontext = openbsd.setclasscontext;
|
|
11217
11303
|
pub const setpassent = openbsd.setpassent;
|
|
@@ -11449,15 +11535,11 @@ pub const disown = serenity.disown;
|
|
|
11449
11535
|
pub const profiling_enable = serenity.profiling_enable;
|
|
11450
11536
|
pub const profiling_disable = serenity.profiling_disable;
|
|
11451
11537
|
pub const profiling_free_buffer = serenity.profiling_free_buffer;
|
|
11452
|
-
pub const futex_wait = serenity.futex_wait;
|
|
11453
|
-
pub const futex_wake = serenity.futex_wake;
|
|
11454
11538
|
pub const purge = serenity.purge;
|
|
11455
11539
|
pub const perf_event = serenity.perf_event;
|
|
11456
11540
|
pub const perf_register_string = serenity.perf_register_string;
|
|
11457
11541
|
pub const get_stack_bounds = serenity.get_stack_bounds;
|
|
11458
11542
|
pub const anon_create = serenity.anon_create;
|
|
11459
|
-
pub const serenity_readlink = serenity.serenity_readlink;
|
|
11460
|
-
pub const serenity_open = serenity.serenity_open;
|
|
11461
11543
|
pub const getkeymap = serenity.getkeymap;
|
|
11462
11544
|
pub const setkeymap = serenity.setkeymap;
|
|
11463
11545
|
|
|
@@ -129,8 +129,7 @@ fn discardDirect(r: *Reader, limit: std.Io.Limit) Reader.Error!usize {
|
|
|
129
129
|
}
|
|
130
130
|
const n = r.stream(&writer, limit) catch |err| switch (err) {
|
|
131
131
|
error.WriteFailed => unreachable,
|
|
132
|
-
error.ReadFailed => return
|
|
133
|
-
error.EndOfStream => return error.EndOfStream,
|
|
132
|
+
error.ReadFailed, error.EndOfStream => |e| return e,
|
|
134
133
|
};
|
|
135
134
|
assert(n <= @intFromEnum(limit));
|
|
136
135
|
return n;
|
|
@@ -258,7 +257,7 @@ fn streamFallible(d: *Decompress, w: *Writer, limit: std.Io.Limit) Reader.Stream
|
|
|
258
257
|
return error.ReadFailed;
|
|
259
258
|
}
|
|
260
259
|
},
|
|
261
|
-
error.WriteFailed => return
|
|
260
|
+
error.WriteFailed => |e| return e,
|
|
262
261
|
else => |e| {
|
|
263
262
|
// In the event of an error, state is unmodified so that it can be
|
|
264
263
|
// better used to diagnose the failure.
|
|
@@ -173,8 +173,7 @@ fn discardDirect(r: *Reader, limit: std.Io.Limit) Reader.Error!usize {
|
|
|
173
173
|
}
|
|
174
174
|
const n = r.stream(&writer, limit) catch |err| switch (err) {
|
|
175
175
|
error.WriteFailed => unreachable,
|
|
176
|
-
error.ReadFailed => return
|
|
177
|
-
error.EndOfStream => return error.EndOfStream,
|
|
176
|
+
error.ReadFailed, error.EndOfStream => |e| return e,
|
|
178
177
|
};
|
|
179
178
|
assert(n <= @intFromEnum(limit));
|
|
180
179
|
return n;
|
|
@@ -252,8 +251,7 @@ fn stream(d: *Decompress, w: *Writer, limit: Limit) Reader.StreamError!usize {
|
|
|
252
251
|
},
|
|
253
252
|
.in_frame => |*in_frame| {
|
|
254
253
|
return readInFrame(d, w, limit, in_frame) catch |err| switch (err) {
|
|
255
|
-
error.ReadFailed => return
|
|
256
|
-
error.WriteFailed => return error.WriteFailed,
|
|
254
|
+
error.ReadFailed, error.WriteFailed => |e| return e,
|
|
257
255
|
else => |e| {
|
|
258
256
|
d.err = e;
|
|
259
257
|
return error.ReadFailed;
|
|
@@ -580,7 +580,10 @@ pub fn parseTime(cert: Certificate, elem: der.Element) ParseTimeError!u64 {
|
|
|
580
580
|
return error.CertificateTimeInvalid;
|
|
581
581
|
|
|
582
582
|
return Date.toSeconds(.{
|
|
583
|
-
.year =
|
|
583
|
+
.year = blk: {
|
|
584
|
+
const year = try parseTimeDigits(bytes[0..2], 0, 99);
|
|
585
|
+
break :blk if (year < 50) @as(u16, 2000) + year else @as(u16, 1900) + year;
|
|
586
|
+
},
|
|
584
587
|
.month = try parseTimeDigits(bytes[2..4], 1, 12),
|
|
585
588
|
.day = try parseTimeDigits(bytes[4..6], 1, 31),
|
|
586
589
|
.hour = try parseTimeDigits(bytes[6..8], 0, 23),
|
|
@@ -670,6 +673,15 @@ pub fn parseTimeDigits(text: *const [2]u8, min: u8, max: u8) !u8 {
|
|
|
670
673
|
return @intCast(result);
|
|
671
674
|
}
|
|
672
675
|
|
|
676
|
+
test "parseTime UTCTime year mapping per RFC 5280" {
|
|
677
|
+
const utc_time_id: der.Identifier = .{ .tag = .utc_time, .pc = .primitive, .class = .universal };
|
|
678
|
+
const elem = der.Element{ .identifier = utc_time_id, .slice = .{ .start = 0, .end = 13 } };
|
|
679
|
+
const cert49 = Certificate{ .buffer = "490101000000Z", .index = 0 };
|
|
680
|
+
try std.testing.expectEqual(@as(u64, 2493072000), try cert49.parseTime(elem));
|
|
681
|
+
const cert99 = Certificate{ .buffer = "990101000000Z", .index = 0 };
|
|
682
|
+
try std.testing.expectEqual(@as(u64, 915148800), try cert99.parseTime(elem));
|
|
683
|
+
}
|
|
684
|
+
|
|
673
685
|
test parseTimeDigits {
|
|
674
686
|
const expectEqual = std.testing.expectEqual;
|
|
675
687
|
try expectEqual(@as(u8, 0), try parseTimeDigits("00", 0, 99));
|
package/std/crypto/ascon.zig
CHANGED
|
@@ -681,6 +681,8 @@ pub const AsconXof128 = struct {
|
|
|
681
681
|
|
|
682
682
|
st: AsconState,
|
|
683
683
|
squeezed: bool,
|
|
684
|
+
buf: [block_length]u8,
|
|
685
|
+
buf_len: usize,
|
|
684
686
|
|
|
685
687
|
pub const Options = struct {};
|
|
686
688
|
|
|
@@ -698,7 +700,7 @@ pub const AsconXof128 = struct {
|
|
|
698
700
|
const words: [5]u64 = .{ iv, 0, 0, 0, 0 };
|
|
699
701
|
var st = AsconState.initFromWords(words);
|
|
700
702
|
st.permuteR(12);
|
|
701
|
-
return AsconXof128{ .st = st, .squeezed = false };
|
|
703
|
+
return AsconXof128{ .st = st, .squeezed = false, .buf = @splat(0), .buf_len = 0 };
|
|
702
704
|
}
|
|
703
705
|
|
|
704
706
|
/// Hash a slice of bytes with variable-length output.
|
|
@@ -726,24 +728,26 @@ pub const AsconXof128 = struct {
|
|
|
726
728
|
|
|
727
729
|
var i: usize = 0;
|
|
728
730
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
self.
|
|
731
|
+
if (self.buf_len > 0) {
|
|
732
|
+
const to_fill = @min(block_length - self.buf_len, b.len);
|
|
733
|
+
@memcpy(self.buf[self.buf_len..][0..to_fill], b[0..to_fill]);
|
|
734
|
+
self.buf_len += to_fill;
|
|
735
|
+
i += to_fill;
|
|
736
|
+
if (self.buf_len == block_length) {
|
|
737
|
+
self.st.addBytes(&self.buf);
|
|
738
|
+
self.st.permuteR(12);
|
|
739
|
+
self.buf_len = 0;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
while (i + block_length <= b.len) : (i += block_length) {
|
|
744
|
+
self.st.addBytes(b[i..][0..block_length]);
|
|
732
745
|
self.st.permuteR(12);
|
|
733
746
|
}
|
|
734
747
|
|
|
735
|
-
// Store partial block for finalization
|
|
736
748
|
if (i < b.len) {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
@memcpy(padded[0..remaining], b[i..]);
|
|
740
|
-
padded[remaining] = 0x01;
|
|
741
|
-
self.st.addBytes(&padded);
|
|
742
|
-
} else {
|
|
743
|
-
// Add padding block
|
|
744
|
-
var padded: [8]u8 = @splat(0);
|
|
745
|
-
padded[0] = 0x01;
|
|
746
|
-
self.st.addBytes(&padded);
|
|
749
|
+
self.buf_len = b.len - i;
|
|
750
|
+
@memcpy(self.buf[0..self.buf_len], b[i..]);
|
|
747
751
|
}
|
|
748
752
|
}
|
|
749
753
|
|
|
@@ -756,7 +760,10 @@ pub const AsconXof128 = struct {
|
|
|
756
760
|
/// After first call, no more data can be absorbed with update().
|
|
757
761
|
pub fn squeeze(self: *AsconXof128, out: []u8) void {
|
|
758
762
|
if (!self.squeezed) {
|
|
759
|
-
|
|
763
|
+
var padded: [block_length]u8 = @splat(0);
|
|
764
|
+
@memcpy(padded[0..self.buf_len], self.buf[0..self.buf_len]);
|
|
765
|
+
padded[self.buf_len] = 0x01;
|
|
766
|
+
self.st.addBytes(&padded);
|
|
760
767
|
self.st.permuteR(12);
|
|
761
768
|
self.squeezed = true;
|
|
762
769
|
}
|
|
@@ -783,6 +790,8 @@ pub const AsconCxof128 = struct {
|
|
|
783
790
|
|
|
784
791
|
st: AsconState,
|
|
785
792
|
squeezed: bool,
|
|
793
|
+
buf: [block_length]u8,
|
|
794
|
+
buf_len: usize,
|
|
786
795
|
|
|
787
796
|
pub const Options = struct { custom: []const u8 = "" };
|
|
788
797
|
|
|
@@ -804,7 +813,7 @@ pub const AsconCxof128 = struct {
|
|
|
804
813
|
var st = AsconState.initFromWords(words);
|
|
805
814
|
st.permuteR(12);
|
|
806
815
|
|
|
807
|
-
var self = AsconCxof128{ .st = st, .squeezed = false };
|
|
816
|
+
var self = AsconCxof128{ .st = st, .squeezed = false, .buf = @splat(0), .buf_len = 0 };
|
|
808
817
|
|
|
809
818
|
// Process customization string - always process length and padding
|
|
810
819
|
// First block: length of customization string
|
|
@@ -867,28 +876,30 @@ pub const AsconCxof128 = struct {
|
|
|
867
876
|
///
|
|
868
877
|
/// Note: Cannot be called after squeeze() has been called
|
|
869
878
|
pub fn update(self: *AsconCxof128, b: []const u8) void {
|
|
870
|
-
debug.assert(!self.squeezed);
|
|
879
|
+
debug.assert(!self.squeezed); // Cannot update after squeezing
|
|
871
880
|
|
|
872
881
|
var i: usize = 0;
|
|
873
882
|
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
self.
|
|
883
|
+
if (self.buf_len > 0) {
|
|
884
|
+
const to_fill = @min(block_length - self.buf_len, b.len);
|
|
885
|
+
@memcpy(self.buf[self.buf_len..][0..to_fill], b[0..to_fill]);
|
|
886
|
+
self.buf_len += to_fill;
|
|
887
|
+
i += to_fill;
|
|
888
|
+
if (self.buf_len == block_length) {
|
|
889
|
+
self.st.addBytes(&self.buf);
|
|
890
|
+
self.st.permuteR(12);
|
|
891
|
+
self.buf_len = 0;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
while (i + block_length <= b.len) : (i += block_length) {
|
|
896
|
+
self.st.addBytes(b[i..][0..block_length]);
|
|
877
897
|
self.st.permuteR(12);
|
|
878
898
|
}
|
|
879
899
|
|
|
880
|
-
// Store partial block for finalization
|
|
881
900
|
if (i < b.len) {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
@memcpy(padded[0..remaining], b[i..]);
|
|
885
|
-
padded[remaining] = 0x01;
|
|
886
|
-
self.st.addBytes(&padded);
|
|
887
|
-
} else {
|
|
888
|
-
// Add padding block
|
|
889
|
-
var padded: [8]u8 = @splat(0);
|
|
890
|
-
padded[0] = 0x01;
|
|
891
|
-
self.st.addBytes(&padded);
|
|
901
|
+
self.buf_len = b.len - i;
|
|
902
|
+
@memcpy(self.buf[0..self.buf_len], b[i..]);
|
|
892
903
|
}
|
|
893
904
|
}
|
|
894
905
|
|
|
@@ -901,7 +912,10 @@ pub const AsconCxof128 = struct {
|
|
|
901
912
|
/// After first call, no more data can be absorbed with update().
|
|
902
913
|
pub fn squeeze(self: *AsconCxof128, out: []u8) void {
|
|
903
914
|
if (!self.squeezed) {
|
|
904
|
-
|
|
915
|
+
var padded: [block_length]u8 = @splat(0);
|
|
916
|
+
@memcpy(padded[0..self.buf_len], self.buf[0..self.buf_len]);
|
|
917
|
+
padded[self.buf_len] = 0x01;
|
|
918
|
+
self.st.addBytes(&padded);
|
|
905
919
|
self.st.permuteR(12);
|
|
906
920
|
self.squeezed = true;
|
|
907
921
|
}
|
|
@@ -1267,6 +1281,34 @@ test "Ascon-XOF128 official test vectors" {
|
|
|
1267
1281
|
}
|
|
1268
1282
|
}
|
|
1269
1283
|
|
|
1284
|
+
test "Ascon-XOF128/CXOF128 streaming chunking invariance" {
|
|
1285
|
+
const msg = "Hello, World!";
|
|
1286
|
+
|
|
1287
|
+
// XOF128: one-shot vs split must match
|
|
1288
|
+
var out1: [32]u8 = undefined;
|
|
1289
|
+
var out2: [32]u8 = undefined;
|
|
1290
|
+
var xof1 = AsconXof128.init(.{});
|
|
1291
|
+
xof1.update(msg);
|
|
1292
|
+
xof1.squeeze(&out1);
|
|
1293
|
+
var xof2 = AsconXof128.init(.{});
|
|
1294
|
+
xof2.update("Hello, ");
|
|
1295
|
+
xof2.update("World!");
|
|
1296
|
+
xof2.squeeze(&out2);
|
|
1297
|
+
try testing.expectEqualSlices(u8, &out1, &out2);
|
|
1298
|
+
|
|
1299
|
+
// CXOF128: one-shot vs split must match
|
|
1300
|
+
var cout1: [32]u8 = undefined;
|
|
1301
|
+
var cout2: [32]u8 = undefined;
|
|
1302
|
+
var cxof1 = AsconCxof128.init(.{ .custom = "cust" });
|
|
1303
|
+
cxof1.update(msg);
|
|
1304
|
+
cxof1.squeeze(&cout1);
|
|
1305
|
+
var cxof2 = AsconCxof128.init(.{ .custom = "cust" });
|
|
1306
|
+
cxof2.update("Hello, ");
|
|
1307
|
+
cxof2.update("World!");
|
|
1308
|
+
cxof2.squeeze(&cout2);
|
|
1309
|
+
try testing.expectEqualSlices(u8, &cout1, &cout2);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1270
1312
|
test "Ascon-CXOF128 official test vectors" {
|
|
1271
1313
|
|
|
1272
1314
|
// Test vector 1: Empty message, empty customization, 64-byte output
|
|
@@ -85,6 +85,14 @@ test toDot {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
test "malformed OID" {
|
|
89
|
+
var empty: der.Decoder = .{ .bytes = &.{ 0x06, 0x00 } };
|
|
90
|
+
try std.testing.expectError(error.EndOfStream, decodeDer(&empty));
|
|
91
|
+
|
|
92
|
+
var truncated: der.Decoder = .{ .bytes = &.{ 0x06, 0x02, 0x2a, 0x80 } };
|
|
93
|
+
try std.testing.expectError(error.InvalidEncoding, decodeDer(&truncated));
|
|
94
|
+
}
|
|
95
|
+
|
|
88
96
|
const TestCase = struct {
|
|
89
97
|
encoded: []const u8,
|
|
90
98
|
dot_notation: []const u8,
|
|
@@ -109,7 +117,10 @@ pub const asn1_tag = asn1.Tag.init(.oid, false, .universal);
|
|
|
109
117
|
|
|
110
118
|
pub fn decodeDer(decoder: *der.Decoder) !Oid {
|
|
111
119
|
const ele = try decoder.element(asn1_tag.toExpected());
|
|
112
|
-
|
|
120
|
+
const encoded = decoder.view(ele);
|
|
121
|
+
if (encoded.len == 0) return error.EndOfStream;
|
|
122
|
+
if (encoded[encoded.len - 1] & 0x80 != 0) return error.InvalidEncoding;
|
|
123
|
+
return Oid{ .encoded = encoded };
|
|
113
124
|
}
|
|
114
125
|
|
|
115
126
|
pub fn encodeDer(self: Oid, encoder: *der.Encoder) !void {
|
|
@@ -47,8 +47,7 @@ pub const hex = struct {
|
|
|
47
47
|
}
|
|
48
48
|
_ = decodeAny(bin, encoded, null) catch |err| {
|
|
49
49
|
switch (err) {
|
|
50
|
-
error.InvalidCharacter => return
|
|
51
|
-
error.InvalidPadding => return error.InvalidPadding,
|
|
50
|
+
error.InvalidCharacter, error.InvalidPadding => |e| return e,
|
|
52
51
|
else => unreachable,
|
|
53
52
|
}
|
|
54
53
|
};
|
|
@@ -228,8 +227,7 @@ pub const base64 = struct {
|
|
|
228
227
|
pub fn decode(bin: []u8, encoded: []const u8, comptime variant: Variant) error{ InvalidCharacter, InvalidPadding }![]const u8 {
|
|
229
228
|
return decodeAny(bin, encoded, variant, null) catch |err| {
|
|
230
229
|
switch (err) {
|
|
231
|
-
error.InvalidCharacter => return
|
|
232
|
-
error.InvalidPadding => return error.InvalidPadding,
|
|
230
|
+
error.InvalidCharacter, error.InvalidPadding => |e| return e,
|
|
233
231
|
else => unreachable,
|
|
234
232
|
}
|
|
235
233
|
};
|
package/std/crypto/ml_kem.zig
CHANGED
|
@@ -1725,15 +1725,8 @@ const NistDRBG = struct {
|
|
|
1725
1725
|
v: [16]u8,
|
|
1726
1726
|
|
|
1727
1727
|
fn incV(g: *NistDRBG) void {
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
if (g.v[j] == 255) {
|
|
1731
|
-
g.v[j] = 0;
|
|
1732
|
-
} else {
|
|
1733
|
-
g.v[j] += 1;
|
|
1734
|
-
break;
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1728
|
+
const val = std.mem.readInt(u128, &g.v, .big);
|
|
1729
|
+
std.mem.writeInt(u128, &g.v, val +% 1, .big);
|
|
1737
1730
|
}
|
|
1738
1731
|
|
|
1739
1732
|
// AES256_CTR_DRBG_Update(pd, &g.key, &g.v).
|
|
@@ -353,7 +353,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
353
353
|
if (record_len > tls.max_ciphertext_len) return error.TlsRecordOverflow;
|
|
354
354
|
const record_buffer = input.take(record_len) catch |err| switch (err) {
|
|
355
355
|
error.EndOfStream => return error.TlsConnectionTruncated,
|
|
356
|
-
error.ReadFailed => return
|
|
356
|
+
error.ReadFailed => |e| return e,
|
|
357
357
|
};
|
|
358
358
|
var record_decoder: tls.Decoder = .fromTheirSlice(record_buffer);
|
|
359
359
|
var ctd, const ct = content: switch (cipher_state) {
|
|
@@ -382,7 +382,9 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
382
382
|
P.AEAD.decrypt(cleartext, ciphertext, auth_tag, record_header, nonce, pv.server_handshake_key) catch
|
|
383
383
|
return error.TlsBadRecordMac;
|
|
384
384
|
// TODO use scalar, non-slice version
|
|
385
|
-
|
|
385
|
+
const trimmed_len = mem.trimEnd(u8, cleartext, "\x00").len;
|
|
386
|
+
if (trimmed_len == 0) return error.TlsDecodeError;
|
|
387
|
+
cleartext_fragment_end += trimmed_len;
|
|
386
388
|
},
|
|
387
389
|
}
|
|
388
390
|
read_seq += 1;
|
|
@@ -1155,7 +1157,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
|
|
|
1155
1157
|
return failRead(c, error.TlsConnectionTruncated);
|
|
1156
1158
|
}
|
|
1157
1159
|
},
|
|
1158
|
-
error.ReadFailed => return
|
|
1160
|
+
error.ReadFailed => |e| return e,
|
|
1159
1161
|
};
|
|
1160
1162
|
const ct: tls.ContentType = @enumFromInt(record_header[0]);
|
|
1161
1163
|
const legacy_version = mem.readInt(u16, record_header[1..][0..2], .big);
|
|
@@ -1166,7 +1168,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
|
|
|
1166
1168
|
if (record_end > input.buffered().len) {
|
|
1167
1169
|
input.fillMore() catch |err| switch (err) {
|
|
1168
1170
|
error.EndOfStream => return failRead(c, error.TlsConnectionTruncated),
|
|
1169
|
-
error.ReadFailed => return
|
|
1171
|
+
error.ReadFailed => |e| return e,
|
|
1170
1172
|
};
|
|
1171
1173
|
if (record_end > input.buffered().len) return 0;
|
|
1172
1174
|
}
|
|
@@ -1176,6 +1178,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
|
|
|
1176
1178
|
.tls_1_3 => {
|
|
1177
1179
|
const pv = &p.tls_1_3;
|
|
1178
1180
|
const P = @TypeOf(p.*);
|
|
1181
|
+
if (record_len < P.AEAD.tag_length) return failRead(c, error.TlsRecordOverflow);
|
|
1179
1182
|
const ad = input.take(tls.record_header_len) catch unreachable; // already peeked
|
|
1180
1183
|
const ciphertext_len = record_len - P.AEAD.tag_length;
|
|
1181
1184
|
const ciphertext = input.take(ciphertext_len) catch unreachable; // already peeked
|
|
@@ -1192,6 +1195,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
|
|
|
1192
1195
|
return failRead(c, error.TlsBadRecordMac);
|
|
1193
1196
|
// TODO use scalar, non-slice version
|
|
1194
1197
|
const msg = mem.trimEnd(u8, cleartext, "\x00");
|
|
1198
|
+
if (msg.len == 0) return failRead(c, error.TlsDecodeError);
|
|
1195
1199
|
break :cleartext .{ msg.len - 1, @enumFromInt(msg[msg.len - 1]) };
|
|
1196
1200
|
},
|
|
1197
1201
|
.tls_1_2 => {
|
|
@@ -1668,3 +1672,74 @@ else
|
|
|
1668
1672
|
.AES_256_GCM_SHA384,
|
|
1669
1673
|
.ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
|
1670
1674
|
});
|
|
1675
|
+
|
|
1676
|
+
fn testReadError(input_buf: []const u8, cipher: tls.ApplicationCipher) ReadError {
|
|
1677
|
+
var input_reader: Reader = .fixed(input_buf);
|
|
1678
|
+
var read_buf: [tls.max_ciphertext_record_len]u8 = undefined;
|
|
1679
|
+
var c: Client = .{
|
|
1680
|
+
.input = &input_reader,
|
|
1681
|
+
.reader = .{
|
|
1682
|
+
.buffer = &read_buf,
|
|
1683
|
+
.vtable = &.{ .stream = stream, .readVec = readVec },
|
|
1684
|
+
.seek = 0,
|
|
1685
|
+
.end = 0,
|
|
1686
|
+
},
|
|
1687
|
+
.output = undefined,
|
|
1688
|
+
.writer = undefined,
|
|
1689
|
+
.tls_version = .tls_1_3,
|
|
1690
|
+
.read_seq = 0,
|
|
1691
|
+
.write_seq = 0,
|
|
1692
|
+
.received_close_notify = false,
|
|
1693
|
+
.allow_truncation_attacks = false,
|
|
1694
|
+
.application_cipher = cipher,
|
|
1695
|
+
.ssl_key_log = null,
|
|
1696
|
+
};
|
|
1697
|
+
var w: Writer = .failing;
|
|
1698
|
+
std.testing.expectError(error.ReadFailed, c.reader.stream(&w, .unlimited)) catch
|
|
1699
|
+
@panic("expected ReadFailed");
|
|
1700
|
+
return c.read_err.?;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
test "empty inner plaintext" {
|
|
1704
|
+
const AEAD = crypto.aead.chacha_poly.ChaCha20Poly1305;
|
|
1705
|
+
const key: [AEAD.key_length]u8 = @splat(0);
|
|
1706
|
+
const iv: [AEAD.nonce_length]u8 = @splat(0);
|
|
1707
|
+
|
|
1708
|
+
const plaintext = [1]u8{0x00};
|
|
1709
|
+
var ciphertext: [plaintext.len]u8 = undefined;
|
|
1710
|
+
var tag: [AEAD.tag_length]u8 = undefined;
|
|
1711
|
+
const content_len: u16 = plaintext.len + AEAD.tag_length;
|
|
1712
|
+
const record_header = [_]u8{ 0x17, 0x03, 0x03 } ++ mem.toBytes(big(content_len));
|
|
1713
|
+
AEAD.encrypt(&ciphertext, &tag, &plaintext, &record_header, iv, key);
|
|
1714
|
+
|
|
1715
|
+
try std.testing.expectEqual(error.TlsDecodeError, testReadError(
|
|
1716
|
+
&record_header ++ ciphertext ++ tag,
|
|
1717
|
+
.{ .CHACHA20_POLY1305_SHA256 = .{ .tls_1_3 = .{
|
|
1718
|
+
.server_key = key,
|
|
1719
|
+
.server_iv = iv,
|
|
1720
|
+
.client_secret = undefined,
|
|
1721
|
+
.server_secret = undefined,
|
|
1722
|
+
.client_key = undefined,
|
|
1723
|
+
.client_iv = undefined,
|
|
1724
|
+
} } },
|
|
1725
|
+
));
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
test "record shorter than tag" {
|
|
1729
|
+
const AEAD = crypto.aead.chacha_poly.ChaCha20Poly1305;
|
|
1730
|
+
const record_len: u16 = AEAD.tag_length - 1;
|
|
1731
|
+
const header = [_]u8{ 0x17, 0x03, 0x03 } ++ mem.toBytes(big(record_len));
|
|
1732
|
+
const wire = header ++ @as([record_len]u8, @splat(0));
|
|
1733
|
+
|
|
1734
|
+
try std.testing.expectEqual(error.TlsRecordOverflow, testReadError(
|
|
1735
|
+
&wire,
|
|
1736
|
+
.{ .CHACHA20_POLY1305_SHA256 = .{ .tls_1_3 = .{
|
|
1737
|
+
.server_key = undefined,
|
|
1738
|
+
.server_iv = undefined,
|
|
1739
|
+
.client_secret = undefined,
|
|
1740
|
+
.server_secret = undefined,
|
|
1741
|
+
.client_key = undefined,
|
|
1742
|
+
.client_iv = undefined,
|
|
1743
|
+
} } },
|
|
1744
|
+
));
|
|
1745
|
+
}
|
package/std/crypto/tls.zig
CHANGED
|
@@ -666,7 +666,7 @@ pub const Decoder = struct {
|
|
|
666
666
|
if (request_amt > dest.len) return error.TlsRecordOverflow;
|
|
667
667
|
stream.readSlice(dest[0..request_amt]) catch |err| switch (err) {
|
|
668
668
|
error.EndOfStream => return error.TlsConnectionTruncated,
|
|
669
|
-
error.ReadFailed => return
|
|
669
|
+
error.ReadFailed => |e| return e,
|
|
670
670
|
};
|
|
671
671
|
d.cap += request_amt;
|
|
672
672
|
}
|
package/std/crypto.zig
CHANGED
package/std/debug/Pdb.zig
CHANGED
|
@@ -138,7 +138,7 @@ pub fn parseDbiStream(self: *Pdb) !void {
|
|
|
138
138
|
if (section_contrib_size != 0) {
|
|
139
139
|
const version = reader.takeEnum(pdb.SectionContrSubstreamVersion, .little) catch |err| switch (err) {
|
|
140
140
|
error.InvalidEnumTag, error.EndOfStream => return error.InvalidDebugInfo,
|
|
141
|
-
error.ReadFailed => return
|
|
141
|
+
error.ReadFailed => |e| return e,
|
|
142
142
|
};
|
|
143
143
|
_ = version;
|
|
144
144
|
sect_cont_offset += @sizeOf(u32);
|
package/std/debug.zig
CHANGED
|
@@ -1197,8 +1197,9 @@ fn printSourceAtAddress(
|
|
|
1197
1197
|
|
|
1198
1198
|
// Initialize the symbol array with space for at least one element, allocating this on the stack
|
|
1199
1199
|
// in the common case where only one element is needed
|
|
1200
|
-
var
|
|
1201
|
-
|
|
1200
|
+
var buf: [1]Symbol = undefined;
|
|
1201
|
+
var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&buf), getDebugInfoAllocator());
|
|
1202
|
+
const symbol_allocator = bfa.allocator();
|
|
1202
1203
|
var symbols = std.ArrayList(Symbol).initCapacity(symbol_allocator, 1) catch unreachable;
|
|
1203
1204
|
defer symbols.deinit(symbol_allocator);
|
|
1204
1205
|
|
|
@@ -1576,12 +1577,12 @@ fn handleSegfaultPosix(sig: posix.SIG, info: *const posix.siginfo_t, ctx_ptr: ?*
|
|
|
1576
1577
|
.tvos,
|
|
1577
1578
|
.visionos,
|
|
1578
1579
|
.watchos,
|
|
1580
|
+
.haiku,
|
|
1579
1581
|
=> @intFromPtr(info.addr),
|
|
1580
1582
|
.linux,
|
|
1581
1583
|
=> @intFromPtr(info.fields.sigfault.addr),
|
|
1582
1584
|
.netbsd,
|
|
1583
1585
|
=> @intFromPtr(info.info.reason.fault.addr),
|
|
1584
|
-
.haiku,
|
|
1585
1586
|
.openbsd,
|
|
1586
1587
|
=> @intFromPtr(info.data.fault.addr),
|
|
1587
1588
|
.illumos,
|