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:
authorMarc Stevens <cr-marcstevens@users.noreply.github.com>2017-02-28 18:02:58 +0300
committerGitHub <noreply@github.com>2017-02-28 18:02:58 +0300
commit1dd0db169a109a63a90c3358391be1bc93d3c008 (patch)
tree281b8cb74c65e04644e68c509ef0d0e5037657d1
parentcb10f50d20a1c6c9efbf526c5da510c492d595b9 (diff)
parent0d80aa0cbb38a69c76457e2f44d84f807d24604f (diff)
Merge pull request #12 from muellermartin/improve-whitespace
Remove trailing whitespace and mixed indentation
-rw-r--r--Makefile4
-rw-r--r--README.md4
-rw-r--r--lib/sha1.c56
-rw-r--r--lib/sha1.h8
-rw-r--r--lib/sha1_simd.cinc56
-rw-r--r--lib/sha1_simd_avx256.c2
-rw-r--r--lib/sha1_simd_neon128.c2
-rw-r--r--lib/sha1_simd_sse128.c2
-rw-r--r--lib/simd_avx256.h6
-rw-r--r--lib/simd_mmx64.h6
-rw-r--r--lib/simd_neon128.h6
-rw-r--r--lib/simd_sse128.h6
-rw-r--r--lib/ubc_check.c4
-rw-r--r--lib/ubc_check_simd_avx256.c2
-rw-r--r--lib/ubc_check_simd_mmx64.c2
-rw-r--r--lib/ubc_check_simd_neon128.c2
-rw-r--r--lib/ubc_check_simd_sse128.c2
-rw-r--r--src/main.c24
18 files changed, 97 insertions, 97 deletions
diff --git a/Makefile b/Makefile
index d4e1659..26b3219 100644
--- a/Makefile
+++ b/Makefile
@@ -126,7 +126,7 @@ sha1dcsum: bin/sha1dcsum
.PHONY: sha1dcsum_partialcoll
sha1dcsum_partialcoll: bin/sha1dcsum
cp bin/sha1dcsum bin/sha1dcsum_partialcoll
-
+
.PHONY: library
library: bin/libdetectcoll.la
@@ -134,7 +134,7 @@ bin/libdetectcoll.la: $(FS_OBJ_LIB)
${LD} ${CFLAGS} $(FS_OBJ_LIB) -o bin/libdetectcoll.la
bin/sha1dcsum: $(FS_OBJ_SRC) library
- ${LD} ${CFLAGS} $(FS_OBJ_SRC) $(FS_OBJ_LIB) -Lbin -ldetectcoll -o bin/sha1dcsum
+ ${LD} ${CFLAGS} $(FS_OBJ_SRC) $(FS_OBJ_LIB) -Lbin -ldetectcoll -o bin/sha1dcsum
${SRC_DEP_DIR}/%.d: ${SRC_DIR}/%.c
diff --git a/README.md b/README.md
index da32271..2fa9f28 100644
--- a/README.md
+++ b/README.md
@@ -18,8 +18,8 @@ They will compute the SHA-1 hash of any given file and additionally will detect
More specifically they will detect any cryptanalytic collision attack against SHA-1 using any of the top 32 SHA-1 disturbance vectors with probability 1:
```
- I(43,0), I(44,0), I(45,0), I(46,0), I(47,0), I(48,0), I(49,0), I(50,0), I(51,0), I(52,0),
- I(46,2), I(47,2), I(48,2), I(49,2), I(50,2), I(51,2),
+ I(43,0), I(44,0), I(45,0), I(46,0), I(47,0), I(48,0), I(49,0), I(50,0), I(51,0), I(52,0),
+ I(46,2), I(47,2), I(48,2), I(49,2), I(50,2), I(51,2),
II(45,0), II(46,0), II(47,0), II(48,0), II(49,0), II(50,0), II(51,0), II(52,0), II(53,0), II(54,0), II(55,0), II(56,0),
II(46,2), II(49,2), II(50,2), II(51,2)
```
diff --git a/lib/sha1.c b/lib/sha1.c
index ed20109..7920c96 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -1,5 +1,5 @@
/***
-* Copyright 2017 Marc Stevens <marc@marc-stevens.nl>, Dan Shumow (danshu@microsoft.com)
+* Copyright 2017 Marc Stevens <marc@marc-stevens.nl>, Dan Shumow (danshu@microsoft.com)
* Distributed under the MIT Software License.
* See accompanying file LICENSE.txt or copy at
* https://opensource.org/licenses/MIT
@@ -185,7 +185,7 @@ void sha1_compression_W(uint32_t ihv[5], const uint32_t W[80])
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30);
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31);
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 32);
- HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33);
+ HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33);
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 34);
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35);
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36);
@@ -355,12 +355,12 @@ void sha1_compression_states(uint32_t ihv[5], const uint32_t W[80], uint32_t sta
SHA1_STORE_STATE(21)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21);
-
+
#ifdef DOSTORESTATE22
SHA1_STORE_STATE(22)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22);
-
+
#ifdef DOSTORESTATE23
SHA1_STORE_STATE(23)
#endif
@@ -385,27 +385,27 @@ void sha1_compression_states(uint32_t ihv[5], const uint32_t W[80], uint32_t sta
SHA1_STORE_STATE(27)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27);
-
+
#ifdef DOSTORESTATE28
SHA1_STORE_STATE(28)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28);
-
+
#ifdef DOSTORESTATE29
SHA1_STORE_STATE(29)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29);
-
+
#ifdef DOSTORESTATE30
SHA1_STORE_STATE(30)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30);
-
+
#ifdef DOSTORESTATE31
SHA1_STORE_STATE(31)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31);
-
+
#ifdef DOSTORESTATE32
SHA1_STORE_STATE(32)
#endif
@@ -425,22 +425,22 @@ void sha1_compression_states(uint32_t ihv[5], const uint32_t W[80], uint32_t sta
SHA1_STORE_STATE(35)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35);
-
+
#ifdef DOSTORESTATE36
SHA1_STORE_STATE(36)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36);
-
+
#ifdef DOSTORESTATE37
SHA1_STORE_STATE(37)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37);
-
+
#ifdef DOSTORESTATE38
SHA1_STORE_STATE(38)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38);
-
+
#ifdef DOSTORESTATE39
SHA1_STORE_STATE(39)
#endif
@@ -547,7 +547,7 @@ void sha1_compression_states(uint32_t ihv[5], const uint32_t W[80], uint32_t sta
SHA1_STORE_STATE(59)
#endif
HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59);
-
+
@@ -826,7 +826,7 @@ void sha1recompress_fast_ ## t (uint32_t ihvin[5], uint32_t ihvout[5], const uin
if (t <= 78) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 78); \
if (t <= 79) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 79); \
ihvout[0] = ihvin[0] + a; ihvout[1] = ihvin[1] + b; ihvout[2] = ihvin[2] + c; ihvout[3] = ihvin[3] + d; ihvout[4] = ihvin[4] + e; \
-}
+}
SHA1_RECOMPRESS(0)
SHA1_RECOMPRESS(1)
@@ -932,7 +932,7 @@ sha1_recompression_type sha1_recompression_step[80] =
-void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])
+void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])
{
unsigned i, j;
uint32_t ubc_dv_mask[DVMASKSIZE];
@@ -953,7 +953,7 @@ void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])
sha1_compression_states(ctx->ihv, ctx->m1, ctx->states);
if (ctx->detect_coll)
{
- for (i = 0; sha1_dvs[i].dvType != 0; ++i)
+ for (i = 0; sha1_dvs[i].dvType != 0; ++i)
{
if ((0 == ctx->ubc_check) || (((uint32_t)(1) << sha1_dvs[i].maskb) & ubc_dv_mask[sha1_dvs[i].maski]))
{
@@ -969,7 +969,7 @@ void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])
if (ctx->callback != NULL)
ctx->callback(ctx->total - 64, ctx->ihv1, ctx->ihv2, ctx->m1, ctx->m2);
- if (ctx->safe_hash)
+ if (ctx->safe_hash)
{
sha1_compression_W(ctx->ihv, ctx->m1);
sha1_compression_W(ctx->ihv, ctx->m1);
@@ -986,17 +986,17 @@ void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])
-void swap_bytes(uint32_t val[16])
+void swap_bytes(uint32_t val[16])
{
unsigned i;
- for (i = 0; i < 16; ++i)
+ for (i = 0; i < 16; ++i)
{
val[i] = ((val[i] << 8) & 0xFF00FF00) | ((val[i] >> 8) & 0xFF00FF);
val[i] = (val[i] << 16) | (val[i] >> 16);
}
}
-void SHA1DCInit(SHA1_CTX* ctx)
+void SHA1DCInit(SHA1_CTX* ctx)
{
static const union { unsigned char bytes[4]; uint32_t value; } endianness = { { 0, 1, 2, 3 } };
static const uint32_t littleendian = 0x03020100;
@@ -1053,16 +1053,16 @@ void SHA1DCSetCallback(SHA1_CTX* ctx, collision_block_callback callback)
ctx->callback = callback;
}
-void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, unsigned len)
+void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, unsigned len)
{
unsigned left, fill;
- if (len == 0)
+ if (len == 0)
return;
left = ctx->total & 63;
fill = 64 - left;
- if (left && len >= fill)
+ if (left && len >= fill)
{
ctx->total += fill;
memcpy(ctx->buffer + left, buf, fill);
@@ -1073,10 +1073,10 @@ void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, unsigned len)
len -= fill;
left = 0;
}
- while (len >= 64)
+ while (len >= 64)
{
ctx->total += 64;
- if (!ctx->bigendian)
+ if (!ctx->bigendian)
{
memcpy(ctx->buffer, buf, 64);
swap_bytes((uint32_t*)(ctx->buffer));
@@ -1087,7 +1087,7 @@ void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, unsigned len)
buf += 64;
len -= 64;
}
- if (len > 0)
+ if (len > 0)
{
ctx->total += len;
memcpy(ctx->buffer + left, buf, len);
@@ -1108,7 +1108,7 @@ int SHA1DCFinal(unsigned char output[20], SHA1_CTX *ctx)
uint32_t padn = (last < 56) ? (56 - last) : (120 - last);
uint64_t total;
SHA1DCUpdate(ctx, (const char*)(sha1_padding), padn);
-
+
total = ctx->total - padn;
total <<= 3;
ctx->buffer[56] = (unsigned char)(total >> 56);
diff --git a/lib/sha1.h b/lib/sha1.h
index 8b522f9..6f7d4d7 100644
--- a/lib/sha1.h
+++ b/lib/sha1.h
@@ -55,17 +55,17 @@ typedef struct {
} SHA1_CTX;
// initialize SHA-1 context
-void SHA1DCInit(SHA1_CTX*);
+void SHA1DCInit(SHA1_CTX*);
// function to enable safe SHA-1 hashing:
// collision attacks are thwarted by hashing a detected near-collision block 3 times
// think of it as extending SHA-1 from 80-steps to 240-steps for such blocks:
-// the best collision attacks against SHA-1 have complexity about 2^60,
+// the best collision attacks against SHA-1 have complexity about 2^60,
// thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would 2^180
// an attacker would be better off using a generic birthday search of complexity 2^80
//
// enabling safe SHA-1 hashing will result in the correct SHA-1 hash for messages where no collision attack was detected
-// but it will result in a different SHA-1 hash for messages where a collision attack was detected
+// but it will result in a different SHA-1 hash for messages where a collision attack was detected
// this will automatically invalidate SHA-1 based digital signature forgeries
// enabled by default
void SHA1DCSetSafeHash(SHA1_CTX*, int);
@@ -91,4 +91,4 @@ void SHA1DCUpdate(SHA1_CTX*, const char*, unsigned);
// obtain SHA-1 hash from SHA-1 context
// returns: 0 = no collision detected, otherwise = collision found => warn user for active attack
-int SHA1DCFinal(unsigned char[20], SHA1_CTX*);
+int SHA1DCFinal(unsigned char[20], SHA1_CTX*);
diff --git a/lib/sha1_simd.cinc b/lib/sha1_simd.cinc
index b0f84ad..fed569d 100644
--- a/lib/sha1_simd.cinc
+++ b/lib/sha1_simd.cinc
@@ -132,11 +132,11 @@ void SHA1_COMPRESSION_SIMD(SIMD_WORD* ihv, const SIMD_WORD* m)
HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78);
HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79);
- ihv[0] = SIMD_ADD_VV(ihv[0],a);
- ihv[1] = SIMD_ADD_VV(ihv[1],b);
- ihv[2] = SIMD_ADD_VV(ihv[2],c);
- ihv[3] = SIMD_ADD_VV(ihv[3],d);
- ihv[4] = SIMD_ADD_VV(ihv[4],e);
+ ihv[0] = SIMD_ADD_VV(ihv[0],a);
+ ihv[1] = SIMD_ADD_VV(ihv[1],b);
+ ihv[2] = SIMD_ADD_VV(ihv[2],c);
+ ihv[3] = SIMD_ADD_VV(ihv[3],d);
+ ihv[4] = SIMD_ADD_VV(ihv[4],e);
}
@@ -229,11 +229,11 @@ void SHA1_COMPRESSION_W_SIMD(SIMD_WORD* ihv, const SIMD_WORD* W)
HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78);
HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79);
- ihv[0] = SIMD_ADD_VV(ihv[0],a);
- ihv[1] = SIMD_ADD_VV(ihv[1],b);
- ihv[2] = SIMD_ADD_VV(ihv[2],c);
- ihv[3] = SIMD_ADD_VV(ihv[3],d);
- ihv[4] = SIMD_ADD_VV(ihv[4],e);
+ ihv[0] = SIMD_ADD_VV(ihv[0],a);
+ ihv[1] = SIMD_ADD_VV(ihv[1],b);
+ ihv[2] = SIMD_ADD_VV(ihv[2],c);
+ ihv[3] = SIMD_ADD_VV(ihv[3],d);
+ ihv[4] = SIMD_ADD_VV(ihv[4],e);
}
@@ -358,12 +358,12 @@ void SHA1_COMPRESSION_STATES_SIMD(SIMD_WORD* ihv, const SIMD_WORD* W, SIMD_WORD*
SHA1_STORE_STATE(21)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21);
-
+
#ifdef DOSTORESTATE22
SHA1_STORE_STATE(22)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22);
-
+
#ifdef DOSTORESTATE23
SHA1_STORE_STATE(23)
#endif
@@ -388,27 +388,27 @@ void SHA1_COMPRESSION_STATES_SIMD(SIMD_WORD* ihv, const SIMD_WORD* W, SIMD_WORD*
SHA1_STORE_STATE(27)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27);
-
+
#ifdef DOSTORESTATE28
SHA1_STORE_STATE(28)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28);
-
+
#ifdef DOSTORESTATE29
SHA1_STORE_STATE(29)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29);
-
+
#ifdef DOSTORESTATE30
SHA1_STORE_STATE(30)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30);
-
+
#ifdef DOSTORESTATE31
SHA1_STORE_STATE(31)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31);
-
+
#ifdef DOSTORESTATE32
SHA1_STORE_STATE(32)
#endif
@@ -428,22 +428,22 @@ void SHA1_COMPRESSION_STATES_SIMD(SIMD_WORD* ihv, const SIMD_WORD* W, SIMD_WORD*
SHA1_STORE_STATE(35)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35);
-
+
#ifdef DOSTORESTATE36
SHA1_STORE_STATE(36)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36);
-
+
#ifdef DOSTORESTATE37
SHA1_STORE_STATE(37)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37);
-
+
#ifdef DOSTORESTATE38
SHA1_STORE_STATE(38)
#endif
HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38);
-
+
#ifdef DOSTORESTATE39
SHA1_STORE_STATE(39)
#endif
@@ -550,7 +550,7 @@ void SHA1_COMPRESSION_STATES_SIMD(SIMD_WORD* ihv, const SIMD_WORD* W, SIMD_WORD*
SHA1_STORE_STATE(59)
#endif
HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59);
-
+
@@ -656,11 +656,11 @@ void SHA1_COMPRESSION_STATES_SIMD(SIMD_WORD* ihv, const SIMD_WORD* W, SIMD_WORD*
- ihv[0] = SIMD_ADD_VV(ihv[0],a);
- ihv[1] = SIMD_ADD_VV(ihv[1],b);
- ihv[2] = SIMD_ADD_VV(ihv[2],c);
- ihv[3] = SIMD_ADD_VV(ihv[3],d);
- ihv[4] = SIMD_ADD_VV(ihv[4],e);
+ ihv[0] = SIMD_ADD_VV(ihv[0],a);
+ ihv[1] = SIMD_ADD_VV(ihv[1],b);
+ ihv[2] = SIMD_ADD_VV(ihv[2],c);
+ ihv[3] = SIMD_ADD_VV(ihv[3],d);
+ ihv[4] = SIMD_ADD_VV(ihv[4],e);
}
@@ -846,7 +846,7 @@ void SHA1_RECOMPRESSION_SIMD(tttt) (SIMD_WORD* ihvin, SIMD_WORD* ihvout, const S
ihvout[2] = SIMD_ADD_VV(ihvin[2],c); \
ihvout[3] = SIMD_ADD_VV(ihvin[3],d); \
ihvout[4] = SIMD_ADD_VV(ihvin[4],e); \
-}
+}
SHA1_RECOMPRESS(0)
SHA1_RECOMPRESS(1)
diff --git a/lib/sha1_simd_avx256.c b/lib/sha1_simd_avx256.c
index 2c11c76..9a85bd2 100644
--- a/lib/sha1_simd_avx256.c
+++ b/lib/sha1_simd_avx256.c
@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
***/
-// this file generates avx256 code using avx256 MACROS (simd_avx256.h) and generic SIMD code (sha1_simd.cinc)
+// this file generates avx256 code using avx256 MACROS (simd_avx256.h) and generic SIMD code (sha1_simd.cinc)
#ifdef HAVE_AVX
#include "sha1.h"
diff --git a/lib/sha1_simd_neon128.c b/lib/sha1_simd_neon128.c
index 0641f02..29ebb7f 100644
--- a/lib/sha1_simd_neon128.c
+++ b/lib/sha1_simd_neon128.c
@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
***/
-// this file generates neon 32x4 code using neon MACROS (arm_neon.h) and generic SIMD code (sha1_simd.cinc)
+// this file generates neon 32x4 code using neon MACROS (arm_neon.h) and generic SIMD code (sha1_simd.cinc)
#ifdef HAVE_NEON
#include "sha1.h"
diff --git a/lib/sha1_simd_sse128.c b/lib/sha1_simd_sse128.c
index 180035f..3f3dcae 100644
--- a/lib/sha1_simd_sse128.c
+++ b/lib/sha1_simd_sse128.c
@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
***/
-// this file generates sse128 code using sse128 MACROS (simd_sse128.h) and generic SIMD code (sha1_simd.cinc)
+// this file generates sse128 code using sse128 MACROS (simd_sse128.h) and generic SIMD code (sha1_simd.cinc)
#ifdef HAVE_SSE
#include "sha1.h"
diff --git a/lib/simd_avx256.h b/lib/simd_avx256.h
index 5643c93..8f3fee7 100644
--- a/lib/simd_avx256.h
+++ b/lib/simd_avx256.h
@@ -6,7 +6,7 @@
***/
// this header defines SIMD MACROS for avx256 intrinsics
-// used to generate avx256 code from generic SIMD code (sha1_simd.cinc, ubc_check_simd.cinc)
+// used to generate avx256 code from generic SIMD code (sha1_simd.cinc, ubc_check_simd.cinc)
#ifndef SIMD_AVX256_HEADER
#define SIMD_AVX256_HEADER
@@ -23,7 +23,7 @@
#define SIMD_WORD __m256i
#define SIMD_ZERO _mm256_setzero_si256()
-#define SIMD_WTOV(l) _mm256_set1_epi32(l)
+#define SIMD_WTOV(l) _mm256_set1_epi32(l)
#define SIMD_ADD_VV(l,r) _mm256_add_epi32(l,r)
#define SIMD_ADD_VW(l,r) _mm256_add_epi32(l, _mm256_set1_epi32(r))
#define SIMD_SUB_VV(l,r) _mm256_sub_epi32(l,r)
@@ -50,7 +50,7 @@
#define SIMD_WORD __m256i
#define SIMD_ZERO _mm256_setzero_si256()
-#define SIMD_WTOV(l) _mm256_set1_epi32(l)
+#define SIMD_WTOV(l) _mm256_set1_epi32(l)
#define SIMD_ADD_VV(l,r) _mm256_add_epi32(l,r)
#define SIMD_ADD_VW(l,r) _mm256_add_epi32(l, _mm256_set1_epi32(r))
#define SIMD_SUB_VV(l,r) _mm256_sub_epi32(l,r)
diff --git a/lib/simd_mmx64.h b/lib/simd_mmx64.h
index 2859e4e..254d132 100644
--- a/lib/simd_mmx64.h
+++ b/lib/simd_mmx64.h
@@ -6,7 +6,7 @@
***/
// this header defines SIMD MACROS for sse128 intrinsics
-// used to generate sse128 code from generic SIMD code (sha1_simd.cinc, ubc_check_simd.cinc)
+// used to generate sse128 code from generic SIMD code (sha1_simd.cinc, ubc_check_simd.cinc)
#ifndef SIMD_MMX64_HEADER
#define SIMD_MMX64_HEADER
@@ -20,7 +20,7 @@
#define SIMD_WORD __m64
#define SIMD_ZERO _mm_setzero_si64()
-#define SIMD_WTOV(l) _mm_set1_pi32(l)
+#define SIMD_WTOV(l) _mm_set1_pi32(l)
#define SIMD_ADD_VV(l,r) _mm_add_pi32(l,r)
#define SIMD_ADD_VW(l,r) _mm_add_pi32(l, _mm_set1_pi32(r))
#define SIMD_SUB_VV(l,r) _mm_sub_pi32(l,r)
@@ -47,7 +47,7 @@
#define SIMD_WORD __m64
#define SIMD_ZERO _mm_setzero_si64()
-#define SIMD_WTOV(l) _mm_set1_pi32(l)
+#define SIMD_WTOV(l) _mm_set1_pi32(l)
#define SIMD_ADD_VV(l,r) _mm_add_pi32(l,r)
#define SIMD_ADD_VW(l,r) _mm_add_pi32(l, _mm_set1_pi32(r))
#define SIMD_SUB_VV(l,r) _mm_sub_pi32(l,r)
diff --git a/lib/simd_neon128.h b/lib/simd_neon128.h
index 2781e40..9b1e314 100644
--- a/lib/simd_neon128.h
+++ b/lib/simd_neon128.h
@@ -6,7 +6,7 @@
***/
// this header defines SIMD MACROS for sse128 intrinsics
-// used to generate sse128 code from generic SIMD code (sha1_simd.cinc, ubc_check_simd.cinc)
+// used to generate sse128 code from generic SIMD code (sha1_simd.cinc, ubc_check_simd.cinc)
#ifndef SIMD_NEON128_HEADER
#define SIMD_NEON128_HEADER
@@ -22,7 +22,7 @@
#define SIMD_WORD int32x4_t
#define SIMD_ZERO vmovq_n_s32(0)
-#define SIMD_WTOV(l) vmovq_n_s32(l)
+#define SIMD_WTOV(l) vmovq_n_s32(l)
#define SIMD_ADD_VV(l,r) vaddq_s32(l,r)
#define SIMD_ADD_VW(l,r) vaddq_s32(l, vmovq_n_s32(r))
#define SIMD_SUB_VV(l,r) vsubq_s32(l,r)
@@ -49,7 +49,7 @@
#define SIMD_WORD __m128i
#define SIMD_ZERO _mm_setzero_si128()
-#define SIMD_WTOV(l) _mm_set1_epi32(l)
+#define SIMD_WTOV(l) _mm_set1_epi32(l)
#define SIMD_ADD_VV(l,r) _mm_add_epi32(l,r)
#define SIMD_ADD_VW(l,r) _mm_add_epi32(l, _mm_set1_epi32(r))
#define SIMD_SUB_VV(l,r) _mm_sub_epi32(l,r)
diff --git a/lib/simd_sse128.h b/lib/simd_sse128.h
index cfbb9d0..927417a 100644
--- a/lib/simd_sse128.h
+++ b/lib/simd_sse128.h
@@ -6,7 +6,7 @@
***/
// this header defines SIMD MACROS for sse128 intrinsics
-// used to generate sse128 code from generic SIMD code (sha1_simd.cinc, ubc_check_simd.cinc)
+// used to generate sse128 code from generic SIMD code (sha1_simd.cinc, ubc_check_simd.cinc)
#ifndef SIMD_SSE128_HEADER
#define SIMD_SSE128_HEADER
@@ -22,7 +22,7 @@
#define SIMD_WORD __m128i
#define SIMD_ZERO _mm_setzero_si128()
-#define SIMD_WTOV(l) _mm_set1_epi32(l)
+#define SIMD_WTOV(l) _mm_set1_epi32(l)
#define SIMD_ADD_VV(l,r) _mm_add_epi32(l,r)
#define SIMD_ADD_VW(l,r) _mm_add_epi32(l, _mm_set1_epi32(r))
#define SIMD_SUB_VV(l,r) _mm_sub_epi32(l,r)
@@ -49,7 +49,7 @@
#define SIMD_WORD __m128i
#define SIMD_ZERO _mm_setzero_si128()
-#define SIMD_WTOV(l) _mm_set1_epi32(l)
+#define SIMD_WTOV(l) _mm_set1_epi32(l)
#define SIMD_ADD_VV(l,r) _mm_add_epi32(l,r)
#define SIMD_ADD_VW(l,r) _mm_add_epi32(l, _mm_set1_epi32(r))
#define SIMD_SUB_VV(l,r) _mm_sub_epi32(l,r)
diff --git a/lib/ubc_check.c b/lib/ubc_check.c
index 556aaf3..6e0ffca 100644
--- a/lib/ubc_check.c
+++ b/lib/ubc_check.c
@@ -17,7 +17,7 @@
// ubc_check takes as input an expanded message block and verifies the unavoidable bitconditions for all listed DVs
// it returns a dvmask where each bit belonging to a DV is set if all unavoidable bitconditions for that DV have been met
// thus one needs to do the recompression check for each DV that has its bit set
-//
+//
// ubc_check is programmatically generated and the unavoidable bitconditions have been hardcoded
// a directly verifiable version named ubc_check_verify can be found in ubc_check_verify.c
// ubc_check has been verified against ubc_check_verify using the 'ubc_check_test' program in the tools section
@@ -58,7 +58,7 @@ static const uint32_t DV_II_54_0_bit = (uint32_t)(1) << 29;
static const uint32_t DV_II_55_0_bit = (uint32_t)(1) << 30;
static const uint32_t DV_II_56_0_bit = (uint32_t)(1) << 31;
-dv_info_t sha1_dvs[] =
+dv_info_t sha1_dvs[] =
{
{1,43,0,58,0,0, { 0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c,0x00000803,0x80000161,0x80000599 } }
, {1,44,0,58,0,1, { 0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c,0x00000803,0x80000161 } }
diff --git a/lib/ubc_check_simd_avx256.c b/lib/ubc_check_simd_avx256.c
index e77c45b..fefb5ba 100644
--- a/lib/ubc_check_simd_avx256.c
+++ b/lib/ubc_check_simd_avx256.c
@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
***/
-// this file generates avx256 code using avx256 MACROS (simd_avx256.h) and generic SIMD code (ubc_check_simd.cinc)
+// this file generates avx256 code using avx256 MACROS (simd_avx256.h) and generic SIMD code (ubc_check_simd.cinc)
#ifdef HAVE_AVX
#include "ubc_check.h"
#include "simd_avx256.h"
diff --git a/lib/ubc_check_simd_mmx64.c b/lib/ubc_check_simd_mmx64.c
index 12b2323..3495f22 100644
--- a/lib/ubc_check_simd_mmx64.c
+++ b/lib/ubc_check_simd_mmx64.c
@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
***/
-// this file generates sse128 code using sse128 MACROS (simd_sse128.h) and generic SIMD code (ubc_check_simd.cinc)
+// this file generates sse128 code using sse128 MACROS (simd_sse128.h) and generic SIMD code (ubc_check_simd.cinc)
#ifdef HAVE_MMX
#include "ubc_check.h"
#include "simd_mmx64.h"
diff --git a/lib/ubc_check_simd_neon128.c b/lib/ubc_check_simd_neon128.c
index 1af96c0..100a975 100644
--- a/lib/ubc_check_simd_neon128.c
+++ b/lib/ubc_check_simd_neon128.c
@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
***/
-// this file generates neon 32x4 code using neon MACROS (arm_neon.h) and generic SIMD code (sha1_simd.cinc)
+// this file generates neon 32x4 code using neon MACROS (arm_neon.h) and generic SIMD code (sha1_simd.cinc)
#ifdef HAVE_NEON
#include "ubc_check.h"
#include "simd_neon128.h"
diff --git a/lib/ubc_check_simd_sse128.c b/lib/ubc_check_simd_sse128.c
index 63147c6..4b3b009 100644
--- a/lib/ubc_check_simd_sse128.c
+++ b/lib/ubc_check_simd_sse128.c
@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
***/
-// this file generates sse128 code using sse128 MACROS (simd_sse128.h) and generic SIMD code (ubc_check_simd.cinc)
+// this file generates sse128 code using sse128 MACROS (simd_sse128.h) and generic SIMD code (ubc_check_simd.cinc)
#ifdef HAVE_SSE
#include "ubc_check.h"
#include "simd_sse128.h"
diff --git a/src/main.c b/src/main.c
index fe09107..90f6f28 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,7 +12,7 @@
#include "sha1.h"
-int main(int argc, char** argv)
+int main(int argc, char** argv)
{
FILE* fd;
unsigned char hash2[20];
@@ -21,18 +21,18 @@ int main(int argc, char** argv)
SHA1_CTX ctx2;
int i,j;
- if (argc < 2)
+ if (argc < 2)
{
printf("Usage: %s <file>\n", basename(argv[0]));
return 1;
}
- for (i=1; i < argc; ++i)
+ for (i=1; i < argc; ++i)
{
// initialize SHA-1 context
SHA1DCInit(&ctx2);
- // if the program name includes the word 'partial' then also test for reduced-round SHA-1 collisions
+ // if the program name includes the word 'partial' then also test for reduced-round SHA-1 collisions
if (NULL != strstr(argv[0], "partial"))
{
SHA1DCSetDetectReducedRoundCollision(&ctx2, 1);
@@ -40,26 +40,26 @@ int main(int argc, char** argv)
// open file
fd = fopen(argv[i], "rb");
- if (fd == NULL)
+ if (fd == NULL)
{
printf("cannot open file: %s\n", argv[i]);
return 1;
}
// feed file through SHA-1 update function
- while (1)
+ while (1)
{
size=fread(buffer,1,65536,fd);
SHA1DCUpdate(&ctx2, buffer, (unsigned)(size));
if (size != 65536)
break;
}
- if (ferror(fd))
+ if (ferror(fd))
{
printf("error while reading file: %s\n", argv[i]);
return 1;
}
- if (!feof(fd))
+ if (!feof(fd))
{
printf("not end of file?: %s\n",argv[i]);
return 1;
@@ -68,15 +68,15 @@ int main(int argc, char** argv)
// obtain SHA-1 and print it
SHA1DCFinal(hash2,&ctx2);
for (j = 0; j < 20; ++j)
- {
+ {
sprintf(buffer+(j*2), "%02x", hash2[j]);
}
buffer[20*2] = 0;
- if (ctx2.found_collision)
+ if (ctx2.found_collision)
{
printf("%s *coll* %s\n", buffer, argv[i]);
- }
- else
+ }
+ else
{
printf("%s %s\n", buffer, argv[i]);
}