Skip to content

Commit a08ab39

Browse files
committed
doc: cracen: add doxygen docs to cracenpsa headers
Added doxygen API documentation to headers under cracenpsa/include. NCSDK-33026. Signed-off-by: Grzegorz Ferenc <[email protected]>
1 parent f3e720e commit a08ab39

16 files changed

+1688
-49
lines changed

doc/nrf/nrf.doxyfile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ INPUT = @DOCSET_SOURCE_BASE@/applications \
963963
@DOCSET_SOURCE_BASE@/subsys/nrf_security/include/psa/crypto_driver_contexts_key_derivation.h \
964964
@DOCSET_SOURCE_BASE@/subsys/nrf_security/include/psa/crypto_driver_contexts_primitives.h \
965965
@DOCSET_SOURCE_BASE@/subsys/nrf_security/include/nrf_security_api_structure.h \
966+
@DOCSET_SOURCE_BASE@/subsys/nrf_security/src/drivers/cracen/cracenpsa/include \
966967
@DOCSET_SOURCE_BASE@/subsys/trusted_storage/include/psa \
967968

968969
# This tag can be used to specify the character encoding of the source files

doc/nrf/security/crypto/drivers.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,24 @@ API documentation
446446
| Header files: :file:`subsys/nrf_security/include/psa/crypto_driver_contexts_*.h`
447447
448448
.. doxygengroup:: nrf_security_api_structures
449+
450+
CRACEN driver API
451+
=================
452+
453+
| Header files: :file:`subsys/nrf_security/src/drivers/cracen/cracenpsa/include/cracen_psa.h`
454+
455+
.. doxygengroup:: cracen_psa_driver
456+
457+
KMU support
458+
-----------
459+
460+
| Header file: :file:`subsys/nrf_security/src/drivers/cracen/cracenpsa/include/cracen_psa_kmu.h`
461+
462+
.. doxygengroup:: cracen_psa_kmu
463+
464+
Identity Key Generation support
465+
-------------------------------
466+
467+
| Header file: :file:`subsys/nrf_security/src/drivers/cracen/cracenpsa/include/cracen_psa_ikg.h`
468+
469+
.. doxygengroup:: cracen_psa_ikg

subsys/nrf_security/src/drivers/cracen/cracenpsa/include/cracen_psa.h

Lines changed: 1039 additions & 3 deletions
Large diffs are not rendered by default.

subsys/nrf_security/src/drivers/cracen/cracenpsa/include/cracen_psa_builtin_key_policy.h

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7+
/**
8+
* @file
9+
* @brief Built-in key policy definitions for CRACEN PSA driver.
10+
*/
11+
712
#ifndef CRACEN_PSA_BUILTIN_KEY_POLICY_H
813
#define CRACEN_PSA_BUILTIN_KEY_POLICY_H
914

@@ -12,24 +17,37 @@
1217

1318
#if defined(__NRF_TFM__)
1419

20+
/** @brief Built-in IKG key policy structure. */
1521
typedef struct {
16-
mbedtls_key_owner_id_t owner;
17-
psa_drv_slot_number_t key_slot;
22+
mbedtls_key_owner_id_t owner; /**< Key owner ID. */
23+
psa_drv_slot_number_t key_slot; /**< Key slot number. */
1824
} cracen_builtin_ikg_key_policy_t;
1925

26+
/** @brief KMU entry slot type. */
2027
typedef enum {
21-
KMU_ENTRY_SLOT_SINGLE,
22-
KMU_ENTRY_SLOT_RANGE,
28+
KMU_ENTRY_SLOT_SINGLE, /**< Single slot entry. */
29+
KMU_ENTRY_SLOT_RANGE, /**< Range of slots entry. */
2330
} cracen_kmu_entry_type_t;
2431

