x509_sign_generate.c
Go to the documentation of this file.
1 /**
2  * @file x509_sign_generate.c
3  * @brief RSA/DSA/ECDSA/EdDSA signature generation
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO 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.5.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/crypto.h"
37 #include "debug.h"
38 
39 //Check crypto library configuration
40 #if (X509_SUPPORT == ENABLED)
41 
42 //Signature generation/verification callback functions
43 #if (X509_SIGN_CALLBACK_SUPPORT == ENABLED)
44  static X509SignGenCallback x509SignGenCallback = NULL;
45 #endif
46 
47 
48 /**
49  * @brief Register signature generation callback function
50  * @param[in] callback Signature generation callback function
51  * @return Error code
52  **/
53 
55 {
56 #if (X509_SIGN_CALLBACK_SUPPORT == ENABLED)
57  //Save callback function
58  x509SignGenCallback = callback;
59  //Successful processing
60  return NO_ERROR;
61 #else
62  //Not implemented
63  return ERROR_NOT_IMPLEMENTED;
64 #endif
65 }
66 
67 
68 /**
69  * @brief Certificate signature generation
70  * @param[in] prngAlgo PRNG algorithm
71  * @param[in] prngContext Pointer to the PRNG context
72  * @param[in] tbsData Pointer to the data to be signed
73  * @param[in] signAlgoId Signature algorithm identifier
74  * @param[in] publicKeyInfo Signer's public key information
75  * @param[in] privateKey Signer's private key
76  * @param[out] output Resulting signature
77  * @param[out] written Length of the resulting signature
78  * @return Error code
79  **/
80 
81 error_t x509GenerateSignature(const PrngAlgo *prngAlgo, void *prngContext,
82  const X509OctetString *tbsData, const X509SignAlgoId *signAlgoId,
83  const X509SubjectPublicKeyInfo *publicKeyInfo, const void *privateKey,
84  uint8_t *output, size_t *written)
85 {
86  error_t error;
87  X509SignatureAlgo signAlgo;
88  const HashAlgo *hashAlgo;
89 
90 #if (X509_SIGN_CALLBACK_SUPPORT == ENABLED)
91  //Valid signature generation callback function?
92  if(x509SignGenCallback != NULL)
93  {
94  //Invoke user-defined callback
95  error = x509SignGenCallback(prngAlgo, prngContext, tbsData,
96  signAlgoId, publicKeyInfo, privateKey, output, written);
97  }
98  else
99 #endif
100  {
101  //No callback function registered
103  }
104 
105  //Check status code
106  if(error == ERROR_UNSUPPORTED_SIGNATURE_ALGO ||
107  error == ERROR_UNKOWN_KEY)
108  {
109  //Retrieve the signature algorithm that will be used to sign the
110  //certificate
111  error = x509GetSignHashAlgo(signAlgoId, &signAlgo, &hashAlgo);
112 
113  //Check status code
114  if(!error)
115  {
116 #if (X509_RSA_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
117  //RSA signature algorithm?
118  if(signAlgo == X509_SIGN_ALGO_RSA)
119  {
120  //Generate RSA signature (RSASSA-PKCS1-v1_5 signature scheme)
121  error = x509GenerateRsaSignature(tbsData, hashAlgo, privateKey,
122  output, written);
123  }
124  else
125 #endif
126 #if (X509_RSA_PSS_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
127  //RSA-PSS signature algorithm?
128  if(signAlgo == X509_SIGN_ALGO_RSA_PSS)
129  {
130  //Generate RSA signature (RSASSA-PSS signature scheme)
131  error = x509GenerateRsaPssSignature(prngAlgo, prngContext, tbsData,
132  hashAlgo, signAlgoId->rsaPssParams.saltLen, privateKey, output,
133  written);
134  }
135  else
136 #endif
137 #if (X509_DSA_SUPPORT == ENABLED && DSA_SUPPORT == ENABLED)
138  //DSA signature algorithm?
139  if(signAlgo == X509_SIGN_ALGO_DSA)
140  {
141  //Generate DSA signature
142  error = x509GenerateDsaSignature(prngAlgo, prngContext, tbsData,
143  hashAlgo, privateKey, output, written);
144  }
145  else
146 #endif
147 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
148  //ECDSA signature algorithm?
149  if(signAlgo == X509_SIGN_ALGO_ECDSA)
150  {
151  //Generate ECDSA signature
152  error = x509GenerateEcdsaSignature(prngAlgo, prngContext, tbsData,
153  hashAlgo, publicKeyInfo, privateKey, output, written);
154  }
155  else
156 #endif
157 #if (X509_SM2_SUPPORT == ENABLED && SM2_SUPPORT == ENABLED)
158  //SM2 signature algorithm?
159  if(signAlgo == X509_SIGN_ALGO_SM2)
160  {
161  //Generate SM2 signature
162  error = x509GenerateSm2Signature(prngAlgo, prngContext, tbsData,
163  hashAlgo, privateKey, output, written);
164  }
165  else
166 #endif
167 #if (X509_ED25519_SUPPORT == ENABLED && ED25519_SUPPORT == ENABLED)
168  //Ed25519 signature algorithm?
169  if(signAlgo == X509_SIGN_ALGO_ED25519)
170  {
171  //Generate Ed25519 signature (PureEdDSA mode)
172  error = x509GenerateEd25519Signature(tbsData, privateKey, output,
173  written);
174  }
175  else
176 #endif
177 #if (X509_ED448_SUPPORT == ENABLED && ED448_SUPPORT == ENABLED)
178  //Ed448 signature algorithm?
179  if(signAlgo == X509_SIGN_ALGO_ED448)
180  {
181  //Generate Ed448 signature (PureEdDSA mode)
182  error = x509GenerateEd448Signature(tbsData, privateKey, output,
183  written);
184  }
185  else
186 #endif
187  //Invalid signature algorithm?
188  {
189  //Report an error
191  }
192  }
193  }
194 
195  //Return status code
196  return error;
197 }
198 
199 
200 /**
201  * @brief RSA signature generation
202  * @param[in] tbsData Pointer to the data to be signed
203  * @param[in] hashAlgo Underlying hash function
204  * @param[in] privateKey Signer's private key
205  * @param[out] output Resulting signature
206  * @param[out] written Length of the resulting signature
207  * @return Error code
208  **/
209 
211  const HashAlgo *hashAlgo, const RsaPrivateKey *privateKey, uint8_t *output,
212  size_t *written)
213 {
214 #if (X509_RSA_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
215  error_t error;
216  uint8_t digest[MAX_HASH_DIGEST_SIZE];
217 
218  //Digest the TBSCertificate structure using the specified hash algorithm
219  error = hashAlgo->compute(tbsData->value, tbsData->length, digest);
220 
221  //Check status code
222  if(!error)
223  {
224  //Generate RSA signature
225  error = rsassaPkcs1v15Sign(privateKey, hashAlgo, digest, output,
226  written);
227  }
228 
229  //Return status code
230  return error;
231 #else
232  //Not implemented
233  return ERROR_NOT_IMPLEMENTED;
234 #endif
235 }
236 
237 
238 /**
239  * @brief RSA-PSS signature generation
240  * @param[in] prngAlgo PRNG algorithm
241  * @param[in] prngContext Pointer to the PRNG context
242  * @param[in] tbsData Pointer to the data to be signed
243  * @param[in] hashAlgo Underlying hash function
244  * @param[in] saltLen Length of the salt, in bytes
245  * @param[in] privateKey Signer's private key
246  * @param[out] output Resulting signature
247  * @param[out] written Length of the resulting signature
248  * @return Error code
249  **/
250 
251 error_t x509GenerateRsaPssSignature(const PrngAlgo *prngAlgo, void *prngContext,
252  const X509OctetString *tbsData, const HashAlgo *hashAlgo, size_t saltLen,
253  const RsaPrivateKey *privateKey, uint8_t *output, size_t *written)
254 {
255 #if (X509_RSA_PSS_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
256  error_t error;
257  uint8_t digest[MAX_HASH_DIGEST_SIZE];
258 
259  //Digest the TBSCertificate structure using the specified hash algorithm
260  error = hashAlgo->compute(tbsData->value, tbsData->length, digest);
261 
262  //Check status code
263  if(!error)
264  {
265  //Generate RSA-PSS signature
266  error = rsassaPssSign(prngAlgo, prngContext, privateKey, hashAlgo,
267  saltLen, digest, output, written);
268  }
269 
270  //Return status code
271  return error;
272 #else
273  //Not implemented
274  return ERROR_NOT_IMPLEMENTED;
275 #endif
276 }
277 
278 
279 /**
280  * @brief DSA signature generation
281  * @param[in] prngAlgo PRNG algorithm
282  * @param[in] prngContext Pointer to the PRNG context
283  * @param[in] tbsData Pointer to the data to be signed
284  * @param[in] hashAlgo Underlying hash function
285  * @param[in] privateKey Signer's private key
286  * @param[out] output Resulting signature
287  * @param[out] written Length of the resulting signature
288  * @return Error code
289  **/
290 
291 error_t x509GenerateDsaSignature(const PrngAlgo *prngAlgo, void *prngContext,
292  const X509OctetString *tbsData, const HashAlgo *hashAlgo,
293  const DsaPrivateKey *privateKey, uint8_t *output, size_t *written)
294 {
295 #if (X509_DSA_SUPPORT == ENABLED && DSA_SUPPORT == ENABLED)
296  error_t error;
297  DsaSignature dsaSignature;
298  uint8_t digest[MAX_HASH_DIGEST_SIZE];
299 
300  //Initialize DSA signature
301  dsaInitSignature(&dsaSignature);
302 
303  //Digest the TBSCertificate structure using the specified hash algorithm
304  error = hashAlgo->compute(tbsData->value, tbsData->length, digest);
305 
306  //Check status code
307  if(!error)
308  {
309  //Generate DSA signature
310  error = dsaGenerateSignature(prngAlgo, prngContext, privateKey, digest,
311  hashAlgo->digestSize, &dsaSignature);
312  }
313 
314  //Check status code
315  if(!error)
316  {
317  //Encode DSA signature using ASN.1
318  error = dsaExportSignature(&dsaSignature, output, written);
319  }
320 
321  //Release previously allocated resources
322  dsaFreeSignature(&dsaSignature);
323 
324  //Return status code
325  return error;
326 #else
327  //Not implemented
328  return ERROR_NOT_IMPLEMENTED;
329 #endif
330 }
331 
332 
333 /**
334  * @brief ECDSA signature generation
335  * @param[in] prngAlgo PRNG algorithm
336  * @param[in] prngContext Pointer to the PRNG context
337  * @param[in] tbsData Pointer to the data to be signed
338  * @param[in] hashAlgo Underlying hash function
339  * @param[in] publicKeyInfo Signer's public key information
340  * @param[in] privateKey Signer's private key
341  * @param[out] output Resulting signature
342  * @param[out] written Length of the resulting signature
343  * @return Error code
344  **/
345 
346 error_t x509GenerateEcdsaSignature(const PrngAlgo *prngAlgo, void *prngContext,
347  const X509OctetString *tbsData, const HashAlgo *hashAlgo,
348  const X509SubjectPublicKeyInfo *publicKeyInfo,
349  const EcPrivateKey *privateKey, uint8_t *output, size_t *written)
350 {
351 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
352  error_t error;
353  const EcCurve *curve;
354  EcdsaSignature ecdsaSignature;
355  uint8_t digest[MAX_HASH_DIGEST_SIZE];
356 
357  //Initialize ECDSA signature
358  ecdsaInitSignature(&ecdsaSignature);
359 
360  //Get the elliptic curve that matches the OID
361  curve = x509GetCurve(publicKeyInfo->ecParams.namedCurve.value,
362  publicKeyInfo->ecParams.namedCurve.length);
363 
364  //Make sure the specified elliptic curve is supported
365  if(curve != NULL && curve == privateKey->curve)
366  {
367  //Digest the TBSCertificate structure using the specified hash algorithm
368  error = hashAlgo->compute(tbsData->value, tbsData->length, digest);
369 
370  //Check status code
371  if(!error)
372  {
373  //Generate ECDSA signature
374  error = ecdsaGenerateSignature(prngAlgo, prngContext, privateKey,
375  digest, hashAlgo->digestSize, &ecdsaSignature);
376  }
377 
378  //Check status code
379  if(!error)
380  {
381  //Encode ECDSA signature using ASN.1
382  error = ecdsaExportSignature(&ecdsaSignature, output, written,
384  }
385  }
386  else
387  {
388  //Invalid elliptic curve
389  error = ERROR_BAD_CERTIFICATE;
390  }
391 
392  //Release previously allocated resources
393  ecdsaFreeSignature(&ecdsaSignature);
394 
395  //Return status code
396  return error;
397 #else
398  //Not implemented
399  return ERROR_NOT_IMPLEMENTED;
400 #endif
401 }
402 
403 
404 /**
405  * @brief SM2 signature generation
406  * @param[in] prngAlgo PRNG algorithm
407  * @param[in] prngContext Pointer to the PRNG context
408  * @param[in] tbsData Pointer to the data to be signed
409  * @param[in] hashAlgo Underlying hash function
410  * @param[in] privateKey Signer's private key
411  * @param[out] output Resulting signature
412  * @param[out] written Length of the resulting signature
413  * @return Error code
414  **/
415 
416 error_t x509GenerateSm2Signature(const PrngAlgo *prngAlgo, void *prngContext,
417  const X509OctetString *tbsData, const HashAlgo *hashAlgo,
418  const EcPrivateKey *privateKey, uint8_t *output, size_t *written)
419 {
420 #if (X509_SM2_SUPPORT == ENABLED && SM2_SUPPORT == ENABLED)
421  error_t error;
422  EcdsaSignature sm2Signature;
423 
424  //Initialize SM2 signature
425  ecdsaInitSignature(&sm2Signature);
426 
427  //Generate SM2 signature
428  error = sm2GenerateSignature(prngAlgo, prngContext, privateKey, hashAlgo,
429  SM2_DEFAULT_ID, osStrlen(SM2_DEFAULT_ID), tbsData->value, tbsData->length,
430  &sm2Signature);
431 
432  //Check status code
433  if(!error)
434  {
435  //Encode SM2 signature using ASN.1
436  error = ecdsaExportSignature(&sm2Signature, output, written,
438  }
439 
440  //Release previously allocated resources
441  ecdsaFreeSignature(&sm2Signature);
442 
443  //Return status code
444  return error;
445 #else
446  //Not implemented
447  return ERROR_NOT_IMPLEMENTED;
448 #endif
449 }
450 
451 
452 /**
453  * @brief Ed25519 signature generation
454  * @param[in] tbsData Pointer to the data to be signed
455  * @param[in] privateKey Signer's private key
456  * @param[out] output Resulting signature
457  * @param[out] written Length of the resulting signature
458  * @return Error code
459  **/
460 
462  const EddsaPrivateKey *privateKey, uint8_t *output, size_t *written)
463 {
464 #if (X509_ED25519_SUPPORT == ENABLED && ED25519_SUPPORT == ENABLED)
465  error_t error;
466  const uint8_t *q;
467 
468  //Check elliptic curve parameters
469  if(privateKey->curve == ED25519_CURVE)
470  {
471  //The public key is optional
472  q = (privateKey->q.curve != NULL) ? privateKey->q.q : NULL;
473 
474  //Generate Ed25519 signature (PureEdDSA mode)
475  error = ed25519GenerateSignature(privateKey->d, q, tbsData->value,
476  tbsData->length, NULL, 0, 0, output);
477 
478  //Check status code
479  if(!error)
480  {
481  //Length of the resulting EdDSA signature
482  *written = ED25519_SIGNATURE_LEN;
483  }
484  }
485  else
486  {
487  //The private key is not valid
488  error = ERROR_INVALID_KEY;
489  }
490 
491  //Return status code
492  return error;
493 #else
494  //Not implemented
495  return ERROR_NOT_IMPLEMENTED;
496 #endif
497 }
498 
499 
500 /**
501  * @brief Ed448 signature generation
502  * @param[in] tbsData Pointer to the data to be signed
503  * @param[in] privateKey Signer's private key
504  * @param[out] output Resulting signature
505  * @param[out] written Length of the resulting signature
506  * @return Error code
507  **/
508 
510  const EddsaPrivateKey *privateKey, uint8_t *output, size_t *written)
511 {
512 #if (X509_ED448_SUPPORT == ENABLED && ED448_SUPPORT == ENABLED)
513  error_t error;
514  const uint8_t *q;
515 
516  //Check elliptic curve parameters
517  if(privateKey->curve == ED448_CURVE)
518  {
519  //The public key is optional
520  q = (privateKey->q.curve != NULL) ? privateKey->q.q : NULL;
521 
522  //Generate Ed448 signature (PureEdDSA mode)
523  error = ed448GenerateSignature(privateKey->d, q, tbsData->value,
524  tbsData->length, NULL, 0, 0, output);
525 
526  //Check status code
527  if(!error)
528  {
529  //Length of the resulting EdDSA signature
530  *written = ED448_SIGNATURE_LEN;
531  }
532  }
533  else
534  {
535  //The private key is not valid
536  error = ERROR_INVALID_KEY;
537  }
538 
539  //Return status code
540  return error;
541 #else
542  //Not implemented
543  return ERROR_NOT_IMPLEMENTED;
544 #endif
545 }
546 
547 #endif
__weak_func error_t ecdsaGenerateSignature(const PrngAlgo *prngAlgo, void *prngContext, const EcPrivateKey *privateKey, const uint8_t *digest, size_t digestLen, EcdsaSignature *signature)
ECDSA signature generation.
Definition: ecdsa.c:509
ECDSA signature.
Definition: ecdsa.h:63
uint8_t d[EDDSA_MAX_PRIVATE_KEY_LEN]
Private key.
Definition: eddsa.h:77
error_t(* X509SignGenCallback)(const PrngAlgo *prngAlgo, void *prngContext, const X509OctetString *tbsData, const X509SignAlgoId *signAlgoId, const X509SubjectPublicKeyInfo *publicKeyInfo, const void *privateKey, uint8_t *output, size_t *written)
Signature generation callback function.
#define PrngAlgo
Definition: crypto.h:973
@ ERROR_NOT_IMPLEMENTED
Definition: error.h:66
const EcCurve * curve
Elliptic curve parameters.
Definition: eddsa.h:76
error_t x509GenerateSignature(const PrngAlgo *prngAlgo, void *prngContext, const X509OctetString *tbsData, const X509SignAlgoId *signAlgoId, const X509SubjectPublicKeyInfo *publicKeyInfo, const void *privateKey, uint8_t *output, size_t *written)
Certificate signature generation.
error_t x509RegisterSignGenCallback(X509SignGenCallback callback)
Register signature generation callback function.
const EcCurve * curve
Elliptic curve parameters.
Definition: ec.h:433
size_t digestSize
Definition: crypto.h:1088
X509EcParameters ecParams
Definition: x509_common.h:850
error_t sm2GenerateSignature(const PrngAlgo *prngAlgo, void *prngContext, const EcPrivateKey *privateKey, const HashAlgo *hashAlgo, const char_t *id, size_t idLen, const void *message, size_t messageLen, EcdsaSignature *signature)
SM2 signature generation.
Definition: sm2.c:62
#define ED25519_CURVE
Definition: ec_curves.h:72
#define ED448_SIGNATURE_LEN
Definition: ed448.h:44
#define ED448_CURVE
Definition: ec_curves.h:73
#define ED25519_SIGNATURE_LEN
Definition: ed25519.h:44
#define osStrlen(s)
Definition: os_port.h:168
error_t ecdsaExportSignature(const EcdsaSignature *signature, uint8_t *data, size_t *length, EcdsaSignatureFormat format)
Export an ECDSA signature.
Definition: ecdsa.c:272
void ecdsaFreeSignature(EcdsaSignature *signature)
Release an ECDSA signature.
Definition: ecdsa.c:86
#define MAX_HASH_DIGEST_SIZE
X509SignatureAlgo
Signature algorithms.
Definition: x509_common.h:652
error_t ed25519GenerateSignature(const uint8_t *privateKey, const uint8_t *publicKey, const void *message, size_t messageLen, const void *context, uint8_t contextLen, uint8_t flag, uint8_t *signature)
EdDSA signature generation.
Definition: ed25519.c:234
error_t x509GenerateRsaPssSignature(const PrngAlgo *prngAlgo, void *prngContext, const X509OctetString *tbsData, const HashAlgo *hashAlgo, size_t saltLen, const RsaPrivateKey *privateKey, uint8_t *output, size_t *written)
RSA-PSS signature generation.
uint8_t q[EDDSA_MAX_PUBLIC_KEY_LEN]
Public key.
Definition: eddsa.h:66
const EcCurve * x509GetCurve(const uint8_t *oid, size_t length)
Get the elliptic curve that matches the specified OID.
Definition: x509_common.c:885
const EcCurve * curve
Elliptic curve parameters.
Definition: eddsa.h:65
error_t
Error codes.
Definition: error.h:43
void dsaInitSignature(DsaSignature *signature)
Initialize a DSA signature.
Definition: dsa.c:168
HashAlgoCompute compute
Definition: crypto.h:1091
@ X509_SIGN_ALGO_ECDSA
Definition: x509_common.h:657
error_t rsassaPssSign(const PrngAlgo *prngAlgo, void *prngContext, const RsaPrivateKey *key, const HashAlgo *hash, size_t saltLen, const uint8_t *digest, uint8_t *signature, size_t *signatureLen)
RSASSA-PSS signature generation operation.
Definition: rsa.c:1189
void ecdsaInitSignature(EcdsaSignature *signature)
Initialize an ECDSA signature.
Definition: ecdsa.c:73
error_t dsaGenerateSignature(const PrngAlgo *prngAlgo, void *prngContext, const DsaPrivateKey *key, const uint8_t *digest, size_t digestLen, DsaSignature *signature)
DSA signature generation.
Definition: dsa.c:500
General definitions for cryptographic algorithms.
error_t x509GetSignHashAlgo(const X509SignAlgoId *signAlgoId, X509SignatureAlgo *signAlgo, const HashAlgo **hashAlgo)
Get the signature and hash algorithms that match the specified identifier.
Definition: x509_common.c:377
@ ERROR_BAD_CERTIFICATE
Definition: error.h:236
EC private key.
Definition: ec.h:432
DSA private key.
Definition: dsa.h:72
error_t x509GenerateSm2Signature(const PrngAlgo *prngAlgo, void *prngContext, const X509OctetString *tbsData, const HashAlgo *hashAlgo, const EcPrivateKey *privateKey, uint8_t *output, size_t *written)
SM2 signature generation.
@ X509_SIGN_ALGO_RSA
Definition: x509_common.h:654
error_t x509GenerateRsaSignature(const X509OctetString *tbsData, const HashAlgo *hashAlgo, const RsaPrivateKey *privateKey, uint8_t *output, size_t *written)
RSA signature generation.
X509OctetString namedCurve
Definition: x509_common.h:819
EdDSA private key.
Definition: eddsa.h:75
@ ECDSA_SIGNATURE_FORMAT_ASN1
Definition: ecdsa.h:51
RSA/DSA/ECDSA/EdDSA signature generation.
@ X509_SIGN_ALGO_RSA_PSS
Definition: x509_common.h:655
error_t x509GenerateEd25519Signature(const X509OctetString *tbsData, const EddsaPrivateKey *privateKey, uint8_t *output, size_t *written)
Ed25519 signature generation.
RSA private key.
Definition: rsa.h:68
Subject Public Key Information extension.
Definition: x509_common.h:838
@ ERROR_UNKOWN_KEY
Definition: error.h:295
void dsaFreeSignature(DsaSignature *signature)
Release a DSA signature.
Definition: dsa.c:181
error_t dsaExportSignature(const DsaSignature *signature, uint8_t *data, size_t *length)
Export a DSA signature to ASN.1 format.
Definition: dsa.c:334
error_t x509GenerateDsaSignature(const PrngAlgo *prngAlgo, void *prngContext, const X509OctetString *tbsData, const HashAlgo *hashAlgo, const DsaPrivateKey *privateKey, uint8_t *output, size_t *written)
DSA signature generation.
EddsaPublicKey q
Public key.
Definition: eddsa.h:79
error_t x509GenerateEd448Signature(const X509OctetString *tbsData, const EddsaPrivateKey *privateKey, uint8_t *output, size_t *written)
Ed448 signature generation.
const uint8_t * value
Definition: x509_common.h:702
Common interface for hash algorithms.
Definition: crypto.h:1082
error_t rsassaPkcs1v15Sign(const RsaPrivateKey *key, const HashAlgo *hash, const uint8_t *digest, uint8_t *signature, size_t *signatureLen)
RSASSA-PKCS1-v1_5 signature generation operation.
Definition: rsa.c:935
DSA signature.
Definition: dsa.h:85
#define EcCurve
Definition: ec.h:346
@ ERROR_UNSUPPORTED_SIGNATURE_ALGO
Definition: error.h:132
@ X509_SIGN_ALGO_SM2
Definition: x509_common.h:658
Octet string.
Definition: x509_common.h:701
#define SM2_DEFAULT_ID
Definition: sm2.h:40
@ X509_SIGN_ALGO_ED25519
Definition: x509_common.h:659
X509RsaPssParameters rsaPssParams
Definition: x509_common.h:1091
error_t ed448GenerateSignature(const uint8_t *privateKey, const uint8_t *publicKey, const void *message, size_t messageLen, const void *context, uint8_t contextLen, uint8_t flag, uint8_t *signature)
EdDSA signature generation.
Definition: ed448.c:223
Signature algorithm identifier.
Definition: x509_common.h:1088
@ ERROR_INVALID_KEY
Definition: error.h:106
@ NO_ERROR
Success.
Definition: error.h:44
Debugging facilities.
error_t x509GenerateEcdsaSignature(const PrngAlgo *prngAlgo, void *prngContext, const X509OctetString *tbsData, const HashAlgo *hashAlgo, const X509SubjectPublicKeyInfo *publicKeyInfo, const EcPrivateKey *privateKey, uint8_t *output, size_t *written)
ECDSA signature generation.
@ X509_SIGN_ALGO_DSA
Definition: x509_common.h:656
@ X509_SIGN_ALGO_ED448
Definition: x509_common.h:660