@@ -1254,7 +1254,7 @@ static int ExportOptions(WOLFSSL* ssl, byte* exp, word32 len, byte ver,
12541254 exp[idx++] = 0;
12551255#endif
12561256#ifdef HAVE_ANON
1257- exp[idx++] = options->haveAnon ;
1257+ exp[idx++] = options->useAnon ;
12581258#else
12591259 exp[idx++] = 0;
12601260#endif
@@ -1459,7 +1459,7 @@ static int ImportOptions(WOLFSSL* ssl, const byte* exp, word32 len, byte ver,
14591459 idx++;
14601460#endif
14611461#ifdef HAVE_ANON
1462- options->haveAnon = exp[idx++]; /* User wants to allow Anon suites */
1462+ options->useAnon = exp[idx++]; /* User wants to allow Anon suites */
14631463#else
14641464 idx++;
14651465#endif
@@ -6409,7 +6409,7 @@ void InitSSL_CTX_Suites(WOLFSSL_CTX* ctx)
64096409 havePSK = ctx->havePSK;
64106410#endif /* NO_PSK */
64116411#ifdef HAVE_ANON
6412- haveAnon = ctx->haveAnon ;
6412+ haveAnon = ctx->useAnon ;
64136413#endif /* HAVE_ANON*/
64146414#ifndef NO_CERTS
64156415 keySz = ctx->privateKeySz;
@@ -6442,7 +6442,7 @@ int InitSSL_Suites(WOLFSSL* ssl)
64426442#endif /* NO_PSK */
64436443#if !defined(NO_CERTS) && !defined(WOLFSSL_SESSION_EXPORT)
64446444#ifdef HAVE_ANON
6445- haveAnon = (byte)ssl->options.haveAnon ;
6445+ haveAnon = (byte)ssl->options.useAnon ;
64466446#endif /* HAVE_ANON*/
64476447#ifdef WOLFSSL_MULTICAST
64486448 haveMcast = (byte)ssl->options.haveMcast;
@@ -6472,7 +6472,7 @@ int InitSSL_Suites(WOLFSSL* ssl)
64726472 havePSK, ssl->options.haveDH, ssl->options.haveECDSAsig,
64736473 ssl->options.haveECC, ssl->options.haveStaticECC,
64746474 ssl->options.haveFalconSig, ssl->options.haveDilithiumSig,
6475- ssl->options.haveAnon , ssl->options.side);
6475+ ssl->options.useAnon , ssl->options.side);
64766476 }
64776477
64786478#if !defined(NO_CERTS) && !defined(WOLFSSL_SESSION_EXPORT)
@@ -6692,7 +6692,7 @@ int SetSSL_CTX(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
66926692#endif
66936693
66946694#ifdef HAVE_ANON
6695- ssl->options.haveAnon = ctx->haveAnon ;
6695+ ssl->options.useAnon = ctx->useAnon ;
66966696#endif
66976697#ifndef NO_DH
66986698 ssl->options.minDhKeySz = ctx->minDhKeySz;
@@ -26198,7 +26198,8 @@ ciphersuites introduced through the "bulk" ciphersuites.
2619826198
2619926199@return true on success, else false.
2620026200*/
26201- int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
26201+ static int ParseCipherList(Suites* suites,
26202+ const char* list, ProtocolVersion version, int privateKeySz, byte side)
2620226203{
2620326204 int ret = 0;
2620426205 int idx = 0;
@@ -26227,14 +26228,14 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
2622726228#ifndef NO_RSA
2622826229 haveRSA = 1;
2622926230#endif
26230- InitSuites(suites, ctx->method-> version,
26231+ InitSuites(suites, version,
2623126232#ifndef NO_CERTS
26232- ctx-> privateKeySz,
26233+ privateKeySz,
2623326234#else
2623426235 0,
2623526236#endif
2623626237 haveRSA, 1, 1, !haveRSA, 1, haveRSA, !haveRSA, 1, 1, 0, 0,
26237- ctx->method-> side);
26238+ side);
2623826239 return 1; /* wolfSSL default */
2623926240 }
2624026241
@@ -26311,9 +26312,6 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
2631126312 haveSig |= SIG_ANON;
2631226313 else
2631326314 haveSig &= ~SIG_ANON;
26314- #ifdef HAVE_ANON
26315- ctx->haveAnon = (haveSig & SIG_ANON) == SIG_ANON;
26316- #endif
2631726315 haveRSA = 1;
2631826316 haveDH = 1;
2631926317 haveECC = 1;
@@ -26336,9 +26334,6 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
2633626334 if (XSTRCMP(name, "HIGH") == 0 && allowing) {
2633726335 /* Disable static, anonymous, and null ciphers */
2633826336 haveSig &= ~SIG_ANON;
26339- #ifdef HAVE_ANON
26340- ctx->haveAnon = 0;
26341- #endif
2634226337 haveRSA = 1;
2634326338 haveDH = 1;
2634426339 haveECC = 1;
@@ -26358,9 +26353,6 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
2635826353 haveSig |= SIG_ANON;
2635926354 else
2636026355 haveSig &= ~SIG_ANON;
26361- #ifdef HAVE_ANON
26362- ctx->haveAnon = allowing;
26363- #endif
2636426356 if (allowing) {
2636526357 /* Allow RSA by default. */
2636626358 if (!haveECC)
@@ -26474,7 +26466,7 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
2647426466
2647526467 #ifdef WOLFSSL_DTLS
2647626468 /* don't allow stream ciphers with DTLS */
26477- if (ctx->method-> version.major == DTLS_MAJOR) {
26469+ if (version.major == DTLS_MAJOR) {
2647826470 if (XSTRSTR(name, "RC4"))
2647926471 {
2648026472 WOLFSSL_MSG("Stream ciphers not supported with DTLS");
@@ -26591,22 +26583,22 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
2659126583 if (ret) {
2659226584 int keySz = 0;
2659326585 #ifndef NO_CERTS
26594- keySz = ctx-> privateKeySz;
26586+ keySz = privateKeySz;
2659526587 #endif
2659626588 #ifdef OPENSSL_EXTRA
2659726589 if (callInitSuites) {
2659826590 suites->setSuites = 0; /* Force InitSuites */
2659926591 suites->hashSigAlgoSz = 0; /* Force InitSuitesHashSigAlgo call
2660026592 * inside InitSuites */
26601- InitSuites(suites, ctx->method-> version, keySz, (word16)haveRSA,
26593+ InitSuites(suites, version, keySz, (word16)haveRSA,
2660226594 (word16)havePSK, (word16)haveDH,
2660326595 (word16)((haveSig & SIG_ECDSA) != 0),
2660426596 (word16)haveECC, (word16)haveStaticRSA,
2660526597 (word16)haveStaticECC,
2660626598 (word16)((haveSig & SIG_FALCON) != 0),
2660726599 (word16)((haveSig & SIG_DILITHIUM) != 0),
2660826600 (word16)((haveSig & SIG_ANON) != 0),
26609- (word16)haveNull, ctx->method-> side);
26601+ (word16)haveNull, side);
2661026602 /* Restore user ciphers ahead of defaults */
2661126603 XMEMMOVE(suites->suites + idx, suites->suites,
2661226604 min(suites->suiteSz, WOLFSSL_MAX_SUITE_SZ-idx));
@@ -26621,7 +26613,7 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
2662126613 }
2662226614
2662326615#ifdef HAVE_RENEGOTIATION_INDICATION
26624- if (ctx->method-> side == WOLFSSL_CLIENT_END) {
26616+ if (side == WOLFSSL_CLIENT_END) {
2662526617 if (suites->suiteSz > WOLFSSL_MAX_SUITE_SZ - 2) {
2662626618 WOLFSSL_MSG("Too many ciphersuites");
2662726619 return 0;
@@ -26635,11 +26627,44 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
2663526627 suites->setSuites = 1;
2663626628 }
2663726629
26638- (void)ctx;
26639-
2664026630 return ret;
2664126631}
2664226632
26633+ int SetCipherList_ex(const WOLFSSL_CTX* ctx, const WOLFSSL* ssl,
26634+ Suites* suites, const char* list)
26635+ {
26636+ ProtocolVersion version;
26637+ int privateKeySz = 0;
26638+ byte side;
26639+
26640+ if (ctx != NULL) {
26641+ version = ctx->method->version;
26642+ #ifndef NO_CERTS
26643+ privateKeySz = ctx->privateKeySz;
26644+ #endif
26645+ side = ctx->method->side;
26646+ }
26647+ else if (ssl != NULL) {
26648+ version = ssl->version;
26649+ #ifndef NO_CERTS
26650+ privateKeySz = ssl->buffers.keySz;
26651+ #endif
26652+ side = (byte)ssl->options.side;
26653+ }
26654+ else {
26655+ WOLFSSL_MSG("SetCipherList_ex parameter error");
26656+ return 0;
26657+ }
26658+
26659+ return ParseCipherList(suites, list, version, privateKeySz, side);
26660+ }
26661+
26662+ int SetCipherList(const WOLFSSL_CTX* ctx, Suites* suites,
26663+ const char* list)
26664+ {
26665+ return SetCipherList_ex(ctx, NULL, suites, list);
26666+ }
26667+
2664326668#if defined(OPENSSL_EXTRA) || defined(WOLFSSL_SET_CIPHER_BYTES)
2664426669int SetCipherListFromBytes(WOLFSSL_CTX* ctx, Suites* suites, const byte* list,
2664526670 const int listSz)
@@ -35323,7 +35348,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3532335348 ssl->options.haveDH, ssl->options.haveECDSAsig,
3532435349 ssl->options.haveECC, TRUE, ssl->options.haveStaticECC,
3532535350 ssl->options.haveFalconSig,
35326- ssl->options.haveDilithiumSig, ssl->options.haveAnon ,
35351+ ssl->options.haveDilithiumSig, ssl->options.useAnon ,
3532735352 TRUE, ssl->options.side);
3532835353 }
3532935354
@@ -35714,7 +35739,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3571435739 ssl->options.haveDH, ssl->options.haveECDSAsig,
3571535740 ssl->options.haveECC, TRUE, ssl->options.haveStaticECC,
3571635741 ssl->options.haveFalconSig,
35717- ssl->options.haveDilithiumSig, ssl->options.haveAnon ,
35742+ ssl->options.haveDilithiumSig, ssl->options.useAnon ,
3571835743 TRUE, ssl->options.side);
3571935744 }
3572035745
@@ -35792,7 +35817,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3579235817 ssl->options.haveDH, ssl->options.haveECDSAsig,
3579335818 ssl->options.haveECC, TRUE, ssl->options.haveStaticECC,
3579435819 ssl->options.haveFalconSig,
35795- ssl->options.haveDilithiumSig, ssl->options.haveAnon ,
35820+ ssl->options.haveDilithiumSig, ssl->options.useAnon ,
3579635821 TRUE, ssl->options.side);
3579735822 }
3579835823 }
0 commit comments