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

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

#
#
# patch "src/cast128.cpp"
#  from [c22138fc93b5506098469c3fc878c410f8b66757]
#    to [c6c53ec85bddb52351921a9e9a08fb0c340b2813]
#
============================================================
--- src/cast128.cpp	c22138fc93b5506098469c3fc878c410f8b66757
+++ src/cast128.cpp	c6c53ec85bddb52351921a9e9a08fb0c340b2813
@@ -1,9 +1,10 @@
 /*************************************************
 * CAST-128 Source File                           *
-* (C) 1999-2006 The Botan Project                *
+* (C) 1999-2007 Jack Lloyd                       *
 *************************************************/

 #include <botan/cast128.h>
+#include <botan/loadstor.h>
 #include <botan/bit_ops.h>

 namespace Botan {
@@ -47,8 +48,8 @@ void CAST_128::enc(const byte in[], byte
 *************************************************/
 void CAST_128::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);

    R1(L, R, MK[ 0], RK[ 0]);
    R2(R, L, MK[ 1], RK[ 1]);
@@ -67,10 +68,7 @@ void CAST_128::enc(const byte in[], byte
    R3(L, R, MK[14], RK[14]);
    R1(R, L, MK[15], RK[15]);

-   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);
    }

 /*************************************************
@@ -78,8 +76,8 @@ void CAST_128::dec(const byte in[], byte
 *************************************************/
 void CAST_128::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);

    R1(L, R, MK[15], RK[15]);
    R3(R, L, MK[14], RK[14]);
@@ -98,10 +96,7 @@ void CAST_128::dec(const byte in[], byte
    R2(L, R, MK[ 1], RK[ 1]);
    R1(R, L, MK[ 0], RK[ 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);
    }

 /*************************************************