aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2023-12-04 20:19:18 +0100
committerLibravatar Rutger Broekhoff2023-12-04 20:20:00 +0100
commita50016c7481b4c8613e03af136d93309c6b30400 (patch)
treedc7679467776395958e98caa68aa210711548e8b
parent2ee6e4a8d062f303d9abddb37551b9ae39630433 (diff)
downloadzig-nkeys-a50016c7481b4c8613e03af136d93309c6b30400.tar.gz
zig-nkeys-a50016c7481b4c8613e03af136d93309c6b30400.zip
Update code for Zig dev
This code was tested on zig-dev-bin-1:0.12.0_dev.1773+8a8fd47d2-1 (AUR)
-rw-r--r--.github/workflows/main.yml2
-rw-r--r--build.zig.zon2
-rw-r--r--src/main.zig10
-rw-r--r--tool/znk.zig4
4 files changed, 9 insertions, 9 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 47b2ee8..544d23a 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -12,7 +12,7 @@ jobs:
12 runs-on: ubuntu-latest 12 runs-on: ubuntu-latest
13 steps: 13 steps:
14 - name: Install the latest Zig version 14 - name: Install the latest Zig version
15 run: sudo snap install zig --classic --beta 15 run: sudo snap install zig --classic --edge
16 16
17 - uses: actions/checkout@v2 17 - uses: actions/checkout@v2
18 18
diff --git a/build.zig.zon b/build.zig.zon
index d922fdd..b3c562d 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -1,5 +1,5 @@
1.{ 1.{
2 .name = "zig-nkeys", 2 .name = "zig-nkeys",
3 .version = "0.5.1", 3 .version = "0.6.0",
4 .paths = .{"."}, 4 .paths = .{"."},
5} 5}
diff --git a/src/main.zig b/src/main.zig
index a93c0ea..b24faea 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -286,11 +286,11 @@ fn encode(
286 var buf: [prefix_len + data_len + 2]u8 = undefined; 286 var buf: [prefix_len + data_len + 2]u8 = undefined;
287 defer wipeBytes(&buf); 287 defer wipeBytes(&buf);
288 288
289 mem.copy(u8, &buf, prefix[0..]); 289 mem.copyForwards(u8, &buf, prefix[0..]);
290 mem.copy(u8, buf[prefix_len..], data[0..]); 290 mem.copyForwards(u8, buf[prefix_len..], data[0..]);
291 const off = prefix_len + data_len; 291 const off = prefix_len + data_len;
292 const checksum = crc16.make(buf[0..off]); 292 const checksum = crc16.make(buf[0..off]);
293 mem.writeIntLittle(u16, buf[buf.len - 2 .. buf.len], checksum); 293 mem.writeInt(u16, buf[buf.len - 2 .. buf.len], checksum, .little);
294 294
295 var text: encoded_key(prefix_len, data_len) = undefined; 295 var text: encoded_key(prefix_len, data_len) = undefined;
296 std.debug.assert(base32.Encoder.encode(&text, &buf).len == text.len); 296 std.debug.assert(base32.Encoder.encode(&text, &buf).len == text.len);
@@ -321,7 +321,7 @@ fn decode(
321 defer wipeBytes(&raw); 321 defer wipeBytes(&raw);
322 std.debug.assert((try base32.Decoder.decode(&raw, text[0..])).len == raw.len); 322 std.debug.assert((try base32.Decoder.decode(&raw, text[0..])).len == raw.len);
323 323
324 const checksum = mem.readIntLittle(u16, raw[raw.len - 2 .. raw.len]); 324 const checksum = mem.readInt(u16, raw[raw.len - 2 .. raw.len], .little);
325 try crc16.validate(raw[0 .. raw.len - 2], checksum); 325 try crc16.validate(raw[0 .. raw.len - 2], checksum);
326 326
327 return DecodedNkey(prefix_len, data_len){ 327 return DecodedNkey(prefix_len, data_len){
@@ -347,7 +347,7 @@ pub fn isValidEncoding(text: []const u8) bool {
347 } 347 }
348 std.debug.assert(wrote_n_total == expect_len); 348 std.debug.assert(wrote_n_total == expect_len);
349 if (crc_buf_len != 2) unreachable; 349 if (crc_buf_len != 2) unreachable;
350 const got_crc = mem.readIntLittle(u16, &crc_buf); 350 const got_crc = mem.readInt(u16, &crc_buf, .little);
351 return made_crc == got_crc; 351 return made_crc == got_crc;
352} 352}
353 353
diff --git a/tool/znk.zig b/tool/znk.zig
index fb2412f..af8f757 100644
--- a/tool/znk.zig
+++ b/tool/znk.zig
@@ -420,7 +420,7 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type {
420 role: nkeys.Role, 420 role: nkeys.Role,
421 prefix: []const u8, 421 prefix: []const u8,
422 allocator: Allocator, 422 allocator: Allocator,
423 done: std.atomic.Atomic(bool), 423 done: std.atomic.Value(bool),
424 entropy: ?EntropyReaderType, 424 entropy: ?EntropyReaderType,
425 425
426 const Self = @This(); 426 const Self = @This();
@@ -430,7 +430,7 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type {
430 .role = role, 430 .role = role,
431 .prefix = prefix, 431 .prefix = prefix,
432 .allocator = allocator, 432 .allocator = allocator,
433 .done = std.atomic.Atomic(bool).init(false), 433 .done = std.atomic.Value(bool).init(false),
434 .entropy = entropy, 434 .entropy = entropy,
435 }; 435 };
436 } 436 }