25-
/* When defining a range of KMU slots both the start and end slot numbers are inclusive. */
32+
/** @brief Built-in KMU key policy structure.
33+
*
34+
* When defining a range of KMU slots, both the start and end slot numbers
35+
* are inclusive.
36+
*/
2637
typedef struct {
27-
mbedtls_key_owner_id_t owner;
28-
psa_drv_slot_number_t key_slot_start;
29-
psa_drv_slot_number_t key_slot_end;
30-
cracen_kmu_entry_type_t kmu_entry_type;
38+
mbedtls_key_owner_id_t owner; /**< Key owner ID. */
39+
psa_drv_slot_number_t key_slot_start; /**< Start slot number (inclusive). */
40+
psa_drv_slot_number_t key_slot_end; /**< End slot number (inclusive). */
41+
cracen_kmu_entry_type_t kmu_entry_type; /**< Entry type. */
3142
} cracen_builtin_kmu_key_policy_t;
3243

44+
/** @brief Check if a user is allowed to access a built-in key.
45+
*
46+
* @param[in] attributes Key attributes.
47+
*
48+
* @retval true The user is allowed to access the key.
49+
* @retval false The user is not allowed to access the key.
50+
*/
3351
bool cracen_builtin_key_user_allowed(const psa_key_attributes_t *attributes);
3452

3553
#else

subsys/nrf_security/src/drivers/cracen/cracenpsa/include/cracen_psa_ecdsa.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,109 @@
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7+
/**
8+
* @file
9+
* @brief ECDSA operations for CRACEN PSA driver.
10+
*/
11+
712
#ifndef CRACEN_PSA_ECDSA_H
813
#define CRACEN_PSA_ECDSA_H
914

1015
#include <psa/crypto.h>
1116
#include <stdint.h>
1217

18+
/** @brief Verify an ECDSA message signature.
19+
*
20+
* @param[in] pubkey Public key.
21+
* @param[in] hashalg Hash algorithm.
22+
* @param[in] message Message that was signed.
23+
* @param[in] message_length Length of the message in bytes.
24+
* @param[in] curve Elliptic curve parameters.
25+
* @param[in] signature Signature to verify.
26+
*
27+
* @retval 0 The signature is valid.
28+
* @retval <0 The signature is invalid or an error occurred.
29+
*/
1330
int cracen_ecdsa_verify_message(const uint8_t *pubkey, const struct sxhashalg *hashalg,
1431
const uint8_t *message, size_t message_length,
1532
const struct sx_pk_ecurve *curve, const uint8_t *signature);
1633

34+
/** @brief Verify an ECDSA digest signature.
35+
*
36+
* @param[in] pubkey Public key.
37+
* @param[in] digest Digest that was signed.
38+
* @param[in] digestsz Length of the digest in bytes.
39+
* @param[in] curve Elliptic curve parameters.
40+
* @param[in] signature Signature to verify.
41+
*
42+
* @retval 0 The signature is valid.
43+
* @retval <0 The signature is invalid or an error occurred.
44+
*/
1745
int cracen_ecdsa_verify_digest(const uint8_t *pubkey, const uint8_t *digest, size_t digestsz,
1846
const struct sx_pk_ecurve *curve, const uint8_t *signature);
1947

48+
/** @brief Sign a message using ECDSA.
49+
*
50+
* @param[in] privkey Private key structure.
51+
* @param[in] hashalg Hash algorithm.
52+
* @param[in] curve Elliptic curve parameters.
53+
* @param[in] message Message to sign.
54+
* @param[in] message_length Length of the message in bytes.
55+
* @param[out] signature Buffer to store the signature.
56+
*
57+
* @retval 0 The operation completed successfully.
58+
* @retval <0 An error occurred.
59+
*/
2060
int cracen_ecdsa_sign_message(const struct cracen_ecc_priv_key *privkey,
2161
const struct sxhashalg *hashalg, const struct sx_pk_ecurve *curve,
2262
const uint8_t *message, size_t message_length, uint8_t *signature);
2363

64+
/** @brief Sign a digest using ECDSA.
65+
*
66+
* @param[in] privkey Private key structure.
67+
* @param[in] hashalg Hash algorithm.
68+
* @param[in] curve Elliptic curve parameters.
69+
* @param[in] digest Digest to sign.
70+
* @param[in] digest_length Length of the digest in bytes.
71+
* @param[out] signature Buffer to store the signature.
72+
*
73+
* @retval 0 The operation completed successfully.
74+
* @retval <0 An error occurred.
75+
*/
2476
int cracen_ecdsa_sign_digest(const struct cracen_ecc_priv_key *privkey,
2577
const struct sxhashalg *hashalg, const struct sx_pk_ecurve *curve,
2678
const uint8_t *digest, size_t digest_length, uint8_t *signature);
2779

