MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / tiger_test

Function tiger_test

extern/libtomcrypt/src/hashes/tiger.c:732–782  ·  view source on GitHub ↗

Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */

Source from the content-addressed store, hash-verified

730 @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled
731*/
732int tiger_test(void)
733{
734 #ifndef LTC_TEST
735 return CRYPT_NOP;
736 #else
737 static const struct {
738 const char *msg;
739 unsigned char hash[24];
740 } tests[] = {
741 { "",
742 { 0x32, 0x93, 0xac, 0x63, 0x0c, 0x13, 0xf0, 0x24,
743 0x5f, 0x92, 0xbb, 0xb1, 0x76, 0x6e, 0x16, 0x16,
744 0x7a, 0x4e, 0x58, 0x49, 0x2d, 0xde, 0x73, 0xf3 }
745 },
746 { "abc",
747 { 0x2a, 0xab, 0x14, 0x84, 0xe8, 0xc1, 0x58, 0xf2,
748 0xbf, 0xb8, 0xc5, 0xff, 0x41, 0xb5, 0x7a, 0x52,
749 0x51, 0x29, 0x13, 0x1c, 0x95, 0x7b, 0x5f, 0x93 }
750 },
751 { "Tiger",
752 { 0xdd, 0x00, 0x23, 0x07, 0x99, 0xf5, 0x00, 0x9f,
753 0xec, 0x6d, 0xeb, 0xc8, 0x38, 0xbb, 0x6a, 0x27,
754 0xdf, 0x2b, 0x9d, 0x6f, 0x11, 0x0c, 0x79, 0x37 }
755 },
756 { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
757 { 0xf7, 0x1c, 0x85, 0x83, 0x90, 0x2a, 0xfb, 0x87,
758 0x9e, 0xdf, 0xe6, 0x10, 0xf8, 0x2c, 0x0d, 0x47,
759 0x86, 0xa3, 0xa5, 0x34, 0x50, 0x44, 0x86, 0xb5 }
760 },
761 { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
762 { 0xc5, 0x40, 0x34, 0xe5, 0xb4, 0x3e, 0xb8, 0x00,
763 0x58, 0x48, 0xa7, 0xe0, 0xae, 0x6a, 0xac, 0x76,
764 0xe4, 0xff, 0x59, 0x0a, 0xe7, 0x15, 0xfd, 0x25 }
765 },
766 };
767
768 int i;
769 unsigned char tmp[24];
770 hash_state md;
771
772 for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) {
773 tiger_init(&md);
774 tiger_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
775 tiger_done(&md, tmp);
776 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "TIGER", i)) {
777 return CRYPT_FAIL_TESTVECTOR;
778 }
779 }
780 return CRYPT_OK;
781 #endif
782}
783
784#endif
785

Callers

nothing calls this directly

Calls 3

tiger_initFunction · 0.85
tiger_doneFunction · 0.85
compare_testvectorFunction · 0.85

Tested by

no test coverage detected