Merge pull request #4486 from dgarske/set_secret

This commit is contained in:
John Safranek
2021-10-20 10:54:13 -07:00
committed by GitHub
2 changed files with 14 additions and 0 deletions

View File

@ -3504,6 +3504,10 @@ static int MakeSslMasterSecret(WOLFSSL* ssl)
wc_Sha sha[1];
#endif
if (ssl->arrays->preMasterSecret == NULL) {
return BAD_FUNC_ARG;
}
#ifdef SHOW_SECRETS
{
word32 j;

View File

@ -1360,8 +1360,18 @@ int wolfSSL_set_secret(WOLFSSL* ssl, word16 epoch,
ret = BAD_FUNC_ARG;
}
if (ret == 0 && ssl->arrays->preMasterSecret == NULL) {
ssl->arrays->preMasterSz = ENCRYPT_LEN;
ssl->arrays->preMasterSecret = (byte*)XMALLOC(ENCRYPT_LEN, ssl->heap,
DYNAMIC_TYPE_SECRET);
if (ssl->arrays->preMasterSecret == NULL) {
ret = MEMORY_E;
}
}
if (ret == 0) {
XMEMCPY(ssl->arrays->preMasterSecret, preMasterSecret, preMasterSz);
XMEMSET(ssl->arrays->preMasterSecret + preMasterSz, 0, ENCRYPT_LEN - preMasterSz);
ssl->arrays->preMasterSz = preMasterSz;
XMEMCPY(ssl->arrays->clientRandom, clientRandom, RAN_LEN);
XMEMCPY(ssl->arrays->serverRandom, serverRandom, RAN_LEN);