| author | |
| committer | |
| log | 391663e497f1871f6bddcf9cbc500710aa9aac4d |
| tree | c16328b97c209c5453cc48837420f4edf43bb490 |
| parent | 83970b6d916a1526869aba2680d5017d495df12a |
| signature |
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. |
| 418 | pub const Aegis256Mac = AegisMac(Aegis256_256); | 418 | pub const Aegis256Mac = AegisMac(Aegis256_256); |
| 419 | 419 | ||
| 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. | ||
| 425 | pub 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. | ||
| 432 | pub const Aegis256Mac_128 = AegisMac(Aegis256); | ||
| 433 | |||
| 420 | fn AegisMac(comptime T: type) type { | 434 | fn AegisMac(comptime T: type) type { |
| 421 | return struct { | 435 | return struct { |
| 422 | const Self = @This(); | 436 | const Self = @This(); |