Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

tls.h File Reference

tls.h File Reference

TLS (Transport Layer Security) More...

Go to the source code of this file.

Data Structures

struct  TlsCipherSuiteInfo
 Structure describing a cipher suite. More...
struct  TlsSession
 TLS session. More...
struct  TlsCache
 Session cache. More...
struct  TlsCertDesc
 Certificate descriptor. More...
struct  _TlsContext
 TLS context. More...

Typedefs

typedef uint16_t TlsCipherSuite
 Cipher suite.
typedef uint8_t TlsCompressionMethod
 Compression method.
typedef uint8_t TlsSequenceNumber [8]
 Sequence number.
typedef void * TlsIoHandle
 Handle for I/O operations.
typedef error_t(* TlsIoSendCallback )(TlsIoHandle handle, const void *data, size_t length, size_t *written, uint_t flags)
 Send callback function.
typedef error_t(* TlsIoReceiveCallback )(TlsIoHandle handle, void *data, size_t size, size_t *received, uint_t flags)
 Receive callback function.
typedef error_t(* TlsPskCallback )(TlsContext *context, const char_t *pskIdentity)
 Pre-shared key callback function.

Enumerations

enum  TlsConnectionEnd
 

TLS connection end.

More...
enum  TlsClientAuthMode
 

Client authentication mode.

More...
enum  TlsFlags
 

Flags used by read and write functions.

More...
enum  TlsContentType
 

Content type.

More...
enum  TlsMessageType
 

Handshake message type.

More...
enum  TlsAlertLevel
 

Alert level.

More...
enum  TlsAlertDescription
 

Alert description.

More...
enum  TlsCompressionMethodList
 

Compression methods.

More...
enum  TlsKeyExchMethod
 

Key exchange methods.

More...
enum  TlsCertificateType
 

Certificate types.

More...
enum  TlsHashAlgo
 

Hash algorithms.

More...
enum  TlsSignatureAlgo
 

Signature algorithms.

More...
enum  TlsExtensionType
 

TLS extension types.

More...
enum  TlsNameType
 

Name type.

More...
enum  TlsEcNamedCurve
 

EC named curves.

More...
enum  TlsEcPointFormat
 

EC point formats.

More...
enum  TlsEcCurveType
 

EC curve types.

More...
enum  TlsState
 

TLS FSM states.

More...

Functions

TlsContext * tlsInit (void)
 TLS context initialization.
error_t tlsSetIoCallbacks (TlsContext *context, TlsIoHandle handle, TlsIoSendCallback sendCallback, TlsIoReceiveCallback receiveCallback)
 Set send and receive callbacks (I/O abstraction layer)
error_t tlsSetConnectionEnd (TlsContext *context, TlsConnectionEnd entity)
 Set operation mode (client or server)
error_t tlsSetPrng (TlsContext *context, const PrngAlgo *prngAlgo, void *prngContext)
 Set the pseudo-random number generator to be used.
error_t tlsSetServerName (TlsContext *context, const char_t *serverName)
 Set the name of the remote server.
error_t tlsSetCache (TlsContext *context, TlsCache *cache)
 Set session cache.
error_t tlsSetClientAuthMode (TlsContext *context, TlsClientAuthMode mode)
 Set client authentication mode.
error_t tlsSetBufferSize (TlsContext *context, size_t txBufferSize, size_t rxBufferSize)
 Set TLS buffer size.
error_t tlsSetCipherSuites (TlsContext *context, const uint16_t *cipherSuites, uint_t length)
 Specify the list of allowed cipher suites.
error_t tlsSetDhParameters (TlsContext *context, const char_t *params, size_t length)
 Import Diffie-Hellman parameters.
error_t tlsSetAlpnProtocolList (TlsContext *context, const char_t *protocolList)
 Set the list of supported ALPN protocols.
const char_t * tlsGetAlpnProtocol (TlsContext *context)
 Get the name of the negotiated ALPN protocol.
error_t tlsSetPsk (TlsContext *context, const uint8_t *psk, size_t pskLength)
 Set the pre-shared key to be used.
error_t tlsSetPskIdentity (TlsContext *context, const char_t *pskIdentity)
 Set the PSK identity to be used by the client.
