tls_common.c File Reference

Handshake message processing (TLS client and server) More...

#include <string.h>
#include "tls.h"
#include "tls_cipher_suites.h"
#include "tls_handshake.h"
#include "tls_client.h"
#include "tls_server.h"
#include "tls_common.h"
#include "tls_certificate.h"
#include "tls_signature.h"
#include "tls_transcript_hash.h"
#include "tls_cache.h"
#include "tls_record.h"
#include "tls_misc.h"
#include "dtls_record.h"
#include "certificate/x509_common.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   TLS_TRACE_LEVEL
 

Functions

error_t tlsSendCertificate (TlsContext *context)
 Send Certificate message. More...
 
error_t tlsSendCertificateVerify (TlsContext *context)
 Send CertificateVerify message. More...
 
error_t tlsSendChangeCipherSpec (TlsContext *context)
 Send ChangeCipherSpec message. More...
 
error_t tlsSendFinished (TlsContext *context)
 Send Finished message. More...
 
error_t tlsSendAlert (TlsContext *context, uint8_t level, uint8_t description)
 Send Alert message. More...
 
error_t tlsFormatCertificate (TlsContext *context, TlsCertificate *message, size_t *length)
 Format Certificate message. More...
 
error_t tlsFormatCertificateVerify (TlsContext *context, TlsCertificateVerify *message, size_t *length)
 Format CertificateVerify message. More...
 
error_t tlsFormatChangeCipherSpec (TlsContext *context, TlsChangeCipherSpec *message, size_t *length)
 Format ChangeCipherSpec message. More...
 
error_t tlsFormatFinished (TlsContext *context, TlsFinished *message, size_t *length)
 Format Finished message. More...
 
error_t tlsFormatAlert (TlsContext *context, uint8_t level, uint8_t description, TlsAlert *message, size_t *length)
 Format Alert message. More...
 
error_t tlsFormatSignatureAlgorithmsExtension (TlsContext *context, uint_t cipherSuiteTypes, uint8_t *p, size_t *written)
 Format SignatureAlgorithms extension. More...
 
error_t tlsFormatSignatureAlgorithmsCertExtension (TlsContext *context, uint8_t *p, size_t *written)
 Format SignatureAlgorithmsCert extension. More...
 
error_t tlsParseCertificate (TlsContext *context, const TlsCertificate *message, size_t length)
 Parse Certificate message. More...
 
error_t tlsParseCertificateVerify (TlsContext *context, const TlsCertificateVerify *message, size_t length)
 Parse CertificateVerify message. More...
 
error_t tlsParseChangeCipherSpec (TlsContext *context, const TlsChangeCipherSpec *message, size_t length)
 Parse ChangeCipherSpec message. More...
 
error_t tlsParseFinished (TlsContext *context, const TlsFinished *message, size_t length)
 Parse Finished message. More...
 
error_t tlsParseAlert (TlsContext *context, const TlsAlert *message, size_t length)
 Parse Alert message. More...
 

Detailed Description

Handshake message processing (TLS client and server)

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

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   TLS_TRACE_LEVEL

Definition at line 30 of file tls_common.c.

Function Documentation

◆ tlsFormatAlert()

error_t tlsFormatAlert ( TlsContext context,
uint8_t  level,
uint8_t  description,
TlsAlert message,
size_t *  length 
)

Format Alert message.

Parameters
[in]contextPointer to the TLS context
[in]levelSeverity of the message (warning or fatal)
[in]descriptionDescription of the alert
[out]messageBuffer where to format the Alert message
[out]lengthLength of the resulting Alert message
Returns
Error code

Definition at line 768 of file tls_common.c.

◆ tlsFormatCertificate()

error_t tlsFormatCertificate ( TlsContext context,
TlsCertificate message,
size_t *  length 
)

Format Certificate message.

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

Definition at line 564 of file tls_common.c.

◆ tlsFormatCertificateVerify()

error_t tlsFormatCertificateVerify ( TlsContext context,
TlsCertificateVerify message,
size_t *  length 
)

