chacha20: Properly reinitialize the cipher context with NULL key
[openssl.git] / providers / implementations / ciphers / cipher_chacha20_poly1305_hw.c
index 65f0fe1ee88016febfac484c1b92a80d1ca9cb7d..55a57de7264f1bde1e00099a69385eb2215308c4 100644 (file)
@@ -79,6 +79,12 @@ static int chacha20_poly1305_initiv(PROV_CIPHER_CTX *bctx)
     unsigned char tempiv[CHACHA_CTR_SIZE] = { 0 };
     int ret = 1;
 
+    ctx->len.aad = 0;
+    ctx->len.text = 0;
+    ctx->aad = 0;
+    ctx->mac_inited = 0;
+    ctx->tls_payload_length = NO_TLS_PAYLOAD_LENGTH;
+
         /* pad on the left */
     if (ctx->nonce_len <= CHACHA_CTR_SIZE) {
             memcpy(tempiv + CHACHA_CTR_SIZE - ctx->nonce_len, bctx->oiv,