Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cr-marcstevens/sha1collisiondetection.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcr-marcstevens <github@marc-stevens.nl>2017-03-13 20:02:11 +0300
committercr-marcstevens <github@marc-stevens.nl>2017-03-13 20:02:11 +0300
commitb17728507ae4c8c13ff4eb521f3d24b493fbe150 (patch)
treeb243ed6077eed86c8439c623e06dda8087bb075b
parente792e8c9f855b72d68f54b88bb484c40591963df (diff)
* Increase lib patch version
* Re-add lost code from merge
-rw-r--r--Makefile2
-rw-r--r--lib/sha1.c49
2 files changed, 27 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index 8c014e5..e887bed 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@
# 3. If any interfaces have been added since the last public release, then increment age.
# 4. If any interfaces have been removed or changed since the last public release,
# then set age to 0.
-LIBCOMPAT=0:0:0
+LIBCOMPAT=0:1:0
PREFIX ?= /usr/local
BINDIR=$(PREFIX)/bin
diff --git a/lib/sha1.c b/lib/sha1.c
index 390b638..745d7f5 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -1013,34 +1013,37 @@ void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])
{
for (i = 0; sha1_dvs[i].dvType != 0; ++i)
{
- for (j = 0; j < 80; ++j)
- ctx->m2[j] = ctx->m1[j] ^ sha1_dvs[i].dm[j];
-
- /* (sha1_recompression_step[sha1_dvs[i].testt])(ctx->ihv2, ihvtmp, ctx->m2, ctx->states[sha1_dvs[i].testt]); */
- switch (sha1_dvs[i].testt)
- {
- case 58:
- sha1recompress_fast_58(ctx->ihv2, ihvtmp, ctx->m2, ctx->states[sha1_dvs[i].testt]);
- break;
- case 65:
- sha1recompress_fast_65(ctx->ihv2, ihvtmp, ctx->m2, ctx->states[sha1_dvs[i].testt]);
- break;
- default:
- abort();
- }
- /* to verify SHA-1 collision detection code with collisions for reduced-step SHA-1 */
- if ((0 == ((ihvtmp[0] ^ ctx->ihv[0]) | (ihvtmp[1] ^ ctx->ihv[1]) | (ihvtmp[2] ^ ctx->ihv[2]) | (ihvtmp[3] ^ ctx->ihv[3]) | (ihvtmp[4] ^ ctx->ihv[4])))
- || (ctx->reduced_round_coll && 0==((ctx->ihv1[0] ^ ctx->ihv2[0]) | (ctx->ihv1[1] ^ ctx->ihv2[1]) | (ctx->ihv1[2] ^ ctx->ihv2[2]) | (ctx->ihv1[3] ^ ctx->ihv2[3]) | (ctx->ihv1[4] ^ ctx->ihv2[4]))))
+ if (ubc_dv_mask[0] & ((uint32_t)(1) << sha1_dvs[i].maskb))
{
- ctx->found_collision = 1;
+ for (j = 0; j < 80; ++j)
+ ctx->m2[j] = ctx->m1[j] ^ sha1_dvs[i].dm[j];
- if (ctx->safe_hash)
+ /* (sha1_recompression_step[sha1_dvs[i].testt])(ctx->ihv2, ihvtmp, ctx->m2, ctx->states[sha1_dvs[i].testt]); */
+ switch (sha1_dvs[i].testt)
{
- sha1_compression_W(ctx->ihv, ctx->m1);
- sha1_compression_W(ctx->ihv, ctx->m1);
+ case 58:
+ sha1recompress_fast_58(ctx->ihv2, ihvtmp, ctx->m2, ctx->states[sha1_dvs[i].testt]);
+ break;
+ case 65:
+ sha1recompress_fast_65(ctx->ihv2, ihvtmp, ctx->m2, ctx->states[sha1_dvs[i].testt]);
+ break;
+ default:
+ abort();
}
+ /* to verify SHA-1 collision detection code with collisions for reduced-step SHA-1 */
+ if ((0 == ((ihvtmp[0] ^ ctx->ihv[0]) | (ihvtmp[1] ^ ctx->ihv[1]) | (ihvtmp[2] ^ ctx->ihv[2]) | (ihvtmp[3] ^ ctx->ihv[3]) | (ihvtmp[4] ^ ctx->ihv[4])))
+ || (ctx->reduced_round_coll && 0==((ctx->ihv1[0] ^ ctx->ihv2[0]) | (ctx->ihv1[1] ^ ctx->ihv2[1]) | (ctx->ihv1[2] ^ ctx->ihv2[2]) | (ctx->ihv1[3] ^ ctx->ihv2[3]) | (ctx->ihv1[4] ^ ctx->ihv2[4]))))
+ {
+ ctx->found_collision = 1;
+
+ if (ctx->safe_hash)
+ {
+ sha1_compression_W(ctx->ihv, ctx->m1);
+ sha1_compression_W(ctx->ihv, ctx->m1);
+ }
- break;
+ break;
+ }
}
}
}