Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tls_misc.h Source File

tls_misc.h

Go to the documentation of this file.
00001 /**
00002  * @file tls_misc.h
00003  * @brief Helper functions (TLS client and server)
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneSSL Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _TLS_MISC_H
00030 #define _TLS_MISC_H
00031 
00032 //Dependencies
00033 #include "tls.h"
00034 #include "x509.h"
00035 
00036 //TLS related functions
00037 void tlsProcessError(TlsContext *context, error_t errorCode);
00038 
00039 error_t tlsGenerateRandomValue(TlsContext *context, TlsRandom *random);
00040 
00041 error_t tlsSetVersion(TlsContext *context, uint16_t version);
00042 error_t tlsSetCipherSuite(TlsContext *context, uint16_t identifier);
00043 error_t tlsSetCompressionMethod(TlsContext *context, uint8_t identifier);
00044 
00045 error_t tlsSelectSignHashAlgo(TlsContext *context,
00046    TlsSignatureAlgo signAlgo, const TlsSignHashAlgos *supportedSignAlgos);
00047 
00048 error_t tlsSelectNamedCurve(TlsContext *context,
00049    const TlsEllipticCurveList *curveList);
00050 
00051 error_t tlsInitHandshakeHash(TlsContext *context);
00052 void tlsUpdateHandshakeHash(TlsContext *context, const void *data, size_t length);
00053 
00054 error_t tlsFinalizeHandshakeHash(TlsContext *context, const HashAlgo *hash,
00055    const void *hashContext, const char_t *label, uint8_t *output);
00056 
00057 error_t tlsComputeVerifyData(TlsContext *context, TlsConnectionEnd entity);
00058 
00059 error_t tlsInitEncryptionEngine(TlsContext *context);
00060 error_t tlsInitDecryptionEngine(TlsContext *context);
00061 
00062 error_t tlsWriteMpi(const Mpi *a, uint8_t *data, size_t *length);
00063 error_t tlsReadMpi(Mpi *a, const uint8_t *data, size_t size, size_t *length);
00064 
00065 error_t tlsWriteEcPoint(const EcDomainParameters *params,
00066    const EcPoint *a, uint8_t *data, size_t *length);
00067 
00068 error_t tlsReadEcPoint(const EcDomainParameters *params,
00069    EcPoint *a, const uint8_t *data, size_t size, size_t *length);
00070 
00071 error_t tlsGenerateRsaSignature(const RsaPrivateKey *key,
00072    const uint8_t *digest, uint8_t *signature, size_t *signatureLength);
00073 
00074 error_t tlsVerifyRsaSignature(const RsaPublicKey *key,
00075    const uint8_t *digest, const uint8_t *signature, size_t signatureLength);
00076 
00077 error_t tlsGenerateDsaSignature(const PrngAlgo *prngAlgo, void *prngContext, const DsaPrivateKey *key,
00078    const uint8_t *digest, size_t digestLength, uint8_t *signature, size_t *signatureLength);
00079 
00080 error_t tlsVerifyDsaSignature(const DsaPublicKey *key, const uint8_t *digest,
00081    size_t digestLength, const uint8_t *signature, size_t signatureLength);
00082 
00083 error_t tlsGenerateEcdsaSignature(const EcDomainParameters *params,
00084    const PrngAlgo *prngAlgo, void *prngContext, const Mpi *key, const uint8_t *digest,
00085    size_t digestLength, uint8_t *signature, size_t *signatureLength);
00086 
00087 error_t tlsVerifyEcdsaSignature(const EcDomainParameters *params,
00088    const EcPoint *key, const uint8_t *digest, size_t digestLength,
00089    const uint8_t *signature, size_t signatureLength);
00090 
00091 error_t tlsGeneratePskPremasterSecret(TlsContext *context);
00092 error_t tlsGenerateKeys(TlsContext *context);
00093 
00094 error_t tlsPrf(const uint8_t *secret, size_t secretLength, const char_t *label,
00095    const uint8_t *seed, size_t seedLength, uint8_t *output, size_t outputLength);
00096 
00097 error_t tlsPrf2(const HashAlgo *hash, const uint8_t *secret, size_t secretLength,
00098    const char_t *label, const uint8_t *seed, size_t seedLength, uint8_t *output, size_t outputLength);
00099 
00100 bool_t tlsIsCertificateAcceptable(const TlsCertDesc *cert,
00101    const uint8_t *certTypes, size_t numCertTypes, const TlsSignHashAlgos *signHashAlgos,
00102    const TlsEllipticCurveList *curveList, const TlsCertAuthorities *certAuthorities);
00103 
00104 error_t tlsGetCertificateType(const X509CertificateInfo *certInfo, TlsCertificateType *certType,
00105    TlsSignatureAlgo *certSignAlgo, TlsHashAlgo *certHashAlgo, TlsEcNamedCurve *namedCurve);
00106 
00107 const TlsExtension *tlsGetExtension(const uint8_t *data, size_t length, uint16_t type);
00108 const char_t *tlsGetVersionName(uint16_t version);
00109 const HashAlgo *tlsGetHashAlgo(uint8_t hashAlgoId);
00110 const EcCurveInfo *tlsGetCurveInfo(uint16_t namedCurve);
00111 TlsEcNamedCurve tlsGetNamedCurve(const uint8_t *oid, size_t length);
00112 
00113 #endif
00114