1 /*
2  * Copyright (c) 2024, The TrustedFirmware-M Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __CC3XX_ECDH_H__
9 #define __CC3XX_ECDH_H__
10 
11 #include <stdint.h>
12 #include <stddef.h>
13 
14 #include "cc3xx_error.h"
15 #include "cc3xx_ec.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /**
22  * @brief                         Generate a shared secret following the ECDH algorithm
23  *
24  * @param[in] curve_id            The ID of the curve to use.
25  * @param[in] private_key         The buffer to load the private key from.
26  * @param[in] private_key_len     The size of the private key buffer.
27  * @param[in] public_key_x        The buffer to load the public key x coord from.
28  * @param[in] public_key_x_len    The size of the public key x coord buffer.
29  * @param[in] public_key_y        The buffer to load the public key x coord from.
30  * @param[in] public_key_y_len    The size of the public key y coord key buffer.
31  * @param[out] shared_secret      The buffer to write the shared secret into.
32  * @param[in] shared_secret_len   The size of the shared secret key buffer.
33  * @param[out] shared_secret_size The size of the shared secret written into
34  *                                the \a shared_secret buffer.
35  *
36  * @return cc3xx_err_t            CC3XX_ERR_SUCCESS on success, another
37  *                                cc3xx_err_t on error.
38  */
39 cc3xx_err_t cc3xx_lowlevel_ecdh(cc3xx_ec_curve_id_t curve_id,
40                                 const uint32_t *private_key, size_t private_key_len,
41                                 const uint32_t *public_key_x, size_t public_key_x_len,
42                                 const uint32_t *public_key_y, size_t public_key_y_len,
43                                 uint32_t *shared_secret, size_t shared_secret_len,
44                                 size_t *shared_secret_size);
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 
50 #endif /* __CC3XX_ECDH_H__ */
51