Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 1 | /* |
Janos Follath | a95f204 | 2022-08-19 12:09:17 +0100 | [diff] [blame] | 2 | * Core bignum functions |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 3 | * |
| 4 | * Copyright The Mbed TLS Contributors |
| 5 | * SPDX-License-Identifier: Apache-2.0 |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 8 | * not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | #include "common.h" |
| 21 | |
| 22 | #if defined(MBEDTLS_BIGNUM_C) |
| 23 | |
| 24 | #include <string.h> |
| 25 | |
| 26 | #include "mbedtls/error.h" |
| 27 | #include "mbedtls/platform_util.h" |
| 28 | |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 29 | #include "mbedtls/platform.h" |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 30 | |
| 31 | #include "bignum_core.h" |
| 32 | |
Janos Follath | 2e328c8 | 2022-08-22 11:19:10 +0100 | [diff] [blame] | 33 | size_t mbedtls_mpi_core_clz( mbedtls_mpi_uint a ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 34 | { |
| 35 | size_t j; |
| 36 | mbedtls_mpi_uint mask = (mbedtls_mpi_uint) 1 << (biL - 1); |
| 37 | |
| 38 | for( j = 0; j < biL; j++ ) |
| 39 | { |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 40 | if( a & mask ) break; |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 41 | |
| 42 | mask >>= 1; |
| 43 | } |
| 44 | |
Gabor Mezei | 89e3146 | 2022-08-12 15:36:56 +0200 | [diff] [blame] | 45 | return( j ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 46 | } |
| 47 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 48 | size_t mbedtls_mpi_core_bitlen( const mbedtls_mpi_uint *A, size_t A_limbs ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 49 | { |
| 50 | size_t i, j; |
| 51 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 52 | if( A_limbs == 0 ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 53 | return( 0 ); |
| 54 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 55 | for( i = A_limbs - 1; i > 0; i-- ) |
| 56 | if( A[i] != 0 ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 57 | break; |
| 58 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 59 | j = biL - mbedtls_mpi_core_clz( A[i] ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 60 | |
| 61 | return( ( i * biL ) + j ); |
| 62 | } |
| 63 | |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 64 | /* Convert a big-endian byte array aligned to the size of mbedtls_mpi_uint |
| 65 | * into the storage form used by mbedtls_mpi. */ |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 66 | static mbedtls_mpi_uint mpi_bigendian_to_host_c( mbedtls_mpi_uint a ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 67 | { |
| 68 | uint8_t i; |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 69 | unsigned char *a_ptr; |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 70 | mbedtls_mpi_uint tmp = 0; |
| 71 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 72 | for( i = 0, a_ptr = (unsigned char *) &a; i < ciL; i++, a_ptr++ ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 73 | { |
| 74 | tmp <<= CHAR_BIT; |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 75 | tmp |= (mbedtls_mpi_uint) *a_ptr; |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | return( tmp ); |
| 79 | } |
| 80 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 81 | static mbedtls_mpi_uint mpi_bigendian_to_host( mbedtls_mpi_uint a ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 82 | { |
| 83 | #if defined(__BYTE_ORDER__) |
| 84 | |
| 85 | /* Nothing to do on bigendian systems. */ |
| 86 | #if ( __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ) |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 87 | return( a ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 88 | #endif /* __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ */ |
| 89 | |
| 90 | #if ( __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) |
| 91 | |
| 92 | /* For GCC and Clang, have builtins for byte swapping. */ |
| 93 | #if defined(__GNUC__) && defined(__GNUC_PREREQ) |
| 94 | #if __GNUC_PREREQ(4,3) |
| 95 | #define have_bswap |
| 96 | #endif |
| 97 | #endif |
| 98 | |
| 99 | #if defined(__clang__) && defined(__has_builtin) |
| 100 | #if __has_builtin(__builtin_bswap32) && \ |
| 101 | __has_builtin(__builtin_bswap64) |
| 102 | #define have_bswap |
| 103 | #endif |
| 104 | #endif |
| 105 | |
| 106 | #if defined(have_bswap) |
| 107 | /* The compiler is hopefully able to statically evaluate this! */ |
| 108 | switch( sizeof(mbedtls_mpi_uint) ) |
| 109 | { |
| 110 | case 4: |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 111 | return( __builtin_bswap32(a) ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 112 | case 8: |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 113 | return( __builtin_bswap64(a) ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 114 | } |
| 115 | #endif |
| 116 | #endif /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ |
| 117 | #endif /* __BYTE_ORDER__ */ |
| 118 | |
| 119 | /* Fall back to C-based reordering if we don't know the byte order |
| 120 | * or we couldn't use a compiler-specific builtin. */ |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 121 | return( mpi_bigendian_to_host_c( a ) ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 122 | } |
| 123 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 124 | void mbedtls_mpi_core_bigendian_to_host( mbedtls_mpi_uint *A, |
Janos Follath | c459641 | 2022-08-22 10:01:27 +0100 | [diff] [blame] | 125 | size_t A_limbs ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 126 | { |
| 127 | mbedtls_mpi_uint *cur_limb_left; |
| 128 | mbedtls_mpi_uint *cur_limb_right; |
Janos Follath | c459641 | 2022-08-22 10:01:27 +0100 | [diff] [blame] | 129 | if( A_limbs == 0 ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 130 | return; |
| 131 | |
| 132 | /* |
| 133 | * Traverse limbs and |
| 134 | * - adapt byte-order in each limb |
| 135 | * - swap the limbs themselves. |
| 136 | * For that, simultaneously traverse the limbs from left to right |
| 137 | * and from right to left, as long as the left index is not bigger |
| 138 | * than the right index (it's not a problem if limbs is odd and the |
| 139 | * indices coincide in the last iteration). |
| 140 | */ |
Janos Follath | c459641 | 2022-08-22 10:01:27 +0100 | [diff] [blame] | 141 | for( cur_limb_left = A, cur_limb_right = A + ( A_limbs - 1 ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 142 | cur_limb_left <= cur_limb_right; |
| 143 | cur_limb_left++, cur_limb_right-- ) |
| 144 | { |
| 145 | mbedtls_mpi_uint tmp; |
| 146 | /* Note that if cur_limb_left == cur_limb_right, |
| 147 | * this code effectively swaps the bytes only once. */ |
| 148 | tmp = mpi_bigendian_to_host( *cur_limb_left ); |
| 149 | *cur_limb_left = mpi_bigendian_to_host( *cur_limb_right ); |
| 150 | *cur_limb_right = tmp; |
| 151 | } |
| 152 | } |
| 153 | |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 154 | int mbedtls_mpi_core_read_le( mbedtls_mpi_uint *X, |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 155 | size_t X_limbs, |
| 156 | const unsigned char *input, |
| 157 | size_t input_length ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 158 | { |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 159 | const size_t limbs = CHARS_TO_LIMBS( input_length ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 160 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 161 | if( X_limbs < limbs ) |
Janos Follath | 2ab2d3e | 2022-08-11 16:13:53 +0100 | [diff] [blame] | 162 | return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL ); |
| 163 | |
| 164 | if( X != NULL ) |
Gabor Mezei | bf9da1d | 2022-08-12 14:11:56 +0200 | [diff] [blame] | 165 | { |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 166 | memset( X, 0, X_limbs * ciL ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 167 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 168 | for( size_t i = 0; i < input_length; i++ ) |
Janos Follath | ca5688e | 2022-08-19 12:05:28 +0100 | [diff] [blame] | 169 | { |
| 170 | size_t offset = ( ( i % ciL ) << 3 ); |
| 171 | X[i / ciL] |= ( (mbedtls_mpi_uint) input[i] ) << offset; |
| 172 | } |
Gabor Mezei | bf9da1d | 2022-08-12 14:11:56 +0200 | [diff] [blame] | 173 | } |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 174 | |
Janos Follath | 2ab2d3e | 2022-08-11 16:13:53 +0100 | [diff] [blame] | 175 | return( 0 ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 176 | } |
| 177 | |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 178 | int mbedtls_mpi_core_read_be( mbedtls_mpi_uint *X, |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 179 | size_t X_limbs, |
| 180 | const unsigned char *input, |
| 181 | size_t input_length ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 182 | { |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 183 | const size_t limbs = CHARS_TO_LIMBS( input_length ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 184 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 185 | if( X_limbs < limbs ) |
Janos Follath | 2ab2d3e | 2022-08-11 16:13:53 +0100 | [diff] [blame] | 186 | return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL ); |
| 187 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 188 | /* If X_limbs is 0, input_length must also be 0 (from previous test). |
| 189 | * Nothing to do. */ |
| 190 | if( X_limbs == 0 ) |
Gabor Mezei | c414ba3 | 2022-08-12 17:47:39 +0200 | [diff] [blame] | 191 | return( 0 ); |
| 192 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 193 | memset( X, 0, X_limbs * ciL ); |
Gabor Mezei | c414ba3 | 2022-08-12 17:47:39 +0200 | [diff] [blame] | 194 | |
| 195 | /* memcpy() with (NULL, 0) is undefined behaviour */ |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 196 | if( input_length != 0 ) |
Gabor Mezei | bf9da1d | 2022-08-12 14:11:56 +0200 | [diff] [blame] | 197 | { |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 198 | size_t overhead = ( X_limbs * ciL ) - input_length; |
Gabor Mezei | c414ba3 | 2022-08-12 17:47:39 +0200 | [diff] [blame] | 199 | unsigned char *Xp = (unsigned char *) X; |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 200 | memcpy( Xp + overhead, input, input_length ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 201 | } |
| 202 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 203 | mbedtls_mpi_core_bigendian_to_host( X, X_limbs ); |
Gabor Mezei | c414ba3 | 2022-08-12 17:47:39 +0200 | [diff] [blame] | 204 | |
Janos Follath | 2ab2d3e | 2022-08-11 16:13:53 +0100 | [diff] [blame] | 205 | return( 0 ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 206 | } |
| 207 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 208 | int mbedtls_mpi_core_write_le( const mbedtls_mpi_uint *A, |
| 209 | size_t A_limbs, |
| 210 | unsigned char *output, |
| 211 | size_t output_length ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 212 | { |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 213 | size_t stored_bytes = A_limbs * ciL; |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 214 | size_t bytes_to_copy; |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 215 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 216 | if( stored_bytes < output_length ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 217 | { |
| 218 | bytes_to_copy = stored_bytes; |
| 219 | } |
| 220 | else |
| 221 | { |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 222 | bytes_to_copy = output_length; |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 223 | |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 224 | /* The output buffer is smaller than the allocated size of A. |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 225 | * However A may fit if its leading bytes are zero. */ |
Janos Follath | cc93908 | 2022-08-15 12:08:49 +0100 | [diff] [blame] | 226 | for( size_t i = bytes_to_copy; i < stored_bytes; i++ ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 227 | { |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 228 | if( GET_BYTE( A, i ) != 0 ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 229 | return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL ); |
| 230 | } |
| 231 | } |
| 232 | |
Janos Follath | cc93908 | 2022-08-15 12:08:49 +0100 | [diff] [blame] | 233 | for( size_t i = 0; i < bytes_to_copy; i++ ) |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 234 | output[i] = GET_BYTE( A, i ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 235 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 236 | if( stored_bytes < output_length ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 237 | { |
| 238 | /* Write trailing 0 bytes */ |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 239 | memset( output + stored_bytes, 0, output_length - stored_bytes ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | return( 0 ); |
| 243 | } |
| 244 | |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 245 | int mbedtls_mpi_core_write_be( const mbedtls_mpi_uint *X, |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 246 | size_t X_limbs, |
| 247 | unsigned char *output, |
| 248 | size_t output_length ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 249 | { |
| 250 | size_t stored_bytes; |
| 251 | size_t bytes_to_copy; |
| 252 | unsigned char *p; |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 253 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 254 | stored_bytes = X_limbs * ciL; |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 255 | |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 256 | if( stored_bytes < output_length ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 257 | { |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 258 | /* There is enough space in the output buffer. Write initial |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 259 | * null bytes and record the position at which to start |
| 260 | * writing the significant bytes. In this case, the execution |
| 261 | * trace of this function does not depend on the value of the |
| 262 | * number. */ |
| 263 | bytes_to_copy = stored_bytes; |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 264 | p = output + output_length - stored_bytes; |
| 265 | memset( output, 0, output_length - stored_bytes ); |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 266 | } |
| 267 | else |
| 268 | { |
Janos Follath | af3f39c | 2022-08-22 09:06:32 +0100 | [diff] [blame] | 269 | /* The output buffer is smaller than the allocated size of X. |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 270 | * However X may fit if its leading bytes are zero. */ |
Janos Follath | b7a88ec | 2022-08-19 12:24:40 +0100 | [diff] [blame] | 271 | bytes_to_copy = output_length; |
| 272 | p = output; |
Janos Follath | cc93908 | 2022-08-15 12:08:49 +0100 | [diff] [blame] | 273 | for( size_t i = bytes_to_copy; i < stored_bytes; i++ ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 274 | { |
| 275 | if( GET_BYTE( X, i ) != 0 ) |
| 276 | return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL ); |
| 277 | } |
| 278 | } |
| 279 | |
Janos Follath | cc93908 | 2022-08-15 12:08:49 +0100 | [diff] [blame] | 280 | for( size_t i = 0; i < bytes_to_copy; i++ ) |
Janos Follath | 3ca0775 | 2022-08-09 11:45:47 +0100 | [diff] [blame] | 281 | p[bytes_to_copy - i - 1] = GET_BYTE( X, i ); |
| 282 | |
| 283 | return( 0 ); |
| 284 | } |
| 285 | |
| 286 | #endif /* MBEDTLS_BIGNUM_C */ |