tls_client.c File Reference

Handshake message processing (TLS client) More...

#include "tls.h"
#include "tls_cipher_suites.h"
#include "tls_handshake.h"
#include "tls_client.h"
#include "tls_client_extensions.h"
#include "tls_client_misc.h"
#include "tls_common.h"
#include "tls_extensions.h"
#include "tls_certificate.h"
#include "tls_sign_misc.h"
#include "tls_key_material.h"
#include "tls_transcript_hash.h"
#include "tls_record.h"
#include "tls_misc.h"
#include "tls13_client.h"
#include "tls13_client_extensions.h"
#include "tls13_client_misc.h"
#include "dtls_record.h"
#include "dtls_misc.h"
#include "pkix/pem_import.h"
#include "date_time.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   TLS_TRACE_LEVEL
 

Functions

error_t tlsSendClientHello (TlsContext *context)
 Send ClientHello message. More...
 
error_t tlsSendClientKeyExchange (TlsContext *context)
 Send ClientKeyExchange message. More...
 
error_t tlsFormatClientHello (TlsContext *context, TlsClientHello *message, size_t *length)
 Format ClientHello message. More...
 
error_t tlsFormatClientKeyExchange (TlsContext *context, TlsClientKeyExchange *message, size_t *length)
 Format ClientKeyExchange message. More...
 
error_t tlsParseHelloRequest (TlsContext *context, const TlsHelloRequest *message, size_t length)
 Parse HelloRequest message. More...
 
error_t tlsParseServerHello (TlsContext *context, const TlsServerHello *message, size_t length)
 Parse ServerHello message. More...
 
error_t tlsParseServerKeyExchange (TlsContext *context, const TlsServerKeyExchange *message, size_t length)
 Parse ServerKeyExchange message. More...
 
error_t tlsParseCertificateRequest (TlsContext *context, const TlsCertificateRequest *message, size_t length)
 Parse CertificateRequest message. More...
 
error_t tlsParseServerHelloDone (TlsContext *context, const TlsServerHelloDone *message, size_t length)
 Parse ServerHelloDone message. More...
 
error_t tlsParseNewSessionTicket (TlsContext *context, const TlsNewSessionTicket *message, size_t length)
 Parse NewSessionTicket message. More...
 

Detailed Description

Handshake message processing (TLS client)

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.

Description

The TLS protocol provides communications security over the Internet. The protocol allows client/server applications to communicate in a way that is designed to prevent eavesdropping, tampering, or message forgery

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

Definition in file tls_client.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   TLS_TRACE_LEVEL

Definition at line 38 of file tls_client.c.

Function Documentation

◆ tlsFormatClientHello()

error_t tlsFormatClientHello ( TlsContext context,
TlsClientHello message,
size_t *  length 
)

Format ClientHello message.

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

Definition at line 312 of file tls_client.c.

◆ tlsFormatClientKeyExchange()

error_t tlsFormatClientKeyExchange ( TlsContext context,
TlsClientKeyExchange message,
size_t *  length 
)

Format ClientKeyExchange message.

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

Definition at line 785 of file tls_client.c.

◆ tlsParseCertificateRequest()

error_t tlsParseCertificateRequest ( TlsContext context,
const TlsCertificateRequest message,
size_t  length 
)

Parse CertificateRequest message.

A server can optionally request a certificate from the client, if appropriate for the selected cipher suite. This message will immediately follow the ServerKeyExchange message

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

Definition at line 1524 of file tls_client.c.

◆ tlsParseHelloRequest()

error_t tlsParseHelloRequest ( TlsContext context,
const TlsHelloRequest message,
size_t  length 
)

Parse HelloRequest message.

HelloRequest is a simple notification that the client should begin the negotiation process anew. In response, the client should send a ClientHello message when convenient

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

Definition at line 872 of file tls_client.c.

◆ tlsParseNewSessionTicket()

error_t tlsParseNewSessionTicket ( TlsContext context,
const TlsNewSessionTicket message,
size_t  length 
)

Parse NewSessionTicket message.

This NewSessionTicket message is sent by the server during the TLS handshake before the ChangeCipherSpec message

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

Definition at line 1914 of file tls_client.c.

◆ tlsParseServerHello()

error_t tlsParseServerHello ( TlsContext context,
const TlsServerHello message,
size_t  length 
)

Parse ServerHello message.

The server will send this message in response to a ClientHello message when it was able to find an acceptable set of algorithms. If it cannot find such a match, it will respond with a handshake failure alert

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

Definition at line 957 of file tls_client.c.

◆ tlsParseServerHelloDone()

error_t tlsParseServerHelloDone ( TlsContext context,
const TlsServerHelloDone message,
size_t  length 
)

Parse ServerHelloDone message.

The ServerHelloDone message is sent by the server to indicate the end of the ServerHello and associated messages. After sending this message, the server will wait for a client response

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

Definition at line 1828 of file tls_client.c.

◆ tlsParseServerKeyExchange()

error_t tlsParseServerKeyExchange ( TlsContext context,
const TlsServerKeyExchange message,
size_t  length 
)

Parse ServerKeyExchange message.

The ServerKeyExchange message is sent by the server only when the server Certificate message does not contain enough data to allow the client to exchange a premaster secret

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

Definition at line 1365 of file tls_client.c.

◆ tlsSendClientHello()

error_t tlsSendClientHello ( TlsContext context)

Send ClientHello message.

When a client first connects to a server, it is required to send the ClientHello as its first message. The client can also send a ClientHello in response to a HelloRequest or on its own initiative in order to renegotiate the security parameters in an existing connection

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

Definition at line 81 of file tls_client.c.

◆ tlsSendClientKeyExchange()

error_t tlsSendClientKeyExchange ( TlsContext context)

Send ClientKeyExchange message.

This message is always sent by the client. It must immediately follow the client Certificate message, if it is sent. Otherwise, it must be the first message sent by the client after it receives the ServerHelloDone message

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

Definition at line 261 of file tls_client.c.