error_t tlsSetPskIdentityHint (TlsContext *context, const char_t *pskIdentityHint)
 Set the PSK identity hint to be used by the server.
error_t tlsSetPskCallback (TlsContext *context, TlsPskCallback pskCallback)
 Register the PSK callback function.
error_t tlsSetTrustedCaList (TlsContext *context, const char_t *trustedCaList, size_t length)
 Import a trusted CA list.
error_t tlsAddCertificate (TlsContext *context, const char_t *certChain, size_t certChainLength, const char_t *privateKey, size_t privateKeyLength)
 Import a certificate and the corresponding private key.
error_t tlsConnect (TlsContext *context)
 Initiate the TLS handshake.
error_t tlsWrite (TlsContext *context, const void *data, size_t length, size_t *written, uint_t flags)
 Send application data to the remote host using TLS.
error_t tlsRead (TlsContext *context, void *data, size_t size, size_t *received, uint_t flags)
 Receive application data from a the remote host using TLS.
error_t tlsShutdown (TlsContext *context)
 Gracefully close TLS session.
error_t tlsShutdownEx (TlsContext *context, bool_t waitForCloseNotify)
 Gracefully close TLS session.
void tlsFree (TlsContext *context)
 Release TLS context.
error_t tlsSaveSession (const TlsContext *context, TlsSession *session)
 Save TLS session.
error_t tlsRestoreSession (TlsContext *context, const TlsSession *session)
 Restore TLS session.
TlsCachetlsInitCache (uint_t size)
 Session cache initialization.
void tlsFreeCache (TlsCache *cache)
 Properly dispose a session cache.

Detailed Description

TLS (Transport Layer Security)

License

Copyright (C) 2010-2017 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.7.6

Definition in file tls.h.


Typedef Documentation

typedef uint16_t TlsCipherSuite

Cipher suite.

Definition at line 905 of file tls.h.

typedef uint8_t TlsCompressionMethod

Compression method.

Definition at line 923 of file tls.h.

typedef void* TlsIoHandle

Handle for I/O operations.

Definition at line 1283 of file tls.h.

typedef error_t(* TlsIoReceiveCallback)(TlsIoHandle handle, void *data, size_t size, size_t *received, uint_t flags)

Receive callback function.

Definition at line 1298 of file tls.h.

typedef error_t(* TlsIoSendCallback)(TlsIoHandle handle, const void *data, size_t length, size_t *written, uint_t flags)

Send callback function.

Definition at line 1290 of file tls.h.

typedef error_t(* TlsPskCallback)(TlsContext *context, const char_t *pskIdentity)

Pre-shared key callback function.

Definition at line 1306 of file tls.h.

typedef uint8_t TlsSequenceNumber[8]

Sequence number.

Definition at line 1276 of file tls.h.


Enumeration Type Documentation

Alert description.

Definition at line 625 of file tls.h.

Alert level.

Definition at line 614 of file tls.h.

Certificate types.

Definition at line 704 of file tls.h.

Client authentication mode.

Definition at line 544 of file tls.h.

Compression methods.

Definition at line 665 of file tls.h.

TLS connection end.

Definition at line 533 of file tls.h.

Content type.

Definition at line 575 of file tls.h.

EC curve types.

Definition at line 850 of file tls.h.

EC named curves.

Definition at line 791 of file tls.h.

EC point formats.

Definition at line 838 of file tls.h.

TLS extension types.

Definition at line 753 of file tls.h.

enum TlsFlags

Flags used by read and write functions.

Definition at line 556 of file tls.h.

Hash algorithms.

Definition at line 724 of file tls.h.

Key exchange methods.

Definition at line 676 of file tls.h.

Handshake message type.

Definition at line 590 of file tls.h.

Name type.

Definition at line 781 of file tls.h.

Signature algorithms.

Definition at line 740 of file tls.h.

enum TlsState

TLS FSM states.

Definition at line 862 of file tls.h.


Function Documentation

error_t tlsAddCertificate ( TlsContext *  context,
const char_t *  certChain,
size_t  certChainLength,
const char_t *  privateKey,
size_t  privateKeyLength 
)

Import a certificate and the corresponding private key.

