Skip to content
Snippets Groups Projects
Commit a79b6151 authored by Matt Johnston's avatar Matt Johnston
Browse files

update to libtomcrypt 1.17 (with Dropbear changes)

parent 99361f54
No related branches found
No related tags found
No related merge requests found
Showing
with 487 additions and 184 deletions
Loading
Loading
@@ -12,7 +12,7 @@ You can disable whole classes of algorithms on the command line with the LTC_NO_
The following build with GCC 3.4.4 on an AMD64 box gets you AES, CTR mode, SHA-256, HMAC, Yarrow, full RSA PKCS #1, PKCS #5 and ASN.1 DER in
roughly 40KB of code (49KB on the ARMv4) (both excluding the math library).
 
CFLAGS="-DLTC_NO_CIPHERS -DLTC_NO_HASHES -DLTC_NO_PRNGS -DLTC_NO_MACS -DLTC_NO_MODES -DLTC_NO_PK -DRIJNDAEL -DLTC_CTR_MODE -DSHA256 \
CFLAGS="-DLTC_NO_CIPHERS -DLTC_NO_HASHES -DLTC_NO_PRNGS -DLTC_NO_MACS -DLTC_NO_MODES -DLTC_NO_PK -DLTC_RIJNDAEL -DLTC_CTR_MODE -DSHA256 \
-DLTC_HMAC -DYARROW -DMRSA -DMPI -DTFM_DESC -DARGTYPE=3 -Os -DLTC_SMALL_CODE -fomit-frame-pointer" make IGNORE_SPEED=1
 
Obviously this won't get you performance but if you need to pack a crypto lib in a device with limited means it's more than enough...
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -32,7 +32,7 @@
 
#include "tomcrypt.h"
 
#ifdef RIJNDAEL
#ifdef LTC_RIJNDAEL
 
#ifndef ENCRYPT_ONLY
 
Loading
Loading
@@ -765,6 +765,6 @@ int ECB_KS(int *keysize)
#endif
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/aes/aes.c,v $ */
/* $Revision: 1.14 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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 */
/*
Loading
Loading
@@ -1023,6 +1023,6 @@ static const ulong32 rcon[] = {
0x1B000000UL, 0x36000000UL, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
};
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/aes/aes_tab.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/04/02 13:19:09 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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
*/
 
/**
Loading
Loading
@@ -17,7 +17,7 @@
 
#include "tomcrypt.h"
 
#ifdef ANUBIS
#ifdef LTC_ANUBIS
 
const struct ltc_cipher_descriptor anubis_desc = {
"anubis",
Loading
Loading
@@ -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,
Loading
Loading
@@ -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,
Loading
Loading
@@ -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,
Loading
Loading
@@ -1553,6 +1553,6 @@ int anubis_keysize(int *keysize)
#endif
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/anubis.c,v $ */
/* $Revision: 1.15 $ */
/* $Date: 2006/11/15 12:41:28 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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
Loading
Loading
@@ -14,7 +14,7 @@
*/
#include "tomcrypt.h"
 
#ifdef BLOWFISH
#ifdef LTC_BLOWFISH
 
