| 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 #include "ecp.h" | 5 #include "ecp.h" |
| 6 #include "ecl-priv.h" | 6 #include "ecl-priv.h" |
| 7 #include "mplogic.h" | 7 #include "mplogic.h" |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #define MAX_SCRATCH 6 | 10 #define MAX_SCRATCH 6 |
| 11 | 11 |
| 12 /* Computes R = 2P. Elliptic curve points P and R can be identical. Uses | 12 /* Computes R = 2P. Elliptic curve points P and R can be identical. Uses |
| 13 * Modified Jacobian coordinates. | 13 * Modified Jacobian coordinates. |
| 14 * | 14 * |
| 15 * Assumes input is already field-encoded using field_enc, and returns | 15 * Assumes input is already field-encoded using field_enc, and returns |
| 16 * output that is still field-encoded. | 16 * output that is still field-encoded. |
| 17 * | 17 * |
| 18 */ | 18 */ |
| 19 mp_err | 19 static mp_err |
| 20 ec_GFp_pt_dbl_jm(const mp_int *px, const mp_int *py, const mp_int *pz, | 20 ec_GFp_pt_dbl_jm(const mp_int *px, const mp_int *py, const mp_int *pz, |
| 21 const mp_int *paz4, mp_int *rx, mp_int *ry, mp_
int *rz, | 21 const mp_int *paz4, mp_int *rx, mp_int *ry, mp_
int *rz, |
| 22 mp_int *raz4, mp_int scratch[], const ECGroup *
group) | 22 mp_int *raz4, mp_int scratch[], const ECGroup *
group) |
| 23 { | 23 { |
| 24 mp_err res = MP_OKAY; | 24 mp_err res = MP_OKAY; |
| 25 mp_int *t0, *t1, *M, *S; | 25 mp_int *t0, *t1, *M, *S; |
| 26 | 26 |
| 27 t0 = &scratch[0]; | 27 t0 = &scratch[0]; |
| 28 t1 = &scratch[1]; | 28 t1 = &scratch[1]; |
| 29 M = &scratch[2]; | 29 M = &scratch[2]; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 CLEANUP: | 80 CLEANUP: |
| 81 return res; | 81 return res; |
| 82 } | 82 } |
| 83 | 83 |
| 84 /* Computes R = P + Q where R is (rx, ry, rz), P is (px, py, pz) and Q is | 84 /* Computes R = P + Q where R is (rx, ry, rz), P is (px, py, pz) and Q is |
| 85 * (qx, qy, 1). Elliptic curve points P, Q, and R can all be identical. | 85 * (qx, qy, 1). Elliptic curve points P, Q, and R can all be identical. |
| 86 * Uses mixed Modified_Jacobian-affine coordinates. Assumes input is | 86 * Uses mixed Modified_Jacobian-affine coordinates. Assumes input is |
| 87 * already field-encoded using field_enc, and returns output that is still | 87 * already field-encoded using field_enc, and returns output that is still |
| 88 * field-encoded. */ | 88 * field-encoded. */ |
| 89 mp_err | 89 static mp_err |
| 90 ec_GFp_pt_add_jm_aff(const mp_int *px, const mp_int *py, const mp_int *pz, | 90 ec_GFp_pt_add_jm_aff(const mp_int *px, const mp_int *py, const mp_int *pz, |
| 91 const mp_int *paz4, const mp_int *qx, | 91 const mp_int *paz4, const mp_int *qx, |
| 92 const mp_int *qy, mp_int *rx, mp_int *r
y, mp_int *rz, | 92 const mp_int *qy, mp_int *rx, mp_int *r
y, mp_int *rz, |
| 93 mp_int *raz4, mp_int scratch[], const E
CGroup *group) | 93 mp_int *raz4, mp_int scratch[], const E
CGroup *group) |
| 94 { | 94 { |
| 95 mp_err res = MP_OKAY; | 95 mp_err res = MP_OKAY; |
| 96 mp_int *A, *B, *C, *D, *C2, *C3; | 96 mp_int *A, *B, *C, *D, *C2, *C3; |
| 97 | 97 |
| 98 A = &scratch[0]; | 98 A = &scratch[0]; |
| 99 B = &scratch[1]; | 99 B = &scratch[1]; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 mp_clear(&precomp[i][0]); | 280 mp_clear(&precomp[i][0]); |
| 281 mp_clear(&precomp[i][1]); | 281 mp_clear(&precomp[i][1]); |
| 282 } | 282 } |
| 283 mp_clear(&tpx); | 283 mp_clear(&tpx); |
| 284 mp_clear(&tpy); | 284 mp_clear(&tpy); |
| 285 mp_clear(&rz); | 285 mp_clear(&rz); |
| 286 mp_clear(&raz4); | 286 mp_clear(&raz4); |
| 287 free(naf); | 287 free(naf); |
| 288 return res; | 288 return res; |
| 289 } | 289 } |
| OLD | NEW |