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;
360 if(context->cookie != NULL)
364 context->cookie = NULL;
365 context->cookieLen = 0;
374 if(context->cookie == NULL)
382 context->cookieLen =
message->cookieLength;
414 const uint16_t supportedVersions[] =
424 n = supportedVersionList->length /
sizeof(uint16_t);
427 for(i = 0; i <
arraysize(supportedVersions) && error; i++)
430 for(j = 0; j <
n && error; j++)
434 if(
ntohs(supportedVersionList->value[j]) == supportedVersions[i])
454 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
460 context->replayWindow[i] = 0;
477 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
479 if(context->replayDetectionEnabled)
491 right =
LOAD48BE(&context->decryptionEngine.dtlsSeqNum);
509 if(context->replayWindow[j] & (1U << k))
564 right =
LOAD48BE(&context->decryptionEngine.dtlsSeqNum);
569 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
583 context->replayWindow[j] |= 1U << k;
589 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
609 context->replayWindow[i] = context->replayWindow[i - j];
613 for(i = 0; i < j; i++)
615 context->replayWindow[i] = 0;
625 context->replayWindow[i] = (context->replayWindow[i] << k) |
626 (context->replayWindow[i - 1] >> (32 - k));
630 context->replayWindow[0] <<= k;
638 context->replayWindow[i] = 0;
643 context->replayWindow[0] |= 1;
647 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.
@ TLS_STATE_CLIENT_HELLO_2
#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.
@ TLS_STATE_SERVER_HELLO_2
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