Merge branch 'fix/anubis' into develop

This commit is contained in:
Steffen Jaeckel 2014-05-01 23:02:40 +02:00
commit be5418368c

View File

@ -32,14 +32,14 @@ const struct ltc_cipher_descriptor anubis_desc = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
#define MIN_N 4
#define MAX_N 10
#define MIN_ROUNDS (8 + MIN_N)
#define MAX_ROUNDS (8 + MAX_N)
#define MIN_KEYSIZEB (4*MIN_N)
#define MAX_KEYSIZEB (4*MAX_N)
#define BLOCKSIZE 128
#define BLOCKSIZEB (BLOCKSIZE/8)
#define MIN_N 4
#define MAX_N 10
#define MIN_ROUNDS (8 + MIN_N)
#define MAX_ROUNDS (8 + MAX_N)
#define MIN_KEYSIZEB (4*MIN_N)
#define MAX_KEYSIZEB (4*MAX_N)
#define BLOCKSIZE 128
#define BLOCKSIZEB (BLOCKSIZE/8)
/*
@ -931,10 +931,10 @@ int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetri
*/
for (i = 0, pos = 0; i < N; i++, pos += 4) {
kappa[i] =
(key[pos ] << 24) ^
(key[pos + 1] << 16) ^
(key[pos + 2] << 8) ^
(key[pos + 3] );
(((ulong32)key[pos ]) << 24) ^
(((ulong32)key[pos + 1]) << 16) ^
(((ulong32)key[pos + 2]) << 8) ^
(((ulong32)key[pos + 3]) );
}
/*
@ -1034,7 +1034,7 @@ int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetri
return err;
}
#endif
static void anubis_crypt(const unsigned char *plaintext, unsigned char *ciphertext,
ulong32 roundKey[18 + 1][4], int R) {
@ -1048,10 +1048,10 @@ static void anubis_crypt(const unsigned char *plaintext, unsigned char *cipherte
*/
for (i = 0, pos = 0; i < 4; i++, pos += 4) {
state[i] =
(plaintext[pos ] << 24) ^
(plaintext[pos + 1] << 16) ^
(plaintext[pos + 2] << 8) ^
(plaintext[pos + 3] ) ^
(((ulong32)plaintext[pos ]) << 24) ^
(((ulong32)plaintext[pos + 1]) << 16) ^
(((ulong32)plaintext[pos + 2]) << 8) ^
(((ulong32)plaintext[pos + 3]) ) ^
roundKey[0][i];
}
@ -1149,7 +1149,7 @@ int anubis_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key
Decrypts a block of text with Anubis
@param ct The input ciphertext (16 bytes)
@param pt The output plaintext (16 bytes)
@param skey The key as scheduled
@param skey The key as scheduled
@return CRYPT_OK if successful
*/
int anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
@ -1181,7 +1181,7 @@ int anubis_test(void)
16,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0xF0, 0x68, 0x60, 0xFC, 0x67, 0x30, 0xE8, 0x18,
{ 0xF0, 0x68, 0x60, 0xFC, 0x67, 0x30, 0xE8, 0x18,
0xF1, 0x32, 0xC7, 0x8A, 0xF4, 0x13, 0x2A, 0xFE },
{ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
@ -1189,7 +1189,7 @@ int anubis_test(void)
16,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0xA8, 0x66, 0x84, 0x80, 0x07, 0x74, 0x5C, 0x89,
{ 0xA8, 0x66, 0x84, 0x80, 0x07, 0x74, 0x5C, 0x89,
0xFC, 0x5E, 0xB5, 0xBA, 0xD4, 0xFE, 0x32, 0x6D },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }
@ -1221,7 +1221,7 @@ int anubis_test(void)
24,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x17, 0xAC, 0x57, 0x44, 0x9D, 0x59, 0x61, 0x66,
{ 0x17, 0xAC, 0x57, 0x44, 0x9D, 0x59, 0x61, 0x66,
0xD0, 0xC7, 0x9E, 0x04, 0x7C, 0xC7, 0x58, 0xF0 },
{ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1230,7 +1230,7 @@ int anubis_test(void)
24,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x71, 0x52, 0xB4, 0xEB, 0x1D, 0xAA, 0x36, 0xFD,
{ 0x71, 0x52, 0xB4, 0xEB, 0x1D, 0xAA, 0x36, 0xFD,
0x57, 0x14, 0x5F, 0x57, 0x04, 0x9F, 0x70, 0x74 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1242,7 +1242,7 @@ int anubis_test(void)
28,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0xA2, 0xF0, 0xA6, 0xB9, 0x17, 0x93, 0x2A, 0x3B,
{ 0xA2, 0xF0, 0xA6, 0xB9, 0x17, 0x93, 0x2A, 0x3B,
0xEF, 0x08, 0xE8, 0x7A, 0x58, 0xD6, 0xF8, 0x53 },
{ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1252,7 +1252,7 @@ int anubis_test(void)
28,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0xF0, 0xCA, 0xFC, 0x78, 0x8B, 0x4B, 0x4E, 0x53,
{ 0xF0, 0xCA, 0xFC, 0x78, 0x8B, 0x4B, 0x4E, 0x53,
0x8B, 0xC4, 0x32, 0x6A, 0xF5, 0xB9, 0x1B, 0x5F },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1265,7 +1265,7 @@ int anubis_test(void)
32,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0xE0, 0x86, 0xAC, 0x45, 0x6B, 0x3C, 0xE5, 0x13,
{ 0xE0, 0x86, 0xAC, 0x45, 0x6B, 0x3C, 0xE5, 0x13,
0xED, 0xF5, 0xDF, 0xDD, 0xD6, 0x3B, 0x71, 0x93 },
{ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1275,7 +1275,7 @@ int anubis_test(void)
32,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x50, 0x01, 0xB9, 0xF5, 0x21, 0xC1, 0xC1, 0x29,
{ 0x50, 0x01, 0xB9, 0xF5, 0x21, 0xC1, 0xC1, 0x29,
0x00, 0xD5, 0xEC, 0x98, 0x2B, 0x9E, 0xE8, 0x21 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1288,7 +1288,7 @@ int anubis_test(void)
36,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0xE8, 0xF4, 0xAF, 0x2B, 0x21, 0xA0, 0x87, 0x9B,
{ 0xE8, 0xF4, 0xAF, 0x2B, 0x21, 0xA0, 0x87, 0x9B,
0x41, 0x95, 0xB9, 0x71, 0x75, 0x79, 0x04, 0x7C },
{ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1299,7 +1299,7 @@ int anubis_test(void)
36,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0xE6, 0xA6, 0xA5, 0xBC, 0x8B, 0x63, 0x6F, 0xE2,
{ 0xE6, 0xA6, 0xA5, 0xBC, 0x8B, 0x63, 0x6F, 0xE2,
0xBD, 0xA7, 0xA7, 0x53, 0xAB, 0x40, 0x22, 0xE0 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1313,7 +1313,7 @@ int anubis_test(void)
40,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x17, 0x04, 0xD7, 0x2C, 0xC6, 0x85, 0x76, 0x02,
{ 0x17, 0x04, 0xD7, 0x2C, 0xC6, 0x85, 0x76, 0x02,
0x4B, 0xCC, 0x39, 0x80, 0xD8, 0x22, 0xEA, 0xA4 },
{ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1324,7 +1324,7 @@ int anubis_test(void)
40,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x7A, 0x41, 0xE6, 0x7D, 0x4F, 0xD8, 0x64, 0xF0,
{ 0x7A, 0x41, 0xE6, 0x7D, 0x4F, 0xD8, 0x64, 0xF0,
0x44, 0xA8, 0x3C, 0x73, 0x81, 0x7E, 0x53, 0xD8 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1515,7 +1515,7 @@ int anubis_test(void)
#endif
}
/** Terminate the context
/** Terminate the context
@param skey The scheduled key
*/
void anubis_done(symmetric_key *skey)