|
@@ -86,11 +86,9 @@ strbuf *argon2_long_hash(unsigned length, ptrlen data)
|
|
|
{
|
|
|
ssh_hash *h = hprime_new(length);
|
|
|
put_datapl(h, data);
|
|
|
- { // WINSCP
|
|
|
strbuf *out = strbuf_new();
|
|
|
hprime_final(h, length, strbuf_append(out, length));
|
|
|
return out;
|
|
|
- } // WINSCP
|
|
|
}
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
@@ -104,9 +102,7 @@ strbuf *argon2_long_hash(unsigned length, ptrlen data)
|
|
|
|
|
|
static inline uint64_t ror(uint64_t x, unsigned rotation)
|
|
|
{
|
|
|
-#pragma option push -w-ngu // WINSCP
|
|
|
unsigned lshift = 63 & -rotation, rshift = 63 & rotation;
|
|
|
-#pragma option pop // WINSCP
|
|
|
return (x << lshift) | (x >> rshift);
|
|
|
}
|
|
|
|
|
@@ -139,8 +135,7 @@ static inline void GB(uint64_t *a, uint64_t *b, uint64_t *c, uint64_t *d)
|
|
|
static inline void P(uint64_t *out, unsigned outstep,
|
|
|
uint64_t *in, unsigned instep)
|
|
|
{
|
|
|
- unsigned i; // WINSCP
|
|
|
- for (i = 0; i < 8; i++) {
|
|
|
+ for (unsigned i = 0; i < 8; i++) {
|
|
|
out[i*outstep] = in[i*instep];
|
|
|
out[i*outstep+1] = in[i*instep+1];
|
|
|
}
|
|
@@ -164,17 +159,16 @@ static void G_xor(uint8_t *out, const uint8_t *X, const uint8_t *Y)
|
|
|
{
|
|
|
uint64_t R[128], Q[128], Z[128];
|
|
|
|
|
|
- unsigned i; // WINSCP
|
|
|
- for (i = 0; i < 128; i++)
|
|
|
+ for (unsigned i = 0; i < 128; i++)
|
|
|
R[i] = GET_64BIT_LSB_FIRST(X + 8*i) ^ GET_64BIT_LSB_FIRST(Y + 8*i);
|
|
|
|
|
|
- for (i = 0; i < 8; i++) // WINSCP
|
|
|
+ for (unsigned i = 0; i < 8; i++)
|
|
|
P(Q+16*i, 2, R+16*i, 2);
|
|
|
|
|
|
- for (i = 0; i < 8; i++) // WINSCP
|
|
|
+ for (unsigned i = 0; i < 8; i++)
|
|
|
P(Z+2*i, 16, Q+2*i, 16);
|
|
|
|
|
|
- for (i = 0; i < 128; i++) // WINSCP
|
|
|
+ for (unsigned i = 0; i < 128; i++)
|
|
|
PUT_64BIT_LSB_FIRST(out + 8*i,
|
|
|
GET_64BIT_LSB_FIRST(out + 8*i) ^ R[i] ^ Z[i]);
|
|
|
|
|
@@ -216,7 +210,6 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
ssh_hash_final(h, h0);
|
|
|
}
|
|
|
|
|
|
- { // WINSCP
|
|
|
struct blk { uint8_t data[1024]; };
|
|
|
|
|
|
/*
|
|
@@ -249,16 +242,14 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
* the long-output hash function H' to hash h0 itself plus the block's
|
|
|
* coordinates in the array.
|
|
|
*/
|
|
|
- { // WINSCP
|
|
|
- size_t i; // WINSCP
|
|
|
- for (i = 0; i < p; i++) {
|
|
|
+ for (size_t i = 0; i < p; i++) {
|
|
|
ssh_hash *h = hprime_new(1024);
|
|
|
put_data(h, h0, 64);
|
|
|
put_uint32_le(h, 0);
|
|
|
put_uint32_le(h, i);
|
|
|
hprime_final(h, 1024, B[i].data);
|
|
|
}
|
|
|
- for (i = 0; i < p; i++) { // WINSCP
|
|
|
+ for (size_t i = 0; i < p; i++) {
|
|
|
ssh_hash *h = hprime_new(1024);
|
|
|
put_data(h, h0, 64);
|
|
|
put_uint32_le(h, 1);
|
|
@@ -283,18 +274,15 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
* independent, and then once we've mixed things up enough, switch over to
|
|
|
* dependent mode to force long serial chains of computation.
|
|
|
*/
|
|
|
- { // WINSCP
|
|
|
size_t jstart = 2;
|
|
|
bool d_mode = (y == 0);
|
|
|
struct blk out2i, tmp2i, in2i;
|
|
|
|
|
|
/* Outermost loop: t whole passes from left to right over the array */
|
|
|
- size_t pass; // WINSCP
|
|
|
- for (pass = 0; pass < t; pass++) {
|
|
|
+ for (size_t pass = 0; pass < t; pass++) {
|
|
|
|
|
|
/* Within that, we process the array in its four main slices */
|
|
|
- unsigned slice; // WINSCP
|
|
|
- for (slice = 0; slice < 4; slice++) {
|
|
|
+ for (unsigned slice = 0; slice < 4; slice++) {
|
|
|
|
|
|
/* In Argon2id mode, if we're half way through the first pass,
|
|
|
* this is the moment to switch d_mode from false to true */
|
|
@@ -303,15 +291,12 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
|
|
|
/* Loop over every segment in the slice (i.e. every row). So i is
|
|
|
* the y-coordinate of each block we process. */
|
|
|
- { // WINSCP
|
|
|
- size_t i; // WINSCP
|
|
|
- for (i = 0; i < p; i++) {
|
|
|
+ for (size_t i = 0; i < p; i++) {
|
|
|
|
|
|
/* And within that segment, process the blocks from left to
|
|
|
* right, starting at 'jstart' (usually 0, but 2 in the first
|
|
|
* slice). */
|
|
|
- size_t jpre; // WINSCP
|
|
|
- for (jpre = jstart; jpre < SL; jpre++) {
|
|
|
+ for (size_t jpre = jstart; jpre < SL; jpre++) {
|
|
|
|
|
|
/* j is the x-coordinate of each block we process, made up
|
|
|
* of the slice number and the index 'jpre' within the
|
|
@@ -406,7 +391,6 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
* because it's already massively randomised from the real
|
|
|
* inputs).
|
|
|
*/
|
|
|
- { // WINSCP
|
|
|
uint32_t index_l = (pass == 0 && slice == 0) ? i : J2 % p;
|
|
|
|
|
|
/*
|
|
@@ -463,7 +447,6 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
}
|
|
|
|
|
|
/* Total number of blocks available to choose from */
|
|
|
- { // WINSCP
|
|
|
uint32_t Wsize = (Wend + q - Wstart) % q;
|
|
|
|
|
|
/* Fiddly computation from the spec that chooses from the
|
|
@@ -483,8 +466,6 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
* in our current output block. */
|
|
|
G_xor(B[i + p * j].data, B[i + p * jm1].data,
|
|
|
B[index_l + p * index_z].data);
|
|
|
- } // WINSCP
|
|
|
- } // WINSCP
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -493,7 +474,6 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
* case it still had its initial value of 2 to avoid the starting
|
|
|
* data. */
|
|
|
jstart = 0;
|
|
|
- } // WINSCP
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -504,10 +484,8 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
* deliver to the caller.
|
|
|
*/
|
|
|
|
|
|
- { // WINSCP
|
|
|
struct blk C = B[p * (q-1)];
|
|
|
- size_t i; // WINSCP
|
|
|
- for (i = 1; i < p; i++)
|
|
|
+ for (size_t i = 1; i < p; i++)
|
|
|
memxor(C.data, C.data, B[i + p * (q-1)].data, 1024);
|
|
|
|
|
|
{
|
|
@@ -525,10 +503,6 @@ static void argon2_internal(uint32_t p, uint32_t T, uint32_t m, uint32_t t,
|
|
|
smemclr(C.data, sizeof(C.data));
|
|
|
smemclr(B, mprime * sizeof(struct blk));
|
|
|
sfree(B);
|
|
|
- } // WINSCP
|
|
|
- } // WINSCP
|
|
|
- } // WINSCP
|
|
|
- } // WINSCP
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -571,7 +545,6 @@ void argon2_choose_passes(
|
|
|
while (true) {
|
|
|
unsigned long start_time = GETTICKCOUNT();
|
|
|
argon2(flavour, mem, b, parallel, taglen, P, S, K, X, out);
|
|
|
- { // WINSCP
|
|
|
unsigned long ticks = GETTICKCOUNT() - start_time;
|
|
|
|
|
|
/* But just in case computers get _too_ fast, we have to cap
|
|
@@ -588,6 +561,5 @@ void argon2_choose_passes(
|
|
|
b += a;
|
|
|
a = b - a;
|
|
|
}
|
|
|
- } // WINSCP
|
|
|
}
|
|
|
}
|