aboutsummaryrefslogtreecommitdiff
path: root/sys/crypto
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2020-06-10 21:18:19 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2020-06-10 21:18:19 +0000
commit9b6b2f8608e24fc824404e2b47e2cecc669b189b (patch)
tree446581e71c4631f97bb44d4c5e0e64e115ba1d14 /sys/crypto
parentf14f00511365d3ba794389a1a5382f02ed669c47 (diff)
Notes
Diffstat (limited to 'sys/crypto')
-rw-r--r--sys/crypto/aesni/aesni.c4
-rw-r--r--sys/crypto/aesni/aesni.h2
-rw-r--r--sys/crypto/blake2/blake2-sw.c8
-rw-r--r--sys/crypto/blake2/blake2_cryptodev.c4
-rw-r--r--sys/crypto/via/padlock_hash.c46
5 files changed, 36 insertions, 28 deletions
diff --git a/sys/crypto/aesni/aesni.c b/sys/crypto/aesni/aesni.c
index 38be9b0acb68..eb41babefdd1 100644
--- a/sys/crypto/aesni/aesni.c
+++ b/sys/crypto/aesni/aesni.c
@@ -388,7 +388,7 @@ MODULE_VERSION(aesni, 1);
MODULE_DEPEND(aesni, crypto, 1, 1, 1);
static int
-intel_sha1_update(void *vctx, void *vdata, u_int datalen)
+intel_sha1_update(void *vctx, const void *vdata, u_int datalen)
{
struct sha1_ctxt *ctx = vctx;
const char *data = vdata;
@@ -437,7 +437,7 @@ SHA1_Finalize_fn(void *digest, void *ctx)
}
static int
-intel_sha256_update(void *vctx, void *vdata, u_int len)
+intel_sha256_update(void *vctx, const void *vdata, u_int len)
{
SHA256_CTX *ctx = vctx;
uint64_t bitlen;
diff --git a/sys/crypto/aesni/aesni.h b/sys/crypto/aesni/aesni.h
index 42b896661f5d..548f61f1bc22 100644
--- a/sys/crypto/aesni/aesni.h
+++ b/sys/crypto/aesni/aesni.h
@@ -63,7 +63,7 @@ struct aesni_session {
int mlen;
int hash_len;
void (*hash_init)(void *);
- int (*hash_update)(void *, void *, unsigned);
+ int (*hash_update)(void *, const void *, u_int);
void (*hash_finalize)(void *, void *);
bool hmac;
};
diff --git a/sys/crypto/blake2/blake2-sw.c b/sys/crypto/blake2/blake2-sw.c
index c25d4db50e29..b7291ac6ef46 100644
--- a/sys/crypto/blake2/blake2-sw.c
+++ b/sys/crypto/blake2/blake2-sw.c
@@ -49,7 +49,7 @@ blake2b_xform_init(void *vctx)
}
static void
-blake2b_xform_setkey(void *vctx, const uint8_t *key, uint16_t klen)
+blake2b_xform_setkey(void *vctx, const uint8_t *key, u_int klen)
{
struct blake2b_xform_ctx *ctx = vctx;
@@ -60,7 +60,7 @@ blake2b_xform_setkey(void *vctx, const uint8_t *key, uint16_t klen)
}
static int
-blake2b_xform_update(void *vctx, const uint8_t *data, uint16_t len)
+blake2b_xform_update(void *vctx, const void *data, u_int len)
{
struct blake2b_xform_ctx *ctx = vctx;
int rc;
@@ -117,7 +117,7 @@ blake2s_xform_init(void *vctx)
}
static void
-blake2s_xform_setkey(void *vctx, const uint8_t *key, uint16_t klen)
+blake2s_xform_setkey(void *vctx, const uint8_t *key, u_int klen)
{
struct blake2s_xform_ctx *ctx = vctx;
@@ -128,7 +128,7 @@ blake2s_xform_setkey(void *vctx, const uint8_t *key, uint16_t klen)
}
static int
-blake2s_xform_update(void *vctx, const uint8_t *data, uint16_t len)
+blake2s_xform_update(void *vctx, const void *data, u_int len)
{
struct blake2s_xform_ctx *ctx = vctx;
int rc;
diff --git a/sys/crypto/blake2/blake2_cryptodev.c b/sys/crypto/blake2/blake2_cryptodev.c
index 065f53734e54..c374be28ea10 100644
--- a/sys/crypto/blake2/blake2_cryptodev.c
+++ b/sys/crypto/blake2/blake2_cryptodev.c
@@ -304,7 +304,7 @@ blake2_cipher_setup(struct blake2_session *ses,
}
static int
-blake2b_applicator(void *state, void *buf, u_int len)
+blake2b_applicator(void *state, const void *buf, u_int len)
{
int rc;
@@ -315,7 +315,7 @@ blake2b_applicator(void *state, void *buf, u_int len)
}
static int
-blake2s_applicator(void *state, void *buf, u_int len)
+blake2s_applicator(void *state, const void *buf, u_int len)
{
int rc;
diff --git a/sys/crypto/via/padlock_hash.c b/sys/crypto/via/padlock_hash.c
index d68757856ab0..c1bfce6135dc 100644
--- a/sys/crypto/via/padlock_hash.c
+++ b/sys/crypto/via/padlock_hash.c
@@ -73,11 +73,10 @@ struct padlock_sha_ctx {
};
CTASSERT(sizeof(struct padlock_sha_ctx) <= sizeof(union authctx));
-static void padlock_sha_init(struct padlock_sha_ctx *ctx);
-static int padlock_sha_update(struct padlock_sha_ctx *ctx, const uint8_t *buf,
- uint16_t bufsize);
-static void padlock_sha1_final(uint8_t *hash, struct padlock_sha_ctx *ctx);
-static void padlock_sha256_final(uint8_t *hash, struct padlock_sha_ctx *ctx);
+static void padlock_sha_init(void *vctx);
+static int padlock_sha_update(void *vctx, const void *buf, u_int bufsize);
+static void padlock_sha1_final(uint8_t *hash, void *vctx);
+static void padlock_sha256_final(uint8_t *hash, void *vctx);
static struct auth_hash padlock_hmac_sha1 = {
.type = CRYPTO_SHA1_HMAC,
@@ -86,9 +85,9 @@ static struct auth_hash padlock_hmac_sha1 = {
.hashsize = SHA1_HASH_LEN,
.ctxsize = sizeof(struct padlock_sha_ctx),
.blocksize = SHA1_BLOCK_LEN,
- .Init = (void (*)(void *))padlock_sha_init,
- .Update = (int (*)(void *, const uint8_t *, uint16_t))padlock_sha_update,
- .Final = (void (*)(uint8_t *, void *))padlock_sha1_final,
+ .Init = padlock_sha_init,
+ .Update = padlock_sha_update,
+ .Final = padlock_sha1_final,
};
static struct auth_hash padlock_hmac_sha256 = {
@@ -98,9 +97,9 @@ static struct auth_hash padlock_hmac_sha256 = {
.hashsize = SHA2_256_HASH_LEN,
.ctxsize = sizeof(struct padlock_sha_ctx),
.blocksize = SHA2_256_BLOCK_LEN,
- .Init = (void (*)(void *))padlock_sha_init,
- .Update = (int (*)(void *, const uint8_t *, uint16_t))padlock_sha_update,
- .Final = (void (*)(uint8_t *, void *))padlock_sha256_final,
+ .Init = padlock_sha_init,
+ .Update = padlock_sha_update,
+ .Final = padlock_sha256_final,
};
MALLOC_DECLARE(M_PADLOCK);
@@ -165,18 +164,22 @@ padlock_do_sha256(const char *in, char *out, int count)
}
static void
-padlock_sha_init(struct padlock_sha_ctx *ctx)
+padlock_sha_init(void *vctx)
{
+ struct padlock_sha_ctx *ctx;
+ ctx = vctx;
ctx->psc_buf = NULL;
ctx->psc_offset = 0;
ctx->psc_size = 0;
}
static int
-padlock_sha_update(struct padlock_sha_ctx *ctx, const uint8_t *buf, uint16_t bufsize)
+padlock_sha_update(void *vctx, const void *buf, u_int bufsize)
{
+ struct padlock_sha_ctx *ctx;
+ ctx = vctx;
if (ctx->psc_size - ctx->psc_offset < bufsize) {
ctx->psc_size = MAX(ctx->psc_size * 2, ctx->psc_size + bufsize);
ctx->psc_buf = realloc(ctx->psc_buf, ctx->psc_size, M_PADLOCK,
@@ -190,9 +193,11 @@ padlock_sha_update(struct padlock_sha_ctx *ctx, const uint8_t *buf, uint16_t buf
}
static void
-padlock_sha_free(struct padlock_sha_ctx *ctx)
+padlock_sha_free(void *vctx)
{
+ struct padlock_sha_ctx *ctx;
+ ctx = vctx;
if (ctx->psc_buf != NULL) {
//bzero(ctx->psc_buf, ctx->psc_size);
free(ctx->psc_buf, M_PADLOCK);
@@ -203,17 +208,21 @@ padlock_sha_free(struct padlock_sha_ctx *ctx)
}
static void
-padlock_sha1_final(uint8_t *hash, struct padlock_sha_ctx *ctx)
+padlock_sha1_final(uint8_t *hash, void *vctx)
{
+ struct padlock_sha_ctx *ctx;
+ ctx = vctx;
padlock_do_sha1(ctx->psc_buf, hash, ctx->psc_offset);
padlock_sha_free(ctx);
}
static void
-padlock_sha256_final(uint8_t *hash, struct padlock_sha_ctx *ctx)
+padlock_sha256_final(uint8_t *hash, void *vctx)
{
+ struct padlock_sha_ctx *ctx;
+ ctx = vctx;
padlock_do_sha256(ctx->psc_buf, hash, ctx->psc_offset);
padlock_sha_free(ctx);
}
@@ -282,14 +291,13 @@ padlock_authcompute(struct padlock_session *ses, struct cryptop *crp)
padlock_copy_ctx(axf, ses->ses_ictx, &ctx);
error = crypto_apply(crp, crp->crp_aad_start, crp->crp_aad_length,
- (int (*)(void *, void *, unsigned int))axf->Update, (caddr_t)&ctx);
+ axf->Update, &ctx);
if (error != 0) {
padlock_free_ctx(axf, &ctx);
return (error);
}
error = crypto_apply(crp, crp->crp_payload_start,
- crp->crp_payload_length,
- (int (*)(void *, void *, unsigned int))axf->Update, (caddr_t)&ctx);
+ crp->crp_payload_length, axf->Update, &ctx);
if (error != 0) {
padlock_free_ctx(axf, &ctx);
return (error);