Peer review fixes. Improve profile not found handling or errors. Improve inline function.

This commit is contained in:
David Garske
2022-01-17 15:52:40 -08:00
parent eade8ecdf1
commit f3f5b0f53b
3 changed files with 9 additions and 5 deletions

View File

@ -501,7 +501,7 @@ int IsDtlsNotSctpMode(WOLFSSL* ssl)
/* Secure Real-time Transport Protocol */ /* Secure Real-time Transport Protocol */
/* If SRTP is not enabled returns the state of the dtls option. /* If SRTP is not enabled returns the state of the dtls option.
* If SRTP is enabled returns dtls && !dtlsSrtpProfiles. */ * If SRTP is enabled returns dtls && !dtlsSrtpProfiles. */
int IsDtlsNotSrtpMode(WOLFSSL* ssl) static WC_INLINE int IsDtlsNotSrtpMode(WOLFSSL* ssl)
{ {
#ifdef WOLFSSL_SRTP #ifdef WOLFSSL_SRTP
return ssl->options.dtls && !ssl->dtlsSrtpProfiles; return ssl->options.dtls && !ssl->dtlsSrtpProfiles;

View File

@ -5430,7 +5430,10 @@ static int TLSX_UseSRTP_Parse(WOLFSSL* ssl, const byte* input, word16 length,
/* total length, not include itself */ /* total length, not include itself */
ato16(input, &profile_len); ato16(input, &profile_len);
offset += OPAQUE16_LEN; offset += OPAQUE16_LEN;
/* parse remainder one profile at a time, looking for match in CTX */ /* parse remainder one profile at a time, looking for match in CTX */
ret = 0;
ssl->dtlsSrtpId = 0;
for (i=offset; i<length; i+=OPAQUE16_LEN) { for (i=offset; i<length; i+=OPAQUE16_LEN) {
ato16(input+i, &profile_value); ato16(input+i, &profile_value);
/* find first match */ /* find first match */
@ -5456,13 +5459,15 @@ static int TLSX_UseSRTP_Parse(WOLFSSL* ssl, const byte* input, word16 length,
(void)profile_len; (void)profile_len;
} }
if (ret != 0) { if (ret == 0 && ssl->dtlsSrtpId == 0) {
WOLFSSL_MSG("SRP Profile not found!"); WOLFSSL_MSG("SRP Profile not found!");
ssl->dtlsSrtpId = 0;
TLSX_UseSRTP_Free(srtp, ssl->heap);
/* not fatal, so return 0 */ /* not fatal, so return 0 */
ret = 0; ret = 0;
} }
else if (ret != 0) {
ssl->dtlsSrtpId = 0;
TLSX_UseSRTP_Free(srtp, ssl->heap);
}
#endif #endif
return ret; return ret;

View File

@ -4949,7 +4949,6 @@ WOLFSSL_LOCAL int GrowInputBuffer(WOLFSSL* ssl, int size, int usedLength);
#endif #endif
WOLFSSL_LOCAL int IsSCR(WOLFSSL* ssl); WOLFSSL_LOCAL int IsSCR(WOLFSSL* ssl);
WOLFSSL_LOCAL int IsDtlsNotSctpMode(WOLFSSL* ssl); WOLFSSL_LOCAL int IsDtlsNotSctpMode(WOLFSSL* ssl);
WOLFSSL_LOCAL int IsDtlsNotSrtpMode(WOLFSSL* ssl);
WOLFSSL_LOCAL void WriteSEQ(WOLFSSL* ssl, int verifyOrder, byte* out); WOLFSSL_LOCAL void WriteSEQ(WOLFSSL* ssl, int verifyOrder, byte* out);