tls_record_encryption.c File Reference

TLS record encryption. More...

#include "tls.h"
#include "tls_record.h"
#include "tls_record_encryption.h"
#include "tls_misc.h"
#include "cipher_modes/cbc.h"
#include "aead/aead_algorithms.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   TLS_TRACE_LEVEL
 

Functions

error_t tlsEncryptRecord (TlsContext *context, TlsEncryptionEngine *encryptionEngine, void *record)
 Encrypt an outgoing TLS record. More...
 
__weak_func error_t tlsEncryptAeadRecord (TlsContext *context, TlsEncryptionEngine *encryptionEngine, void *record)
 Record encryption (AEAD cipher) More...
 
__weak_func error_t tlsEncryptCbcRecord (TlsContext *context, TlsEncryptionEngine *encryptionEngine, void *record)
 Record encryption (CBC block cipher) More...
 
error_t tlsEncryptStreamRecord (TlsContext *context, TlsEncryptionEngine *encryptionEngine, void *record)
 Record encryption (stream cipher) More...
 
error_t tlsAppendMessageAuthCode (TlsContext *context, TlsEncryptionEngine *encryptionEngine, void *record)
 Append message authentication code. More...
 
__weak_func error_t tlsComputeMac (TlsContext *context, TlsEncryptionEngine *encryptionEngine, const void *record, const uint8_t *data, size_t dataLen, uint8_t *mac)
 Compute message authentication code. More...
 

Detailed Description

TLS record encryption.

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

Definition in file tls_record_encryption.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   TLS_TRACE_LEVEL

Definition at line 32 of file tls_record_encryption.c.

Function Documentation

◆ tlsAppendMessageAuthCode()

error_t tlsAppendMessageAuthCode ( TlsContext context,
TlsEncryptionEngine encryptionEngine,
void *  record 
)

Append message authentication code.

Parameters
[in]contextPointer to the TLS context
[in]encryptionEnginePointer to the encryption engine
[in,out]recordTLS record to be authenticated
Returns
Error code

Definition at line 424 of file tls_record_encryption.c.

◆ tlsComputeMac()

__weak_func error_t tlsComputeMac ( TlsContext context,
TlsEncryptionEngine encryptionEngine,
const void *  record,
const uint8_t *  data,
size_t  dataLen,
uint8_t *  mac 
)

Compute message authentication code.

Parameters
[in]contextPointer to the TLS context
[in]encryptionEnginePointer to the encryption/decryption engine
[in]recordPointer to the TLS record
[in]dataPointer to the record data
[in]dataLenLength of the data
[out]macThe computed MAC value
Returns
Error code

Definition at line 509 of file tls_record_encryption.c.

◆ tlsEncryptAeadRecord()

__weak_func error_t tlsEncryptAeadRecord ( TlsContext context,
TlsEncryptionEngine encryptionEngine,
void *  record 
)

Record encryption (AEAD cipher)

Parameters
[in]contextPointer to the TLS context
[in]encryptionEnginePointer to the encryption engine
[in,out]recordTLS record to be encrypted
Returns
Error code

Definition at line 151 of file tls_record_encryption.c.

◆ tlsEncryptCbcRecord()

__weak_func error_t tlsEncryptCbcRecord ( TlsContext context,
TlsEncryptionEngine encryptionEngine,
void *  record 
)

Record encryption (CBC block cipher)

Parameters
[in]contextPointer to the TLS context
[in]encryptionEnginePointer to the encryption engine
[in,out]recordTLS record to be encrypted
Returns
Error code

Definition at line 288 of file tls_record_encryption.c.

◆ tlsEncryptRecord()

error_t tlsEncryptRecord ( TlsContext context,
TlsEncryptionEngine encryptionEngine,
void *  record 
)

Encrypt an outgoing TLS record.

Parameters
[in]contextPointer to the TLS context
[in]encryptionEnginePointer to the encryption engine
[in,out]recordTLS record to be encrypted
Returns
Error code

Definition at line 55 of file tls_record_encryption.c.

◆ tlsEncryptStreamRecord()

error_t tlsEncryptStreamRecord ( TlsContext context,
TlsEncryptionEngine encryptionEngine,
void *  record 
)

Record encryption (stream cipher)

Parameters
[in]contextPointer to the TLS context
[in]encryptionEnginePointer to the encryption engine
[in,out]recordTLS record to be encrypted
Returns
Error code

Definition at line 383 of file tls_record_encryption.c.