Gabor Mezei | b903070 | 2022-07-18 23:09:45 +0200 | [diff] [blame] | 1 | /** |
Janos Follath | 6318468 | 2022-08-11 17:42:59 +0100 | [diff] [blame] | 2 | * Core bignum functions |
| 3 | * |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 4 | * This interface should only be used by the legacy bignum module (bignum.h) |
Janos Follath | 6318468 | 2022-08-11 17:42:59 +0100 | [diff] [blame] | 5 | * and the modular bignum modules (bignum_mod.c, bignum_mod_raw.c). All other |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 6 | * modules should use the high-level modular bignum interface (bignum_mod.h) |
Janos Follath | 6318468 | 2022-08-11 17:42:59 +0100 | [diff] [blame] | 7 | * or the legacy bignum interface (bignum.h). |
Gabor Mezei | b903070 | 2022-07-18 23:09:45 +0200 | [diff] [blame] | 8 | * |
| 9 | * Copyright The Mbed TLS Contributors |
| 10 | * SPDX-License-Identifier: Apache-2.0 |
| 11 | * |
| 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 13 | * not use this file except in compliance with the License. |
| 14 | * You may obtain a copy of the License at |
| 15 | * |
| 16 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 17 | * |
| 18 | * Unless required by applicable law or agreed to in writing, software |
| 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | * See the License for the specific language governing permissions and |
| 22 | * limitations under the License. |
| 23 | */ |
| 24 | |
| 25 | #ifndef MBEDTLS_BIGNUM_CORE_H |
| 26 | #define MBEDTLS_BIGNUM_CORE_H |
| 27 | |
| 28 | #include "common.h" |
| 29 | |
| 30 | #if defined(MBEDTLS_BIGNUM_C) |
| 31 | #include "mbedtls/bignum.h" |
| 32 | #endif |
| 33 | |
Tom Cosgrove | 5eefc3d | 2022-08-31 17:16:50 +0100 | [diff] [blame] | 34 | #define ciL ( sizeof(mbedtls_mpi_uint) ) /* chars in limb */ |
| 35 | #define biL ( ciL << 3 ) /* bits in limb */ |
| 36 | #define biH ( ciL << 2 ) /* half limb size */ |
| 37 | |
| 38 | /* |
| 39 | * Convert between bits/chars and number of limbs |
| 40 | * Divide first in order to avoid potential overflows |
| 41 | */ |
| 42 | #define BITS_TO_LIMBS(i) ( (i) / biL + ( (i) % biL != 0 ) ) |
| 43 | #define CHARS_TO_LIMBS(i) ( (i) / ciL + ( (i) % ciL != 0 ) ) |
| 44 | /* Get a specific byte, without range checks. */ |
| 45 | #define GET_BYTE( X, i ) \ |
| 46 | ( ( (X)[(i) / ciL] >> ( ( (i) % ciL ) * 8 ) ) & 0xff ) |
| 47 | |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 48 | /** Count leading zero bits in a given integer. |
| 49 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 50 | * \param a Integer to count leading zero bits. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 51 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 52 | * \return The number of leading zero bits in \p a. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 53 | */ |
Janos Follath | 2e328c8 | 2022-08-22 11:19:10 +0100 | [diff] [blame] | 54 | size_t mbedtls_mpi_core_clz( mbedtls_mpi_uint a ); |
Janos Follath | 4670f88 | 2022-07-21 18:25:42 +0100 | [diff] [blame] | 55 | |
Janos Follath | a95f204 | 2022-08-19 12:09:17 +0100 | [diff] [blame] | 56 | /** Return the minimum number of bits required to represent the value held |
Janos Follath | 6318468 | 2022-08-11 17:42:59 +0100 | [diff] [blame] | 57 | * in the MPI. |
| 58 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 59 | * \note This function returns 0 if all the limbs of \p A are 0. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 60 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 61 | * \param[in] A The address of the MPI. |
Janos Follath | c459641 | 2022-08-22 10:01:27 +0100 | [diff] [blame] | 62 | * \param A_limbs The number of limbs of \p A. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 63 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 64 | * \return The number of bits in \p A. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 65 | */ |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 66 | size_t mbedtls_mpi_core_bitlen( const mbedtls_mpi_uint *A, size_t A_limbs ); |
Janos Follath | 4670f88 | 2022-07-21 18:25:42 +0100 | [diff] [blame] | 67 | |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 68 | /** Convert a big-endian byte array aligned to the size of mbedtls_mpi_uint |
| 69 | * into the storage form used by mbedtls_mpi. |
| 70 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 71 | * \param[in,out] A The address of the MPI. |
Janos Follath | c459641 | 2022-08-22 10:01:27 +0100 | [diff] [blame] | 72 | * \param A_limbs The number of limbs of \p A. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 73 | */ |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 74 | void mbedtls_mpi_core_bigendian_to_host( mbedtls_mpi_uint *A, |
Janos Follath | c459641 | 2022-08-22 10:01:27 +0100 | [diff] [blame] | 75 | size_t A_limbs ); |
Janos Follath | 4670f88 | 2022-07-21 18:25:42 +0100 | [diff] [blame] | 76 | |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 77 | /** Import X from unsigned binary data, little-endian. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 78 | * |
Janos Follath | 6318468 | 2022-08-11 17:42:59 +0100 | [diff] [blame] | 79 | * The MPI needs to have enough limbs to store the full value (including any |
| 80 | * most significant zero bytes in the input). |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 81 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 82 | * \param[out] X The address of the MPI. |
| 83 | * \param X_limbs The number of limbs of \p X. |
| 84 | * \param[in] input The input buffer to import from. |
| 85 | * \param input_length The length bytes of \p input. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 86 | * |
| 87 | * \return \c 0 if successful. |
| 88 | * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p X isn't |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 89 | * large enough to hold the value in \p input. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 90 | */ |
Gabor Mezei | b903070 | 2022-07-18 23:09:45 +0200 | [diff] [blame] | 91 | int mbedtls_mpi_core_read_le( mbedtls_mpi_uint *X, |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 92 | size_t X_limbs, |
| 93 | const unsigned char *input, |
| 94 | size_t input_length ); |
Gabor Mezei | b903070 | 2022-07-18 23:09:45 +0200 | [diff] [blame] | 95 | |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 96 | /** Import X from unsigned binary data, big-endian. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 97 | * |
Janos Follath | 6318468 | 2022-08-11 17:42:59 +0100 | [diff] [blame] | 98 | * The MPI needs to have enough limbs to store the full value (including any |
| 99 | * most significant zero bytes in the input). |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 100 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 101 | * \param[out] X The address of the MPI. |
| 102 | * May only be #NULL if \X_limbs is 0 and \p input_length |
| 103 | * is 0. |
| 104 | * \param X_limbs The number of limbs of \p X. |
| 105 | * \param[in] input The input buffer to import from. |
| 106 | * May only be #NULL if \p input_length is 0. |
| 107 | * \param input_length The length in bytes of \p input. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 108 | * |
| 109 | * \return \c 0 if successful. |
| 110 | * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p X isn't |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 111 | * large enough to hold the value in \p input. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 112 | */ |
Gabor Mezei | b903070 | 2022-07-18 23:09:45 +0200 | [diff] [blame] | 113 | int mbedtls_mpi_core_read_be( mbedtls_mpi_uint *X, |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 114 | size_t X_limbs, |
| 115 | const unsigned char *input, |
| 116 | size_t input_length ); |
Gabor Mezei | b903070 | 2022-07-18 23:09:45 +0200 | [diff] [blame] | 117 | |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 118 | /** Export A into unsigned binary data, little-endian. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 119 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 120 | * \note If \p output is shorter than \p A the export is still successful if the |
| 121 | * value held in \p A fits in the buffer (that is, if enough of the most |
| 122 | * significant bytes of \p A are 0). |
Janos Follath | 6318468 | 2022-08-11 17:42:59 +0100 | [diff] [blame] | 123 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 124 | * \param[in] A The address of the MPI. |
| 125 | * \param A_limbs The number of limbs of \p A. |
| 126 | * \param[out] output The output buffer to export to. |
| 127 | * \param output_length The length in bytes of \p output. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 128 | * |
| 129 | * \return \c 0 if successful. |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 130 | * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p output isn't |
| 131 | * large enough to hold the value of \p A. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 132 | */ |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 133 | int mbedtls_mpi_core_write_le( const mbedtls_mpi_uint *A, |
| 134 | size_t A_limbs, |
| 135 | unsigned char *output, |
| 136 | size_t output_length ); |
Gabor Mezei | b903070 | 2022-07-18 23:09:45 +0200 | [diff] [blame] | 137 | |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 138 | /** Export A into unsigned binary data, big-endian. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 139 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 140 | * \note If \p output is shorter than \p A the export is still successful if the |
| 141 | * value held in \p A fits in the buffer (that is, if enough of the most |
| 142 | * significant bytes of \p A are 0). |
Janos Follath | 6318468 | 2022-08-11 17:42:59 +0100 | [diff] [blame] | 143 | * |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 144 | * \param[in] A The address of the MPI. |
| 145 | * \param A_limbs The number of limbs of \p A. |
| 146 | * \param[out] output The output buffer to export to. |
| 147 | * \param output_length The length in bytes of \p output. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 148 | * |
| 149 | * \return \c 0 if successful. |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 150 | * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p output isn't |
| 151 | * large enough to hold the value of \p A. |
Gabor Mezei | 37b0636 | 2022-08-02 17:22:18 +0200 | [diff] [blame] | 152 | */ |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 153 | int mbedtls_mpi_core_write_be( const mbedtls_mpi_uint *A, |
| 154 | size_t A_limbs, |
| 155 | unsigned char *output, |
| 156 | size_t output_length ); |
Gabor Mezei | b903070 | 2022-07-18 23:09:45 +0200 | [diff] [blame] | 157 | |
Tom Cosgrove | 90c426b | 2022-08-23 16:15:19 +0100 | [diff] [blame] | 158 | /** |
Tom Cosgrove | d932de8 | 2022-08-25 16:43:43 +0100 | [diff] [blame] | 159 | * \brief Conditional addition of two known-size large unsigned integers, |
| 160 | * returning the carry. |
Hanno Becker | 71f4b0d | 2022-08-23 12:09:35 +0100 | [diff] [blame] | 161 | * |
| 162 | * Functionally equivalent to |
| 163 | * |
| 164 | * ``` |
| 165 | * if( cond ) |
Tom Cosgrove | 7259463 | 2022-08-24 11:51:58 +0100 | [diff] [blame] | 166 | * A += B; |
Hanno Becker | 71f4b0d | 2022-08-23 12:09:35 +0100 | [diff] [blame] | 167 | * return carry; |
| 168 | * ``` |
| 169 | * |
Tom Cosgrove | 7259463 | 2022-08-24 11:51:58 +0100 | [diff] [blame] | 170 | * \param[in,out] A The pointer to the (little-endian) array |
| 171 | * representing the bignum to accumulate onto. |
| 172 | * \param[in] B The pointer to the (little-endian) array |
| 173 | * representing the bignum to conditionally add |
Tom Cosgrove | ed43c6c | 2022-08-31 11:35:00 +0100 | [diff] [blame] | 174 | * to \p A. This may be aliased to \p A but may not |
| 175 | * overlap otherwise. |
Tom Cosgrove | 7259463 | 2022-08-24 11:51:58 +0100 | [diff] [blame] | 176 | * \param limbs Number of limbs of \p A and \p B. |
| 177 | * \param cond Condition bit dictating whether addition should |
| 178 | * happen or not. This must be \c 0 or \c 1. |
Hanno Becker | 71f4b0d | 2022-08-23 12:09:35 +0100 | [diff] [blame] | 179 | * |
Tom Cosgrove | ecbb124 | 2022-08-25 10:13:44 +0100 | [diff] [blame] | 180 | * \warning If \p cond is neither 0 nor 1, the result of this function |
Tom Cosgrove | 7259463 | 2022-08-24 11:51:58 +0100 | [diff] [blame] | 181 | * is unspecified, and the resulting value in \p A might be |
| 182 | * neither its original value nor \p A + \p B. |
| 183 | * |
Tom Cosgrove | 630110a | 2022-08-31 17:09:29 +0100 | [diff] [blame] | 184 | * \return 1 if `A + cond * B >= 2^(biL*limbs)`, 0 otherwise. |
Hanno Becker | 71f4b0d | 2022-08-23 12:09:35 +0100 | [diff] [blame] | 185 | */ |
Tom Cosgrove | 7259463 | 2022-08-24 11:51:58 +0100 | [diff] [blame] | 186 | mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *A, |
| 187 | const mbedtls_mpi_uint *B, |
| 188 | size_t limbs, |
Tom Cosgrove | 90c426b | 2022-08-23 16:15:19 +0100 | [diff] [blame] | 189 | unsigned cond ); |
Hanno Becker | 71f4b0d | 2022-08-23 12:09:35 +0100 | [diff] [blame] | 190 | |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 191 | /** |
| 192 | * \brief Subtract two known-size large unsigned integers, returning the borrow. |
| 193 | * |
Tom Cosgrove | 5dd97e6 | 2022-08-30 14:31:49 +0100 | [diff] [blame] | 194 | * Calculate `A - B` where \p A and \p B have the same size. |
Tom Cosgrove | 630110a | 2022-08-31 17:09:29 +0100 | [diff] [blame] | 195 | * This function operates modulo `2^(biL*limbs)` and returns the carry |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 196 | * (1 if there was a wraparound, i.e. if `A < B`, and 0 otherwise). |
| 197 | * |
Tom Cosgrove | 5dd97e6 | 2022-08-30 14:31:49 +0100 | [diff] [blame] | 198 | * \p X may be aliased to \p A or \p B, or even both, but may not overlap |
| 199 | * either otherwise. |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 200 | * |
| 201 | * \param[out] X The result of the subtraction. |
| 202 | * \param[in] A Little-endian presentation of left operand. |
| 203 | * \param[in] B Little-endian presentation of right operand. |
| 204 | * \param limbs Number of limbs of \p X, \p A and \p B. |
| 205 | * |
| 206 | * \return 1 if `A < B`. |
| 207 | * 0 if `A >= B`. |
| 208 | */ |
| 209 | mbedtls_mpi_uint mbedtls_mpi_core_sub( mbedtls_mpi_uint *X, |
| 210 | const mbedtls_mpi_uint *A, |
| 211 | const mbedtls_mpi_uint *B, |
| 212 | size_t limbs ); |
| 213 | |
| 214 | /** |
| 215 | * \brief Perform a known-size multiply accumulate operation: A += c * B |
| 216 | * |
| 217 | * \param[in,out] A The pointer to the (little-endian) array |
| 218 | * representing the bignum to accumulate onto. |
| 219 | * \param A_limbs The number of limbs of \p A. This must be |
| 220 | * at least \p B_limbs. |
| 221 | * \param[in] B The pointer to the (little-endian) array |
| 222 | * representing the bignum to multiply with. |
Tom Cosgrove | ed43c6c | 2022-08-31 11:35:00 +0100 | [diff] [blame] | 223 | * This may be aliased to \p A but may not overlap |
| 224 | * otherwise. |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 225 | * \param B_limbs The number of limbs of \p B. |
| 226 | * \param c A scalar to multiply with. |
| 227 | * |
| 228 | * \return The carry at the end of the operation. |
| 229 | */ |
| 230 | mbedtls_mpi_uint mbedtls_mpi_core_mla( mbedtls_mpi_uint *A, size_t A_limbs, |
| 231 | const mbedtls_mpi_uint *B, size_t B_limbs, |
| 232 | mbedtls_mpi_uint c ); |
| 233 | |
| 234 | /** |
| 235 | * \brief Calculate initialisation value for fast Montgomery modular |
| 236 | * multiplication |
| 237 | * |
| 238 | * \param[in] N Little-endian presentation of the modulus. This must have |
| 239 | * at least one limb. |
| 240 | * |
| 241 | * \return The initialisation value for fast Montgomery modular multiplication |
| 242 | */ |
Tom Cosgrove | b7438d1 | 2022-09-15 15:05:59 +0100 | [diff] [blame^] | 243 | mbedtls_mpi_uint mbedtls_mpi_core_montmul_init( const mbedtls_mpi_uint *N ); |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 244 | |
| 245 | /** |
| 246 | * \brief Montgomery multiplication: X = A * B * R^-1 mod N (HAC 14.36) |
| 247 | * |
| 248 | * \param[out] X The destination MPI, as a little-endian array of |
| 249 | * length \p AN_limbs. |
| 250 | * On successful completion, X contains the result of |
Tom Cosgrove | 630110a | 2022-08-31 17:09:29 +0100 | [diff] [blame] | 251 | * the multiplication `A * B * R^-1` mod N where |
| 252 | * `R = 2^(biL*AN_limbs)`. |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 253 | * \param[in] A Little-endian presentation of first operand. |
Tom Cosgrove | 5dd97e6 | 2022-08-30 14:31:49 +0100 | [diff] [blame] | 254 | * Must have the same number of limbs as \p N. |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 255 | * \param[in] B Little-endian presentation of second operand. |
| 256 | * \param[in] B_limbs The number of limbs in \p B. |
Tom Cosgrove | 5dd97e6 | 2022-08-30 14:31:49 +0100 | [diff] [blame] | 257 | * Must be <= \p AN_limbs. |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 258 | * \param[in] N Little-endian presentation of the modulus. |
Tom Cosgrove | 5dd97e6 | 2022-08-30 14:31:49 +0100 | [diff] [blame] | 259 | * This must be odd, and have exactly the same number |
| 260 | * of limbs as \p A. |
| 261 | * \param[in] AN_limbs The number of limbs in \p X, \p A and \p N. |
Tom Cosgrove | 630110a | 2022-08-31 17:09:29 +0100 | [diff] [blame] | 262 | * \param mm The Montgomery constant for \p N: -N^-1 mod 2^biL. |
Tom Cosgrove | b7438d1 | 2022-09-15 15:05:59 +0100 | [diff] [blame^] | 263 | * This can be calculated by `mbedtls_mpi_core_montmul_init()`. |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 264 | * \param[in,out] T Temporary storage of size at least 2*AN_limbs+1 limbs. |
| 265 | * Its initial content is unused and |
| 266 | * its final content is indeterminate. |
Tom Cosgrove | 818d992 | 2022-09-15 14:58:10 +0100 | [diff] [blame] | 267 | * It must not overlap any of the other parameters. |
Tom Cosgrove | b496486 | 2022-08-30 11:57:22 +0100 | [diff] [blame] | 268 | */ |
| 269 | void mbedtls_mpi_core_montmul( mbedtls_mpi_uint *X, |
| 270 | const mbedtls_mpi_uint *A, |
| 271 | const mbedtls_mpi_uint *B, size_t B_limbs, |
| 272 | const mbedtls_mpi_uint *N, size_t AN_limbs, |
| 273 | mbedtls_mpi_uint mm, mbedtls_mpi_uint *T ); |
| 274 | |
Gabor Mezei | b903070 | 2022-07-18 23:09:45 +0200 | [diff] [blame] | 275 | #endif /* MBEDTLS_BIGNUM_CORE_H */ |