KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > spec > ECParameterSpec


1 /*
2  * @(#)ECParameterSpec.java 1.3 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package java.security.spec;
8
9 import java.math.BigInteger JavaDoc;
10
11 /**
12  * This immutable class specifies the set of domain parameters
13  * used with elliptic curve cryptography (ECC).
14  *
15  * @see AlgorithmParameterSpec
16  *
17  * @author Valerie Peng
18  * @version 1.3, 12/19/03
19  *
20  * @since 1.5
21  */

22 public class ECParameterSpec implements AlgorithmParameterSpec JavaDoc {
23
24     private final EllipticCurve JavaDoc curve;
25     private final ECPoint JavaDoc g;
26     private final BigInteger JavaDoc n;
27     private final int h;
28
29     /**
30      * Creates elliptic curve domain parameters based on the
31      * specified values.
32      * @param curve the elliptic curve which this parameter
33      * defines.
34      * @param g the generator which is also known as the base point.
35      * @param n the order of the generator <code>g</code>.
36      * @param h the cofactor.
37      * @exception NullPointerException if <code>curve</code>,
38      * <code>g</code>, or <code>n</code> is null.
39      * @exception IllegalArgumentException if <code>n</code>
40      * or <code>h</code> is not positive.
41      */

42     public ECParameterSpec(EllipticCurve JavaDoc curve, ECPoint JavaDoc g,
43                BigInteger JavaDoc n, int h) {
44     if (curve == null) {
45         throw new NullPointerException JavaDoc("curve is null");
46     }
47         if (g == null) {
48             throw new NullPointerException JavaDoc("g is null");
49         }
50         if (n == null) {
51             throw new NullPointerException JavaDoc("n is null");
52         }
53     if (n.signum() != 1) {
54         throw new IllegalArgumentException JavaDoc("n is not positive");
55     }
56     if (h <= 0) {
57         throw new IllegalArgumentException JavaDoc("h is not positive");
58     }
59     this.curve = curve;
60     this.g = g;
61     this.n = n;
62     this.h = h;
63     }
64
65     /**
66      * Returns the elliptic curve that this parameter defines.
67      * @return the elliptic curve that this parameter defines.
68      */

69     public EllipticCurve JavaDoc getCurve() {
70     return curve;
71     }
72     
73     /**
74      * Returns the generator which is also known as the base point.
75      * @return the generator which is also known as the base point.
76      */

77     public ECPoint JavaDoc getGenerator() {
78     return g;
79     }
80
81     /**
82      * Returns the order of the generator.
83      * @return the order of the generator.
84      */

85     public BigInteger JavaDoc getOrder() {
86     return n;
87     }
88
89     /**
90      * Returns the cofactor.
91      * @return the cofactor.
92      */

93     public int getCofactor() {
94     return h;
95     }
96 }
97
Popular Tags