summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-03-07 23:34:50 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-03-07 23:34:50 +0100
commitcdcb458991053a9a972ddf2f9e2cd3fca3c96dd6 (patch)
treef425691591b42d1708c1fb9c9b777b6162f35f4a
parent1393e95e3f5534b84fa016fdd1992b1e381a18bf (diff)
downloadgnutls-cdcb458991053a9a972ddf2f9e2cd3fca3c96dd6.tar.gz
when using cryptodev do not set all the digest function since they are not always faster.
-rw-r--r--lib/accelerated/cryptodev.c149
1 files changed, 11 insertions, 138 deletions
diff --git a/lib/accelerated/cryptodev.c b/lib/accelerated/cryptodev.c
index 5117f7962f..7d1eacc2f8 100644
--- a/lib/accelerated/cryptodev.c
+++ b/lib/accelerated/cryptodev.c
@@ -312,98 +312,6 @@ static const int gnutls_mac_map[] = {
};
static int
-cryptodev_mac_init (gnutls_mac_algorithm_t algorithm, void **_ctx)
-{
- struct cryptodev_ctx *ctx;
- int mac = gnutls_mac_map[algorithm];
-
- *_ctx = gnutls_calloc (1, sizeof (struct cryptodev_ctx));
- if (*_ctx == NULL)
- {
- gnutls_assert ();
- return GNUTLS_E_MEMORY_ERROR;
- }
-
- ctx = *_ctx;
-
- ctx->cfd = _gnutls_cryptodev_fd;
-
- ctx->sess.mac = mac;
-
- return 0;
-}
-
-static int
-cryptodev_mac_setkey (void *_ctx, const void *key, size_t keysize)
-{
- struct cryptodev_ctx *ctx = _ctx;
-
- ctx->sess.mackeylen = keysize;
- ctx->sess.mackey = (void*)key;
-
- if (ioctl (ctx->cfd, CIOCGSESSION, &ctx->sess))
- {
- gnutls_assert ();
- return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
- }
- ctx->cryp.ses = ctx->sess.ses;
-
- return 0;
-}
-
-static int
-cryptodev_mac_hash (void *_ctx, const void *text, size_t textsize)
-{
- struct cryptodev_ctx *ctx = _ctx;
-
- ctx->cryp.len = textsize;
- ctx->cryp.src = (void *) text;
- 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))
- {
- gnutls_assert ();
- return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
- }
- return 0;
-}
-
-static int
-cryptodev_mac_output (void *_ctx, void *digest, size_t digestsize)
-{
- struct cryptodev_ctx *ctx = _ctx;
-
- ctx->cryp.len = 0;
- ctx->cryp.src = NULL;
- ctx->cryp.mac = digest;
- ctx->cryp.op = COP_ENCRYPT;
- ctx->cryp.flags = COP_FLAG_FINAL;
-
- if (ioctl (ctx->cfd, CIOCCRYPT, &ctx->cryp))
- {
- gnutls_assert ();
- return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
- }
-
- return 0;
-}
-
-static void
-cryptodev_mac_reset (void *_ctx)
-{
- struct cryptodev_ctx *ctx = _ctx;
-
- ctx->reset = 1;
-}
-
-static int
cryptodev_mac_fast (gnutls_mac_algorithm_t algo,
const void *key, size_t key_size, const void *text,
size_t text_size, void *digest)
@@ -441,12 +349,12 @@ int ret;
#define cryptodev_mac_deinit cryptodev_deinit
static const gnutls_crypto_mac_st mac_struct = {
- .init = cryptodev_mac_init,
- .setkey = cryptodev_mac_setkey,
- .hash = cryptodev_mac_hash,
- .output = cryptodev_mac_output,
- .deinit = cryptodev_mac_deinit,
- .reset = cryptodev_mac_reset,
+ .init = NULL,
+ .setkey = NULL,
+ .hash = NULL,
+ .output = NULL,
+ .deinit = NULL,
+ .reset = NULL,
.fast = cryptodev_mac_fast
};
@@ -461,39 +369,6 @@ static const int gnutls_digest_map[] = {
};
static int
-cryptodev_digest_init (gnutls_digest_algorithm_t algorithm, void **_ctx)
-{
- struct cryptodev_ctx *ctx;
- int dig = gnutls_digest_map[algorithm];
-
- *_ctx = gnutls_calloc (1, sizeof (struct cryptodev_ctx));
- if (*_ctx == NULL)
- {
- gnutls_assert ();
- return GNUTLS_E_MEMORY_ERROR;
- }
-
- ctx = *_ctx;
-
- ctx->cfd = _gnutls_cryptodev_fd;
- ctx->sess.mac = dig;
-
- if (ioctl (ctx->cfd, CIOCGSESSION, &ctx->sess))
- {
- gnutls_assert ();
- gnutls_free(ctx);
- return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
- }
- ctx->cryp.ses = ctx->sess.ses;
-
- return 0;
-}
-
-#define cryptodev_digest_hash cryptodev_mac_hash
-#define cryptodev_digest_output cryptodev_mac_output
-#define cryptodev_digest_reset cryptodev_mac_reset
-
-static int
cryptodev_digest_fast (gnutls_digest_algorithm_t algo,
const void *text, size_t text_size,
void *digest)
@@ -525,14 +400,12 @@ int ret;
return 0;
}
-#define cryptodev_digest_deinit cryptodev_deinit
-
static const gnutls_crypto_digest_st digest_struct = {
- .init = cryptodev_digest_init,
- .hash = cryptodev_digest_hash,
- .output = cryptodev_digest_output,
- .deinit = cryptodev_digest_deinit,
- .reset = cryptodev_digest_reset,
+ .init = NULL,
+ .hash = NULL,
+ .output = NULL,
+ .deinit = NULL,
+ .reset = NULL,
.fast = cryptodev_digest_fast
};