tls_record_encryption.c File Reference

TLS record encryption. More...

#include <string.h>
#include "tls.h"
#include "tls_record.h"
#include "tls_record_encryption.h"
#include "tls_misc.h"
#include "ssl_misc.h"
#include "cipher_mode/cbc.h"
#include "aead/ccm.h"
#include "aead/gcm.h"
#include "aead/chacha20_poly1305.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...
 
error_t tlsEncryptAeadRecord (TlsContext *context, TlsEncryptionEngine *encryptionEngine, void *record)
 Record encryption (AEAD cipher) More...
 
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...
 
error_t tlsComputeMac (TlsContext *context, TlsEncryptionEngine *encryptionEngine, 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-2019 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.2

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 407 of file tls_record_encryption.c.

◆ tlsComputeMac()

error_t tlsComputeMac ( TlsContext context,
TlsEncryptionEngine encryptionEngine,
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 479 of file tls_record_encryption.c.

◆ tlsEncryptAeadRecord()

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 136 of file tls_record_encryption.c.

◆ tlsEncryptCbcRecord()

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 273 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 59 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 366 of file tls_record_encryption.c.