Go to the documentation of this file.
32 #define TRACE_LEVEL TLS_TRACE_LEVEL
43 #if (TLS_SUPPORT == ENABLED && DTLS_SUPPORT == ENABLED)
94 if(context->encryptionEngine.epoch == 0)
97 context->encryptionEngine.version = context->version;
153 if(context->cookieLen > 0)
160 cookie->length = (uint8_t) context->cookieLen;
184 if(context->cookieVerifyCallback != NULL &&
185 context->cookieGenerateCallback != NULL)
188 error = context->cookieVerifyCallback(context, clientParams,
198 if(context->cookie == NULL)
204 if(context->cookie != NULL)
208 error = context->cookieGenerateCallback(context, clientParams,
209 context->cookie, &context->cookieLen, context->cookieParam);
300 if(context->cookieLen > 0)
307 message->cookieLength = (uint8_t) context->cookieLen;
356 if(context->cookie != NULL)
360 context->cookie = NULL;
361 context->cookieLen = 0;
370 if(context->cookie == NULL)
378 context->cookieLen =
message->cookieLength;
410 const uint16_t supportedVersions[] =
420 n = supportedVersionList->length /
sizeof(uint16_t);
423 for(i = 0; i <
arraysize(supportedVersions) && error; i++)
426 for(j = 0; j <
n && error; j++)
430 if(
ntohs(supportedVersionList->value[j]) == supportedVersions[i])
450 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
456 context->replayWindow[i] = 0;
473 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
475 if(context->replayDetectionEnabled)
487 right =
LOAD48BE(&context->decryptionEngine.dtlsSeqNum);
505 if(context->replayWindow[j] & (1U << k))
560 right =
LOAD48BE(&context->decryptionEngine.dtlsSeqNum);
565 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
579 context->replayWindow[j] |= 1U << k;
585 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
605 context->replayWindow[i] = context->replayWindow[i - j];
609 for(i = 0; i < j; i++)
611 context->replayWindow[i] = 0;
621 context->replayWindow[i] = (context->replayWindow[i] << k) |
622 (context->replayWindow[i - 1] >> (32 - k));
626 context->replayWindow[0] <<= k;
634 context->replayWindow[i] = 0;
639 context->replayWindow[0] |= 1;
643 context->decryptionEngine.dtlsSeqNum = *
seqNum;
#define tlsAllocMem(size)
DTLS (Datagram Transport Layer Security)
void dtlsInitReplayWindow(TlsContext *context)
Initialize sliding window.
error_t dtlsSelectVersion(TlsContext *context, uint16_t version)
Set the DTLS version to be used.
error_t dtlsFormatHelloVerifyRequest(TlsContext *context, DtlsHelloVerifyRequest *message, size_t *length)
Format HelloVerifyRequest message.
@ ERROR_VERSION_NOT_SUPPORTED
@ ERROR_UNEXPECTED_MESSAGE
@ TLS_TRANSPORT_PROTOCOL_DATAGRAM
#define DTLS_REPLAY_WINDOW_SIZE
error_t dtlsCheckReplayWindow(TlsContext *context, DtlsSequenceNumber *seqNum)
Perform replay detection.
error_t tlsSendHandshakeMessage(TlsContext *context, const void *data, size_t length, TlsMessageType type)
Send handshake message.
error_t dtlsParseClientSupportedVersionsExtension(TlsContext *context, const DtlsSupportedVersionList *supportedVersionList)
Parse SupportedVersions extension.
#define DTLS_MAX_COOKIE_SIZE
@ TLS_STATE_HELLO_VERIFY_REQUEST
#define osMemcpy(dest, src, length)
Handshake message processing (TLS client and server)
@ TLS_TYPE_HELLO_VERIFY_REQUEST
uint16_t dtlsTranslateVersion(uint16_t version)
Translate TLS version into DTLS version.
void dtlsUpdateReplayWindow(TlsContext *context, DtlsSequenceNumber *seqNum)
Update sliding window.
#define TRACE_DEBUG_ARRAY(p, a, n)
TLS (Transport Layer Security)
error_t dtlsSendHelloVerifyRequest(TlsContext *context)
Send HelloVerifyRequest message.
void tlsChangeState(TlsContext *context, TlsState newState)
Update TLS state.
error_t dtlsFormatCookie(TlsContext *context, uint8_t *p, size_t *written)
Format Cookie field.
error_t dtlsParseHelloVerifyRequest(TlsContext *context, const DtlsHelloVerifyRequest *message, size_t length)
Parse HelloVerifyRequest message.
error_t dtlsVerifyCookie(TlsContext *context, const DtlsCookie *cookie, const DtlsClientParameters *clientParams)
Cookie verification.
@ ERROR_INVALID_SEQUENCE_NUMBER