summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>1999-02-23 05:14:47 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>1999-02-23 05:14:47 +0000
commitfcaf3f00e0a6bb690356f6ebf396e743449fcab9 (patch)
treefc8fa549747d5eed6524a46862a2617ec74ff2da
parent84b193b97e1536400d2b4390b8f2bb595032391a (diff)
This one seems to work, at least in the direction Sparc->i386.
Btw, for all the curious souls, I am in Canada at the moment (land of free commits).
-rw-r--r--sys/netinet/ip_blf.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/sys/netinet/ip_blf.c b/sys/netinet/ip_blf.c
index 71b2c98f35e..9f660f3717d 100644
--- a/sys/netinet/ip_blf.c
+++ b/sys/netinet/ip_blf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_blf.c,v 1.4 1999/02/23 05:04:27 angelos Exp $ */
+/* $OpenBSD: ip_blf.c,v 1.5 1999/02/23 05:14:46 angelos Exp $ */
/*
* Blowfish block cipher for OpenBSD
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@@ -581,3 +581,63 @@ blf_dec(c, data, blocks)
d += 2;
}
}
+
+#if __STDC__
+void
+blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
+#else
+void
+blf_ecb_encrypt(c, data, len)
+ blf_ctx *c;
+ u_int8_t *data;
+ u_int32_t len;
+#endif
+{
+ u_int32_t l, r;
+ u_int32_t i;
+
+ for (i = 0; i < len; i += 8) {
+ l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
+ r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
+ Blowfish_encipher(c, &l, &r);
+ data[0] = l >> 24 & 0xff;
+ data[1] = l >> 16 & 0xff;
+ data[2] = l >> 8 & 0xff;
+ data[3] = l & 0xff;
+ data[4] = r >> 24 & 0xff;
+ data[5] = r >> 16 & 0xff;
+ data[6] = r >> 8 & 0xff;
+ data[7] = r & 0xff;
+ data += 8;
+ }
+}
+
+#if __STDC__
+void
+blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
+#else
+void
+blf_ecb_decrypt(c, data, len)
+ blf_ctx *c;
+ u_int8_t *data;
+ u_int32_t len;
+#endif
+{
+ u_int32_t l, r;
+ u_int32_t i;
+
+ for (i = 0; i < len; i += 8) {
+ l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
+ r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
+ Blowfish_decipher(c, &l, &r);
+ data[0] = l >> 24 & 0xff;
+ data[1] = l >> 16 & 0xff;
+ data[2] = l >> 8 & 0xff;
+ data[3] = l & 0xff;
+ data[4] = r >> 24 & 0xff;
+ data[5] = r >> 16 & 0xff;
+ data[6] = r >> 8 & 0xff;
+ data[7] = r & 0xff;
+ data += 8;
+ }
+}