tls_signature.c File Reference

RSA/DSA/ECDSA/EdDSA signature generation and verification. More...

#include <string.h>
#include "tls.h"
#include "tls_signature.h"
#include "tls_transcript_hash.h"
#include "tls_misc.h"
#include "certificate/pem_import.h"
#include "pkc/rsa.h"
#include "pkc/dsa.h"
#include "ecc/ecdsa.h"
#include "ecc/ed25519.h"
#include "ecc/ed448.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   TLS_TRACE_LEVEL
 

Functions

error_t tlsSelectSignatureScheme (TlsContext *context, const TlsCertDesc *cert, const TlsSignHashAlgos *supportedSignAlgos)
 Select the algorithm to be used when generating digital signatures. More...
 
error_t tlsGenerateSignature (TlsContext *context, uint8_t *p, size_t *length)
 Digital signature generation(SSL 3.0, TLS 1.0 or TLS 1.1) More...
 
error_t tlsVerifySignature (TlsContext *context, const uint8_t *p, size_t length)
 Digital signature verification (SSL 3.0, TLS 1.0 and TLS 1.1) More...
 
error_t tls12GenerateSignature (TlsContext *context, uint8_t *p, size_t *length)
 Digital signature generation(TLS 1.2) More...
 
error_t tls12VerifySignature (TlsContext *context, const uint8_t *p, size_t length)
 Digital signature verification (TLS 1.2) More...
 
error_t tlsGenerateRsaSignature (const RsaPrivateKey *key, const uint8_t *digest, uint8_t *signature, size_t *signatureLen)
 Generate RSA signature (SSL 3.0, TLS 1.0 and TLS 1.1) More...
 
error_t tlsVerifyRsaSignature (const RsaPublicKey *key, const uint8_t *digest, const uint8_t *signature, size_t signatureLen)
 Verify RSA signature (SSL 3.0, TLS 1.0 and TLS 1.1) More...
 
error_t tlsGenerateDsaSignature (TlsContext *context, const uint8_t *digest, size_t digestLen, uint8_t *signature, size_t *signatureLen)
 Generate DSA signature. More...
 
error_t tlsVerifyDsaSignature (TlsContext *context, const uint8_t *digest, size_t digestLen, const uint8_t *signature, size_t signatureLen)
 Verify DSA signature. More...
 
error_t tlsGenerateEcdsaSignature (TlsContext *context, const uint8_t *digest, size_t digestLen, uint8_t *signature, size_t *signatureLen)
 Generate ECDSA signature. More...
 
error_t tlsVerifyEcdsaSignature (TlsContext *context, const uint8_t *digest, size_t digestLen, const uint8_t *signature, size_t signatureLen)
 Verify ECDSA signature. More...
 
error_t tlsGenerateEddsaSignature (TlsContext *context, const uint8_t *message, size_t messageLen, uint8_t *signature, size_t *signatureLen)
 Generate EdDSA signature. More...
 
error_t tlsVerifyEddsaSignature (TlsContext *context, const uint8_t *message, size_t messageLen, const uint8_t *signature, size_t signatureLen)
 Verify EdDSA signature. More...
 

Detailed Description

RSA/DSA/ECDSA/EdDSA signature generation and verification.

License

Copyright (C) 2010-2018 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.9.0

Definition in file tls_signature.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   TLS_TRACE_LEVEL

Definition at line 30 of file tls_signature.c.

Function Documentation

◆ tls12GenerateSignature()

error_t tls12GenerateSignature ( TlsContext context,
uint8_t *  p,
size_t *  length 
)

Digital signature generation(TLS 1.2)

Parameters
[in]contextPointer to the TLS context
[out]pBuffer where to store the digitally-signed element
[out]lengthLength of the digitally-signed element
Returns
Error code

Definition at line 578 of file tls_signature.c.

◆ tls12VerifySignature()

error_t tls12VerifySignature ( TlsContext context,
const uint8_t *  p,
size_t  length 
)

Digital signature verification (TLS 1.2)

Parameters
[in]contextPointer to the TLS context
[in]pPointer to the digitally-signed element to be verified
[in]lengthLength of the digitally-signed element
Returns
Error code

Definition at line 759 of file tls_signature.c.

◆ tlsGenerateDsaSignature()

error_t tlsGenerateDsaSignature ( TlsContext context,
const uint8_t *  digest,
size_t  digestLen,
uint8_t *  signature,
size_t *  signatureLen 
)

Generate DSA signature.

Parameters
[in]contextPointer to the TLS context
[in]digestDigest of the message to be signed
[in]digestLenLength in octets of the digest
[out]signatureResulting signature
[out]signatureLenLength of the resulting signature
Returns
Error code

Definition at line 1186 of file tls_signature.c.

◆ tlsGenerateEcdsaSignature()

error_t tlsGenerateEcdsaSignature ( TlsContext context,
const uint8_t *  digest,
size_t  digestLen,
uint8_t *  signature,
size_t *  signatureLen 
)

