MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / rabbit_test

Function rabbit_test

extra/yassl/taocrypt/test/test.cpp:797–847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

795
796
797int rabbit_test()
798{
799 byte cipher[16];
800 byte plain[16];
801
802 const char* keys[] =
803 {
804 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
805 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
806 "\xAC\xC3\x51\xDC\xF1\x62\xFC\x3B\xFE\x36\x3D\x2E\x29\x13\x28\x91"
807 };
808
809 const char* ivs[] =
810 {
811 "\x00\x00\x00\x00\x00\x00\x00\x00",
812 "\x59\x7E\x26\xC1\x75\xF5\x73\xC3",
813 0
814 };
815
816
817 testVector test_rabbit[] =
818 {
819 testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
820 "\xED\xB7\x05\x67\x37\x5D\xCD\x7C"),
821 testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
822 "\x6D\x7D\x01\x22\x92\xCC\xDC\xE0"),
823 testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
824 "\x9C\x51\xE2\x87\x84\xC3\x7F\xE9")
825 };
826
827
828 int times( sizeof(test_rabbit) / sizeof(testVector) );
829 for (int i = 0; i < times; ++i) {
830 Rabbit::Encryption enc;
831 Rabbit::Decryption dec;
832
833 enc.SetKey((byte*)keys[i], (byte*)ivs[i]);
834 dec.SetKey((byte*)keys[i], (byte*)ivs[i]);
835
836 enc.Process(cipher, test_rabbit[i].input_, test_rabbit[i].outLen_);
837 dec.Process(plain, cipher, test_rabbit[i].outLen_);
838
839 if (memcmp(plain, test_rabbit[i].input_, test_rabbit[i].outLen_))
840 return -230 - i;
841
842 if (memcmp(cipher, test_rabbit[i].output_, test_rabbit[i].outLen_))
843 return -240 - i;
844 }
845
846 return 0;
847}
848
849
850int hc128_test()

Callers 1

taocrypt_testFunction · 0.85

Calls 3

testVectorClass · 0.85
SetKeyMethod · 0.45
ProcessMethod · 0.45

Tested by

no test coverage detected