sprinkle DPRINTF()...
This commit is contained in:
parent
03d1230d6c
commit
5403b0bea4
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cryptodev.c,v 1.17 2006/03/01 12:38:32 yamt Exp $ */
|
||||
/* $NetBSD: cryptodev.c,v 1.18 2006/03/06 00:50:44 christos Exp $ */
|
||||
/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
|
||||
/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.17 2006/03/01 12:38:32 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.18 2006/03/06 00:50:44 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -56,6 +56,11 @@ __KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.17 2006/03/01 12:38:32 yamt Exp $");
|
||||
#ifdef __NetBSD__
|
||||
#define splcrypto splnet
|
||||
#endif
|
||||
#ifdef CRYPTO_DEBUG
|
||||
#define DPRINTF(a) uprintf a
|
||||
#else
|
||||
#define DPRINTF(a)
|
||||
#endif
|
||||
|
||||
struct csession {
|
||||
TAILQ_ENTRY(csession) next;
|
||||
@ -192,6 +197,7 @@ cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
|
||||
txform = &enc_xform_arc4;
|
||||
break;
|
||||
default:
|
||||
DPRINTF(("Invalid cipher %d\n", sop->cipher));
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
@ -211,8 +217,11 @@ cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
|
||||
thash = &auth_hash_hmac_sha2_384;
|
||||
else if (sop->mackeylen == auth_hash_hmac_sha2_512.keysize)
|
||||
thash = &auth_hash_hmac_sha2_512;
|
||||
else
|
||||
else {
|
||||
DPRINTF(("Invalid mackeylen %d\n",
|
||||
sop->mackeylen));
|
||||
return (EINVAL);
|
||||
}
|
||||
break;
|
||||
case CRYPTO_RIPEMD160_HMAC:
|
||||
thash = &auth_hash_hmac_ripemd_160_96;
|
||||
@ -227,6 +236,7 @@ cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
|
||||
thash = &auth_hash_null;
|
||||
break;
|
||||
default:
|
||||
DPRINTF(("Invalid mac %d\n", sop->mac));
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
@ -238,6 +248,9 @@ cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
|
||||
crie.cri_klen = sop->keylen * 8;
|
||||
if (sop->keylen > txform->maxkey ||
|
||||
sop->keylen < txform->minkey) {
|
||||
DPRINTF(("keylen %d not in [%d,%d]\n",
|
||||
sop->keylen, txform->minkey,
|
||||
txform->maxkey));
|
||||
error = EINVAL;
|
||||
goto bail;
|
||||
}
|
||||
@ -255,6 +268,8 @@ cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
|
||||
cria.cri_alg = thash->type;
|
||||
cria.cri_klen = sop->mackeylen * 8;
|
||||
if (sop->mackeylen != thash->keysize) {
|
||||
DPRINTF(("mackeylen %d != keysize %d\n",
|
||||
sop->mackeylen, thash->keysize));
|
||||
error = EINVAL;
|
||||
goto bail;
|
||||
}
|
||||
@ -271,9 +286,8 @@ cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
|
||||
error = crypto_newsession(&sid, (txform ? &crie : &cria),
|
||||
crypto_devallowsoft);
|
||||
if (error) {
|
||||
#ifdef CRYPTO_DEBUG
|
||||
printf("SIOCSESSION violates kernel parameters\n");
|
||||
#endif
|
||||
DPRINTF(("SIOCSESSION violates kernel parameters %d\n",
|
||||
error));
|
||||
goto bail;
|
||||
}
|
||||
|
||||
@ -282,6 +296,7 @@ cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
|
||||
thash);
|
||||
|
||||
if (cse == NULL) {
|
||||
DPRINTF(("csecreate failed\n"));
|
||||
crypto_freesession(sid);
|
||||
error = EINVAL;
|
||||
goto bail;
|
||||
@ -307,8 +322,10 @@ bail:
|
||||
case CIOCCRYPT:
|
||||
cop = (struct crypt_op *)data;
|
||||
cse = csefind(fcr, cop->ses);
|
||||
if (cse == NULL)
|
||||
if (cse == NULL) {
|
||||
DPRINTF(("csefind failed\n"));
|
||||
return (EINVAL);
|
||||
}
|
||||
error = cryptodev_op(cse, cop, l);
|
||||
break;
|
||||
case CIOCKEY:
|
||||
@ -318,6 +335,7 @@ bail:
|
||||
error = crypto_getfeat((int *)data);
|
||||
break;
|
||||
default:
|
||||
DPRINTF(("invalid ioctl cmd %ld\n", cmd));
|
||||
error = EINVAL;
|
||||
}
|
||||
return (error);
|
||||
|
Loading…
Reference in New Issue
Block a user