99
1010#if defined(LTC_SHA224 ) && defined(LTC_SHA256 )
1111
12- const struct ltc_hash_descriptor sha224_c_desc =
12+ const struct ltc_hash_descriptor sha224_portable_desc =
1313{
1414 "sha224" ,
1515 10 ,
@@ -21,7 +21,7 @@ const struct ltc_hash_descriptor sha224_c_desc =
2121 9 ,
2222
2323 & sha224_c_init ,
24- & sha256_process ,
24+ & sha256_c_process ,
2525 & sha224_c_done ,
2626 & sha224_test ,
2727 NULL
@@ -78,41 +78,7 @@ int sha224_c_done(hash_state * md, unsigned char *out)
7878*/
7979int sha224_c_test (void )
8080{
81- #ifndef LTC_TEST
82- return CRYPT_NOP ;
83- #else
84- static const struct {
85- const char * msg ;
86- unsigned char hash [28 ];
87- } tests [] = {
88- { "abc" ,
89- { 0x23 , 0x09 , 0x7d , 0x22 , 0x34 , 0x05 , 0xd8 ,
90- 0x22 , 0x86 , 0x42 , 0xa4 , 0x77 , 0xbd , 0xa2 ,
91- 0x55 , 0xb3 , 0x2a , 0xad , 0xbc , 0xe4 , 0xbd ,
92- 0xa0 , 0xb3 , 0xf7 , 0xe3 , 0x6c , 0x9d , 0xa7 }
93- },
94- { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" ,
95- { 0x75 , 0x38 , 0x8b , 0x16 , 0x51 , 0x27 , 0x76 ,
96- 0xcc , 0x5d , 0xba , 0x5d , 0xa1 , 0xfd , 0x89 ,
97- 0x01 , 0x50 , 0xb0 , 0xc6 , 0x45 , 0x5c , 0xb4 ,
98- 0xf5 , 0x8b , 0x19 , 0x52 , 0x52 , 0x25 , 0x25 }
99- },
100- };
101-
102- int i ;
103- unsigned char tmp [28 ];
104- hash_state md ;
105-
106- for (i = 0 ; i < (int )(sizeof (tests ) / sizeof (tests [0 ])); i ++ ) {
107- sha224_c_init (& md );
108- sha224_c_process (& md , (unsigned char * )tests [i ].msg , (unsigned long )XSTRLEN (tests [i ].msg ));
109- sha224_c_done (& md , tmp );
110- if (ltc_compare_testvector (tmp , sizeof (tmp ), tests [i ].hash , sizeof (tests [i ].hash ), "SHA224" , i )) {
111- return CRYPT_FAIL_TESTVECTOR ;
112- }
113- }
114- return CRYPT_OK ;
115- #endif
81+ return sha224_test_desc (& sha224_portable_desc , "SHA224 portable" );
11682}
11783
11884#endif /* defined(LTC_SHA224) && defined(LTC_SHA256) */
0 commit comments