| /* |
| * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. |
| * |
| * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license |
| */ |
| |
| #ifndef MBEDTLS_DHM_ALT_H |
| #define MBEDTLS_DHM_ALT_H |
| |
| |
| #if defined(MBEDTLS_DHM_ALT) |
| |
| |
| #if defined(MBEDTLS_CONFIG_FILE) |
| #include MBEDTLS_CONFIG_FILE |
| #endif |
| |
| #include <stddef.h> |
| |
| /* |
| * DHM Error codes |
| */ |
| #define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080 /**< Bad input parameters. */ |
| #define MBEDTLS_ERR_DHM_READ_PARAMS_FAILED -0x3100 /**< Reading of the DHM parameters failed. */ |
| #define MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 /**< Making of the DHM parameters failed. */ |
| #define MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED -0x3200 /**< Reading of the public values failed. */ |
| #define MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 /**< Making of the public value failed. */ |
| #define MBEDTLS_ERR_DHM_CALC_SECRET_FAILED -0x3300 /**< Calculation of the DHM secret failed. */ |
| #define MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380 /**< The ASN.1 data is not formatted correctly. */ |
| #define MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400 /**< Allocation of memory failed. */ |
| #define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 /**< Read or write of file failed. */ |
| #define MBEDTLS_ERR_DHM_HW_ACCEL_FAILED -0x3500 /**< DHM hardware accelerator failed. */ |
| #define MBEDTLS_ERR_DHM_SET_GROUP_FAILED -0x3580 /**< Setting the modulus and generator failed. */ |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| /** |
| * \brief The DHM context structure. |
| */ |
| typedef struct |
| { |
| size_t len; /*!< The size of \p P in Bytes. */ |
| mbedtls_mpi P; /*!< The prime modulus. */ |
| mbedtls_mpi G; /*!< The generator. */ |
| mbedtls_mpi X; /*!< Our secret value. */ |
| mbedtls_mpi GX; /*!< Our public key = \c G^X mod \c P. */ |
| mbedtls_mpi GY; /*!< The public key of the peer = \c G^Y mod \c P. */ |
| mbedtls_mpi K; /*!< The shared secret = \c G^(XY) mod \c P. */ |
| mbedtls_mpi RP; /*!< The cached value = \c R^2 mod \c P. */ |
| mbedtls_mpi Vi; /*!< The blinding value. */ |
| mbedtls_mpi Vf; /*!< The unblinding value. */ |
| mbedtls_mpi pX; /*!< The previous \c X. */ |
| } |
| mbedtls_dhm_context; |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* MBEDTLS_DHM_ALT - use alternative code */ |
| #endif /* MBEDTLS_DHM_ALT_H - include only once */ |