tls13_sign_verify.c
Go to the documentation of this file.
1 /**
2  * @file tls13_sign_verify.c
3  * @brief RSA/DSA/ECDSA/SM2/EdDSA signature verification (TLS 1.3)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSSL Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL TLS_TRACE_LEVEL
33 
34 //Dependencies
35 #include "tls.h"
36 #include "tls_sign_verify.h"
37 #include "tls_sign_misc.h"
38 #include "tls_transcript_hash.h"
39 #include "tls_misc.h"
40 #include "tls13_sign_verify.h"
41 #include "debug.h"
42 
43 //Check TLS library configuration
44 #if (TLS_SUPPORT == ENABLED && TLS_MAX_VERSION >= TLS_VERSION_1_3)
45 
46 
47 /**
48  * @brief Digital signature verification (TLS 1.3)
49  * @param[in] context Pointer to the TLS context
50  * @param[in] p Pointer to the digitally-signed element to be verified
51  * @param[in] length Length of the digitally-signed element
52  * @return Error code
53  **/
54 
55 error_t tls13VerifySignature(TlsContext *context, const uint8_t *p,
56  size_t length)
57 {
58  error_t error;
59  size_t n;
60  uint8_t *buffer;
61  TlsSignatureScheme signScheme;
62  const Tls13DigitalSignature *signature;
63  const HashAlgo *hashAlgo;
64 
65  //Point to the digitally-signed element
66  signature = (Tls13DigitalSignature *) p;
67 
68  //Malformed CertificateVerify message?
69  if(length < sizeof(Tls13DigitalSignature))
70  return ERROR_DECODING_FAILED;
71  if(length != (sizeof(Tls13DigitalSignature) + ntohs(signature->length)))
72  return ERROR_DECODING_FAILED;
73 
74  //The signature algorithm must be one of those offered in the
75  //SignatureAlgorithms extension (refer to RFC 8446, section 4.4.3)
76  if(!tlsIsSignAlgoSupported(context, ntohs(signature->algorithm)))
78 
79  //The hash function used by HKDF is the cipher suite hash algorithm
80  hashAlgo = context->cipherSuite.prfHashAlgo;
81  //Make sure the hash algorithm is valid
82  if(hashAlgo == NULL)
83  return ERROR_FAILURE;
84 
85  //Calculate the length of the content covered by the digital signature
86  n = hashAlgo->digestSize + 98;
87 
88  //Allocate a memory buffer
89  buffer = tlsAllocMem(n);
90 
91  //Successful memory allocation?
92  if(buffer != NULL)
93  {
94  //Form a string that consists of octet 32 (0x20) repeated 64 times
95  osMemset(buffer, ' ', 64);
96 
97  //Append the context string. It is used to provide separation between
98  //signatures made in different contexts, helping against potential
99  //cross-protocol attacks
100  if(context->entity == TLS_CONNECTION_END_CLIENT)
101  {
102  osMemcpy(buffer + 64, "TLS 1.3, server CertificateVerify", 33);
103  }
104  else
105  {
106  osMemcpy(buffer + 64, "TLS 1.3, client CertificateVerify", 33);
107  }
108 
109  //Append a single 0 byte which serves as the separator
110  buffer[97] = 0x00;
111 
112  //Compute the transcript hash
113  error = tlsFinalizeTranscriptHash(context, hashAlgo,
114  context->transcriptHashContext, "", buffer + 98);
115 
116  //Check status code
117  if(!error)
118  {
119  //The algorithm field specifies the signature scheme
120  signScheme = (TlsSignatureScheme) ntohs(signature->algorithm);
121 
122 #if (TLS_RSA_PSS_SIGN_SUPPORT == ENABLED)
123  //RSASSA-PSS signature scheme?
124  if(signScheme == TLS_SIGN_SCHEME_RSA_PSS_RSAE_SHA256 ||
125  signScheme == TLS_SIGN_SCHEME_RSA_PSS_RSAE_SHA384 ||
126  signScheme == TLS_SIGN_SCHEME_RSA_PSS_RSAE_SHA512 ||
127  signScheme == TLS_SIGN_SCHEME_RSA_PSS_PSS_SHA256 ||
128  signScheme == TLS_SIGN_SCHEME_RSA_PSS_PSS_SHA384 ||
130  {
131  //Verify RSA-PSS signature
132  error = tls13VerifyRsaPssSignature(context, buffer, n, signature);
133  }
134  else
135 #endif
136 #if (TLS_ECDSA_SIGN_SUPPORT == ENABLED)
137  //ECDSA signature scheme?
138  if(signScheme == TLS_SIGN_SCHEME_ECDSA_SECP256R1_SHA256 ||
144  {
145  //Verify ECDSA signature
146  error = tls13VerifyEcdsaSignature(context, buffer, n, signature);
147  }
148  else
149 #endif
150 #if (TLS_SM2_SIGN_SUPPORT == ENABLED)
151  //SM2 signature scheme?
152  if(signScheme == TLS_SIGN_SCHEME_SM2SIG_SM3)
153  {
154  //Verify SM2 signature
155  error = tls13VerifySm2Signature(context, buffer, n, signature);
156  }
157  else
158 #endif
159 #if (TLS_ED25519_SIGN_SUPPORT == ENABLED)
160  //Ed25519 signature scheme?
161  if(signScheme == TLS_SIGN_SCHEME_ED25519)
162  {
163  //Verify Ed25519 signature
164  error = tls13VerifyEd25519Signature(context, buffer, n, signature);
165  }
166  else
167 #endif
168 #if (TLS_ED448_SIGN_SUPPORT == ENABLED)
169  //Ed448 signature scheme?
170  if(signScheme == TLS_SIGN_SCHEME_ED448)
171  {
172  //Verify Ed448 signature
173  error = tls13VerifyEd448Signature(context, buffer, n, signature);
174  }
175  else
176 #endif
177  //Unknown signature scheme?
178  {
179  //Report an error
180  error = ERROR_ILLEGAL_PARAMETER;
181  }
182  }
183 
184  //Release memory buffer
185  tlsFreeMem(buffer);
186  }
187  else
188  {
189  //Failed to allocate memory
190  error = ERROR_OUT_OF_MEMORY;
191  }
192 
193  //Return status code
194  return error;
195 }
196 
197 
198 /**
199  * @brief RSA-PSS signature verification (TLS 1.3)
200  * @param[in] context Pointer to the TLS context
201  * @param[in] message Message whose signature is to be verified
202  * @param[in] length Length of the message, in bytes
203  * @param[in] signature Pointer to the digital signature to be verified
204  * @return Error code
205  **/
206 
208  size_t length, const Tls13DigitalSignature *signature)
209 {
210 #if (TLS_RSA_PSS_SIGN_SUPPORT == ENABLED)
211  error_t error;
212  TlsSignatureScheme signScheme;
213  const HashAlgo *hashAlgo;
214 
215  //The algorithm field specifies the signature scheme
216  signScheme = (TlsSignatureScheme) ntohs(signature->algorithm);
217 
218  //The signature algorithm must be compatible with the key in the sender's
219  //end-entity certificate (refer to RFC 8446, section 4.4.3)
220  if(context->peerCertType == TLS_CERT_RSA_SIGN)
221  {
222  //Retrieve the hash algorithm used for signing
223  if(signScheme == TLS_SIGN_SCHEME_RSA_PSS_RSAE_SHA256)
224  {
225  //Select SHA-256 hash algorithm
227  }
228  else if(signScheme == TLS_SIGN_SCHEME_RSA_PSS_RSAE_SHA384)
229  {
230  //Select SHA-384 hash algorithm
232  }
233  else if(signScheme == TLS_SIGN_SCHEME_RSA_PSS_RSAE_SHA512)
234  {
235  //Select SHA-512 hash algorithm
237  }
238  else
239  {
240  //Invalid signature scheme
241  hashAlgo = NULL;
242  }
243  }
244  else if(context->peerCertType == TLS_CERT_RSA_PSS_SIGN)
245  {
246  //Retrieve the hash algorithm used for signing
247  if(signScheme == TLS_SIGN_SCHEME_RSA_PSS_PSS_SHA256)
248  {
249  //Select SHA-256 hash algorithm
251  }
252  else if(signScheme == TLS_SIGN_SCHEME_RSA_PSS_PSS_SHA384)
253  {
254  //Select SHA-384 hash algorithm
256  }
257  else if(signScheme == TLS_SIGN_SCHEME_RSA_PSS_PSS_SHA512)
258  {
259  //Select SHA-512 hash algorithm
261  }
262  else
263  {
264  //Invalid signature scheme
265  hashAlgo = NULL;
266  }
267  }
268  else
269  {
270  //Invalid certificate
271  hashAlgo = NULL;
272  }
273 
274  //Pre-hash the content covered by the digital signature
275  if(hashAlgo != NULL)
276  {
277  error = hashAlgo->compute(message, length, context->clientVerifyData);
278  }
279  else
280  {
281  error = ERROR_ILLEGAL_PARAMETER;
282  }
283 
284  //Check status code
285  if(!error)
286  {
287  //Verify RSASSA-PSS signature
288  error = rsassaPssVerify(&context->peerRsaPublicKey, hashAlgo,
289  hashAlgo->digestSize, context->clientVerifyData, signature->value,
290  ntohs(signature->length));
291  }
292 
293  //Return status code
294  return error;
295 #else
296  //RSA-PSS signature algorithm not implemented
297  return ERROR_NOT_IMPLEMENTED;
298 #endif
299 }
300 
301 
302 /**
303  * @brief ECDSA signature verification (TLS 1.3)
304  * @param[in] context Pointer to the TLS context
305  * @param[in] message Message whose signature is to be verified
306  * @param[in] length Length of the message, in bytes
307  * @param[in] signature Pointer to the digital signature to be verified
308  * @return Error code
309  **/
310 
312  size_t length, const Tls13DigitalSignature *signature)
313 {
314 #if (TLS_ECDSA_SIGN_SUPPORT == ENABLED)
315  error_t error;
316  TlsSignatureScheme signScheme;
317  const HashAlgo *hashAlgo;
318 
319  //The algorithm field specifies the signature scheme
320  signScheme = (TlsSignatureScheme) ntohs(signature->algorithm);
321 
322  //The signature algorithm must be compatible with the key in the sender's
323  //end-entity certificate (refer to RFC 8446, section 4.4.3)
324  if(context->peerCertType == TLS_CERT_ECDSA_SIGN)
325  {
326  //Retrieve the hash algorithm used for signing
327  if(context->peerEcParams.name == NULL)
328  {
329  //Invalid signature scheme
330  hashAlgo = NULL;
331  }
332  else if(signScheme == TLS_SIGN_SCHEME_ECDSA_SECP256R1_SHA256 &&
333  osStrcmp(context->peerEcParams.name, "secp256r1") == 0)
334  {
335  //Select SHA-256 hash algorithm
337  }
338  else if(signScheme == TLS_SIGN_SCHEME_ECDSA_SECP384R1_SHA384 &&
339  osStrcmp(context->peerEcParams.name, "secp384r1") == 0)
340  {
341  //Select SHA-384 hash algorithm
343  }
344  else if(signScheme == TLS_SIGN_SCHEME_ECDSA_SECP521R1_SHA512 &&
345  osStrcmp(context->peerEcParams.name, "secp521r1") == 0)
346  {
347  //Select SHA-512 hash algorithm
349  }
350  else if(signScheme == TLS_SIGN_SCHEME_ECDSA_BP256R1_TLS13_SHA256 &&
351  osStrcmp(context->peerEcParams.name, "brainpoolP256r1") == 0)
352  {
353  //Select SHA-256 hash algorithm
355  }
356  else if(signScheme == TLS_SIGN_SCHEME_ECDSA_BP384R1_TLS13_SHA384 &&
357  osStrcmp(context->peerEcParams.name, "brainpoolP384r1") == 0)
358  {
359  //Select SHA-384 hash algorithm
361  }
362  else if(signScheme == TLS_SIGN_SCHEME_ECDSA_BP512R1_TLS13_SHA512 &&
363  osStrcmp(context->peerEcParams.name, "brainpoolP512r1") == 0)
364  {
365  //Select SHA-512 hash algorithm
367  }
368  else
369  {
370  //Invalid signature scheme
371  hashAlgo = NULL;
372  }
373  }
374  else
375  {
376  //Invalid certificate
377  hashAlgo = NULL;
378  }
379 
380  //Pre-hash the content covered by the digital signature
381  if(hashAlgo != NULL)
382  {
383  error = hashAlgo->compute(message, length, context->clientVerifyData);
384  }
385  else
386  {
387  error = ERROR_ILLEGAL_PARAMETER;
388  }
389 
390  //Check status code
391  if(!error)
392  {
393  //Verify ECDSA signature
394  error = tlsVerifyEcdsaSignature(context, context->clientVerifyData,
395  hashAlgo->digestSize, signature->value, ntohs(signature->length));
396  }
397 
398  //Return status code
399  return error;
400 #else
401  //ECDSA signature algorithm not implemented
402  return ERROR_NOT_IMPLEMENTED;
403 #endif
404 }
405 
406 
407 /**
408  * @brief SM2 signature verification (TLS 1.3)
409  * @param[in] context Pointer to the TLS context
410  * @param[in] message Message whose signature is to be verified
411  * @param[in] length Length of the message, in bytes
412  * @param[in] signature Pointer to the digital signature to be verified
413  * @return Error code
414  **/
415 
417  size_t length, const Tls13DigitalSignature *signature)
418 {
419 #if (TLS_SM2_SIGN_SUPPORT == ENABLED)
420  error_t error;
421  EcdsaSignature sm2Signature;
422 
423  //The signature algorithm must be compatible with the key in the sender's
424  //end-entity certificate (refer to RFC 8446, section 4.4.3)
425  if(context->peerCertType == TLS_CERT_SM2_SIGN)
426  {
427  //Initialize SM2 signature
428  ecdsaInitSignature(&sm2Signature);
429 
430  //Read the ASN.1 encoded SM2 signature
431  error = ecdsaReadSignature(signature->value, ntohs(signature->length),
432  &sm2Signature);
433 
434  //Check status code
435  if(!error)
436  {
437  //Verify SM2 signature
438  error = sm2VerifySignature(&context->peerEcParams,
439  &context->peerEcPublicKey, SM3_HASH_ALGO, SM2_TLS13_ID,
440  osStrlen(SM2_TLS13_ID), message, length, &sm2Signature);
441  }
442 
443  //Free previously allocated resources
444  ecdsaFreeSignature(&sm2Signature);
445  }
446  else
447  {
448  //Invalid certificate
449  error = ERROR_ILLEGAL_PARAMETER;
450  }
451 
452  //Return status code
453  return error;
454 #else
455  //SM2 signature algorithm not implemented
456  return ERROR_NOT_IMPLEMENTED;
457 #endif
458 }
459 
460 
461 /**
462  * @brief Ed25519 signature verification (TLS 1.3)
463  * @param[in] context Pointer to the TLS context
464  * @param[in] message Message whose signature is to be verified
465  * @param[in] length Length of the message, in bytes
466  * @param[in] signature Pointer to the digital signature to be verified
467  * @return Error code
468  **/
469 
471  size_t length, const Tls13DigitalSignature *signature)
472 {
473 #if (TLS_ED25519_SIGN_SUPPORT == ENABLED)
474  error_t error;
475  DataChunk messageChunks[2];
476 
477  //The signature algorithm must be compatible with the key in the sender's
478  //end-entity certificate (refer to RFC 8446, section 4.4.3)
479  if(context->peerCertType == TLS_CERT_ED25519_SIGN)
480  {
481  //Data to be verified is run through the EdDSA algorithm without pre-hashing
482  messageChunks[0].buffer = message;
483  messageChunks[0].length = length;
484  messageChunks[1].buffer = NULL;
485  messageChunks[1].length = 0;
486 
487  //Verify Ed25519 signature (PureEdDSA mode)
488  error = tlsVerifyEd25519Signature(context, messageChunks,
489  signature->value, ntohs(signature->length));
490  }
491  else
492  {
493  //Invalid certificate
494  error = ERROR_ILLEGAL_PARAMETER;
495  }
496 
497  //Return status code
498  return error;
499 #else
500  //Ed25519 signature algorithm not implemented
501  return ERROR_NOT_IMPLEMENTED;
502 #endif
503 }
504 
505 
506 /**
507  * @brief Ed448 signature verification (TLS 1.3)
508  * @param[in] context Pointer to the TLS context
509  * @param[in] message Message whose signature is to be verified
510  * @param[in] length Length of the message, in bytes
511  * @param[in] signature Pointer to the digital signature to be verified
512  * @return Error code
513  **/
514 
516  size_t length, const Tls13DigitalSignature *signature)
517 {
518 #if (TLS_ED448_SIGN_SUPPORT == ENABLED)
519  error_t error;
520  DataChunk messageChunks[2];
521 
522  //The signature algorithm must be compatible with the key in the sender's
523  //end-entity certificate (refer to RFC 8446, section 4.4.3)
524  if(context->peerCertType == TLS_CERT_ED448_SIGN)
525  {
526  //Data to be verified is run through the EdDSA algorithm without pre-hashing
527  messageChunks[0].buffer = message;
528  messageChunks[0].length = length;
529  messageChunks[1].buffer = NULL;
530  messageChunks[1].length = 0;
531 
532  //Verify Ed448 signature (PureEdDSA mode)
533  error = tlsVerifyEd448Signature(context, messageChunks,
534  signature->value, ntohs(signature->length));
535  }
536  else
537  {
538  //Invalid certificate
539  error = ERROR_ILLEGAL_PARAMETER;
540  }
541 
542  //Return status code
543  return error;
544 #else
545  //Ed448 signature algorithm not implemented
546  return ERROR_NOT_IMPLEMENTED;
547 #endif
548 }
549 
550 #endif
#define tlsAllocMem(size)
Definition: tls.h:853
ECDSA signature.
Definition: ecdsa.h:49
TLS helper functions.
@ TLS_SIGN_SCHEME_ECDSA_BP256R1_TLS13_SHA256
Definition: tls.h:1263
error_t tls13VerifyEd25519Signature(TlsContext *context, const uint8_t *message, size_t length, const Tls13DigitalSignature *signature)
Ed25519 signature verification (TLS 1.3)
RSA/DSA/ECDSA/SM2/EdDSA signature verification (TLS 1.3)
const HashAlgo * tlsGetHashAlgo(TlsHashAlgo hashAlgoId)
Get the hash algorithm that matches the specified identifier.
Definition: tls_misc.c:1173
@ TLS_SIGN_SCHEME_RSA_PSS_RSAE_SHA256
Definition: tls.h:1253
@ ERROR_NOT_IMPLEMENTED
Definition: error.h:66
@ ERROR_ILLEGAL_PARAMETER
Definition: error.h:243
error_t tls13VerifySignature(TlsContext *context, const uint8_t *p, size_t length)
Digital signature verification (TLS 1.3)
error_t tlsFinalizeTranscriptHash(TlsContext *context, const HashAlgo *hash, const void *hashContext, const char_t *label, uint8_t *output)
Finalize hash calculation from previous handshake messages.
uint8_t p
Definition: ndp.h:300
uint8_t message[]
Definition: chap.h:154
size_t digestSize
Definition: crypto.h:1052
const void * buffer
Definition: crypto.h:982
@ TLS_SIGN_SCHEME_RSA_PSS_PSS_SHA512
Definition: tls.h:1258
@ ERROR_OUT_OF_MEMORY
Definition: error.h:63
#define SM3_HASH_ALGO
Definition: sm3.h:49
@ TLS_SIGN_SCHEME_RSA_PSS_RSAE_SHA512
Definition: tls.h:1255
#define osStrcmp(s1, s2)
Definition: os_port.h:171
@ TLS_SIGN_SCHEME_ED25519
Definition: tls.h:1267
#define osStrlen(s)
Definition: os_port.h:165
@ TLS_SIGN_SCHEME_RSA_PSS_PSS_SHA384
Definition: tls.h:1257
@ TLS_SIGN_SCHEME_RSA_PSS_RSAE_SHA384
Definition: tls.h:1254
void ecdsaFreeSignature(EcdsaSignature *signature)
Release an ECDSA signature.
Definition: ecdsa.c:82
@ TLS_HASH_ALGO_SHA512
Definition: tls.h:1219
bool_t tlsIsSignAlgoSupported(TlsContext *context, uint16_t signScheme)
Check whether a signature algorithm can be used for digital signatures.
#define osMemcpy(dest, src, length)
Definition: os_port.h:141
#define TlsContext
Definition: tls.h:36
error_t
Error codes.
Definition: error.h:43
@ TLS_SIGN_SCHEME_RSA_PSS_PSS_SHA256
Definition: tls.h:1256
@ TLS_SIGN_SCHEME_ECDSA_SECP521R1_SHA512
Definition: tls.h:1262
@ TLS_CERT_ED25519_SIGN
Definition: tls.h:1202
HashAlgoCompute compute
Definition: crypto.h:1055
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
error_t tls13VerifyEd448Signature(TlsContext *context, const uint8_t *message, size_t length, const Tls13DigitalSignature *signature)
Ed448 signature verification (TLS 1.3)
void ecdsaInitSignature(EcdsaSignature *signature)
Initialize an ECDSA signature.
Definition: ecdsa.c:69
@ TLS_HASH_ALGO_SHA384
Definition: tls.h:1218
@ TLS_CERT_RSA_PSS_SIGN
Definition: tls.h:1200
@ TLS_SIGN_SCHEME_ECDSA_BP512R1_TLS13_SHA512
Definition: tls.h:1265
@ TLS_HASH_ALGO_SHA256
Definition: tls.h:1217
@ TLS_CERT_ED448_SIGN
Definition: tls.h:1203
@ TLS_CERT_RSA_SIGN
Definition: tls.h:1188
uint8_t length
Definition: tcp.h:368
@ TLS_CERT_SM2_SIGN
Definition: tls.h:1201
RSA/DSA/ECDSA/EdDSA signature verification.
Transcript hash calculation.
Data chunk descriptor.
Definition: crypto.h:981
#define ntohs(value)
Definition: cpu_endian.h:421
error_t tlsVerifyEcdsaSignature(TlsContext *context, const uint8_t *digest, size_t digestLen, const uint8_t *signature, size_t signatureLen)
Verify ECDSA signature.
#define SM2_TLS13_ID
Definition: sm2.h:40
error_t tls13VerifyEcdsaSignature(TlsContext *context, const uint8_t *message, size_t length, const Tls13DigitalSignature *signature)
ECDSA signature verification (TLS 1.3)
error_t tlsVerifyEd25519Signature(TlsContext *context, const DataChunk *messageChunks, const uint8_t *signature, size_t signatureLen)
Verify Ed25519 signature.
error_t tls13VerifyRsaPssSignature(TlsContext *context, const uint8_t *message, size_t length, const Tls13DigitalSignature *signature)
RSA-PSS signature verification (TLS 1.3)
uint8_t n
@ TLS_SIGN_SCHEME_SM2SIG_SM3
Definition: tls.h:1266
error_t rsassaPssVerify(const RsaPublicKey *key, const HashAlgo *hash, size_t saltLen, const uint8_t *digest, const uint8_t *signature, size_t signatureLen)
RSASSA-PSS signature verification operation.
Definition: rsa.c:1079
@ TLS_SIGN_SCHEME_ECDSA_BP384R1_TLS13_SHA384
Definition: tls.h:1264
@ TLS_SIGN_SCHEME_ED448
Definition: tls.h:1268
@ TLS_SIGN_SCHEME_ECDSA_SECP384R1_SHA384
Definition: tls.h:1261
Tls13DigitalSignature
Definition: tls13_misc.h:284
@ TLS_CONNECTION_END_CLIENT
Definition: tls.h:968
error_t tls13VerifySm2Signature(TlsContext *context, const uint8_t *message, size_t length, const Tls13DigitalSignature *signature)
SM2 signature verification (TLS 1.3)
Helper functions for signature generation and verification.
TLS (Transport Layer Security)
@ TLS_CERT_ECDSA_SIGN
Definition: tls.h:1195
size_t length
Definition: crypto.h:983
error_t ecdsaReadSignature(const uint8_t *data, size_t length, EcdsaSignature *signature)
Read an ASN.1 encoded ECDSA signature.
Definition: ecdsa.c:260
Common interface for hash algorithms.
Definition: crypto.h:1046
error_t sm2VerifySignature(const EcDomainParameters *params, const EcPublicKey *publicKey, const HashAlgo *hashAlgo, const char_t *id, size_t idLen, const void *message, size_t messageLen, const EcdsaSignature *signature)
SM2 signature verification.
Definition: sm2.c:216
@ TLS_SIGN_SCHEME_ECDSA_SECP256R1_SHA256
Definition: tls.h:1260
TlsSignatureScheme
Signature schemes.
Definition: tls.h:1247
@ ERROR_DECODING_FAILED
Definition: error.h:241
#define osMemset(p, value, length)
Definition: os_port.h:135
#define tlsFreeMem(p)
Definition: tls.h:858
error_t tlsVerifyEd448Signature(TlsContext *context, const DataChunk *messageChunks, const uint8_t *signature, size_t signatureLen)
Verify Ed448 signature.
Debugging facilities.