tls_misc.h File Reference

TLS helper functions. More...

#include "tls.h"

Go to the source code of this file.

Functions

void tlsProcessError (TlsContext *context, error_t errorCode)
 Translate an error code to an alert message. More...
 
error_t tlsGenerateRandomValue (TlsContext *context, uint8_t *random)
 Generate client or server random value. More...
 
error_t tlsSelectVersion (TlsContext *context, uint16_t version)
 Set the TLS version to be used. More...
 
error_t tlsSelectCipherSuite (TlsContext *context, uint16_t identifier)
 Set cipher suite. More...
 
error_t tlsSelectCompressMethod (TlsContext *context, uint8_t identifier)
 Set compression method. More...
 
error_t tlsInitEncryptionEngine (TlsContext *context, TlsEncryptionEngine *encryptionEngine, TlsConnectionEnd entity, const uint8_t *secret)
 Initialize encryption engine. More...
 
void tlsFreeEncryptionEngine (TlsEncryptionEngine *encryptionEngine)
 Release encryption engine. More...
 
error_t tlsWriteMpi (const Mpi *a, uint8_t *data, size_t *length)
 Encode a multiple precision integer to an opaque vector. More...
 
error_t tlsReadMpi (Mpi *a, const uint8_t *data, size_t size, size_t *length)
 Read a multiple precision integer from an opaque vector. More...
 
error_t tlsWriteEcPoint (const EcDomainParameters *params, const EcPoint *a, uint8_t *data, size_t *length)
 Encode an EC point to an opaque vector. More...
 
error_t tlsReadEcPoint (const EcDomainParameters *params, EcPoint *a, const uint8_t *data, size_t size, size_t *length)
 Read an EC point from an opaque vector. More...
 
const char_ttlsGetVersionName (uint16_t version)
 Convert TLS version to string representation. More...
 
const HashAlgotlsGetHashAlgo (uint8_t hashAlgoId)
 Get the hash algorithm that matches the specified identifier. More...
 
const EcCurveInfotlsGetCurveInfo (TlsContext *context, uint16_t namedCurve)
 Get the EC domain parameters that match the specified named curve. More...
 
TlsNamedGroup tlsGetNamedCurve (const uint8_t *oid, size_t length)
 Get the named curve that matches the specified OID. More...
 
size_t tlsComputeEncryptionOverhead (TlsEncryptionEngine *encryptionEngine, size_t payloadLen)
 Compute overhead caused by encryption. More...
 

Detailed Description

TLS helper functions.

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_misc.h.

Function Documentation

◆ tlsComputeEncryptionOverhead()

size_t tlsComputeEncryptionOverhead ( TlsEncryptionEngine encryptionEngine,
size_t  payloadLen 
)

Compute overhead caused by encryption.

Parameters
[in]encryptionEnginePointer to the encryption engine
[in]payloadLenLength of the payload, in bytes
Returns
Overhead, in bytes, caused by encryption

Definition at line 1170 of file tls_misc.c.

◆ tlsFreeEncryptionEngine()

void tlsFreeEncryptionEngine ( TlsEncryptionEngine encryptionEngine)

Release encryption engine.

Parameters
[in]encryptionEnginePointer to the encryption/decryption engine

Definition at line 599 of file tls_misc.c.

◆ tlsGenerateRandomValue()

error_t tlsGenerateRandomValue ( TlsContext context,
uint8_t *  random 
)

Generate client or server random value.

Parameters
[in]contextPointer to the TLS context
[out]randomPointer to the random value
Returns
Error code

Definition at line 158 of file tls_misc.c.

◆ tlsGetCurveInfo()

const EcCurveInfo* tlsGetCurveInfo ( TlsContext context,
uint16_t  namedCurve 
)

Get the EC domain parameters that match the specified named curve.

Parameters
[in]contextPointer to the TLS context
[in]namedCurveElliptic curve identifier
Returns
Elliptic curve domain parameters

Definition at line 897 of file tls_misc.c.

◆ tlsGetHashAlgo()

const HashAlgo* tlsGetHashAlgo ( uint8_t  hashAlgoId)

