This example uses the PSA Crypto API to perform ECDH key agreement on the supported device.
The Elliptic Curve Diffie-Hellman (ECDH) is an anonymous key agreement protocol that allows two parties, each having an elliptic-curve private-public key pair, to establish a shared secret over an insecure channel.
In this example, two peers (client and server) each generate their Elliptic Curve Cryptography (ECC) key pair. They exchange public keys and compute a shared secret using their private ECC keys. These secrets are compared with each other to make sure they are equal.
The example redirects standard I/O to the virtual serial port (VCOM) of the kit. By default, the serial port setting is 115200 bps and 8-N-1 configuration.
Except for the Series 1 Cortex-M0+ device, the example has been instrumented with code to count the number of clock cycles spent in different operations. The results are printed on the VCOM serial port console. This feature can be disabled by defining PSA_CRYPTO_PRINT=0
(default is 1) in the IDE setting (Preprocessor->Defined symbols
).
The following key storages are supported in this example:
The following elliptic curve keys are supported in this example:
PSA_ECC_FAMILY_SECP_R1
:PSA_ECC_FAMILY_MONTGOMERY
:The following key agreement algorithm is supported in this example:
PSA_ALG_ECDH
The PSA_ALG_KEY_AGREEMENT(PSA_ALG_ECDH, PSA_ALG_HKDF(hash_alg))
algorithm is used in the PSA Crypto KDF example.
The following PSA Crypto APIs are used in this example:
psa_crypto_init
psa_key_attributes_init
psa_set_key_type
psa_set_key_bits
psa_set_key_usage_flags
psa_set_key_algorithm
psa_set_key_id
psa_set_key_lifetime
psa_generate_key
psa_reset_key_attributes
psa_export_public_key
psa_raw_key_agreement
psa_destroy_key
mbedtls_psa_crypto_free
Adapter Firmware
under General Device Information in Simplicity Studio 5 Users Guide).Secure Firmware
under General Device Information in Simplicity Studio 5 Users Guide).Device Console
in Simplicity Studio 5, Line terminator:
must be set to None
).Platform()
checkbox to browse the platform examples).4096
) in sl_memory_config.h
can be reset to the default value (2048
) if the software fallback feature in Mbed TLS is disabled.CLIENT_KEY_ID
and SERVER_KEY_ID
values in app_process.h
if these key IDs had already existed in NVM3.Optimize for debugging (-Og)
on Simplicity IDE and None
on IAR Embedded Workbench.