Only cache messages when required.

This commit is contained in:
Sean Parkinson
2018-05-15 10:43:17 +10:00
parent 9358edf5dd
commit 982119b495

View File

@@ -6053,10 +6053,19 @@ static int Ed25519Update(WOLFSSL* ssl, const byte* data, int sz)
int ret = 0; int ret = 0;
byte* msgs; byte* msgs;
if (!IsAtLeastTLSv1_3(ssl->version) || ssl->options.downgrade) { if (!IsAtLeastTLSv1_2(ssl))
msgs = (byte*)XREALLOC(ssl->hsHashes->messages, return 0;
ssl->hsHashes->length + sz, ssl->heap, if (IsAtLeastTLSv1_3(ssl->version) && !ssl->options.downgrade)
DYNAMIC_TYPE_HASHES); return 0;
if (ssl->options.side == WOLFSSL_CLIENT_END &&
ssl->buffers.keyType != ed25519_sa_algo)
return 0;
if (ssl->options.side == WOLFSSL_SERVER_END && (ssl->options.resuming ||
!ssl->options.verifyPeer))
return 0;
msgs = (byte*)XREALLOC(ssl->hsHashes->messages, ssl->hsHashes->length + sz,
ssl->heap, DYNAMIC_TYPE_HASHES);
if (msgs == NULL) if (msgs == NULL)
ret = MEMORY_E; ret = MEMORY_E;
if (ret == 0) { if (ret == 0) {
@@ -6065,7 +6074,6 @@ static int Ed25519Update(WOLFSSL* ssl, const byte* data, int sz)
ssl->hsHashes->prevLen = ssl->hsHashes->length; ssl->hsHashes->prevLen = ssl->hsHashes->length;
ssl->hsHashes->length += sz; ssl->hsHashes->length += sz;
} }
}
return ret; return ret;
} }