Changeset View
Changeset View
Standalone View
Standalone View
head/sys/opencrypto/xform_blf.c
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <crypto/blowfish/blowfish.h> | #include <crypto/blowfish/blowfish.h> | ||||
#include <opencrypto/xform_enc.h> | #include <opencrypto/xform_enc.h> | ||||
static int blf_setkey(u_int8_t **, u_int8_t *, int); | static int blf_setkey(u_int8_t **, const u_int8_t *, int); | ||||
static void blf_encrypt(caddr_t, u_int8_t *); | static void blf_encrypt(caddr_t, u_int8_t *); | ||||
static void blf_decrypt(caddr_t, u_int8_t *); | static void blf_decrypt(caddr_t, u_int8_t *); | ||||
static void blf_zerokey(u_int8_t **); | static void blf_zerokey(u_int8_t **); | ||||
/* Encryption instances */ | /* Encryption instances */ | ||||
struct enc_xform enc_xform_blf = { | struct enc_xform enc_xform_blf = { | ||||
CRYPTO_BLF_CBC, "Blowfish", | CRYPTO_BLF_CBC, "Blowfish", | ||||
BLOWFISH_BLOCK_LEN, BLOWFISH_BLOCK_LEN, BLOWFISH_MIN_KEY, | BLOWFISH_BLOCK_LEN, BLOWFISH_BLOCK_LEN, BLOWFISH_MIN_KEY, | ||||
Show All 34 Lines | blf_decrypt(caddr_t key, u_int8_t *blk) | ||||
/* NB: BF_decrypt expects the block in host order! */ | /* NB: BF_decrypt expects the block in host order! */ | ||||
BF_decrypt(t, (BF_KEY *) key); | BF_decrypt(t, (BF_KEY *) key); | ||||
t[0] = htonl(t[0]); | t[0] = htonl(t[0]); | ||||
t[1] = htonl(t[1]); | t[1] = htonl(t[1]); | ||||
memcpy(blk, t, sizeof (t)); | memcpy(blk, t, sizeof (t)); | ||||
} | } | ||||
static int | static int | ||||
blf_setkey(u_int8_t **sched, u_int8_t *key, int len) | blf_setkey(u_int8_t **sched, const u_int8_t *key, int len) | ||||
{ | { | ||||
int err; | int err; | ||||
*sched = KMALLOC(sizeof(BF_KEY), | *sched = KMALLOC(sizeof(BF_KEY), | ||||
M_CRYPTO_DATA, M_NOWAIT|M_ZERO); | M_CRYPTO_DATA, M_NOWAIT|M_ZERO); | ||||
if (*sched != NULL) { | if (*sched != NULL) { | ||||
BF_set_key((BF_KEY *) *sched, len, key); | BF_set_key((BF_KEY *) *sched, len, key); | ||||
err = 0; | err = 0; | ||||
Show All 12 Lines |