Commit 101752bd authored by Davide Galassi's avatar Davide Galassi

Style check script execution

parent d5aff054
Pipeline #45868760 passed with stages
in 1 minute and 23 seconds
......@@ -11,7 +11,7 @@
* To decrypt the message each ciphertext block of n octets is instead left
* multiplied by the inverse matrix A^-1.
*
* Given the cleartext x=<x1,...,xn> and the ciphertext y=<x1...yn>
* Given the cleartext x=<x1,...,xn> and the ciphertext y=<x1...yn>
* Encryption function: E(x) = A * x = y
* Encryption function: D(y) = A^-1 * y = x
*
......
......@@ -53,4 +53,3 @@ int cry_affine_init(struct cry_affine_ctx *ctx, const unsigned char *keya,
}
return res;
}
......@@ -36,17 +36,17 @@ void cry_cfb_crypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
size_t n;
for (n = len; n >= ctx->vlen; n -= ctx->vlen) {
encrypt(ciph, ctx->v, ctx->v, ctx->vlen);
encrypt(ciph, ctx->v, ctx->v, ctx->vlen);
cry_memxor2(dst, src, ctx->v, ctx->vlen);
memcpy(ctx->v, dst, ctx->vlen);
src += ctx->vlen;
dst += ctx->vlen;
memcpy(ctx->v, dst, ctx->vlen);
src += ctx->vlen;
dst += ctx->vlen;
}
if (n != 0) {
encrypt(ciph, ctx->v, ctx->v, ctx->vlen);
encrypt(ciph, ctx->v, ctx->v, ctx->vlen);
cry_memxor2(dst, src, ctx->v, n);
memcpy(ctx->v, dst, ctx->vlen);
memcpy(ctx->v, dst, ctx->vlen);
}
}
......@@ -61,14 +61,14 @@ void cry_cfb8_encrypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
memcpy(buf, ctx->v, ctx->vlen);
pos = 0;
while (len != 0) {
if (pos == ctx->vlen) {
memcpy(buf, buf + ctx->vlen, ctx->vlen);
pos = 0;
}
encrypt(ciph, ctx->v, buf + pos, ctx->vlen);
buf[pos + ctx->vlen] = *(dst++) = *(src++) ^ ctx->v[0];
len--;
pos++;
if (pos == ctx->vlen) {
memcpy(buf, buf + ctx->vlen, ctx->vlen);
pos = 0;
}
encrypt(ciph, ctx->v, buf + pos, ctx->vlen);
buf[pos + ctx->vlen] = *(dst++) = *(src++) ^ ctx->v[0];
len--;
pos++;
}
memcpy(ctx->v, buf + pos, ctx->vlen);
}
......@@ -86,15 +86,14 @@ void cry_cfb8_decrypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
memcpy(buf + ctx->vlen, src, len < ctx->vlen ? len : ctx->vlen);
while (len != 0) {
for (i = 0; i < len && i < ctx->vlen; i++)
encrypt(ciph, obuf + i, buf + i, ctx->vlen);
cry_memxor2(dst, src, obuf, i);
len -= i;
src += i;
dst += i;
memcpy(buf, buf + ctx->vlen, ctx->vlen);
memcpy(buf + ctx->vlen, src, len < ctx->vlen ? len : ctx->vlen);
for (i = 0; i < len && i < ctx->vlen; i++)
encrypt(ciph, obuf + i, buf + i, ctx->vlen);
cry_memxor2(dst, src, obuf, i);
len -= i;
src += i;
dst += i;
memcpy(buf, buf + ctx->vlen, ctx->vlen);
memcpy(buf + ctx->vlen, src, len < ctx->vlen ? len : ctx->vlen);
}
memcpy(ctx->v, buf + i, ctx->vlen);
}
......@@ -77,7 +77,7 @@ static const unsigned char p_tab[] = {
/* S-Box table.
* In textbooks, the presented S-Box table is usually constructed by
* interpreting the six bits input as
* interpreting the six bits input as
* [ R1 | C3 | C2 | C1 | C0 | R0 ]
* Thus, for example, the output for the bit string 101100 is found
* in row 2 and column 6.
......
......@@ -154,7 +154,7 @@ static void operate(cry_trivium_ctx *ctx, unsigned char *dst,
UPDATE();
ROTATE();
for ( ; i < size; i++, z >>= 8)
dst[i] = src[i] ^ (uint8_t)(z);
dst[i] = src[i] ^ (uint8_t)(z);
}
STORE(ctx->s);
......
......@@ -165,9 +165,9 @@ static void aes_cfb_encrypt(int argc, char *argv[], int do8)
cry_cfb_key_set(&ctx, par.key, par.keylen);
cry_cfb_iv_set(&ctx, par.iv, par.ivlen);
if (do8 == 0)
cry_cfb_encrypt(&ctx, dst, par.src, par.srclen);
cry_cfb_encrypt(&ctx, dst, par.src, par.srclen);
else
cry_cfb8_encrypt(&ctx, dst, par.src, par.srclen);
cry_cfb8_encrypt(&ctx, dst, par.src, par.srclen);
ASSERT_EQ_BUF(dst, par.dst, par.srclen);
}
......@@ -186,9 +186,9 @@ static void aes_cfb_decrypt(int argc, char *argv[], int do8)
cry_cfb_key_set(&ctx, par.key, par.keylen);
cry_cfb_iv_set(&ctx, par.iv, par.ivlen);
if (do8 == 0)
cry_cfb_decrypt(&ctx, dst, par.src, par.srclen);
cry_cfb_decrypt(&ctx, dst, par.src, par.srclen);
else
cry_cfb8_decrypt(&ctx, dst, par.src, par.srclen);
cry_cfb8_decrypt(&ctx, dst, par.src, par.srclen);
ASSERT_EQ_BUF(dst, par.dst, par.srclen);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment