authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2023-04-21 13:52:33-06:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-04-21 19:52:33+00:00
log391663e497f1871f6bddcf9cbc500710aa9aac4d
treec16328b97c209c5453cc48837420f4edf43bb490
parent83970b6d916a1526869aba2680d5017d495df12a
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

AEGIS MAC: add support for 128-bit tags (#15379)

When used as a MAC, 256-bit tags are recommended. But in interactive protocols, 128 bits may be acceptable.

2 files changed, 16 insertions(+), 0 deletions(-)

lib/std/crypto.zig+2
...@@ -41,7 +41,9 @@ pub const auth = struct {...@@ -41,7 +41,9 @@ pub const auth = struct {
41 pub const siphash = @import("crypto/siphash.zig");41 pub const siphash = @import("crypto/siphash.zig");
42 pub const aegis = struct {42 pub const aegis = struct {
43 pub const Aegis128LMac = @import("crypto/aegis.zig").Aegis128LMac;43 pub const Aegis128LMac = @import("crypto/aegis.zig").Aegis128LMac;
44 pub const Aegis128LMac_128 = @import("crypto/aegis.zig").Aegis128LMac_128;
44 pub const Aegis256Mac = @import("crypto/aegis.zig").Aegis256Mac;45 pub const Aegis256Mac = @import("crypto/aegis.zig").Aegis256Mac;
46 pub const Aegis256Mac_128 = @import("crypto/aegis.zig").Aegis256Mac_128;
45 };47 };
46 pub const cmac = @import("crypto/cmac.zig");48 pub const cmac = @import("crypto/cmac.zig");
47};49};
lib/std/crypto/aegis.zig+14
...@@ -417,6 +417,20 @@ pub const Aegis128LMac = AegisMac(Aegis128L_256);...@@ -417,6 +417,20 @@ pub const Aegis128LMac = AegisMac(Aegis128L_256);
417/// - It has a large security margin against internal collisions.417/// - It has a large security margin against internal collisions.
418pub const Aegis256Mac = AegisMac(Aegis256_256);418pub const Aegis256Mac = AegisMac(Aegis256_256);
419419
420/// Aegis128L MAC with a 128-bit output.
421/// A MAC with a 128-bit output is not safe unless the number of messages
422/// authenticated with the same key remains small.
423/// After 2^48 messages, the probability of a collision is already ~ 2^-33.
424/// If unsure, use the Aegis128LMac type, that has a 256 bit output.
425pub const Aegis128LMac_128 = AegisMac(Aegis128L);
426
427/// Aegis256 MAC with a 128-bit output.
428/// A MAC with a 128-bit output is not safe unless the number of messages
429/// authenticated with the same key remains small.
430/// After 2^48 messages, the probability of a collision is already ~ 2^-33.
431/// If unsure, use the Aegis256Mac type, that has a 256 bit output.
432pub const Aegis256Mac_128 = AegisMac(Aegis256);
433
420fn AegisMac(comptime T: type) type {434fn AegisMac(comptime T: type) type {
421 return struct {435 return struct {
422 const Self = @This();436 const Self = @This();