dtls_misc.h File Reference

DTLS (Datagram Transport Layer Security) More...

Go to the source code of this file.

Data Structures

struct  DtlsClientParameters
 Client parameters. More...
 

Macros

#define DTLS_VERSION_1_0   0xFEFF
 
#define DTLS_VERSION_1_2   0xFEFD
 
#define DTLS_VERSION_1_3   0xFEFC
 
#define DTLS_SUPPORT   DISABLED
 
#define DTLS_DEFAULT_PMTU   1452
 
#define DTLS_MIN_PMTU   528
 
#define DTLS_REPLAY_DETECTION_SUPPORT   ENABLED
 
#define DTLS_REPLAY_WINDOW_SIZE   64
 
#define DTLS_MAX_COOKIE_SIZE   32
 
#define DTLS_MAX_RETRIES   5
 
#define DTLS_INIT_TIMEOUT   1000
 
#define DTLS_MIN_TIMEOUT   500
 
#define DTLS_MAX_TIMEOUT   60000
 

Typedefs

typedef error_t(* DtlsCookieGenerateCallback) (TlsContext *context, const DtlsClientParameters *clientParams, uint8_t *cookie, size_t *length, void *param)
 DTLS cookie generation callback function. More...
 
typedef error_t(* DtlsCookieVerifyCallback) (TlsContext *context, const DtlsClientParameters *clientParams, const uint8_t *cookie, size_t length, void *param)
 DTLS cookie verification callback function. More...
 

Enumerations

enum  DtlsRetransmitState { DTLS_RETRANSMIT_STATE_PREPARING = 0, DTLS_RETRANSMIT_STATE_SENDING = 1, DTLS_RETRANSMIT_STATE_WAITING = 2, DTLS_RETRANSMIT_STATE_FINISHED = 3 }
 DTLS retransmission states. More...
 

Functions

error_t dtlsSelectVersion (TlsContext *context, uint16_t version)
 Set the DTLS version to be used. More...
 
uint16_t dtlsTranslateVersion (uint16_t version)
 Translate TLS version into DTLS version. More...
 
error_t dtlsFormatCookie (TlsContext *context, uint8_t *p, size_t *written)
 Format Cookie field. More...
 
error_t dtlsVerifyCookie (TlsContext *context, const DtlsCookie *cookie, const DtlsClientParameters *clientParams)
 Cookie verification. More...
 
error_t dtlsSendHelloVerifyRequest (TlsContext *context)
 Send HelloVerifyRequest message. More...
 
error_t dtlsFormatHelloVerifyRequest (TlsContext *context, DtlsHelloVerifyRequest *message, size_t *length)
 Format HelloVerifyRequest message. More...
 
error_t dtlsParseHelloVerifyRequest (TlsContext *context, const DtlsHelloVerifyRequest *message, size_t length)
 Parse HelloVerifyRequest message. More...
 
error_t dtlsParseClientSupportedVersionsExtension (TlsContext *context, const DtlsSupportedVersionList *supportedVersionList)
 Parse SupportedVersions extension. More...
 
void dtlsInitReplayWindow (TlsContext *context)
 Initialize sliding window. More...
 
error_t dtlsCheckReplayWindow (TlsContext *context, DtlsSequenceNumber *seqNum)
 Perform replay detection. More...
 
void dtlsUpdateReplayWindow (TlsContext *context, DtlsSequenceNumber *seqNum)
 Update sliding window. More...
 

Variables

typedef __packed_struct
 Sequence number. More...
 
 DtlsSequenceNumber
 
uint8_t value []
 
 DtlsCookie
 
 DtlsSupportedVersionList
 
uint16_t version
 
uint16_t epoch
 
DtlsSequenceNumber seqNum
 
uint16_t length
 
uint8_t data []
 
 DtlsRecord
 
uint16_t msgSeq
 
uint8_t fragOffset [3]
 
uint8_t fragLength [3]
 
 DtlsHandshake
 
uint8_t cookieLength
 
uint8_t cookie []
 
 DtlsHelloVerifyRequest
 

Detailed Description

DTLS (Datagram Transport Layer Security)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneSSL Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file dtls_misc.h.

Macro Definition Documentation

◆ DTLS_DEFAULT_PMTU

#define DTLS_DEFAULT_PMTU   1452

Definition at line 48 of file dtls_misc.h.

◆ DTLS_INIT_TIMEOUT

#define DTLS_INIT_TIMEOUT   1000

