x509_sign_generate.h
Go to the documentation of this file.
1 /**
2  * @file x509_sign_generate.h
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-2024 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.4.4
29  **/
30 
31 #ifndef _X509_SIGN_GENERATE_H
32 #define _X509_SIGN_GENERATE_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "pkix/x509_common.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 
44 /**
45  * @brief Signature generation callback function
46  **/
47 
48 typedef error_t (*X509SignGenCallback)(const PrngAlgo *prngAlgo,
49  void *prngContext, const X509OctetString *tbsData,
50  const X509SignAlgoId *signAlgoId,
51  const X509SubjectPublicKeyInfo *publicKeyInfo, const void *privateKey,
52  uint8_t *output, size_t *written);
53 
54 
55 //X.509 related functions
57 
58 error_t x509GenerateSignature(const PrngAlgo *prngAlgo, void *prngContext,
59  const X509OctetString *tbsData, const X509SignAlgoId *signAlgoId,
60  const X509SubjectPublicKeyInfo *publicKeyInfo, const void *privateKey,
61  uint8_t *output, size_t *written);
62 
64  const HashAlgo *hashAlgo, const RsaPrivateKey *privateKey, uint8_t *output,
65  size_t *written);
66 
67 error_t x509GenerateRsaPssSignature(const PrngAlgo *prngAlgo, void *prngContext,
68  const X509OctetString *tbsData, const HashAlgo *hashAlgo, size_t saltLen,
69  const RsaPrivateKey *privateKey, uint8_t *output, size_t *written);
70 
71 error_t x509GenerateDsaSignature(const PrngAlgo *prngAlgo, void *prngContext,
72  const X509OctetString *tbsData, const HashAlgo *hashAlgo,
73  const DsaPrivateKey *privateKey, uint8_t *output, size_t *written);
74 
75 error_t x509GenerateEcdsaSignature(const PrngAlgo *prngAlgo, void *prngContext,
76  const X509OctetString *tbsData, const HashAlgo *hashAlgo,
77  const X509SubjectPublicKeyInfo *publicKeyInfo,
78  const EcPrivateKey *privateKey, uint8_t *output, size_t *written);
79 
80 error_t x509GenerateSm2Signature(const PrngAlgo *prngAlgo, void *prngContext,
81  const X509OctetString *tbsData, const HashAlgo *hashAlgo,
82  const EcPrivateKey *privateKey, uint8_t *output, size_t *written);
83 
85  const EddsaPrivateKey *privateKey, uint8_t *output, size_t *written);
86 
88  const EddsaPrivateKey *privateKey, uint8_t *output, size_t *written);
89 
90 //C++ guard
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif
X.509 common definitions.
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:938
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.
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.
error_t
Error codes.
Definition: error.h:43
error_t x509GenerateRsaSignature(const X509OctetString *tbsData, const HashAlgo *hashAlgo, const RsaPrivateKey *privateKey, uint8_t *output, size_t *written)
RSA signature generation.
error_t x509GenerateEd25519Signature(const X509OctetString *tbsData, const EddsaPrivateKey *privateKey, uint8_t *output, size_t *written)
Ed25519 signature generation.
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.
General definitions for cryptographic algorithms.
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.
EC private key.
Definition: ec.h:104
DSA private key.
Definition: dsa.h:72
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.
EdDSA private key.
Definition: eddsa.h:59
RSA private key.
Definition: rsa.h:68
Subject Public Key Information extension.
Definition: x509_common.h:790
Common interface for hash algorithms.
Definition: crypto.h:1046
Octet string.
Definition: x509_common.h:653
error_t x509GenerateEd448Signature(const X509OctetString *tbsData, const EddsaPrivateKey *privateKey, uint8_t *output, size_t *written)
Ed448 signature generation.
Signature algorithm identifier.
Definition: x509_common.h:1040