From 83e85a9d8209d409134bdc6073b6522eadcc6f84 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 11 May 2008 14:14:15 +0300 Subject: hash_deinit can now handle a NULL digest value. --- lib/gnutls_hash_int.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/gnutls_hash_int.c b/lib/gnutls_hash_int.c index 49bcdf8715..570e457405 100644 --- a/lib/gnutls_hash_int.c +++ b/lib/gnutls_hash_int.c @@ -138,14 +138,18 @@ _gnutls_hash_deinit (digest_hd_st* handle, void *digest) maclen = _gnutls_hash_get_algo_len (handle->algorithm); - if (handle->registered && handle->hd.rh.ctx != NULL) { - handle->hd.rh.cc->output( handle->hd.rh.ctx, digest, maclen); - handle->hd.rh.cc->deinit( handle->hd.rh.ctx); - return; - } + if (handle->registered && handle->hd.rh.ctx != NULL) + { + handle->hd.rh.cc->output( handle->hd.rh.ctx, digest, maclen); + handle->hd.rh.cc->deinit( handle->hd.rh.ctx); + return; + } - _gnutls_digest_ops.output( handle->hd.gc, digest, maclen); - _gnutls_digest_ops.deinit( handle->hd.gc); + if (digest != NULL) + { + _gnutls_digest_ops.output( handle->hd.gc, digest, maclen); + } + _gnutls_digest_ops.deinit( handle->hd.gc); } /* HMAC interface */ @@ -221,13 +225,17 @@ _gnutls_hmac_deinit (digest_hd_st* handle, void *digest) maclen = _gnutls_hmac_get_algo_len (handle->algorithm); - if (handle->registered && handle->hd.rh.ctx != NULL) { - handle->hd.rh.cc->output( handle->hd.rh.ctx, digest, maclen); - handle->hd.rh.cc->deinit( handle->hd.rh.ctx); - return; - } + if (handle->registered && handle->hd.rh.ctx != NULL) + { + handle->hd.rh.cc->output( handle->hd.rh.ctx, digest, maclen); + handle->hd.rh.cc->deinit( handle->hd.rh.ctx); + return; + } - _gnutls_mac_ops.output( handle->hd.gc, digest, maclen); + if (digest != NULL) + { + _gnutls_mac_ops.output( handle->hd.gc, digest, maclen); + } _gnutls_mac_ops.deinit( handle->hd.gc); } -- cgit v1.2.1