Go to the documentation of this file.
32 #define TRACE_LEVEL TLS_TRACE_LEVEL
43 #if (TLS_SUPPORT == ENABLED && DTLS_SUPPORT == ENABLED)
106 if(context->encryptionEngine[0].epoch == 0)
109 context->encryptionEngine[0].version = context->version;
171 if(context->cookieLen > 0)
178 cookie->length = (uint8_t) context->cookieLen;
216 if(context->cookieVerifyCallback != NULL &&
217 context->cookieGenerateCallback != NULL)
220 error = context->cookieVerifyCallback(context, clientParams,
227 if(context->cookie != NULL)
238 if(context->cookie != NULL)
242 error = context->cookieGenerateCallback(context, clientParams,
243 context->cookie, &context->cookieLen, context->cookieParam);
334 if(context->cookieLen > 0)
341 message->cookieLength = (uint8_t) context->cookieLen;
399 if(context->cookie != NULL)
402 context->cookie = NULL;
403 context->cookieLen = 0;
412 if(context->cookie == NULL)
420 context->cookieLen =
message->cookieLength;
446 const uint16_t supportedVersions[] =
457 n = supportedVersionList->length /
sizeof(uint16_t);
460 for(i = 0; i <
arraysize(supportedVersions) && error; i++)
463 for(j = 0; j <
n && error; j++)
467 if(
ntohs(supportedVersionList->value[j]) == supportedVersions[i])
487 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
493 decryptionEngine->replayWindow[i] = 0;
509 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
521 right =
LOAD48BE(&decryptionEngine->dtlsSeqNum);
539 if(decryptionEngine->replayWindow[j] & (1U << k))
592 right =
LOAD48BE(&decryptionEngine->dtlsSeqNum);
597 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
611 decryptionEngine->replayWindow[j] |= 1U << k;
617 #if (DTLS_REPLAY_DETECTION_SUPPORT == ENABLED)
637 decryptionEngine->replayWindow[i] =
638 decryptionEngine->replayWindow[i - j];
642 for(i = 0; i < j; i++)
644 decryptionEngine->replayWindow[i] = 0;
654 decryptionEngine->replayWindow[i] =
655 (decryptionEngine->replayWindow[i] << k) |
656 (decryptionEngine->replayWindow[i - 1] >> (32 - k));
660 decryptionEngine->replayWindow[0] <<= k;
668 decryptionEngine->replayWindow[i] = 0;
673 decryptionEngine->replayWindow[0] |= 1;
677 decryptionEngine->dtlsSeqNum = *
seqNum;
#define tlsAllocMem(size)
DTLS (Datagram Transport Layer Security)
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 tlsSendHandshakeMessage(TlsContext *context, const void *data, size_t length, TlsMessageType type)
Send handshake message.
void dtlsUpdateReplayWindow(TlsEncryptionEngine *decryptionEngine, const DtlsSequenceNumber *seqNum)
Update sliding window.
error_t dtlsParseClientSupportedVersionsExtension(TlsContext *context, const DtlsSupportedVersionList *supportedVersionList)
Parse SupportedVersions extension.
#define DTLS_MAX_COOKIE_SIZE
@ TLS_STATE_HELLO_VERIFY_REQUEST
error_t dtlsCheckReplayWindow(TlsEncryptionEngine *decryptionEngine, const DtlsSequenceNumber *seqNum)
Perform replay detection.
#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 dtlsInitReplayWindow(TlsEncryptionEngine *decryptionEngine)
Initialize 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.
#define TlsEncryptionEngine
error_t dtlsVerifyCookie(TlsContext *context, const DtlsCookie *cookie, const DtlsClientParameters *clientParams)
Cookie verification.
@ ERROR_INVALID_SEQUENCE_NUMBER