The unified diff between revisions [92f17752..] and [11a5f681..] is displayed below. It can also be downloaded as a raw diff.

This diff has been restricted to the following files: 'src/blowfish.cpp'

#
#
# patch "src/blowfish.cpp"
#  from [aa95cd8260ffe198982ddf3ec3f391a7f69e9b2e]
#    to [fddf7167914ab45f09eac78875fba52264c35aa3]
#
============================================================
--- src/blowfish.cpp	aa95cd8260ffe198982ddf3ec3f391a7f69e9b2e
+++ src/blowfish.cpp	fddf7167914ab45f09eac78875fba52264c35aa3
@@ -1,10 +1,10 @@
 /*************************************************
 * Blowfish Source File                           *
-* (C) 1999-2006 The Botan Project                *
+* (C) 1999-2007 Jack Lloyd                       *
 *************************************************/

 #include <botan/blowfish.h>
-#include <botan/bit_ops.h>
+#include <botan/loadstor.h>

 namespace Botan {

@@ -13,8 +13,8 @@ void Blowfish::enc(const byte in[], byte
 *************************************************/
 void Blowfish::enc(const byte in[], byte out[]) const
    {
-   u32bit L = make_u32bit(in[0], in[1], in[2], in[3]),
-          R = make_u32bit(in[4], in[5], in[6], in[7]);
+   u32bit L = load_be<u32bit>(in, 0);
+   u32bit R = load_be<u32bit>(in, 1);

    for(u32bit j = 0; j != 16; j += 2)
       {
@@ -29,10 +29,7 @@ void Blowfish::enc(const byte in[], byte

    L ^= P[16]; R ^= P[17];

-   out[0] = get_byte(0, R); out[1] = get_byte(1, R);
-   out[2] = get_byte(2, R); out[3] = get_byte(3, R);
-   out[4] = get_byte(0, L); out[5] = get_byte(1, L);
-   out[6] = get_byte(2, L); out[7] = get_byte(3, L);
+   store_be(out, R, L);
    }

 /*************************************************
@@ -40,8 +37,8 @@ void Blowfish::dec(const byte in[], byte
 *************************************************/
 void Blowfish::dec(const byte in[], byte out[]) const
    {
-   u32bit L = make_u32bit(in[0], in[1], in[2], in[3]),
-          R = make_u32bit(in[4], in[5], in[6], in[7]);
+   u32bit L = load_be<u32bit>(in, 0);
+   u32bit R = load_be<u32bit>(in, 1);

    for(u32bit j = 17; j != 1; j -= 2)
       {
@@ -56,10 +53,7 @@ void Blowfish::dec(const byte in[], byte

    L ^= P[1]; R ^= P[0];

-   out[0] = get_byte(0, R); out[1] = get_byte(1, R);
-   out[2] = get_byte(2, R); out[3] = get_byte(3, R);
-   out[4] = get_byte(0, L); out[5] = get_byte(1, L);
-   out[6] = get_byte(2, L); out[7] = get_byte(3, L);
+   store_be(out, R, L);
    }

 /*************************************************
@@ -68,9 +62,11 @@ void Blowfish::key(const byte key[], u32
 void Blowfish::key(const byte key[], u32bit length)
    {
    clear();
+
    for(u32bit j = 0, k = 0; j != 18; ++j, k += 4)
       P[j] ^= make_u32bit(key[(k  ) % length], key[(k+1) % length],
-                             key[(k+2) % length], key[(k+3) % length]);
+                          key[(k+2) % length], key[(k+3) % length]);
+
    u32bit L = 0, R = 0;
    generate_sbox(P,  18,  L, R);
    generate_sbox(S1, 256, L, R);
@@ -109,10 +105,10 @@ void Blowfish::clear() throw()
 void Blowfish::clear() throw()
    {
    P.copy(PBOX, 18);
-   S1.copy(SBOX1, 256);
-   S2.copy(SBOX2, 256);
-   S3.copy(SBOX3, 256);
-   S4.copy(SBOX4, 256);
+   S1.copy(SBOX +   0, 256);
+   S2.copy(SBOX + 256, 256);
+   S3.copy(SBOX + 512, 256);
+   S4.copy(SBOX + 768, 256);
    }

 }