| 1 | // Copyright ©2025 blackshirt. |
| 2 | // Use of this source code is governed by an MIT license |
| 3 | // that can be found in the LICENSE file. |
| 4 | // |
| 5 | module ascon |
| 6 | |
| 7 | // This test mostly taken from https://docs.rs/ascon/latest/src/ascon/lib.rs.html |
| 8 | fn test_ascon_round_p6() { |
| 9 | mut s := State{ |
| 10 | e0: u64(0x0123456789abcdef) |
| 11 | e1: 0xef0123456789abcd |
| 12 | e2: 0xcdef0123456789ab |
| 13 | e3: 0xabcdef0123456789 |
| 14 | e4: 0x89abcdef01234567 |
| 15 | } |
| 16 | ascon_pnr(mut s, .ascon_prnd_6) |
| 17 | assert s.e0 == u64(0xc27b505c635eb07f) |
| 18 | assert s.e1 == u64(0xd388f5d2a72046fa) |
| 19 | assert s.e2 == u64(0x9e415c204d7b15e7) |
| 20 | assert s.e3 == u64(0xce0d71450fe44581) |
| 21 | assert s.e4 == u64(0xdd7c5fef57befe48) |
| 22 | } |
| 23 | |
| 24 | fn test_ascon_round_p8() { |
| 25 | mut s := State{ |
| 26 | e0: u64(0x0123456789abcdef) |
| 27 | e1: 0xef0123456789abcd |
| 28 | e2: 0xcdef0123456789ab |
| 29 | e3: 0xabcdef0123456789 |
| 30 | e4: 0x89abcdef01234567 |
| 31 | } |
| 32 | ascon_pnr(mut s, .ascon_prnd_8) |
| 33 | assert s.e0 == u64(0x67ed228272f46eee) |
| 34 | assert s.e1 == u64(0x80bc0b097aad7944) |
| 35 | assert s.e2 == u64(0x2fa599382c6db215) |
| 36 | assert s.e3 == u64(0x368133fae2f7667a) |
| 37 | assert s.e4 == u64(0x28cefb195a7c651c) |
| 38 | } |
| 39 | |
| 40 | fn test_ascon_round_p12() { |
| 41 | mut s := State{ |
| 42 | e0: u64(0x0123456789abcdef) |
| 43 | e1: 0xef0123456789abcd |
| 44 | e2: 0xcdef0123456789ab |
| 45 | e3: 0xabcdef0123456789 |
| 46 | e4: 0x89abcdef01234567 |
| 47 | } |
| 48 | ascon_pnr(mut s, .ascon_prnd_12) |
| 49 | assert s.e0 == u64(0x206416dfc624bb14) |
| 50 | assert s.e1 == u64(0x1b0c47a601058aab) |
| 51 | assert s.e2 == u64(0x8934cfc93814cddd) |
| 52 | assert s.e3 == u64(0xa9738d287a748e4b) |
| 53 | assert s.e4 == u64(0xddd934f058afc7e1) |
| 54 | } |
| 55 | |