std.crypto: fix invalid pass by value

This commit is contained in:
Veikka Tuominen 2022-06-20 15:11:22 +03:00
parent 8f9b31af92
commit 38a1222c87
5 changed files with 4 additions and 12 deletions

View File

@ -897,7 +897,6 @@ test "kdf" {
}
test "phc format hasher" {
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
const allocator = std.testing.allocator;
const password = "testpass";
@ -913,7 +912,6 @@ test "phc format hasher" {
}
test "password hash and password verify" {
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
const allocator = std.testing.allocator;
const password = "testpass";

View File

@ -802,7 +802,6 @@ test "bcrypt crypt format" {
}
test "bcrypt phc format" {
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
const hash_options = HashOptions{
.params = .{ .rounds_log = 5 },
.encoding = .phc,

View File

@ -41,7 +41,7 @@ pub fn BinValue(comptime max_len: usize) type {
}
/// Return the slice containing the actual value.
pub fn constSlice(self: Self) []const u8 {
pub fn constSlice(self: *const Self) []const u8 {
return self.buf[0..self.len];
}
@ -52,7 +52,7 @@ pub fn BinValue(comptime max_len: usize) type {
self.len = len;
}
fn toB64(self: Self, buf: []u8) ![]const u8 {
fn toB64(self: *const Self, buf: []u8) ![]const u8 {
const value = self.constSlice();
const len = B64Encoder.calcSize(value.len);
if (len > buf.len) return Error.NoSpaceLeft;
@ -260,7 +260,6 @@ fn kvSplit(str: []const u8) !struct { key: []const u8, value: []const u8 } {
}
test "phc format - encoding/decoding" {
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
const Input = struct {
str: []const u8,
HashResult: type,

View File

@ -248,7 +248,7 @@ const crypt_format = struct {
}
/// Return the slice containing the actual value.
pub fn constSlice(self: Self) []const u8 {
pub fn constSlice(self: *const Self) []const u8 {
return self.buf[0..self.len];
}
@ -259,7 +259,7 @@ const crypt_format = struct {
self.len = len;
}
fn toB64(self: Self, buf: []u8) ![]const u8 {
fn toB64(self: *const Self, buf: []u8) ![]const u8 {
const value = self.constSlice();
const len = Codec.encodedLen(value.len);
if (len > buf.len) return EncodingError.NoSpaceLeft;
@ -683,7 +683,6 @@ test "unix-scrypt" {
}
test "crypt format" {
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
const str = "$7$C6..../....SodiumChloride$kBGj9fHznVYFQMEn/qDCfrDevf9YDtcDdKvEqHJLV8D";
const params = try crypt_format.deserialize(crypt_format.HashResult(32), str);
var buf: [str.len]u8 = undefined;

View File

@ -225,9 +225,6 @@ fn formatIdent(
}
pub fn fmtIdent(ident: []const u8) std.fmt.Formatter(formatIdent) {
if (builtin.zig_backend != .stage1) {
@panic("TODO");
}
return .{ .data = ident };
}