Generate ECDSA signature.

Parameters
[in]contextPointer to the TLS context
[in]digestDigest of the message to be signed
[in]digestLenLength in octets of the digest
[out]signatureResulting signature
[out]signatureLenLength of the resulting signature
Returns
Error code

Definition at line 1284 of file tls_signature.c.

◆ tlsGenerateEddsaSignature()

error_t tlsGenerateEddsaSignature ( TlsContext context,
const uint8_t *  message,
size_t  messageLen,
uint8_t *  signature,
size_t *  signatureLen 
)

Generate EdDSA signature.

Parameters
[in]contextPointer to the TLS context
[in]messagePointer to the message to be signed
[in]messageLenLength of the message, in bytes
[out]signatureResulting signature
[out]signatureLenLength of the resulting signature
Returns
Error code

Definition at line 1431 of file tls_signature.c.

◆ tlsGenerateRsaSignature()

error_t tlsGenerateRsaSignature ( const RsaPrivateKey key,
const uint8_t *  digest,
uint8_t *  signature,
size_t *  signatureLen 
)

Generate RSA signature (SSL 3.0, TLS 1.0 and TLS 1.1)

Parameters
[in]keySigner's RSA private key
[in]digestDigest of the message to be signed
[out]signatureResulting signature
[out]signatureLenLength of the resulting signature
Returns
Error code

Definition at line 932 of file tls_signature.c.

◆ tlsGenerateSignature()

error_t tlsGenerateSignature ( TlsContext context,
uint8_t *  p,
size_t *  length 
)

Digital signature generation(SSL 3.0, TLS 1.0 or TLS 1.1)

Parameters
[in]contextPointer to the TLS context
[out]pBuffer where to store the digitally-signed element
[out]lengthLength of the digitally-signed element
Returns
Error code

Definition at line 357 of file tls_signature.c.

◆ tlsSelectSignatureScheme()

error_t tlsSelectSignatureScheme ( TlsContext context,
const TlsCertDesc cert,
const TlsSignHashAlgos supportedSignAlgos 
)

Select the algorithm to be used when generating digital signatures.

Parameters
[in]contextPointer to the TLS context
[in]certEnd entity certificate
[in]supportedSignAlgosList of supported signature/hash algorithm pairs
Returns
Error code

Definition at line 58 of file tls_signature.c.

◆ tlsVerifyDsaSignature()

error_t tlsVerifyDsaSignature ( TlsContext context,
const uint8_t *  digest,
size_t  digestLen,
const uint8_t *  signature,
size_t  signatureLen 
)

Verify DSA signature.

Parameters
[in]contextPointer to the TLS context
[in]digestDigest of the message whose signature is to be verified
[in]digestLenLength in octets of the digest
[in]signatureSignature to be verified
[in]signatureLenLength of the signature to be verified
Returns
Error code

Definition at line 1241 of file tls_signature.c.

◆ tlsVerifyEcdsaSignature()

error_t tlsVerifyEcdsaSignature ( TlsContext context,
const uint8_t *  digest,
size_t  digestLen,
const uint8_t *  signature,
size_t  signatureLen 
)

Verify ECDSA signature.

Parameters
[in]contextPointer to the TLS context
[in]digestDigest of the message whose signature is to be verified
[in]digestLenLength in octets of the digest
[in]signatureSignature to be verified
[in]signatureLenLength of the signature to be verified
Returns
Error code

Definition at line 1368 of file tls_signature.c.

◆ tlsVerifyEddsaSignature()

error_t tlsVerifyEddsaSignature ( TlsContext context,
const uint8_t *  message,
size_t  messageLen,
const uint8_t *  signature,
size_t  signatureLen 
)

Verify EdDSA signature.

Parameters
[in]contextPointer to the TLS context
[in]messageMessage whose signature is to be verified
[in]messageLenLength of the message, in bytes
[in]signatureSignature to be verified
[in]signatureLenLength of the signature to be verified
Returns
Error code

Definition at line 1550 of file tls_signature.c.

◆ tlsVerifyRsaSignature()

error_t tlsVerifyRsaSignature ( const RsaPublicKey key,
const uint8_t *  digest,
const uint8_t *  signature,
size_t  signatureLen 
)

Verify RSA signature (SSL 3.0, TLS 1.0 and TLS 1.1)

Parameters
[in]keySigner's RSA public key
[in]digestDigest of the message whose signature is to be verified
[in]signatureSignature to be verified
[in]signatureLenLength of the signature to be verified
Returns
Error code

Definition at line 1051 of file tls_signature.c.

◆ tlsVerifySignature()

error_t tlsVerifySignature ( TlsContext context,
const uint8_t *  p,
size_t  length 
)

Digital signature verification (SSL 3.0, TLS 1.0 and TLS 1.1)

Parameters
[in]contextPointer to the TLS context
[in]pPointer to the digitally-signed element to be verified
[in]lengthLength of the digitally-signed element
Returns
Error code

Definition at line 476 of file tls_signature.c.