dtls_misc.c File Reference

DTLS (Datagram Transport Layer Security) More...

#include "tls.h"
#include "tls_handshake.h"
#include "tls_common.h"
#include "tls_misc.h"
#include "dtls_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   TLS_TRACE_LEVEL
 

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

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.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   TLS_TRACE_LEVEL

Definition at line 32 of file dtls_misc.c.

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.