summaryrefslogtreecommitdiff
path: root/lib/accelerated/cryptodev.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-02-26 15:33:32 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-02-26 15:35:08 +0100
commit66c7e7d87f4bbfc426b15e2c125a5ac25bbf5e59 (patch)
treec0099340dc6fa03ed0c847732d46547483ccef00 /lib/accelerated/cryptodev.c
parentdd3d82754187de0a54b1039dc1752a9b36c392fe (diff)
downloadgnutls-66c7e7d87f4bbfc426b15e2c125a5ac25bbf5e59.tar.gz
Updated cryptodev code.
Hash reset is being performed in a single ioctl() with update and TLS versions (<1.1) that do not have explicit IV are correctly handled.
Diffstat (limited to 'lib/accelerated/cryptodev.c')
-rw-r--r--lib/accelerated/cryptodev.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/lib/accelerated/cryptodev.c b/lib/accelerated/cryptodev.c
index 3974f69f84..6d8dd8609d 100644
--- a/lib/accelerated/cryptodev.c
+++ b/lib/accelerated/cryptodev.c
@@ -49,6 +49,8 @@ struct cryptodev_ctx
struct session_op sess;
struct crypt_op cryp;
uint8_t iv[EALG_MAX_BLOCK_LEN];
+ int reset;
+
int cfd;
};
@@ -113,38 +115,43 @@ cryptodev_setiv (void *_ctx, const void *iv, size_t iv_size)
}
static int
-cryptodev_encrypt (void *_ctx, const void *plain, size_t plainsize,
- void *encr, size_t encrsize)
+cryptodev_encrypt (void *_ctx, const void *src, size_t src_size,
+ void *dst, size_t dst_size)
{
struct cryptodev_ctx *ctx = _ctx;
- ctx->cryp.len = plainsize;
- ctx->cryp.src = (void *) plain;
- ctx->cryp.dst = encr;
+ ctx->cryp.len = src_size;
+ ctx->cryp.src = (void *) src;
+ ctx->cryp.dst = dst;
ctx->cryp.op = COP_ENCRYPT;
+ ctx->cryp.flags = COP_FLAG_WRITE_IV;
if (ioctl (ctx->cfd, CIOCCRYPT, &ctx->cryp))
{
gnutls_assert ();
return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
}
+
return 0;
}
static int
-cryptodev_decrypt (void *_ctx, const void *encr, size_t encrsize,
- void *plain, size_t plainsize)
+cryptodev_decrypt (void *_ctx, const void *src, size_t src_size,
+ void *dst, size_t dst_size)
{
struct cryptodev_ctx *ctx = _ctx;
- ctx->cryp.len = encrsize;
- ctx->cryp.src = (void *) encr;
- ctx->cryp.dst = plain;
+ ctx->cryp.len = src_size;
+ ctx->cryp.src = (void *) src;
+ ctx->cryp.dst = dst;
ctx->cryp.op = COP_DECRYPT;
+ ctx->cryp.flags = COP_FLAG_WRITE_IV;
+
if (ioctl (ctx->cfd, CIOCCRYPT, &ctx->cryp))
{
gnutls_assert ();
return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
}
+
return 0;
}
@@ -354,6 +361,11 @@ cryptodev_mac_hash (void *_ctx, const void *text, size_t textsize)
ctx->cryp.dst = NULL;
ctx->cryp.op = COP_ENCRYPT;
ctx->cryp.flags = COP_FLAG_UPDATE;
+ if (ctx->reset)
+ {
+ ctx->cryp.flags |= COP_FLAG_RESET;
+ ctx->reset = 0;
+ }
if (ioctl (ctx->cfd, CIOCCRYPT, &ctx->cryp))
{
@@ -388,13 +400,7 @@ cryptodev_mac_reset (void *_ctx)
{
struct cryptodev_ctx *ctx = _ctx;
- ctx->cryp.len = 0;
- ctx->cryp.src = NULL;
- ctx->cryp.dst = NULL;
- ctx->cryp.op = COP_ENCRYPT;
- ctx->cryp.flags = COP_FLAG_RESET;
-
- ioctl (ctx->cfd, CIOCCRYPT, &ctx->cryp);
+ ctx->reset = 1;
}
static int