summaryrefslogtreecommitdiffhomepage
path: root/libtomcrypt/src/ciphers/safer
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2007-01-11 02:41:05 +0000
committerMatt Johnston <matt@ucc.asn.au>2007-01-11 02:41:05 +0000
commita938f4cfe140e8561d9dbf108b896492a662a893 (patch)
treef2a74322f959ff6a505ba5e87274ebe3d17d5e74 /libtomcrypt/src/ciphers/safer
parent692d737a821c5e401c227d936b8f0d76b955650f (diff)
parent28ad393b008b34bc3cdbaa192440b8cc615329f0 (diff)
propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 2af22fb4e878750b88f80f90d439b316d229796f)
to branch 'au.asn.ucc.matt.dropbear' (head 02c413252c90e9de8e03d91e9939dde3029f5c0a) --HG-- extra : convert_revision : 52ccb0ad0587a62bc64aecb939adbb76546aac16
Diffstat (limited to 'libtomcrypt/src/ciphers/safer')
-rw-r--r--libtomcrypt/src/ciphers/safer/safer.c40
-rw-r--r--libtomcrypt/src/ciphers/safer/safer_tab.c6
-rw-r--r--libtomcrypt/src/ciphers/safer/saferp.c18
3 files changed, 36 insertions, 28 deletions
diff --git a/libtomcrypt/src/ciphers/safer/safer.c b/libtomcrypt/src/ciphers/safer/safer.c
index bad00a0..9fdaf37 100644
--- a/libtomcrypt/src/ciphers/safer/safer.c
+++ b/libtomcrypt/src/ciphers/safer/safer.c
@@ -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.org
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
/*******************************************************************************
@@ -42,7 +42,7 @@ const struct ltc_cipher_descriptor
&safer_k64_test,
&safer_done,
&safer_64_keysize,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
},
safer_sk64_desc = {
@@ -54,7 +54,7 @@ const struct ltc_cipher_descriptor
&safer_sk64_test,
&safer_done,
&safer_64_keysize,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
},
safer_k128_desc = {
@@ -66,7 +66,7 @@ const struct ltc_cipher_descriptor
&safer_sk128_test,
&safer_done,
&safer_128_keysize,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
},
safer_sk128_desc = {
@@ -78,7 +78,7 @@ const struct ltc_cipher_descriptor
&safer_sk128_test,
&safer_done,
&safer_128_keysize,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
/******************* Constants ************************************************/
@@ -246,11 +246,11 @@ int safer_sk128_setup(const unsigned char *key, int keylen, int numrounds, symme
}
#ifdef LTC_CLEAN_STACK
-static void _safer_ecb_encrypt(const unsigned char *block_in,
+static int _safer_ecb_encrypt(const unsigned char *block_in,
unsigned char *block_out,
symmetric_key *skey)
#else
-void safer_ecb_encrypt(const unsigned char *block_in,
+int safer_ecb_encrypt(const unsigned char *block_in,
unsigned char *block_out,
symmetric_key *skey)
#endif
@@ -285,24 +285,26 @@ void safer_ecb_encrypt(const unsigned char *block_in,
block_out[2] = c & 0xFF; block_out[3] = d & 0xFF;
block_out[4] = e & 0xFF; block_out[5] = f & 0xFF;
block_out[6] = g & 0xFF; block_out[7] = h & 0xFF;
+ return CRYPT_OK;
}
#ifdef LTC_CLEAN_STACK
-void safer_ecb_encrypt(const unsigned char *block_in,
+int safer_ecb_encrypt(const unsigned char *block_in,
unsigned char *block_out,
symmetric_key *skey)
{
- _safer_ecb_encrypt(block_in, block_out, skey);
+ int err = _safer_ecb_encrypt(block_in, block_out, skey);
burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *));
+ return err;
}
#endif
#ifdef LTC_CLEAN_STACK
-static void _safer_ecb_decrypt(const unsigned char *block_in,
+static int _safer_ecb_decrypt(const unsigned char *block_in,
unsigned char *block_out,
symmetric_key *skey)
#else
-void safer_ecb_decrypt(const unsigned char *block_in,
+int safer_ecb_decrypt(const unsigned char *block_in,
unsigned char *block_out,
symmetric_key *skey)
#endif
@@ -338,15 +340,17 @@ void safer_ecb_decrypt(const unsigned char *block_in,
block_out[2] = c & 0xFF; block_out[3] = d & 0xFF;
block_out[4] = e & 0xFF; block_out[5] = f & 0xFF;
block_out[6] = g & 0xFF; block_out[7] = h & 0xFF;
+ return CRYPT_OK;
}
#ifdef LTC_CLEAN_STACK
-void safer_ecb_decrypt(const unsigned char *block_in,
+int safer_ecb_decrypt(const unsigned char *block_in,
unsigned char *block_out,
symmetric_key *skey)
{
- _safer_ecb_decrypt(block_in, block_out, skey);
+ int err = _safer_ecb_decrypt(block_in, block_out, skey);
burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *));
+ return err;
}
#endif
@@ -392,7 +396,7 @@ int safer_k64_test(void)
safer_ecb_encrypt(k64_pt, buf[0], &skey);
safer_ecb_decrypt(buf[0], buf[1], &skey);
- if (memcmp(buf[0], k64_ct, 8) != 0 || memcmp(buf[1], k64_pt, 8) != 0) {
+ if (XMEMCMP(buf[0], k64_ct, 8) != 0 || XMEMCMP(buf[1], k64_pt, 8) != 0) {
return CRYPT_FAIL_TESTVECTOR;
}
@@ -422,7 +426,7 @@ int safer_sk64_test(void)
safer_ecb_encrypt(sk64_pt, buf[0], &skey);
safer_ecb_decrypt(buf[0], buf[1], &skey);
- if (memcmp(buf[0], sk64_ct, 8) != 0 || memcmp(buf[1], sk64_pt, 8) != 0) {
+ if (XMEMCMP(buf[0], sk64_ct, 8) != 0 || XMEMCMP(buf[1], sk64_pt, 8) != 0) {
return CRYPT_FAIL_TESTVECTOR;
}
@@ -464,7 +468,7 @@ int safer_sk128_test(void)
safer_ecb_encrypt(sk128_pt, buf[0], &skey);
safer_ecb_decrypt(buf[0], buf[1], &skey);
- if (memcmp(buf[0], sk128_ct, 8) != 0 || memcmp(buf[1], sk128_pt, 8) != 0) {
+ if (XMEMCMP(buf[0], sk128_ct, 8) != 0 || XMEMCMP(buf[1], sk128_pt, 8) != 0) {
return CRYPT_FAIL_TESTVECTOR;
}
@@ -483,5 +487,5 @@ int safer_sk128_test(void)
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/safer/safer.c,v $ */
-/* $Revision: 1.8 $ */
-/* $Date: 2005/05/05 14:35:58 $ */
+/* $Revision: 1.13 $ */
+/* $Date: 2006/11/08 23:01:06 $ */
diff --git a/libtomcrypt/src/ciphers/safer/safer_tab.c b/libtomcrypt/src/ciphers/safer/safer_tab.c
index 47fbd1c..a542768 100644
--- a/libtomcrypt/src/ciphers/safer/safer_tab.c
+++ b/libtomcrypt/src/ciphers/safer/safer_tab.c
@@ -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.org
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
/**
@@ -64,5 +64,5 @@ const unsigned char safer_lbox[256] = {
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/safer/safer_tab.c,v $ */
-/* $Revision: 1.3 $ */
-/* $Date: 2005/05/05 14:35:58 $ */
+/* $Revision: 1.4 $ */
+/* $Date: 2006/03/31 14:15:35 $ */
diff --git a/libtomcrypt/src/ciphers/safer/saferp.c b/libtomcrypt/src/ciphers/safer/saferp.c
index 6d0d589..dff4ee9 100644
--- a/libtomcrypt/src/ciphers/safer/saferp.c
+++ b/libtomcrypt/src/ciphers/safer/saferp.c
@@ -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.org
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
/**
@@ -28,7 +28,7 @@ const struct ltc_cipher_descriptor saferp_desc =
&saferp_test,
&saferp_done,
&saferp_keysize,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
/* ROUND(b,i)
@@ -329,8 +329,9 @@ int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric
@param pt The input plaintext (16 bytes)
@param ct The output ciphertext (16 bytes)
@param skey The key as scheduled
+ @return CRYPT_OK if successful
*/
-void saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
+int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
{
unsigned char b[16];
int x;
@@ -384,6 +385,7 @@ void saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_ke
#ifdef LTC_CLEAN_STACK
zeromem(b, sizeof(b));
#endif
+ return CRYPT_OK;
}
/**
@@ -391,8 +393,9 @@ void saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_ke
@param ct The input ciphertext (16 bytes)
@param pt The output plaintext (16 bytes)
@param skey The key as scheduled
+ @return CRYPT_OK if successful
*/
-void saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
+int saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
{
unsigned char b[16];
int x;
@@ -446,6 +449,7 @@ void saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_ke
#ifdef LTC_CLEAN_STACK
zeromem(b, sizeof(b));
#endif
+ return CRYPT_OK;
}
/**
@@ -503,7 +507,7 @@ int saferp_test(void)
saferp_ecb_decrypt(tmp[0], tmp[1], &skey);
/* compare */
- if (memcmp(tmp[0], tests[i].ct, 16) || memcmp(tmp[1], tests[i].pt, 16)) {
+ if (XMEMCMP(tmp[0], tests[i].ct, 16) || XMEMCMP(tmp[1], tests[i].pt, 16)) {
return CRYPT_FAIL_TESTVECTOR;
}
@@ -551,5 +555,5 @@ int saferp_keysize(int *keysize)
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/safer/saferp.c,v $ */
-/* $Revision: 1.7 $ */
-/* $Date: 2005/05/05 14:35:58 $ */
+/* $Revision: 1.12 $ */
+/* $Date: 2006/11/08 23:01:06 $ */