Definition at line 90 of file dtls_misc.h.

◆ DTLS_MAX_COOKIE_SIZE

#define DTLS_MAX_COOKIE_SIZE   32

Definition at line 76 of file dtls_misc.h.

◆ DTLS_MAX_RETRIES

#define DTLS_MAX_RETRIES   5

Definition at line 83 of file dtls_misc.h.

◆ DTLS_MAX_TIMEOUT

#define DTLS_MAX_TIMEOUT   60000

Definition at line 104 of file dtls_misc.h.

◆ DTLS_MIN_PMTU

#define DTLS_MIN_PMTU   528

Definition at line 55 of file dtls_misc.h.

◆ DTLS_MIN_TIMEOUT

#define DTLS_MIN_TIMEOUT   500

Definition at line 97 of file dtls_misc.h.

◆ DTLS_REPLAY_DETECTION_SUPPORT

#define DTLS_REPLAY_DETECTION_SUPPORT   ENABLED

Definition at line 62 of file dtls_misc.h.

◆ DTLS_REPLAY_WINDOW_SIZE

#define DTLS_REPLAY_WINDOW_SIZE   64

Definition at line 69 of file dtls_misc.h.

◆ DTLS_SUPPORT

#define DTLS_SUPPORT   DISABLED

Definition at line 41 of file dtls_misc.h.

◆ DTLS_VERSION_1_0

#define DTLS_VERSION_1_0   0xFEFF

Definition at line 35 of file dtls_misc.h.

◆ DTLS_VERSION_1_2

#define DTLS_VERSION_1_2   0xFEFD

Definition at line 36 of file dtls_misc.h.

◆ DTLS_VERSION_1_3

#define DTLS_VERSION_1_3   0xFEFC

Definition at line 37 of file dtls_misc.h.

Typedef Documentation

◆ DtlsCookieGenerateCallback

typedef error_t(* DtlsCookieGenerateCallback) (TlsContext *context, const DtlsClientParameters *clientParams, uint8_t *cookie, size_t *length, void *param)

DTLS cookie generation callback function.

Definition at line 240 of file dtls_misc.h.

◆ DtlsCookieVerifyCallback

typedef error_t(* DtlsCookieVerifyCallback) (TlsContext *context, const DtlsClientParameters *clientParams, const uint8_t *cookie, size_t length, void *param)

DTLS cookie verification callback function.

Definition at line 249 of file dtls_misc.h.

Enumeration Type Documentation

◆ DtlsRetransmitState

DTLS retransmission states.

Enumerator
DTLS_RETRANSMIT_STATE_PREPARING 
DTLS_RETRANSMIT_STATE_SENDING 
DTLS_RETRANSMIT_STATE_WAITING 
DTLS_RETRANSMIT_STATE_FINISHED 

Definition at line 119 of file dtls_misc.h.

Function Documentation

◆ dtlsCheckReplayWindow()

error_t dtlsCheckReplayWindow ( TlsContext context,
DtlsSequenceNumber seqNum 
)

Perform replay detection.

Parameters
[in]contextPointer to the TLS context
[in]seqNumSequence number of the received DTLS record
Returns
Error code

Definition at line 469 of file dtls_misc.c.

◆ dtlsFormatCookie()

error_t dtlsFormatCookie ( TlsContext context,
uint8_t *  p,
size_t *  written 
)

Format Cookie field.

Parameters
[in]contextPointer to the TLS context
[in]pOutput stream where to write the Cookie field
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 144 of file dtls_misc.c.

◆ dtlsFormatHelloVerifyRequest()

error_t dtlsFormatHelloVerifyRequest ( TlsContext context,
DtlsHelloVerifyRequest message,
size_t *  length 
)

Format HelloVerifyRequest message.

Parameters
[in]contextPointer to the TLS context
[out]messageBuffer where to format the HelloVerifyRequest message
[out]lengthLength of the resulting HelloVerifyRequest message
Returns
Error code

Definition at line 291 of file dtls_misc.c.

◆ dtlsInitReplayWindow()

void dtlsInitReplayWindow ( TlsContext context)

Initialize sliding window.

Parameters
[in]contextPointer to the TLS context

Definition at line 448 of file dtls_misc.c.

◆ dtlsParseClientSupportedVersionsExtension()

error_t dtlsParseClientSupportedVersionsExtension ( TlsContext context,
const DtlsSupportedVersionList supportedVersionList 
)

Parse SupportedVersions extension.

