Change script for apply upstream code
[platform/upstream/connectedhomeip.git] / third_party / openthread / repo / third_party / NordicSemiconductor / libraries / nrf_security / include / mbedtls / dhm_alt.h
1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
5  */
6
7 #ifndef MBEDTLS_DHM_ALT_H
8 #define MBEDTLS_DHM_ALT_H
9
10
11 #if defined(MBEDTLS_DHM_ALT)
12
13
14 #if defined(MBEDTLS_CONFIG_FILE)
15 #include MBEDTLS_CONFIG_FILE
16 #endif
17
18 #include <stddef.h>
19
20 /*
21  * DHM Error codes
22  */
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. */
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /**
40  * \brief          The DHM context structure.
41  */
42 typedef struct
43 {
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. */
55 }
56 mbedtls_dhm_context;
57
58 #ifdef __cplusplus
59 }
60 #endif
61
62 #endif  /* MBEDTLS_DHM_ALT  - use alternative code */
63 #endif  /* MBEDTLS_DHM_ALT_H  - include only once  */