Webserver+3d print
cyclone_ssl/tls_misc.h@0:8918a71cdbe9, 2017-02-04 (annotated)
- Committer:
- Sergunb
- Date:
- Sat Feb 04 18:15:49 2017 +0000
- Revision:
- 0:8918a71cdbe9
nothing else
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sergunb | 0:8918a71cdbe9 | 1 | /** |
Sergunb | 0:8918a71cdbe9 | 2 | * @file tls_misc.h |
Sergunb | 0:8918a71cdbe9 | 3 | * @brief Helper functions (TLS client and server) |
Sergunb | 0:8918a71cdbe9 | 4 | * |
Sergunb | 0:8918a71cdbe9 | 5 | * @section License |
Sergunb | 0:8918a71cdbe9 | 6 | * |
Sergunb | 0:8918a71cdbe9 | 7 | * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. |
Sergunb | 0:8918a71cdbe9 | 8 | * |
Sergunb | 0:8918a71cdbe9 | 9 | * This file is part of CycloneSSL Open. |
Sergunb | 0:8918a71cdbe9 | 10 | * |
Sergunb | 0:8918a71cdbe9 | 11 | * This program is free software; you can redistribute it and/or |
Sergunb | 0:8918a71cdbe9 | 12 | * modify it under the terms of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 13 | * as published by the Free Software Foundation; either version 2 |
Sergunb | 0:8918a71cdbe9 | 14 | * of the License, or (at your option) any later version. |
Sergunb | 0:8918a71cdbe9 | 15 | * |
Sergunb | 0:8918a71cdbe9 | 16 | * This program is distributed in the hope that it will be useful, |
Sergunb | 0:8918a71cdbe9 | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Sergunb | 0:8918a71cdbe9 | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Sergunb | 0:8918a71cdbe9 | 19 | * GNU General Public License for more details. |
Sergunb | 0:8918a71cdbe9 | 20 | * |
Sergunb | 0:8918a71cdbe9 | 21 | * You should have received a copy of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 22 | * along with this program; if not, write to the Free Software Foundation, |
Sergunb | 0:8918a71cdbe9 | 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
Sergunb | 0:8918a71cdbe9 | 24 | * |
Sergunb | 0:8918a71cdbe9 | 25 | * @author Oryx Embedded SARL (www.oryx-embedded.com) |
Sergunb | 0:8918a71cdbe9 | 26 | * @version 1.7.6 |
Sergunb | 0:8918a71cdbe9 | 27 | **/ |
Sergunb | 0:8918a71cdbe9 | 28 | |
Sergunb | 0:8918a71cdbe9 | 29 | #ifndef _TLS_MISC_H |
Sergunb | 0:8918a71cdbe9 | 30 | #define _TLS_MISC_H |
Sergunb | 0:8918a71cdbe9 | 31 | |
Sergunb | 0:8918a71cdbe9 | 32 | //Dependencies |
Sergunb | 0:8918a71cdbe9 | 33 | #include "tls.h" |
Sergunb | 0:8918a71cdbe9 | 34 | #include "x509.h" |
Sergunb | 0:8918a71cdbe9 | 35 | |
Sergunb | 0:8918a71cdbe9 | 36 | //TLS related functions |
Sergunb | 0:8918a71cdbe9 | 37 | void tlsProcessError(TlsContext *context, error_t errorCode); |
Sergunb | 0:8918a71cdbe9 | 38 | |
Sergunb | 0:8918a71cdbe9 | 39 | error_t tlsGenerateRandomValue(TlsContext *context, TlsRandom *random); |
Sergunb | 0:8918a71cdbe9 | 40 | |
Sergunb | 0:8918a71cdbe9 | 41 | error_t tlsSetVersion(TlsContext *context, uint16_t version); |
Sergunb | 0:8918a71cdbe9 | 42 | error_t tlsSetCipherSuite(TlsContext *context, uint16_t identifier); |
Sergunb | 0:8918a71cdbe9 | 43 | error_t tlsSetCompressionMethod(TlsContext *context, uint8_t identifier); |
Sergunb | 0:8918a71cdbe9 | 44 | |
Sergunb | 0:8918a71cdbe9 | 45 | error_t tlsSelectSignHashAlgo(TlsContext *context, |
Sergunb | 0:8918a71cdbe9 | 46 | TlsSignatureAlgo signAlgo, const TlsSignHashAlgos *supportedSignAlgos); |
Sergunb | 0:8918a71cdbe9 | 47 | |
Sergunb | 0:8918a71cdbe9 | 48 | error_t tlsSelectNamedCurve(TlsContext *context, |
Sergunb | 0:8918a71cdbe9 | 49 | const TlsEllipticCurveList *curveList); |
Sergunb | 0:8918a71cdbe9 | 50 | |
Sergunb | 0:8918a71cdbe9 | 51 | error_t tlsInitHandshakeHash(TlsContext *context); |
Sergunb | 0:8918a71cdbe9 | 52 | void tlsUpdateHandshakeHash(TlsContext *context, const void *data, size_t length); |
Sergunb | 0:8918a71cdbe9 | 53 | |
Sergunb | 0:8918a71cdbe9 | 54 | error_t tlsFinalizeHandshakeHash(TlsContext *context, const HashAlgo *hash, |
Sergunb | 0:8918a71cdbe9 | 55 | const void *hashContext, const char_t *label, uint8_t *output); |
Sergunb | 0:8918a71cdbe9 | 56 | |
Sergunb | 0:8918a71cdbe9 | 57 | error_t tlsComputeVerifyData(TlsContext *context, TlsConnectionEnd entity); |
Sergunb | 0:8918a71cdbe9 | 58 | |
Sergunb | 0:8918a71cdbe9 | 59 | error_t tlsInitEncryptionEngine(TlsContext *context); |
Sergunb | 0:8918a71cdbe9 | 60 | error_t tlsInitDecryptionEngine(TlsContext *context); |
Sergunb | 0:8918a71cdbe9 | 61 | |
Sergunb | 0:8918a71cdbe9 | 62 | error_t tlsWriteMpi(const Mpi *a, uint8_t *data, size_t *length); |
Sergunb | 0:8918a71cdbe9 | 63 | error_t tlsReadMpi(Mpi *a, const uint8_t *data, size_t size, size_t *length); |
Sergunb | 0:8918a71cdbe9 | 64 | |
Sergunb | 0:8918a71cdbe9 | 65 | error_t tlsWriteEcPoint(const EcDomainParameters *params, |
Sergunb | 0:8918a71cdbe9 | 66 | const EcPoint *a, uint8_t *data, size_t *length); |
Sergunb | 0:8918a71cdbe9 | 67 | |
Sergunb | 0:8918a71cdbe9 | 68 | error_t tlsReadEcPoint(const EcDomainParameters *params, |
Sergunb | 0:8918a71cdbe9 | 69 | EcPoint *a, const uint8_t *data, size_t size, size_t *length); |
Sergunb | 0:8918a71cdbe9 | 70 | |
Sergunb | 0:8918a71cdbe9 | 71 | error_t tlsGenerateRsaSignature(const RsaPrivateKey *key, |
Sergunb | 0:8918a71cdbe9 | 72 | const uint8_t *digest, uint8_t *signature, size_t *signatureLength); |
Sergunb | 0:8918a71cdbe9 | 73 | |
Sergunb | 0:8918a71cdbe9 | 74 | error_t tlsVerifyRsaSignature(const RsaPublicKey *key, |
Sergunb | 0:8918a71cdbe9 | 75 | const uint8_t *digest, const uint8_t *signature, size_t signatureLength); |
Sergunb | 0:8918a71cdbe9 | 76 | |
Sergunb | 0:8918a71cdbe9 | 77 | error_t tlsGenerateDsaSignature(const PrngAlgo *prngAlgo, void *prngContext, const DsaPrivateKey *key, |
Sergunb | 0:8918a71cdbe9 | 78 | const uint8_t *digest, size_t digestLength, uint8_t *signature, size_t *signatureLength); |
Sergunb | 0:8918a71cdbe9 | 79 | |
Sergunb | 0:8918a71cdbe9 | 80 | error_t tlsVerifyDsaSignature(const DsaPublicKey *key, const uint8_t *digest, |
Sergunb | 0:8918a71cdbe9 | 81 | size_t digestLength, const uint8_t *signature, size_t signatureLength); |
Sergunb | 0:8918a71cdbe9 | 82 | |
Sergunb | 0:8918a71cdbe9 | 83 | error_t tlsGenerateEcdsaSignature(const EcDomainParameters *params, |
Sergunb | 0:8918a71cdbe9 | 84 | const PrngAlgo *prngAlgo, void *prngContext, const Mpi *key, const uint8_t *digest, |
Sergunb | 0:8918a71cdbe9 | 85 | size_t digestLength, uint8_t *signature, size_t *signatureLength); |
Sergunb | 0:8918a71cdbe9 | 86 | |
Sergunb | 0:8918a71cdbe9 | 87 | error_t tlsVerifyEcdsaSignature(const EcDomainParameters *params, |
Sergunb | 0:8918a71cdbe9 | 88 | const EcPoint *key, const uint8_t *digest, size_t digestLength, |
Sergunb | 0:8918a71cdbe9 | 89 | const uint8_t *signature, size_t signatureLength); |
Sergunb | 0:8918a71cdbe9 | 90 | |
Sergunb | 0:8918a71cdbe9 | 91 | error_t tlsGeneratePskPremasterSecret(TlsContext *context); |
Sergunb | 0:8918a71cdbe9 | 92 | error_t tlsGenerateKeys(TlsContext *context); |
Sergunb | 0:8918a71cdbe9 | 93 | |
Sergunb | 0:8918a71cdbe9 | 94 | error_t tlsPrf(const uint8_t *secret, size_t secretLength, const char_t *label, |
Sergunb | 0:8918a71cdbe9 | 95 | const uint8_t *seed, size_t seedLength, uint8_t *output, size_t outputLength); |
Sergunb | 0:8918a71cdbe9 | 96 | |
Sergunb | 0:8918a71cdbe9 | 97 | error_t tlsPrf2(const HashAlgo *hash, const uint8_t *secret, size_t secretLength, |
Sergunb | 0:8918a71cdbe9 | 98 | const char_t *label, const uint8_t *seed, size_t seedLength, uint8_t *output, size_t outputLength); |
Sergunb | 0:8918a71cdbe9 | 99 | |
Sergunb | 0:8918a71cdbe9 | 100 | bool_t tlsIsCertificateAcceptable(const TlsCertDesc *cert, |
Sergunb | 0:8918a71cdbe9 | 101 | const uint8_t *certTypes, size_t numCertTypes, const TlsSignHashAlgos *signHashAlgos, |
Sergunb | 0:8918a71cdbe9 | 102 | const TlsEllipticCurveList *curveList, const TlsCertAuthorities *certAuthorities); |
Sergunb | 0:8918a71cdbe9 | 103 | |
Sergunb | 0:8918a71cdbe9 | 104 | error_t tlsGetCertificateType(const X509CertificateInfo *certInfo, TlsCertificateType *certType, |
Sergunb | 0:8918a71cdbe9 | 105 | TlsSignatureAlgo *certSignAlgo, TlsHashAlgo *certHashAlgo, TlsEcNamedCurve *namedCurve); |
Sergunb | 0:8918a71cdbe9 | 106 | |
Sergunb | 0:8918a71cdbe9 | 107 | const TlsExtension *tlsGetExtension(const uint8_t *data, size_t length, uint16_t type); |
Sergunb | 0:8918a71cdbe9 | 108 | const char_t *tlsGetVersionName(uint16_t version); |
Sergunb | 0:8918a71cdbe9 | 109 | const HashAlgo *tlsGetHashAlgo(uint8_t hashAlgoId); |
Sergunb | 0:8918a71cdbe9 | 110 | const EcCurveInfo *tlsGetCurveInfo(uint16_t namedCurve); |
Sergunb | 0:8918a71cdbe9 | 111 | TlsEcNamedCurve tlsGetNamedCurve(const uint8_t *oid, size_t length); |
Sergunb | 0:8918a71cdbe9 | 112 | |
Sergunb | 0:8918a71cdbe9 | 113 | #endif |
Sergunb | 0:8918a71cdbe9 | 114 |