summaryrefslogtreecommitdiff
path: root/lib/libc/crypt
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-08-21 23:31:29 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-08-21 23:31:29 +0000
commit1274d4f909c6bc16b5a91647f99d09c4db759407 (patch)
tree35855cd16714c2104a7810517a2d8de13f0b3a58 /lib/libc/crypt
parentb90c1d7dbb73ada29058adea32331248789f4596 (diff)
for new functions, fix BE & UA cases. LE UA case is still busted
Diffstat (limited to 'lib/libc/crypt')
-rw-r--r--lib/libc/crypt/blowfish.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/libc/crypt/blowfish.c b/lib/libc/crypt/blowfish.c
index d9466556245..96b4c06f000 100644
--- a/lib/libc/crypt/blowfish.c
+++ b/lib/libc/crypt/blowfish.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: blowfish.c,v 1.9 1998/08/10 18:40:59 provos Exp $ */
+/* $OpenBSD: blowfish.c,v 1.10 1998/08/21 23:31:28 deraadt Exp $ */
/*
* Blowfish block cipher for OpenBSD
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@@ -611,16 +611,16 @@ blf_ecb_encrypt(c, data, len)
u_int32_t len;
#endif
{
-#if BYTE_ORDER == LITTLE_ENDIAN
u_int32_t l, r;
-#endif
u_int32_t i;
for (i = 0; i < len; i += 8) {
#if BYTE_ORDER == LITTLE_ENDIAN
BLF_BLK_ENC;
#else
- Blowfish_encipher(c, data, data + 4);
+ memcpy(&l, data, sizeof l);
+ memcpy(&r, data + 4, sizeof r);
+ Blowfish_encipher(c, &l, &r);
#endif
data += 8;
}
@@ -637,16 +637,16 @@ blf_ecb_decrypt(c, data, len)
u_int32_t len;
#endif
{
-#if BYTE_ORDER == LITTLE_ENDIAN
u_int32_t l, r;
-#endif
u_int32_t i;
for (i = 0; i < len; i += 8) {
#if BYTE_ORDER == LITTLE_ENDIAN
BLF_BLK_DEC;
#else
- Blowfish_decipher(c, data, data + 4);
+ memcpy(&l, data, sizeof l);
+ memcpy(&r, data + 4, sizeof r);
+ Blowfish_decipher(c, &l, &r);
#endif
data += 8;
}
@@ -664,9 +664,7 @@ blf_cbc_encrypt(c, iv, data, len)
u_int32_t len;
#endif
{
-#if BYTE_ORDER == LITTLE_ENDIAN
u_int32_t l, r;
-#endif
u_int32_t i;
for (i = 0; i < len; i += 8) {
@@ -675,7 +673,9 @@ blf_cbc_encrypt(c, iv, data, len)
#if BYTE_ORDER == LITTLE_ENDIAN
BLF_BLK_ENC;
#else
- Blowfish_encipher(c, data, data + 4);
+ memcpy(&l, data, sizeof l);
+ memcpy(&r, data + 4, sizeof r);
+ Blowfish_encipher(c, &l, &r);
#endif
iv = data;
data += 8;
@@ -694,9 +694,7 @@ blf_cbc_decrypt(c, iva, data, len)
u_int32_t len;
#endif
{
-#if BYTE_ORDER == LITTLE_ENDIAN
u_int32_t l, r;
-#endif
u_int8_t *iv;
u_int32_t i;
@@ -706,7 +704,9 @@ blf_cbc_decrypt(c, iva, data, len)
#if BYTE_ORDER == LITTLE_ENDIAN
BLF_BLK_DEC;
#else
- Blowfish_decipher(c, data, data + 4);
+ memcpy(&l, data, sizeof l);
+ memcpy(&r, data + 4, sizeof r);
+ Blowfish_decipher(c, &l, &r);
#endif
*(u_int32_t *)data ^= *(u_int32_t *)iv;
*(u_int32_t *)(data + 4) ^= *(u_int32_t *)(iv + 4);
@@ -716,7 +716,9 @@ blf_cbc_decrypt(c, iva, data, len)
#if BYTE_ORDER == LITTLE_ENDIAN
BLF_BLK_DEC;
#else
- Blowfish_decipher(c, data, data + 4);
+ memcpy(&l, data, sizeof l);
+ memcpy(&r, data + 4, sizeof r);
+ Blowfish_decipher(c, &l, &r);
#endif
*(u_int32_t *)data ^= *(u_int32_t *)iva;
*(u_int32_t *)(data + 4) ^= *(u_int32_t *)(iva + 4);