mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
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 4b593a6c24797484e68a668818736b0f6a8d81a2. Revert "crypto - threaded K12: separate context computation from thread spawning (#25793)" This reverts commit ee4df4ad3edad160fb737a1935cd86bc2f9cfbbe. Revert "crypto.kt128: when using incremental hashing, use SIMD when possible (#25783)" This reverts commit bf9082518c32ce7d53d011777bf8d8056472cbf9. Revert "Add std.crypto.hash.sha3.{KT128,KT256} - RFC 9861. (#25593)" This reverts commit 95c76b1b4aa7302966281c6b9b7f6cadea3cf7a6.
This commit is contained in:
parent
a892e09435
commit
bb3b5d09cc
@ -30,7 +30,6 @@ const hashes = [_]Crypto{
|
||||
Crypto{ .ty = crypto.hash.sha3.Shake256, .name = "shake-256" },
|
||||
Crypto{ .ty = crypto.hash.sha3.TurboShake128(null), .name = "turboshake-128" },
|
||||
Crypto{ .ty = crypto.hash.sha3.TurboShake256(null), .name = "turboshake-256" },
|
||||
Crypto{ .ty = crypto.hash.sha3.KT128, .name = "kt128" },
|
||||
Crypto{ .ty = crypto.hash.blake2.Blake2s256, .name = "blake2s" },
|
||||
Crypto{ .ty = crypto.hash.blake2.Blake2b512, .name = "blake2b" },
|
||||
Crypto{ .ty = crypto.hash.Blake3, .name = "blake3" },
|
||||
@ -38,7 +37,6 @@ const hashes = [_]Crypto{
|
||||
|
||||
const parallel_hashes = [_]Crypto{
|
||||
Crypto{ .ty = crypto.hash.Blake3, .name = "blake3-parallel" },
|
||||
Crypto{ .ty = crypto.hash.sha3.KT128, .name = "kt128-parallel" },
|
||||
};
|
||||
|
||||
const block_size: usize = 8 * 8192;
|
||||
|
||||
@ -12,8 +12,8 @@ const Vec16 = @Vector(16, u32);
|
||||
const chunk_length = 1024;
|
||||
const max_depth = 54;
|
||||
|
||||
const simd_degree = std.simd.suggestVectorLength(u32) orelse 1;
|
||||
const max_simd_degree = simd_degree;
|
||||
pub const simd_degree = std.simd.suggestVectorLength(u32) orelse 1;
|
||||
pub const max_simd_degree = simd_degree;
|
||||
const max_simd_degree_or_2 = if (max_simd_degree > 2) max_simd_degree else 2;
|
||||
|
||||
/// Threshold for switching to parallel processing.
|
||||
@ -502,7 +502,9 @@ fn hashManySimd(
|
||||
var out_ptr = out.ptr;
|
||||
var cnt = counter;
|
||||
|
||||
if (simd_degree >= 16) {
|
||||
const simd_deg = comptime simd_degree;
|
||||
|
||||
if (comptime simd_deg >= 16) {
|
||||
while (remaining >= 16) {
|
||||
const sixteen_inputs = [16][*]const u8{
|
||||
inp[0], inp[1], inp[2], inp[3],
|
||||
@ -523,7 +525,7 @@ fn hashManySimd(
|
||||
}
|
||||
}
|
||||
|
||||
if (simd_degree >= 8) {
|
||||
if (comptime simd_deg >= 8) {
|
||||
while (remaining >= 8) {
|
||||
const eight_inputs = [8][*]const u8{
|
||||
inp[0], inp[1], inp[2], inp[3],
|
||||
@ -542,7 +544,7 @@ fn hashManySimd(
|
||||
}
|
||||
}
|
||||
|
||||
if (simd_degree >= 4) {
|
||||
if (comptime simd_deg >= 4) {
|
||||
while (remaining >= 4) {
|
||||
const four_inputs = [4][*]const u8{
|
||||
inp[0],
|
||||
@ -569,7 +571,7 @@ fn hashManySimd(
|
||||
}
|
||||
|
||||
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 {
|
||||
if (max_simd_degree >= 4) {
|
||||
if (comptime max_simd_degree >= 4) {
|
||||
hashManySimd(inputs, num_inputs, blocks, key, counter, increment_counter, flags, flags_start, flags_end, out);
|
||||
} else {
|
||||
hashManyPortable(inputs, num_inputs, blocks, key, counter, increment_counter, flags, flags_start, flags_end, out);
|
||||
@ -907,7 +909,7 @@ pub const Blake3 = struct {
|
||||
pub const digest_length = 32;
|
||||
pub const key_length = 32;
|
||||
|
||||
pub const Options = struct { key: ?[key_length]u8 = null };
|
||||
pub const Options = struct { key: ?[digest_length]u8 = null };
|
||||
pub const KdfOptions = struct {};
|
||||
|
||||
key: [8]u32,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,8 +4,6 @@ const assert = std.debug.assert;
|
||||
const math = std.math;
|
||||
const mem = std.mem;
|
||||
|
||||
const kangarootwelve = @import("kangarootwelve.zig");
|
||||
|
||||
const KeccakState = std.crypto.core.keccak.State;
|
||||
|
||||
pub const Sha3_224 = Keccak(1600, 224, 0x06, 24);
|
||||
@ -28,9 +26,6 @@ pub const KMac256 = KMac(256);
|
||||
pub const TupleHash128 = TupleHash(128);
|
||||
pub const TupleHash256 = TupleHash(256);
|
||||
|
||||
pub const KT128 = kangarootwelve.KT128;
|
||||
pub const KT256 = kangarootwelve.KT256;
|
||||
|
||||
/// TurboSHAKE128 is a XOF (a secure hash function with a variable output length), with a 128 bit security level.
|
||||
/// It is based on the same permutation as SHA3 and SHAKE128, but which much higher performance.
|
||||
/// The delimiter is 0x1f by default, but can be changed for context-separation.
|
||||
@ -486,10 +481,6 @@ pub const NistLengthEncoding = enum {
|
||||
|
||||
const htest = @import("test.zig");
|
||||
|
||||
test {
|
||||
_ = kangarootwelve;
|
||||
}
|
||||
|
||||
test "sha3-224 single" {
|
||||
try htest.assertEqualHash(Sha3_224, "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7", "");
|
||||
try htest.assertEqualHash(Sha3_224, "e642824c3f8cf24ad09234ee7d3c766fc9a3a5168d0c94ad73b46fdf", "abc");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user