diff libtomcrypt/src/ciphers/blowfish.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
line wrap: on
line diff
--- a/libtomcrypt/src/ciphers/blowfish.c	Thu Feb 08 23:11:40 2018 +0800
+++ b/libtomcrypt/src/ciphers/blowfish.c	Fri Feb 09 21:44:05 2018 +0800
@@ -5,8 +5,6 @@
  *
  * The library is free for all purposes without any express
  * guarantee it works.
- *
- * Tom St Denis, [email protected], http://libtom.org
  */
 /**
   @file blowfish.c
@@ -27,7 +25,7 @@
     &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 @@
    /* 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 @@
    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 @@
   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 @@
     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 @@
 {
  #ifndef LTC_TEST
     return CRYPT_NOP;
- #else    
+ #else
    int err;
    symmetric_key key;
    static const struct {
@@ -548,7 +546,8 @@
       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 @@
  #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 @@
 #endif
 
 
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref:         $Format:%D$ */
+/* git commit:  $Format:%H$ */
+/* commit time: $Format:%ai$ */