aboutsummaryrefslogtreecommitdiffstats
path: root/src/des.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/des.cpp')
-rw-r--r--src/des.cpp32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/des.cpp b/src/des.cpp
index 47bdb8f56..e8f173c5c 100644
--- a/src/des.cpp
+++ b/src/des.cpp
@@ -13,17 +13,13 @@ namespace Botan {
*************************************************/
void DES::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), R = load_be<u32bit>(in, 1);
IP(L, R);
raw_encrypt(L, R);
FP(L, R);
- 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);
}
/*************************************************
@@ -31,17 +27,13 @@ void DES::enc(const byte in[], byte out[]) const
*************************************************/
void DES::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), R = load_be<u32bit>(in, 1);
IP(L, R);
raw_decrypt(L, R);
FP(L, R);
- 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);
}
/*************************************************
@@ -193,8 +185,7 @@ void DES::key(const byte key[], u32bit)
*************************************************/
void TripleDES::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), R = load_be<u32bit>(in, 1);
DES::IP(L, R);
des1.raw_encrypt(L, R);
@@ -202,10 +193,7 @@ void TripleDES::enc(const byte in[], byte out[]) const
des3.raw_encrypt(L, R);
DES::FP(L, R);
- 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);
}
/*************************************************
@@ -213,8 +201,7 @@ void TripleDES::enc(const byte in[], byte out[]) const
*************************************************/
void TripleDES::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), R = load_be<u32bit>(in, 1);
DES::IP(L, R);
des3.raw_decrypt(L, R);
@@ -222,10 +209,7 @@ void TripleDES::dec(const byte in[], byte out[]) const
des1.raw_decrypt(L, R);
DES::FP(L, R);
- 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);
}
/*************************************************