Skip to content

Commit bb3b5d0

Browse files
committed
Revert std.crypto kangarootwelve addition
I would like a chance to review this before it lands, please. Feel free to submit the work again without changes and I will make review comments. In the meantime, these reverts avoid intermittent CI failures, and remove bad patterns from occurring in the standard library that other users might copy. Revert "std.crypto: improve KT documentation, use key_length for B3 key length (#25807)" This reverts commit 4b593a6. Revert "crypto - threaded K12: separate context computation from thread spawning (#25793)" This reverts commit ee4df4a. Revert "crypto.kt128: when using incremental hashing, use SIMD when possible (#25783)" This reverts commit bf90825. Revert "Add std.crypto.hash.sha3.{KT128,KT256} - RFC 9861. (#25593)" This reverts commit 95c76b1.
1 parent a892e09 commit bb3b5d0

File tree

4 files changed

+9
-1985
lines changed

4 files changed

+9
-1985
lines changed

lib/std/crypto/benchmark.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@ const hashes = [_]Crypto{
3030
Crypto{ .ty = crypto.hash.sha3.Shake256, .name = "shake-256" },
3131
Crypto{ .ty = crypto.hash.sha3.TurboShake128(null), .name = "turboshake-128" },
3232
Crypto{ .ty = crypto.hash.sha3.TurboShake256(null), .name = "turboshake-256" },
33-
Crypto{ .ty = crypto.hash.sha3.KT128, .name = "kt128" },
3433
Crypto{ .ty = crypto.hash.blake2.Blake2s256, .name = "blake2s" },
3534
Crypto{ .ty = crypto.hash.blake2.Blake2b512, .name = "blake2b" },
3635
Crypto{ .ty = crypto.hash.Blake3, .name = "blake3" },
3736
};
3837

3938
const parallel_hashes = [_]Crypto{
4039
Crypto{ .ty = crypto.hash.Blake3, .name = "blake3-parallel" },
41-
Crypto{ .ty = crypto.hash.sha3.KT128, .name = "kt128-parallel" },
4240
};
4341

4442
const block_size: usize = 8 * 8192;

lib/std/crypto/blake3.zig

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const Vec16 = @Vector(16, u32);
1212
const chunk_length = 1024;
1313
const max_depth = 54;
1414

15-
const simd_degree = std.simd.suggestVectorLength(u32) orelse 1;
16-
const max_simd_degree = simd_degree;
15+
pub const simd_degree = std.simd.suggestVectorLength(u32) orelse 1;
16+
pub const max_simd_degree = simd_degree;
1717
const max_simd_degree_or_2 = if (max_simd_degree > 2) max_simd_degree else 2;
1818

1919
/// Threshold for switching to parallel processing.
@@ -502,7 +502,9 @@ fn hashManySimd(
502502
var out_ptr = out.ptr;
503503
var cnt = counter;
504504

505-
if (simd_degree >= 16) {
505+
const simd_deg = comptime simd_degree;
506+
507+
if (comptime simd_deg >= 16) {
506508
while (remaining >= 16) {
507509
const sixteen_inputs = [16][*]const u8{
508510
inp[0], inp[1], inp[2], inp[3],
@@ -523,7 +525,7 @@ fn hashManySimd(
523525
}
524526
}
525527

526-
if (simd_degree >= 8) {
528+
if (comptime simd_deg >= 8) {
527529
while (remaining >= 8) {
528530
const eight_inputs = [8][*]const u8{
529531
inp[0], inp[1], inp[2], inp[3],
@@ -542,7 +544,7 @@ fn hashManySimd(
542544
}
543545
}
544546

545-
if (simd_degree >= 4) {
547+
if (comptime simd_deg >= 4) {
546548
while (remaining >= 4) {
547549
const four_inputs = [4][*]const u8{
548550
inp[0],
@@ -569,7 +571,7 @@ fn hashManySimd(
569571
}
570572

571573
fn hashMany(inputs: [][*]const u8, num_inputs: usize, blocks: usize, key: [8]u32, counter: u64, increment_counter: bool, flags: Flags, flags_start: Flags, flags_end: Flags, out: []u8) void {
572-
if (max_simd_degree >= 4) {
574+
if (comptime max_simd_degree >= 4) {
573575
hashManySimd(inputs, num_inputs, blocks, key, counter, increment_counter, flags, flags_start, flags_end, out);
574576
} else {
575577
hashManyPortable(inputs, num_inputs, blocks, key, counter, increment_counter, flags, flags_start, flags_end, out);
@@ -907,7 +909,7 @@ pub const Blake3 = struct {
907909
pub const digest_length = 32;
908910
pub const key_length = 32;
909911

910-
pub const Options = struct { key: ?[key_length]u8 = null };
912+
pub const Options = struct { key: ?[digest_length]u8 = null };
911913
pub const KdfOptions = struct {};
912914

913915
key: [8]u32,

0 commit comments

Comments
 (0)