| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 1 | /** | 
| Gilles Peskine | 6a2fb61 | 2021-05-24 22:25:04 +0200 | [diff] [blame] | 2 | * \file ecp_internal_alt.h | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 3 | * | 
| Janos Follath | 372697b | 2016-10-28 16:53:11 +0100 | [diff] [blame] | 4 | * \brief Function declarations for alternative implementation of elliptic curve | 
|  | 5 | * point arithmetic. | 
| Darryl Green | a40a101 | 2018-01-05 15:33:17 +0000 | [diff] [blame] | 6 | */ | 
|  | 7 | /* | 
| Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 8 | *  Copyright The Mbed TLS Contributors | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 9 | *  SPDX-License-Identifier: Apache-2.0 | 
|  | 10 | * | 
|  | 11 | *  Licensed under the Apache License, Version 2.0 (the "License"); you may | 
|  | 12 | *  not use this file except in compliance with the License. | 
|  | 13 | *  You may obtain a copy of the License at | 
|  | 14 | * | 
|  | 15 | *  http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 16 | * | 
|  | 17 | *  Unless required by applicable law or agreed to in writing, software | 
|  | 18 | *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
|  | 19 | *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 20 | *  See the License for the specific language governing permissions and | 
|  | 21 | *  limitations under the License. | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 22 | */ | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 23 |  | 
|  | 24 | /* | 
|  | 25 | * References: | 
|  | 26 | * | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 27 | * [1] BERNSTEIN, Daniel J. Curve25519: new Diffie-Hellman speed records. | 
|  | 28 | *     <http://cr.yp.to/ecdh/curve25519-20060209.pdf> | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 29 | * | 
|  | 30 | * [2] CORON, Jean-S'ebastien. Resistance against differential power analysis | 
|  | 31 | *     for elliptic curve cryptosystems. In : Cryptographic Hardware and | 
|  | 32 | *     Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302. | 
|  | 33 | *     <http://link.springer.com/chapter/10.1007/3-540-48059-5_25> | 
|  | 34 | * | 
|  | 35 | * [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to | 
|  | 36 | *     render ECC resistant against Side Channel Attacks. IACR Cryptology | 
|  | 37 | *     ePrint Archive, 2004, vol. 2004, p. 342. | 
|  | 38 | *     <http://eprint.iacr.org/2004/342.pdf> | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 39 | * | 
|  | 40 | * [4] Certicom Research. SEC 2: Recommended Elliptic Curve Domain Parameters. | 
|  | 41 | *     <http://www.secg.org/sec2-v2.pdf> | 
|  | 42 | * | 
|  | 43 | * [5] HANKERSON, Darrel, MENEZES, Alfred J., VANSTONE, Scott. Guide to Elliptic | 
|  | 44 | *     Curve Cryptography. | 
|  | 45 | * | 
|  | 46 | * [6] Digital Signature Standard (DSS), FIPS 186-4. | 
|  | 47 | *     <http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf> | 
|  | 48 | * | 
| Darryl Green | 11999bb | 2018-03-13 15:22:58 +0000 | [diff] [blame] | 49 | * [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 50 | *     Security (TLS), RFC 4492. | 
|  | 51 | *     <https://tools.ietf.org/search/rfc4492> | 
|  | 52 | * | 
|  | 53 | * [8] <http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian.html> | 
|  | 54 | * | 
|  | 55 | * [9] COHEN, Henri. A Course in Computational Algebraic Number Theory. | 
|  | 56 | *     Springer Science & Business Media, 1 Aug 2000 | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 57 | */ | 
|  | 58 |  | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 59 | #ifndef MBEDTLS_ECP_INTERNAL_H | 
|  | 60 | #define MBEDTLS_ECP_INTERNAL_H | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 61 |  | 
| Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 62 | #include "mbedtls/build_info.h" | 
| Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 63 |  | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 64 | #if defined(MBEDTLS_ECP_INTERNAL_ALT) | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 65 |  | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 66 | /** | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 67 | * \brief           Indicate if the Elliptic Curve Point module extension can | 
|  | 68 | *                  handle the group. | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 69 | * | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 70 | * \param grp       The pointer to the elliptic curve group that will be the | 
|  | 71 | *                  basis of the cryptographic computations. | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 72 | * | 
|  | 73 | * \return          Non-zero if successful. | 
|  | 74 | */ | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 75 | unsigned char mbedtls_internal_ecp_grp_capable( const mbedtls_ecp_group *grp ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 76 |  | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 77 | /** | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 78 | * \brief           Initialise the Elliptic Curve Point module extension. | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 79 | * | 
|  | 80 | *                  If mbedtls_internal_ecp_grp_capable returns true for a | 
|  | 81 | *                  group, this function has to be able to initialise the | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 82 | *                  module for it. | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 83 | * | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 84 | *                  This module can be a driver to a crypto hardware | 
|  | 85 | *                  accelerator, for which this could be an initialise function. | 
|  | 86 | * | 
|  | 87 | * \param grp       The pointer to the group the module needs to be | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 88 | *                  initialised for. | 
|  | 89 | * | 
|  | 90 | * \return          0 if successful. | 
|  | 91 | */ | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 92 | int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 93 |  | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 94 | /** | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 95 | * \brief           Frees and deallocates the Elliptic Curve Point module | 
|  | 96 | *                  extension. | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 97 | * | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 98 | * \param grp       The pointer to the group the module was initialised for. | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 99 | */ | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 100 | void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 101 |  | 
| Gilles Peskine | e8c04fe | 2018-09-14 17:44:21 +0200 | [diff] [blame] | 102 | #if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 103 |  | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 104 | #if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 105 | /** | 
|  | 106 | * \brief           Randomize jacobian coordinates: | 
|  | 107 | *                  (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l. | 
|  | 108 | * | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 109 | * \param grp       Pointer to the group representing the curve. | 
|  | 110 | * | 
|  | 111 | * \param pt        The point on the curve to be randomised, given with Jacobian | 
|  | 112 | *                  coordinates. | 
|  | 113 | * | 
|  | 114 | * \param f_rng     A function pointer to the random number generator. | 
|  | 115 | * | 
|  | 116 | * \param p_rng     A pointer to the random number generator state. | 
|  | 117 | * | 
|  | 118 | * \return          0 if successful. | 
|  | 119 | */ | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 120 | int mbedtls_internal_ecp_randomize_jac( const mbedtls_ecp_group *grp, | 
| Janos Follath | b8a90fb | 2016-11-15 13:45:01 +0000 | [diff] [blame] | 121 | mbedtls_ecp_point *pt, int (*f_rng)(void *, unsigned char *, size_t), | 
|  | 122 | void *p_rng ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 123 | #endif | 
|  | 124 |  | 
|  | 125 | #if defined(MBEDTLS_ECP_ADD_MIXED_ALT) | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 126 | /** | 
|  | 127 | * \brief           Addition: R = P + Q, mixed affine-Jacobian coordinates. | 
|  | 128 | * | 
|  | 129 | *                  The coordinates of Q must be normalized (= affine), | 
|  | 130 | *                  but those of P don't need to. R is not normalized. | 
|  | 131 | * | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 132 | *                  This function is used only as a subrutine of | 
|  | 133 | *                  ecp_mul_comb(). | 
|  | 134 | * | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 135 | *                  Special cases: (1) P or Q is zero, (2) R is zero, | 
|  | 136 | *                      (3) P == Q. | 
|  | 137 | *                  None of these cases can happen as intermediate step in | 
|  | 138 | *                  ecp_mul_comb(): | 
|  | 139 | *                      - at each step, P, Q and R are multiples of the base | 
|  | 140 | *                      point, the factor being less than its order, so none of | 
|  | 141 | *                      them is zero; | 
|  | 142 | *                      - Q is an odd multiple of the base point, P an even | 
|  | 143 | *                      multiple, due to the choice of precomputed points in the | 
|  | 144 | *                      modified comb method. | 
|  | 145 | *                  So branches for these cases do not leak secret information. | 
|  | 146 | * | 
|  | 147 | *                  We accept Q->Z being unset (saving memory in tables) as | 
|  | 148 | *                  meaning 1. | 
|  | 149 | * | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 150 | *                  Cost in field operations if done by [5] 3.22: | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 151 | *                      1A := 8M + 3S | 
|  | 152 | * | 
|  | 153 | * \param grp       Pointer to the group representing the curve. | 
|  | 154 | * | 
|  | 155 | * \param R         Pointer to a point structure to hold the result. | 
|  | 156 | * | 
|  | 157 | * \param P         Pointer to the first summand, given with Jacobian | 
|  | 158 | *                  coordinates | 
|  | 159 | * | 
|  | 160 | * \param Q         Pointer to the second summand, given with affine | 
|  | 161 | *                  coordinates. | 
|  | 162 | * | 
|  | 163 | * \return          0 if successful. | 
|  | 164 | */ | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 165 | int mbedtls_internal_ecp_add_mixed( const mbedtls_ecp_group *grp, | 
| Janos Follath | b8a90fb | 2016-11-15 13:45:01 +0000 | [diff] [blame] | 166 | mbedtls_ecp_point *R, const mbedtls_ecp_point *P, | 
|  | 167 | const mbedtls_ecp_point *Q ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 168 | #endif | 
|  | 169 |  | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 170 | /** | 
|  | 171 | * \brief           Point doubling R = 2 P, Jacobian coordinates. | 
|  | 172 | * | 
|  | 173 | *                  Cost:   1D := 3M + 4S    (A ==  0) | 
|  | 174 | *                          4M + 4S          (A == -3) | 
|  | 175 | *                          3M + 6S + 1a     otherwise | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 176 | *                  when the implementation is based on the "dbl-1998-cmo-2" | 
|  | 177 | *                  doubling formulas in [8] and standard optimizations are | 
|  | 178 | *                  applied when curve parameter A is one of { 0, -3 }. | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 179 | * | 
|  | 180 | * \param grp       Pointer to the group representing the curve. | 
|  | 181 | * | 
|  | 182 | * \param R         Pointer to a point structure to hold the result. | 
|  | 183 | * | 
|  | 184 | * \param P         Pointer to the point that has to be doubled, given with | 
|  | 185 | *                  Jacobian coordinates. | 
|  | 186 | * | 
|  | 187 | * \return          0 if successful. | 
|  | 188 | */ | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 189 | #if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 190 | int mbedtls_internal_ecp_double_jac( const mbedtls_ecp_group *grp, | 
| Janos Follath | b8a90fb | 2016-11-15 13:45:01 +0000 | [diff] [blame] | 191 | mbedtls_ecp_point *R, const mbedtls_ecp_point *P ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 192 | #endif | 
|  | 193 |  | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 194 | /** | 
|  | 195 | * \brief           Normalize jacobian coordinates of an array of (pointers to) | 
|  | 196 | *                  points. | 
|  | 197 | * | 
|  | 198 | *                  Using Montgomery's trick to perform only one inversion mod P | 
|  | 199 | *                  the cost is: | 
|  | 200 | *                      1N(t) := 1I + (6t - 3)M + 1S | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 201 | *                  (See for example Algorithm 10.3.4. in [9]) | 
|  | 202 | * | 
|  | 203 | *                  This function is used only as a subrutine of | 
|  | 204 | *                  ecp_mul_comb(). | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 205 | * | 
|  | 206 | *                  Warning: fails (returning an error) if one of the points is | 
|  | 207 | *                  zero! | 
|  | 208 | *                  This should never happen, see choice of w in ecp_mul_comb(). | 
|  | 209 | * | 
|  | 210 | * \param grp       Pointer to the group representing the curve. | 
|  | 211 | * | 
|  | 212 | * \param T         Array of pointers to the points to normalise. | 
|  | 213 | * | 
|  | 214 | * \param t_len     Number of elements in the array. | 
|  | 215 | * | 
|  | 216 | * \return          0 if successful, | 
|  | 217 | *                      an error if one of the points is zero. | 
|  | 218 | */ | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 219 | #if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 220 | int mbedtls_internal_ecp_normalize_jac_many( const mbedtls_ecp_group *grp, | 
| Janos Follath | b8a90fb | 2016-11-15 13:45:01 +0000 | [diff] [blame] | 221 | mbedtls_ecp_point *T[], size_t t_len ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 222 | #endif | 
|  | 223 |  | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 224 | /** | 
|  | 225 | * \brief           Normalize jacobian coordinates so that Z == 0 || Z == 1. | 
|  | 226 | * | 
| Janos Follath | 5634b86 | 2016-12-08 16:15:51 +0000 | [diff] [blame] | 227 | *                  Cost in field operations if done by [5] 3.2.1: | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 228 | *                      1N := 1I + 3M + 1S | 
|  | 229 | * | 
|  | 230 | * \param grp       Pointer to the group representing the curve. | 
|  | 231 | * | 
|  | 232 | * \param pt        pointer to the point to be normalised. This is an | 
|  | 233 | *                  input/output parameter. | 
|  | 234 | * | 
|  | 235 | * \return          0 if successful. | 
|  | 236 | */ | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 237 | #if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 238 | int mbedtls_internal_ecp_normalize_jac( const mbedtls_ecp_group *grp, | 
| Janos Follath | b8a90fb | 2016-11-15 13:45:01 +0000 | [diff] [blame] | 239 | mbedtls_ecp_point *pt ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 240 | #endif | 
|  | 241 |  | 
| Gilles Peskine | e8c04fe | 2018-09-14 17:44:21 +0200 | [diff] [blame] | 242 | #endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 243 |  | 
| Gilles Peskine | e8c04fe | 2018-09-14 17:44:21 +0200 | [diff] [blame] | 244 | #if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 245 |  | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 246 | #if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 247 | int mbedtls_internal_ecp_double_add_mxz( const mbedtls_ecp_group *grp, | 
| Janos Follath | b8a90fb | 2016-11-15 13:45:01 +0000 | [diff] [blame] | 248 | mbedtls_ecp_point *R, mbedtls_ecp_point *S, const mbedtls_ecp_point *P, | 
|  | 249 | const mbedtls_ecp_point *Q, const mbedtls_mpi *d ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 250 | #endif | 
|  | 251 |  | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 252 | /** | 
|  | 253 | * \brief           Randomize projective x/z coordinates: | 
|  | 254 | *                      (X, Z) -> (l X, l Z) for random l | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 255 | * | 
|  | 256 | * \param grp       pointer to the group representing the curve | 
|  | 257 | * | 
|  | 258 | * \param P         the point on the curve to be randomised given with | 
|  | 259 | *                  projective coordinates. This is an input/output parameter. | 
|  | 260 | * | 
|  | 261 | * \param f_rng     a function pointer to the random number generator | 
|  | 262 | * | 
|  | 263 | * \param p_rng     a pointer to the random number generator state | 
|  | 264 | * | 
|  | 265 | * \return          0 if successful | 
|  | 266 | */ | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 267 | #if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 268 | int mbedtls_internal_ecp_randomize_mxz( const mbedtls_ecp_group *grp, | 
| Janos Follath | b8a90fb | 2016-11-15 13:45:01 +0000 | [diff] [blame] | 269 | mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t), | 
|  | 270 | void *p_rng ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 271 | #endif | 
|  | 272 |  | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 273 | /** | 
|  | 274 | * \brief           Normalize Montgomery x/z coordinates: X = X/Z, Z = 1. | 
|  | 275 | * | 
|  | 276 | * \param grp       pointer to the group representing the curve | 
|  | 277 | * | 
|  | 278 | * \param P         pointer to the point to be normalised. This is an | 
|  | 279 | *                  input/output parameter. | 
|  | 280 | * | 
|  | 281 | * \return          0 if successful | 
|  | 282 | */ | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 283 | #if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 284 | int mbedtls_internal_ecp_normalize_mxz( const mbedtls_ecp_group *grp, | 
| Janos Follath | b8a90fb | 2016-11-15 13:45:01 +0000 | [diff] [blame] | 285 | mbedtls_ecp_point *P ); | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 286 | #endif | 
|  | 287 |  | 
| Gilles Peskine | e8c04fe | 2018-09-14 17:44:21 +0200 | [diff] [blame] | 288 | #endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ | 
| Janos Follath | aab9efb | 2016-12-02 13:49:21 +0000 | [diff] [blame] | 289 |  | 
| Janos Follath | c44ab97 | 2016-11-18 16:38:23 +0000 | [diff] [blame] | 290 | #endif /* MBEDTLS_ECP_INTERNAL_ALT */ | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 291 |  | 
| Gilles Peskine | 6a2fb61 | 2021-05-24 22:25:04 +0200 | [diff] [blame] | 292 | #endif /* ecp_internal_alt.h */ | 
| Janos Follath | b069753 | 2016-08-18 12:38:46 +0100 | [diff] [blame] | 293 |  |