commit
01bb22e865
@ -171,7 +171,7 @@ static const ulong32 SP4404[] = {
|
||||
0x28280028, 0x7b7b007b, 0xc9c900c9, 0xc1c100c1, 0xe3e300e3, 0xf4f400f4, 0xc7c700c7, 0x9e9e009e,
|
||||
};
|
||||
|
||||
static ulong64 key_sigma[] = {
|
||||
static const ulong64 key_sigma[] = {
|
||||
CONST64(0xA09E667F3BCC908B),
|
||||
CONST64(0xB67AE8584CAA73B2),
|
||||
CONST64(0xC6EF372FE94F82BE),
|
||||
|
@ -96,9 +96,9 @@ static void decrypt(ulong32 *p, int N, ulong32 *uk)
|
||||
int n, t;
|
||||
for (t = 4*(((N-1)>>2)&1), n = N; ; ) {
|
||||
switch (n<=4 ? n : ((n-1)%4)+1) {
|
||||
case 4: pi4(p, uk+t); --n;
|
||||
case 3: pi3(p, uk+t); --n;
|
||||
case 2: pi2(p, uk+t); --n;
|
||||
case 4: pi4(p, uk+t); --n; /* FALLTHROUGH */
|
||||
case 3: pi3(p, uk+t); --n; /* FALLTHROUGH */
|
||||
case 2: pi2(p, uk+t); --n; /* FALLTHROUGH */
|
||||
case 1: pi1(p); --n; break;
|
||||
case 0: return;
|
||||
}
|
||||
|
@ -480,6 +480,7 @@ int safer_sk128_test(void)
|
||||
for (y = 0; y < 1000; y++) safer_ecb_encrypt(buf[0], buf[0], &skey);
|
||||
for (y = 0; y < 1000; y++) safer_ecb_decrypt(buf[0], buf[0], &skey);
|
||||
for (y = 0; y < 8; y++) if (buf[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
|
||||
|
||||
return CRYPT_OK;
|
||||
#endif
|
||||
}
|
||||
|
@ -252,16 +252,19 @@ static void h_func(const unsigned char *in, unsigned char *out, unsigned char *M
|
||||
y[1] = (unsigned char)(sbox(0, (ulong32)y[1]) ^ M[4 * (6 + offset) + 1]);
|
||||
y[2] = (unsigned char)(sbox(0, (ulong32)y[2]) ^ M[4 * (6 + offset) + 2]);
|
||||
y[3] = (unsigned char)(sbox(1, (ulong32)y[3]) ^ M[4 * (6 + offset) + 3]);
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
y[0] = (unsigned char)(sbox(1, (ulong32)y[0]) ^ M[4 * (4 + offset) + 0]);
|
||||
y[1] = (unsigned char)(sbox(1, (ulong32)y[1]) ^ M[4 * (4 + offset) + 1]);
|
||||
y[2] = (unsigned char)(sbox(0, (ulong32)y[2]) ^ M[4 * (4 + offset) + 2]);
|
||||
y[3] = (unsigned char)(sbox(0, (ulong32)y[3]) ^ M[4 * (4 + offset) + 3]);
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
y[0] = (unsigned char)(sbox(1, sbox(0, sbox(0, (ulong32)y[0]) ^ M[4 * (2 + offset) + 0]) ^ M[4 * (0 + offset) + 0]));
|
||||
y[1] = (unsigned char)(sbox(0, sbox(0, sbox(1, (ulong32)y[1]) ^ M[4 * (2 + offset) + 1]) ^ M[4 * (0 + offset) + 1]));
|
||||
y[2] = (unsigned char)(sbox(1, sbox(1, sbox(0, (ulong32)y[2]) ^ M[4 * (2 + offset) + 2]) ^ M[4 * (0 + offset) + 2]));
|
||||
y[3] = (unsigned char)(sbox(0, sbox(1, sbox(1, (ulong32)y[3]) ^ M[4 * (2 + offset) + 3]) ^ M[4 * (0 + offset) + 3]));
|
||||
/* FALLTHROUGH */
|
||||
}
|
||||
mds_mult(y, out);
|
||||
}
|
||||
|
@ -89,16 +89,16 @@ void adler32_finish(adler32_state *ctx, void *hash, unsigned long size)
|
||||
switch (size) {
|
||||
default:
|
||||
h[3] = ctx->s[0] & 0x0ff;
|
||||
/* no break */
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
h[2] = (ctx->s[0] >> 8) & 0x0ff;
|
||||
/* no break */
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
h[1] = ctx->s[1] & 0x0ff;
|
||||
/* no break */
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
h[0] = (ctx->s[1] >> 8) & 0x0ff;
|
||||
/* no break */
|
||||
/* FALLTHROUGH */
|
||||
case 0:
|
||||
;
|
||||
}
|
||||
|
@ -20,12 +20,12 @@
|
||||
#if defined(LTC_BASE64) || defined (LTC_BASE64_URL)
|
||||
|
||||
#if defined(LTC_BASE64)
|
||||
static const char *codes_base64 =
|
||||
static const char * const codes_base64 =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
#endif /* LTC_BASE64 */
|
||||
|
||||
#if defined(LTC_BASE64_URL)
|
||||
static const char *codes_base64url =
|
||||
static const char * const codes_base64url =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
||||
#endif /* LTC_BASE64_URL */
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
Convert error codes to ASCII strings, Tom St Denis
|
||||
*/
|
||||
|
||||
static const char *err_2_str[] =
|
||||
static const char * const err_2_str[] =
|
||||
{
|
||||
"CRYPT_OK",
|
||||
"CRYPT_ERROR",
|
||||
|
@ -9,7 +9,6 @@
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -9,7 +9,6 @@
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#ifdef LTC_DER
|
||||
|
||||
static const char *baseten = "0123456789";
|
||||
static const char * const baseten = "0123456789";
|
||||
|
||||
#define STORE_V(y) \
|
||||
out[x++] = der_ia5_char_encode(baseten[(y/10) % 10]); \
|
||||
|
@ -80,7 +80,6 @@ static unsigned long rng_ansic(unsigned char *buf, unsigned long len,
|
||||
acc = 0;
|
||||
bits = 8;
|
||||
}
|
||||
acc = bits = a = b = 0;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user