| ... | @@ -11,6 +11,9 @@ const tracer = @import("tracer"); | ... | @@ -11,6 +11,9 @@ const tracer = @import("tracer"); |
| 11 | | 11 | |
| 12 | const sys = switch (builtin.target.os.tag) { | 12 | const sys = switch (builtin.target.os.tag) { |
| 13 | .linux => @import("sys-linux"), | 13 | .linux => @import("sys-linux"), |
| | 14 | .freebsd => @import("sys-freebsd"), |
| | 15 | .netbsd => @import("sys-netbsd"), |
| | 16 | .openbsd => @import("sys-openbsd"), |
| 14 | else => unreachable, | 17 | else => unreachable, |
| 15 | }; | 18 | }; |
| 16 | | 19 | |
| ... | @@ -37,8 +40,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver { | ... | @@ -37,8 +40,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver { |
| 37 | | 40 | |
| 38 | // https://github.com/postgres/postgres/blob/REL_18_0/src/include/common/scram-common.h#L32-L37 | 41 | // https://github.com/postgres/postgres/blob/REL_18_0/src/include/common/scram-common.h#L32-L37 |
| 39 | const nonce_len = 18; | 42 | const nonce_len = 18; |
| 40 | var cnonce_buf: [nonce_len]u8 = @splat(0); | 43 | const cnonce = nio.randomBytes(nonce_len); |
| 41 | var cnonce = try sys.getrandom(&cnonce_buf, 0); | | |
| 42 | _ = &cnonce; | 44 | _ = &cnonce; |
| 43 | | 45 | |
| 44 | var snonce_b64_buf: [128]u8 = @splat(0); | 46 | var snonce_b64_buf: [128]u8 = @splat(0); |
| ... | @@ -111,7 +113,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver { | ... | @@ -111,7 +113,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver { |
| 111 | // server-error-value = "invalid-encoding" / "extensions-not-supported" / "invalid-proof" / "channel-bindings-dont-match" / "server-does-support-channel-binding" / "channel-binding-not-supported" / "unsupported-channel-binding-type" / "unknown-user" / "invalid-username-encoding" / "no-resources" / "other-error" / server-error-value-ext | 113 | // server-error-value = "invalid-encoding" / "extensions-not-supported" / "invalid-proof" / "channel-bindings-dont-match" / "server-does-support-channel-binding" / "channel-binding-not-supported" / "unsupported-channel-binding-type" / "unknown-user" / "invalid-username-encoding" / "no-resources" / "other-error" / server-error-value-ext |
| 112 | | 114 | |
| 113 | var cnonce_b64_buf: [Base64Enc.calcSize(nonce_len)]u8 = @splat(0); | 115 | var cnonce_b64_buf: [Base64Enc.calcSize(nonce_len)]u8 = @splat(0); |
| 114 | const cnonce_b64 = Base64Enc.encode(&cnonce_b64_buf, cnonce); | 116 | const cnonce_b64 = Base64Enc.encode(&cnonce_b64_buf, &cnonce); |
| 115 | | 117 | |
| 116 | var salt_b64_buf: [128]u8 = @splat(0); | 118 | var salt_b64_buf: [128]u8 = @splat(0); |
| 117 | var salt_b64: []u8 = salt_b64_buf[0..]; | 119 | var salt_b64: []u8 = salt_b64_buf[0..]; |