]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
when using cryptodev do not set all the digest function since they are not always...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 7 Mar 2012 22:34:50 +0000 (23:34 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 7 Mar 2012 22:34:50 +0000 (23:34 +0100)
lib/accelerated/cryptodev.c

index 5117f7962f8654ad1c583108380309942631dbe1..7d1eacc2f8ffc09e1031a6684866ee56d83a976d 100644 (file)
@@ -311,98 +311,6 @@ static const int gnutls_mac_map[] = {
   [GNUTLS_MAC_SHA512] = CRYPTO_SHA2_512_HMAC,
 };
 
-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,
@@ -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
 };
 
@@ -460,39 +368,6 @@ static const int gnutls_digest_map[] = {
   [GNUTLS_DIG_SHA512] = CRYPTO_SHA2_512,
 };
 
-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, 
@@ -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
 };