aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/sun/security/ec/point/AffinePoint.java
diff options
context:
space:
mode:
authorandrew <unknown>2019-06-28 22:57:58 +0100
committerbell-sw <liberica@bell-sw.com>2019-07-22 19:22:40 +0300
commit0fa1fcb23e545dca39ed0cc32bafaa1666ed45ca (patch)
treeccc4beb7eaae7858dd2f74d6017887534f3c3e17 /src/share/classes/sun/security/ec/point/AffinePoint.java
parentbfd8e31d12e4048ac60f5bb6b9bc8c4f81b80e41 (diff)
downloadjdk8u_jdk-0fa1fcb23e545dca39ed0cc32bafaa1666ed45ca.tar.gz
8208698: Improved ECC Implementation
Summary: New implementation of ECDH and ECDSA forsome prime-order curves Reviewed-by: ascarpino, andrew Contributed-by: David Alvarez <alvdavi@amazon.com>
Diffstat (limited to 'src/share/classes/sun/security/ec/point/AffinePoint.java')
-rw-r--r--src/share/classes/sun/security/ec/point/AffinePoint.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/share/classes/sun/security/ec/point/AffinePoint.java b/src/share/classes/sun/security/ec/point/AffinePoint.java
new file mode 100644
index 0000000000..a8b74bdd4c
--- /dev/null
+++ b/src/share/classes/sun/security/ec/point/AffinePoint.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.security.ec.point;
+
+import sun.security.util.math.ImmutableIntegerModuloP;
+
+import java.util.Objects;
+
+/**
+ * Elliptic curve point represented using affine coordinates (x, y). This class
+ * is not part of the sun.security.ec.point.Point hierarchy because it is not
+ * used to hold intermediate values during point arithmetic, and so it does not
+ * have a mutable form.
+ */
+public class AffinePoint {
+
+ private final ImmutableIntegerModuloP x;
+ private final ImmutableIntegerModuloP y;
+
+ public AffinePoint(ImmutableIntegerModuloP x, ImmutableIntegerModuloP y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public ImmutableIntegerModuloP getX() {
+ return x;
+ }
+
+ public ImmutableIntegerModuloP getY() {
+ return y;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof AffinePoint)) {
+ return false;
+ }
+ AffinePoint p = (AffinePoint) obj;
+ boolean xEquals = x.asBigInteger().equals(p.x.asBigInteger());
+ boolean yEquals = y.asBigInteger().equals(p.y.asBigInteger());
+ return xEquals && yEquals;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(x, y);
+ }
+
+ @Override
+ public String toString() {
+ return "(" + x.asBigInteger().toString() + "," +
+ y.asBigInteger().toString() + ")";
+ }
+}