01 /*
02 * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
03 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04 *
05 * This code is free software; you can redistribute it and/or modify it
06 * under the terms of the GNU General Public License version 2 only, as
07 * published by the Free Software Foundation. Sun designates this
08 * particular file as subject to the "Classpath" exception as provided
09 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25 package java.security.spec;
26
27 /**
28 * This immutable class specifies an elliptic curve public key with
29 * its associated parameters.
30 *
31 * @see KeySpec
32 * @see ECPoint
33 * @see ECParameterSpec
34 *
35 * @author Valerie Peng
36 * @version 1.10, 05/05/07
37 *
38 * @since 1.5
39 */
40 public class ECPublicKeySpec implements KeySpec {
41
42 private ECPoint w;
43 private ECParameterSpec params;
44
45 /**
46 * Creates a new ECPublicKeySpec with the specified
47 * parameter values.
48 * @param w the public point.
49 * @param params the associated elliptic curve domain
50 * parameters.
51 * @exception NullPointerException if <code>w</code>
52 * or <code>params</code> is null.
53 * @exception IllegalArgumentException if <code>w</code>
54 * is point at infinity, i.e. ECPoint.POINT_INFINITY
55 */
56 public ECPublicKeySpec(ECPoint w, ECParameterSpec params) {
57 if (w == null) {
58 throw new NullPointerException("w is null");
59 }
60 if (params == null) {
61 throw new NullPointerException("params is null");
62 }
63 if (w == ECPoint.POINT_INFINITY) {
64 throw new IllegalArgumentException(
65 "w is ECPoint.POINT_INFINITY");
66 }
67 this .w = w;
68 this .params = params;
69 }
70
71 /**
72 * Returns the public point W.
73 * @return the public point W.
74 */
75 public ECPoint getW() {
76 return w;
77 }
78
79 /**
80 * Returns the associated elliptic curve domain
81 * parameters.
82 * @return the EC domain parameters.
83 */
84 public ECParameterSpec getParams() {
85 return params;
86 }
87 }
|