2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
7 #ifndef MBEDTLS_DHM_ALT_H
8 #define MBEDTLS_DHM_ALT_H
11 #if defined(MBEDTLS_DHM_ALT)
14 #if defined(MBEDTLS_CONFIG_FILE)
15 #include MBEDTLS_CONFIG_FILE
23 #define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080 /**< Bad input parameters. */
24 #define MBEDTLS_ERR_DHM_READ_PARAMS_FAILED -0x3100 /**< Reading of the DHM parameters failed. */
25 #define MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 /**< Making of the DHM parameters failed. */
26 #define MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED -0x3200 /**< Reading of the public values failed. */
27 #define MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 /**< Making of the public value failed. */
28 #define MBEDTLS_ERR_DHM_CALC_SECRET_FAILED -0x3300 /**< Calculation of the DHM secret failed. */
29 #define MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380 /**< The ASN.1 data is not formatted correctly. */
30 #define MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400 /**< Allocation of memory failed. */
31 #define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 /**< Read or write of file failed. */
32 #define MBEDTLS_ERR_DHM_HW_ACCEL_FAILED -0x3500 /**< DHM hardware accelerator failed. */
33 #define MBEDTLS_ERR_DHM_SET_GROUP_FAILED -0x3580 /**< Setting the modulus and generator failed. */
40 * \brief The DHM context structure.
44 size_t len; /*!< The size of \p P in Bytes. */
45 mbedtls_mpi P; /*!< The prime modulus. */
46 mbedtls_mpi G; /*!< The generator. */
47 mbedtls_mpi X; /*!< Our secret value. */
48 mbedtls_mpi GX; /*!< Our public key = \c G^X mod \c P. */
49 mbedtls_mpi GY; /*!< The public key of the peer = \c G^Y mod \c P. */
50 mbedtls_mpi K; /*!< The shared secret = \c G^(XY) mod \c P. */
51 mbedtls_mpi RP; /*!< The cached value = \c R^2 mod \c P. */
52 mbedtls_mpi Vi; /*!< The blinding value. */
53 mbedtls_mpi Vf; /*!< The unblinding value. */
54 mbedtls_mpi pX; /*!< The previous \c X. */
62 #endif /* MBEDTLS_DHM_ALT - use alternative code */
63 #endif /* MBEDTLS_DHM_ALT_H - include only once */