33
44#define FIXTURE_DIR "sha1"
55
6- void test_core_sha256__initialize (void )
6+ #ifdef GIT_SHA256_WIN32
7+ static git_hash_win32_provider_t orig_provider ;
8+ #endif
9+
10+ void test_sha256__initialize (void )
711{
12+ #ifdef GIT_SHA256_WIN32
13+ orig_provider = git_hash_win32_provider ();
14+ #endif
15+
816 cl_fixture_sandbox (FIXTURE_DIR );
917}
1018
11- void test_core_sha256__cleanup (void )
19+ void test_sha256__cleanup (void )
1220{
21+ #ifdef GIT_SHA256_WIN32
22+ git_hash_win32_set_provider (orig_provider );
23+ #endif
24+
1325 cl_fixture_cleanup (FIXTURE_DIR );
1426}
1527
@@ -37,7 +49,7 @@ static int sha256_file(unsigned char *out, const char *filename)
3749 return ret ;
3850}
3951
40- void test_core_sha256__empty (void )
52+ void test_sha256__empty (void )
4153{
4254 unsigned char expected [GIT_HASH_SHA256_SIZE ] = {
4355 0xe3 , 0xb0 , 0xc4 , 0x42 , 0x98 , 0xfc , 0x1c , 0x14 ,
@@ -51,7 +63,7 @@ void test_core_sha256__empty(void)
5163 cl_assert_equal_i (0 , memcmp (expected , actual , GIT_HASH_SHA256_SIZE ));
5264}
5365
54- void test_core_sha256__hello (void )
66+ void test_sha256__hello (void )
5567{
5668 unsigned char expected [GIT_HASH_SHA256_SIZE ] = {
5769 0xaa , 0x32 , 0x7f , 0xae , 0x5c , 0x91 , 0x58 , 0x3a ,
@@ -65,7 +77,7 @@ void test_core_sha256__hello(void)
6577 cl_assert_equal_i (0 , memcmp (expected , actual , GIT_HASH_SHA256_SIZE ));
6678}
6779
68- void test_core_sha256__pdf (void )
80+ void test_sha256__pdf (void )
6981{
7082 unsigned char expected [GIT_HASH_SHA256_SIZE ] = {
7183 0x2b , 0xb7 , 0x87 , 0xa7 , 0x3e , 0x37 , 0x35 , 0x2f ,
@@ -79,3 +91,23 @@ void test_core_sha256__pdf(void)
7991 cl_assert_equal_i (0 , memcmp (expected , actual , GIT_HASH_SHA256_SIZE ));
8092}
8193
94+ void test_sha256__win32_providers (void )
95+ {
96+ #ifdef GIT_SHA256_WIN32
97+ unsigned char expected [GIT_HASH_SHA256_SIZE ] = {
98+ 0x2b , 0xb7 , 0x87 , 0xa7 , 0x3e , 0x37 , 0x35 , 0x2f ,
99+ 0x92 , 0x38 , 0x3a , 0xbe , 0x7e , 0x29 , 0x02 , 0x93 ,
100+ 0x6d , 0x10 , 0x59 , 0xad , 0x9f , 0x1b , 0xa6 , 0xda ,
101+ 0xaa , 0x9c , 0x1e , 0x58 , 0xee , 0x69 , 0x70 , 0xd0
102+ };
103+ unsigned char actual [GIT_HASH_SHA256_SIZE ];
104+
105+ git_hash_win32_set_provider (GIT_HASH_WIN32_CRYPTOAPI );
106+ cl_git_pass (sha256_file (actual , FIXTURE_DIR "/shattered-1.pdf" ));
107+ cl_assert_equal_i (0 , memcmp (expected , actual , GIT_HASH_SHA256_SIZE ));
108+
109+ git_hash_win32_set_provider (GIT_HASH_WIN32_CNG );
110+ cl_git_pass (sha256_file (actual , FIXTURE_DIR "/shattered-1.pdf" ));
111+ cl_assert_equal_i (0 , memcmp (expected , actual , GIT_HASH_SHA256_SIZE ));
112+ #endif
113+ }
0 commit comments