summaryrefslogtreecommitdiffhomepage
path: root/libtomcrypt/src/ciphers/blowfish.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2018-02-17 19:29:51 +0800
committerMatt Johnston <matt@ucc.asn.au>2018-02-17 19:29:51 +0800
commit7e8094d53a1c01ac671156ff2e67157b64d01a3a (patch)
treec88345f5bdd118eb9414dff5ab5c307bb1806c57 /libtomcrypt/src/ciphers/blowfish.c
parentf7a664f127d3dfde0e7c7a9ca74b1d14f9a2f983 (diff)
parentf042eb41ab0d31f8ba0c5ccc9c848ad01f08f986 (diff)
merge from main
--HG-- branch : fuzz
Diffstat (limited to 'libtomcrypt/src/ciphers/blowfish.c')
-rw-r--r--libtomcrypt/src/ciphers/blowfish.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/libtomcrypt/src/ciphers/blowfish.c b/libtomcrypt/src/ciphers/blowfish.c
index 6a55abc..a1945ae 100644
--- a/libtomcrypt/src/ciphers/blowfish.c
+++ b/libtomcrypt/src/ciphers/blowfish.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
*/
/**
@file blowfish.c
@@ -27,7 +25,7 @@ const struct ltc_cipher_descriptor blowfish_desc =
&blowfish_test,
&blowfish_done,
&blowfish_keysize,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
static const ulong32 ORIG_P[16 + 2] = {
@@ -322,15 +320,15 @@ int blowfish_setup(const unsigned char *key, int keylen, int num_rounds,
/* check rounds */
if (num_rounds != 0 && num_rounds != 16) {
return CRYPT_INVALID_ROUNDS;
- }
+ }
/* load in key bytes (Supplied by David Hopwood) */
for (x = y = 0; x < 18; x++) {
A = 0;
for (z = 0; z < 4; z++) {
A = (A << 8) | ((ulong32)key[y++] & 255);
- if (y == (ulong32)keylen) {
- y = 0;
+ if (y == (ulong32)keylen) {
+ y = 0;
}
}
skey->blowfish.K[x] = ORIG_P[x] ^ A;
@@ -347,7 +345,7 @@ int blowfish_setup(const unsigned char *key, int keylen, int num_rounds,
for (x = 0; x < 8; x++) {
B[x] = 0;
}
-
+
for (x = 0; x < 18; x += 2) {
/* encrypt it */
blowfish_ecb_encrypt(B, B, skey);
@@ -446,7 +444,7 @@ int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_k
Decrypts a block of text with Blowfish
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
- @param skey The key as scheduled
+ @param skey The key as scheduled
@return CRYPT_OK if successful
*/
#ifdef LTC_CLEAN_STACK
@@ -464,7 +462,7 @@ int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_k
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
LTC_ARGCHK(skey != NULL);
-
+
#ifndef __GNUC__
S1 = skey->blowfish.S[0];
S2 = skey->blowfish.S[1];
@@ -512,7 +510,7 @@ int blowfish_test(void)
{
#ifndef LTC_TEST
return CRYPT_NOP;
- #else
+ #else
int err;
symmetric_key key;
static const struct {
@@ -548,7 +546,8 @@ int blowfish_test(void)
blowfish_ecb_decrypt(tmp[0], tmp[1], &key);
/* compare */
- if ((XMEMCMP(tmp[0], tests[x].ct, 8) != 0) || (XMEMCMP(tmp[1], tests[x].pt, 8) != 0)) {
+ if ((compare_testvector(tmp[0], 8, tests[x].ct, 8, "Blowfish Encrypt", x) != 0) ||
+ (compare_testvector(tmp[1], 8, tests[x].pt, 8, "Blowfish Decrypt", x) != 0)) {
return CRYPT_FAIL_TESTVECTOR;
}
@@ -562,11 +561,12 @@ int blowfish_test(void)
#endif
}
-/** Terminate the context
+/** Terminate the context
@param skey The scheduled key
*/
void blowfish_done(symmetric_key *skey)
{
+ LTC_UNUSED_PARAM(skey);
}
/**
@@ -589,6 +589,6 @@ int blowfish_keysize(int *keysize)
#endif
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */