Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
tls_misc.c File Reference
Helper functions (TLS client and server) More...
Go to the source code of this file.
Functions | |
void | tlsProcessError (TlsContext *context, error_t errorCode) |
Translate an error code to an alert message. | |
error_t | tlsGenerateRandomValue (TlsContext *context, TlsRandom *random) |
Generate client or server random value. | |
error_t | tlsSetVersion (TlsContext *context, uint16_t version) |
Set TLS version to use. | |
error_t | tlsSetCipherSuite (TlsContext *context, uint16_t identifier) |
Set cipher suite. | |
error_t | tlsSetCompressionMethod (TlsContext *context, uint8_t identifier) |
Set compression method. | |
error_t | tlsSelectSignHashAlgo (TlsContext *context, TlsSignatureAlgo signAlgo, const TlsSignHashAlgos *supportedSignAlgos) |
Select the hash algorithm to be used when generating signatures. | |
error_t | tlsSelectNamedCurve (TlsContext *context, const TlsEllipticCurveList *curveList) |
Select the named curve to be used when performing ECDH key exchange. | |
error_t | tlsInitHandshakeHash (TlsContext *context) |
Initialize handshake message hashing. | |
void | tlsUpdateHandshakeHash (TlsContext *context, const void *data, size_t length) |
Update hash value with a handshake message. | |
error_t | tlsFinalizeHandshakeHash (TlsContext *context, const HashAlgo *hash, const void *hashContext, const char_t *label, uint8_t *output) |
Finalize hash calculation from previous handshake messages. | |
error_t | tlsComputeVerifyData (TlsContext *context, TlsConnectionEnd entity) |
Compute verify data from previous handshake messages. | |
error_t | tlsInitEncryptionEngine (TlsContext *context) |
Initialize encryption engine. | |
error_t | tlsInitDecryptionEngine (TlsContext *context) |
Initialize decryption engine. | |
error_t | tlsWriteMpi (const Mpi *a, uint8_t *data, size_t *length) |
Encode a multiple precision integer to an opaque vector. | |
error_t | tlsReadMpi (Mpi *a, const uint8_t *data, size_t size, size_t *length) |
Read a multiple precision integer from an opaque vector. | |
error_t | tlsWriteEcPoint (const EcDomainParameters *params, const EcPoint *a, uint8_t *data, size_t *length) |
Encode an EC point to an opaque vector. | |
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. | |
error_t | tlsGenerateRsaSignature (const RsaPrivateKey *key, const uint8_t *digest, uint8_t *signature, size_t *signatureLength) |
Generate RSA signature (SSL 3.0, TLS 1.0 and TLS 1.1) | |
error_t | tlsVerifyRsaSignature (const RsaPublicKey *key, const uint8_t *digest, const uint8_t *signature, size_t signatureLength) |
Verify RSA signature (SSL 3.0, TLS 1.0 and TLS 1.1) | |
error_t | tlsGenerateDsaSignature (const PrngAlgo *prngAlgo, void *prngContext, const DsaPrivateKey *key, const uint8_t *digest, size_t digestLength, uint8_t *signature, size_t *signatureLength) |
Generate DSA signature. | |
error_t | tlsVerifyDsaSignature (const DsaPublicKey *key, const uint8_t *digest, size_t digestLength, const uint8_t *signature, size_t signatureLength) |
Verify DSA signature. | |
error_t | tlsGenerateEcdsaSignature (const EcDomainParameters *params, const PrngAlgo *prngAlgo, void *prngContext, const Mpi *key, const uint8_t *digest, size_t digestLength, uint8_t *signature, size_t *signatureLength) |
Generate ECDSA signature. | |
error_t | tlsVerifyEcdsaSignature (const EcDomainParameters *params, const EcPoint *key, const uint8_t *digest, size_t digestLength, const uint8_t *signature, size_t signatureLength) |
Verify ECDSA signature. | |
error_t | tlsGeneratePskPremasterSecret (TlsContext *context) |
Premaster secret generation (for PSK cipher suites) | |
error_t | tlsGenerateKeys (TlsContext *context) |
Key generation. | |
error_t | tlsPrf (const uint8_t *secret, size_t secretLength, const char_t *label, const uint8_t *seed, size_t seedLength, uint8_t *output, size_t outputLength) |
Pseudorandom function (TLS 1.0 and 1.1) | |
error_t | tlsPrf2 (const HashAlgo *hash, const uint8_t *secret, size_t secretLength, const char_t *label, const uint8_t *seed, size_t seedLength, uint8_t *output, size_t outputLength) |
Pseudorandom function (TLS 1.2) | |
bool_t | tlsIsCertificateAcceptable (const TlsCertDesc *cert, const uint8_t *certTypes, size_t numCertTypes, const TlsSignHashAlgos *signHashAlgos, const TlsEllipticCurveList *curveList, const TlsCertAuthorities *certAuthorities) |
Check whether a certificate is acceptable. | |
error_t | tlsGetCertificateType (const X509CertificateInfo *certInfo, TlsCertificateType *certType, TlsSignatureAlgo *certSignAlgo, TlsHashAlgo *certHashAlgo, TlsEcNamedCurve *namedCurve) |
Retrieve the certificate type. | |
const TlsExtension * | tlsGetExtension (const uint8_t *data, size_t length, uint16_t type) |
Find the specified extension. | |
const char_t * | tlsGetVersionName (uint16_t version) |
Convert TLS version to string representation. | |
const HashAlgo * | tlsGetHashAlgo (uint8_t hashAlgoId) |
Get the hash algorithm that matches the specified identifier. | |
const EcCurveInfo * | tlsGetCurveInfo (uint16_t namedCurve) |
Get the EC domain parameters that match the specified named curve. | |
TlsEcNamedCurve | tlsGetNamedCurve (const uint8_t *oid, size_t length) |
Get the named curve that matches the specified OID. |
Detailed Description
Helper functions (TLS client and server)
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.
- Version:
- 1.7.6
Definition in file tls_misc.c.
Function Documentation
error_t tlsComputeVerifyData | ( | TlsContext * | context, |
TlsConnectionEnd | entity | ||
) |
Compute verify data from previous handshake messages.
- Parameters:
-
[in] context Pointer to the TLS context [in] entity Specifies whether the computation is performed at client or server side
- Returns:
- Error code
Definition at line 690 of file tls_misc.c.
error_t tlsFinalizeHandshakeHash | ( | TlsContext * | context, |
const HashAlgo * | hash, | ||
const void * | hashContext, | ||
const char_t * | label, | ||
uint8_t * | output | ||
) |
Finalize hash calculation from previous handshake messages.
- Parameters:
-
[in] context Pointer to the TLS context [in] hash Hash function used to digest the handshake messages [in] hashContext Pointer to the hash context [in] label NULL-terminated string [out] output Buffer where to store the resulting hash value
- Returns:
- Error code
Definition at line 609 of file tls_misc.c.
error_t tlsGenerateDsaSignature | ( | const PrngAlgo * | prngAlgo, |
void * | prngContext, | ||
const DsaPrivateKey * | key, | ||
const uint8_t * | digest, | ||
size_t | digestLength, | ||
uint8_t * | signature, | ||
size_t * | signatureLength | ||
) |
Generate DSA signature.
- Parameters:
-
[in] prngAlgo PRNG algorithm [in] prngContext Pointer to the PRNG context [in] key Signer's DSA private key [in] digest Digest of the message to be signed [in] digestLength Length in octets of the digest [out] signature Resulting signature [out] signatureLength Length of the resulting signature
- Returns:
- Error code
Definition at line 1378 of file tls_misc.c.
error_t tlsGenerateEcdsaSignature | ( | const EcDomainParameters * | params, |
const PrngAlgo * | prngAlgo, | ||
void * | prngContext, | ||
const Mpi * | key, | ||
const uint8_t * | digest, | ||
size_t | digestLength, | ||
uint8_t * | signature, | ||
size_t * | signatureLength | ||
) |
Generate ECDSA signature.
- Parameters:
-
[in] params EC domain parameters [in] prngAlgo PRNG algorithm [in] prngContext Pointer to the PRNG context [in] key Signer's ECDSA private key [in] digest Digest of the message to be signed [in] digestLength Length in octets of the digest [out] signature Resulting signature [out] signatureLength Length of the resulting signature
- Returns:
- Error code
Definition at line 1464 of file tls_misc.c.
error_t tlsGenerateKeys | ( | TlsContext * | context ) |
Key generation.
- Parameters:
-
[in] context Pointer to the TLS context
- Returns:
- Error code
Definition at line 1646 of file tls_misc.c.
error_t tlsGeneratePskPremasterSecret | ( | TlsContext * | context ) |
Premaster secret generation (for PSK cipher suites)
- Parameters:
-
[in] context Pointer to the TLS context
- Returns:
- Error code
Definition at line 1547 of file tls_misc.c.
error_t tlsGenerateRandomValue | ( | TlsContext * | context, |
TlsRandom * | random | ||
) |
Generate client or server random value.
- Parameters:
-
[in] context Pointer to the TLS context [out] random Pointer to the random value
- Returns:
- Error code
Definition at line 139 of file tls_misc.c.
error_t tlsGenerateRsaSignature | ( | const RsaPrivateKey * | key, |
const uint8_t * | digest, | ||
uint8_t * | signature, | ||
size_t * | signatureLength | ||
) |
Generate RSA signature (SSL 3.0, TLS 1.0 and TLS 1.1)
- Parameters:
-
[in] key Signer's RSA private key [in] digest Digest of the message to be signed [out] signature Resulting signature [out] signatureLength Length of the resulting signature
- Returns:
- Error code
Definition at line 1125 of file tls_misc.c.
error_t tlsGetCertificateType | ( | const X509CertificateInfo * | certInfo, |
TlsCertificateType * | certType, | ||
TlsSignatureAlgo * | certSignAlgo, | ||
TlsHashAlgo * | certHashAlgo, | ||
TlsEcNamedCurve * | namedCurve | ||
) |
Retrieve the certificate type.
- Parameters:
-
[in] certInfo X.509 certificate [out] certType Certificate type [out] certSignAlgo Signature algorithm that has been used to sign the certificate [out] certHashAlgo Hash algorithm that has been used to sign the certificate [out] namedCurve Elliptic curve (only for ECDSA certificates)
- Returns:
- Error code
Definition at line 2193 of file tls_misc.c.
const EcCurveInfo* tlsGetCurveInfo | ( | uint16_t | namedCurve ) |
Get the EC domain parameters that match the specified named curve.
- Parameters:
-
[in] namedCurve Elliptic curve identifier
- Returns:
- Elliptic curve domain parameters
Definition at line 2487 of file tls_misc.c.
const TlsExtension* tlsGetExtension | ( | const uint8_t * | data, |
size_t | length, | ||
uint16_t | type | ||
) |
Find the specified extension.
- Parameters:
-
[in] data Pointer to the list of extensions [in] length Length in bytes of the list [in] type Expected extension type
- Returns:
- If the specified extension was found, a pointer to the corresponding extension is returned. Otherwise NULL pointer is returned
Definition at line 2372 of file tls_misc.c.
const HashAlgo* tlsGetHashAlgo | ( | uint8_t | hashAlgoId ) |
Get the hash algorithm that matches the specified identifier.
- Parameters:
-
[in] hashAlgoId Hash algorithm identifier
- Returns:
- Cipher suite name
Definition at line 2449 of file tls_misc.c.
TlsEcNamedCurve tlsGetNamedCurve | ( | const uint8_t * | oid, |
size_t | length | ||
) |
Get the named curve that matches the specified OID.
- Parameters:
-
[in] oid Object identifier [in] length OID length
- Returns:
- Named curve
Definition at line 2584 of file tls_misc.c.
const char_t* tlsGetVersionName | ( | uint16_t | version ) |
Convert TLS version to string representation.
- Parameters:
-
[in] version Version number
- Returns:
- Cipher suite name
Definition at line 2424 of file tls_misc.c.
error_t tlsInitDecryptionEngine | ( | TlsContext * | context ) |
Initialize decryption engine.
- Parameters:
-
[in] context Pointer to the TLS context
- Returns:
- Error code
Definition at line 887 of file tls_misc.c.
error_t tlsInitEncryptionEngine | ( | TlsContext * | context ) |
Initialize encryption engine.
- Parameters:
-
[in] context Pointer to the TLS context
- Returns:
- Error code
Definition at line 804 of file tls_misc.c.
error_t tlsInitHandshakeHash | ( | TlsContext * | context ) |
Initialize handshake message hashing.
- Parameters:
-
[in] context Pointer to the TLS context
- Returns:
- Error code
Definition at line 495 of file tls_misc.c.
bool_t tlsIsCertificateAcceptable | ( | const TlsCertDesc * | cert, |
const uint8_t * | certTypes, | ||
size_t | numCertTypes, | ||
const TlsSignHashAlgos * | signHashAlgos, | ||
const TlsEllipticCurveList * | curveList, | ||
const TlsCertAuthorities * | certAuthorities | ||
) |
Check whether a certificate is acceptable.
- Parameters:
-
[in] cert End entity certificate [in] certTypes List of supported certificate types [in] numCertTypes Size of the list that contains the supported certificate types [in] signHashAlgos List of supported signature algorithms [in] curveList List of supported elliptic curves [in] certAuthorities List of trusted CA
- Returns:
- TRUE if the specified certificate conforms to the requirements, else FALSE
Definition at line 2005 of file tls_misc.c.
error_t tlsPrf | ( | const uint8_t * | secret, |
size_t | secretLength, | ||
const char_t * | label, | ||
const uint8_t * | seed, | ||
size_t | seedLength, | ||
uint8_t * | output, | ||
size_t | outputLength | ||
) |
Pseudorandom function (TLS 1.0 and 1.1)
The pseudorandom function (PRF) takes as input a secret, a seed, and an identifying label and produces an output of arbitrary length. This function is used to expand secrets into blocks of data for the purpose of key generation
- Parameters:
-
[in] secret Pointer to the secret [in] secretLength Length of the secret [in] label Identifying label (NULL-terminated string) [in] seed Pointer to the seed [in] seedLength Length of the seed [out] output Pointer to the output [in] outputLength Desired output length
- Returns:
- Error code
Definition at line 1831 of file tls_misc.c.
error_t tlsPrf2 | ( | const HashAlgo * | hash, |
const uint8_t * | secret, | ||
size_t | secretLength, | ||
const char_t * | label, | ||
const uint8_t * | seed, | ||
size_t | seedLength, | ||
uint8_t * | output, | ||
size_t | outputLength | ||
) |
Pseudorandom function (TLS 1.2)
The pseudorandom function (PRF) takes as input a secret, a seed, and an identifying label and produces an output of arbitrary length. This function is used to expand secrets into blocks of data for the purpose of key generation
- Parameters:
-
[in] hash Hash function used to compute PRF [in] secret Pointer to the secret [in] secretLength Length of the secret [in] label Identifying label (NULL-terminated string) [in] seed Pointer to the seed [in] seedLength Length of the seed [out] output Pointer to the output [in] outputLength Desired output length
- Returns:
- Error code
Definition at line 1938 of file tls_misc.c.
void tlsProcessError | ( | TlsContext * | context, |
error_t | errorCode | ||
) |
Translate an error code to an alert message.
- Parameters:
-
[in] context Pointer to the TLS context [in] errorCode Internal error code
- Returns:
- Error code
Definition at line 57 of file tls_misc.c.
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] params EC domain parameters [out] a Resulting EC point [in] data Buffer where to read the opaque vector [in] size Total number of bytes available in the buffer [out] length Total number of bytes that have been read
- Returns:
- Error code
Definition at line 1080 of file tls_misc.c.
Read a multiple precision integer from an opaque vector.
- Parameters:
-
[out] a Resulting multiple precision integer [in] data Buffer where to read the opaque vector [in] size Total number of bytes available in the buffer [out] length Total number of bytes that have been read
- Returns:
- Error code
Definition at line 1005 of file tls_misc.c.
error_t tlsSelectNamedCurve | ( | TlsContext * | context, |
const TlsEllipticCurveList * | curveList | ||
) |
Select the named curve to be used when performing ECDH key exchange.
- Parameters:
-
[in] context Pointer to the TLS context [in] curveList Set of elliptic curves supported by the peer
- Returns:
- Error code
Definition at line 446 of file tls_misc.c.
error_t tlsSelectSignHashAlgo | ( | TlsContext * | context, |
TlsSignatureAlgo | signAlgo, | ||
const TlsSignHashAlgos * | supportedSignAlgos | ||
) |
Select the hash algorithm to be used when generating signatures.
- Parameters:
-
[in] context Pointer to the TLS context [in] signAlgo Desired signature algorithm (RSA, DSA or ECDSA) [in] supportedSignAlgos List of supported signature/hash algorithm pairs
- Returns:
- Error code
Definition at line 355 of file tls_misc.c.
error_t tlsSetCipherSuite | ( | TlsContext * | context, |
uint16_t | identifier | ||
) |
Set cipher suite.
- Parameters:
-
[in] context Pointer to the TLS context [in] identifier Cipher suite identifier
- Returns:
- Error code
Definition at line 210 of file tls_misc.c.
error_t tlsSetCompressionMethod | ( | TlsContext * | context, |
uint8_t | identifier | ||
) |
Set compression method.
- Parameters:
-
[in] context Pointer to the TLS context [in] identifier Compression method identifier
- Returns:
- Error code
Definition at line 334 of file tls_misc.c.
error_t tlsSetVersion | ( | TlsContext * | context, |
uint16_t | version | ||
) |
Set TLS version to use.
- Parameters:
-
[in] context Pointer to the TLS context [in] version TLS version
- Returns:
- Error code
Definition at line 185 of file tls_misc.c.
void tlsUpdateHandshakeHash | ( | TlsContext * | context, |
const void * | data, | ||
size_t | length | ||
) |
Update hash value with a handshake message.
- Parameters:
-
[in] context Pointer to the TLS context [in] data Pointer to the handshake message being hashed [in] length Length of the message
Definition at line 576 of file tls_misc.c.
error_t tlsVerifyDsaSignature | ( | const DsaPublicKey * | key, |
const uint8_t * | digest, | ||
size_t | digestLength, | ||
const uint8_t * | signature, | ||
size_t | signatureLength | ||
) |
Verify DSA signature.
- Parameters:
-
[in] key Signer's DSA public key [in] digest Digest of the message whose signature is to be verified [in] digestLength Length in octets of the digest [in] signature Signature to be verified [in] signatureLength Length of the signature to be verified
- Returns:
- Error code
Definition at line 1420 of file tls_misc.c.
error_t tlsVerifyEcdsaSignature | ( | const EcDomainParameters * | params, |
const EcPoint * | key, | ||
const uint8_t * | digest, | ||
size_t | digestLength, | ||
const uint8_t * | signature, | ||
size_t | signatureLength | ||
) |
Verify ECDSA signature.
- Parameters:
-
[in] params EC domain parameters [in] key Signer's ECDSA public key [in] digest Digest of the message whose signature is to be verified [in] digestLength Length in octets of the digest [in] signature Signature to be verified [in] signatureLength Length of the signature to be verified
- Returns:
- Error code
Definition at line 1508 of file tls_misc.c.
error_t tlsVerifyRsaSignature | ( | const RsaPublicKey * | key, |
const uint8_t * | digest, | ||
const uint8_t * | signature, | ||
size_t | signatureLength | ||
) |
Verify RSA signature (SSL 3.0, TLS 1.0 and TLS 1.1)
- Parameters:
-
[in] key Signer's RSA public key [in] digest Digest of the message whose signature is to be verified [in] signature Signature to be verified [in] signatureLength Length of the signature to be verified
- Returns:
- Error code
Definition at line 1244 of file tls_misc.c.
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] params EC domain parameters [in] a Pointer to an EC point [out] data Buffer where to store the opaque vector [out] length Total number of bytes that have been written
- Returns:
- Error code
Definition at line 1043 of file tls_misc.c.
Encode a multiple precision integer to an opaque vector.
- Parameters:
-
[in] a Pointer to a multiple precision integer [out] data Buffer where to store the opaque vector [out] length Total number of bytes that have been written
- Returns:
- Error code
Definition at line 972 of file tls_misc.c.
Generated on Tue Jul 12 2022 17:10:23 by
