From: Nikos Mavrogiannopoulos Date: Mon, 20 Feb 2012 22:54:15 +0000 (+0100) Subject: added reset X-Git-Tag: gnutls_3_0_14~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b6980d07184cbb1315eec992c67adf94ecff3c54;p=thirdparty%2Fgnutls.git added reset --- diff --git a/lib/accelerated/cryptodev.c b/lib/accelerated/cryptodev.c index 3397614921..0069488ada 100644 --- a/lib/accelerated/cryptodev.c +++ b/lib/accelerated/cryptodev.c @@ -49,6 +49,7 @@ struct cryptodev_ctx struct session_op sess; struct crypt_op cryp; uint8_t iv[EALG_MAX_BLOCK_LEN]; + unsigned int hash_reset; int cfd; }; @@ -349,7 +350,14 @@ cryptodev_mac_hash (void *_ctx, const void *text, size_t textsize) ctx->cryp.src = (void *) text; ctx->cryp.dst = NULL; ctx->cryp.op = COP_ENCRYPT; - ctx->cryp.flags = COP_FLAG_UPDATE; + + if (ctx->hash_reset == 0) + ctx->cryp.flags = COP_FLAG_UPDATE; + else + { + ctx->cryp.flags = 0; + ctx->hash_reset = 0; + } if (ioctl (ctx->cfd, CIOCCRYPT, &ctx->cryp)) { gnutls_assert (); @@ -376,6 +384,14 @@ cryptodev_mac_output (void *_ctx, void *digest, size_t digestsize) return 0; } +static void +cryptodev_mac_reset (void *_ctx) +{ + struct cryptodev_ctx *ctx = _ctx; + + ctx->hash_reset = 1; +} + static int cryptodev_mac_fast (gnutls_mac_algorithm_t algo, const void *key, size_t key_size, const void *text, @@ -422,6 +438,7 @@ static const gnutls_crypto_mac_st mac_struct = { .hash = cryptodev_mac_hash, .output = cryptodev_mac_output, .deinit = cryptodev_mac_deinit, + .reset = cryptodev_mac_reset, .fast = cryptodev_mac_fast }; @@ -466,6 +483,7 @@ cryptodev_digest_init (gnutls_digest_algorithm_t algorithm, void **_ctx) #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, @@ -509,6 +527,7 @@ static const gnutls_crypto_digest_st digest_struct = { .hash = cryptodev_digest_hash, .output = cryptodev_digest_output, .deinit = cryptodev_digest_deinit, + .reset = cryptodev_digest_reset, .fast = cryptodev_digest_fast };