1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /*! 8 @addtogroup ecdh_edwards 9 @} 10 */ 11 12 /*! 13 @file 14 15 @brief This file contains the CryptoCell ECDH Edwards curve APIs. 16 */ 17 18 #ifndef ECDH_EDWARDS_H 19 #define ECDH_EDWARDS_H 20 21 #ifdef __cplusplus 22 extern "C" 23 { 24 #endif 25 26 27 #include "mbedtls/ecp.h" 28 29 /*************************** Defines *****************************************/ 30 31 /*************************** Typedefs ***************************************/ 32 33 /*************************** Enums *******************************************/ 34 35 /*************************** Structs ****************************************/ 36 37 /*************************** context Structs ********************************/ 38 39 /*! 40 @brief This function generates a public key and a TLS ServerKeyExchange 41 payload. 42 43 This is the first function used by a TLS server for ECDHE ciphersuites. 44 45 @note This function can be used only for curve 25519. 46 47 @note This function assumes that the ECP group (\c grp) of the 48 \p ctx context has already been properly set, 49 for example, using mbedtls_ecp_group_load(). 50 51 @see ecp.h 52 53 @return \c 0 on success. 54 @return An \c MBEDTLS_ERR_ECP_XXX error code on failure. 55 */ 56 57 int mbedtls_ecdh_make_params_edwards( 58 /*! The ECDH context. */ 59 mbedtls_ecdh_context *ctx, 60 /*! The number of characters written. */ 61 size_t *olen, 62 /*! The destination buffer. */ 63 unsigned char *buf, 64 /*! The length of the destination buffer. */ 65 size_t blen, 66 /*! The RNG function. */ 67 int (*f_rng)(void *, unsigned char *, size_t), 68 /*! The RNG context. */ 69 void *p_rng 70 ); 71 72 /*! 73 @brief This function parses and processes a TLS ServerKeyExhange 74 payload. 75 76 This is the first function used by a TLS client for ECDHE ciphersuites. 77 78 @note This function can be used only for curve 25519. 79 80 @see ecp.h 81 82 @return \c 0 on success. 83 @return An \c MBEDTLS_ERR_ECP_XXX error code on failure. 84 */ 85 int mbedtls_ecdh_read_params_edwards( 86 /*! The ECDH context. */ 87 mbedtls_ecdh_context *ctx, 88 /*! The pointer to the start of the input buffer. */ 89 const unsigned char **buf, 90 /*! The address for one byte past the end of the buffer. */ 91 const unsigned char *end 92 ); 93 94 95 #ifdef __cplusplus 96 } 97 #endif 98 99 /*! 100 @} 101 */ 102 #endif /* MBEDTLS_ECDH_EDWARDS */ 103