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_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_MAX_TIMEOUT   60000
 

Typedefs

struct {
   uint8_t   b [6]
 
DtlsSequenceNumber
 Sequence number. More...
 
struct {
   uint8_t   length
 
   uint8_t   value []
 
DtlsCookie
 Cookie. More...
 
struct {
   uint8_t   length
 
   uint16_t   value []
 
DtlsSupportedVersionList
 List of supported versions. More...
 
struct {
   uint8_t   type
 
   uint16_t   version
 
   uint16_t   epoch
 
   DtlsSequenceNumber   seqNum
 
   uint16_t   length
 
   uint8_t   data []
 
DtlsRecord
 DTLS record. More...
 
struct {
   uint8_t   msgType
 
   uint8_t   length [3]
 
   uint16_t   msgSeq
 
   uint8_t   fragOffset [3]
 
   uint8_t   fragLength [3]
 
   uint8_t   data []
 
DtlsHandshake
 DTLS handshake message. More...
 
struct {
   uint16_t   serverVersion
 
   uint8_t   cookieLength
 
   uint8_t   cookie []
 
DtlsHelloVerifyRequest
 HelloVerifyRequest message. More...
 
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...
 

Detailed Description

DTLS (Datagram Transport Layer Security)

License

Copyright (C) 2010-2018 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
1.9.0

Definition in file dtls_misc.h.

Macro Definition Documentation

◆ DTLS_DEFAULT_PMTU

#define DTLS_DEFAULT_PMTU   1452

Definition at line 45 of file dtls_misc.h.

◆ DTLS_INIT_TIMEOUT

#define DTLS_INIT_TIMEOUT   1000

Definition at line 87 of file dtls_misc.h.

◆ DTLS_MAX_COOKIE_SIZE

#define DTLS_MAX_COOKIE_SIZE   32

Definition at line 73 of file dtls_misc.h.

◆ DTLS_MAX_RETRIES

#define DTLS_MAX_RETRIES   5

Definition at line 80 of file dtls_misc.h.

◆ DTLS_MAX_TIMEOUT

#define DTLS_MAX_TIMEOUT   60000

Definition at line 94 of file dtls_misc.h.

◆ DTLS_MIN_PMTU

#define DTLS_MIN_PMTU   528

Definition at line 52 of file dtls_misc.h.

◆ DTLS_REPLAY_DETECTION_SUPPORT

#define DTLS_REPLAY_DETECTION_SUPPORT   ENABLED

Definition at line 59 of file dtls_misc.h.

◆ DTLS_REPLAY_WINDOW_SIZE

#define DTLS_REPLAY_WINDOW_SIZE   64

Definition at line 66 of file dtls_misc.h.

◆ DTLS_SUPPORT

#define DTLS_SUPPORT   DISABLED

Definition at line 38 of file dtls_misc.h.

◆ DTLS_VERSION_1_0

#define DTLS_VERSION_1_0   0xFEFF

Definition at line 33 of file dtls_misc.h.

◆ DTLS_VERSION_1_2

#define DTLS_VERSION_1_2   0xFEFD

Definition at line 34 of file dtls_misc.h.

Typedef Documentation

◆ DtlsCookie

typedef { ... } DtlsCookie

Cookie.

◆ 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 226 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 235 of file dtls_misc.h.

◆ DtlsHandshake

typedef { ... } DtlsHandshake

DTLS handshake message.

◆ DtlsHelloVerifyRequest

typedef { ... } DtlsHelloVerifyRequest

HelloVerifyRequest message.

◆ DtlsRecord

typedef { ... } DtlsRecord

DTLS record.

◆ DtlsSequenceNumber

typedef { ... } DtlsSequenceNumber

Sequence number.

◆ DtlsSupportedVersionList

typedef { ... } DtlsSupportedVersionList

List of supported versions.

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 109 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 462 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 138 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 283 of file dtls_misc.c.

◆ dtlsInitReplayWindow()

void dtlsInitReplayWindow ( TlsContext context)

Initialize sliding window.

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

Definition at line 441 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 393 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 321 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 52 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 239 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 111 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 543 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 172 of file dtls_misc.c.

Variable Documentation

◆ b

uint8_t b[6]

Definition at line 130 of file dtls_misc.h.

◆ cookie

uint8_t cookie[]

Definition at line 194 of file dtls_misc.h.

◆ cookieLength

uint8_t cookieLength

Definition at line 193 of file dtls_misc.h.

◆ data

uint8_t data[]

Definition at line 167 of file dtls_misc.h.

◆ epoch

uint16_t epoch

Definition at line 164 of file dtls_misc.h.

◆ fragLength

uint8_t fragLength[3]

Definition at line 181 of file dtls_misc.h.

◆ fragOffset

uint8_t fragOffset[3]

Definition at line 180 of file dtls_misc.h.

◆ length

uint8_t length[3]

Definition at line 140 of file dtls_misc.h.

◆ msgSeq

uint16_t msgSeq

Definition at line 179 of file dtls_misc.h.

◆ msgType

uint8_t msgType

Definition at line 177 of file dtls_misc.h.

◆ seqNum

Definition at line 165 of file dtls_misc.h.

◆ serverVersion

uint16_t serverVersion

Definition at line 192 of file dtls_misc.h.

◆ type

uint8_t type

Definition at line 162 of file dtls_misc.h.

◆ value

uint16_t value[]

Definition at line 141 of file dtls_misc.h.

◆ version

uint16_t version

Definition at line 163 of file dtls_misc.h.