const struct ltc_cipher_descriptor blowfish_desc =
{
Loading
Loading
@@ -589,6 +589,6 @@ int blowfish_keysize(int *keysize)
#endif
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/blowfish.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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",
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
@@ -715,6 +715,6 @@ int cast5_keysize(int *keysize)
 
#endif
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/cast5.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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
Loading
Loading
@@ -1522,7 +1522,7 @@ static void desfunc(ulong32 *block, const ulong32 *keys)
 
#if 0
/**
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)
Loading
Loading
@@ -1550,7 +1550,7 @@ int des_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_ke
#endif
 
/**
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)
Loading
Loading
@@ -1583,7 +1583,7 @@ int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_k
 
#if 0
/**
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
Loading
Loading
@@ -1604,7 +1604,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
Loading
Loading
@@ -1626,7 +1626,7 @@ int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *s
#endif
 
/**
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
Loading
Loading
@@ -1650,7 +1650,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
Loading
Loading
@@ -1674,7 +1674,7 @@ int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *
 
#if 0
/**
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)
Loading
Loading
@@ -1910,6 +1910,6 @@ int des3_keysize(int *keysize)
#endif
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/des.c,v $ */
/* $Revision: 1.13 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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
*/
 
/**
Loading
Loading
@@ -313,6 +313,6 @@ int kasumi_test(void)
 
#endif
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/kasumi.c,v $ */
/* $Revision: 1.7 $ */
/* $Date: 2006/11/09 03:05:44 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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"
 
Loading
Loading
@@ -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",
Loading
Loading
@@ -850,6 +850,6 @@ int khazad_keysize(int *keysize)
 
#endif
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/khazad.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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
*/
 
/**
Loading
Loading
@@ -17,7 +17,7 @@
 
#include "tomcrypt.h"
 
#ifdef KSEED
#ifdef LTC_KSEED
 
const struct ltc_cipher_descriptor kseed_desc = {
"seed",
Loading
Loading
@@ -371,6 +371,6 @@ int kseed_keysize(int *keysize)
 
#endif
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/kseed.c,v $ */
/* $Revision: 1.8 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
/* 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$ */
Loading
Loading
@@ -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
Loading
Loading
@@ -14,7 +14,7 @@
*/
#include "tomcrypt.h"
 
#ifdef NOEKEON
#ifdef LTC_NOEKEON
 
const struct ltc_cipher_descriptor noekeon_desc =
{
Loading
Loading
@@ -298,6 +298,6 @@ int noekeon_keysize(int *keysize)
#endif
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/noekeon.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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 *
Loading
Loading
@@ -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",
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
@@ -357,6 +357,6 @@ int rc2_keysize(int *keysize)
 
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/rc2.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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 =
{
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
@@ -317,6 +317,6 @@ int rc5_keysize(int *keysize)
 
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/rc5.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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 =
{
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
@@ -339,10 +339,10 @@ int rc6_keysize(int *keysize)
return CRYPT_OK;
}
 
#endif /*RC6*/
#endif /*LTC_RC6*/
 
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/rc6.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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
Loading
Loading
@@ -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,
Loading
Loading
@@ -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,
Loading
Loading
@@ -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,
Loading
Loading
@@ -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,
Loading
Loading
@@ -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;
}
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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;
}
 
Loading
Loading
@@ -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;
}
Loading
Loading
@@ -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;
}
 
Loading
Loading
@@ -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;
}
 
Loading
Loading
@@ -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;
}
 
Loading
Loading
@@ -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;
}
 
Loading
Loading
@@ -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;
}
 
Loading
Loading
@@ -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;
}
 
Loading
Loading
@@ -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;
Loading
Loading
@@ -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--)
Loading
Loading
@@ -486,6 +486,6 @@ int safer_sk128_test(void)
 
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/safer/safer.c,v $ */
/* $Revision: 1.13 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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. */
Loading
Loading
@@ -63,6 +63,6 @@ const unsigned char safer_lbox[256] = {
 
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/safer/safer_tab.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/03/31 14:15:35 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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 =
{
Loading
Loading
@@ -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
*/
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
@@ -554,6 +554,6 @@ int saferp_keysize(int *keysize)
 
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/safer/saferp.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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
*/
 
/**
Loading
Loading
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
 
#ifdef SKIPJACK
#ifdef LTC_SKIPJACK
 
const struct ltc_cipher_descriptor skipjack_desc =
{
Loading
Loading
@@ -338,6 +338,6 @@ int skipjack_keysize(int *keysize)
 
#endif
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/skipjack.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Loading
Loading
@@ -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
*/
 
/**
Loading
Loading
@@ -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
 
Loading
Loading
@@ -68,7 +68,7 @@ static const unsigned char qord[4][5] = {
{ 1, 0, 1, 1, 0 }
};
 
#ifdef TWOFISH_TABLES
#ifdef LTC_TWOFISH_TABLES
 
#include "twofish_tab.c"
 
Loading
Loading
@@ -142,7 +142,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)
Loading
Loading
@@ -167,7 +167,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;
Loading
Loading
@@ -202,11 +202,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)
Loading
Loading
@@ -219,7 +219,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)
{
Loading
Loading
@@ -229,7 +229,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)
Loading
Loading
@@ -273,7 +273,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__)
Loading
Loading
@@ -332,7 +332,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
Loading
Loading
@@ -348,7 +348,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;
Loading
Loading
@@ -376,7 +376,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));
}
Loading
Loading
@@ -410,7 +410,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++) {
Loading
Loading
@@ -477,7 +477,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
 
Loading
Loading
@@ -485,7 +485,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];
Loading
Loading
@@ -550,7 +550,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
 
Loading
Loading
@@ -558,7 +558,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];
Loading
Loading
@@ -714,6 +714,6 @@ int twofish_keysize(int *keysize)
 
 
 
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/twofish/twofish.c,v $ */
/* $Revision: 1.14 $ */
/* $Date: 2006/12/04 21:34:03 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment