From: Nikos Mavrogiannopoulos Date: Fri, 26 Apr 2013 21:37:07 +0000 (+0300) Subject: Do not handle MAC reset separately. It is implied by nettle's output function. X-Git-Tag: gnutls_3_2_0~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f0ecbf401b4a764ecb0f1e77e1cffccc441f8ba;p=thirdparty%2Fgnutls.git Do not handle MAC reset separately. It is implied by nettle's output function. --- diff --git a/lib/accelerated/x86/hmac-padlock.c b/lib/accelerated/x86/hmac-padlock.c index d8057eb291..5da3571f38 100644 --- a/lib/accelerated/x86/hmac-padlock.c +++ b/lib/accelerated/x86/hmac-padlock.c @@ -54,17 +54,6 @@ struct padlock_hmac_ctx struct hmac_sha1_ctx sha1; } ctx; - /* this is the context just after - * the set_key. Used in reset(). - */ - union - { - struct hmac_sha224_ctx sha224; - struct hmac_sha256_ctx sha256; - struct hmac_sha384_ctx sha384; - struct hmac_sha512_ctx sha512; - struct hmac_sha1_ctx sha1; - } init_ctx; void *ctx_ptr; gnutls_mac_algorithm_t algo; size_t length; @@ -244,19 +233,9 @@ wrap_padlock_hmac_setkey (void *_ctx, const void *key, size_t keylen) ctx->setkey (ctx->ctx_ptr, keylen, key); - memcpy (&ctx->init_ctx, &ctx->ctx, sizeof (ctx->ctx)); - return GNUTLS_E_SUCCESS; } -static void -wrap_padlock_hmac_reset (void *_ctx) -{ - struct padlock_hmac_ctx *ctx = _ctx; - - memcpy (&ctx->ctx, &ctx->init_ctx, sizeof (ctx->ctx)); -} - static int wrap_padlock_hmac_update (void *_ctx, const void *text, size_t textsize) { @@ -357,7 +336,6 @@ const gnutls_crypto_mac_st hmac_sha_padlock_struct = { .setkey = NULL, .setnonce = NULL, .hash = NULL, - .reset = NULL, .output = NULL, .deinit = NULL, .fast = wrap_padlock_hmac_fast @@ -368,7 +346,6 @@ const gnutls_crypto_mac_st hmac_sha_padlock_nano_struct = { .setkey = wrap_padlock_hmac_setkey, .setnonce = NULL, .hash = wrap_padlock_hmac_update, - .reset = wrap_padlock_hmac_reset, .output = wrap_padlock_hmac_output, .deinit = wrap_padlock_hmac_deinit, .fast = wrap_padlock_hmac_fast, diff --git a/lib/crypto-backend.h b/lib/crypto-backend.h index 955e4bd1e8..eba691badb 100644 --- a/lib/crypto-backend.h +++ b/lib/crypto-backend.h @@ -52,7 +52,6 @@ int (*init) (gnutls_mac_algorithm_t, void **ctx); int (*setkey) (void *ctx, const void *key, size_t keysize); int (*setnonce) (void *ctx, const void *nonce, size_t noncesize); - void (*reset) (void *ctx); int (*hash) (void *ctx, const void *text, size_t textsize); int (*output) (void *src_ctx, void *digest, size_t digestsize); void (*deinit) (void *ctx); diff --git a/lib/gnutls_cipher_int.c b/lib/gnutls_cipher_int.c index 0744aea4e3..d56bf0a4ff 100644 --- a/lib/gnutls_cipher_int.c +++ b/lib/gnutls_cipher_int.c @@ -283,7 +283,6 @@ int ret; else { _gnutls_mac_output (&handle->mac.mac, tag); - _gnutls_mac_reset (&handle->mac.mac); } } else if (_gnutls_cipher_is_aead(&handle->cipher)) diff --git a/lib/gnutls_hash_int.c b/lib/gnutls_hash_int.c index 439b91c647..2621ec4256 100644 --- a/lib/gnutls_hash_int.c +++ b/lib/gnutls_hash_int.c @@ -232,7 +232,6 @@ _gnutls_mac_init (mac_hd_st * mac, gnutls_mac_algorithm_t algorithm, mac->setnonce = cc->setnonce; mac->output = cc->output; mac->deinit = cc->deinit; - mac->reset = cc->reset; return 0; } @@ -248,7 +247,6 @@ _gnutls_mac_init (mac_hd_st * mac, gnutls_mac_algorithm_t algorithm, mac->setnonce = _gnutls_mac_ops.setnonce; mac->output = _gnutls_mac_ops.output; mac->deinit = _gnutls_mac_ops.deinit; - mac->reset = _gnutls_mac_ops.reset; if (_gnutls_mac_ops.setkey (mac->handle, key, keylen) < 0) { diff --git a/lib/gnutls_hash_int.h b/lib/gnutls_hash_int.h index cb0de13d22..c83c01d87e 100644 --- a/lib/gnutls_hash_int.h +++ b/lib/gnutls_hash_int.h @@ -62,7 +62,6 @@ typedef struct int mac_len; hash_func hash; - reset_func reset; nonce_func setnonce; output_func output; deinit_func deinit; @@ -111,18 +110,6 @@ _gnutls_mac_set_nonce (mac_hd_st * handle, const void *nonce, size_t n_size) void _gnutls_mac_deinit (mac_hd_st * handle, void *digest); -inline static void -_gnutls_mac_reset (mac_hd_st * handle) -{ - if (handle->handle == NULL) - { - return; - } - - handle->reset (handle->handle); -} - - /* Hash interface */ int _gnutls_hash_init (digest_hd_st *, gnutls_digest_algorithm_t algorithm); diff --git a/lib/nettle/mac.c b/lib/nettle/mac.c index 6a52e5917c..9e95c2a1ad 100644 --- a/lib/nettle/mac.c +++ b/lib/nettle/mac.c @@ -71,19 +71,6 @@ struct nettle_mac_ctx struct umac96_ctx umac; } ctx; - /* this is the context just after - * the set_key. Used in reset(). - */ - union - { - struct hmac_md5_ctx md5; - struct hmac_sha224_ctx sha224; - struct hmac_sha256_ctx sha256; - struct hmac_sha384_ctx sha384; - struct hmac_sha512_ctx sha512; - struct hmac_sha1_ctx sha1; - struct umac96_ctx umac; - } init_ctx; void *ctx_ptr; gnutls_mac_algorithm_t algo; size_t length; @@ -235,8 +222,6 @@ wrap_nettle_mac_set_key (void *_ctx, const void *key, size_t keylen) ctx->set_key (ctx->ctx_ptr, keylen, key); - memcpy(&ctx->init_ctx, &ctx->ctx, sizeof(ctx->ctx)); - return GNUTLS_E_SUCCESS; } @@ -253,14 +238,6 @@ wrap_nettle_mac_set_nonce (void *_ctx, const void *nonce, size_t noncelen) return GNUTLS_E_SUCCESS; } -static void -wrap_nettle_mac_reset (void *_ctx) -{ - struct nettle_mac_ctx *ctx = _ctx; - - memcpy(&ctx->ctx, &ctx->init_ctx, sizeof(ctx->ctx)); -} - static int wrap_nettle_mac_update (void *_ctx, const void *text, size_t textsize) { @@ -466,7 +443,6 @@ gnutls_crypto_mac_st _gnutls_mac_ops = { .setkey = wrap_nettle_mac_set_key, .setnonce = wrap_nettle_mac_set_nonce, .hash = wrap_nettle_mac_update, - .reset = wrap_nettle_mac_reset, .output = wrap_nettle_mac_output, .deinit = wrap_nettle_mac_deinit, .fast = wrap_nettle_mac_fast,