Skip to content

Recalculate suites at ssl initialization. #8757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6920,13 +6920,35 @@ int SetSSL_CTX(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
/* If we are setting the ctx on an already initialized SSL object
* then we possibly already have a side defined. Don't overwrite unless
* the context has a well defined role. */
if (newSSL || ctx->method->side != WOLFSSL_NEITHER_END)
ssl->options.side = (word16)(ctx->method->side);
ssl->options.downgrade = (word16)(ctx->method->downgrade);
ssl->options.minDowngrade = ctx->minDowngrade;

if (newSSL || ctx->method->side != WOLFSSL_NEITHER_END) {
ssl->options.side = (word16)(ctx->method->side);
}
ssl->options.downgrade = (word16)(ctx->method->downgrade);
ssl->options.minDowngrade = ctx->minDowngrade;
ssl->options.haveRSA = ctx->haveRSA;
ssl->options.haveDH = ctx->haveDH;
#ifndef NO_CERTS
/* Its possible that algorithm parameters were set in the ctx (ie: DH),
* recalculate cipher suites. */
if (ssl->options.haveDH) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to test more stringently here for whether we need to recalculate? It would be nice to avoid the overhead if it's not needed.

if (ssl->suites == NULL) {
if (AllocateSuites(ssl) != 0) {
return MEMORY_E;
}
}
InitSuites(ssl->suites, ssl->version, ssl->buffers.keySz,
ssl->options.haveRSA,
#ifdef NO_PSK
0,
#else
ctx->havePSK,
#endif
ssl->options.haveDH,
ssl->options.haveECDSAsig, ssl->options.haveECC, TRUE,
ssl->options.haveStaticECC, ssl->options.useAnon,
TRUE, TRUE, TRUE, TRUE, ssl->options.side);
}
#endif /* ! NO_CERTS */
ssl->options.haveECDSAsig = ctx->haveECDSAsig;
ssl->options.haveECC = ctx->haveECC;
ssl->options.haveStaticECC = ctx->haveStaticECC;
Expand Down