Format CertificateVerify message.

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

Definition at line 653 of file tls_common.c.

◆ tlsFormatChangeCipherSpec()

error_t tlsFormatChangeCipherSpec ( TlsContext context,
TlsChangeCipherSpec message,
size_t *  length 
)

Format ChangeCipherSpec message.

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

Definition at line 712 of file tls_common.c.

◆ tlsFormatFinished()

error_t tlsFormatFinished ( TlsContext context,
TlsFinished message,
size_t *  length 
)

Format Finished message.

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

Definition at line 734 of file tls_common.c.

◆ tlsFormatSignatureAlgorithmsCertExtension()

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

Format SignatureAlgorithmsCert extension.

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

Definition at line 999 of file tls_common.c.

◆ tlsFormatSignatureAlgorithmsExtension()

error_t tlsFormatSignatureAlgorithmsExtension ( TlsContext context,
uint_t  cipherSuiteTypes,
uint8_t *  p,
size_t *  written 
)

Format SignatureAlgorithms extension.

Parameters
[in]contextPointer to the TLS context
[in]cipherSuiteTypesTypes of cipher suites proposed by the client
[in]pOutput stream where to write the SignatureAlgorithms extension
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 793 of file tls_common.c.

◆ tlsParseAlert()

error_t tlsParseAlert ( TlsContext context,
const TlsAlert message,
size_t  length 
)

Parse Alert message.

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

Definition at line 1745 of file tls_common.c.

◆ tlsParseCertificate()

error_t tlsParseCertificate ( TlsContext context,
const TlsCertificate message,
size_t  length 
)

Parse Certificate message.

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

Definition at line 1229 of file tls_common.c.

◆ tlsParseCertificateVerify()

error_t tlsParseCertificateVerify ( TlsContext context,
const TlsCertificateVerify message,
size_t  length 
)

Parse CertificateVerify message.

The CertificateVerify message is used to provide explicit verification of a client certificate. This message is only sent following a client certificate that has signing capability

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

Definition at line 1405 of file tls_common.c.

◆ tlsParseChangeCipherSpec()

error_t tlsParseChangeCipherSpec ( TlsContext context,
const TlsChangeCipherSpec message,
size_t  length 
)

Parse ChangeCipherSpec message.

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

Definition at line 1498 of file tls_common.c.

◆ tlsParseFinished()

error_t tlsParseFinished ( TlsContext context,
const TlsFinished message,
size_t  length 
)

Parse Finished message.

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

Definition at line 1629 of file tls_common.c.

◆ tlsSendAlert()

error_t tlsSendAlert ( TlsContext context,
uint8_t  level,
uint8_t  description 
)

Send Alert message.

Parameters
[in]contextPointer to the TLS context
[in]levelSeverity of the message (warning or fatal)
[in]descriptionDescription of the alert
Returns
Error code

Definition at line 478 of file tls_common.c.

◆ tlsSendCertificate()

error_t tlsSendCertificate ( TlsContext context)

Send Certificate message.

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

Definition at line 60 of file tls_common.c.

◆ tlsSendCertificateVerify()

error_t tlsSendCertificateVerify ( TlsContext context)

Send CertificateVerify message.

The CertificateVerify message is used to provide explicit verification of a client certificate. This message is only sent following a client certificate that has signing capability

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

Definition at line 190 of file tls_common.c.

◆ tlsSendChangeCipherSpec()

error_t tlsSendChangeCipherSpec ( TlsContext context)

Send ChangeCipherSpec message.

The change cipher spec message is sent by both the client and the server to notify the receiving party that subsequent records will be protected under the newly negotiated CipherSpec and keys

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

Definition at line 266 of file tls_common.c.

◆ tlsSendFinished()

error_t tlsSendFinished ( TlsContext context)

Send Finished message.

A Finished message is always sent immediately after a change cipher spec message to verify that the key exchange and authentication processes were successful. It is essential that a change cipher spec message be received between the other handshake messages and the Finished message

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

Definition at line 381 of file tls_common.c.