summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2010-10-19 07:47:35 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2010-10-19 07:47:35 +0000
commite154dbba927d48c799102e09bd34fdefdc331676 (patch)
tree421eb6eb0a2181d2f4900a92278b4208497de262 /sbin
parentad032780ca155e1622297ac9e956a4577ec77576 (diff)
convert to fuse cast from the libcrypto. with a simplification nit from
blambert, ok jsg, "seems ok" todd
Diffstat (limited to 'sbin')
-rw-r--r--sbin/isakmpd/crypto.c27
-rw-r--r--sbin/isakmpd/crypto.h6
2 files changed, 8 insertions, 25 deletions
diff --git a/sbin/isakmpd/crypto.c b/sbin/isakmpd/crypto.c
index 1dac786313f..9574a491351 100644
--- a/sbin/isakmpd/crypto.c
+++ b/sbin/isakmpd/crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto.c,v 1.30 2010/10/15 10:18:42 jsg Exp $ */
+/* $OpenBSD: crypto.c,v 1.31 2010/10/19 07:47:34 mikeb Exp $ */
/* $EOM: crypto.c,v 1.32 2000/03/07 20:08:51 niklas Exp $ */
/*
@@ -204,38 +204,21 @@ blf_decrypt(struct keystate *ks, u_int8_t *data, u_int16_t len)
enum cryptoerr
cast_init(struct keystate *ks, u_int8_t *key, u_int16_t len)
{
- cast_setkey(&ks->ks_cast, key, len);
+ CAST_set_key(&ks->ks_cast, len, key);
return EOKAY;
}
void
cast1_encrypt(struct keystate *ks, u_int8_t *data, u_int16_t len)
{
- u_int16_t i, blocksize = ks->xf->blocksize;
- u_int8_t *iv = ks->liv;
-
- memcpy(iv, ks->riv, blocksize);
-
- for (i = 0; i < len; data += blocksize, i += blocksize) {
- XOR64(data, iv);
- cast_encrypt(&ks->ks_cast, data, data);
- SET64(iv, data);
- }
+ memcpy(ks->liv, ks->riv, ks->xf->blocksize);
+ CAST_cbc_encrypt(data, data, len, &ks->ks_cast, ks->liv, 1);
}
void
cast1_decrypt(struct keystate *ks, u_int8_t *data, u_int16_t len)
{
- u_int16_t i, blocksize = ks->xf->blocksize;
-
- data += len - blocksize;
- for (i = len - blocksize; i >= blocksize; data -= blocksize,
- i -= blocksize) {
- cast_decrypt(&ks->ks_cast, data, data);
- XOR64(data, data - blocksize);
- }
- cast_decrypt(&ks->ks_cast, data, data);
- XOR64(data, ks->riv);
+ CAST_cbc_encrypt(data, data, len, &ks->ks_cast, ks->riv, 0);
}
enum cryptoerr
diff --git a/sbin/isakmpd/crypto.h b/sbin/isakmpd/crypto.h
index effdb189d1c..860bb0a67ca 100644
--- a/sbin/isakmpd/crypto.h
+++ b/sbin/isakmpd/crypto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto.h,v 1.19 2010/10/15 10:18:42 jsg Exp $ */
+/* $OpenBSD: crypto.h,v 1.20 2010/10/19 07:47:34 mikeb Exp $ */
/* $EOM: crypto.h,v 1.12 2000/10/15 21:56:41 niklas Exp $ */
/*
@@ -34,7 +34,7 @@
#include <openssl/des.h>
#include <blf.h>
-#include <cast.h>
+#include <openssl/cast.h>
#include <openssl/aes.h>
@@ -82,7 +82,7 @@ struct keystate {
union {
DES_key_schedule desks[3];
blf_ctx blfks;
- cast_key castks;
+ CAST_KEY castks;
AES_KEY aesks[2];
} keydata;
};