Skip to content

Commit b202b83

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 b202b83

17 files changed

+1886
-132
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,10 @@ 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` and related headers
454+
455+
.. doxygengroup:: cracen_psa_driver

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: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7+
/**
8+
* @file
9+
* @addtogroup cracen_psa_driver
10+
* @{
11+
* @brief Built-in key policy definitions for CRACEN PSA driver.
12+
*/
13+
714
#ifndef CRACEN_PSA_BUILTIN_KEY_POLICY_H
815
#define CRACEN_PSA_BUILTIN_KEY_POLICY_H
916

@@ -12,24 +19,37 @@
1219

1320
#if defined(__NRF_TFM__)
1421

22+
/** @brief Built-in IKG key policy structure. */
1523
typedef struct {
16-
mbedtls_key_owner_id_t owner;
17-
psa_drv_slot_number_t key_slot;
24+
mbedtls_key_owner_id_t owner; /**< Key owner ID. */
25+
psa_drv_slot_number_t key_slot; /**< Key slot number. */
1826
} cracen_builtin_ikg_key_policy_t;
1927

28+
/** @brief KMU entry slot type. */
2029
typedef enum {
21-
KMU_ENTRY_SLOT_SINGLE,
22-
KMU_ENTRY_SLOT_RANGE,
30+
KMU_ENTRY_SLOT_SINGLE, /**< Single slot entry. */
31+
KMU_ENTRY_SLOT_RANGE, /**< Range of slots entry. */
2332
} cracen_kmu_entry_type_t;
2433

25-
/* When defining a range of KMU slots both the start and end slot numbers are inclusive. */
34+
/** @brief Built-in KMU key policy structure.
35+
*
36+
* When defining a range of KMU slots, both the start and end slot numbers
37+
* are inclusive.
38+
*/
2639
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;
40+
mbedtls_key_owner_id_t owner; /**< Key owner ID. */
41+
psa_drv_slot_number_t key_slot_start; /**< Start slot number (inclusive). */
42+
psa_drv_slot_number_t key_slot_end; /**< End slot number (inclusive). */
43+
cracen_kmu_entry_type_t kmu_entry_type; /**< Entry type. */
3144
} cracen_builtin_kmu_key_policy_t;
3245

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

3555
#else
@@ -42,4 +62,6 @@ static inline bool cracen_builtin_key_user_allowed(const psa_key_attributes_t *a
4262

4363
#endif /* __NRF_TFM__ */
4464

65+
/** @} */
66+
4567
#endif /* CRACEN_PSA_BUILTIN_KEY_POLICY_H */

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

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

7+
/**
8+
* @file
9+
* @addtogroup cracen_psa_driver
10+
* @{
11+
* @brief ECDSA operations for CRACEN PSA driver.
12+
*/
13+
714
#ifndef CRACEN_PSA_ECDSA_H
815
#define CRACEN_PSA_ECDSA_H
916

1017
#include <psa/crypto.h>
1118
#include <stdint.h>
1219

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

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

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

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

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

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

117+
/** @} */
118+
39119
#endif /* CRACEN_PSA_ECDSA_H */

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

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

7+
/**
8+
* @file
9+
* @addtogroup cracen_psa_driver
10+
* @{
11+
* @brief EdDSA operations for CRACEN PSA driver.
12+
*/
13+
714
#ifndef CRACEN_PSA_EDDSA_H
815
#define CRACEN_PSA_EDDSA_H
916

1017
#include <stddef.h>
1118
#include <stdbool.h>
1219
#include <stdint.h>
1320

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

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

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

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

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

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

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

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

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

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

149+
/** @} */
150+
42151
#endif /* CRACEN_PSA_EDDSA_H */

0 commit comments

Comments
 (0)