]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
nettle/mac: in mac_fast call set_nonce after set_key
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Thu, 27 Jun 2019 21:27:04 +0000 (00:27 +0300)
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Fri, 28 Jun 2019 13:45:21 +0000 (16:45 +0300)
Calling set_nonce before set_key is plain incorrect. For GMAC key is not
initialized. For UMAC set_key will reset nonce to empty.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
lib/nettle/mac.c

index 64fa7e4925973eece2a9130ebcc4b2b9ca30b237..6b688add33fe37aaa75ad09fcb313552e6134777 100644 (file)
@@ -391,9 +391,9 @@ static int wrap_nettle_mac_fast(gnutls_mac_algorithm_t algo,
        if (ret < 0)
                return gnutls_assert_val(ret);
 
+       ctx.set_key(&ctx, key_size, key);
        if (ctx.set_nonce)
                ctx.set_nonce(&ctx, nonce_size, nonce);
-       ctx.set_key(&ctx, key_size, key);
        ctx.update(&ctx, text_size, text);
        ctx.digest(&ctx, ctx.length, digest);