OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* A 32-bit implementation of the NIST P-256 elliptic curve. */ | 5 /* A 32-bit implementation of the NIST P-256 elliptic curve. */ |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "prtypes.h" | 9 #include "prtypes.h" |
10 #include "mpi.h" | 10 #include "mpi.h" |
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 /* BYTESWAP_MP_DIGIT_TO_LE swaps the bytes of a mp_digit to | 1247 /* BYTESWAP_MP_DIGIT_TO_LE swaps the bytes of a mp_digit to |
1248 * little-endian order. | 1248 * little-endian order. |
1249 */ | 1249 */ |
1250 #ifdef IS_BIG_ENDIAN | 1250 #ifdef IS_BIG_ENDIAN |
1251 #ifdef __APPLE__ | 1251 #ifdef __APPLE__ |
1252 #include <libkern/OSByteOrder.h> | 1252 #include <libkern/OSByteOrder.h> |
1253 #define BYTESWAP32(x) OSSwapInt32(x) | 1253 #define BYTESWAP32(x) OSSwapInt32(x) |
1254 #define BYTESWAP64(x) OSSwapInt64(x) | 1254 #define BYTESWAP64(x) OSSwapInt64(x) |
1255 #else | 1255 #else |
1256 #define BYTESWAP32(x) \ | 1256 #define BYTESWAP32(x) \ |
1257 ((x) >> 24 | (x) >> 8 & 0xff00 | ((x) & 0xff00) << 8 | (x) << 24) | 1257 (((x) >> 24) | (((x) >> 8) & 0xff00) | (((x) & 0xff00) << 8) | ((x) << 24)) |
1258 #define BYTESWAP64(x) \ | 1258 #define BYTESWAP64(x) \ |
1259 ((x) >> 56 | (x) >> 40 & 0xff00 | \ | 1259 (((x) >> 56) | (((x) >> 40) & 0xff00) | \ |
1260 (x) >> 24 & 0xff0000 | (x) >> 8 & 0xff000000 | \ | 1260 (((x) >> 24) & 0xff0000) | (((x) >> 8) & 0xff000000) | \ |
1261 ((x) & 0xff000000) << 8 | ((x) & 0xff0000) << 24 | \ | 1261 (((x) & 0xff000000) << 8) | (((x) & 0xff0000) << 24) | \ |
1262 ((x) & 0xff00) << 40 | (x) << 56) | 1262 (((x) & 0xff00) << 40) | ((x) << 56)) |
1263 #endif | 1263 #endif |
1264 | 1264 |
1265 #ifdef MP_USE_UINT_DIGIT | 1265 #ifdef MP_USE_UINT_DIGIT |
1266 #define BYTESWAP_MP_DIGIT_TO_LE(x) BYTESWAP32(x) | 1266 #define BYTESWAP_MP_DIGIT_TO_LE(x) BYTESWAP32(x) |
1267 #else | 1267 #else |
1268 #define BYTESWAP_MP_DIGIT_TO_LE(x) BYTESWAP64(x) | 1268 #define BYTESWAP_MP_DIGIT_TO_LE(x) BYTESWAP64(x) |
1269 #endif | 1269 #endif |
1270 #endif /* IS_BIG_ENDIAN */ | 1270 #endif /* IS_BIG_ENDIAN */ |
1271 | 1271 |
1272 #ifdef MP_USE_UINT_DIGIT | 1272 #ifdef MP_USE_UINT_DIGIT |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 /* Wire in fast point multiplication for named curves. */ | 1495 /* Wire in fast point multiplication for named curves. */ |
1496 mp_err ec_group_set_gfp256_32(ECGroup *group, ECCurveName name) | 1496 mp_err ec_group_set_gfp256_32(ECGroup *group, ECCurveName name) |
1497 { | 1497 { |
1498 if (name == ECCurve_NIST_P256) { | 1498 if (name == ECCurve_NIST_P256) { |
1499 group->base_point_mul = &ec_GFp_nistp256_base_point_mul; | 1499 group->base_point_mul = &ec_GFp_nistp256_base_point_mul; |
1500 group->point_mul = &ec_GFp_nistp256_point_mul; | 1500 group->point_mul = &ec_GFp_nistp256_point_mul; |
1501 group->points_mul = &ec_GFp_nistp256_points_mul_vartime; | 1501 group->points_mul = &ec_GFp_nistp256_points_mul_vartime; |
1502 } | 1502 } |
1503 return MP_OKAY; | 1503 return MP_OKAY; |
1504 } | 1504 } |
OLD | NEW |