changeset 17376:6c683034d1b5

8178135: Additional elliptic curve support Reviewed-by: mullan
author vinnie
date Tue, 23 May 2017 16:59:50 +0100
parents 65cce978b3b5
children 3abd28d7136d
files src/jdk.crypto.ec/share/native/libsunec/impl/ecp_jac.c src/jdk.crypto.ec/share/native/libsunec/impl/ecp_jm.c
diffstat 2 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.crypto.ec/share/native/libsunec/impl/ecp_jac.c	Mon May 22 09:32:30 2017 -0700
+++ b/src/jdk.crypto.ec/share/native/libsunec/impl/ecp_jac.c	Tue May 23 16:59:50 2017 +0100
@@ -181,6 +181,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/jdk.crypto.ec/share/native/libsunec/impl/ecp_jm.c	Mon May 22 09:32:30 2017 -0700
+++ b/src/jdk.crypto.ec/share/native/libsunec/impl/ecp_jm.c	Tue May 23 16:59:50 2017 +0100
@@ -166,6 +166,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));