Parameters
[in]contextPointer to the TLS context
[in]supportedVersionListPointer to the SupportedVersions extension
Returns
Error code

Definition at line 401 of file dtls_misc.c.

◆ dtlsParseHelloVerifyRequest()

error_t dtlsParseHelloVerifyRequest ( TlsContext context,
const DtlsHelloVerifyRequest message,
size_t  length 
)

Parse HelloVerifyRequest message.

When the client sends its ClientHello message to the server, the server may respond with a HelloVerifyRequest message

Parameters
[in]contextPointer to the TLS context
[in]messageIncoming HelloVerifyRequest message to parse
[in]lengthMessage length
Returns
Error code

Definition at line 329 of file dtls_misc.c.

◆ dtlsSelectVersion()

error_t dtlsSelectVersion ( TlsContext context,
uint16_t  version 
)

Set the DTLS version to be used.

Parameters
[in]contextPointer to the TLS context
[in]versionDTLS version
Returns
Error code

Definition at line 53 of file dtls_misc.c.

◆ dtlsSendHelloVerifyRequest()

error_t dtlsSendHelloVerifyRequest ( TlsContext context)

Send HelloVerifyRequest message.

When the client sends its ClientHello message to the server, the server may respond with a HelloVerifyRequest message. This message contains a stateless cookie

Parameters
[in]contextPointer to the TLS context
Returns
Error code

Definition at line 247 of file dtls_misc.c.

◆ dtlsTranslateVersion()

uint16_t dtlsTranslateVersion ( uint16_t  version)

Translate TLS version into DTLS version.

Parameters
[in]versionTLS version
Returns
DTLS version

Definition at line 112 of file dtls_misc.c.

◆ dtlsUpdateReplayWindow()

void dtlsUpdateReplayWindow ( TlsContext context,
DtlsSequenceNumber seqNum 
)

Update sliding window.

Parameters
[in]contextPointer to the TLS context
[in]seqNumSequence number of the received DTLS record

Definition at line 550 of file dtls_misc.c.

◆ dtlsVerifyCookie()

error_t dtlsVerifyCookie ( TlsContext context,
const DtlsCookie cookie,
const DtlsClientParameters clientParams 
)

Cookie verification.

Parameters
[in]contextPointer to the TLS context
[in]cookiePointer to the client's cookie
[in]clientParamsClient's parameters
Returns
Error code

Definition at line 178 of file dtls_misc.c.

Variable Documentation

◆ __packed_struct

typedef __packed_struct
Initial value:
{
uint8_t b[6]

Sequence number.

HelloVerifyRequest message.

DTLS handshake message.

DTLS record.

List of supported versions.

Cookie.

Definition at line 140 of file dtls_misc.h.

◆ cookie

uint8_t cookie[]

Definition at line 206 of file dtls_misc.h.

◆ cookieLength

uint8_t cookieLength

Definition at line 205 of file dtls_misc.h.

◆ data

uint8_t data[]

Definition at line 179 of file dtls_misc.h.

◆ DtlsCookie

DtlsCookie

Definition at line 154 of file dtls_misc.h.

◆ DtlsHandshake

DtlsHandshake

Definition at line 195 of file dtls_misc.h.

◆ DtlsHelloVerifyRequest

DtlsHelloVerifyRequest

Definition at line 207 of file dtls_misc.h.

◆ DtlsRecord

DtlsRecord

Definition at line 180 of file dtls_misc.h.

◆ DtlsSequenceNumber

DtlsSequenceNumber

Definition at line 143 of file dtls_misc.h.

◆ DtlsSupportedVersionList

DtlsSupportedVersionList

Definition at line 165 of file dtls_misc.h.

◆ epoch

uint16_t epoch

Definition at line 176 of file dtls_misc.h.

◆ fragLength

uint8_t fragLength[3]

Definition at line 193 of file dtls_misc.h.

◆ fragOffset

uint8_t fragOffset[3]

Definition at line 192 of file dtls_misc.h.

◆ length

uint8_t length[3]

Definition at line 178 of file dtls_misc.h.

◆ msgSeq

uint16_t msgSeq

Definition at line 191 of file dtls_misc.h.

◆ seqNum

Definition at line 177 of file dtls_misc.h.

◆ value

uint16_t value[]

Definition at line 153 of file dtls_misc.h.

◆ version

uint16_t version

Definition at line 175 of file dtls_misc.h.

uint8_t b
Definition: nbns_common.h:104