aboutsummaryrefslogtreecommitdiffstats
path: root/tool/znk.zig
diff options
context:
space:
mode:
Diffstat (limited to 'tool/znk.zig')
-rw-r--r--tool/znk.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/tool/znk.zig b/tool/znk.zig
index 554f191..fb2412f 100644
--- a/tool/znk.zig
+++ b/tool/znk.zig
@@ -166,7 +166,7 @@ pub fn cmdGen(arena: Allocator, args: []const []const u8) !void {
166 fatal("failed to generate key", .{}); 166 fatal("failed to generate key", .{});
167 }; 167 };
168 } else { 168 } else {
169 var gen_result = res: { 169 const gen_result = res: {
170 if (entropy) |e| { 170 if (entropy) |e| {
171 break :res nkeys.SeedKeyPair.generateWithCustomEntropy(role.?, e.reader()); 171 break :res nkeys.SeedKeyPair.generateWithCustomEntropy(role.?, e.reader());
172 } else { 172 } else {
@@ -266,7 +266,7 @@ pub fn cmdSign(arena: Allocator, args: []const []const u8) !void {
266 defer nkey.wipe(); 266 defer nkey.wipe();
267 267
268 const sig = nkey.sign(content) catch fatal("could not generate signature", .{}); 268 const sig = nkey.sign(content) catch fatal("could not generate signature", .{});
269 var encoded_sig = try arena.alloc(u8, std.base64.standard.Encoder.calcSize(std.crypto.sign.Ed25519.Signature.encoded_length)); 269 const encoded_sig = try arena.alloc(u8, std.base64.standard.Encoder.calcSize(std.crypto.sign.Ed25519.Signature.encoded_length));
270 _ = std.base64.standard.Encoder.encode(encoded_sig, &sig.toBytes()); 270 _ = std.base64.standard.Encoder.encode(encoded_sig, &sig.toBytes());
271 try stdout.writeAll(encoded_sig); 271 try stdout.writeAll(encoded_sig);
272 try stdout.writeAll("\n"); 272 try stdout.writeAll("\n");
@@ -439,7 +439,7 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type {
439 var rr = RandomReader.init(&std.crypto.random); 439 var rr = RandomReader.init(&std.crypto.random);
440 var brr = io.BufferedReader(1024 * 4096, @TypeOf(rr.reader())){ .unbuffered_reader = rr.reader() }; 440 var brr = io.BufferedReader(1024 * 4096, @TypeOf(rr.reader())){ .unbuffered_reader = rr.reader() };
441 while (!self.done.load(.SeqCst)) { 441 while (!self.done.load(.SeqCst)) {
442 var gen_result = if (self.entropy) |entropy| 442 const gen_result = if (self.entropy) |entropy|
443 nkeys.SeedKeyPair.generateWithCustomEntropy(self.role, entropy) 443 nkeys.SeedKeyPair.generateWithCustomEntropy(self.role, entropy)
444 else 444 else
445 nkeys.SeedKeyPair.generateWithCustomEntropy(self.role, brr.reader()); 445 nkeys.SeedKeyPair.generateWithCustomEntropy(self.role, brr.reader());
@@ -463,8 +463,8 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type {
463 } 463 }
464 } else struct { 464 } else struct {
465 pub fn generate(self: *Self) !void { 465 pub fn generate(self: *Self) !void {
466 var cpu_count = try std.Thread.getCpuCount(); 466 const cpu_count = try std.Thread.getCpuCount();
467 var threads = try self.allocator.alloc(std.Thread, cpu_count * 4); 467 const threads = try self.allocator.alloc(std.Thread, cpu_count * 4);
468 defer self.allocator.free(threads); 468 defer self.allocator.free(threads);
469 for (threads) |*thread| thread.* = try std.Thread.spawn(.{}, Self.generatePrivate, .{self}); 469 for (threads) |*thread| thread.* = try std.Thread.spawn(.{}, Self.generatePrivate, .{self});
470 for (threads) |thread| thread.join(); 470 for (threads) |thread| thread.join();
@@ -540,7 +540,7 @@ pub const Nkey = union(enum) {
540}; 540};
541 541
542pub fn readKeyFile(allocator: Allocator, file: fs.File) ?Nkey { 542pub fn readKeyFile(allocator: Allocator, file: fs.File) ?Nkey {
543 var bytes = file.readToEndAlloc(allocator, std.math.maxInt(usize)) catch fatal("could not read key file", .{}); 543 const bytes = file.readToEndAlloc(allocator, std.math.maxInt(usize)) catch fatal("could not read key file", .{});
544 defer { 544 defer {
545 for (bytes) |*b| b.* = 0; 545 for (bytes) |*b| b.* = 0;
546 allocator.free(bytes); 546 allocator.free(bytes);