summaryrefslogtreecommitdiffhomepage
path: root/libtomcrypt/src/modes/f8
diff options
context:
space:
mode:
Diffstat (limited to 'libtomcrypt/src/modes/f8')
-rw-r--r--libtomcrypt/src/modes/f8/f8_decrypt.c10
-rw-r--r--libtomcrypt/src/modes/f8/f8_done.c10
-rw-r--r--libtomcrypt/src/modes/f8/f8_encrypt.c18
-rw-r--r--libtomcrypt/src/modes/f8/f8_getiv.c14
-rw-r--r--libtomcrypt/src/modes/f8/f8_setiv.c14
-rw-r--r--libtomcrypt/src/modes/f8/f8_start.c28
-rw-r--r--libtomcrypt/src/modes/f8/f8_test_mode.c38
7 files changed, 59 insertions, 73 deletions
diff --git a/libtomcrypt/src/modes/f8/f8_decrypt.c b/libtomcrypt/src/modes/f8/f8_decrypt.c
index 9c4525d..9c92952 100644
--- a/libtomcrypt/src/modes/f8/f8_decrypt.c
+++ b/libtomcrypt/src/modes/f8/f8_decrypt.c
@@ -5,8 +5,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
@@ -36,8 +34,8 @@ int f8_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, sy
#endif
-
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtomcrypt/src/modes/f8/f8_done.c b/libtomcrypt/src/modes/f8/f8_done.c
index 867d603..3f0af66 100644
--- a/libtomcrypt/src/modes/f8/f8_done.c
+++ b/libtomcrypt/src/modes/f8/f8_done.c
@@ -5,8 +5,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
@@ -33,10 +31,10 @@ int f8_done(symmetric_F8 *f8)
return CRYPT_OK;
}
-
+
#endif
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtomcrypt/src/modes/f8/f8_encrypt.c b/libtomcrypt/src/modes/f8/f8_encrypt.c
index d1a96df..058f25a 100644
--- a/libtomcrypt/src/modes/f8/f8_encrypt.c
+++ b/libtomcrypt/src/modes/f8/f8_encrypt.c
@@ -5,8 +5,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
@@ -35,13 +33,13 @@ int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, sy
if ((err = cipher_is_valid(f8->cipher)) != CRYPT_OK) {
return err;
}
-
+
/* is blocklen/padlen valid? */
if (f8->blocklen < 0 || f8->blocklen > (int)sizeof(f8->IV) ||
f8->padlen < 0 || f8->padlen > (int)sizeof(f8->IV)) {
return CRYPT_INVALID_ARG;
}
-
+
zeromem(buf, sizeof(buf));
/* make sure the pad is empty */
@@ -64,8 +62,8 @@ int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, sy
STORE32H(f8->blockcnt, (buf+(f8->blocklen-4)));
++(f8->blockcnt);
for (x = 0; x < f8->blocklen; x += sizeof(LTC_FAST_TYPE)) {
- *((LTC_FAST_TYPE*)(&ct[x])) = *((LTC_FAST_TYPE*)(&pt[x])) ^ *((LTC_FAST_TYPE*)(&f8->IV[x]));
- *((LTC_FAST_TYPE*)(&f8->IV[x])) ^= *((LTC_FAST_TYPE*)(&f8->MIV[x])) ^ *((LTC_FAST_TYPE*)(&buf[x]));
+ *(LTC_FAST_TYPE_PTR_CAST(&ct[x])) = *(LTC_FAST_TYPE_PTR_CAST(&pt[x])) ^ *(LTC_FAST_TYPE_PTR_CAST(&f8->IV[x]));
+ *(LTC_FAST_TYPE_PTR_CAST(&f8->IV[x])) ^= *(LTC_FAST_TYPE_PTR_CAST(&f8->MIV[x])) ^ *(LTC_FAST_TYPE_PTR_CAST(&buf[x]));
}
if ((err = cipher_descriptor[f8->cipher].ecb_encrypt(f8->IV, f8->IV, &f8->key)) != CRYPT_OK) {
return err;
@@ -75,7 +73,7 @@ int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, sy
ct += x;
}
}
-#endif
+#endif
while (len > 0) {
if (f8->padlen == f8->blocklen) {
@@ -98,6 +96,6 @@ int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, sy
#endif
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtomcrypt/src/modes/f8/f8_getiv.c b/libtomcrypt/src/modes/f8/f8_getiv.c
index ff7cb91..a5885c9 100644
--- a/libtomcrypt/src/modes/f8/f8_getiv.c
+++ b/libtomcrypt/src/modes/f8/f8_getiv.c
@@ -5,8 +5,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
@@ -18,9 +16,9 @@
#ifdef LTC_F8_MODE
/**
- Get the current initial vector
- @param IV [out] The destination of the initial vector
- @param len [in/out] The max size and resulting size of the initial vector
+ Get the current initialization vector
+ @param IV [out] The destination of the initialization vector
+ @param len [in/out] The max size and resulting size of the initialization vector
@param f8 The F8 state
@return CRYPT_OK if successful
*/
@@ -41,6 +39,6 @@ int f8_getiv(unsigned char *IV, unsigned long *len, symmetric_F8 *f8)
#endif
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtomcrypt/src/modes/f8/f8_setiv.c b/libtomcrypt/src/modes/f8/f8_setiv.c
index d1cafcf..8f45a3f 100644
--- a/libtomcrypt/src/modes/f8/f8_setiv.c
+++ b/libtomcrypt/src/modes/f8/f8_setiv.c
@@ -5,8 +5,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
@@ -18,8 +16,8 @@
#ifdef LTC_F8_MODE
/**
- Set an initial vector
- @param IV The initial vector
+ Set an initialization vector
+ @param IV The initialization vector
@param len The length of the vector (in octets)
@param f8 The F8 state
@return CRYPT_OK if successful
@@ -44,9 +42,9 @@ int f8_setiv(const unsigned char *IV, unsigned long len, symmetric_F8 *f8)
return cipher_descriptor[f8->cipher].ecb_encrypt(IV, f8->IV, &f8->key);
}
-#endif
+#endif
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtomcrypt/src/modes/f8/f8_start.c b/libtomcrypt/src/modes/f8/f8_start.c
index 4cd58de..6801702 100644
--- a/libtomcrypt/src/modes/f8/f8_start.c
+++ b/libtomcrypt/src/modes/f8/f8_start.c
@@ -5,8 +5,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
@@ -21,8 +19,8 @@
/**
Initialize an F8 context
@param cipher The index of the cipher desired
- @param IV The initial vector
- @param key The secret key
+ @param IV The initialization vector
+ @param key The secret key
@param keylen The length of the secret key (octets)
@param salt_key The salting key for the IV
@param skeylen The length of the salting key (octets)
@@ -30,8 +28,8 @@
@param f8 The F8 state to initialize
@return CRYPT_OK if successful
*/
-int f8_start( int cipher, const unsigned char *IV,
- const unsigned char *key, int keylen,
+int f8_start( int cipher, const unsigned char *IV,
+ const unsigned char *key, int keylen,
const unsigned char *salt_key, int skeylen,
int num_rounds, symmetric_F8 *f8)
{
@@ -58,7 +56,7 @@ int f8_start( int cipher, const unsigned char *IV,
f8->cipher = cipher;
f8->blocklen = cipher_descriptor[cipher].block_length;
f8->padlen = f8->blocklen;
-
+
/* now get key ^ salt_key [extend salt_ket with 0x55 as required to match length] */
zeromem(tkey, sizeof(tkey));
for (x = 0; x < keylen && x < (int)sizeof(tkey); x++) {
@@ -66,16 +64,16 @@ int f8_start( int cipher, const unsigned char *IV,
}
for (x = 0; x < skeylen && x < (int)sizeof(tkey); x++) {
tkey[x] ^= salt_key[x];
- }
+ }
for (; x < keylen && x < (int)sizeof(tkey); x++) {
tkey[x] ^= 0x55;
}
-
+
/* now encrypt with tkey[0..keylen-1] the IV and use that as the IV */
if ((err = cipher_descriptor[cipher].setup(tkey, keylen, num_rounds, &f8->key)) != CRYPT_OK) {
return err;
}
-
+
/* encrypt IV */
if ((err = cipher_descriptor[f8->cipher].ecb_encrypt(IV, f8->MIV, &f8->key)) != CRYPT_OK) {
cipher_descriptor[f8->cipher].done(&f8->key);
@@ -83,16 +81,16 @@ int f8_start( int cipher, const unsigned char *IV,
}
zeromem(tkey, sizeof(tkey));
zeromem(f8->IV, sizeof(f8->IV));
-
+
/* terminate this cipher */
cipher_descriptor[f8->cipher].done(&f8->key);
-
+
/* init the cipher */
return cipher_descriptor[cipher].setup(key, keylen, num_rounds, &f8->key);
}
#endif
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtomcrypt/src/modes/f8/f8_test_mode.c b/libtomcrypt/src/modes/f8/f8_test_mode.c
index 5cc391b..778cd35 100644
--- a/libtomcrypt/src/modes/f8/f8_test_mode.c
+++ b/libtomcrypt/src/modes/f8/f8_test_mode.c
@@ -5,8 +5,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
@@ -23,36 +21,36 @@ int f8_test_mode(void)
#ifndef LTC_TEST
return CRYPT_NOP;
#else
- static const unsigned char key[16] = { 0x23, 0x48, 0x29, 0x00, 0x84, 0x67, 0xbe, 0x18,
+ static const unsigned char key[16] = { 0x23, 0x48, 0x29, 0x00, 0x84, 0x67, 0xbe, 0x18,
0x6c, 0x3d, 0xe1, 0x4a, 0xae, 0x72, 0xd6, 0x2c };
static const unsigned char salt[4] = { 0x32, 0xf2, 0x87, 0x0d };
- static const unsigned char IV[16] = { 0x00, 0x6e, 0x5c, 0xba, 0x50, 0x68, 0x1d, 0xe5,
+ static const unsigned char IV[16] = { 0x00, 0x6e, 0x5c, 0xba, 0x50, 0x68, 0x1d, 0xe5,
0x5c, 0x62, 0x15, 0x99, 0xd4, 0x62, 0x56, 0x4a };
- static const unsigned char pt[39] = { 0x70, 0x73, 0x65, 0x75, 0x64, 0x6f, 0x72, 0x61,
+ static const unsigned char pt[39] = { 0x70, 0x73, 0x65, 0x75, 0x64, 0x6f, 0x72, 0x61,
0x6e, 0x64, 0x6f, 0x6d, 0x6e, 0x65, 0x73, 0x73,
- 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20,
0x6e, 0x65, 0x78, 0x74, 0x20, 0x62, 0x65, 0x73,
0x74, 0x20, 0x74, 0x68, 0x69, 0x6e, 0x67 };
- static const unsigned char ct[39] = { 0x01, 0x9c, 0xe7, 0xa2, 0x6e, 0x78, 0x54, 0x01,
+ static const unsigned char ct[39] = { 0x01, 0x9c, 0xe7, 0xa2, 0x6e, 0x78, 0x54, 0x01,
0x4a, 0x63, 0x66, 0xaa, 0x95, 0xd4, 0xee, 0xfd,
- 0x1a, 0xd4, 0x17, 0x2a, 0x14, 0xf9, 0xfa, 0xf4,
+ 0x1a, 0xd4, 0x17, 0x2a, 0x14, 0xf9, 0xfa, 0xf4,
0x55, 0xb7, 0xf1, 0xd4, 0xb6, 0x2b, 0xd0, 0x8f,
0x56, 0x2c, 0x0e, 0xef, 0x7c, 0x48, 0x02 };
unsigned char buf[39];
symmetric_F8 f8;
int err, idx;
-
+
idx = find_cipher("aes");
if (idx == -1) {
idx = find_cipher("rijndael");
if (idx == -1) return CRYPT_NOP;
- }
-
+ }
+
/* initialize the context */
if ((err = f8_start(idx, IV, key, sizeof(key), salt, sizeof(salt), 0, &f8)) != CRYPT_OK) {
return err;
}
-
+
/* encrypt block */
if ((err = f8_encrypt(pt, buf, sizeof(pt), &f8)) != CRYPT_OK) {
f8_done(&f8);
@@ -61,16 +59,16 @@ int f8_test_mode(void)
f8_done(&f8);
/* compare */
- if (XMEMCMP(buf, ct, sizeof(ct))) {
+ if (compare_testvector(buf, sizeof(ct), ct, sizeof(ct), "f8", 0)) {
return CRYPT_FAIL_TESTVECTOR;
- }
-
+ }
+
return CRYPT_OK;
-#endif
-}
+#endif
+}
#endif
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */