@@ -767,6 +767,57 @@ BOOST_AUTO_TEST_CASE(poly1305_testvector)
767
767
TestPoly1305 (" e33594d7505e43b900000000000000003394d7505e4379cd010000000000000000000000000000000000000000000000" ,
768
768
" 0100000000000000040000000000000000000000000000000000000000000000" ,
769
769
" 13000000000000000000000000000000" );
770
+
771
+ // Tests from https://github.com/floodyberry/poly1305-donna/blob/master/poly1305-donna.c
772
+ TestPoly1305 (" 8e993b9f48681273c29650ba32fc76ce48332ea7164d96a4476fb8c531a1186a"
773
+ " c0dfc17c98dce87b4da7f011ec48c97271d2c20f9b928fe2270d6fb863d51738"
774
+ " b48eeee314a7cc8ab932164548e526ae90224368517acfeabd6bb3732bc0e9da"
775
+ " 99832b61ca01b6de56244a9e88d5f9b37973f622a43d14a6599b1f654cb45a74"
776
+ " e355a5" ,
777
+ " eea6a7251c1e72916d11c2cb214d3c252539121d8e234e652d651fa4c8cff880" ,
778
+ " f3ffc7703f9400e52a7dfb4b3d3305d9" );
779
+ {
780
+ // mac of the macs of messages of length 0 to 256, where the key and messages have all
781
+ // their values set to the length.
782
+ auto total_key = ParseHex<std::byte>(" 01020304050607fffefdfcfbfaf9ffffffffffffffffffffffffffff00000000" );
783
+ Poly1305 total_ctx (total_key);
784
+ for (unsigned i = 0 ; i < 256 ; ++i) {
785
+ std::vector<std::byte> key (32 , std::byte{(uint8_t )i});
786
+ std::vector<std::byte> msg (i, std::byte{(uint8_t )i});
787
+ std::array<std::byte, Poly1305::TAGLEN> tag;
788
+ Poly1305{key}.Update (msg).Finalize (tag);
789
+ total_ctx.Update (tag);
790
+ }
791
+ std::vector<std::byte> total_tag (Poly1305::TAGLEN);
792
+ total_ctx.Finalize (total_tag);
793
+ BOOST_CHECK (total_tag == ParseHex<std::byte>(" 64afe2e8d6ad7bbdd287f97c44623d39" ));
794
+ }
795
+
796
+ // Tests with sparse messages and random keys.
797
+ TestPoly1305 (" 000000000000000000000094000000000000b07c4300000000002c002600d500"
798
+ " 00000000000000000000000000bc58000000000000000000c9000000dd000000"
799
+ " 00000000000000d34c000000000000000000000000f9009100000000000000c2"
800
+ " 4b0000e900000000000000000000000000000000000e00000027000074000000"
801
+ " 0000000003000000000000f1000000000000dce2000000000000003900000000"
802
+ " 0000000000000000000000000000000000000000000000520000000000000000"
803
+ " 000000000000000000000000009500000000000000000000000000cf00826700"
804
+ " 000000a900000000000000000000000000000000000000000079000000000000"
805
+ " 0000de0000004c000000000033000000000000000000000000002800aa000000"
806
+ " 00003300860000e000000000" ,
807
+ " 6e543496db3cf677592989891ab021f58390feb84fb419fbc7bb516a60bfa302" ,
808
+ " 7ea80968354d40d9d790b45310caf7f3" );
809
+ TestPoly1305 (" 0000005900000000c40000002f00000000000000000000000000000029690000"
810
+ " 0000e8000037000000000000000000000000000b000000000000000000000000"
811
+ " 000000000000000000000000001800006e0000000000a4000000000000000000"
812
+ " 00000000000000004d00000000000000b0000000000000000000005a00000000"
813
+ " 0000000000b7c300000000000000540000000000000000000000000a00000000"
814
+ " 00005b0000000000000000000000000000000000002d00e70000000000000000"
815
+ " 000000000000003400006800d700000000000000000000360000000000000000"
816
+ " 00eb000000000000000000000000000000000000000000000000000028000000"
817
+ " 37000000000000000000000000000000000000000000000000000000008f0000"
818
+ " 000000000000000000000000" ,
819
+ " f0b659a4f3143d8a1e1dacb9a409fe7e7cd501dfb58b16a2623046c5d337922a" ,
820
+ " 0e410fa9d7a40ac582e77546be9a72bb" );
770
821
}
771
822
772
823
BOOST_AUTO_TEST_CASE (hkdf_hmac_sha256_l32_tests)
0 commit comments