80+
/** @brief Sign a message using deterministic ECDSA.
81+
*
82+
* @param[in] privkey Private key structure.
83+
* @param[in] hashalg Hash algorithm.
84+
* @param[in] curve Elliptic curve parameters.
85+
* @param[in] message Message to sign.
86+
* @param[in] message_length Length of the message in bytes.
87+
* @param[out] signature Buffer to store the signature.
88+
*
89+
* @retval 0 The operation completed successfully.
90+
* @retval <0 An error occurred.
91+
*/
2892
int cracen_ecdsa_sign_message_deterministic(const struct cracen_ecc_priv_key *privkey,
2993
const struct sxhashalg *hashalg,
3094
const struct sx_pk_ecurve *curve,
3195
const uint8_t *message, size_t message_length,
3296
uint8_t *signature);
3397

98+
/** @brief Sign a digest using deterministic ECDSA.
99+
*
100+
* @param[in] privkey Private key structure.
101+
* @param[in] hashalg Hash algorithm.
102+
* @param[in] curve Elliptic curve parameters.
103+
* @param[in] digest Digest to sign.
104+
* @param[in] digestsz Length of the digest in bytes.
105+
* @param[out] signature Buffer to store the signature.
106+
*
107+
* @retval 0 The operation completed successfully.
108+
* @retval <0 An error occurred.
109+
*/
34110
int cracen_ecdsa_sign_digest_deterministic(const struct cracen_ecc_priv_key *privkey,
35111
const struct sxhashalg *hashalg,
36112
const struct sx_pk_ecurve *curve, const uint8_t *digest,

subsys/nrf_security/src/drivers/cracen/cracenpsa/include/cracen_psa_eddsa.h

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,144 @@
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7+
/**
8+
* @file
9+
* @brief EdDSA operations for CRACEN PSA driver.
10+
*/
11+
712
#ifndef CRACEN_PSA_EDDSA_H
813
#define CRACEN_PSA_EDDSA_H
914

1015
#include <stddef.h>
1116
#include <stdbool.h>
1217
#include <stdint.h>
1318

19+
/** @brief Sign a message using Ed25519.
20+
*
21+
* @param[in] priv_key Private key.
22+
* @param[out] signature Buffer to store the signature.
23+
* @param[in] message Message to sign.
24+
* @param[in] message_length Length of the message in bytes.
25+
*
26+
* @retval 0 The operation completed successfully.
27+
* @retval <0 An error occurred.
28+
*/
1429
int cracen_ed25519_sign(const uint8_t *priv_key, uint8_t *signature, const uint8_t *message,
1530
size_t message_length);
1631

32+
/** @brief Verify an Ed25519 signature.
33+
*
34+
* @param[in] pub_key Public key.
35+
* @param[in] message Message that was signed.
36+
* @param[in] message_length Length of the message in bytes.
37+
* @param[in] signature Signature to verify.
38+
*
39+
* @retval 0 The signature is valid.
40+
* @retval <0 The signature is invalid or an error occurred.
41+
*/
1742
int cracen_ed25519_verify(const uint8_t *pub_key, const uint8_t *message, size_t message_length,
1843
const uint8_t *signature);
1944

45+
/** @brief Sign a message using Ed25519ph (pre-hashed).
46+
*
47+
* @param[in] priv_key Private key.
48+
* @param[out] signature Buffer to store the signature.
49+
* @param[in] message Message or hash to sign.
50+
* @param[in] message_length Length of the message in bytes.
51+
* @param[in] is_message True if @p message is a message, false if it's a hash.
52+
*
53+
* @retval 0 The operation completed successfully.
54+
* @retval <0 An error occurred.
55+
*/
2056
int cracen_ed25519ph_sign(const uint8_t *priv_key, uint8_t *signature, const uint8_t *message,
2157
size_t message_length, bool is_message);
2258

59+
/** @brief Verify an Ed25519ph signature.
60+
*
61+
* @param[in] pub_key Public key.
62+
* @param[in] message Message or hash that was signed.
63+
* @param[in] message_length Length of the message in bytes.
64+
* @param[in] signature Signature to verify.
65+
* @param[in] is_message True if @p message is a message, false if it's a hash.
66+
*
67+
* @retval 0 The signature is valid.
68+
* @retval <0 The signature is invalid or an error occurred.
69+
*/
2370
int cracen_ed25519ph_verify(const uint8_t *pub_key, const uint8_t *message, size_t message_length,
2471
const uint8_t *signature, bool is_message);
2572

73+
/** @brief Create an Ed25519 public key from a private key.
74+
*
75+
* @param[in] priv_key Private key.
76+
* @param[out] pub_key Buffer to store the public key.
77+
*
78+
* @retval 0 The operation completed successfully.
79+
* @retval <0 An error occurred.
80+
*/
2681
int cracen_ed25519_create_pubkey(const uint8_t *priv_key, uint8_t *pub_key);
2782

83+
/** @brief Sign a message using Ed448.
84+
*
85+
* @param[in] priv_key Private key.
86+
* @param[out] signature Buffer to store the signature.
87+
* @param[in] message Message to sign.
88+
* @param[in] message_length Length of the message in bytes.
89+
*
90+
* @retval 0 The operation completed successfully.
91+
* @retval <0 An error occurred.
92+
*/
2893
int cracen_ed448_sign(const uint8_t *priv_key, uint8_t *signature, const uint8_t *message,
2994
size_t message_length);
3095

96+
/** @brief Verify an Ed448 signature.
97+
*
98+
* @param[in] pub_key Public key.
99+
* @param[in] message Message that was signed.
100+
* @param[in] message_length Length of the message in bytes.
101+
* @param[in] signature Signature to verify.
102+
*
103+
* @retval 0 The signature is valid.
104+
* @retval <0 The signature is invalid or an error occurred.
105+
*/
31106
int cracen_ed448_verify(const uint8_t *pub_key, const uint8_t *message, size_t message_length,
32107
const uint8_t *signature);
33108

109+
/** @brief Sign a message using Ed448ph (pre-hashed).
110+
*
111+
* @param[in] priv_key Private key.
112+
* @param[out] signature Buffer to store the signature.
113+
* @param[in] message Message or hash to sign.
114+
* @param[in] message_length Length of the message in bytes.
115+
* @param[in] is_message True if @p message is a message, false if it's a hash.
116+
*
117+
* @retval 0 The operation completed successfully.
118+
* @retval <0 An error occurred.
119+
*/
34120
int cracen_ed448ph_sign(const uint8_t *priv_key, uint8_t *signature, const uint8_t *message,
35121
size_t message_length, bool is_message);
36122

123+
/** @brief Verify an Ed448ph signature.
124+
*
125+
* @param[in] pub_key Public key.
126+
* @param[in] message Message or hash that was signed.
127+
* @param[in] message_length Length of the message in bytes.
128+
* @param[in] signature Signature to verify.
129+
* @param[in] is_message True if @p message is a message, false if it's a hash.
130+
*
131+
* @retval 0 The signature is valid.
132+
* @retval <0 The signature is invalid or an error occurred.
133+
*/
37134
int cracen_ed448ph_verify(const uint8_t *pub_key, const uint8_t *message, size_t message_length,
38135
const uint8_t *signature, bool is_message);
39136

137+
/** @brief Create an Ed448 public key from a private key.
138+
*
139+
* @param[in] priv_key Private key.
140+
* @param[out] pub_key Buffer to store the public key.
141+
*
142+
* @retval 0 The operation completed successfully.
143+
* @retval <0 An error occurred.
144+
*/
40145
int cracen_ed448_create_pubkey(const uint8_t *priv_key, uint8_t *pub_key);
41146

42147
#endif /* CRACEN_PSA_EDDSA_H */

0 commit comments

Comments
 (0)