@@ -742,6 +742,64 @@ test "aegis128x4 - MAC" {
742
742
try testing .expectEqualSlices (u8 , & mac , & mac2 );
743
743
}
744
744
745
+ test "aegis128l - MAC test vector" {
746
+ const key = [_ ]u8 { 0x10 , 0x01 } ++ [_ ]u8 {0x00 } ** (16 - 2 );
747
+ const nonce = [_ ]u8 { 0x10 , 0x00 , 0x02 } ++ [_ ]u8 {0x00 } ** (16 - 3 );
748
+ var msg : [35 ]u8 = undefined ;
749
+ for (& msg , 0.. ) | * byte , i | byte .* = @truncate (i );
750
+ var mac128 : [16 ]u8 = undefined ;
751
+ var mac256 : [32 ]u8 = undefined ;
752
+ var st : aegis.aegis128l_mac_state = undefined ;
753
+ var ret : c_int = undefined ;
754
+ aegis .aegis128l_mac_init (& st , & key , & nonce );
755
+ ret = aegis .aegis128l_mac_update (& st , & msg , msg .len );
756
+ try testing .expectEqual (ret , 0 );
757
+ ret = aegis .aegis128l_mac_final (& st , & mac128 , mac128 .len );
758
+ try testing .expectEqual (ret , 0 );
759
+ aegis .aegis128l_mac_reset (& st );
760
+ ret = aegis .aegis128l_mac_update (& st , & msg , msg .len );
761
+ try testing .expectEqual (ret , 0 );
762
+ ret = aegis .aegis128l_mac_final (& st , & mac256 , mac256 .len );
763
+ try testing .expectEqual (ret , 0 );
764
+ const expected128_hex = "3982e98c66fa9232e9190ec57b120725" ;
765
+ const expected256_hex = "a7d01b4636e8d312af8b65b3bb680feb8ffd62aa234584001b1e419b4b40c317" ;
766
+ var expected128 : [16 ]u8 = undefined ;
767
+ var expected256 : [32 ]u8 = undefined ;
768
+ _ = try std .fmt .hexToBytes (& expected128 , expected128_hex );
769
+ _ = try std .fmt .hexToBytes (& expected256 , expected256_hex );
770
+ try std .testing .expectEqualSlices (u8 , & expected128 , & mac128 );
771
+ try std .testing .expectEqualSlices (u8 , & expected256 , & mac256 );
772
+ }
773
+
774
+ test "aegis128x2 - MAC test vector" {
775
+ const key = [_ ]u8 { 0x10 , 0x01 } ++ [_ ]u8 {0x00 } ** (16 - 2 );
776
+ const nonce = [_ ]u8 { 0x10 , 0x00 , 0x02 } ++ [_ ]u8 {0x00 } ** (16 - 3 );
777
+ var msg : [35 ]u8 = undefined ;
778
+ for (& msg , 0.. ) | * byte , i | byte .* = @truncate (i );
779
+ var mac128 : [16 ]u8 = undefined ;
780
+ var mac256 : [32 ]u8 = undefined ;
781
+ var st : aegis.aegis128x2_mac_state = undefined ;
782
+ var ret : c_int = undefined ;
783
+ aegis .aegis128x2_mac_init (& st , & key , & nonce );
784
+ ret = aegis .aegis128x2_mac_update (& st , & msg , msg .len );
785
+ try testing .expectEqual (ret , 0 );
786
+ ret = aegis .aegis128x2_mac_final (& st , & mac128 , mac128 .len );
787
+ try testing .expectEqual (ret , 0 );
788
+ aegis .aegis128x2_mac_reset (& st );
789
+ ret = aegis .aegis128x2_mac_update (& st , & msg , msg .len );
790
+ try testing .expectEqual (ret , 0 );
791
+ ret = aegis .aegis128x2_mac_final (& st , & mac256 , mac256 .len );
792
+ try testing .expectEqual (ret , 0 );
793
+ const expected128_hex = "30ff53a9e8fe94705b753598b4899ded" ;
794
+ const expected256_hex = "cfcd370c2f182244b512ec5c7e71f54e2b56ae9e8462e845ec02d4f65bc346c0" ;
795
+ var expected128 : [16 ]u8 = undefined ;
796
+ var expected256 : [32 ]u8 = undefined ;
797
+ _ = try std .fmt .hexToBytes (& expected128 , expected128_hex );
798
+ _ = try std .fmt .hexToBytes (& expected256 , expected256_hex );
799
+ try std .testing .expectEqualSlices (u8 , & expected128 , & mac128 );
800
+ try std .testing .expectEqualSlices (u8 , & expected256 , & mac256 );
801
+ }
802
+
745
803
// Wycheproof tests
746
804
747
805
const JsonTest = struct {
0 commit comments