Parameters:
[in]contextPointer to the TLS context
[in]certChainCertificate chain (PEM format)
[in]certChainLengthTotal length of the certificate chain
[in]privateKeyPrivate key (PEM format)
[in]privateKeyLengthTotal length of the private key
Returns:
Error code

Definition at line 674 of file tls.c.

error_t tlsConnect ( TlsContext *  context )

Initiate the TLS handshake.

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

Definition at line 778 of file tls.c.

void tlsFree ( TlsContext *  context )

Release TLS context.

Parameters:
[in]contextPointer to the TLS context

Definition at line 1230 of file tls.c.

void tlsFreeCache ( TlsCache cache )

Properly dispose a session cache.

Parameters:
[in]cachePointer to the session cache to be released

Definition at line 286 of file tls_cache.c.

const char_t* tlsGetAlpnProtocol ( TlsContext *  context )

Get the name of the negotiated ALPN protocol.

Parameters:
[in]contextPointer to the TLS context
Returns:
Pointer to the protocol name

Definition at line 450 of file tls.c.

TlsContext* tlsInit ( void   )

TLS context initialization.

Returns:
Handle referencing the fully initialized TLS context

Definition at line 60 of file tls.c.

TlsCache* tlsInitCache ( uint_t  size )

Session cache initialization.

Parameters:
[in]sizeMaximum number of cache entries
Returns:
Handle referencing the fully initialized session cache

Definition at line 48 of file tls_cache.c.

error_t tlsRead ( TlsContext *  context,
void *  data,
size_t  size,
size_t *  received,
uint_t  flags 
)

Receive application data from a the remote host using TLS.

Parameters:
[in]contextPointer to the TLS context
[out]dataBuffer into which received data will be placed
[in]sizeMaximum number of bytes that can be received
[out]receivedNumber of bytes that have been received
[in]flagsSet of flags that influences the behavior of this function
Returns:
Error code

Definition at line 932 of file tls.c.

error_t tlsRestoreSession ( TlsContext *  context,
const TlsSession session 
)

Restore TLS session.

Parameters:
[in]contextPointer to the TLS context
[in]sessionPointer to the session to be restored
Returns:
Error code

Definition at line 1408 of file tls.c.

error_t tlsSaveSession ( const TlsContext *  context,
TlsSession session 
)

Save TLS session.

Parameters:
[in]contextPointer to the TLS context
[out]sessionBuffer where to store the current session parameters
Returns:
Error code

Definition at line 1372 of file tls.c.

error_t tlsSetAlpnProtocolList ( TlsContext *  context,
const char_t *  protocolList 
)

Set the list of supported ALPN protocols.

Parameters:
[in]contextPointer to the TLS context
[in]protocolListComma-delimited list of supported protocols
Returns:
Error code

Definition at line 402 of file tls.c.

error_t tlsSetBufferSize ( TlsContext *  context,
size_t  txBufferSize,
size_t  rxBufferSize 
)

Set TLS buffer size.

Parameters:
[in]contextPointer to the TLS context
[in]txBufferSizeTX buffer size
[in]rxBufferSizeRX buffer size
Returns:
Error code

Definition at line 310 of file tls.c.

error_t tlsSetCache ( TlsContext *  context,
TlsCache cache 
)

Set session cache.

Parameters:
[in]contextPointer to the TLS context
[in]cacheSession cache that will be used to save/resume TLS sessions
Returns:
Error code

Definition at line 267 of file tls.c.

error_t tlsSetCipherSuites ( TlsContext *  context,
const uint16_t *  cipherSuites,
uint_t  length 
)

Specify the list of allowed cipher suites.

Parameters:
[in]contextPointer to the TLS context
[in]cipherSuitesPointer to the cipher suite list
[in]lengthNumber of cipher suites in the list
Returns:
Error code

Definition at line 347 of file tls.c.

error_t tlsSetClientAuthMode ( TlsContext *  context,
TlsClientAuthMode  mode 
)

Set client authentication mode.

Parameters:
[in]contextPointer to the TLS context
[in]modeClient authentication mode
Returns:
Error code

Definition at line 288 of file tls.c.

error_t tlsSetConnectionEnd ( TlsContext *  context,
TlsConnectionEnd  entity 
)

Set operation mode (client or server)

Parameters:
[in]contextPointer to the TLS context
[in]entitySpecifies whether this entity is considered a client or a server
Returns:
Error code