Get the hash algorithm that matches the specified identifier.

Parameters
[in]hashAlgoIdHash algorithm identifier
Returns
Pointer to the hash algorithm

Definition at line 836 of file tls_misc.c.

◆ tlsGetNamedCurve()

TlsNamedGroup tlsGetNamedCurve ( const uint8_t *  oid,
size_t  length 
)

Get the named curve that matches the specified OID.

Parameters
[in]oidObject identifier
[in]lengthOID length
Returns
Named curve

Definition at line 1040 of file tls_misc.c.

◆ tlsGetVersionName()

const char_t* tlsGetVersionName ( uint16_t  version)

Convert TLS version to string representation.

Parameters
[in]versionVersion number
Returns
Cipher suite name

Definition at line 795 of file tls_misc.c.

◆ tlsInitEncryptionEngine()

error_t tlsInitEncryptionEngine ( TlsContext context,
TlsEncryptionEngine encryptionEngine,
TlsConnectionEnd  entity,
const uint8_t *  secret 
)

Initialize encryption engine.

Parameters
[in]contextPointer to the TLS context
[in]encryptionEnginePointer to the encryption/decryption engine to be initialized
[in]entitySpecifies whether client or server write keys shall be used
[in]secretPointer to the secret value
Returns
Error code

Definition at line 376 of file tls_misc.c.

◆ tlsProcessError()

void tlsProcessError ( TlsContext context,
error_t  errorCode 
)

Translate an error code to an alert message.

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

Definition at line 54 of file tls_misc.c.

◆ tlsReadEcPoint()

error_t tlsReadEcPoint ( const EcDomainParameters params,
EcPoint a,
const uint8_t *  data,
size_t  size,
size_t *  length 
)

Read an EC point from an opaque vector.

Parameters
[in]paramsEC domain parameters
[out]aResulting EC point
[in]dataBuffer where to read the opaque vector
[in]sizeTotal number of bytes available in the buffer
[out]lengthTotal number of bytes that have been read
Returns
Error code

Definition at line 749 of file tls_misc.c.

◆ tlsReadMpi()

error_t tlsReadMpi ( Mpi a,
const uint8_t *  data,
size_t  size,
size_t *  length 
)

Read a multiple precision integer from an opaque vector.

Parameters
[out]aResulting multiple precision integer
[in]dataBuffer where to read the opaque vector
[in]sizeTotal number of bytes available in the buffer
[out]lengthTotal number of bytes that have been read
Returns
Error code

Definition at line 674 of file tls_misc.c.

◆ tlsSelectCipherSuite()

error_t tlsSelectCipherSuite ( TlsContext context,
uint16_t  identifier 
)

Set cipher suite.

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

Definition at line 247 of file tls_misc.c.

◆ tlsSelectCompressMethod()

error_t tlsSelectCompressMethod ( TlsContext context,
uint8_t  identifier 
)

Set compression method.

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

Definition at line 345 of file tls_misc.c.

◆ tlsSelectVersion()

error_t tlsSelectVersion ( TlsContext context,
uint16_t  version 
)

Set the TLS version to be used.

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

Definition at line 219 of file tls_misc.c.

◆ tlsWriteEcPoint()

error_t tlsWriteEcPoint ( const EcDomainParameters params,
const EcPoint a,
uint8_t *  data,
size_t *  length 
)

Encode an EC point to an opaque vector.

Parameters
[in]paramsEC domain parameters
[in]aPointer to an EC point
[out]dataBuffer where to store the opaque vector
[out]lengthTotal number of bytes that have been written
Returns
Error code

Definition at line 712 of file tls_misc.c.

◆ tlsWriteMpi()

error_t tlsWriteMpi ( const Mpi a,
uint8_t *  data,
size_t *  length 
)

Encode a multiple precision integer to an opaque vector.

Parameters
[in]aPointer to a multiple precision integer
[out]dataBuffer where to store the opaque vector
[out]lengthTotal number of bytes that have been written
Returns
Error code

Definition at line 641 of file tls_misc.c.