added libtomcrypt-1.17

This commit is contained in:
Tom St Denis
2007-07-20 17:48:02 +00:00
committed by Steffen Jaeckel
parent e24b01d392
commit bbc52b9e1b
341 changed files with 4806 additions and 1740 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/* AES implementation by Tom St Denis
@@ -32,7 +32,7 @@
#include "tomcrypt.h"
#ifdef RIJNDAEL
#ifdef LTC_RIJNDAEL
#ifndef ENCRYPT_ONLY
+1 -1
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/* The precomputed tables for AES */
/*
+6 -6
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@@ -17,7 +17,7 @@
#include "tomcrypt.h"
#ifdef ANUBIS
#ifdef LTC_ANUBIS
const struct ltc_cipher_descriptor anubis_desc = {
"anubis",
@@ -48,7 +48,7 @@ const struct ltc_cipher_descriptor anubis_desc = {
* (but little-endian notation would be equally suitable if consistently
* employed).
*/
#if defined(ANUBIS_TWEAK)
#if defined(LTC_ANUBIS_TWEAK)
static const ulong32 T0[256] = {
0xba69d2bbU, 0x54a84de5U, 0x2f5ebce2U, 0x74e8cd25U,
@@ -1174,8 +1174,8 @@ int anubis_test(void)
int keylen;
unsigned char pt[16], ct[16], key[40];
} tests[] = {
#ifndef ANUBIS_TWEAK
/**** ORIGINAL ANUBIS ****/
#ifndef LTC_ANUBIS_TWEAK
/**** ORIGINAL LTC_ANUBIS ****/
/* 128 bit keys */
{
16,
@@ -1333,7 +1333,7 @@ int anubis_test(void)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }
}
#else
/**** Tweaked ANUBIS ****/
/**** Tweaked LTC_ANUBIS ****/
/* 128 bit keys */
{
16,
+2 -2
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file blowfish.c
@@ -14,7 +14,7 @@
*/
#include "tomcrypt.h"
#ifdef BLOWFISH
#ifdef LTC_BLOWFISH
const struct ltc_cipher_descriptor blowfish_desc =
{
+7 -7
View File
@@ -6,16 +6,16 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file cast5.c
Implementation of CAST5 (RFC 2144) by Tom St Denis
Implementation of LTC_CAST5 (RFC 2144) by Tom St Denis
*/
#include "tomcrypt.h"
#ifdef CAST5
#ifdef LTC_CAST5
const struct ltc_cipher_descriptor cast5_desc = {
"cast5",
@@ -398,7 +398,7 @@ static const ulong32 S8[256] = {
#endif
/**
Initialize the CAST5 block cipher
Initialize the LTC_CAST5 block cipher
@param key The symmetric key you wish to pass
@param keylen The key length in bytes
@param num_rounds The number of rounds desired (0 for default)
@@ -530,7 +530,7 @@ INLINE static ulong32 FIII(ulong32 R, ulong32 Km, ulong32 Kr)
}
/**
Encrypts a block of text with CAST5
Encrypts a block of text with LTC_CAST5
@param pt The input plaintext (8 bytes)
@param ct The output ciphertext (8 bytes)
@param skey The key as scheduled
@@ -583,7 +583,7 @@ int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key
#endif
/**
Decrypts a block of text with CAST5
Decrypts a block of text with LTC_CAST5
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
@param skey The key as scheduled
@@ -636,7 +636,7 @@ int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key
#endif
/**
Performs a self-test of the CAST5 block cipher
Performs a self-test of the LTC_CAST5 block cipher
@return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
*/
int cast5_test(void)
+10 -10
View File
@@ -6,16 +6,16 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
/**
@file des.c
DES code submitted by Dobes Vandermeer
LTC_DES code submitted by Dobes Vandermeer
*/
#ifdef DES
#ifdef LTC_DES
#define EN0 0
#define DE1 1
@@ -1519,7 +1519,7 @@ static void desfunc(ulong32 *block, const ulong32 *keys)
#endif
/**
Initialize the DES block cipher
Initialize the LTC_DES block cipher
@param key The symmetric key you wish to pass
@param keylen The key length in bytes
@param num_rounds The number of rounds desired (0 for default)
@@ -1546,7 +1546,7 @@ int des_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_ke
}
/**
Initialize the 3DES-EDE block cipher
Initialize the 3LTC_DES-EDE block cipher
@param key The symmetric key you wish to pass
@param keylen The key length in bytes
@param num_rounds The number of rounds desired (0 for default)
@@ -1578,7 +1578,7 @@ int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_k
}
/**
Encrypts a block of text with DES
Encrypts a block of text with LTC_DES
@param pt The input plaintext (8 bytes)
@param ct The output ciphertext (8 bytes)
@param skey The key as scheduled
@@ -1599,7 +1599,7 @@ int des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *s
}
/**
Decrypts a block of text with DES
Decrypts a block of text with LTC_DES
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
@param skey The key as scheduled
@@ -1620,7 +1620,7 @@ int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *s
}
/**
Encrypts a block of text with 3DES-EDE
Encrypts a block of text with 3LTC_DES-EDE
@param pt The input plaintext (8 bytes)
@param ct The output ciphertext (8 bytes)
@param skey The key as scheduled
@@ -1644,7 +1644,7 @@ int des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *
}
/**
Decrypts a block of text with 3DES-EDE
Decrypts a block of text with 3LTC_DES-EDE
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
@param skey The key as scheduled
@@ -1667,7 +1667,7 @@ int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *
}
/**
Performs a self-test of the DES block cipher
Performs a self-test of the LTC_DES block cipher
@return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
*/
int des_test(void)
+1 -1
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
+2 -2
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
@@ -16,7 +16,7 @@
Authors: Paulo S.L.M. Barreto and Vincent Rijmen.
*/
#ifdef KHAZAD
#ifdef LTC_KHAZAD
const struct ltc_cipher_descriptor khazad_desc = {
"khazad",
+2 -2
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@@ -17,7 +17,7 @@
#include "tomcrypt.h"
#ifdef KSEED
#ifdef LTC_KSEED
const struct ltc_cipher_descriptor kseed_desc = {
"seed",
+303
View File
@@ -0,0 +1,303 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file multi2.c
Multi-2 implementation (not public domain, hence the default disable)
*/
#include "tomcrypt.h"
#ifdef LTC_MULTI2
static void pi1(ulong32 *p)
{
p[1] ^= p[0];
}
static void pi2(ulong32 *p, ulong32 *k)
{
ulong32 t;
t = (p[1] + k[0]) & 0xFFFFFFFFUL;
t = (ROL(t, 1) + t - 1) & 0xFFFFFFFFUL;
t = (ROL(t, 4) ^ t) & 0xFFFFFFFFUL;
p[0] ^= t;
}
static void pi3(ulong32 *p, ulong32 *k)
{
ulong32 t;
t = p[0] + k[1];
t = (ROL(t, 2) + t + 1) & 0xFFFFFFFFUL;
t = (ROL(t, 8) ^ t) & 0xFFFFFFFFUL;
t = (t + k[2]) & 0xFFFFFFFFUL;
t = (ROL(t, 1) - t) & 0xFFFFFFFFUL;
t = ROL(t, 16) ^ (p[0] | t);
p[1] ^= t;
}
static void pi4(ulong32 *p, ulong32 *k)
{
ulong32 t;
t = (p[1] + k[3]) & 0xFFFFFFFFUL;
t = (ROL(t, 2) + t + 1) & 0xFFFFFFFFUL;
p[0] ^= t;
}
static void setup(ulong32 *dk, ulong32 *k, ulong32 *uk)
{
int n, t;
ulong32 p[2];
p[0] = dk[0]; p[1] = dk[1];
t = 4;
n = 0;
pi1(p);
pi2(p, k);
uk[n++] = p[0];
pi3(p, k);
uk[n++] = p[1];
pi4(p, k);
uk[n++] = p[0];
pi1(p);
uk[n++] = p[1];
pi2(p, k+t);
uk[n++] = p[0];
pi3(p, k+t);
uk[n++] = p[1];
pi4(p, k+t);
uk[n++] = p[0];
pi1(p);
uk[n++] = p[1];
}
static void encrypt(ulong32 *p, int N, ulong32 *uk)
{
int n, t;
for (t = n = 0; ; ) {
pi1(p); if (++n == N) break;
pi2(p, uk+t); if (++n == N) break;
pi3(p, uk+t); if (++n == N) break;
pi4(p, uk+t); if (++n == N) break;
t ^= 4;
}
}
static void decrypt(ulong32 *p, int N, ulong32 *uk)
{
int n, t;
for (t = 4*((N&1)^1), n = N; ; ) {
switch (n >= 4 ? 4 : 0) {
case 4: pi4(p, uk+t); --n;
case 3: pi3(p, uk+t); --n;
case 2: pi2(p, uk+t); --n;
case 1: pi1(p); --n; break;
case 0: return;
}
t ^= 4;
}
}
const struct ltc_cipher_descriptor multi2_desc = {
"multi2",
22,
40, 40, 8, 128,
&multi2_setup,
&multi2_ecb_encrypt,
&multi2_ecb_decrypt,
&multi2_test,
&multi2_done,
&multi2_keysize,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
int multi2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
{
ulong32 sk[8], dk[2];
int x;
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(skey != NULL);
if (keylen != 40) return CRYPT_INVALID_KEYSIZE;
if (num_rounds == 0) num_rounds = 128;
skey->multi2.N = num_rounds;
for (x = 0; x < 8; x++) {
LOAD32H(sk[x], key + x*4);
}
LOAD32H(dk[0], key + 32);
LOAD32H(dk[1], key + 36);
setup(dk, sk, skey->multi2.uk);
zeromem(sk, sizeof(sk));
zeromem(dk, sizeof(dk));
return CRYPT_OK;
}
/**
Encrypts a block of text with multi2
@param pt The input plaintext (8 bytes)
@param ct The output ciphertext (8 bytes)
@param skey The key as scheduled
@return CRYPT_OK if successful
*/
int multi2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
{
ulong32 p[2];
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
LTC_ARGCHK(skey != NULL);
LOAD32H(p[0], pt);
LOAD32H(p[1], pt+4);
encrypt(p, skey->multi2.N, skey->multi2.uk);
STORE32H(p[0], ct);
STORE32H(p[1], ct+4);
return CRYPT_OK;
}
/**
Decrypts a block of text with multi2
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
@param skey The key as scheduled
@return CRYPT_OK if successful
*/
int multi2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
{
ulong32 p[2];
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
LTC_ARGCHK(skey != NULL);
LOAD32H(p[0], ct);
LOAD32H(p[1], ct+4);
decrypt(p, skey->multi2.N, skey->multi2.uk);
STORE32H(p[0], pt);
STORE32H(p[1], pt+4);
return CRYPT_OK;
}
/**
Performs a self-test of the multi2 block cipher
@return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
*/
int multi2_test(void)
{
static const struct {
unsigned char key[40];
unsigned char pt[8], ct[8];
int rounds;
} tests[] = {
{
{
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x01, 0x23, 0x45, 0x67,
0x89, 0xAB, 0xCD, 0xEF
},
{
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
},
{
0xf8, 0x94, 0x40, 0x84,
0x5e, 0x11, 0xcf, 0x89
},
128,
},
{
{
0x35, 0x91, 0x9d, 0x96,
0x07, 0x02, 0xe2, 0xce,
0x8d, 0x0b, 0x58, 0x3c,
0xc9, 0xc8, 0x9d, 0x59,
0xa2, 0xae, 0x96, 0x4e,
0x87, 0x82, 0x45, 0xed,
0x3f, 0x2e, 0x62, 0xd6,
0x36, 0x35, 0xd0, 0x67,
0xb1, 0x27, 0xb9, 0x06,
0xe7, 0x56, 0x22, 0x38,
},
{
0x1f, 0xb4, 0x60, 0x60,
0xd0, 0xb3, 0x4f, 0xa5
},
{
0xca, 0x84, 0xa9, 0x34,
0x75, 0xc8, 0x60, 0xe5
},
216,
}
};
unsigned char buf[8];
symmetric_key skey;
int err, x;
for (x = 1; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
if ((err = multi2_setup(tests[x].key, 40, tests[x].rounds, &skey)) != CRYPT_OK) {
return err;
}
if ((err = multi2_ecb_encrypt(tests[x].pt, buf, &skey)) != CRYPT_OK) {
return err;
}
if (XMEMCMP(buf, tests[x].ct, 8)) {
return CRYPT_FAIL_TESTVECTOR;
}
if ((err = multi2_ecb_decrypt(buf, buf, &skey)) != CRYPT_OK) {
return err;
}
if (XMEMCMP(buf, tests[x].pt, 8)) {
return CRYPT_FAIL_TESTVECTOR;
}
}
return CRYPT_OK;
}
/** Terminate the context
@param skey The scheduled key
*/
void multi2_done(symmetric_key *skey)
{
}
/**
Gets suitable key size
@param keysize [in/out] The length of the recommended key (in bytes). This function will store the suitable size back in this variable.
@return CRYPT_OK if the input key size is acceptable.
*/
int multi2_keysize(int *keysize)
{
LTC_ARGCHK(keysize != NULL);
if (*keysize >= 40) {
*keysize = 40;
} else {
return CRYPT_INVALID_KEYSIZE;
}
return CRYPT_OK;
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+2 -2
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file noekeon.c
@@ -14,7 +14,7 @@
*/
#include "tomcrypt.h"
#ifdef NOEKEON
#ifdef LTC_NOEKEON
const struct ltc_cipher_descriptor noekeon_desc =
{
+7 -7
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**********************************************************************\
* To commemorate the 1996 RSA Data Security Conference, the following *
@@ -22,10 +22,10 @@
/**
@file rc2.c
Implementation of RC2
Implementation of LTC_RC2
*/
#ifdef RC2
#ifdef LTC_RC2
const struct ltc_cipher_descriptor rc2_desc = {
"rc2",
@@ -60,7 +60,7 @@ static const unsigned char permute[256] = {
};
/**
Initialize the RC2 block cipher
Initialize the LTC_RC2 block cipher
@param key The symmetric key you wish to pass
@param keylen The key length in bytes
@param num_rounds The number of rounds desired (0 for default)
@@ -121,7 +121,7 @@ int rc2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_ke
* Encrypt an 8-byte block of plaintext using the given key. *
\**********************************************************************/
/**
Encrypts a block of text with RC2
Encrypts a block of text with LTC_RC2
@param pt The input plaintext (8 bytes)
@param ct The output ciphertext (8 bytes)
@param skey The key as scheduled
@@ -199,7 +199,7 @@ int rc2_ecb_encrypt( const unsigned char *pt,
* Decrypt an 8-byte block of ciphertext using the given key. *
\**********************************************************************/
/**
Decrypts a block of text with RC2
Decrypts a block of text with LTC_RC2
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
@param skey The key as scheduled
@@ -275,7 +275,7 @@ int rc2_ecb_decrypt( const unsigned char *ct,
#endif
/**
Performs a self-test of the RC2 block cipher
Performs a self-test of the LTC_RC2 block cipher
@return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
*/
int rc2_test(void)
+7 -7
View File
@@ -6,17 +6,17 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file rc5.c
RC5 code by Tom St Denis
LTC_RC5 code by Tom St Denis
*/
#include "tomcrypt.h"
#ifdef RC5
#ifdef LTC_RC5
const struct ltc_cipher_descriptor rc5_desc =
{
@@ -43,7 +43,7 @@ static const ulong32 stab[50] = {
};
/**
Initialize the RC5 block cipher
Initialize the LTC_RC5 block cipher
@param key The symmetric key you wish to pass
@param keylen The key length in bytes
@param num_rounds The number of rounds desired (0 for default)
@@ -119,7 +119,7 @@ int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_ke
#endif
/**
Encrypts a block of text with RC5
Encrypts a block of text with LTC_RC5
@param pt The input plaintext (8 bytes)
@param ct The output ciphertext (8 bytes)
@param skey The key as scheduled
@@ -174,7 +174,7 @@ int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *s
#endif
/**
Decrypts a block of text with RC5
Decrypts a block of text with LTC_RC5
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
@param skey The key as scheduled
@@ -230,7 +230,7 @@ int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *s
#endif
/**
Performs a self-test of the RC5 block cipher
Performs a self-test of the LTC_RC5 block cipher
@return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
*/
int rc5_test(void)
+8 -8
View File
@@ -6,16 +6,16 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file rc6.c
RC6 code by Tom St Denis
LTC_RC6 code by Tom St Denis
*/
#include "tomcrypt.h"
#ifdef RC6
#ifdef LTC_RC6
const struct ltc_cipher_descriptor rc6_desc =
{
@@ -40,7 +40,7 @@ static const ulong32 stab[44] = {
0x708c564bUL, 0x0ec3d004UL, 0xacfb49bdUL, 0x4b32c376UL };
/**
Initialize the RC6 block cipher
Initialize the LTC_RC6 block cipher
@param key The symmetric key you wish to pass
@param keylen The key length in bytes
@param num_rounds The number of rounds desired (0 for default)
@@ -114,7 +114,7 @@ int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_ke
#endif
/**
Encrypts a block of text with RC6
Encrypts a block of text with LTC_RC6
@param pt The input plaintext (16 bytes)
@param ct The output ciphertext (16 bytes)
@param skey The key as scheduled
@@ -168,7 +168,7 @@ int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *s
#endif
/**
Decrypts a block of text with RC6
Decrypts a block of text with LTC_RC6
@param ct The input ciphertext (16 bytes)
@param pt The output plaintext (16 bytes)
@param skey The key as scheduled
@@ -224,7 +224,7 @@ int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *s
#endif
/**
Performs a self-test of the RC6 block cipher
Performs a self-test of the LTC_RC6 block cipher
@return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
*/
int rc6_test(void)
@@ -339,7 +339,7 @@ int rc6_keysize(int *keysize)
return CRYPT_OK;
}
#endif /*RC6*/
#endif /*LTC_RC6*/
+37 -37
View File
@@ -6,16 +6,16 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/*******************************************************************************
*
* FILE: safer.c
*
* DESCRIPTION: block-cipher algorithm SAFER (Secure And Fast Encryption
* Routine) in its four versions: SAFER K-64, SAFER K-128,
* SAFER SK-64 and SAFER SK-128.
* LTC_DESCRIPTION: block-cipher algorithm LTC_SAFER (Secure And Fast Encryption
* Routine) in its four versions: LTC_SAFER K-64, LTC_SAFER K-128,
* LTC_SAFER SK-64 and LTC_SAFER SK-128.
*
* AUTHOR: Richard De Moliner (demoliner@isi.ee.ethz.ch)
* Signal and Information Processing Laboratory
@@ -30,12 +30,12 @@
#include <tomcrypt.h>
#ifdef SAFER
#ifdef LTC_SAFER
const struct ltc_cipher_descriptor
safer_k64_desc = {
"safer-k64",
8, 8, 8, 8, SAFER_K64_DEFAULT_NOF_ROUNDS,
8, 8, 8, 8, LTC_SAFER_K64_DEFAULT_NOF_ROUNDS,
&safer_k64_setup,
&safer_ecb_encrypt,
&safer_ecb_decrypt,
@@ -47,7 +47,7 @@ const struct ltc_cipher_descriptor
safer_sk64_desc = {
"safer-sk64",
9, 8, 8, 8, SAFER_SK64_DEFAULT_NOF_ROUNDS,
9, 8, 8, 8, LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS,
&safer_sk64_setup,
&safer_ecb_encrypt,
&safer_ecb_decrypt,
@@ -59,7 +59,7 @@ const struct ltc_cipher_descriptor
safer_k128_desc = {
"safer-k128",
10, 16, 16, 8, SAFER_K128_DEFAULT_NOF_ROUNDS,
10, 16, 16, 8, LTC_SAFER_K128_DEFAULT_NOF_ROUNDS,
&safer_k128_setup,
&safer_ecb_encrypt,
&safer_ecb_decrypt,
@@ -71,7 +71,7 @@ const struct ltc_cipher_descriptor
safer_sk128_desc = {
"safer-sk128",
11, 16, 16, 8, SAFER_SK128_DEFAULT_NOF_ROUNDS,
11, 16, 16, 8, LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS,
&safer_sk128_setup,
&safer_ecb_encrypt,
&safer_ecb_decrypt,
@@ -111,48 +111,48 @@ static void Safer_Expand_Userkey(const unsigned char *userkey_1,
safer_key_t key)
#endif
{ unsigned int i, j, k;
unsigned char ka[SAFER_BLOCK_LEN + 1];
unsigned char kb[SAFER_BLOCK_LEN + 1];
unsigned char ka[LTC_SAFER_BLOCK_LEN + 1];
unsigned char kb[LTC_SAFER_BLOCK_LEN + 1];
if (SAFER_MAX_NOF_ROUNDS < nof_rounds)
nof_rounds = SAFER_MAX_NOF_ROUNDS;
if (LTC_SAFER_MAX_NOF_ROUNDS < nof_rounds)
nof_rounds = LTC_SAFER_MAX_NOF_ROUNDS;
*key++ = (unsigned char)nof_rounds;
ka[SAFER_BLOCK_LEN] = (unsigned char)0;
kb[SAFER_BLOCK_LEN] = (unsigned char)0;
ka[LTC_SAFER_BLOCK_LEN] = (unsigned char)0;
kb[LTC_SAFER_BLOCK_LEN] = (unsigned char)0;
k = 0;
for (j = 0; j < SAFER_BLOCK_LEN; j++) {
for (j = 0; j < LTC_SAFER_BLOCK_LEN; j++) {
ka[j] = ROL8(userkey_1[j], 5);
ka[SAFER_BLOCK_LEN] ^= ka[j];
ka[LTC_SAFER_BLOCK_LEN] ^= ka[j];
kb[j] = *key++ = userkey_2[j];
kb[SAFER_BLOCK_LEN] ^= kb[j];
kb[LTC_SAFER_BLOCK_LEN] ^= kb[j];
}
for (i = 1; i <= nof_rounds; i++) {
for (j = 0; j < SAFER_BLOCK_LEN + 1; j++) {
for (j = 0; j < LTC_SAFER_BLOCK_LEN + 1; j++) {
ka[j] = ROL8(ka[j], 6);
kb[j] = ROL8(kb[j], 6);
}
if (strengthened) {
k = 2 * i - 1;
while (k >= (SAFER_BLOCK_LEN + 1)) { k -= SAFER_BLOCK_LEN + 1; }
while (k >= (LTC_SAFER_BLOCK_LEN + 1)) { k -= LTC_SAFER_BLOCK_LEN + 1; }
}
for (j = 0; j < SAFER_BLOCK_LEN; j++) {
for (j = 0; j < LTC_SAFER_BLOCK_LEN; j++) {
if (strengthened) {
*key++ = (ka[k]
+ safer_ebox[(int)safer_ebox[(int)((18 * i + j + 1)&0xFF)]]) & 0xFF;
if (++k == (SAFER_BLOCK_LEN + 1)) { k = 0; }
if (++k == (LTC_SAFER_BLOCK_LEN + 1)) { k = 0; }
} else {
*key++ = (ka[j] + safer_ebox[(int)safer_ebox[(int)((18 * i + j + 1)&0xFF)]]) & 0xFF;
}
}
if (strengthened) {
k = 2 * i;
while (k >= (SAFER_BLOCK_LEN + 1)) { k -= SAFER_BLOCK_LEN + 1; }
while (k >= (LTC_SAFER_BLOCK_LEN + 1)) { k -= LTC_SAFER_BLOCK_LEN + 1; }
}
for (j = 0; j < SAFER_BLOCK_LEN; j++) {
for (j = 0; j < LTC_SAFER_BLOCK_LEN; j++) {
if (strengthened) {
*key++ = (kb[k]
+ safer_ebox[(int)safer_ebox[(int)((18 * i + j + 10)&0xFF)]]) & 0xFF;
if (++k == (SAFER_BLOCK_LEN + 1)) { k = 0; }
if (++k == (LTC_SAFER_BLOCK_LEN + 1)) { k = 0; }
} else {
*key++ = (kb[j] + safer_ebox[(int)safer_ebox[(int)((18 * i + j + 10)&0xFF)]]) & 0xFF;
}
@@ -173,7 +173,7 @@ static void Safer_Expand_Userkey(const unsigned char *userkey_1,
safer_key_t key)
{
_Safer_Expand_Userkey(userkey_1, userkey_2, nof_rounds, strengthened, key);
burn_stack(sizeof(unsigned char) * (2 * (SAFER_BLOCK_LEN + 1)) + sizeof(unsigned int)*2);
burn_stack(sizeof(unsigned char) * (2 * (LTC_SAFER_BLOCK_LEN + 1)) + sizeof(unsigned int)*2);
}
#endif
@@ -182,7 +182,7 @@ int safer_k64_setup(const unsigned char *key, int keylen, int numrounds, symmetr
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(skey != NULL);
if (numrounds != 0 && (numrounds < 6 || numrounds > SAFER_MAX_NOF_ROUNDS)) {
if (numrounds != 0 && (numrounds < 6 || numrounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
return CRYPT_INVALID_ROUNDS;
}
@@ -190,7 +190,7 @@ int safer_k64_setup(const unsigned char *key, int keylen, int numrounds, symmetr
return CRYPT_INVALID_KEYSIZE;
}
Safer_Expand_Userkey(key, key, (unsigned int)(numrounds != 0 ?numrounds:SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
Safer_Expand_Userkey(key, key, (unsigned int)(numrounds != 0 ?numrounds:LTC_SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
return CRYPT_OK;
}
@@ -199,7 +199,7 @@ int safer_sk64_setup(const unsigned char *key, int keylen, int numrounds, symmet
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(skey != NULL);
if (numrounds != 0 && (numrounds < 6 || numrounds > SAFER_MAX_NOF_ROUNDS)) {
if (numrounds != 0 && (numrounds < 6 || numrounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
return CRYPT_INVALID_ROUNDS;
}
@@ -207,7 +207,7 @@ int safer_sk64_setup(const unsigned char *key, int keylen, int numrounds, symmet
return CRYPT_INVALID_KEYSIZE;
}
Safer_Expand_Userkey(key, key, (unsigned int)(numrounds != 0 ?numrounds:SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
Safer_Expand_Userkey(key, key, (unsigned int)(numrounds != 0 ?numrounds:LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
return CRYPT_OK;
}
@@ -216,7 +216,7 @@ int safer_k128_setup(const unsigned char *key, int keylen, int numrounds, symmet
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(skey != NULL);
if (numrounds != 0 && (numrounds < 6 || numrounds > SAFER_MAX_NOF_ROUNDS)) {
if (numrounds != 0 && (numrounds < 6 || numrounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
return CRYPT_INVALID_ROUNDS;
}
@@ -224,7 +224,7 @@ int safer_k128_setup(const unsigned char *key, int keylen, int numrounds, symmet
return CRYPT_INVALID_KEYSIZE;
}
Safer_Expand_Userkey(key, key+8, (unsigned int)(numrounds != 0 ?numrounds:SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
Safer_Expand_Userkey(key, key+8, (unsigned int)(numrounds != 0 ?numrounds:LTC_SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
return CRYPT_OK;
}
@@ -233,7 +233,7 @@ int safer_sk128_setup(const unsigned char *key, int keylen, int numrounds, symme
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(skey != NULL);
if (numrounds != 0 && (numrounds < 6 || numrounds > SAFER_MAX_NOF_ROUNDS)) {
if (numrounds != 0 && (numrounds < 6 || numrounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
return CRYPT_INVALID_ROUNDS;
}
@@ -241,7 +241,7 @@ int safer_sk128_setup(const unsigned char *key, int keylen, int numrounds, symme
return CRYPT_INVALID_KEYSIZE;
}
Safer_Expand_Userkey(key, key+8, (unsigned int)(numrounds != 0?numrounds:SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
Safer_Expand_Userkey(key, key+8, (unsigned int)(numrounds != 0?numrounds:LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
return CRYPT_OK;
}
@@ -265,7 +265,7 @@ int safer_ecb_encrypt(const unsigned char *block_in,
key = skey->safer.key;
a = block_in[0]; b = block_in[1]; c = block_in[2]; d = block_in[3];
e = block_in[4]; f = block_in[5]; g = block_in[6]; h = block_in[7];
if (SAFER_MAX_NOF_ROUNDS < (round = *key)) round = SAFER_MAX_NOF_ROUNDS;
if (LTC_SAFER_MAX_NOF_ROUNDS < (round = *key)) round = LTC_SAFER_MAX_NOF_ROUNDS;
while(round-- > 0)
{
a ^= *++key; b += *++key; c += *++key; d ^= *++key;
@@ -319,8 +319,8 @@ int safer_ecb_decrypt(const unsigned char *block_in,
key = skey->safer.key;
a = block_in[0]; b = block_in[1]; c = block_in[2]; d = block_in[3];
e = block_in[4]; f = block_in[5]; g = block_in[6]; h = block_in[7];
if (SAFER_MAX_NOF_ROUNDS < (round = *key)) round = SAFER_MAX_NOF_ROUNDS;
key += SAFER_BLOCK_LEN * (1 + 2 * round);
if (LTC_SAFER_MAX_NOF_ROUNDS < (round = *key)) round = LTC_SAFER_MAX_NOF_ROUNDS;
key += LTC_SAFER_BLOCK_LEN * (1 + 2 * round);
h ^= *key; g -= *--key; f -= *--key; e ^= *--key;
d ^= *--key; c -= *--key; b -= *--key; a ^= *--key;
while (round--)
+3 -3
View File
@@ -6,17 +6,17 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file safer_tab.c
Tables for SAFER block ciphers
Tables for LTC_SAFER block ciphers
*/
#include "tomcrypt.h"
#if defined(SAFERP) || defined(SAFER)
#if defined(LTC_SAFERP) || defined(LTC_SAFER)
/* This is the box defined by ebox[x] = 45^x mod 257.
* Its assumed that the value "256" corresponds to zero. */
+8 -8
View File
@@ -6,16 +6,16 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file saferp.c
SAFER+ Implementation by Tom St Denis
LTC_SAFER+ Implementation by Tom St Denis
*/
#include "tomcrypt.h"
#ifdef SAFERP
#ifdef LTC_SAFERP
const struct ltc_cipher_descriptor saferp_desc =
{
@@ -37,7 +37,7 @@ const struct ltc_cipher_descriptor saferp_desc =
* key addition, substitution, key addition. The safer_ebox and safer_lbox
* are the exponentiation box and logarithm boxes respectively.
* The value of 'i' is the current round number which allows this
* function to be unrolled massively. Most of SAFER+'s speed
* function to be unrolled massively. Most of LTC_SAFER+'s speed
* comes from not having to compute indirect accesses into the
* array of 16 bytes b[0..15] which is the block of data
*/
@@ -206,7 +206,7 @@ static const unsigned char safer_bias[33][16] = {
{ 62, 220, 134, 119, 215, 166, 17, 251, 244, 186, 146, 145, 100, 131, 241, 51}};
/**
Initialize the SAFER+ block cipher
Initialize the LTC_SAFER+ block cipher
@param key The symmetric key you wish to pass
@param keylen The key length in bytes
@param num_rounds The number of rounds desired (0 for default)
@@ -325,7 +325,7 @@ int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric
}
/**
Encrypts a block of text with SAFER+
Encrypts a block of text with LTC_SAFER+
@param pt The input plaintext (16 bytes)
@param ct The output ciphertext (16 bytes)
@param skey The key as scheduled
@@ -389,7 +389,7 @@ int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key
}
/**
Decrypts a block of text with SAFER+
Decrypts a block of text with LTC_SAFER+
@param ct The input ciphertext (16 bytes)
@param pt The output plaintext (16 bytes)
@param skey The key as scheduled
@@ -453,7 +453,7 @@ int saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key
}
/**
Performs a self-test of the SAFER+ block cipher
Performs a self-test of the LTC_SAFER+ block cipher
@return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
*/
int saferp_test(void)
+2 -2
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef SKIPJACK
#ifdef LTC_SKIPJACK
const struct ltc_cipher_descriptor skipjack_desc =
{
+22 -22
View File
@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@@ -15,12 +15,12 @@
*/
#include "tomcrypt.h"
#ifdef TWOFISH
#ifdef LTC_TWOFISH
/* first TWOFISH_ALL_TABLES must ensure TWOFISH_TABLES is defined */
#ifdef TWOFISH_ALL_TABLES
#ifndef TWOFISH_TABLES
#define TWOFISH_TABLES
/* first LTC_TWOFISH_ALL_TABLES must ensure LTC_TWOFISH_TABLES is defined */
#ifdef LTC_TWOFISH_ALL_TABLES
#ifndef LTC_TWOFISH_TABLES
#define LTC_TWOFISH_TABLES
#endif
#endif
@@ -66,7 +66,7 @@ static const unsigned char qord[4][5] = {
{ 1, 0, 1, 1, 0 }
};
#ifdef TWOFISH_TABLES
#ifdef LTC_TWOFISH_TABLES
#include "twofish_tab.c"
@@ -140,7 +140,7 @@ static ulong32 sbox(int i, ulong32 x)
}
#endif /* LTC_CLEAN_STACK */
#endif /* TWOFISH_TABLES */
#endif /* LTC_TWOFISH_TABLES */
/* computes ab mod p */
static ulong32 gf_mult(ulong32 a, ulong32 b, ulong32 p)
@@ -165,7 +165,7 @@ static ulong32 gf_mult(ulong32 a, ulong32 b, ulong32 p)
}
/* computes [y0 y1 y2 y3] = MDS . [x0] */
#ifndef TWOFISH_TABLES
#ifndef LTC_TWOFISH_TABLES
static ulong32 mds_column_mult(unsigned char in, int col)
{
ulong32 x01, x5B, xEF;
@@ -200,11 +200,11 @@ static ulong32 mds_column_mult(unsigned char in, int col)
return 0;
}
#else /* !TWOFISH_TABLES */
#else /* !LTC_TWOFISH_TABLES */
#define mds_column_mult(x, i) mds_tab[i][x]
#endif /* TWOFISH_TABLES */
#endif /* LTC_TWOFISH_TABLES */
/* Computes [y0 y1 y2 y3] = MDS . [x0 x1 x2 x3] */
static void mds_mult(const unsigned char *in, unsigned char *out)
@@ -217,7 +217,7 @@ static void mds_mult(const unsigned char *in, unsigned char *out)
STORE32L(tmp, out);
}
#ifdef TWOFISH_ALL_TABLES
#ifdef LTC_TWOFISH_ALL_TABLES
/* computes [y0 y1 y2 y3] = RS . [x0 x1 x2 x3 x4 x5 x6 x7] */
static void rs_mult(const unsigned char *in, unsigned char *out)
{
@@ -227,7 +227,7 @@ static void rs_mult(const unsigned char *in, unsigned char *out)
STORE32L(tmp, out);
}
#else /* !TWOFISH_ALL_TABLES */
#else /* !LTC_TWOFISH_ALL_TABLES */
/* computes [y0 y1 y2 y3] = RS . [x0 x1 x2 x3 x4 x5 x6 x7] */
static void rs_mult(const unsigned char *in, unsigned char *out)
@@ -271,7 +271,7 @@ static void h_func(const unsigned char *in, unsigned char *out, unsigned char *M
mds_mult(y, out);
}
#ifndef TWOFISH_SMALL
#ifndef LTC_TWOFISH_SMALL
/* for GCC we don't use pointer aliases */
#if defined(__GNUC__)
@@ -330,7 +330,7 @@ static ulong32 g_func(ulong32 x, symmetric_key *key)
}
#endif /* LTC_CLEAN_STACK */
#endif /* TWOFISH_SMALL */
#endif /* LTC_TWOFISH_SMALL */
/**
Initialize the Twofish block cipher
@@ -346,7 +346,7 @@ static int _twofish_setup(const unsigned char *key, int keylen, int num_rounds,
int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
#endif
{
#ifndef TWOFISH_SMALL
#ifndef LTC_TWOFISH_SMALL
unsigned char S[4*4], tmpx0, tmpx1;
#endif
int k, x, y;
@@ -374,7 +374,7 @@ int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetri
}
/* create the S[..] words */
#ifndef TWOFISH_SMALL
#ifndef LTC_TWOFISH_SMALL
for (x = 0; x < k; x++) {
rs_mult(M+(x*8), S+(x*4));
}
@@ -408,7 +408,7 @@ int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetri
skey->twofish.K[x+x+1] = ROLc(B + B + A, 9);
}
#ifndef TWOFISH_SMALL
#ifndef LTC_TWOFISH_SMALL
/* make the sboxes (large ram variant) */
if (k == 2) {
for (x = 0; x < 256; x++) {
@@ -475,7 +475,7 @@ int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_ke
{
ulong32 a,b,c,d,ta,tb,tc,td,t1,t2, *k;
int r;
#if !defined(TWOFISH_SMALL) && !defined(__GNUC__)
#if !defined(LTC_TWOFISH_SMALL) && !defined(__GNUC__)
ulong32 *S1, *S2, *S3, *S4;
#endif
@@ -483,7 +483,7 @@ int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_ke
LTC_ARGCHK(ct != NULL);
LTC_ARGCHK(skey != NULL);
#if !defined(TWOFISH_SMALL) && !defined(__GNUC__)
#if !defined(LTC_TWOFISH_SMALL) && !defined(__GNUC__)
S1 = skey->twofish.S[0];
S2 = skey->twofish.S[1];
S3 = skey->twofish.S[2];
@@ -548,7 +548,7 @@ int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_ke
{
ulong32 a,b,c,d,ta,tb,tc,td,t1,t2, *k;
int r;
#if !defined(TWOFISH_SMALL) && !defined(__GNUC__)
#if !defined(LTC_TWOFISH_SMALL) && !defined(__GNUC__)
ulong32 *S1, *S2, *S3, *S4;
#endif
@@ -556,7 +556,7 @@ int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_ke
LTC_ARGCHK(ct != NULL);
LTC_ARGCHK(skey != NULL);
#if !defined(TWOFISH_SMALL) && !defined(__GNUC__)
#if !defined(LTC_TWOFISH_SMALL) && !defined(__GNUC__)
S1 = skey->twofish.S[0];
S2 = skey->twofish.S[1];
S3 = skey->twofish.S[2];
+4 -4
View File
@@ -6,14 +6,14 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file twofish_tab.c
Twofish tables, Tom St Denis
*/
#ifdef TWOFISH_TABLES
#ifdef LTC_TWOFISH_TABLES
/* pre generated 8x8 tables from the four 4x4s */
static const unsigned char SBOX[2][256] = {
@@ -212,7 +212,7 @@ static const ulong32 mds_tab[4][256] = {
0xc6baf8c6UL, 0x9d55f99dUL, 0x700dfa70UL, 0x2be2fb2bUL, 0xc3bdfcc3UL, 0x9852fd98UL, 0x750afe75UL, 0x2ee5ff2eUL
}};
#ifdef TWOFISH_ALL_TABLES
#ifdef LTC_TWOFISH_ALL_TABLES
/* the 4x8 RS transform */
static const ulong32 rs_tab0[256] = {
@@ -487,7 +487,7 @@ static const ulong32 rs_tab7[256] = {
0x5d8218b2LU, 0x5e9bfd2cLU, 0x5bb09fc3LU, 0x58a97a5dLU, 0x51e65b50LU, 0x52ffbeceLU, 0x57d4dc21LU, 0x54cd39bfLU,
0x454a9e3bLU, 0x46537ba5LU, 0x4378194aLU, 0x4061fcd4LU, 0x492eddd9LU, 0x4a373847LU, 0x4f1c5aa8LU, 0x4c05bf36LU };
#endif /* TWOFISH_ALL_TABLES */
#endif /* LTC_TWOFISH_ALL_TABLES */
#endif
+6 -6
View File
@@ -6,16 +6,16 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@file xtea.c
Implementation of XTEA, Tom St Denis
Implementation of LTC_XTEA, Tom St Denis
*/
#include "tomcrypt.h"
#ifdef XTEA
#ifdef LTC_XTEA
const struct ltc_cipher_descriptor xtea_desc =
{
@@ -67,7 +67,7 @@ int xtea_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_k
}
/**
Encrypts a block of text with XTEA
Encrypts a block of text with LTC_XTEA
@param pt The input plaintext (8 bytes)
@param ct The output ciphertext (8 bytes)
@param skey The key as scheduled
@@ -103,7 +103,7 @@ int xtea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *
}
/**
Decrypts a block of text with XTEA
Decrypts a block of text with LTC_XTEA
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
@param skey The key as scheduled
@@ -139,7 +139,7 @@ int xtea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *
}
/**
Performs a self-test of the XTEA block cipher
Performs a self-test of the LTC_XTEA block cipher
@return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
*/
int xtea_test(void)