Definition at line 167 of file tls.c.

error_t tlsSetDhParameters ( TlsContext *  context,
const char_t *  params,
size_t  length 
)

Import Diffie-Hellman parameters.

Parameters:
[in]contextPointer to the TLS context
[in]paramsPEM structure that holds Diffie-Hellman parameters
[in]lengthTotal length of the DER structure
Returns:
Error code

Definition at line 374 of file tls.c.

error_t tlsSetIoCallbacks ( TlsContext *  context,
TlsIoHandle  handle,
TlsIoSendCallback  sendCallback,
TlsIoReceiveCallback  receiveCallback 
)

Set send and receive callbacks (I/O abstraction layer)

Parameters:
[in]contextPointer to the TLS context
[in]handleHandle for I/O operations
[in]sendCallbackSend callback function
[in]receiveCallbackReceive callback function
Returns:
Error code

Definition at line 141 of file tls.c.

error_t tlsSetPrng ( TlsContext *  context,
const PrngAlgo prngAlgo,
void *  prngContext 
)

Set the pseudo-random number generator to be used.

Parameters:
[in]contextPointer to the TLS context
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
Returns:
Error code

Definition at line 192 of file tls.c.

error_t tlsSetPsk ( TlsContext *  context,
const uint8_t *  psk,
size_t  pskLength 
)

Set the pre-shared key to be used.

Parameters:
[in]contextPointer to the TLS context
[in]pskPointer to the pre-shared key
[in]pskLengthLength of the pre-shared key, in bytes
Returns:
Error code

Definition at line 465 of file tls.c.

error_t tlsSetPskCallback ( TlsContext *  context,
TlsPskCallback  pskCallback 
)

Register the PSK callback function.

Parameters:
[in]contextPointer to the TLS context
[in]pskCallbackPSK callback function
Returns:
Error code

Definition at line 617 of file tls.c.

error_t tlsSetPskIdentity ( TlsContext *  context,
const char_t *  pskIdentity 
)

Set the PSK identity to be used by the client.

Parameters:
[in]contextPointer to the TLS context
[in]pskIdentityNULL-terminated string that contains the PSK identity
Returns:
Error code

Definition at line 517 of file tls.c.

error_t tlsSetPskIdentityHint ( TlsContext *  context,
const char_t *  pskIdentityHint 
)

Set the PSK identity hint to be used by the server.

Parameters:
[in]contextPointer to the TLS context
[in]pskIdentityHintNULL-terminated string that contains the PSK identity hint
Returns:
Error code

Definition at line 567 of file tls.c.

error_t tlsSetServerName ( TlsContext *  context,
const char_t *  serverName 
)

Set the name of the remote server.

Parameters:
[in]contextPointer to the TLS context
[in]serverNameFully qualified domain name of the server
Returns:
Error code

Definition at line 218 of file tls.c.

error_t tlsSetTrustedCaList ( TlsContext *  context,
const char_t *  trustedCaList,
size_t  length 
)

Import a trusted CA list.

Parameters:
[in]contextPointer to the TLS context
[in]trustedCaListList of trusted CA (PEM format)
[in]lengthTotal length of the list
Returns:
Error code

Definition at line 645 of file tls.c.

error_t tlsShutdown ( TlsContext *  context )

Gracefully close TLS session.

Parameters:
[in]contextPointer to the TLS context

Definition at line 1097 of file tls.c.

error_t tlsShutdownEx ( TlsContext *  context,
bool_t  waitForCloseNotify 
)

Gracefully close TLS session.

Parameters:
[in]contextPointer to the TLS context
[in]waitForCloseNotifyWait for the close notify alert from the peer

Definition at line 1110 of file tls.c.

error_t tlsWrite ( TlsContext *  context,
const void *  data,
size_t  length,
size_t *  written,
uint_t  flags 
)

Send application data to the remote host using TLS.

Parameters:
[in]contextPointer to the TLS context
[in]dataPointer to a buffer containing the data to be transmitted
[in]lengthNumber of bytes to be transmitted
[out]writtenActual number of bytes written (optional parameter)
[in]flagsSet of flags that influences the behavior of this function
Returns:
Error code

Definition at line 849 of file tls.c.