1 /* 2 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package java.security.spec; 26 27 import java.util.Objects; 28 29 /** 30 * A class representing elliptic curve public keys as defined in 31 * <a href="https://tools.ietf.org/html/rfc8032">RFC 8032: Edwards-Curve 32 * Digital Signature Algorithm (EdDSA)</a>, including the curve and other 33 * algorithm parameters. The public key is a point on the curve, which is 34 * represented using an {@code EdECPoint}. 35 * 36 * @since 15 37 */ 38 public final class EdECPublicKeySpec implements KeySpec { 39 40 private final NamedParameterSpec params; 41 private final EdECPoint point; 42 43 /** 44 * Construct a public key spec using the supplied parameters and 45 * point. 46 * 47 * @param params the algorithm parameters. 48 * @param point the point representing the public key. 49 * 50 * @throws NullPointerException if {@code params} or {@code point} 51 * is null. 52 */ EdECPublicKeySpec(NamedParameterSpec params, EdECPoint point)53 public EdECPublicKeySpec(NamedParameterSpec params, EdECPoint point) { 54 Objects.requireNonNull(params, "params must not be null"); 55 Objects.requireNonNull(point, "point must not be null"); 56 57 this.params = params; 58 this.point = point; 59 } 60 61 /** 62 * Get the algorithm parameters that define the curve and other settings. 63 * 64 * @return the parameters. 65 */ getParams()66 public NamedParameterSpec getParams() { 67 return params; 68 } 69 70 /** 71 * Get the point representing the public key. 72 * 73 * @return the {@code EdECPoint} representing the public key. 74 */ getPoint()75 public EdECPoint getPoint() { 76 return point; 77 } 78 } 79