tls_misc.h
Go to the documentation of this file.
1 /**
2  * @file tls_misc.h
3  * @brief TLS helper functions
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneSSL Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _TLS_MISC_H
30 #define _TLS_MISC_H
31 
32 //Dependencies
33 #include "tls.h"
34 
35 //C++ guard
36 #ifdef __cplusplus
37  extern "C" {
38 #endif
39 
40 //TLS related functions
42 
44 
45 error_t tlsSelectVersion(TlsContext *context, uint16_t version);
48 
50  TlsEncryptionEngine *encryptionEngine, TlsConnectionEnd entity,
51  const uint8_t *secret);
52 
53 void tlsFreeEncryptionEngine(TlsEncryptionEngine *encryptionEngine);
54 
55 error_t tlsWriteMpi(const Mpi *a, uint8_t *data, size_t *length);
56 error_t tlsReadMpi(Mpi *a, const uint8_t *data, size_t size, size_t *length);
57 
59  const EcPoint *a, uint8_t *data, size_t *length);
60 
62  EcPoint *a, const uint8_t *data, size_t size, size_t *length);
63 
64 const char_t *tlsGetVersionName(uint16_t version);
65 const HashAlgo *tlsGetHashAlgo(uint8_t hashAlgoId);
66 const EcCurveInfo *tlsGetCurveInfo(TlsContext *context, uint16_t namedCurve);
67 TlsNamedGroup tlsGetNamedCurve(const uint8_t *oid, size_t length);
68 
69 size_t tlsComputeEncryptionOverhead(TlsEncryptionEngine *encryptionEngine,
70  size_t payloadLen);
71 
72 //C++ guard
73 #ifdef __cplusplus
74  }
75 #endif
76 
77 #endif
TLS (Transport Layer Security)
uint16_t version
Definition: dtls_misc.h:163
uint8_t payloadLen
Definition: ipv6.h:341
EC domain parameters.
Definition: ec.h:61
Arbitrary precision integer.
Definition: mpi.h:67
char char_t
Definition: compiler_port.h:41
Elliptic curve parameters.
Definition: ec_curves.h:290
error_t tlsWriteMpi(const Mpi *a, uint8_t *data, size_t *length)
Encode a multiple precision integer to an opaque vector.
Definition: tls_misc.c:641
error_t tlsWriteEcPoint(const EcDomainParameters *params, const EcPoint *a, uint8_t *data, size_t *length)
Encode an EC point to an opaque vector.
Definition: tls_misc.c:712
void tlsProcessError(TlsContext *context, error_t errorCode)
Translate an error code to an alert message.
Definition: tls_misc.c:54
uint8_t a
Definition: ndp.h:407
TlsNamedGroup
Named groups.
Definition: tls.h:1195
Elliptic curve point.
Definition: ec.h:49
error_t tlsSelectCompressMethod(TlsContext *context, uint8_t identifier)
Set compression method.
Definition: tls_misc.c:345
error_t tlsSelectCipherSuite(TlsContext *context, uint16_t identifier)
Set cipher suite.
Definition: tls_misc.c:247
uint16_t errorCode
Definition: tftp_common.h:134
const EcCurveInfo * tlsGetCurveInfo(TlsContext *context, uint16_t namedCurve)
Get the EC domain parameters that match the specified named curve.
Definition: tls_misc.c:897
error_t tlsInitEncryptionEngine(TlsContext *context, TlsEncryptionEngine *encryptionEngine, TlsConnectionEnd entity, const uint8_t *secret)
Initialize encryption engine.
Definition: tls_misc.c:376
Encryption engine.
Definition: tls.h:1926
uint8_t identifier[]
error_t tlsSelectVersion(TlsContext *context, uint16_t version)
Set the TLS version to be used.
Definition: tls_misc.c:219
error_t tlsReadMpi(Mpi *a, const uint8_t *data, size_t size, size_t *length)
Read a multiple precision integer from an opaque vector.
Definition: tls_misc.c:674
error_t
Error codes.
Definition: error.h:40
size_t tlsComputeEncryptionOverhead(TlsEncryptionEngine *encryptionEngine, size_t payloadLen)
Compute overhead caused by encryption.
Definition: tls_misc.c:1170
error_t tlsGenerateRandomValue(TlsContext *context, uint8_t *random)
Generate client or server random value.
Definition: tls_misc.c:158
uint8_t data[]
Definition: dtls_misc.h:167
TlsNamedGroup tlsGetNamedCurve(const uint8_t *oid, size_t length)
Get the named curve that matches the specified OID.
Definition: tls_misc.c:1040
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.
Definition: tls_misc.c:749
void tlsFreeEncryptionEngine(TlsEncryptionEngine *encryptionEngine)
Release encryption engine.
Definition: tls_misc.c:599
const char_t * tlsGetVersionName(uint16_t version)
Convert TLS version to string representation.
Definition: tls_misc.c:795
uint8_t random[32]
Definition: tls.h:1608
TlsConnectionEnd
TLS connection end.
Definition: tls.h:855
Common interface for hash algorithms.
Definition: crypto.h:1054
uint8_t length
Definition: dtls_misc.h:140
uint8_t oid[1]
Definition: mib_common.h:184
#define TlsContext
Definition: tls.h:34
const HashAlgo * tlsGetHashAlgo(uint8_t hashAlgoId)
Get the hash algorithm that matches the specified identifier.
Definition: tls_misc.c:836