tls_signature.c File Reference

RSA/DSA/ECDSA/EdDSA signature generation and verification (TLS 1.3) More...

#include "tls.h"
#include "tls_signature.h"
#include "tls_transcript_hash.h"
#include "tls_misc.h"
#include "pkix/pem_import.h"
#include "pkc/rsa.h"
#include "pkc/dsa.h"
#include "ecc/ecdsa.h"
#include "ecc/eddsa.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 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 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 EddsaMessageChunk *messageChunks, uint8_t *signature, size_t *signatureLen)
 Generate EdDSA signature. More...
 
error_t tlsVerifyEddsaSignature (TlsContext *context, const EddsaMessageChunk *messageChunks, const uint8_t *signature, size_t signatureLen)
 Verify EdDSA signature. More...
 

Detailed Description

RSA/DSA/ECDSA/EdDSA signature generation and verification (TLS 1.3)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2023 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
2.3.2

Definition in file tls_signature.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   TLS_TRACE_LEVEL

Definition at line 32 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 629 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 810 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 1262 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 1365 of file tls_signature.c.

◆ tlsGenerateEddsaSignature()

error_t tlsGenerateEddsaSignature ( TlsContext context,
const EddsaMessageChunk messageChunks,
uint8_t *  signature,
size_t *  signatureLen 
)

Generate EdDSA signature.

Parameters
[in]contextPointer to the TLS context
[in]messageChunksCollection of chunks representing the message to be signed
[out]signatureResulting signature
[out]signatureLenLength of the resulting signature
Returns
Error code

Definition at line 1516 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 1317 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 1448 of file tls_signature.c.

◆ tlsVerifyEddsaSignature()

error_t tlsVerifyEddsaSignature ( TlsContext context,
const EddsaMessageChunk messageChunks,
const uint8_t *  signature,
size_t  signatureLen 
)

Verify EdDSA signature.

Parameters
[in]contextPointer to the TLS context
[in]messageChunksCollection of chunks representing 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 1636 of file tls_signature.c.