| ... | ... | @@ -85,7 +85,7 @@ const State128L = struct { |
| 85 | 85 | /// The 128L variant of AEGIS has a 128 bit key, a 128 bit nonce, and processes 256 bit message blocks. |
| 86 | 86 | /// It was designed to fully exploit the parallelism and built-in AES support of recent Intel and ARM CPUs. |
| 87 | 87 | /// |
| 88 | | /// https://eprint.iacr.org/2013/695.pdf |
| 88 | /// https://competitions.cr.yp.to/round3/aegisv11.pdf |
| 89 | 89 | pub const AEGIS128L = struct { |
| 90 | 90 | pub const tag_length = 16; |
| 91 | 91 | pub const nonce_length = 16; |
| ... | ... | @@ -247,7 +247,7 @@ const State256 = struct { |
| 247 | 247 | /// |
| 248 | 248 | /// The 256 bit variant of AEGIS has a 256 bit key, a 256 bit nonce, and processes 128 bit message blocks. |
| 249 | 249 | /// |
| 250 | | /// https://eprint.iacr.org/2013/695.pdf |
| 250 | /// https://competitions.cr.yp.to/round3/aegisv11.pdf |
| 251 | 251 | pub const AEGIS256 = struct { |
| 252 | 252 | pub const tag_length = 16; |
| 253 | 253 | pub const nonce_length = 32; |
| ... | ... | @@ -374,6 +374,22 @@ test "AEGIS128L test vector 2" { |
| 374 | 374 | htest.assertEqual("f4d997cc9b94227ada4fe4165422b1c8", &tag); |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | test "AEGIS128L test vector 3" { |
| 378 | const key: [AEGIS128L.key_length]u8 = [_]u8{0x00} ** 16; |
| 379 | const nonce: [AEGIS128L.nonce_length]u8 = [_]u8{0x00} ** 16; |
| 380 | const ad = [_]u8{}; |
| 381 | const m = [_]u8{}; |
| 382 | var c: [m.len]u8 = undefined; |
| 383 | var m2: [m.len]u8 = undefined; |
| 384 | var tag: [AEGIS128L.tag_length]u8 = undefined; |
| 385 | |
| 386 | AEGIS128L.encrypt(&c, &tag, &m, &ad, nonce, key); |
| 387 | try AEGIS128L.decrypt(&m2, &c, tag, &ad, nonce, key); |
| 388 | testing.expectEqualSlices(u8, &m, &m2); |
| 389 | |
| 390 | htest.assertEqual("83cc600dc4e3e7e62d4055826174f149", &tag); |
| 391 | } |
| 392 | |
| 377 | 393 | test "AEGIS256 test vector 1" { |
| 378 | 394 | const key: [AEGIS256.key_length]u8 = [_]u8{ 0x10, 0x01 } ++ [_]u8{0x00} ** 30; |
| 379 | 395 | const nonce: [AEGIS256.nonce_length]u8 = [_]u8{ 0x10, 0x00, 0x02 } ++ [_]u8{0x00} ** 29; |
| ... | ... | @@ -413,3 +429,19 @@ test "AEGIS256 test vector 2" { |
| 413 | 429 | htest.assertEqual("b98f03a947807713d75a4fff9fc277a6", &c); |
| 414 | 430 | htest.assertEqual("478f3b50dc478ef7d5cf2d0f7cc13180", &tag); |
| 415 | 431 | } |
| 432 | |
| 433 | test "AEGIS256 test vector 3" { |
| 434 | const key: [AEGIS256.key_length]u8 = [_]u8{0x00} ** 32; |
| 435 | const nonce: [AEGIS256.nonce_length]u8 = [_]u8{0x00} ** 32; |
| 436 | const ad = [_]u8{}; |
| 437 | const m = [_]u8{}; |
| 438 | var c: [m.len]u8 = undefined; |
| 439 | var m2: [m.len]u8 = undefined; |
| 440 | var tag: [AEGIS256.tag_length]u8 = undefined; |
| 441 | |
| 442 | AEGIS256.encrypt(&c, &tag, &m, &ad, nonce, key); |
| 443 | try AEGIS256.decrypt(&m2, &c, tag, &ad, nonce, key); |
| 444 | testing.expectEqualSlices(u8, &m, &m2); |
| 445 | |
| 446 | htest.assertEqual("f7a0878f68bd083e8065354071fc27c3", &tag); |
| 447 | } |