changeset 17281:f8955f187094

8178135: Additional elliptic curve support Reviewed-by: mullan
author vinnie
date Tue, 23 May 2017 16:59:50 +0100
parents f09a6beb1e23
children 763a4750255b a22f016c6555
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	Fri May 12 17:30:47 2017 +0100
+++ 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	Fri May 12 17:30:47 2017 +0100
+++ 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));