10 #include "test_util_lib.h"
21 for (i
= 0; i
< cb
; i
++)
23 pb
[i
] = (unsigned char)rng();
31 size_t cntBytesToHash
,
34 unsigned char hash
[20];
36 unsigned char buffer_to_hash
[64];
40 int i
= cntBytesToHash
;
42 br::mt19937
rng(uiSeed
);
48 unsigned int cb
= min(64, i
);
50 cb
= GenRandomBytes(buffer_to_hash
, cb
, rng
);
52 SHA1DCUpdate(&ctx
, (char *)buffer_to_hash
, cb
);
57 SHA1DCFinal(hash
, &ctx
);
59 cout
<< "Done." << endl
;
61 if (ctx
.found_collision
)
63 cout
<< "Collision found." << endl
;
70 int UBCVerifyRandomBytes(
71 size_t cntBytesToHash
,
74 unsigned char buffer_to_hash
[64];
76 uint32_t expanded_message
[80];
78 uint32_t dvmask
[1] = { 0 };
79 uint32_t dvmask_verify
[1] = { 0 };
81 int i
= cntBytesToHash
;
83 br::mt19937
rng(uiSeed
);
84 cout
<< "Unavoidable bit checking...";
88 unsigned int cb
= min(64, i
);
90 cb
= GenRandomBytes(buffer_to_hash
, cb
, rng
);
92 memset(dvmask
, 0, sizeof(dvmask
));
93 memset(dvmask_verify
, 0, sizeof(dvmask_verify
));
95 sha1_compression_W((uint32_t*)buffer_to_hash
, expanded_message
);
97 ubc_check(expanded_message
, dvmask
);
98 //ubc_check_verify(expanded_message, dvmask_verify);
100 if (0 != memcmp(dvmask
, dvmask_verify
, sizeof(dvmask
)))
102 printf("Calculated dvmask does not equal dvmask verify output.\n");
108 cout
<< "Done." << endl
;