forked from wolfSSL/wolfssl
set ChaCha counter state for TLS 1.3 AEAD
This commit is contained in:
@ -1656,6 +1656,9 @@ static int ChaCha20Poly1305_Encrypt(WOLFSSL* ssl, byte* output,
|
|||||||
return ret;
|
return ret;
|
||||||
/* Create Poly1305 key using ChaCha20 keystream. */
|
/* Create Poly1305 key using ChaCha20 keystream. */
|
||||||
ret = wc_Chacha_Process(ssl->encrypt.chacha, poly, poly, sizeof(poly));
|
ret = wc_Chacha_Process(ssl->encrypt.chacha, poly, poly, sizeof(poly));
|
||||||
|
if (ret != 0)
|
||||||
|
return ret;
|
||||||
|
ret = wc_Chacha_SetIV(ssl->encrypt.chacha, nonce, 1);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
/* Encrypt the plain text. */
|
/* Encrypt the plain text. */
|
||||||
@ -1939,6 +1942,9 @@ static int ChaCha20Poly1305_Decrypt(WOLFSSL* ssl, byte* output,
|
|||||||
return ret;
|
return ret;
|
||||||
/* Use ChaCha20 keystream to get Poly1305 key for tag. */
|
/* Use ChaCha20 keystream to get Poly1305 key for tag. */
|
||||||
ret = wc_Chacha_Process(ssl->decrypt.chacha, poly, poly, sizeof(poly));
|
ret = wc_Chacha_Process(ssl->decrypt.chacha, poly, poly, sizeof(poly));
|
||||||
|
if (ret != 0)
|
||||||
|
return ret;
|
||||||
|
ret = wc_Chacha_SetIV(ssl->decrypt.chacha, nonce, 1);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user