1 /* 2 * Copyright (c) 2018, 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 * This class is used to specify any algorithm parameters that are determined 31 * by a standard name. This class also holds constants for standard parameter 32 * set names. The names of these constants exactly match the corresponding 33 * parameter set name. For example, NamedParameterSpec.X25519 represents the 34 * parameter set identified by the string "X25519". These strings are defined 35 * in the <a href= 36 * "{@docRoot}/../specs/security/standard-names.html#parameterspec-names"> 37 * Java Security Standard Algorithm Names Specification</a>. 38 * 39 * @since 11 40 * 41 */ 42 public class NamedParameterSpec implements AlgorithmParameterSpec { 43 44 /** 45 * The X25519 parameters 46 */ 47 public static final NamedParameterSpec X25519 48 = new NamedParameterSpec("X25519"); 49 /** 50 * The X448 parameters 51 */ 52 public static final NamedParameterSpec X448 53 = new NamedParameterSpec("X448"); 54 55 /** 56 * The Ed25519 parameters 57 * 58 * @since 15 59 */ 60 public static final NamedParameterSpec ED25519 61 = new NamedParameterSpec("Ed25519"); 62 63 /** 64 * The Ed448 parameters 65 * 66 * @since 15 67 */ 68 public static final NamedParameterSpec ED448 69 = new NamedParameterSpec("Ed448"); 70 71 private String name; 72 73 /** 74 * Creates a parameter specification using a standard (or predefined) 75 * name {@code stdName}. For the 76 * list of supported names, please consult the documentation 77 * of the provider whose implementation will be used. 78 * 79 * @param stdName the standard name of the algorithm parameters. See the 80 * ParameterSpec Names section in the 81 * <a href= 82 * "{@docRoot}/../specs/security/standard-names.html#parameterspec-names"> 83 * Java Security Standard Algorithm Names Specification</a> for 84 * information about standard names. 85 * 86 * @throws NullPointerException if {@code stdName} is null. 87 */ NamedParameterSpec(String stdName)88 public NamedParameterSpec(String stdName) { 89 Objects.requireNonNull(stdName, "stdName must not be null"); 90 91 this.name = stdName; 92 } 93 94 /** 95 * Returns the standard name that determines the algorithm parameters. 96 * @return the standard name. 97 */ getName()98 public String getName() { 99 return name; 100 } 101 } 102