changeset 12700:c3ba55613abe

8178135: Additional elliptic curve support Reviewed-by: mullan
author igerasim
date Tue, 23 May 2017 11:30:25 -0700
parents 6c88634aa73a
children aa5c0133e5ad
files src/share/native/sun/security/ec/impl/ecp_jac.c src/share/native/sun/security/ec/impl/ecp_jm.c
diffstat 2 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/sun/security/ec/impl/ecp_jac.c	Thu May 18 22:52:38 2017 +0100
+++ b/src/share/native/sun/security/ec/impl/ecp_jac.c	Tue May 23 11:30:25 2017 -0700
@@ -180,6 +180,15 @@
         MP_CHECKOK(group->meth->field_mul(&A, qx, &A, group->meth));
         MP_CHECKOK(group->meth->field_mul(&B, qy, &B, group->meth));
 
+        /*
+         * Additional checks for point equality and point at infinity
+         */
+        if (mp_cmp(px, &A) == 0 && mp_cmp(py, &B) == 0) {
+            /* POINT_DOUBLE(P) */
+            MP_CHECKOK(ec_GFp_pt_dbl_jac(px, py, pz, rx, ry, rz, group));
+            goto CLEANUP;
+        }
+
         /* C = A - px, D = B - py */
         MP_CHECKOK(group->meth->field_sub(&A, px, &C, group->meth));
         MP_CHECKOK(group->meth->field_sub(&B, py, &D, group->meth));
--- a/src/share/native/sun/security/ec/impl/ecp_jm.c	Thu May 18 22:52:38 2017 +0100
+++ b/src/share/native/sun/security/ec/impl/ecp_jm.c	Tue May 23 11:30:25 2017 -0700
@@ -165,6 +165,16 @@
         MP_CHECKOK(group->meth->field_mul(A, qx, A, group->meth));
         MP_CHECKOK(group->meth->field_mul(B, qy, B, group->meth));
 
+        /*
+         * Additional checks for point equality and point at infinity
+         */
+        if (mp_cmp(px, A) == 0 && mp_cmp(py, B) == 0) {
+            /* POINT_DOUBLE(P) */
+            MP_CHECKOK(ec_GFp_pt_dbl_jm(px, py, pz, paz4, rx, ry, rz, raz4,
+                                        scratch, group));
+            goto CLEANUP;
+        }
+
         /* C = A - px, D = B - py */
         MP_CHECKOK(group->meth->field_sub(A, px, C, group->meth));
         MP_CHECKOK(group->meth->field_sub(B, py, D, group->meth));