| author | |
| committer | |
| log | eaa6218f09d12fc84a29462f8287c0e6ecfd6739 |
| tree | b7d649de3f0f5185dbf2c5b75905edd33f271cf3 |
| parent | f5dbcd1cb4374be619ba0b18e40a069a7e860d93 |
This fixes issues targetting both `x86_64-linux` and `x86_64-macos` with
the self-hosted backend.5 files changed, 55 insertions(+), 24 deletions(-)
lib/std/crypto/Certificate/Bundle/macos.zig+2-2| ... | ... | @@ -21,7 +21,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { |
| 21 | 21 | const reader = stream.reader(); |
| 22 | 22 | |
| 23 | 23 | const db_header = try reader.readStructEndian(ApplDbHeader, .big); |
| 24 | assert(mem.eql(u8, "kych", &@as([4]u8, @bitCast(db_header.signature)))); | |
| 24 | assert(mem.eql(u8, &db_header.signature, "kych")); | |
| 25 | 25 | |
| 26 | 26 | try stream.seekTo(db_header.schema_offset); |
| 27 | 27 | |
| ... | ... | @@ -73,7 +73,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | const ApplDbHeader = extern struct { |
| 76 | signature: @Vector(4, u8), | |
| 76 | signature: [4]u8, | |
| 77 | 77 | version: u32, |
| 78 | 78 | header_size: u32, |
| 79 | 79 | schema_offset: u32, |
lib/std/crypto/tls/Client.zig+39-12| ... | ... | @@ -452,11 +452,20 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In |
| 452 | 452 | if (ciphertext.len > cleartext_buf.len) return error.TlsRecordOverflow; |
| 453 | 453 | const cleartext = cleartext_buf[0..ciphertext.len]; |
| 454 | 454 | const auth_tag = record_decoder.array(P.AEAD.tag_length).*; |
| 455 | const V = @Vector(P.AEAD.nonce_length, u8); | |
| 456 | const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8); | |
| 457 | const operand: V = pad ++ @as([8]u8, @bitCast(big(read_seq))); | |
| 455 | const nonce = if (builtin.zig_backend == .stage2_x86_64 and | |
| 456 | P.AEAD.nonce_length > comptime std.simd.suggestVectorLength(u8) orelse 1) | |
| 457 | nonce: { | |
| 458 | var nonce = p.server_handshake_iv; | |
| 459 | const operand = std.mem.readInt(u64, nonce[nonce.len - 8 ..], .big); | |
| 460 | std.mem.writeInt(u64, nonce[nonce.len - 8 ..], operand ^ read_seq, .big); | |
| 461 | break :nonce nonce; | |
| 462 | } else nonce: { | |
| 463 | const V = @Vector(P.AEAD.nonce_length, u8); | |
| 464 | const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8); | |
| 465 | const operand: V = pad ++ @as([8]u8, @bitCast(big(read_seq))); | |
| 466 | break :nonce @as(V, p.server_handshake_iv) ^ operand; | |
| 467 | }; | |
| 458 | 468 | read_seq += 1; |
| 459 | const nonce = @as(V, p.server_handshake_iv) ^ operand; | |
| 460 | 469 | P.AEAD.decrypt(cleartext, ciphertext, auth_tag, record_header, nonce, p.server_handshake_key) catch |
| 461 | 470 | return error.TlsBadRecordMac; |
| 462 | 471 | break :c cleartext; |
| ... | ... | @@ -806,7 +815,6 @@ fn prepareCiphertextRecord( |
| 806 | 815 | switch (c.application_cipher) { |
| 807 | 816 | inline else => |*p| { |
| 808 | 817 | const P = @TypeOf(p.*); |
| 809 | const V = @Vector(P.AEAD.nonce_length, u8); | |
| 810 | 818 | const overhead_len = tls.record_header_len + P.AEAD.tag_length + 1; |
| 811 | 819 | const close_notify_alert_reserved = tls.close_notify_alert.len + overhead_len; |
| 812 | 820 | while (true) { |
| ... | ... | @@ -838,10 +846,20 @@ fn prepareCiphertextRecord( |
| 838 | 846 | ciphertext_end += ciphertext_len; |
| 839 | 847 | const auth_tag = ciphertext_buf[ciphertext_end..][0..P.AEAD.tag_length]; |
| 840 | 848 | ciphertext_end += auth_tag.len; |
| 841 | const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8); | |
| 842 | const operand: V = pad ++ @as([8]u8, @bitCast(big(c.write_seq))); | |
| 849 | const nonce = if (builtin.zig_backend == .stage2_x86_64 and | |
| 850 | P.AEAD.nonce_length > comptime std.simd.suggestVectorLength(u8) orelse 1) | |
| 851 | nonce: { | |
| 852 | var nonce = p.client_iv; | |
| 853 | const operand = std.mem.readInt(u64, nonce[nonce.len - 8 ..], .big); | |
| 854 | std.mem.writeInt(u64, nonce[nonce.len - 8 ..], operand ^ c.write_seq, .big); | |
| 855 | break :nonce nonce; | |
| 856 | } else nonce: { | |
| 857 | const V = @Vector(P.AEAD.nonce_length, u8); | |
| 858 | const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8); | |
| 859 | const operand: V = pad ++ @as([8]u8, @bitCast(big(c.write_seq))); | |
| 860 | break :nonce @as(V, p.client_iv) ^ operand; | |
| 861 | }; | |
| 843 | 862 | c.write_seq += 1; // TODO send key_update on overflow |
| 844 | const nonce = @as(V, p.client_iv) ^ operand; | |
| 845 | 863 | P.AEAD.encrypt(ciphertext, auth_tag, cleartext, ad, nonce, p.client_key); |
| 846 | 864 | |
| 847 | 865 | const record = ciphertext_buf[record_start..ciphertext_end]; |
| ... | ... | @@ -1102,15 +1120,24 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec) |
| 1102 | 1120 | const cleartext = switch (c.application_cipher) { |
| 1103 | 1121 | inline else => |*p| c: { |
| 1104 | 1122 | const P = @TypeOf(p.*); |
| 1105 | const V = @Vector(P.AEAD.nonce_length, u8); | |
| 1106 | 1123 | const ad = frag[in - 5 ..][0..5]; |
| 1107 | 1124 | const ciphertext_len = record_len - P.AEAD.tag_length; |
| 1108 | 1125 | const ciphertext = frag[in..][0..ciphertext_len]; |
| 1109 | 1126 | in += ciphertext_len; |
| 1110 | 1127 | const auth_tag = frag[in..][0..P.AEAD.tag_length].*; |
| 1111 | const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8); | |
| 1112 | const operand: V = pad ++ @as([8]u8, @bitCast(big(c.read_seq))); | |
| 1113 | const nonce: [P.AEAD.nonce_length]u8 = @as(V, p.server_iv) ^ operand; | |
| 1128 | const nonce = if (builtin.zig_backend == .stage2_x86_64 and | |
| 1129 | P.AEAD.nonce_length > comptime std.simd.suggestVectorLength(u8) orelse 1) | |
| 1130 | nonce: { | |
| 1131 | var nonce = p.server_iv; | |
| 1132 | const operand = std.mem.readInt(u64, nonce[nonce.len - 8 ..], .big); | |
| 1133 | std.mem.writeInt(u64, nonce[nonce.len - 8 ..], operand ^ c.read_seq, .big); | |
| 1134 | break :nonce nonce; | |
| 1135 | } else nonce: { | |
| 1136 | const V = @Vector(P.AEAD.nonce_length, u8); | |
| 1137 | const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8); | |
| 1138 | const operand: V = pad ++ @as([8]u8, @bitCast(big(c.read_seq))); | |
| 1139 | break :nonce @as(V, p.server_iv) ^ operand; | |
| 1140 | }; | |
| 1114 | 1141 | const out_buf = vp.peek(); |
| 1115 | 1142 | const cleartext_buf = if (ciphertext.len <= out_buf.len) |
| 1116 | 1143 | out_buf |
src/Sema.zig+2-1| ... | ... | @@ -20136,6 +20136,7 @@ fn finishStructInit( |
| 20136 | 20136 | }, |
| 20137 | 20137 | else => |e| return e, |
| 20138 | 20138 | }; |
| 20139 | try sema.resolveStructFieldInits(struct_ty); | |
| 20139 | 20140 | try sema.queueFullTypeResolution(struct_ty); |
| 20140 | 20141 | const struct_val = try block.addAggregateInit(struct_ty, field_inits); |
| 20141 | 20142 | return sema.coerce(block, result_ty, struct_val, init_src); |
| ... | ... | @@ -35939,7 +35940,7 @@ pub fn resolveTypeFully(sema: *Sema, ty: Type) CompileError!void { |
| 35939 | 35940 | return sema.resolveTypeFully(ty.childType(mod)); |
| 35940 | 35941 | }, |
| 35941 | 35942 | .Struct => switch (mod.intern_pool.indexToKey(ty.toIntern())) { |
| 35942 | .struct_type => return sema.resolveStructFully(ty), | |
| 35943 | .struct_type => try sema.resolveStructFully(ty), | |
| 35943 | 35944 | .anon_struct_type => |tuple| { |
| 35944 | 35945 | for (tuple.types.get(ip)) |field_ty| { |
| 35945 | 35946 | try sema.resolveTypeFully(Type.fromInterned(field_ty)); |
src/TypedValue.zig+8-6| ... | ... | @@ -310,11 +310,6 @@ pub fn print( |
| 310 | 310 | return writer.writeAll(" }"); |
| 311 | 311 | }, |
| 312 | 312 | .ptr => |ptr| { |
| 313 | if (ptr.addr == .int) {} | |
| 314 | ||
| 315 | const ptr_ty = ip.indexToKey(ty.toIntern()).ptr_type; | |
| 316 | if (ptr_ty.flags.size == .Slice) {} | |
| 317 | ||
| 318 | 313 | switch (ptr.addr) { |
| 319 | 314 | .decl => |decl_index| { |
| 320 | 315 | const decl = mod.declPtr(decl_index); |
| ... | ... | @@ -348,7 +343,14 @@ pub fn print( |
| 348 | 343 | .val = Value.fromInterned(field_val_ip), |
| 349 | 344 | }, writer, level - 1, mod); |
| 350 | 345 | }, |
| 351 | .int => unreachable, | |
| 346 | .int => |int_ip| { | |
| 347 | try writer.writeAll("@ptrFromInt("); | |
| 348 | try print(.{ | |
| 349 | .ty = Type.usize, | |
| 350 | .val = Value.fromInterned(int_ip), | |
| 351 | }, writer, level - 1, mod); | |
| 352 | try writer.writeByte(')'); | |
| 353 | }, | |
| 352 | 354 | .eu_payload => |eu_ip| { |
| 353 | 355 | try writer.writeAll("(payload of "); |
| 354 | 356 | try print(.{ |
src/codegen/llvm/Builder.zig+4-3| ... | ... | @@ -9978,10 +9978,10 @@ fn fnTypeAssumeCapacity( |
| 9978 | 9978 | } |
| 9979 | 9979 | pub fn eql(ctx: @This(), lhs_key: Key, _: void, rhs_index: usize) bool { |
| 9980 | 9980 | const rhs_data = ctx.builder.type_items.items[rhs_index]; |
| 9981 | if (rhs_data.tag != tag) return false; | |
| 9981 | 9982 | var rhs_extra = ctx.builder.typeExtraDataTrail(Type.Function, rhs_data.data); |
| 9982 | 9983 | const rhs_params = rhs_extra.trail.next(rhs_extra.data.params_len, Type, ctx.builder); |
| 9983 | return rhs_data.tag == tag and lhs_key.ret == rhs_extra.data.ret and | |
| 9984 | std.mem.eql(Type, lhs_key.params, rhs_params); | |
| 9984 | return lhs_key.ret == rhs_extra.data.ret and std.mem.eql(Type, lhs_key.params, rhs_params); | |
| 9985 | 9985 | } |
| 9986 | 9986 | }; |
| 9987 | 9987 | const gop = self.type_map.getOrPutAssumeCapacityAdapted( |
| ... | ... | @@ -10161,9 +10161,10 @@ fn structTypeAssumeCapacity( |
| 10161 | 10161 | } |
| 10162 | 10162 | pub fn eql(ctx: @This(), lhs_key: []const Type, _: void, rhs_index: usize) bool { |
| 10163 | 10163 | const rhs_data = ctx.builder.type_items.items[rhs_index]; |
| 10164 | if (rhs_data.tag != tag) return false; | |
| 10164 | 10165 | var rhs_extra = ctx.builder.typeExtraDataTrail(Type.Structure, rhs_data.data); |
| 10165 | 10166 | const rhs_fields = rhs_extra.trail.next(rhs_extra.data.fields_len, Type, ctx.builder); |
| 10166 | return rhs_data.tag == tag and std.mem.eql(Type, lhs_key, rhs_fields); | |
| 10167 | return std.mem.eql(Type, lhs_key, rhs_fields); | |
| 10167 | 10168 | } |
| 10168 | 10169 | }; |
| 10169 | 10170 | const gop = self.type_map.getOrPutAssumeCapacityAdapted(fields, Adapter{ .builder = self }); |