diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-08-08 15:03:11 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2017-08-08 21:17:56 +0200 |
commit | e916bd0486ba616077ee7dbdf8da9ff2b8273777 (patch) | |
tree | ac020d961a64f035a5f76004ef7884c0ab1146db /lib | |
parent | 612f8e8de15685f025b9e80a6e84f4da125d48b7 (diff) | |
download | gnutls-e916bd0486ba616077ee7dbdf8da9ff2b8273777.tar.gz |
mac: simplified iteration functions
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/algorithms/mac.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/lib/algorithms/mac.c b/lib/algorithms/mac.c index 776e44c2be..becc753776 100644 --- a/lib/algorithms/mac.c +++ b/lib/algorithms/mac.c @@ -350,20 +350,16 @@ const gnutls_digest_algorithm_t *gnutls_digest_list(void) **/ gnutls_digest_algorithm_t gnutls_oid_to_digest(const char *oid) { - gnutls_digest_algorithm_t ret = 0; - GNUTLS_HASH_LOOP( if (p->oid && strcmp(oid, p->oid) == 0) { if (_gnutls_digest_exists((gnutls_digest_algorithm_t)p->id)) { - ret = (gnutls_digest_algorithm_t) p->id; + return (gnutls_digest_algorithm_t) p->id; } break; } ); - if (ret == 0) - return GNUTLS_DIG_UNKNOWN; - return ret; + return GNUTLS_DIG_UNKNOWN; } /** @@ -379,20 +375,16 @@ gnutls_digest_algorithm_t gnutls_oid_to_digest(const char *oid) **/ gnutls_mac_algorithm_t gnutls_oid_to_mac(const char *oid) { - gnutls_digest_algorithm_t ret = 0; - GNUTLS_HASH_LOOP( if (p->mac_oid && strcmp(oid, p->mac_oid) == 0) { if (_gnutls_mac_exists(p->id)) { - ret = p->id; + return p->id; } break; } ); - if (ret == 0) - return GNUTLS_MAC_UNKNOWN; - return ret; + return GNUTLS_MAC_UNKNOWN; } /** @@ -408,14 +400,11 @@ gnutls_mac_algorithm_t gnutls_oid_to_mac(const char *oid) **/ const char *gnutls_digest_get_oid(gnutls_digest_algorithm_t algorithm) { - const char *ret = NULL; - GNUTLS_HASH_LOOP( if (algorithm == (unsigned) p->id && p->oid != NULL) { - ret = p->oid; - break; + return p->oid; } ); - return ret; + return NULL; } |