SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SharkSslCSR.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / __/ /___/ /_/ / /_/ / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * SharkSSL Embedded SSL/TLS Stack
10 ****************************************************************************
11 * PROGRAM MODULE
12 *
13 * COPYRIGHT: Real Time Logic LLC, 2026
14 *
15 * This software is copyrighted by and is the sole property of Real
16 * Time Logic LLC. All rights, title, ownership, or other interests in
17 * the software remain the property of Real Time Logic LLC. This
18 * software may only be used in accordance with the terms and
19 * conditions stipulated in the corresponding license agreement under
20 * which the software has been supplied. Any unauthorized use,
21 * duplication, transmission, distribution, or disclosure of this
22 * software is expressly forbidden.
23 *
24 * This Copyright notice may not be removed or modified without prior
25 * written consent of Real Time Logic LLC.
26 *
27 * Real Time Logic LLC. reserves the right to modify this software
28 * without notice.
29 *
30 * http://www.realtimelogic.com
31 * http://www.sharkssl.com
32 ****************************************************************************
33 *
34 */
35
36#ifndef _SharkSslCSR_h
37#define _SharkSslCSR_h
38
43#include "SharkSSL.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#if (SHARKSSL_ENABLE_CSR_SIGNING)
55#define SHARKSSL_CERT_PROFILE_ROOT_CA 1
56#define SHARKSSL_CERT_PROFILE_INTERMEDIATE_CA 2
57#define SHARKSSL_CERT_PROFILE_TLS_SERVER 3
58#define SHARKSSL_CERT_PROFILE_TLS_CLIENT 4
59#define SHARKSSL_CERT_PROFILE_OPCUA_SERVER 5
60#define SHARKSSL_CERT_PROFILE_OPCUA_CLIENT 6
61#define SHARKSSL_CERT_PROFILE_TLS_SERVER_SELF_SIGNED 7
62
63#define SHARKSSL_CERT_SAN_DNS 2
64#define SHARKSSL_CERT_SAN_URI 6
65#define SHARKSSL_CERT_SAN_IP 7
66
68typedef struct SharkSslCertSAN
69{
70 const U8 *value;
71 U16 length;
72 U8 type;
74
75typedef struct SharkSslCertProfile
76{
77 int (*approveSANs)(void *context, const SharkSslCertSAN *names, U16 count);
78 void *context;
80 U8 type;
82
84typedef struct SharkSslCertDER
85{
86 const U8 *data;
87 U16 length;
89
101SHARKSSL_API int
103 const SharkSslCertDER *trustedRoot,
104 const SharkSslKey expectedKey,
105 const char *utcNow,
106 U16 count);
107
117SHARKSSL_API int
119 const SharkSslCertDER *issuer,
120 const SharkSslKey expectedKey,
121 const SharkSslCertSAN *approvedSANs,
122 const char *validFrom,
123 const char *validTo,
124 const char *utcNow,
125 U16 sanCount);
126
151SHARKSSL_API int
153 const SharkSslCertProfile *profile,
154 const U8 *csrData,
155 const SharkSslCert caCert,
156 const SharkSslKey privKey,
157 const char *validFrom,
158 const char *validTo,
159 int csrDataLen,
160 SharkCertSerialNumber serialNumber,
161 U8 hashID);
162#if SHARKSSL_PSA_CONSUMER
169 const SharkSslCertProfile *profile,
170 const U8 *csrData,
171 const SharkSslCert caCert,
172 const char *validFrom,
173 const char *validTo,
174 int csrDataLen,
175 SharkCertSerialNumber serialNumber,
176 psa_key_id_t psaSignKey,
177 U8 hashID);
178#if SHARKSSL_ENABLE_EDDSA
184SHARKSSL_API int
186 const SharkSslCertProfile *profile,
187 const U8 *csrData,
188 const SharkSslCert caCert,
189 const char *validFrom,
190 const char *validTo,
191 int csrDataLen,
192 SharkCertSerialNumber serialNumber,
193 psa_key_id_t psaSignKey);
194#endif
195#endif
196#endif
197
198#ifdef __cplusplus
199}
200#endif
201
202#endif
TLS objects, certificate/session operations, and public-key interfaces.
SHARKSSL_API int SharkSslCert_validateCAChain(const SharkSslCertDER *chain, const SharkSslCertDER *trustedRoot, const SharkSslKey expectedKey, const char *utcNow, U16 count)
Validate an imported CA chain before enabling its issuing key.
SHARKSSL_API int SharkSslCert_signCSR(SharkSslCert *signedCSR, const SharkSslCertProfile *profile, const U8 *csrData, const SharkSslCert caCert, const SharkSslKey privKey, const char *validFrom, const char *validTo, int csrDataLen, SharkCertSerialNumber serialNumber, U8 hashID)
Sign a verified CSR under an explicit issuer policy.
struct SharkSslCertSAN SharkSslCertSAN
DNS/URI values are ASCII bytes; IP values are 4 or 16 network-order bytes.
SHARKSSL_API int SharkSslCert_signCSRWithPSAEdDSAKey(SharkSslCert *signedCSR, const SharkSslCertProfile *profile, const U8 *csrData, const SharkSslCert caCert, const char *validFrom, const char *validTo, int csrDataLen, SharkCertSerialNumber serialNumber, psa_key_id_t psaSignKey)
Sign a verified CSR with a PSA Ed25519 or Ed448 PureEdDSA private handle The public key of the handle...
struct SharkSslCertProfile SharkSslCertProfile
struct SharkSslCertDER SharkSslCertDER
One bounded DER certificate; a chain runs from operational CA to root.
SHARKSSL_API int SharkSslCert_validateIssuedIdentity(const SharkSslCertDER *issued, const SharkSslCertDER *issuer, const SharkSslKey expectedKey, const SharkSslCertSAN *approvedSANs, const char *validFrom, const char *validTo, const char *utcNow, U16 sanCount)
Check an issued leaf against the approved key, exact typed DNS/URI/IP SAN set, issuer,...
SHARKSSL_API int SharkSslCert_signCSRWithPSAKey(SharkSslCert *signedCSR, const SharkSslCertProfile *profile, const U8 *csrData, const SharkSslCert caCert, const char *validFrom, const char *validTo, int csrDataLen, SharkCertSerialNumber serialNumber, psa_key_id_t psaSignKey, U8 hashID)
Sign a verified CSR with a PSA RSA or P-256/P-384/P-521 ECDSA private handle The public key of the ha...
uint32_t psa_key_id_t
Definition: crypto.h:60
const U8 * SharkSslCert
The SharkSSL Certificate is in a binary format optimized for speed and size.
Definition: SharkSSL.h:326
U8 * SharkSslKey
The SharkSslKey type.
Definition: SharkSSL.h:318
One bounded DER certificate; a chain runs from operational CA to root.
Definition: SharkSslCSR.h:85
const U8 * data
Definition: SharkSslCSR.h:86
U16 length
Definition: SharkSslCSR.h:87
Required issuer policy for certificate signing.
Definition: SharkSslCSR.h:76
U16 pathLenConstraint
Definition: SharkSslCSR.h:79
int(* approveSANs)(void *context, const SharkSslCertSAN *names, U16 count)
Definition: SharkSslCSR.h:77
U8 type
Definition: SharkSslCSR.h:80
void * context
Definition: SharkSslCSR.h:78
DNS/URI values are ASCII bytes; IP values are 4 or 16 network-order bytes.
Definition: SharkSslCSR.h:69
U16 length
Definition: SharkSslCSR.h:71
U8 type
Definition: SharkSslCSR.h:72
const U8 * value
Definition: SharkSslCSR.h:70