| 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 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 #define BYTESWAP32(x) \ | 1257 #define BYTESWAP32(x) \ |
| 1258 ((x) >> 24 | (x) >> 8 & 0xff00 | ((x) & 0xff00) << 8 | (x) << 24) | 1258 ((x) >> 24 | (x) >> 8 & 0xff00 | ((x) & 0xff00) << 8 | (x) << 24) |
| 1259 #define BYTESWAP64(x) \ | 1259 #define BYTESWAP64(x) \ |
| 1260 ((x) >> 56 | (x) >> 40 & 0xff00 | \ | 1260 ((x) >> 56 | (x) >> 40 & 0xff00 | \ |
| 1261 (x) >> 24 & 0xff0000 | (x) >> 8 & 0xff000000 | \ | 1261 (x) >> 24 & 0xff0000 | (x) >> 8 & 0xff000000 | \ |
| 1262 ((x) & 0xff000000) << 8 | ((x) & 0xff0000) << 24 | \ | 1262 ((x) & 0xff000000) << 8 | ((x) & 0xff0000) << 24 | \ |
| 1263 ((x) & 0xff00) << 40 | (x) << 56) | 1263 ((x) & 0xff00) << 40 | (x) << 56) |
| 1264 #endif | 1264 #endif |
| 1265 | 1265 |
| 1266 #ifdef MP_USE_UINT_DIGIT | 1266 #ifdef MP_USE_UINT_DIGIT |
| 1267 #define BYTESWAP_MP_DIGIT_TO_LE(x) BYTESWAP32(BYTESWAP32(x)) | 1267 #define BYTESWAP_MP_DIGIT_TO_LE(x) BYTESWAP32(x) |
| 1268 #else | 1268 #else |
| 1269 #define BYTESWAP_MP_DIGIT_TO_LE(x) BYTESWAP64(BYTESWAP64(x)) | 1269 #define BYTESWAP_MP_DIGIT_TO_LE(x) BYTESWAP64(x) |
| 1270 #endif | 1270 #endif |
| 1271 #endif /* IS_BIG_ENDIAN */ | 1271 #endif /* IS_BIG_ENDIAN */ |
| 1272 | 1272 |
| 1273 #ifdef MP_USE_UINT_DIGIT | 1273 #ifdef MP_USE_UINT_DIGIT |
| 1274 static const mp_digit kRInvDigits[8] = { | 1274 static const mp_digit kRInvDigits[8] = { |
| 1275 0x80000000, 1, 0xffffffff, 0, | 1275 0x80000000, 1, 0xffffffff, 0, |
| 1276 0x80000001, 0xfffffffe, 1, 0x7fffffff | 1276 0x80000001, 0xfffffffe, 1, 0x7fffffff |
| 1277 }; | 1277 }; |
| 1278 #else | 1278 #else |
| 1279 static const mp_digit kRInvDigits[4] = { | 1279 static const mp_digit kRInvDigits[4] = { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 /* Wire in fast point multiplication for named curves. */ | 1497 /* Wire in fast point multiplication for named curves. */ |
| 1498 mp_err ec_group_set_gfp256_32(ECGroup *group, ECCurveName name) | 1498 mp_err ec_group_set_gfp256_32(ECGroup *group, ECCurveName name) |
| 1499 { | 1499 { |
| 1500 if (name == ECCurve_NIST_P256) { | 1500 if (name == ECCurve_NIST_P256) { |
| 1501 group->base_point_mul = &ec_GFp_nistp256_base_point_mul; | 1501 group->base_point_mul = &ec_GFp_nistp256_base_point_mul; |
| 1502 group->point_mul = &ec_GFp_nistp256_point_mul; | 1502 group->point_mul = &ec_GFp_nistp256_point_mul; |
| 1503 group->points_mul = &ec_GFp_nistp256_points_mul_vartime; | 1503 group->points_mul = &ec_GFp_nistp256_points_mul_vartime; |
| 1504 } | 1504 } |
| 1505 return MP_OKAY; | 1505 return MP_OKAY; |
| 1506 } | 1506 } |
| OLD | NEW |