Merge pull request #203 from dgarske/SendServerHelloRNGCombine

Combined "wc_RNG_GenerateBlock" calls in "SendServerHello".
This commit is contained in:
toddouska
2015-12-03 11:16:00 -08:00

View File

@@ -12765,16 +12765,28 @@ int DoSessionTicket(WOLFSSL* ssl,
output[idx++] = ssl->version.major;
output[idx++] = ssl->version.minor;
/* then random */
/* then random and session id */
if (!ssl->options.resuming) {
ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->serverRandom,
RAN_LEN);
/* generate random part and session id */
ret = wc_RNG_GenerateBlock(ssl->rng, output + idx,
RAN_LEN + sizeof(sessIdSz) + sessIdSz);
if (ret != 0)
return ret;
}
/* store info in SSL context for later */
XMEMCPY(ssl->arrays->serverRandom, output + idx, RAN_LEN);
idx += RAN_LEN;
output[idx++] = sessIdSz;
XMEMCPY(ssl->arrays->sessionID, output + idx, sessIdSz);
}
else {
/* If resuming, use info from SSL context */
XMEMCPY(output + idx, ssl->arrays->serverRandom, RAN_LEN);
idx += RAN_LEN;
output[idx++] = sessIdSz;
XMEMCPY(output + idx, ssl->arrays->sessionID, sessIdSz);
}
idx += sessIdSz;
#ifdef SHOW_SECRETS
{
@@ -12785,19 +12797,6 @@ int DoSessionTicket(WOLFSSL* ssl,
printf("\n");
}
#endif
/* then session id */
output[idx++] = sessIdSz;
if (sessIdSz) {
if (!ssl->options.resuming) {
ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->sessionID,
sessIdSz);
if (ret != 0) return ret;
}
XMEMCPY(output + idx, ssl->arrays->sessionID, sessIdSz);
idx += sessIdSz;
}
/* then cipher suite */
output[idx++] = ssl->options.cipherSuite0;