poly1305: Properly copy the whole context on dup
authorTomas Mraz <tomas@openssl.org>
Thu, 21 Apr 2022 15:33:26 +0000 (17:33 +0200)
committerPauli <pauli@openssl.org>
Fri, 29 Apr 2022 00:00:39 +0000 (10:00 +1000)
Also reset the updated flag when Poly1305_Init is called.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18143)

(cherry picked from commit bbe909d00e9a593bd5954dfca4d3020467977565)

providers/implementations/macs/poly1305_prov.c

index ad67216d2a4b4be000636258c46a6174f125a97d..28789d25c81da521a739f5730d49de9bcd4cb2ea 100644 (file)
@@ -65,11 +65,11 @@ static void *poly1305_dup(void *vsrc)
 
     if (!ossl_prov_is_running())
         return NULL;
-    dst = poly1305_new(src->provctx);
+    dst = OPENSSL_malloc(sizeof(*dst));
     if (dst == NULL)
         return NULL;
 
-    dst->poly1305 = src->poly1305;
+    *dst = *src;
     return dst;
 }
 
@@ -86,6 +86,7 @@ static int poly1305_setkey(struct poly1305_data_st *ctx,
         return 0;
     }
     Poly1305_Init(&ctx->poly1305, key);
+    ctx->updated = 0;
     return 1;
 }