You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updated the documentation of crypto samples.
Added sample output, cross-links to recently updated docs,
more details in the overview sections.
Edited sample.yaml for term and style consistency.
Future PRs will edit remaining crypto samples.
NCSDK-33435.
Signed-off-by: Grzegorz Ferenc <[email protected]>
Copy file name to clipboardExpand all lines: samples/crypto/aes_cbc/README.rst
+69-10Lines changed: 69 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Crypto: AES CBC
7
7
:local:
8
8
:depth: 2
9
9
10
-
The AES CBC sample shows how to perform AES encryption and decryption operations using the CBC block cipher mode without padding and a 128-bit AES key.
10
+
The AES CBC sample demonstrates how to use the :ref:`PSA Crypto API <ug_psa_certified_api_overview_crypto>` to perform AES encryption and decryption operations using the CBC block cipher mode without padding and a 128-bit AES key.
11
11
12
12
Requirements
13
13
************
@@ -21,22 +21,38 @@ The sample supports the following development kits:
21
21
Overview
22
22
********
23
23
24
-
The sample performs the following operations:
24
+
The sample :ref:`enables PSA Crypto API <psa_crypto_support_enable>` and configures the following Kconfig options for the cryptographic features:
25
+
26
+
* :kconfig:option:`CONFIG_PSA_WANT_KEY_TYPE_AES` - Used to enable support for AES key types from among the supported cryptographic operations for :ref:`ug_crypto_supported_features_key_types`.
27
+
* :kconfig:option:`CONFIG_PSA_WANT_ALG_CBC_NO_PADDING` - Used to enable support for the CBC cipher mode without padding from among the supported cryptographic operations for :ref:`ug_crypto_supported_features_cipher_modes`.
28
+
* :kconfig:option:`CONFIG_PSA_WANT_GENERATE_RANDOM` - Used to enable random number generation for key and IV generation from among the supported cryptographic operations for :ref:`ug_crypto_supported_features_rng_algorithms`.
29
+
30
+
The sample also configures the cryptographic drivers for each board target using Kconfig options in the overlay files in the :file:`boards` directory.
31
+
32
+
These Kconfig options are then used by Oberon PSA Crypto to compile the required cryptographic PSA directives and select the cryptographic drivers.
33
+
See :ref:`crypto_drivers_driver_selection` for more information about the driver selection process.
34
+
35
+
Once built and run, the sample performs the following operations:
25
36
26
37
1. Initialization:
27
38
28
-
a. The Platform Security Architecture (PSA) API is initialized.
29
-
#. A random AES key is generated and imported into the PSA crypto keystore.
39
+
a. The PSA Crypto API is initialized using :c:func:`psa_crypto_init`.
40
+
#. A random 128-bit AES key is generated using :c:func:`psa_generate_key` and stored in the PSA crypto keystore.
41
+
The key is configured with usage flags for both encryption and decryption.
30
42
31
43
#. Encryption and decryption of a sample plaintext:
32
44
33
-
a. A random initialization vector (IV) is generated.
34
-
#. Encryption is performed.
35
-
#. Decryption is performed.
45
+
a. An encryption operation is set up using :c:func:`psa_cipher_encrypt_setup` with the ``PSA_ALG_CBC_NO_PADDING`` algorithm.
46
+
#. A random initialization vector (IV) is generated using :c:func:`psa_cipher_generate_iv`.
47
+
#. Encryption is performed using :c:func:`psa_cipher_update` and finalized with :c:func:`psa_cipher_finish`.
48
+
#. A decryption operation is set up using :c:func:`psa_cipher_decrypt_setup`.
49
+
#. The IV from the encryption step is set using :c:func:`psa_cipher_set_iv`.
50
+
#. Decryption is performed using :c:func:`psa_cipher_update` and finalized with :c:func:`psa_cipher_finish`.
51
+
#. The decrypted text is compared with the original plaintext to verify correctness.
36
52
37
53
#. Cleanup:
38
54
39
-
a. The AES key is removed from the PSA crypto keystore.
55
+
a. The AES key is removed from the PSA crypto keystore using :c:func:`psa_destroy_key`.
40
56
41
57
Building and running
42
58
********************
@@ -50,6 +66,49 @@ Testing
50
66
51
67
After programming the sample to your development kit, complete the following steps to test it:
52
68
69
+
.. crypto_sample_testing_start
70
+
53
71
1. |connect_terminal|
54
-
#. Compile and program the application.
55
-
#. Observe the logs from the application using a terminal emulator.
72
+
#. Build and program the application.
73
+
#. Observe the logs from the application using the terminal emulator.
74
+
For example, the log output should look like this:
Copy file name to clipboardExpand all lines: samples/crypto/aes_ccm/README.rst
+58-13Lines changed: 58 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,8 @@ Crypto: AES CCM
7
7
:local:
8
8
:depth: 2
9
9
10
-
The AES CCM sample shows how to perform authenticated encryption and decryption operations using the CCM algorithm and a 128-bit key.
11
-
The sample uses additional data and a random nonce.
10
+
The AES CCM sample demonstrates how to use the :ref:`PSA Crypto API <ug_psa_certified_api_overview_crypto>` to perform authenticated encryption and decryption operations using the CCM AEAD algorithm with a 128-bit AES key.
11
+
The sample uses additional authenticated data (AAD) and a random nonce.
12
12
13
13
Requirements
14
14
************
@@ -22,22 +22,36 @@ The sample supports the following development kits:
22
22
Overview
23
23
********
24
24
25
-
The sample performs the following operations:
25
+
The sample :ref:`enables PSA Crypto API <psa_crypto_support_enable>` and configures the following Kconfig options for the cryptographic features:
26
+
27
+
* :kconfig:option:`CONFIG_PSA_WANT_KEY_TYPE_AES` - Used to enable support for AES key types from among the supported cryptographic operations for :ref:`ug_crypto_supported_features_key_types`.
28
+
* :kconfig:option:`CONFIG_PSA_WANT_ALG_CCM` - Used to enable support for the CCM AEAD algorithm from among the supported cryptographic operations for :ref:`ug_crypto_supported_features_aead_algorithms`.
29
+
* :kconfig:option:`CONFIG_PSA_WANT_GENERATE_RANDOM` - Used to enable random number generation for key generation from among the supported cryptographic operations for :ref:`ug_crypto_supported_features_rng_algorithms`.
30
+
31
+
The sample also configures the cryptographic drivers for each board target using Kconfig options in the overlay files in the :file:`boards` directory.
32
+
33
+
These Kconfig options are then used by Oberon PSA Crypto to compile the required cryptographic PSA directives and select the cryptographic drivers.
34
+
See :ref:`crypto_drivers_driver_selection` for more information about the driver selection process.
35
+
36
+
Once built and run, the sample performs the following operations:
26
37
27
38
1. Initialization:
28
39
29
-
a. The Platform Security Architecture (PSA) API is initialized.
30
-
#. A random AES key is generated and imported into the PSA crypto keystore.
40
+
a. The PSA Crypto API is initialized using :c:func:`psa_crypto_init`.
41
+
#. A random 128-bit AES key is generated using :c:func:`psa_generate_key` and stored in the PSA crypto keystore.
42
+
The key is configured with usage flags for both encryption and decryption.
31
43
32
-
#. Encryption and decryption of a sample plaintext:
44
+
#. Authenticated encryption and decryption of a sample plaintext:
33
45
34
-
a. A random nonce is generated.
35
-
#. Authenticated encryption is performed.
36
-
#. Authenticated decryption is performed.
46
+
a. Authenticated encryption is performed using :c:func:`psa_aead_encrypt` with the ``PSA_ALG_CCM`` algorithm.
47
+
This function encrypts the plaintext with the provided nonce and additional authenticated data, and appends an authentication tag to the ciphertext.
48
+
#. Authenticated decryption is performed using :c:func:`psa_aead_decrypt`.
49
+
This function decrypts the ciphertext, verifies the authentication tag, and authenticates the additional data.
50
+
#. The decrypted text is compared with the original plaintext to verify correctness.
37
51
38
52
#. Cleanup:
39
53
40
-
a. The AES key is removed from the PSA crypto keystore.
54
+
a. The AES key is removed from the PSA crypto keystore using :c:func:`psa_destroy_key`.
41
55
42
56
Building and running
43
57
********************
@@ -51,6 +65,37 @@ Testing
51
65
52
66
After programming the sample to your development kit, complete the following steps to test it:
53
67
54
-
1. |connect_terminal|
55
-
#. Compile and program the application.
56
-
#. Observe the logs from the application using a terminal emulator.
Copy file name to clipboardExpand all lines: samples/crypto/aes_ctr/README.rst
+55-11Lines changed: 55 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Crypto: AES CTR
7
7
:local:
8
8
:depth: 2
9
9
10
-
The AES CTR sample shows how to perform AES encryption and decryption operations using the CTR block cipher mode without padding and a 128-bit AES key.
10
+
The AES CTR sample demonstrates how to use the :ref:`PSA Crypto API <ug_psa_certified_api_overview_crypto>` to perform AES encryption and decryption operations using the CTR block cipher mode and a 128-bit AES key.
11
11
12
12
Requirements
13
13
************
@@ -21,22 +21,38 @@ The sample supports the following development kits:
21
21
Overview
22
22
********
23
23
24
-
The sample performs the following operations:
24
+
The sample :ref:`enables PSA Crypto API <psa_crypto_support_enable>` and configures the following Kconfig options for the cryptographic features:
25
+
26
+
* :kconfig:option:`CONFIG_PSA_WANT_KEY_TYPE_AES` - Used to enable support for AES key types from among the supported cryptographic operations for :ref:`ug_crypto_supported_features_key_types`.
27
+
* :kconfig:option:`CONFIG_PSA_WANT_ALG_CTR` - Used to enable support for the CTR cipher mode from among the supported cryptographic operations for :ref:`ug_crypto_supported_features_cipher_modes`.
28
+
* :kconfig:option:`CONFIG_PSA_WANT_GENERATE_RANDOM` - Used to enable random number generation for key and IV generation from among the supported cryptographic operations for :ref:`ug_crypto_supported_features_rng_algorithms`.
29
+
30
+
The sample also configures the cryptographic drivers for each board target using Kconfig options in the overlay files in the :file:`boards` directory.
31
+
32
+
These Kconfig options are then used by Oberon PSA Crypto to compile the required cryptographic PSA directives and select the cryptographic drivers.
33
+
See :ref:`crypto_drivers_driver_selection` for more information about the driver selection process.
34
+
35
+
Once built and run, the sample performs the following operations:
25
36
26
37
1. Initialization:
27
38
28
-
a. The Platform Security Architecture (PSA) API is initialized.
29
-
#. A random AES key is generated and imported into the PSA crypto keystore.
39
+
a. The PSA Crypto API is initialized using :c:func:`psa_crypto_init`.
40
+
#. A random 128-bit AES key is generated using :c:func:`psa_generate_key` and stored in the PSA crypto keystore.
41
+
The key is configured with usage flags for both encryption and decryption.
30
42
31
43
#. Encryption and decryption of a sample plaintext:
32
44
33
-
a. A random initialization vector (IV) is generated.
34
-
#. Encryption is performed.
35
-
#. Decryption is performed.
45
+
a. An encryption operation is set up using :c:func:`psa_cipher_encrypt_setup` with the ``PSA_ALG_CTR`` algorithm.
46
+
#. A random initialization vector (IV) is generated using :c:func:`psa_cipher_generate_iv`.
47
+
#. Encryption is performed using :c:func:`psa_cipher_update` and finalized with :c:func:`psa_cipher_finish`.
48
+
#. A decryption operation is set up using :c:func:`psa_cipher_decrypt_setup`.
49
+
#. The IV from the encryption step is set using :c:func:`psa_cipher_set_iv`.
50
+
#. Decryption is performed using :c:func:`psa_cipher_update` and finalized with :c:func:`psa_cipher_finish`.
51
+
#. The decrypted text is compared with the original plaintext to verify correctness.
36
52
37
53
#. Cleanup:
38
54
39
-
a. The AES key is removed from the PSA crypto keystore.
55
+
a. The AES key is removed from the PSA crypto keystore using :c:func:`psa_destroy_key`.
40
56
41
57
Building and running
42
58
********************
@@ -51,6 +67,34 @@ Testing
51
67
52
68
After programming the sample to your development kit, complete the following steps to test it:
53
69
54
-
1. |connect_terminal|
55
-
#. Compile and program the application.
56
-
#. Observe the logs from the application using a terminal emulator.
0 commit comments