mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Address code review
This commit is contained in:
committed by
David Garske
parent
0e662dea6e
commit
50cb3a7b8c
@ -2789,7 +2789,7 @@ static int GetMacDigestSize(byte macAlgo)
|
|||||||
out[*inOutIdx + 1] = minor; \
|
out[*inOutIdx + 1] = minor; \
|
||||||
} \
|
} \
|
||||||
*inOutIdx += 2; \
|
*inOutIdx += 2; \
|
||||||
} while(0)
|
} while (0)
|
||||||
|
|
||||||
static WC_INLINE void AddSuiteHashSigAlgo(byte* hashSigAlgo, byte macAlgo,
|
static WC_INLINE void AddSuiteHashSigAlgo(byte* hashSigAlgo, byte macAlgo,
|
||||||
byte sigAlgo, int keySz, word16* inOutIdx)
|
byte sigAlgo, int keySz, word16* inOutIdx)
|
||||||
@ -2864,9 +2864,19 @@ static WC_INLINE void AddSuiteHashSigAlgo(byte* hashSigAlgo, byte macAlgo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitSuitesHashSigAlgo(byte* hashSigAlgo, int haveECDSAsig, int haveRSAsig,
|
void InitSuitesHashSigAlgo(Suites* suites, int haveECDSAsig,
|
||||||
int haveFalconSig, int haveDilithiumSig,
|
int haveRSAsig, int haveFalconSig,
|
||||||
int haveAnon, int tls1_2, int keySz, word16* len)
|
int haveDilithiumSig, int haveAnon,
|
||||||
|
int tls1_2, int keySz)
|
||||||
|
{
|
||||||
|
InitSuitesHashSigAlgo_ex(suites->hashSigAlgo, haveECDSAsig, haveRSAsig,
|
||||||
|
haveFalconSig, haveDilithiumSig, haveAnon, tls1_2, keySz,
|
||||||
|
&suites->hashSigAlgoSz);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitSuitesHashSigAlgo_ex(byte* hashSigAlgo, int haveECDSAsig, int haveRSAsig,
|
||||||
|
int haveFalconSig, int haveDilithiumSig,
|
||||||
|
int haveAnon, int tls1_2, int keySz, word16* len)
|
||||||
{
|
{
|
||||||
word16 idx = 0;
|
word16 idx = 0;
|
||||||
|
|
||||||
@ -2986,7 +2996,7 @@ int AllocateSuites(WOLFSSL* ssl)
|
|||||||
DYNAMIC_TYPE_SUITES);
|
DYNAMIC_TYPE_SUITES);
|
||||||
if (ssl->suites == NULL) {
|
if (ssl->suites == NULL) {
|
||||||
WOLFSSL_MSG("Suites Memory error");
|
WOLFSSL_MSG("Suites Memory error");
|
||||||
return MEMORY_E;
|
return MEMORY_ERROR;
|
||||||
}
|
}
|
||||||
if (ssl->ctx != NULL && ssl->ctx->suites != NULL)
|
if (ssl->ctx != NULL && ssl->ctx->suites != NULL)
|
||||||
XMEMCPY(ssl->suites, ssl->ctx->suites, sizeof(Suites));
|
XMEMCPY(ssl->suites, ssl->ctx->suites, sizeof(Suites));
|
||||||
@ -3959,10 +3969,9 @@ void InitSuites(Suites* suites, ProtocolVersion pv, int keySz, word16 haveRSA,
|
|||||||
suites->suiteSz = idx;
|
suites->suiteSz = idx;
|
||||||
|
|
||||||
if (suites->hashSigAlgoSz == 0) {
|
if (suites->hashSigAlgoSz == 0) {
|
||||||
InitSuitesHashSigAlgo(suites->hashSigAlgo, haveECDSAsig | haveECC,
|
InitSuitesHashSigAlgo(suites, haveECDSAsig | haveECC,
|
||||||
haveRSAsig | haveRSA, haveFalconSig,
|
haveRSAsig | haveRSA, haveFalconSig,
|
||||||
haveDilithiumSig, 0, tls1_2, keySz,
|
haveDilithiumSig, 0, tls1_2, keySz);
|
||||||
&suites->hashSigAlgoSz);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24624,9 +24633,9 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
suites->suiteSz = (word16)idx;
|
suites->suiteSz = (word16)idx;
|
||||||
InitSuitesHashSigAlgo(suites->hashSigAlgo, haveECDSAsig, haveRSAsig,
|
InitSuitesHashSigAlgo(suites, haveECDSAsig, haveRSAsig,
|
||||||
haveFalconSig, haveDilithiumSig, haveAnon,
|
haveFalconSig, haveDilithiumSig, haveAnon,
|
||||||
1, keySz, &suites->hashSigAlgoSz);
|
1, keySz);
|
||||||
}
|
}
|
||||||
suites->setSuites = 1;
|
suites->setSuites = 1;
|
||||||
}
|
}
|
||||||
@ -24750,9 +24759,9 @@ int SetCipherListFromBytes(WOLFSSL_CTX* ctx, Suites* suites, const byte* list,
|
|||||||
keySz = ctx->privateKeySz;
|
keySz = ctx->privateKeySz;
|
||||||
#endif
|
#endif
|
||||||
suites->suiteSz = (word16)idx;
|
suites->suiteSz = (word16)idx;
|
||||||
InitSuitesHashSigAlgo(suites->hashSigAlgo, haveECDSAsig, haveRSAsig,
|
InitSuitesHashSigAlgo(suites, haveECDSAsig, haveRSAsig,
|
||||||
haveFalconSig, haveDilithiumSig, haveAnon, 1,
|
haveFalconSig, haveDilithiumSig, haveAnon, 1,
|
||||||
keySz, &suites->hashSigAlgoSz);
|
keySz);
|
||||||
suites->setSuites = 1;
|
suites->setSuites = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
src/ssl.c
24
src/ssl.c
@ -6998,15 +6998,15 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff,
|
|||||||
word16 havePSK = 0;
|
word16 havePSK = 0;
|
||||||
word16 haveRSA = 0;
|
word16 haveRSA = 0;
|
||||||
|
|
||||||
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
|
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
|
||||||
if (ssl->options.havePSK) {
|
if (ssl->options.havePSK) {
|
||||||
havePSK = 1;
|
havePSK = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_RSA
|
#ifndef NO_RSA
|
||||||
haveRSA = 1;
|
haveRSA = 1;
|
||||||
#endif
|
#endif
|
||||||
keySz = ssl->buffers.keySz;
|
keySz = ssl->buffers.keySz;
|
||||||
|
|
||||||
if (AllocateSuites(ssl) != 0)
|
if (AllocateSuites(ssl) != 0)
|
||||||
return WOLFSSL_FAILURE;
|
return WOLFSSL_FAILURE;
|
||||||
@ -7021,15 +7021,15 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff,
|
|||||||
word16 havePSK = 0;
|
word16 havePSK = 0;
|
||||||
word16 haveRSA = 0;
|
word16 haveRSA = 0;
|
||||||
|
|
||||||
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
|
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
|
||||||
if (ctx->havePSK) {
|
if (ctx->havePSK) {
|
||||||
havePSK = 1;
|
havePSK = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_RSA
|
#ifndef NO_RSA
|
||||||
haveRSA = 1;
|
haveRSA = 1;
|
||||||
#endif
|
#endif
|
||||||
keySz = ctx->privateKeySz;
|
keySz = ctx->privateKeySz;
|
||||||
|
|
||||||
if (AllocateCtxSuites(ctx) != 0)
|
if (AllocateCtxSuites(ctx) != 0)
|
||||||
return WOLFSSL_FAILURE;
|
return WOLFSSL_FAILURE;
|
||||||
|
@ -6632,13 +6632,13 @@ static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx,
|
|||||||
return SIDE_ERROR;
|
return SIDE_ERROR;
|
||||||
|
|
||||||
/* Get the length of the hashSigAlgo buffer */
|
/* Get the length of the hashSigAlgo buffer */
|
||||||
InitSuitesHashSigAlgo(NULL, 1, 1, 1, 1, 0, 1, ssl->buffers.keySz,
|
InitSuitesHashSigAlgo_ex(NULL, 1, 1, 1, 1, 0, 1, ssl->buffers.keySz,
|
||||||
&hashSigAlgoSz);
|
&hashSigAlgoSz);
|
||||||
sa = TLSX_SignatureAlgorithms_New(ssl, hashSigAlgoSz, ssl->heap);
|
sa = TLSX_SignatureAlgorithms_New(ssl, hashSigAlgoSz, ssl->heap);
|
||||||
if (sa == NULL)
|
if (sa == NULL)
|
||||||
return MEMORY_ERROR;
|
return MEMORY_ERROR;
|
||||||
InitSuitesHashSigAlgo(sa->hashSigAlgo, 1, 1, 1, 1, 0, 1, ssl->buffers.keySz,
|
InitSuitesHashSigAlgo_ex(sa->hashSigAlgo, 1, 1, 1, 1, 0, 1, ssl->buffers.keySz,
|
||||||
&sa->hashSigAlgoSz);
|
&sa->hashSigAlgoSz);
|
||||||
ret = TLSX_Push(&ssl->extensions, TLSX_SIGNATURE_ALGORITHMS, sa, ssl->heap);
|
ret = TLSX_Push(&ssl->extensions, TLSX_SIGNATURE_ALGORITHMS, sa, ssl->heap);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
TLSX_SignatureAlgorithms_FreeAll(sa, ssl->heap);
|
TLSX_SignatureAlgorithms_FreeAll(sa, ssl->heap);
|
||||||
|
@ -2121,10 +2121,14 @@ struct Suites {
|
|||||||
byte setSuites; /* user set suites from default */
|
byte setSuites; /* user set suites from default */
|
||||||
};
|
};
|
||||||
|
|
||||||
WOLFSSL_LOCAL void InitSuitesHashSigAlgo(byte* hashSigAlgo, int haveECDSAsig,
|
WOLFSSL_LOCAL void InitSuitesHashSigAlgo(Suites* suites, int haveECDSAsig,
|
||||||
int haveRSAsig, int haveFalconSig,
|
int haveRSAsig, int haveFalconSig,
|
||||||
int haveDilithiumSig, int haveAnon,
|
int haveDilithiumSig, int haveAnon,
|
||||||
int tls1_2, int keySz, word16* len);
|
int tls1_2, int keySz);
|
||||||
|
WOLFSSL_LOCAL void InitSuitesHashSigAlgo_ex(byte* hashSigAlgo, int haveECDSAsig,
|
||||||
|
int haveRSAsig, int haveFalconSig,
|
||||||
|
int haveDilithiumSig, int haveAnon,
|
||||||
|
int tls1_2, int keySz, word16* len);
|
||||||
WOLFSSL_LOCAL int AllocateCtxSuites(WOLFSSL_CTX* ctx);
|
WOLFSSL_LOCAL int AllocateCtxSuites(WOLFSSL_CTX* ctx);
|
||||||
WOLFSSL_LOCAL int AllocateSuites(WOLFSSL* ssl);
|
WOLFSSL_LOCAL int AllocateSuites(WOLFSSL* ssl);
|
||||||
WOLFSSL_LOCAL void InitSuites(Suites* suites, ProtocolVersion pv, int keySz,
|
WOLFSSL_LOCAL void InitSuites(Suites* suites, ProtocolVersion pv, int keySz,
|
||||||
|
Reference in New Issue
Block a user