1a8e1175bSopenharmony_ci/**
2a8e1175bSopenharmony_ci * \file ecp_invasive.h
3a8e1175bSopenharmony_ci *
4a8e1175bSopenharmony_ci * \brief ECP module: interfaces for invasive testing only.
5a8e1175bSopenharmony_ci *
6a8e1175bSopenharmony_ci * The interfaces in this file are intended for testing purposes only.
7a8e1175bSopenharmony_ci * They SHOULD NOT be made available in library integrations except when
8a8e1175bSopenharmony_ci * building the library for testing.
9a8e1175bSopenharmony_ci */
10a8e1175bSopenharmony_ci/*
11a8e1175bSopenharmony_ci *  Copyright The Mbed TLS Contributors
12a8e1175bSopenharmony_ci *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
13a8e1175bSopenharmony_ci */
14a8e1175bSopenharmony_ci#ifndef MBEDTLS_ECP_INVASIVE_H
15a8e1175bSopenharmony_ci#define MBEDTLS_ECP_INVASIVE_H
16a8e1175bSopenharmony_ci
17a8e1175bSopenharmony_ci#include "common.h"
18a8e1175bSopenharmony_ci#include "mbedtls/bignum.h"
19a8e1175bSopenharmony_ci#include "bignum_mod.h"
20a8e1175bSopenharmony_ci#include "mbedtls/ecp.h"
21a8e1175bSopenharmony_ci
22a8e1175bSopenharmony_ci/*
23a8e1175bSopenharmony_ci * Curve modulus types
24a8e1175bSopenharmony_ci */
25a8e1175bSopenharmony_citypedef enum {
26a8e1175bSopenharmony_ci    MBEDTLS_ECP_MOD_NONE = 0,
27a8e1175bSopenharmony_ci    MBEDTLS_ECP_MOD_COORDINATE,
28a8e1175bSopenharmony_ci    MBEDTLS_ECP_MOD_SCALAR
29a8e1175bSopenharmony_ci} mbedtls_ecp_modulus_type;
30a8e1175bSopenharmony_ci
31a8e1175bSopenharmony_citypedef enum {
32a8e1175bSopenharmony_ci    MBEDTLS_ECP_VARIANT_NONE = 0,
33a8e1175bSopenharmony_ci    MBEDTLS_ECP_VARIANT_WITH_MPI_STRUCT,
34a8e1175bSopenharmony_ci    MBEDTLS_ECP_VARIANT_WITH_MPI_UINT
35a8e1175bSopenharmony_ci} mbedtls_ecp_variant;
36a8e1175bSopenharmony_ci
37a8e1175bSopenharmony_ci#if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_ECP_LIGHT)
38a8e1175bSopenharmony_ci
39a8e1175bSopenharmony_ci/** Queries the ecp variant.
40a8e1175bSopenharmony_ci *
41a8e1175bSopenharmony_ci * \return  The id of the ecp variant.
42a8e1175bSopenharmony_ci */
43a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
44a8e1175bSopenharmony_cimbedtls_ecp_variant mbedtls_ecp_get_variant(void);
45a8e1175bSopenharmony_ci
46a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED)
47a8e1175bSopenharmony_ci/** Generate a private key on a Montgomery curve (Curve25519 or Curve448).
48a8e1175bSopenharmony_ci *
49a8e1175bSopenharmony_ci * This function implements key generation for the set of secret keys
50a8e1175bSopenharmony_ci * specified in [Curve25519] p. 5 and in [Curve448]. The resulting value
51a8e1175bSopenharmony_ci * has the lower bits masked but is not necessarily canonical.
52a8e1175bSopenharmony_ci *
53a8e1175bSopenharmony_ci * \note            - [Curve25519] http://cr.yp.to/ecdh/curve25519-20060209.pdf
54a8e1175bSopenharmony_ci *                  - [RFC7748] https://tools.ietf.org/html/rfc7748
55a8e1175bSopenharmony_ci *
56a8e1175bSopenharmony_ci * \p high_bit      The position of the high-order bit of the key to generate.
57a8e1175bSopenharmony_ci *                  This is the bit-size of the key minus 1:
58a8e1175bSopenharmony_ci *                  254 for Curve25519 or 447 for Curve448.
59a8e1175bSopenharmony_ci * \param d         The randomly generated key. This is a number of size
60a8e1175bSopenharmony_ci *                  exactly \p high_bit + 1 bits, with the least significant bits
61a8e1175bSopenharmony_ci *                  masked as specified in [Curve25519] and in [RFC7748] §5.
62a8e1175bSopenharmony_ci * \param f_rng     The RNG function.
63a8e1175bSopenharmony_ci * \param p_rng     The RNG context to be passed to \p f_rng.
64a8e1175bSopenharmony_ci *
65a8e1175bSopenharmony_ci * \return          \c 0 on success.
66a8e1175bSopenharmony_ci * \return          \c MBEDTLS_ERR_ECP_xxx or MBEDTLS_ERR_MPI_xxx on failure.
67a8e1175bSopenharmony_ci */
68a8e1175bSopenharmony_ciint mbedtls_ecp_gen_privkey_mx(size_t high_bit,
69a8e1175bSopenharmony_ci                               mbedtls_mpi *d,
70a8e1175bSopenharmony_ci                               int (*f_rng)(void *, unsigned char *, size_t),
71a8e1175bSopenharmony_ci                               void *p_rng);
72a8e1175bSopenharmony_ci
73a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */
74a8e1175bSopenharmony_ci
75a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
76a8e1175bSopenharmony_ci
77a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p192 (FIPS 186-3 D.2.1)
78a8e1175bSopenharmony_ci *
79a8e1175bSopenharmony_ci * This operation expects a 384 bit MPI and the result of the reduction
80a8e1175bSopenharmony_ci * is a 192 bit MPI.
81a8e1175bSopenharmony_ci *
82a8e1175bSopenharmony_ci * \param[in,out]   Np  The address of the MPI to be converted.
83a8e1175bSopenharmony_ci *                      Must have twice as many limbs as the modulus.
84a8e1175bSopenharmony_ci *                      Upon return this holds the reduced value. The bitlength
85a8e1175bSopenharmony_ci *                      of the reduced value is the same as that of the modulus
86a8e1175bSopenharmony_ci *                      (192 bits).
87a8e1175bSopenharmony_ci * \param[in]       Nn  The length of \p Np in limbs.
88a8e1175bSopenharmony_ci */
89a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
90a8e1175bSopenharmony_ciint mbedtls_ecp_mod_p192_raw(mbedtls_mpi_uint *Np, size_t Nn);
91a8e1175bSopenharmony_ci
92a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */
93a8e1175bSopenharmony_ci
94a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
95a8e1175bSopenharmony_ci
96a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p224 (FIPS 186-3 D.2.2)
97a8e1175bSopenharmony_ci *
98a8e1175bSopenharmony_ci * \param[in,out]   X       The address of the MPI to be converted.
99a8e1175bSopenharmony_ci *                          Must have exact limb size that stores a 448-bit MPI
100a8e1175bSopenharmony_ci *                          (double the bitlength of the modulus).
101a8e1175bSopenharmony_ci *                          Upon return holds the reduced value which is
102a8e1175bSopenharmony_ci *                          in range `0 <= X < 2 * N` (where N is the modulus).
103a8e1175bSopenharmony_ci *                          The bitlength of the reduced value is the same as
104a8e1175bSopenharmony_ci *                          that of the modulus (224 bits).
105a8e1175bSopenharmony_ci * \param[in]       X_limbs The length of \p X in limbs.
106a8e1175bSopenharmony_ci *
107a8e1175bSopenharmony_ci * \return          \c 0 on success.
108a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p X_limbs is not the
109a8e1175bSopenharmony_ci *                  limb size that sores a 448-bit MPI.
110a8e1175bSopenharmony_ci */
111a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
112a8e1175bSopenharmony_ciint mbedtls_ecp_mod_p224_raw(mbedtls_mpi_uint *X, size_t X_limbs);
113a8e1175bSopenharmony_ci
114a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */
115a8e1175bSopenharmony_ci
116a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
117a8e1175bSopenharmony_ci
118a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p256 (FIPS 186-3 D.2.3)
119a8e1175bSopenharmony_ci *
120a8e1175bSopenharmony_ci * \param[in,out]   X       The address of the MPI to be converted.
121a8e1175bSopenharmony_ci *                          Must have exact limb size that stores a 512-bit MPI
122a8e1175bSopenharmony_ci *                          (double the bitlength of the modulus).
123a8e1175bSopenharmony_ci *                          Upon return holds the reduced value which is
124a8e1175bSopenharmony_ci *                          in range `0 <= X < 2 * N` (where N is the modulus).
125a8e1175bSopenharmony_ci *                          The bitlength of the reduced value is the same as
126a8e1175bSopenharmony_ci *                          that of the modulus (256 bits).
127a8e1175bSopenharmony_ci * \param[in]       X_limbs The length of \p X in limbs.
128a8e1175bSopenharmony_ci *
129a8e1175bSopenharmony_ci * \return          \c 0 on success.
130a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p X_limbs is not the
131a8e1175bSopenharmony_ci *                  limb size that sores a 512-bit MPI.
132a8e1175bSopenharmony_ci */
133a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
134a8e1175bSopenharmony_ciint mbedtls_ecp_mod_p256_raw(mbedtls_mpi_uint *X, size_t X_limbs);
135a8e1175bSopenharmony_ci
136a8e1175bSopenharmony_ci#endif
137a8e1175bSopenharmony_ci
138a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
139a8e1175bSopenharmony_ci
140a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p521 = 2^521 - 1 (FIPS 186-3 D.2.5)
141a8e1175bSopenharmony_ci *
142a8e1175bSopenharmony_ci * \param[in,out]   X       The address of the MPI to be converted.
143a8e1175bSopenharmony_ci *                          Must have twice as many limbs as the modulus
144a8e1175bSopenharmony_ci *                          (the modulus is 521 bits long). Upon return this
145a8e1175bSopenharmony_ci *                          holds the reduced value. The reduced value is
146a8e1175bSopenharmony_ci *                          in range `0 <= X < 2 * N` (where N is the modulus).
147a8e1175bSopenharmony_ci *                          and its the bitlength is one plus the bitlength
148a8e1175bSopenharmony_ci *                          of the modulus.
149a8e1175bSopenharmony_ci * \param[in]       X_limbs The length of \p X in limbs.
150a8e1175bSopenharmony_ci *
151a8e1175bSopenharmony_ci * \return          \c 0 on success.
152a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p X_limbs does not have
153a8e1175bSopenharmony_ci *                  twice as many limbs as the modulus.
154a8e1175bSopenharmony_ci */
155a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
156a8e1175bSopenharmony_ciint mbedtls_ecp_mod_p521_raw(mbedtls_mpi_uint *X, size_t X_limbs);
157a8e1175bSopenharmony_ci
158a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */
159a8e1175bSopenharmony_ci
160a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
161a8e1175bSopenharmony_ci
162a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p384 (FIPS 186-3 D.2.4)
163a8e1175bSopenharmony_ci *
164a8e1175bSopenharmony_ci * \param[in,out]   X       The address of the MPI to be converted.
165a8e1175bSopenharmony_ci *                          Must have exact limb size that stores a 768-bit MPI
166a8e1175bSopenharmony_ci *                          (double the bitlength of the modulus).
167a8e1175bSopenharmony_ci *                          Upon return holds the reduced value which is
168a8e1175bSopenharmony_ci *                          in range `0 <= X < 2 * N` (where N is the modulus).
169a8e1175bSopenharmony_ci *                          The bitlength of the reduced value is the same as
170a8e1175bSopenharmony_ci *                          that of the modulus (384 bits).
171a8e1175bSopenharmony_ci * \param[in]       X_limbs The length of \p N in limbs.
172a8e1175bSopenharmony_ci *
173a8e1175bSopenharmony_ci * \return          \c 0 on success.
174a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p N_n does not have
175a8e1175bSopenharmony_ci *                  twice as many limbs as the modulus.
176a8e1175bSopenharmony_ci */
177a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
178a8e1175bSopenharmony_ciint  mbedtls_ecp_mod_p384_raw(mbedtls_mpi_uint *X, size_t X_limbs);
179a8e1175bSopenharmony_ci
180a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */
181a8e1175bSopenharmony_ci
182a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
183a8e1175bSopenharmony_ci
184a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p192k1 = 2^192 - R,
185a8e1175bSopenharmony_ci * with R = 2^32 + 2^12 + 2^8 + 2^7 + 2^6 + 2^3 + 1 = 0x01000011C9
186a8e1175bSopenharmony_ci *
187a8e1175bSopenharmony_ci * \param[in,out]   X       The address of the MPI to be converted.
188a8e1175bSopenharmony_ci *                          Must have exact limb size that stores a 384-bit MPI
189a8e1175bSopenharmony_ci *                          (double the bitlength of the modulus).
190a8e1175bSopenharmony_ci *                          Upon return holds the reduced value which is
191a8e1175bSopenharmony_ci *                          in range `0 <= X < 2 * N` (where N is the modulus).
192a8e1175bSopenharmony_ci *                          The bitlength of the reduced value is the same as
193a8e1175bSopenharmony_ci *                          that of the modulus (192 bits).
194a8e1175bSopenharmony_ci * \param[in]       X_limbs The length of \p X in limbs.
195a8e1175bSopenharmony_ci *
196a8e1175bSopenharmony_ci * \return          \c 0 on success.
197a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p X does not have
198a8e1175bSopenharmony_ci *                  twice as many limbs as the modulus.
199a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_ALLOC_FAILED if memory allocation failed.
200a8e1175bSopenharmony_ci */
201a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
202a8e1175bSopenharmony_ciint mbedtls_ecp_mod_p192k1_raw(mbedtls_mpi_uint *X, size_t X_limbs);
203a8e1175bSopenharmony_ci
204a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */
205a8e1175bSopenharmony_ci
206a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
207a8e1175bSopenharmony_ci
208a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p224k1 = 2^224 - R,
209a8e1175bSopenharmony_ci * with R = 2^32 + 2^12 + 2^11 + 2^9 + 2^7 + 2^4 + 2 + 1 = 0x0100001A93
210a8e1175bSopenharmony_ci *
211a8e1175bSopenharmony_ci * \param[in,out]   X       The address of the MPI to be converted.
212a8e1175bSopenharmony_ci *                          Must have exact limb size that stores a 448-bit MPI
213a8e1175bSopenharmony_ci *                          (double the bitlength of the modulus).
214a8e1175bSopenharmony_ci *                          Upon return holds the reduced value which is
215a8e1175bSopenharmony_ci *                          in range `0 <= X < 2 * N` (where N is the modulus).
216a8e1175bSopenharmony_ci *                          The bitlength of the reduced value is the same as
217a8e1175bSopenharmony_ci *                          that of the modulus (224 bits).
218a8e1175bSopenharmony_ci * \param[in]       X_limbs The length of \p X in limbs.
219a8e1175bSopenharmony_ci *
220a8e1175bSopenharmony_ci * \return          \c 0 on success.
221a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p X does not have
222a8e1175bSopenharmony_ci *                  twice as many limbs as the modulus.
223a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_ALLOC_FAILED if memory allocation failed.
224a8e1175bSopenharmony_ci */
225a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
226a8e1175bSopenharmony_ciint mbedtls_ecp_mod_p224k1_raw(mbedtls_mpi_uint *X, size_t X_limbs);
227a8e1175bSopenharmony_ci
228a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */
229a8e1175bSopenharmony_ci
230a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
231a8e1175bSopenharmony_ci
232a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p256k1 = 2^256 - R,
233a8e1175bSopenharmony_ci * with R = 2^32 + 2^9 + 2^8 + 2^7 + 2^6 + 2^4 + 1 = 0x01000003D1
234a8e1175bSopenharmony_ci *
235a8e1175bSopenharmony_ci * \param[in,out]   X       The address of the MPI to be converted.
236a8e1175bSopenharmony_ci *                          Must have exact limb size that stores a 512-bit MPI
237a8e1175bSopenharmony_ci *                          (double the bitlength of the modulus).
238a8e1175bSopenharmony_ci *                          Upon return holds the reduced value which is
239a8e1175bSopenharmony_ci *                          in range `0 <= X < 2 * N` (where N is the modulus).
240a8e1175bSopenharmony_ci *                          The bitlength of the reduced value is the same as
241a8e1175bSopenharmony_ci *                          that of the modulus (256 bits).
242a8e1175bSopenharmony_ci * \param[in]       X_limbs The length of \p X in limbs.
243a8e1175bSopenharmony_ci *
244a8e1175bSopenharmony_ci * \return          \c 0 on success.
245a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p X does not have
246a8e1175bSopenharmony_ci *                  twice as many limbs as the modulus.
247a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_ALLOC_FAILED if memory allocation failed.
248a8e1175bSopenharmony_ci */
249a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
250a8e1175bSopenharmony_ciint mbedtls_ecp_mod_p256k1_raw(mbedtls_mpi_uint *X, size_t X_limbs);
251a8e1175bSopenharmony_ci
252a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
253a8e1175bSopenharmony_ci
254a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
255a8e1175bSopenharmony_ci
256a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p255 = 2^255 - 19
257a8e1175bSopenharmony_ci *
258a8e1175bSopenharmony_ci * \param[in,out]   X       The address of the MPI to be converted.
259a8e1175bSopenharmony_ci *                          Must have exact limb size that stores a 510-bit MPI
260a8e1175bSopenharmony_ci *                          (double the bitlength of the modulus).
261a8e1175bSopenharmony_ci *                          Upon return holds the reduced value which is
262a8e1175bSopenharmony_ci *                          in range `0 <= X < 2 * N` (where N is the modulus).
263a8e1175bSopenharmony_ci * \param[in]       X_limbs The length of \p X in limbs.
264a8e1175bSopenharmony_ci *
265a8e1175bSopenharmony_ci * \return          \c 0 on success.
266a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p X does not have
267a8e1175bSopenharmony_ci *                  twice as many limbs as the modulus.
268a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_ALLOC_FAILED if memory allocation failed.
269a8e1175bSopenharmony_ci */
270a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
271a8e1175bSopenharmony_ciint mbedtls_ecp_mod_p255_raw(mbedtls_mpi_uint *X, size_t X_limbs);
272a8e1175bSopenharmony_ci
273a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */
274a8e1175bSopenharmony_ci
275a8e1175bSopenharmony_ci#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
276a8e1175bSopenharmony_ci
277a8e1175bSopenharmony_ci/** Fast quasi-reduction modulo p448 = 2^448 - 2^224 - 1
278a8e1175bSopenharmony_ci * Write X as A0 + 2^448 A1 and A1 as B0 + 2^224 B1, and return A0 + A1 + B1 +
279a8e1175bSopenharmony_ci * (B0 + B1) * 2^224.
280a8e1175bSopenharmony_ci *
281a8e1175bSopenharmony_ci * \param[in,out]   X       The address of the MPI to be converted.
282a8e1175bSopenharmony_ci *                          Must have exact limb size that stores a 896-bit MPI
283a8e1175bSopenharmony_ci *                          (double the bitlength of the modulus). Upon return
284a8e1175bSopenharmony_ci *                          holds the reduced value which is in range `0 <= X <
285a8e1175bSopenharmony_ci *                          N` (where N is the modulus). The bitlength of the
286a8e1175bSopenharmony_ci *                          reduced value is the same as that of the modulus
287a8e1175bSopenharmony_ci *                          (448 bits).
288a8e1175bSopenharmony_ci * \param[in]       X_limbs The length of \p X in limbs.
289a8e1175bSopenharmony_ci *
290a8e1175bSopenharmony_ci * \return          \c 0 on Success.
291a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p X does not have
292a8e1175bSopenharmony_ci *                  twice as many limbs as the modulus.
293a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_ALLOC_FAILED if memory allocation
294a8e1175bSopenharmony_ci *                  failed.
295a8e1175bSopenharmony_ci */
296a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
297a8e1175bSopenharmony_ciint mbedtls_ecp_mod_p448_raw(mbedtls_mpi_uint *X, size_t X_limbs);
298a8e1175bSopenharmony_ci
299a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */
300a8e1175bSopenharmony_ci
301a8e1175bSopenharmony_ci/** Initialise a modulus with hard-coded const curve data.
302a8e1175bSopenharmony_ci *
303a8e1175bSopenharmony_ci * \note            The caller is responsible for the \p N modulus' memory.
304a8e1175bSopenharmony_ci *                  mbedtls_mpi_mod_modulus_free(&N) should be invoked at the
305a8e1175bSopenharmony_ci *                  end of its lifecycle.
306a8e1175bSopenharmony_ci *
307a8e1175bSopenharmony_ci * \param[in,out] N The address of the modulus structure to populate.
308a8e1175bSopenharmony_ci *                  Must be initialized.
309a8e1175bSopenharmony_ci * \param[in] id    The mbedtls_ecp_group_id for which to initialise the modulus.
310a8e1175bSopenharmony_ci * \param[in] ctype The mbedtls_ecp_modulus_type identifier for a coordinate modulus (P)
311a8e1175bSopenharmony_ci *                  or a scalar modulus (N).
312a8e1175bSopenharmony_ci *
313a8e1175bSopenharmony_ci * \return          \c 0 if successful.
314a8e1175bSopenharmony_ci * \return          #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the given MPIs do not
315a8e1175bSopenharmony_ci *                  have the correct number of limbs.
316a8e1175bSopenharmony_ci *
317a8e1175bSopenharmony_ci */
318a8e1175bSopenharmony_ciMBEDTLS_STATIC_TESTABLE
319a8e1175bSopenharmony_ciint mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N,
320a8e1175bSopenharmony_ci                              const mbedtls_ecp_group_id id,
321a8e1175bSopenharmony_ci                              const mbedtls_ecp_modulus_type ctype);
322a8e1175bSopenharmony_ci
323a8e1175bSopenharmony_ci#endif /* MBEDTLS_TEST_HOOKS && MBEDTLS_ECP_C */
324a8e1175bSopenharmony_ci
325a8e1175bSopenharmony_ci#endif /* MBEDTLS_ECP_INVASIVE_H */
326