@zigc/lib 0.15.0-dev.0 → 0.15.1
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/README.md +1 -5
- package/build-web/fuzz.zig +6 -6
- package/build-web/time_report.zig +13 -14
- package/compiler/reduce/Walk.zig +9 -10
- package/compiler/reduce.zig +20 -19
- package/compiler/resinator/compile.zig +1 -1
- package/compiler_rt/arm.zig +1 -1
- package/init/build.zig +1 -1
- package/libc/freebsd/lib/csu/aarch64/crt.h +1 -0
- package/libc/freebsd/lib/csu/aarch64/crt1_c.c +33 -0
- package/libc/freebsd/lib/csu/aarch64/crt1_s.S +68 -0
- package/libc/freebsd/lib/csu/amd64/crt.h +30 -0
- package/libc/freebsd/lib/csu/amd64/crt1_c.c +30 -0
- package/libc/freebsd/lib/csu/amd64/crt1_s.S +89 -0
- package/libc/freebsd/lib/csu/arm/crt.h +1 -0
- package/libc/freebsd/lib/csu/arm/crt1_c.c +80 -0
- package/libc/freebsd/lib/csu/arm/crt1_s.S +77 -0
- package/libc/freebsd/lib/csu/common/crtbegin.c +95 -0
- package/libc/freebsd/lib/csu/common/crtbrand.S +55 -0
- package/libc/freebsd/lib/csu/common/crtend.c +65 -0
- package/libc/freebsd/lib/csu/common/csu_common.h +50 -0
- package/libc/freebsd/lib/csu/common/feature_note.S +47 -0
- package/libc/freebsd/lib/csu/common/ignore_init_note.S +48 -0
- package/libc/freebsd/lib/csu/common/notes.h +32 -0
- package/libc/freebsd/lib/csu/i386/crt.h +30 -0
- package/libc/freebsd/lib/csu/i386/crt1_c.c +30 -0
- package/libc/freebsd/lib/csu/i386/crt1_s.S +91 -0
- package/libc/freebsd/lib/csu/powerpc/crt.h +31 -0
- package/libc/freebsd/lib/csu/powerpc/crt1_c.c +89 -0
- package/libc/freebsd/lib/csu/powerpc/crtsavres.S +189 -0
- package/libc/freebsd/lib/csu/powerpc64/crt.h +31 -0
- package/libc/freebsd/lib/csu/powerpc64/crt1_c.c +83 -0
- package/libc/freebsd/lib/csu/riscv/crt.h +8 -0
- package/libc/freebsd/lib/csu/riscv/crt1_c.c +51 -0
- package/libc/freebsd/lib/csu/riscv/crt1_s.S +51 -0
- package/libc/freebsd/lib/libc/include/libc_private.h +450 -0
- package/libc/include/generic-glibc/arpa/inet.h +0 -3
- package/libc/netbsd/lib/csu/arch/aarch64/crt0.S +45 -0
- package/libc/netbsd/lib/csu/arch/earm/crt0.S +61 -0
- package/libc/netbsd/lib/csu/arch/i386/crt0.S +48 -0
- package/libc/netbsd/lib/csu/arch/m68k/crt0.S +47 -0
- package/libc/netbsd/lib/csu/arch/mips/crt0.S +59 -0
- package/libc/netbsd/lib/csu/arch/powerpc/crt0.S +56 -0
- package/libc/netbsd/lib/csu/arch/sparc/crt0.S +55 -0
- package/libc/netbsd/lib/csu/arch/sparc64/crt0.S +59 -0
- package/libc/netbsd/lib/csu/arch/x86_64/crt0.S +48 -0
- package/libc/netbsd/lib/csu/common/crt0-common.c +351 -0
- package/libc/netbsd/lib/csu/common/crtbegin.c +135 -0
- package/libc/netbsd/lib/csu/common/csu-common.h +38 -0
- package/libc/netbsd/lib/csu/common/sysident.S +89 -0
- package/libc/netbsd/lib/csu/common/sysident_assym.h +17 -0
- package/package.json +2 -2
- package/std/Build/Step/Compile.zig +1 -20
- package/std/Build/Step/TranslateC.zig +0 -6
- package/std/Build/WebServer.zig +1 -1
- package/std/Build.zig +1 -4
- package/std/Io/Reader/Limited.zig +0 -44
- package/std/Io/Reader.zig +28 -128
- package/std/Io/Writer.zig +6 -31
- package/std/Target.zig +0 -8
- package/std/Thread.zig +4 -3
- package/std/c.zig +26 -87
- package/std/crypto/aes_ocb.zig +3 -32
- package/std/crypto/tls/Client.zig +8 -19
- package/std/debug.zig +1 -1
- package/std/fs/Dir.zig +1 -2
- package/std/fs/File.zig +104 -105
- package/std/http/Client.zig +2 -3
- package/std/json/static.zig +3 -3
- package/std/math/big/int.zig +4 -3
- package/std/math/powi.zig +0 -1
- package/std/mem/Allocator.zig +1 -3
- package/std/mem.zig +1 -3
- package/std/net.zig +2 -3
- package/std/os/linux/bpf.zig +2 -2
- package/std/os/linux/powerpc.zig +12 -74
- package/std/os/linux/powerpc64.zig +12 -74
- package/std/os/linux.zig +2 -7
- package/std/os/uefi/protocol/service_binding.zig +1 -1
- package/std/os/uefi/tables.zig +1 -1
- package/std/pie.zig +1 -1
- package/std/posix.zig +4 -6
- package/std/process/Child.zig +1 -5
- package/std/process.zig +2 -16
- package/std/sort/pdq.zig +1 -48
- package/std/testing.zig +0 -60
- package/std/zig/llvm/BitcodeReader.zig +1 -5
- package/std/zig/system/linux.zig +4 -1
- package/std/zig/system.zig +2 -3
- package/std/zon/parse.zig +0 -1
- package/ubsan_rt.zig +3 -3
- package/libc/musl/src/fenv/loongarch64/fenv-sf.c +0 -3
package/std/Io/Writer.zig
CHANGED
|
@@ -917,12 +917,10 @@ pub fn sendFileHeader(
|
|
|
917
917
|
return n;
|
|
918
918
|
}
|
|
919
919
|
|
|
920
|
-
/// Asserts nonzero buffer capacity
|
|
920
|
+
/// Asserts nonzero buffer capacity.
|
|
921
921
|
pub fn sendFileReading(w: *Writer, file_reader: *File.Reader, limit: Limit) FileReadingError!usize {
|
|
922
|
-
assert(limit != .nothing);
|
|
923
922
|
const dest = limit.slice(try w.writableSliceGreedy(1));
|
|
924
|
-
const n = try file_reader.
|
|
925
|
-
if (n == 0) return error.EndOfStream;
|
|
923
|
+
const n = try file_reader.read(dest);
|
|
926
924
|
w.advance(n);
|
|
927
925
|
return n;
|
|
928
926
|
}
|
|
@@ -2657,8 +2655,7 @@ pub const Allocating = struct {
|
|
|
2657
2655
|
if (additional == 0) return error.EndOfStream;
|
|
2658
2656
|
list.ensureUnusedCapacity(gpa, limit.minInt64(additional)) catch return error.WriteFailed;
|
|
2659
2657
|
const dest = limit.slice(list.unusedCapacitySlice());
|
|
2660
|
-
const n = try file_reader.
|
|
2661
|
-
if (n == 0) return error.EndOfStream;
|
|
2658
|
+
const n = try file_reader.read(dest);
|
|
2662
2659
|
list.items.len += n;
|
|
2663
2660
|
return n;
|
|
2664
2661
|
}
|
|
@@ -2717,40 +2714,18 @@ test "allocating sendFile" {
|
|
|
2717
2714
|
|
|
2718
2715
|
const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true });
|
|
2719
2716
|
defer file.close();
|
|
2720
|
-
var r_buffer: [
|
|
2717
|
+
var r_buffer: [256]u8 = undefined;
|
|
2721
2718
|
var file_writer: std.fs.File.Writer = .init(file, &r_buffer);
|
|
2722
|
-
try file_writer.interface.
|
|
2719
|
+
try file_writer.interface.writeByte('h');
|
|
2723
2720
|
try file_writer.interface.flush();
|
|
2724
2721
|
|
|
2725
2722
|
var file_reader = file_writer.moveToReader();
|
|
2726
2723
|
try file_reader.seekTo(0);
|
|
2727
|
-
try file_reader.interface.fill(2);
|
|
2728
2724
|
|
|
2729
2725
|
var allocating: Writer.Allocating = .init(testing.allocator);
|
|
2730
2726
|
defer allocating.deinit();
|
|
2731
|
-
try allocating.ensureUnusedCapacity(1);
|
|
2732
|
-
try testing.expectEqual(4, allocating.writer.sendFileAll(&file_reader, .unlimited));
|
|
2733
|
-
try testing.expectEqualStrings("abcd", allocating.writer.buffered());
|
|
2734
|
-
}
|
|
2735
|
-
|
|
2736
|
-
test sendFileReading {
|
|
2737
|
-
var tmp_dir = testing.tmpDir(.{});
|
|
2738
|
-
defer tmp_dir.cleanup();
|
|
2739
|
-
|
|
2740
|
-
const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true });
|
|
2741
|
-
defer file.close();
|
|
2742
|
-
var r_buffer: [2]u8 = undefined;
|
|
2743
|
-
var file_writer: std.fs.File.Writer = .init(file, &r_buffer);
|
|
2744
|
-
try file_writer.interface.writeAll("abcd");
|
|
2745
|
-
try file_writer.interface.flush();
|
|
2746
2727
|
|
|
2747
|
-
|
|
2748
|
-
try file_reader.seekTo(0);
|
|
2749
|
-
try file_reader.interface.fill(2);
|
|
2750
|
-
|
|
2751
|
-
var w_buffer: [1]u8 = undefined;
|
|
2752
|
-
var discarding: Writer.Discarding = .init(&w_buffer);
|
|
2753
|
-
try testing.expectEqual(4, discarding.writer.sendFileReadingAll(&file_reader, .unlimited));
|
|
2728
|
+
_ = try file_reader.interface.streamRemaining(&allocating.writer);
|
|
2754
2729
|
}
|
|
2755
2730
|
|
|
2756
2731
|
test writeStruct {
|
package/std/Target.zig
CHANGED
|
@@ -3075,10 +3075,6 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
|
|
|
3075
3075
|
},
|
|
3076
3076
|
else => {},
|
|
3077
3077
|
},
|
|
3078
|
-
.m68k => switch (c_type) {
|
|
3079
|
-
.int, .uint, .long, .ulong => return 2,
|
|
3080
|
-
else => {},
|
|
3081
|
-
},
|
|
3082
3078
|
.powerpc, .powerpcle, .powerpc64, .powerpc64le => switch (target.os.tag) {
|
|
3083
3079
|
.aix => switch (c_type) {
|
|
3084
3080
|
.double, .longdouble => return 4,
|
|
@@ -3179,10 +3175,6 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
|
|
|
3179
3175
|
else => {},
|
|
3180
3176
|
},
|
|
3181
3177
|
},
|
|
3182
|
-
.m68k => switch (c_type) {
|
|
3183
|
-
.int, .uint, .long, .ulong => return 2,
|
|
3184
|
-
else => {},
|
|
3185
|
-
},
|
|
3186
3178
|
.wasm32, .wasm64 => switch (target.os.tag) {
|
|
3187
3179
|
.emscripten => switch (c_type) {
|
|
3188
3180
|
.longdouble => return 8,
|
package/std/Thread.zig
CHANGED
package/std/c.zig
CHANGED
|
@@ -2235,70 +2235,40 @@ pub const S = switch (native_os) {
|
|
|
2235
2235
|
}
|
|
2236
2236
|
},
|
|
2237
2237
|
.dragonfly => struct {
|
|
2238
|
-
pub const IFMT = 0o170000;
|
|
2239
|
-
|
|
2240
|
-
pub const IFIFO = 0o010000;
|
|
2241
|
-
pub const IFCHR = 0o020000;
|
|
2242
|
-
pub const IFDIR = 0o040000;
|
|
2243
|
-
pub const IFBLK = 0o060000;
|
|
2244
|
-
pub const IFREG = 0o100000;
|
|
2245
|
-
pub const IFLNK = 0o120000;
|
|
2246
|
-
pub const IFSOCK = 0o140000;
|
|
2247
|
-
pub const IFWHT = 0o160000;
|
|
2248
|
-
|
|
2249
|
-
pub const ISUID = 0o4000;
|
|
2250
|
-
pub const ISGID = 0o2000;
|
|
2251
|
-
pub const ISVTX = 0o1000;
|
|
2252
|
-
pub const IRWXU = 0o700;
|
|
2253
|
-
pub const IRUSR = 0o400;
|
|
2254
|
-
pub const IWUSR = 0o200;
|
|
2255
|
-
pub const IXUSR = 0o100;
|
|
2256
|
-
pub const IRWXG = 0o070;
|
|
2257
|
-
pub const IRGRP = 0o040;
|
|
2258
|
-
pub const IWGRP = 0o020;
|
|
2259
|
-
pub const IXGRP = 0o010;
|
|
2260
|
-
pub const IRWXO = 0o007;
|
|
2261
|
-
pub const IROTH = 0o004;
|
|
2262
|
-
pub const IWOTH = 0o002;
|
|
2263
|
-
pub const IXOTH = 0o001;
|
|
2264
|
-
|
|
2265
2238
|
pub const IREAD = IRUSR;
|
|
2266
2239
|
pub const IEXEC = IXUSR;
|
|
2267
2240
|
pub const IWRITE = IWUSR;
|
|
2241
|
+
pub const IXOTH = 1;
|
|
2242
|
+
pub const IWOTH = 2;
|
|
2243
|
+
pub const IROTH = 4;
|
|
2244
|
+
pub const IRWXO = 7;
|
|
2245
|
+
pub const IXGRP = 8;
|
|
2246
|
+
pub const IWGRP = 16;
|
|
2247
|
+
pub const IRGRP = 32;
|
|
2248
|
+
pub const IRWXG = 56;
|
|
2249
|
+
pub const IXUSR = 64;
|
|
2250
|
+
pub const IWUSR = 128;
|
|
2251
|
+
pub const IRUSR = 256;
|
|
2252
|
+
pub const IRWXU = 448;
|
|
2268
2253
|
pub const ISTXT = 512;
|
|
2269
2254
|
pub const BLKSIZE = 512;
|
|
2270
|
-
|
|
2271
|
-
pub
|
|
2272
|
-
|
|
2273
|
-
|
|
2255
|
+
pub const ISVTX = 512;
|
|
2256
|
+
pub const ISGID = 1024;
|
|
2257
|
+
pub const ISUID = 2048;
|
|
2258
|
+
pub const IFIFO = 4096;
|
|
2259
|
+
pub const IFCHR = 8192;
|
|
2260
|
+
pub const IFDIR = 16384;
|
|
2261
|
+
pub const IFBLK = 24576;
|
|
2262
|
+
pub const IFREG = 32768;
|
|
2263
|
+
pub const IFDB = 36864;
|
|
2264
|
+
pub const IFLNK = 40960;
|
|
2265
|
+
pub const IFSOCK = 49152;
|
|
2266
|
+
pub const IFWHT = 57344;
|
|
2267
|
+
pub const IFMT = 61440;
|
|
2274
2268
|
|
|
2275
2269
|
pub fn ISCHR(m: u32) bool {
|
|
2276
2270
|
return m & IFMT == IFCHR;
|
|
2277
2271
|
}
|
|
2278
|
-
|
|
2279
|
-
pub fn ISDIR(m: u32) bool {
|
|
2280
|
-
return m & IFMT == IFDIR;
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
pub fn ISBLK(m: u32) bool {
|
|
2284
|
-
return m & IFMT == IFBLK;
|
|
2285
|
-
}
|
|
2286
|
-
|
|
2287
|
-
pub fn ISREG(m: u32) bool {
|
|
2288
|
-
return m & IFMT == IFREG;
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2291
|
-
pub fn ISLNK(m: u32) bool {
|
|
2292
|
-
return m & IFMT == IFLNK;
|
|
2293
|
-
}
|
|
2294
|
-
|
|
2295
|
-
pub fn ISSOCK(m: u32) bool {
|
|
2296
|
-
return m & IFMT == IFSOCK;
|
|
2297
|
-
}
|
|
2298
|
-
|
|
2299
|
-
pub fn IWHT(m: u32) bool {
|
|
2300
|
-
return m & IFMT == IFWHT;
|
|
2301
|
-
}
|
|
2302
2272
|
},
|
|
2303
2273
|
.haiku => struct {
|
|
2304
2274
|
pub const IFMT = 0o170000;
|
|
@@ -3121,17 +3091,8 @@ pub const SIG = switch (native_os) {
|
|
|
3121
3091
|
pub const UNBLOCK = 2;
|
|
3122
3092
|
pub const SETMASK = 3;
|
|
3123
3093
|
},
|
|
3124
|
-
// https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal.h
|
|
3125
3094
|
// https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h
|
|
3126
3095
|
.serenity => struct {
|
|
3127
|
-
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
|
|
3128
|
-
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
|
|
3129
|
-
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
|
|
3130
|
-
|
|
3131
|
-
pub const BLOCK = 1;
|
|
3132
|
-
pub const UNBLOCK = 2;
|
|
3133
|
-
pub const SETMASK = 3;
|
|
3134
|
-
|
|
3135
3096
|
pub const INVAL = 0;
|
|
3136
3097
|
pub const HUP = 1;
|
|
3137
3098
|
pub const INT = 2;
|
|
@@ -5724,23 +5685,6 @@ pub const MSG = switch (native_os) {
|
|
|
5724
5685
|
pub const WAITFORONE = 0x2000;
|
|
5725
5686
|
pub const NOTIFICATION = 0x4000;
|
|
5726
5687
|
},
|
|
5727
|
-
// https://github.com/openbsd/src/blob/42a7be81bef70c04732f45ec573622effe56b563/sys/sys/socket.h#L506
|
|
5728
|
-
.openbsd => struct {
|
|
5729
|
-
pub const OOB = 0x1;
|
|
5730
|
-
pub const PEEK = 0x2;
|
|
5731
|
-
pub const DONTROUTE = 0x4;
|
|
5732
|
-
pub const EOR = 0x8;
|
|
5733
|
-
pub const TRUNC = 0x10;
|
|
5734
|
-
pub const CTRUNC = 0x20;
|
|
5735
|
-
pub const WAITALL = 0x40;
|
|
5736
|
-
pub const DONTWAIT = 0x80;
|
|
5737
|
-
pub const BCAST = 0x100;
|
|
5738
|
-
pub const MCAST = 0x200;
|
|
5739
|
-
pub const NOSIGNAL = 0x400;
|
|
5740
|
-
pub const CMSG_CLOEXEC = 0x800;
|
|
5741
|
-
pub const WAITFORONE = 0x1000;
|
|
5742
|
-
pub const CMSG_CLOFORK = 0x2000;
|
|
5743
|
-
},
|
|
5744
5688
|
else => void,
|
|
5745
5689
|
};
|
|
5746
5690
|
pub const SOCK = switch (native_os) {
|
|
@@ -6720,12 +6664,7 @@ pub const SOMAXCONN = switch (native_os) {
|
|
|
6720
6664
|
.windows => ws2_32.SOMAXCONN,
|
|
6721
6665
|
// https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L128
|
|
6722
6666
|
.solaris, .illumos, .serenity => 128,
|
|
6723
|
-
|
|
6724
|
-
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/fd3d1949d526ffa646e57037770acd6f2f3bb617/sys/sys/socket.h#L393
|
|
6725
|
-
// https://github.com/NetBSD/src/blob/a673fb3f8487e974c669216064f7588207229fea/sys/sys/socket.h#L472
|
|
6726
|
-
// https://github.com/openbsd/src/blob/8ba9cd88f10123fef7af805b8e5ccc2463ad8fa4/sys/sys/socket.h#L483
|
|
6727
|
-
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L815
|
|
6728
|
-
.freebsd, .dragonfly, .netbsd, .openbsd, .driverkit, .macos, .ios, .tvos, .watchos, .visionos => 128,
|
|
6667
|
+
.openbsd => 28,
|
|
6729
6668
|
else => void,
|
|
6730
6669
|
};
|
|
6731
6670
|
pub const IFNAMESIZE = switch (native_os) {
|
package/std/crypto/aes_ocb.zig
CHANGED
|
@@ -155,12 +155,12 @@ fn AesOcb(comptime Aes: anytype) type {
|
|
|
155
155
|
xorWith(&offset, lx.star);
|
|
156
156
|
var pad = offset;
|
|
157
157
|
aes_enc_ctx.encrypt(&pad, &pad);
|
|
158
|
-
var e = [_]u8{0} ** 16;
|
|
159
|
-
@memcpy(e[0..leftover], m[i * 16 ..][0..leftover]);
|
|
160
|
-
e[leftover] = 0x80;
|
|
161
158
|
for (m[i * 16 ..], 0..) |x, j| {
|
|
162
159
|
c[i * 16 + j] = pad[j] ^ x;
|
|
163
160
|
}
|
|
161
|
+
var e = [_]u8{0} ** 16;
|
|
162
|
+
@memcpy(e[0..leftover], m[i * 16 ..][0..leftover]);
|
|
163
|
+
e[leftover] = 0x80;
|
|
164
164
|
xorWith(&sum, e);
|
|
165
165
|
}
|
|
166
166
|
var e = xorBlocks(xorBlocks(sum, offset), lx.dol);
|
|
@@ -354,32 +354,3 @@ test "AesOcb test vector 4" {
|
|
|
354
354
|
try Aes128Ocb.decrypt(&m2, &c, tag, &ad, nonce, k);
|
|
355
355
|
assert(mem.eql(u8, &m, &m2));
|
|
356
356
|
}
|
|
357
|
-
|
|
358
|
-
test "AesOcb in-place encryption-decryption" {
|
|
359
|
-
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
|
360
|
-
|
|
361
|
-
var k: [Aes128Ocb.key_length]u8 = undefined;
|
|
362
|
-
var nonce: [Aes128Ocb.nonce_length]u8 = undefined;
|
|
363
|
-
var tag: [Aes128Ocb.tag_length]u8 = undefined;
|
|
364
|
-
var m: [40]u8 = undefined;
|
|
365
|
-
var original_m: [m.len]u8 = undefined;
|
|
366
|
-
_ = try hexToBytes(&k, "000102030405060708090A0B0C0D0E0F");
|
|
367
|
-
_ = try hexToBytes(&m, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627");
|
|
368
|
-
_ = try hexToBytes(&nonce, "BBAA9988776655443322110D");
|
|
369
|
-
const ad = m;
|
|
370
|
-
|
|
371
|
-
@memcpy(&original_m, &m);
|
|
372
|
-
|
|
373
|
-
Aes128Ocb.encrypt(&m, &tag, &m, &ad, nonce, k);
|
|
374
|
-
|
|
375
|
-
var expected_c: [m.len]u8 = undefined;
|
|
376
|
-
var expected_tag: [tag.len]u8 = undefined;
|
|
377
|
-
_ = try hexToBytes(&expected_tag, "ED07BA06A4A69483A7035490C5769E60");
|
|
378
|
-
_ = try hexToBytes(&expected_c, "D5CA91748410C1751FF8A2F618255B68A0A12E093FF454606E59F9C1D0DDC54B65E8628E568BAD7A");
|
|
379
|
-
|
|
380
|
-
try testing.expectEqualSlices(u8, &expected_tag, &tag);
|
|
381
|
-
try testing.expectEqualSlices(u8, &expected_c, &m);
|
|
382
|
-
try Aes128Ocb.decrypt(&m, &m, tag, &ad, nonce, k);
|
|
383
|
-
|
|
384
|
-
try testing.expectEqualSlices(u8, &original_m, &m);
|
|
385
|
-
}
|
|
@@ -320,7 +320,6 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
320
320
|
var handshake_state: HandshakeState = .hello;
|
|
321
321
|
var handshake_cipher: tls.HandshakeCipher = undefined;
|
|
322
322
|
var main_cert_pub_key: CertificatePublicKey = undefined;
|
|
323
|
-
var tls12_negotiated_group: ?tls.NamedGroup = null;
|
|
324
323
|
const now_sec = std.time.timestamp();
|
|
325
324
|
|
|
326
325
|
var cleartext_fragment_start: usize = 0;
|
|
@@ -680,7 +679,6 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
680
679
|
const curve_type = hsd.decode(u8);
|
|
681
680
|
if (curve_type != 0x03) return error.TlsIllegalParameter; // named_curve
|
|
682
681
|
const named_group = hsd.decode(tls.NamedGroup);
|
|
683
|
-
tls12_negotiated_group = named_group;
|
|
684
682
|
const key_size = hsd.decode(u8);
|
|
685
683
|
try hsd.ensure(key_size);
|
|
686
684
|
const server_pub_key = hsd.slice(key_size);
|
|
@@ -693,19 +691,10 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
693
691
|
if (cipher_state != .cleartext) return error.TlsUnexpectedMessage;
|
|
694
692
|
if (handshake_state != .server_hello_done) return error.TlsUnexpectedMessage;
|
|
695
693
|
|
|
696
|
-
const
|
|
697
|
-
.secp256r1 => &key_share.secp256r1_kp.public_key.toUncompressedSec1(),
|
|
698
|
-
.secp384r1 => &key_share.secp384r1_kp.public_key.toUncompressedSec1(),
|
|
699
|
-
.x25519 => &key_share.x25519_kp.public_key,
|
|
700
|
-
else => return error.TlsIllegalParameter,
|
|
701
|
-
};
|
|
702
|
-
|
|
703
|
-
const client_key_exchange_prefix = .{@intFromEnum(tls.ContentType.handshake)} ++
|
|
694
|
+
const client_key_exchange_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
|
|
704
695
|
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
int(u24, @intCast(public_key_bytes.len + 1)) ++ // handshake message length
|
|
708
|
-
.{@as(u8, @intCast(public_key_bytes.len))}; // public key length
|
|
696
|
+
array(u16, u8, .{@intFromEnum(tls.HandshakeType.client_key_exchange)} ++
|
|
697
|
+
array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
|
|
709
698
|
const client_change_cipher_spec_msg = .{@intFromEnum(tls.ContentType.change_cipher_spec)} ++
|
|
710
699
|
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
|
711
700
|
array(u16, tls.ChangeCipherSpecType, .{.change_cipher_spec});
|
|
@@ -714,8 +703,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
714
703
|
inline else => |*p| {
|
|
715
704
|
const P = @TypeOf(p.*).A;
|
|
716
705
|
p.transcript_hash.update(wrapped_handshake);
|
|
717
|
-
p.transcript_hash.update(
|
|
718
|
-
p.transcript_hash.update(public_key_bytes);
|
|
706
|
+
p.transcript_hash.update(client_key_exchange_msg[tls.record_header_len..]);
|
|
719
707
|
const master_secret = hmacExpandLabel(P.Hmac, pre_master_secret, &.{
|
|
720
708
|
"master secret",
|
|
721
709
|
&client_hello_rand,
|
|
@@ -769,9 +757,8 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
769
757
|
nonce,
|
|
770
758
|
pv.app_cipher.client_write_key,
|
|
771
759
|
);
|
|
772
|
-
var all_msgs_vec: [
|
|
773
|
-
&
|
|
774
|
-
public_key_bytes,
|
|
760
|
+
var all_msgs_vec: [3][]const u8 = .{
|
|
761
|
+
&client_key_exchange_msg,
|
|
775
762
|
&client_change_cipher_spec_msg,
|
|
776
763
|
&client_verify_msg,
|
|
777
764
|
};
|
|
@@ -942,6 +929,7 @@ fn drain(w: *Writer, data: []const []const u8, splat: usize) Writer.Error!usize
|
|
|
942
929
|
if (prepared.cleartext_len < buf.len) break :done;
|
|
943
930
|
}
|
|
944
931
|
for (data[0 .. data.len - 1]) |buf| {
|
|
932
|
+
if (buf.len < min_buffer_len) break :done;
|
|
945
933
|
const prepared = prepareCiphertextRecord(c, ciphertext_buf[ciphertext_end..], buf, .application_data);
|
|
946
934
|
total_clear += prepared.cleartext_len;
|
|
947
935
|
ciphertext_end += prepared.ciphertext_end;
|
|
@@ -949,6 +937,7 @@ fn drain(w: *Writer, data: []const []const u8, splat: usize) Writer.Error!usize
|
|
|
949
937
|
}
|
|
950
938
|
const buf = data[data.len - 1];
|
|
951
939
|
for (0..splat) |_| {
|
|
940
|
+
if (buf.len < min_buffer_len) break :done;
|
|
952
941
|
const prepared = prepareCiphertextRecord(c, ciphertext_buf[ciphertext_end..], buf, .application_data);
|
|
953
942
|
total_clear += prepared.cleartext_len;
|
|
954
943
|
ciphertext_end += prepared.ciphertext_end;
|
package/std/debug.zig
CHANGED
|
@@ -569,7 +569,7 @@ pub fn assertReadable(slice: []const volatile u8) void {
|
|
|
569
569
|
/// Invokes detectable illegal behavior when the provided array is not aligned
|
|
570
570
|
/// to the provided amount.
|
|
571
571
|
pub fn assertAligned(ptr: anytype, comptime alignment: std.mem.Alignment) void {
|
|
572
|
-
const aligned_ptr: *align(alignment.toByteUnits())
|
|
572
|
+
const aligned_ptr: *align(alignment.toByteUnits()) anyopaque = @ptrCast(@alignCast(ptr));
|
|
573
573
|
_ = aligned_ptr;
|
|
574
574
|
}
|
|
575
575
|
|
package/std/fs/Dir.zig
CHANGED
|
@@ -2583,9 +2583,8 @@ pub fn updateFile(
|
|
|
2583
2583
|
error.ReadFailed => return src_reader.err.?,
|
|
2584
2584
|
error.WriteFailed => return atomic_file.file_writer.err.?,
|
|
2585
2585
|
};
|
|
2586
|
-
try atomic_file.flush();
|
|
2587
2586
|
try atomic_file.file_writer.file.updateTimes(src_stat.atime, src_stat.mtime);
|
|
2588
|
-
try atomic_file.
|
|
2587
|
+
try atomic_file.finish();
|
|
2589
2588
|
return .stale;
|
|
2590
2589
|
}
|
|
2591
2590
|
|