Showing the changes to java/pkg/java/security/spec (56 of 18352 files). Show all
Unified · Split
Binary file not shown.
| @@ -0,0 +1,44 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1999, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * A (transparent) specification of cryptographic parameters. | |
| 30 | + * | |
| 31 | + * <P> This interface contains no methods or constants. Its only purpose | |
| 32 | + * is to group (and provide type safety for) all parameter specifications. | |
| 33 | + * All parameter specifications must implement this interface. | |
| 34 | + * | |
| 35 | + * @author Jan Luehe | |
| 36 | + * | |
| 37 | + * | |
| 38 | + * @see java.security.AlgorithmParameters | |
| 39 | + * @see DSAParameterSpec | |
| 40 | + * | |
| 41 | + * @since 1.2 | |
| 42 | + */ | |
| 43 | + | |
| 44 | +public interface AlgorithmParameterSpec { } | |
Binary file not shown.
| @@ -0,0 +1,89 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1999, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This class specifies the set of parameters used with the DSA algorithm. | |
| 32 | + * | |
| 33 | + * @author Jan Luehe | |
| 34 | + * | |
| 35 | + * | |
| 36 | + * @see AlgorithmParameterSpec | |
| 37 | + * | |
| 38 | + * @since 1.2 | |
| 39 | + */ | |
| 40 | + | |
| 41 | +public class DSAParameterSpec implements AlgorithmParameterSpec, | |
| 42 | +java.security.interfaces.DSAParams { | |
| 43 | + | |
| 44 | + BigInteger p; | |
| 45 | + BigInteger q; | |
| 46 | + BigInteger g; | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * Creates a new DSAParameterSpec with the specified parameter values. | |
| 50 | + * | |
| 51 | + * @param p the prime. | |
| 52 | + * | |
| 53 | + * @param q the sub-prime. | |
| 54 | + * | |
| 55 | + * @param g the base. | |
| 56 | + */ | |
| 57 | + public DSAParameterSpec(BigInteger p, BigInteger q, BigInteger g) { | |
| 58 | + this.p = p; | |
| 59 | + this.q = q; | |
| 60 | + this.g = g; | |
| 61 | + } | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * Returns the prime <code>p</code>. | |
| 65 | + * | |
| 66 | + * @return the prime <code>p</code>. | |
| 67 | + */ | |
| 68 | + public BigInteger getP() { | |
| 69 | + return this.p; | |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Returns the sub-prime <code>q</code>. | |
| 74 | + * | |
| 75 | + * @return the sub-prime <code>q</code>. | |
| 76 | + */ | |
| 77 | + public BigInteger getQ() { | |
| 78 | + return this.q; | |
| 79 | + } | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * Returns the base <code>g</code>. | |
| 83 | + * | |
| 84 | + * @return the base <code>g</code>. | |
| 85 | + */ | |
| 86 | + public BigInteger getG() { | |
| 87 | + return this.g; | |
| 88 | + } | |
| 89 | +} | |
Binary file not shown.
| @@ -0,0 +1,106 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1999, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This class specifies a DSA private key with its associated parameters. | |
| 32 | + * | |
| 33 | + * @author Jan Luehe | |
| 34 | + * | |
| 35 | + * | |
| 36 | + * @see java.security.Key | |
| 37 | + * @see java.security.KeyFactory | |
| 38 | + * @see KeySpec | |
| 39 | + * @see DSAPublicKeySpec | |
| 40 | + * @see PKCS8EncodedKeySpec | |
| 41 | + * | |
| 42 | + * @since 1.2 | |
| 43 | + */ | |
| 44 | + | |
| 45 | +public class DSAPrivateKeySpec implements KeySpec { | |
| 46 | + | |
| 47 | + private BigInteger x; | |
| 48 | + private BigInteger p; | |
| 49 | + private BigInteger q; | |
| 50 | + private BigInteger g; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Creates a new DSAPrivateKeySpec with the specified parameter values. | |
| 54 | + * | |
| 55 | + * @param x the private key. | |
| 56 | + * | |
| 57 | + * @param p the prime. | |
| 58 | + * | |
| 59 | + * @param q the sub-prime. | |
| 60 | + * | |
| 61 | + * @param g the base. | |
| 62 | + */ | |
| 63 | + public DSAPrivateKeySpec(BigInteger x, BigInteger p, BigInteger q, | |
| 64 | + BigInteger g) { | |
| 65 | + this.x = x; | |
| 66 | + this.p = p; | |
| 67 | + this.q = q; | |
| 68 | + this.g = g; | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Returns the private key <code>x</code>. | |
| 73 | + * | |
| 74 | + * @return the private key <code>x</code>. | |
| 75 | + */ | |
| 76 | + public BigInteger getX() { | |
| 77 | + return this.x; | |
| 78 | + } | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Returns the prime <code>p</code>. | |
| 82 | + * | |
| 83 | + * @return the prime <code>p</code>. | |
| 84 | + */ | |
| 85 | + public BigInteger getP() { | |
| 86 | + return this.p; | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * Returns the sub-prime <code>q</code>. | |
| 91 | + * | |
| 92 | + * @return the sub-prime <code>q</code>. | |
| 93 | + */ | |
| 94 | + public BigInteger getQ() { | |
| 95 | + return this.q; | |
| 96 | + } | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * Returns the base <code>g</code>. | |
| 100 | + * | |
| 101 | + * @return the base <code>g</code>. | |
| 102 | + */ | |
| 103 | + public BigInteger getG() { | |
| 104 | + return this.g; | |
| 105 | + } | |
| 106 | +} | |
Binary file not shown.
| @@ -0,0 +1,106 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1999, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This class specifies a DSA public key with its associated parameters. | |
| 32 | + * | |
| 33 | + * @author Jan Luehe | |
| 34 | + * | |
| 35 | + * | |
| 36 | + * @see java.security.Key | |
| 37 | + * @see java.security.KeyFactory | |
| 38 | + * @see KeySpec | |
| 39 | + * @see DSAPrivateKeySpec | |
| 40 | + * @see X509EncodedKeySpec | |
| 41 | + * | |
| 42 | + * @since 1.2 | |
| 43 | + */ | |
| 44 | + | |
| 45 | +public class DSAPublicKeySpec implements KeySpec { | |
| 46 | + | |
| 47 | + private BigInteger y; | |
| 48 | + private BigInteger p; | |
| 49 | + private BigInteger q; | |
| 50 | + private BigInteger g; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Creates a new DSAPublicKeySpec with the specified parameter values. | |
| 54 | + * | |
| 55 | + * @param y the public key. | |
| 56 | + * | |
| 57 | + * @param p the prime. | |
| 58 | + * | |
| 59 | + * @param q the sub-prime. | |
| 60 | + * | |
| 61 | + * @param g the base. | |
| 62 | + */ | |
| 63 | + public DSAPublicKeySpec(BigInteger y, BigInteger p, BigInteger q, | |
| 64 | + BigInteger g) { | |
| 65 | + this.y = y; | |
| 66 | + this.p = p; | |
| 67 | + this.q = q; | |
| 68 | + this.g = g; | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Returns the public key <code>y</code>. | |
| 73 | + * | |
| 74 | + * @return the public key <code>y</code>. | |
| 75 | + */ | |
| 76 | + public BigInteger getY() { | |
| 77 | + return this.y; | |
| 78 | + } | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Returns the prime <code>p</code>. | |
| 82 | + * | |
| 83 | + * @return the prime <code>p</code>. | |
| 84 | + */ | |
| 85 | + public BigInteger getP() { | |
| 86 | + return this.p; | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * Returns the sub-prime <code>q</code>. | |
| 91 | + * | |
| 92 | + * @return the sub-prime <code>q</code>. | |
| 93 | + */ | |
| 94 | + public BigInteger getQ() { | |
| 95 | + return this.q; | |
| 96 | + } | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * Returns the base <code>g</code>. | |
| 100 | + * | |
| 101 | + * @return the base <code>g</code>. | |
| 102 | + */ | |
| 103 | + public BigInteger getG() { | |
| 104 | + return this.g; | |
| 105 | + } | |
| 106 | +} | |
Binary file not shown.
| @@ -0,0 +1,49 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 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.math.BigInteger; | |
| 28 | +import java.util.Arrays; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This interface represents an elliptic curve (EC) finite field. | |
| 32 | + * All specialized EC fields must implements this interface. | |
| 33 | + * | |
| 34 | + * @see ECFieldFp | |
| 35 | + * @see ECFieldF2m | |
| 36 | + * | |
| 37 | + * @author Valerie Peng | |
| 38 | + * | |
| 39 | + * @since 1.5 | |
| 40 | + */ | |
| 41 | +public interface ECField { | |
| 42 | + /** | |
| 43 | + * Returns the field size in bits. Note: For prime finite | |
| 44 | + * field ECFieldFp, size of prime p in bits is returned. | |
| 45 | + * For characteristic 2 finite field ECFieldF2m, m is returned. | |
| 46 | + * @return the field size in bits. | |
| 47 | + */ | |
| 48 | + int getFieldSize(); | |
| 49 | +} | |
Binary file not shown.
| @@ -0,0 +1,241 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 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.math.BigInteger; | |
| 28 | +import java.util.Arrays; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This immutable class defines an elliptic curve (EC) | |
| 32 | + * characteristic 2 finite field. | |
| 33 | + * | |
| 34 | + * @see ECField | |
| 35 | + * | |
| 36 | + * @author Valerie Peng | |
| 37 | + * | |
| 38 | + * @since 1.5 | |
| 39 | + */ | |
| 40 | +public class ECFieldF2m implements ECField { | |
| 41 | + | |
| 42 | + private int m; | |
| 43 | + private int[] ks; | |
| 44 | + private BigInteger rp; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Creates an elliptic curve characteristic 2 finite | |
| 48 | + * field which has 2^<code>m</code> elements with normal basis. | |
| 49 | + * @param m with 2^<code>m</code> being the number of elements. | |
| 50 | + * @exception IllegalArgumentException if <code>m</code> | |
| 51 | + * is not positive. | |
| 52 | + */ | |
| 53 | + public ECFieldF2m(int m) { | |
| 54 | + if (m <= 0) { | |
| 55 | + throw new IllegalArgumentException("m is not positive"); | |
| 56 | + } | |
| 57 | + this.m = m; | |
| 58 | + this.ks = null; | |
| 59 | + this.rp = null; | |
| 60 | + } | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * Creates an elliptic curve characteristic 2 finite | |
| 64 | + * field which has 2^<code>m</code> elements with | |
| 65 | + * polynomial basis. | |
| 66 | + * The reduction polynomial for this field is based | |
| 67 | + * on <code>rp</code> whose i-th bit correspondes to | |
| 68 | + * the i-th coefficient of the reduction polynomial.<p> | |
| 69 | + * Note: A valid reduction polynomial is either a | |
| 70 | + * trinomial (X^<code>m</code> + X^<code>k</code> + 1 | |
| 71 | + * with <code>m</code> > <code>k</code> >= 1) or a | |
| 72 | + * pentanomial (X^<code>m</code> + X^<code>k3</code> | |
| 73 | + * + X^<code>k2</code> + X^<code>k1</code> + 1 with | |
| 74 | + * <code>m</code> > <code>k3</code> > <code>k2</code> | |
| 75 | + * > <code>k1</code> >= 1). | |
| 76 | + * @param m with 2^<code>m</code> being the number of elements. | |
| 77 | + * @param rp the BigInteger whose i-th bit corresponds to | |
| 78 | + * the i-th coefficient of the reduction polynomial. | |
| 79 | + * @exception NullPointerException if <code>rp</code> is null. | |
| 80 | + * @exception IllegalArgumentException if <code>m</code> | |
| 81 | + * is not positive, or <code>rp</code> does not represent | |
| 82 | + * a valid reduction polynomial. | |
| 83 | + */ | |
| 84 | + public ECFieldF2m(int m, BigInteger rp) { | |
| 85 | + // check m and rp | |
| 86 | + this.m = m; | |
| 87 | + this.rp = rp; | |
| 88 | + if (m <= 0) { | |
| 89 | + throw new IllegalArgumentException("m is not positive"); | |
| 90 | + } | |
| 91 | + int bitCount = this.rp.bitCount(); | |
| 92 | + if (!this.rp.testBit(0) || !this.rp.testBit(m) || | |
| 93 | + ((bitCount != 3) && (bitCount != 5))) { | |
| 94 | + throw new IllegalArgumentException | |
| 95 | + ("rp does not represent a valid reduction polynomial"); | |
| 96 | + } | |
| 97 | + // convert rp into ks | |
| 98 | + BigInteger temp = this.rp.clearBit(0).clearBit(m); | |
| 99 | + this.ks = new int[bitCount-2]; | |
| 100 | + for (int i = this.ks.length-1; i >= 0; i--) { | |
| 101 | + int index = temp.getLowestSetBit(); | |
| 102 | + this.ks[i] = index; | |
| 103 | + temp = temp.clearBit(index); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + | |
| 107 | + /** | |
| 108 | + * Creates an elliptic curve characteristic 2 finite | |
| 109 | + * field which has 2^<code>m</code> elements with | |
| 110 | + * polynomial basis. The reduction polynomial for this | |
| 111 | + * field is based on <code>ks</code> whose content | |
| 112 | + * contains the order of the middle term(s) of the | |
| 113 | + * reduction polynomial. | |
| 114 | + * Note: A valid reduction polynomial is either a | |
| 115 | + * trinomial (X^<code>m</code> + X^<code>k</code> + 1 | |
| 116 | + * with <code>m</code> > <code>k</code> >= 1) or a | |
| 117 | + * pentanomial (X^<code>m</code> + X^<code>k3</code> | |
| 118 | + * + X^<code>k2</code> + X^<code>k1</code> + 1 with | |
| 119 | + * <code>m</code> > <code>k3</code> > <code>k2</code> | |
| 120 | + * > <code>k1</code> >= 1), so <code>ks</code> should | |
| 121 | + * have length 1 or 3. | |
| 122 | + * @param m with 2^<code>m</code> being the number of elements. | |
| 123 | + * @param ks the order of the middle term(s) of the | |
| 124 | + * reduction polynomial. Contents of this array are copied | |
| 125 | + * to protect against subsequent modification. | |
| 126 | + * @exception NullPointerException if <code>ks</code> is null. | |
| 127 | + * @exception IllegalArgumentException if<code>m</code> | |
| 128 | + * is not positive, or the length of <code>ks</code> | |
| 129 | + * is neither 1 nor 3, or values in <code>ks</code> | |
| 130 | + * are not between <code>m</code>-1 and 1 (inclusive) | |
| 131 | + * and in descending order. | |
| 132 | + */ | |
| 133 | + public ECFieldF2m(int m, int[] ks) { | |
| 134 | + // check m and ks | |
| 135 | + this.m = m; | |
| 136 | + this.ks = ks.clone(); | |
| 137 | + if (m <= 0) { | |
| 138 | + throw new IllegalArgumentException("m is not positive"); | |
| 139 | + } | |
| 140 | + if ((this.ks.length != 1) && (this.ks.length != 3)) { | |
| 141 | + throw new IllegalArgumentException | |
| 142 | + ("length of ks is neither 1 nor 3"); | |
| 143 | + } | |
| 144 | + for (int i = 0; i < this.ks.length; i++) { | |
| 145 | + if ((this.ks[i] < 1) || (this.ks[i] > m-1)) { | |
| 146 | + throw new IllegalArgumentException | |
| 147 | + ("ks["+ i + "] is out of range"); | |
| 148 | + } | |
| 149 | + if ((i != 0) && (this.ks[i] >= this.ks[i-1])) { | |
| 150 | + throw new IllegalArgumentException | |
| 151 | + ("values in ks are not in descending order"); | |
| 152 | + } | |
| 153 | + } | |
| 154 | + // convert ks into rp | |
| 155 | + this.rp = BigInteger.ONE; | |
| 156 | + this.rp = rp.setBit(m); | |
| 157 | + for (int j = 0; j < this.ks.length; j++) { | |
| 158 | + rp = rp.setBit(this.ks[j]); | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 162 | + /** | |
| 163 | + * Returns the field size in bits which is <code>m</code> | |
| 164 | + * for this characteristic 2 finite field. | |
| 165 | + * @return the field size in bits. | |
| 166 | + */ | |
| 167 | + public int getFieldSize() { | |
| 168 | + return m; | |
| 169 | + } | |
| 170 | + | |
| 171 | + /** | |
| 172 | + * Returns the value <code>m</code> of this characteristic | |
| 173 | + * 2 finite field. | |
| 174 | + * @return <code>m</code> with 2^<code>m</code> being the | |
| 175 | + * number of elements. | |
| 176 | + */ | |
| 177 | + public int getM() { | |
| 178 | + return m; | |
| 179 | + } | |
| 180 | + | |
| 181 | + /** | |
| 182 | + * Returns a BigInteger whose i-th bit corresponds to the | |
| 183 | + * i-th coefficient of the reduction polynomial for polynomial | |
| 184 | + * basis or null for normal basis. | |
| 185 | + * @return a BigInteger whose i-th bit corresponds to the | |
| 186 | + * i-th coefficient of the reduction polynomial for polynomial | |
| 187 | + * basis or null for normal basis. | |
| 188 | + */ | |
| 189 | + public BigInteger getReductionPolynomial() { | |
| 190 | + return rp; | |
| 191 | + } | |
| 192 | + | |
| 193 | + /** | |
| 194 | + * Returns an integer array which contains the order of the | |
| 195 | + * middle term(s) of the reduction polynomial for polynomial | |
| 196 | + * basis or null for normal basis. | |
| 197 | + * @return an integer array which contains the order of the | |
| 198 | + * middle term(s) of the reduction polynomial for polynomial | |
| 199 | + * basis or null for normal basis. A new array is returned | |
| 200 | + * each time this method is called. | |
| 201 | + */ | |
| 202 | + public int[] getMidTermsOfReductionPolynomial() { | |
| 203 | + if (ks == null) { | |
| 204 | + return null; | |
| 205 | + } else { | |
| 206 | + return ks.clone(); | |
| 207 | + } | |
| 208 | + } | |
| 209 | + | |
| 210 | + /** | |
| 211 | + * Compares this finite field for equality with the | |
| 212 | + * specified object. | |
| 213 | + * @param obj the object to be compared. | |
| 214 | + * @return true if <code>obj</code> is an instance | |
| 215 | + * of ECFieldF2m and both <code>m</code> and the reduction | |
| 216 | + * polynomial match, false otherwise. | |
| 217 | + */ | |
| 218 | + public boolean equals(Object obj) { | |
| 219 | + if (this == obj) return true; | |
| 220 | + if (obj instanceof ECFieldF2m) { | |
| 221 | + // no need to compare rp here since ks and rp | |
| 222 | + // should be equivalent | |
| 223 | + return ((m == ((ECFieldF2m)obj).m) && | |
| 224 | + (Arrays.equals(ks, ((ECFieldF2m) obj).ks))); | |
| 225 | + } | |
| 226 | + return false; | |
| 227 | + } | |
| 228 | + | |
| 229 | + /** | |
| 230 | + * Returns a hash code value for this characteristic 2 | |
| 231 | + * finite field. | |
| 232 | + * @return a hash code value. | |
| 233 | + */ | |
| 234 | + public int hashCode() { | |
| 235 | + int value = m << 5; | |
| 236 | + value += (rp==null? 0:rp.hashCode()); | |
| 237 | + // no need to involve ks here since ks and rp | |
| 238 | + // should be equivalent. | |
| 239 | + return value; | |
| 240 | + } | |
| 241 | +} | |
Binary file not shown.
| @@ -0,0 +1,98 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 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.math.BigInteger; | |
| 28 | +import java.util.Arrays; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This immutable class defines an elliptic curve (EC) prime | |
| 32 | + * finite field. | |
| 33 | + * | |
| 34 | + * @see ECField | |
| 35 | + * | |
| 36 | + * @author Valerie Peng | |
| 37 | + * | |
| 38 | + * @since 1.5 | |
| 39 | + */ | |
| 40 | +public class ECFieldFp implements ECField { | |
| 41 | + | |
| 42 | + private BigInteger p; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Creates an elliptic curve prime finite field | |
| 46 | + * with the specified prime <code>p</code>. | |
| 47 | + * @param p the prime. | |
| 48 | + * @exception NullPointerException if <code>p</code> is null. | |
| 49 | + * @exception IllegalArgumentException if <code>p</code> | |
| 50 | + * is not positive. | |
| 51 | + */ | |
| 52 | + public ECFieldFp(BigInteger p) { | |
| 53 | + if (p.signum() != 1) { | |
| 54 | + throw new IllegalArgumentException("p is not positive"); | |
| 55 | + } | |
| 56 | + this.p = p; | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Returns the field size in bits which is size of prime p | |
| 61 | + * for this prime finite field. | |
| 62 | + * @return the field size in bits. | |
| 63 | + */ | |
| 64 | + public int getFieldSize() { | |
| 65 | + return p.bitLength(); | |
| 66 | + }; | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Returns the prime <code>p</code> of this prime finite field. | |
| 70 | + * @return the prime. | |
| 71 | + */ | |
| 72 | + public BigInteger getP() { | |
| 73 | + return p; | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * Compares this prime finite field for equality with the | |
| 78 | + * specified object. | |
| 79 | + * @param obj the object to be compared. | |
| 80 | + * @return true if <code>obj</code> is an instance | |
| 81 | + * of ECFieldFp and the prime value match, false otherwise. | |
| 82 | + */ | |
| 83 | + public boolean equals(Object obj) { | |
| 84 | + if (this == obj) return true; | |
| 85 | + if (obj instanceof ECFieldFp) { | |
| 86 | + return (p.equals(((ECFieldFp)obj).p)); | |
| 87 | + } | |
| 88 | + return false; | |
| 89 | + } | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * Returns a hash code value for this prime finite field. | |
| 93 | + * @return a hash code value. | |
| 94 | + */ | |
| 95 | + public int hashCode() { | |
| 96 | + return p.hashCode(); | |
| 97 | + } | |
| 98 | +} | |
Binary file not shown.
| @@ -0,0 +1,68 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 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 | +/** | |
| 28 | + * This immutable class specifies the set of parameters used for | |
| 29 | + * generating elliptic curve (EC) domain parameters. | |
| 30 | + * | |
| 31 | + * @see AlgorithmParameterSpec | |
| 32 | + * | |
| 33 | + * @author Valerie Peng | |
| 34 | + * | |
| 35 | + * @since 1.5 | |
| 36 | + */ | |
| 37 | +public class ECGenParameterSpec implements AlgorithmParameterSpec { | |
| 38 | + | |
| 39 | + private String name; | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * Creates a parameter specification for EC parameter | |
| 43 | + * generation using a standard (or predefined) name | |
| 44 | + * <code>stdName</code> in order to generate the corresponding | |
| 45 | + * (precomputed) elliptic curve domain parameters. For the | |
| 46 | + * list of supported names, please consult the documentation | |
| 47 | + * of provider whose implementation will be used. | |
| 48 | + * @param stdName the standard name of the to-be-generated EC | |
| 49 | + * domain parameters. | |
| 50 | + * @exception NullPointerException if <code>stdName</code> | |
| 51 | + * is null. | |
| 52 | + */ | |
| 53 | + public ECGenParameterSpec(String stdName) { | |
| 54 | + if (stdName == null) { | |
| 55 | + throw new NullPointerException("stdName is null"); | |
| 56 | + } | |
| 57 | + this.name = stdName; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Returns the standard or predefined name of the | |
| 62 | + * to-be-generated EC domain parameters. | |
| 63 | + * @return the standard or predefined name. | |
| 64 | + */ | |
| 65 | + public String getName() { | |
| 66 | + return name; | |
| 67 | + } | |
| 68 | +} | |
Binary file not shown.
| @@ -0,0 +1,113 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 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.math.BigInteger; | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * This immutable class specifies the set of domain parameters | |
| 31 | + * used with elliptic curve cryptography (ECC). | |
| 32 | + * | |
| 33 | + * @see AlgorithmParameterSpec | |
| 34 | + * | |
| 35 | + * @author Valerie Peng | |
| 36 | + * | |
| 37 | + * @since 1.5 | |
| 38 | + */ | |
| 39 | +public class ECParameterSpec implements AlgorithmParameterSpec { | |
| 40 | + | |
| 41 | + private final EllipticCurve curve; | |
| 42 | + private final ECPoint g; | |
| 43 | + private final BigInteger n; | |
| 44 | + private final int h; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Creates elliptic curve domain parameters based on the | |
| 48 | + * specified values. | |
| 49 | + * @param curve the elliptic curve which this parameter | |
| 50 | + * defines. | |
| 51 | + * @param g the generator which is also known as the base point. | |
| 52 | + * @param n the order of the generator <code>g</code>. | |
| 53 | + * @param h the cofactor. | |
| 54 | + * @exception NullPointerException if <code>curve</code>, | |
| 55 | + * <code>g</code>, or <code>n</code> is null. | |
| 56 | + * @exception IllegalArgumentException if <code>n</code> | |
| 57 | + * or <code>h</code> is not positive. | |
| 58 | + */ | |
| 59 | + public ECParameterSpec(EllipticCurve curve, ECPoint g, | |
| 60 | + BigInteger n, int h) { | |
| 61 | + if (curve == null) { | |
| 62 | + throw new NullPointerException("curve is null"); | |
| 63 | + } | |
| 64 | + if (g == null) { | |
| 65 | + throw new NullPointerException("g is null"); | |
| 66 | + } | |
| 67 | + if (n == null) { | |
| 68 | + throw new NullPointerException("n is null"); | |
| 69 | + } | |
| 70 | + if (n.signum() != 1) { | |
| 71 | + throw new IllegalArgumentException("n is not positive"); | |
| 72 | + } | |
| 73 | + if (h <= 0) { | |
| 74 | + throw new IllegalArgumentException("h is not positive"); | |
| 75 | + } | |
| 76 | + this.curve = curve; | |
| 77 | + this.g = g; | |
| 78 | + this.n = n; | |
| 79 | + this.h = h; | |
| 80 | + } | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * Returns the elliptic curve that this parameter defines. | |
| 84 | + * @return the elliptic curve that this parameter defines. | |
| 85 | + */ | |
| 86 | + public EllipticCurve getCurve() { | |
| 87 | + return curve; | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * Returns the generator which is also known as the base point. | |
| 92 | + * @return the generator which is also known as the base point. | |
| 93 | + */ | |
| 94 | + public ECPoint getGenerator() { | |
| 95 | + return g; | |
| 96 | + } | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * Returns the order of the generator. | |
| 100 | + * @return the order of the generator. | |
| 101 | + */ | |
| 102 | + public BigInteger getOrder() { | |
| 103 | + return n; | |
| 104 | + } | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * Returns the cofactor. | |
| 108 | + * @return the cofactor. | |
| 109 | + */ | |
| 110 | + public int getCofactor() { | |
| 111 | + return h; | |
| 112 | + } | |
| 113 | +} | |
Binary file not shown.
| @@ -0,0 +1,114 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 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.math.BigInteger; | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * This immutable class represents a point on an elliptic curve (EC) | |
| 31 | + * in affine coordinates. Other coordinate systems can | |
| 32 | + * extend this class to represent this point in other | |
| 33 | + * coordinates. | |
| 34 | + * | |
| 35 | + * @author Valerie Peng | |
| 36 | + * | |
| 37 | + * @since 1.5 | |
| 38 | + */ | |
| 39 | +public class ECPoint { | |
| 40 | + | |
| 41 | + private final BigInteger x; | |
| 42 | + private final BigInteger y; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * This defines the point at infinity. | |
| 46 | + */ | |
| 47 | + public static final ECPoint POINT_INFINITY = new ECPoint(); | |
| 48 | + | |
| 49 | + // private constructor for constructing point at infinity | |
| 50 | + private ECPoint() { | |
| 51 | + this.x = null; | |
| 52 | + this.y = null; | |
| 53 | + } | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * Creates an ECPoint from the specified affine x-coordinate | |
| 57 | + * <code>x</code> and affine y-coordinate <code>y</code>. | |
| 58 | + * @param x the affine x-coordinate. | |
| 59 | + * @param y the affine y-coordinate. | |
| 60 | + * @exception NullPointerException if <code>x</code> or | |
| 61 | + * <code>y</code> is null. | |
| 62 | + */ | |
| 63 | + public ECPoint(BigInteger x, BigInteger y) { | |
| 64 | + if ((x==null) || (y==null)) { | |
| 65 | + throw new NullPointerException("affine coordinate x or y is null"); | |
| 66 | + } | |
| 67 | + this.x = x; | |
| 68 | + this.y = y; | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Returns the affine x-coordinate <code>x</code>. | |
| 73 | + * Note: POINT_INFINITY has a null affine x-coordinate. | |
| 74 | + * @return the affine x-coordinate. | |
| 75 | + */ | |
| 76 | + public BigInteger getAffineX() { | |
| 77 | + return x; | |
| 78 | + } | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Returns the affine y-coordinate <code>y</code>. | |
| 82 | + * Note: POINT_INFINITY has a null affine y-coordinate. | |
| 83 | + * @return the affine y-coordinate. | |
| 84 | + */ | |
| 85 | + public BigInteger getAffineY() { | |
| 86 | + return y; | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * Compares this elliptic curve point for equality with | |
| 91 | + * the specified object. | |
| 92 | + * @param obj the object to be compared. | |
| 93 | + * @return true if <code>obj</code> is an instance of | |
| 94 | + * ECPoint and the affine coordinates match, false otherwise. | |
| 95 | + */ | |
| 96 | + public boolean equals(Object obj) { | |
| 97 | + if (this == obj) return true; | |
| 98 | + if (this == POINT_INFINITY) return false; | |
| 99 | + if (obj instanceof ECPoint) { | |
| 100 | + return ((x.equals(((ECPoint)obj).x)) && | |
| 101 | + (y.equals(((ECPoint)obj).y))); | |
| 102 | + } | |
| 103 | + return false; | |
| 104 | + } | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * Returns a hash code value for this elliptic curve point. | |
| 108 | + * @return a hash code value. | |
| 109 | + */ | |
| 110 | + public int hashCode() { | |
| 111 | + if (this == POINT_INFINITY) return 0; | |
| 112 | + return x.hashCode() << 5 + y.hashCode(); | |
| 113 | + } | |
| 114 | +} | |
Binary file not shown.
| @@ -0,0 +1,81 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 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.math.BigInteger; | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * This immutable class specifies an elliptic curve private key with | |
| 31 | + * its associated parameters. | |
| 32 | + * | |
| 33 | + * @see KeySpec | |
| 34 | + * @see ECParameterSpec | |
| 35 | + * | |
| 36 | + * @author Valerie Peng | |
| 37 | + * | |
| 38 | + * @since 1.5 | |
| 39 | + */ | |
| 40 | +public class ECPrivateKeySpec implements KeySpec { | |
| 41 | + | |
| 42 | + private BigInteger s; | |
| 43 | + private ECParameterSpec params; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Creates a new ECPrivateKeySpec with the specified | |
| 47 | + * parameter values. | |
| 48 | + * @param s the private value. | |
| 49 | + * @param params the associated elliptic curve domain | |
| 50 | + * parameters. | |
| 51 | + * @exception NullPointerException if <code>s</code> | |
| 52 | + * or <code>params</code> is null. | |
| 53 | + */ | |
| 54 | + public ECPrivateKeySpec(BigInteger s, ECParameterSpec params) { | |
| 55 | + if (s == null) { | |
| 56 | + throw new NullPointerException("s is null"); | |
| 57 | + } | |
| 58 | + if (params == null) { | |
| 59 | + throw new NullPointerException("params is null"); | |
| 60 | + } | |
| 61 | + this.s = s; | |
| 62 | + this.params = params; | |
| 63 | + } | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * Returns the private value S. | |
| 67 | + * @return the private value S. | |
| 68 | + */ | |
| 69 | + public BigInteger getS() { | |
| 70 | + return s; | |
| 71 | + } | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * Returns the associated elliptic curve domain | |
| 75 | + * parameters. | |
| 76 | + * @return the EC domain parameters. | |
| 77 | + */ | |
| 78 | + public ECParameterSpec getParams() { | |
| 79 | + return params; | |
| 80 | + } | |
| 81 | +} | |
Binary file not shown.
| @@ -0,0 +1,85 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 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 | +/** | |
| 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 | + * | |
| 37 | + * @since 1.5 | |
| 38 | + */ | |
| 39 | +public class ECPublicKeySpec implements KeySpec { | |
| 40 | + | |
| 41 | + private ECPoint w; | |
| 42 | + private ECParameterSpec params; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Creates a new ECPublicKeySpec with the specified | |
| 46 | + * parameter values. | |
| 47 | + * @param w the public point. | |
| 48 | + * @param params the associated elliptic curve domain | |
| 49 | + * parameters. | |
| 50 | + * @exception NullPointerException if <code>w</code> | |
| 51 | + * or <code>params</code> is null. | |
| 52 | + * @exception IllegalArgumentException if <code>w</code> | |
| 53 | + * is point at infinity, i.e. ECPoint.POINT_INFINITY | |
| 54 | + */ | |
| 55 | + public ECPublicKeySpec(ECPoint w, ECParameterSpec params) { | |
| 56 | + if (w == null) { | |
| 57 | + throw new NullPointerException("w is null"); | |
| 58 | + } | |
| 59 | + if (params == null) { | |
| 60 | + throw new NullPointerException("params is null"); | |
| 61 | + } | |
| 62 | + if (w == ECPoint.POINT_INFINITY) { | |
| 63 | + throw new IllegalArgumentException("w is ECPoint.POINT_INFINITY"); | |
| 64 | + } | |
| 65 | + this.w = w; | |
| 66 | + this.params = params; | |
| 67 | + } | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * Returns the public point W. | |
| 71 | + * @return the public point W. | |
| 72 | + */ | |
| 73 | + public ECPoint getW() { | |
| 74 | + return w; | |
| 75 | + } | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * Returns the associated elliptic curve domain | |
| 79 | + * parameters. | |
| 80 | + * @return the EC domain parameters. | |
| 81 | + */ | |
| 82 | + public ECParameterSpec getParams() { | |
| 83 | + return params; | |
| 84 | + } | |
| 85 | +} | |
Binary file not shown.
| @@ -0,0 +1,196 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 2011, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | +import java.util.Arrays; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * This immutable class holds the necessary values needed to represent | |
| 33 | + * an elliptic curve. | |
| 34 | + * | |
| 35 | + * @see ECField | |
| 36 | + * @see ECFieldFp | |
| 37 | + * @see ECFieldF2m | |
| 38 | + * | |
| 39 | + * @author Valerie Peng | |
| 40 | + * | |
| 41 | + * @since 1.5 | |
| 42 | + */ | |
| 43 | +public class EllipticCurve { | |
| 44 | + | |
| 45 | + private final ECField field; | |
| 46 | + private final BigInteger a; | |
| 47 | + private final BigInteger b; | |
| 48 | + private final byte[] seed; | |
| 49 | + | |
| 50 | + // Check coefficient c is a valid element in ECField field. | |
| 51 | + private static void checkValidity(ECField field, BigInteger c, | |
| 52 | + String cName) { | |
| 53 | + // can only perform check if field is ECFieldFp or ECFieldF2m. | |
| 54 | + if (field instanceof ECFieldFp) { | |
| 55 | + BigInteger p = ((ECFieldFp)field).getP(); | |
| 56 | + if (p.compareTo(c) != 1) { | |
| 57 | + throw new IllegalArgumentException(cName + " is too large"); | |
| 58 | + } else if (c.signum() < 0) { | |
| 59 | + throw new IllegalArgumentException(cName + " is negative"); | |
| 60 | + } | |
| 61 | + } else if (field instanceof ECFieldF2m) { | |
| 62 | + int m = ((ECFieldF2m)field).getM(); | |
| 63 | + if (c.bitLength() > m) { | |
| 64 | + throw new IllegalArgumentException(cName + " is too large"); | |
| 65 | + } | |
| 66 | + } | |
| 67 | + } | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * Creates an elliptic curve with the specified elliptic field | |
| 71 | + * <code>field</code> and the coefficients <code>a</code> and | |
| 72 | + * <code>b</code>. | |
| 73 | + * @param field the finite field that this elliptic curve is over. | |
| 74 | + * @param a the first coefficient of this elliptic curve. | |
| 75 | + * @param b the second coefficient of this elliptic curve. | |
| 76 | + * @exception NullPointerException if <code>field</code>, | |
| 77 | + * <code>a</code>, or <code>b</code> is null. | |
| 78 | + * @exception IllegalArgumentException if <code>a</code> | |
| 79 | + * or <code>b</code> is not null and not in <code>field</code>. | |
| 80 | + */ | |
| 81 | + public EllipticCurve(ECField field, BigInteger a, | |
| 82 | + BigInteger b) { | |
| 83 | + this(field, a, b, null); | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * Creates an elliptic curve with the specified elliptic field | |
| 88 | + * <code>field</code>, the coefficients <code>a</code> and | |
| 89 | + * <code>b</code>, and the <code>seed</code> used for curve generation. | |
| 90 | + * @param field the finite field that this elliptic curve is over. | |
| 91 | + * @param a the first coefficient of this elliptic curve. | |
| 92 | + * @param b the second coefficient of this elliptic curve. | |
| 93 | + * @param seed the bytes used during curve generation for later | |
| 94 | + * validation. Contents of this array are copied to protect against | |
| 95 | + * subsequent modification. | |
| 96 | + * @exception NullPointerException if <code>field</code>, | |
| 97 | + * <code>a</code>, or <code>b</code> is null. | |
| 98 | + * @exception IllegalArgumentException if <code>a</code> | |
| 99 | + * or <code>b</code> is not null and not in <code>field</code>. | |
| 100 | + */ | |
| 101 | + public EllipticCurve(ECField field, BigInteger a, | |
| 102 | + BigInteger b, byte[] seed) { | |
| 103 | + if (field == null) { | |
| 104 | + throw new NullPointerException("field is null"); | |
| 105 | + } | |
| 106 | + if (a == null) { | |
| 107 | + throw new NullPointerException("first coefficient is null"); | |
| 108 | + } | |
| 109 | + if (b == null) { | |
| 110 | + throw new NullPointerException("second coefficient is null"); | |
| 111 | + } | |
| 112 | + checkValidity(field, a, "first coefficient"); | |
| 113 | + checkValidity(field, b, "second coefficient"); | |
| 114 | + this.field = field; | |
| 115 | + this.a = a; | |
| 116 | + this.b = b; | |
| 117 | + if (seed != null) { | |
| 118 | + this.seed = seed.clone(); | |
| 119 | + } else { | |
| 120 | + this.seed = null; | |
| 121 | + } | |
| 122 | + } | |
| 123 | + | |
| 124 | + /** | |
| 125 | + * Returns the finite field <code>field</code> that this | |
| 126 | + * elliptic curve is over. | |
| 127 | + * @return the field <code>field</code> that this curve | |
| 128 | + * is over. | |
| 129 | + */ | |
| 130 | + public ECField getField() { | |
| 131 | + return field; | |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * Returns the first coefficient <code>a</code> of the | |
| 136 | + * elliptic curve. | |
| 137 | + * @return the first coefficient <code>a</code>. | |
| 138 | + */ | |
| 139 | + public BigInteger getA() { | |
| 140 | + return a; | |
| 141 | + } | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * Returns the second coefficient <code>b</code> of the | |
| 145 | + * elliptic curve. | |
| 146 | + * @return the second coefficient <code>b</code>. | |
| 147 | + */ | |
| 148 | + public BigInteger getB() { | |
| 149 | + return b; | |
| 150 | + } | |
| 151 | + | |
| 152 | + /** | |
| 153 | + * Returns the seeding bytes <code>seed</code> used | |
| 154 | + * during curve generation. May be null if not specified. | |
| 155 | + * @return the seeding bytes <code>seed</code>. A new | |
| 156 | + * array is returned each time this method is called. | |
| 157 | + */ | |
| 158 | + public byte[] getSeed() { | |
| 159 | + if (seed == null) return null; | |
| 160 | + else return seed.clone(); | |
| 161 | + } | |
| 162 | + | |
| 163 | + /** | |
| 164 | + * Compares this elliptic curve for equality with the | |
| 165 | + * specified object. | |
| 166 | + * @param obj the object to be compared. | |
| 167 | + * @return true if <code>obj</code> is an instance of | |
| 168 | + * EllipticCurve and the field, A, and B match, false otherwise. | |
| 169 | + */ | |
| 170 | + public boolean equals(Object obj) { | |
| 171 | + if (this == obj) return true; | |
| 172 | + if (obj instanceof EllipticCurve) { | |
| 173 | + EllipticCurve curve = (EllipticCurve) obj; | |
| 174 | + if ((field.equals(curve.field)) && | |
| 175 | + (a.equals(curve.a)) && | |
| 176 | + (b.equals(curve.b))) { | |
| 177 | + return true; | |
| 178 | + } | |
| 179 | + } | |
| 180 | + return false; | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 184 | + * Returns a hash code value for this elliptic curve. | |
| 185 | + * @return a hash code value computed from the hash codes of the field, A, | |
| 186 | + * and B, as follows: | |
| 187 | + * <code> | |
| 188 | + * (field.hashCode() << 6) + (a.hashCode() << 4) + (b.hashCode() << 2) | |
| 189 | + * </code> | |
| 190 | + */ | |
| 191 | + public int hashCode() { | |
| 192 | + return (field.hashCode() << 6 + | |
| 193 | + (a.hashCode() << 4) + | |
| 194 | + (b.hashCode() << 2)); | |
| 195 | + } | |
| 196 | +} | |
Binary file not shown.
| @@ -0,0 +1,85 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2005, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * This class represents a public or private key in encoded format. | |
| 30 | + * | |
| 31 | + * @author Jan Luehe | |
| 32 | + * | |
| 33 | + * | |
| 34 | + * @see java.security.Key | |
| 35 | + * @see java.security.KeyFactory | |
| 36 | + * @see KeySpec | |
| 37 | + * @see X509EncodedKeySpec | |
| 38 | + * @see PKCS8EncodedKeySpec | |
| 39 | + * | |
| 40 | + * @since 1.2 | |
| 41 | + */ | |
| 42 | + | |
| 43 | +public abstract class EncodedKeySpec implements KeySpec { | |
| 44 | + | |
| 45 | + private byte[] encodedKey; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Creates a new EncodedKeySpec with the given encoded key. | |
| 49 | + * | |
| 50 | + * @param encodedKey the encoded key. The contents of the | |
| 51 | + * array are copied to protect against subsequent modification. | |
| 52 | + * @exception NullPointerException if <code>encodedKey</code> | |
| 53 | + * is null. | |
| 54 | + */ | |
| 55 | + public EncodedKeySpec(byte[] encodedKey) { | |
| 56 | + this.encodedKey = encodedKey.clone(); | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Returns the encoded key. | |
| 61 | + * | |
| 62 | + * @return the encoded key. Returns a new array each time | |
| 63 | + * this method is called. | |
| 64 | + */ | |
| 65 | + public byte[] getEncoded() { | |
| 66 | + return this.encodedKey.clone(); | |
| 67 | + } | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * Returns the name of the encoding format associated with this | |
| 71 | + * key specification. | |
| 72 | + * | |
| 73 | + * <p>If the opaque representation of a key | |
| 74 | + * (see {@link java.security.Key Key}) can be transformed | |
| 75 | + * (see {@link java.security.KeyFactory KeyFactory}) | |
| 76 | + * into this key specification (or a subclass of it), | |
| 77 | + * <code>getFormat</code> called | |
| 78 | + * on the opaque key returns the same value as the | |
| 79 | + * <code>getFormat</code> method | |
| 80 | + * of this key specification. | |
| 81 | + * | |
| 82 | + * @return a string representation of the encoding format. | |
| 83 | + */ | |
| 84 | + public abstract String getFormat(); | |
| 85 | +} | |
Binary file not shown.
| @@ -0,0 +1,94 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2003, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.security.GeneralSecurityException; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This is the exception for invalid key specifications. | |
| 32 | + * | |
| 33 | + * @author Jan Luehe | |
| 34 | + * | |
| 35 | + * | |
| 36 | + * @see KeySpec | |
| 37 | + * | |
| 38 | + * @since 1.2 | |
| 39 | + */ | |
| 40 | + | |
| 41 | +public class InvalidKeySpecException extends GeneralSecurityException { | |
| 42 | + | |
| 43 | + private static final long serialVersionUID = 3546139293998810778L; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Constructs an InvalidKeySpecException with no detail message. A | |
| 47 | + * detail message is a String that describes this particular | |
| 48 | + * exception. | |
| 49 | + */ | |
| 50 | + public InvalidKeySpecException() { | |
| 51 | + super(); | |
| 52 | + } | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Constructs an InvalidKeySpecException with the specified detail | |
| 56 | + * message. A detail message is a String that describes this | |
| 57 | + * particular exception. | |
| 58 | + * | |
| 59 | + * @param msg the detail message. | |
| 60 | + */ | |
| 61 | + public InvalidKeySpecException(String msg) { | |
| 62 | + super(msg); | |
| 63 | + } | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * Creates a <code>InvalidKeySpecException</code> with the specified | |
| 67 | + * detail message and cause. | |
| 68 | + * | |
| 69 | + * @param message the detail message (which is saved for later retrieval | |
| 70 | + * by the {@link #getMessage()} method). | |
| 71 | + * @param cause the cause (which is saved for later retrieval by the | |
| 72 | + * {@link #getCause()} method). (A <tt>null</tt> value is permitted, | |
| 73 | + * and indicates that the cause is nonexistent or unknown.) | |
| 74 | + * @since 1.5 | |
| 75 | + */ | |
| 76 | + public InvalidKeySpecException(String message, Throwable cause) { | |
| 77 | + super(message, cause); | |
| 78 | + } | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Creates a <code>InvalidKeySpecException</code> with the specified cause | |
| 82 | + * and a detail message of <tt>(cause==null ? null : cause.toString())</tt> | |
| 83 | + * (which typically contains the class and detail message of | |
| 84 | + * <tt>cause</tt>). | |
| 85 | + * | |
| 86 | + * @param cause the cause (which is saved for later retrieval by the | |
| 87 | + * {@link #getCause()} method). (A <tt>null</tt> value is permitted, | |
| 88 | + * and indicates that the cause is nonexistent or unknown.) | |
| 89 | + * @since 1.5 | |
| 90 | + */ | |
| 91 | + public InvalidKeySpecException(Throwable cause) { | |
| 92 | + super(cause); | |
| 93 | + } | |
| 94 | +} | |
Binary file not shown.
| @@ -0,0 +1,66 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2003, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.security.GeneralSecurityException; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This is the exception for invalid parameter specifications. | |
| 32 | + * | |
| 33 | + * @author Jan Luehe | |
| 34 | + * | |
| 35 | + * | |
| 36 | + * @see java.security.AlgorithmParameters | |
| 37 | + * @see AlgorithmParameterSpec | |
| 38 | + * @see DSAParameterSpec | |
| 39 | + * | |
| 40 | + * @since 1.2 | |
| 41 | + */ | |
| 42 | + | |
| 43 | +public class InvalidParameterSpecException extends GeneralSecurityException { | |
| 44 | + | |
| 45 | + private static final long serialVersionUID = -970468769593399342L; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Constructs an InvalidParameterSpecException with no detail message. A | |
| 49 | + * detail message is a String that describes this particular | |
| 50 | + * exception. | |
| 51 | + */ | |
| 52 | + public InvalidParameterSpecException() { | |
| 53 | + super(); | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Constructs an InvalidParameterSpecException with the specified detail | |
| 58 | + * message. A detail message is a String that describes this | |
| 59 | + * particular exception. | |
| 60 | + * | |
| 61 | + * @param msg the detail message. | |
| 62 | + */ | |
| 63 | + public InvalidParameterSpecException(String msg) { | |
| 64 | + super(msg); | |
| 65 | + } | |
| 66 | +} | |
Binary file not shown.
| @@ -0,0 +1,62 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1999, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * A (transparent) specification of the key material | |
| 30 | + * that constitutes a cryptographic key. | |
| 31 | + * | |
| 32 | + * <p>If the key is stored on a hardware device, its | |
| 33 | + * specification may contain information that helps identify the key on the | |
| 34 | + * device. | |
| 35 | + * | |
| 36 | + * <P> A key may be specified in an algorithm-specific way, or in an | |
| 37 | + * algorithm-independent encoding format (such as ASN.1). | |
| 38 | + * For example, a DSA private key may be specified by its components | |
| 39 | + * <code>x</code>, <code>p</code>, <code>q</code>, and <code>g</code> | |
| 40 | + * (see {@link DSAPrivateKeySpec}), or it may be | |
| 41 | + * specified using its DER encoding | |
| 42 | + * (see {@link PKCS8EncodedKeySpec}). | |
| 43 | + * | |
| 44 | + * <P> This interface contains no methods or constants. Its only purpose | |
| 45 | + * is to group (and provide type safety for) all key specifications. | |
| 46 | + * All key specifications must implement this interface. | |
| 47 | + * | |
| 48 | + * @author Jan Luehe | |
| 49 | + * | |
| 50 | + * | |
| 51 | + * @see java.security.Key | |
| 52 | + * @see java.security.KeyFactory | |
| 53 | + * @see EncodedKeySpec | |
| 54 | + * @see X509EncodedKeySpec | |
| 55 | + * @see PKCS8EncodedKeySpec | |
| 56 | + * @see DSAPrivateKeySpec | |
| 57 | + * @see DSAPublicKeySpec | |
| 58 | + * | |
| 59 | + * @since 1.2 | |
| 60 | + */ | |
| 61 | + | |
| 62 | +public interface KeySpec { } | |
Binary file not shown.
| @@ -0,0 +1,107 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 2006, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.security.spec.AlgorithmParameterSpec; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This class specifies the set of parameters used with mask generation | |
| 32 | + * function MGF1 in OAEP Padding and RSA-PSS signature scheme, as | |
| 33 | + * defined in the | |
| 34 | + * <a href="http://www.ietf.org/rfc/rfc3447.txt">PKCS #1 v2.1</a> | |
| 35 | + * standard. | |
| 36 | + * | |
| 37 | + * <p>Its ASN.1 definition in PKCS#1 standard is described below: | |
| 38 | + * <pre> | |
| 39 | + * MGF1Parameters ::= OAEP-PSSDigestAlgorthms | |
| 40 | + * </pre> | |
| 41 | + * where | |
| 42 | + * <pre> | |
| 43 | + * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= { | |
| 44 | + * { OID id-sha1 PARAMETERS NULL }| | |
| 45 | + * { OID id-sha256 PARAMETERS NULL }| | |
| 46 | + * { OID id-sha384 PARAMETERS NULL }| | |
| 47 | + * { OID id-sha512 PARAMETERS NULL }, | |
| 48 | + * ... -- Allows for future expansion -- | |
| 49 | + * } | |
| 50 | + * </pre> | |
| 51 | + * @see PSSParameterSpec | |
| 52 | + * @see javax.crypto.spec.OAEPParameterSpec | |
| 53 | + * | |
| 54 | + * @author Valerie Peng | |
| 55 | + * | |
| 56 | + * @since 1.5 | |
| 57 | + */ | |
| 58 | +public class MGF1ParameterSpec implements AlgorithmParameterSpec { | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * The MGF1ParameterSpec which uses "SHA-1" message digest. | |
| 62 | + */ | |
| 63 | + public static final MGF1ParameterSpec SHA1 = | |
| 64 | + new MGF1ParameterSpec("SHA-1"); | |
| 65 | + /** | |
| 66 | + * The MGF1ParameterSpec which uses "SHA-256" message digest. | |
| 67 | + */ | |
| 68 | + public static final MGF1ParameterSpec SHA256 = | |
| 69 | + new MGF1ParameterSpec("SHA-256"); | |
| 70 | + /** | |
| 71 | + * The MGF1ParameterSpec which uses "SHA-384" message digest. | |
| 72 | + */ | |
| 73 | + public static final MGF1ParameterSpec SHA384 = | |
| 74 | + new MGF1ParameterSpec("SHA-384"); | |
| 75 | + /** | |
| 76 | + * The MGF1ParameterSpec which uses SHA-512 message digest. | |
| 77 | + */ | |
| 78 | + public static final MGF1ParameterSpec SHA512 = | |
| 79 | + new MGF1ParameterSpec("SHA-512"); | |
| 80 | + | |
| 81 | + private String mdName; | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * Constructs a parameter set for mask generation function MGF1 | |
| 85 | + * as defined in the PKCS #1 standard. | |
| 86 | + * | |
| 87 | + * @param mdName the algorithm name for the message digest | |
| 88 | + * used in this mask generation function MGF1. | |
| 89 | + * @exception NullPointerException if <code>mdName</code> is null. | |
| 90 | + */ | |
| 91 | + public MGF1ParameterSpec(String mdName) { | |
| 92 | + if (mdName == null) { | |
| 93 | + throw new NullPointerException("digest algorithm is null"); | |
| 94 | + } | |
| 95 | + this.mdName = mdName; | |
| 96 | + } | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * Returns the algorithm name of the message digest used by the mask | |
| 100 | + * generation function. | |
| 101 | + * | |
| 102 | + * @return the algorithm name of the message digest. | |
| 103 | + */ | |
| 104 | + public String getDigestAlgorithm() { | |
| 105 | + return mdName; | |
| 106 | + } | |
| 107 | +} | |
Binary file not shown.
| @@ -0,0 +1,96 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2005, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * This class represents the ASN.1 encoding of a private key, | |
| 30 | + * encoded according to the ASN.1 type <code>PrivateKeyInfo</code>. | |
| 31 | + * The <code>PrivateKeyInfo</code> syntax is defined in the PKCS#8 standard | |
| 32 | + * as follows: | |
| 33 | + * | |
| 34 | + * <pre> | |
| 35 | + * PrivateKeyInfo ::= SEQUENCE { | |
| 36 | + * version Version, | |
| 37 | + * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, | |
| 38 | + * privateKey PrivateKey, | |
| 39 | + * attributes [0] IMPLICIT Attributes OPTIONAL } | |
| 40 | + * | |
| 41 | + * Version ::= INTEGER | |
| 42 | + * | |
| 43 | + * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier | |
| 44 | + * | |
| 45 | + * PrivateKey ::= OCTET STRING | |
| 46 | + * | |
| 47 | + * Attributes ::= SET OF Attribute | |
| 48 | + * </pre> | |
| 49 | + * | |
| 50 | + * @author Jan Luehe | |
| 51 | + * | |
| 52 | + * | |
| 53 | + * @see java.security.Key | |
| 54 | + * @see java.security.KeyFactory | |
| 55 | + * @see KeySpec | |
| 56 | + * @see EncodedKeySpec | |
| 57 | + * @see X509EncodedKeySpec | |
| 58 | + * | |
| 59 | + * @since 1.2 | |
| 60 | + */ | |
| 61 | + | |
| 62 | +public class PKCS8EncodedKeySpec extends EncodedKeySpec { | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * Creates a new PKCS8EncodedKeySpec with the given encoded key. | |
| 66 | + * | |
| 67 | + * @param encodedKey the key, which is assumed to be | |
| 68 | + * encoded according to the PKCS #8 standard. The contents of | |
| 69 | + * the array are copied to protect against subsequent modification. | |
| 70 | + * @exception NullPointerException if <code>encodedKey</code> | |
| 71 | + * is null. | |
| 72 | + */ | |
| 73 | + public PKCS8EncodedKeySpec(byte[] encodedKey) { | |
| 74 | + super(encodedKey); | |
| 75 | + } | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * Returns the key bytes, encoded according to the PKCS #8 standard. | |
| 79 | + * | |
| 80 | + * @return the PKCS #8 encoding of the key. Returns a new array | |
| 81 | + * each time this method is called. | |
| 82 | + */ | |
| 83 | + public byte[] getEncoded() { | |
| 84 | + return super.getEncoded(); | |
| 85 | + } | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * Returns the name of the encoding format associated with this | |
| 89 | + * key specification. | |
| 90 | + * | |
| 91 | + * @return the string <code>"PKCS#8"</code>. | |
| 92 | + */ | |
| 93 | + public final String getFormat() { | |
| 94 | + return "PKCS#8"; | |
| 95 | + } | |
| 96 | +} | |
Binary file not shown.
| @@ -0,0 +1,211 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2001, 2006, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | +import java.security.spec.MGF1ParameterSpec; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * This class specifies a parameter spec for RSA-PSS signature scheme, | |
| 33 | + * as defined in the | |
| 34 | + * <a href="http://www.ietf.org/rfc/rfc3447.txt">PKCS#1 v2.1</a> | |
| 35 | + * standard. | |
| 36 | + * | |
| 37 | + * <p>Its ASN.1 definition in PKCS#1 standard is described below: | |
| 38 | + * <pre> | |
| 39 | + * RSASSA-PSS-params ::= SEQUENCE { | |
| 40 | + * hashAlgorithm [0] OAEP-PSSDigestAlgorithms DEFAULT sha1, | |
| 41 | + * maskGenAlgorithm [1] PKCS1MGFAlgorithms DEFAULT mgf1SHA1, | |
| 42 | + * saltLength [2] INTEGER DEFAULT 20, | |
| 43 | + * trailerField [3] INTEGER DEFAULT 1 | |
| 44 | + * } | |
| 45 | + * </pre> | |
| 46 | + * where | |
| 47 | + * <pre> | |
| 48 | + * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= { | |
| 49 | + * { OID id-sha1 PARAMETERS NULL }| | |
| 50 | + * { OID id-sha256 PARAMETERS NULL }| | |
| 51 | + * { OID id-sha384 PARAMETERS NULL }| | |
| 52 | + * { OID id-sha512 PARAMETERS NULL }, | |
| 53 | + * ... -- Allows for future expansion -- | |
| 54 | + * } | |
| 55 | + * | |
| 56 | + * PKCS1MGFAlgorithms ALGORITHM-IDENTIFIER ::= { | |
| 57 | + * { OID id-mgf1 PARAMETERS OAEP-PSSDigestAlgorithms }, | |
| 58 | + * ... -- Allows for future expansion -- | |
| 59 | + * } | |
| 60 | + * </pre> | |
| 61 | + * <p>Note: the PSSParameterSpec.DEFAULT uses the following: | |
| 62 | + * message digest -- "SHA-1" | |
| 63 | + * mask generation function (mgf) -- "MGF1" | |
| 64 | + * parameters for mgf -- MGF1ParameterSpec.SHA1 | |
| 65 | + * SaltLength -- 20 | |
| 66 | + * TrailerField -- 1 | |
| 67 | + * | |
| 68 | + * @see MGF1ParameterSpec | |
| 69 | + * @see AlgorithmParameterSpec | |
| 70 | + * @see java.security.Signature | |
| 71 | + * | |
| 72 | + * @author Valerie Peng | |
| 73 | + * | |
| 74 | + * | |
| 75 | + * @since 1.4 | |
| 76 | + */ | |
| 77 | + | |
| 78 | +public class PSSParameterSpec implements AlgorithmParameterSpec { | |
| 79 | + | |
| 80 | + private String mdName = "SHA-1"; | |
| 81 | + private String mgfName = "MGF1"; | |
| 82 | + private AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1; | |
| 83 | + private int saltLen = 20; | |
| 84 | + private int trailerField = 1; | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * The PSS parameter set with all default values. | |
| 88 | + * @since 1.5 | |
| 89 | + */ | |
| 90 | + public static final PSSParameterSpec DEFAULT = new PSSParameterSpec(); | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * Constructs a new <code>PSSParameterSpec</code> as defined in | |
| 94 | + * the PKCS #1 standard using the default values. | |
| 95 | + */ | |
| 96 | + private PSSParameterSpec() { | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * Creates a new <code>PSSParameterSpec</code> as defined in | |
| 101 | + * the PKCS #1 standard using the specified message digest, | |
| 102 | + * mask generation function, parameters for mask generation | |
| 103 | + * function, salt length, and trailer field values. | |
| 104 | + * | |
| 105 | + * @param mdName the algorithm name of the hash function. | |
| 106 | + * @param mgfName the algorithm name of the mask generation | |
| 107 | + * function. | |
| 108 | + * @param mgfSpec the parameters for the mask generation | |
| 109 | + * function. If null is specified, null will be returned by | |
| 110 | + * getMGFParameters(). | |
| 111 | + * @param saltLen the length of salt. | |
| 112 | + * @param trailerField the value of the trailer field. | |
| 113 | + * @exception NullPointerException if <code>mdName</code>, | |
| 114 | + * or <code>mgfName</code> is null. | |
| 115 | + * @exception IllegalArgumentException if <code>saltLen</code> | |
| 116 | + * or <code>trailerField</code> is less than 0. | |
| 117 | + * @since 1.5 | |
| 118 | + */ | |
| 119 | + public PSSParameterSpec(String mdName, String mgfName, | |
| 120 | + AlgorithmParameterSpec mgfSpec, | |
| 121 | + int saltLen, int trailerField) { | |
| 122 | + if (mdName == null) { | |
| 123 | + throw new NullPointerException("digest algorithm is null"); | |
| 124 | + } | |
| 125 | + if (mgfName == null) { | |
| 126 | + throw new NullPointerException("mask generation function " + | |
| 127 | + "algorithm is null"); | |
| 128 | + } | |
| 129 | + if (saltLen < 0) { | |
| 130 | + throw new IllegalArgumentException("negative saltLen value: " + | |
| 131 | + saltLen); | |
| 132 | + } | |
| 133 | + if (trailerField < 0) { | |
| 134 | + throw new IllegalArgumentException("negative trailerField: " + | |
| 135 | + trailerField); | |
| 136 | + } | |
| 137 | + this.mdName = mdName; | |
| 138 | + this.mgfName = mgfName; | |
| 139 | + this.mgfSpec = mgfSpec; | |
| 140 | + this.saltLen = saltLen; | |
| 141 | + this.trailerField = trailerField; | |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 145 | + * Creates a new <code>PSSParameterSpec</code> | |
| 146 | + * using the specified salt length and other default values as | |
| 147 | + * defined in PKCS#1. | |
| 148 | + * | |
| 149 | + * @param saltLen the length of salt in bits to be used in PKCS#1 | |
| 150 | + * PSS encoding. | |
| 151 | + * @exception IllegalArgumentException if <code>saltLen</code> is | |
| 152 | + * less than 0. | |
| 153 | + */ | |
| 154 | + public PSSParameterSpec(int saltLen) { | |
| 155 | + if (saltLen < 0) { | |
| 156 | + throw new IllegalArgumentException("negative saltLen value: " + | |
| 157 | + saltLen); | |
| 158 | + } | |
| 159 | + this.saltLen = saltLen; | |
| 160 | + } | |
| 161 | + | |
| 162 | + /** | |
| 163 | + * Returns the message digest algorithm name. | |
| 164 | + * | |
| 165 | + * @return the message digest algorithm name. | |
| 166 | + * @since 1.5 | |
| 167 | + */ | |
| 168 | + public String getDigestAlgorithm() { | |
| 169 | + return mdName; | |
| 170 | + } | |
| 171 | + | |
| 172 | + /** | |
| 173 | + * Returns the mask generation function algorithm name. | |
| 174 | + * | |
| 175 | + * @return the mask generation function algorithm name. | |
| 176 | + * | |
| 177 | + * @since 1.5 | |
| 178 | + */ | |
| 179 | + public String getMGFAlgorithm() { | |
| 180 | + return mgfName; | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 184 | + * Returns the parameters for the mask generation function. | |
| 185 | + * | |
| 186 | + * @return the parameters for the mask generation function. | |
| 187 | + * @since 1.5 | |
| 188 | + */ | |
| 189 | + public AlgorithmParameterSpec getMGFParameters() { | |
| 190 | + return mgfSpec; | |
| 191 | + } | |
| 192 | + | |
| 193 | + /** | |
| 194 | + * Returns the salt length in bits. | |
| 195 | + * | |
| 196 | + * @return the salt length. | |
| 197 | + */ | |
| 198 | + public int getSaltLength() { | |
| 199 | + return saltLen; | |
| 200 | + } | |
| 201 | + | |
| 202 | + /** | |
| 203 | + * Returns the value for the trailer field, i.e. bc in PKCS#1 v2.1. | |
| 204 | + * | |
| 205 | + * @return the value for the trailer field, i.e. bc in PKCS#1 v2.1. | |
| 206 | + * @since 1.5 | |
| 207 | + */ | |
| 208 | + public int getTrailerField() { | |
| 209 | + return trailerField; | |
| 210 | + } | |
| 211 | +} | |
Binary file not shown.
| @@ -0,0 +1,86 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1999, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | +import java.security.spec.AlgorithmParameterSpec; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * This class specifies the set of parameters used to generate an RSA | |
| 33 | + * key pair. | |
| 34 | + * | |
| 35 | + * @author Jan Luehe | |
| 36 | + * | |
| 37 | + * @see java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec) | |
| 38 | + * | |
| 39 | + * @since 1.3 | |
| 40 | + */ | |
| 41 | + | |
| 42 | +public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec { | |
| 43 | + | |
| 44 | + private int keysize; | |
| 45 | + private BigInteger publicExponent; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * The public-exponent value F0 = 3. | |
| 49 | + */ | |
| 50 | + public static final BigInteger F0 = BigInteger.valueOf(3); | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * The public exponent-value F4 = 65537. | |
| 54 | + */ | |
| 55 | + public static final BigInteger F4 = BigInteger.valueOf(65537); | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * Constructs a new <code>RSAParameterSpec</code> object from the | |
| 59 | + * given keysize and public-exponent value. | |
| 60 | + * | |
| 61 | + * @param keysize the modulus size (specified in number of bits) | |
| 62 | + * @param publicExponent the public exponent | |
| 63 | + */ | |
| 64 | + public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent) { | |
| 65 | + this.keysize = keysize; | |
| 66 | + this.publicExponent = publicExponent; | |
| 67 | + } | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * Returns the keysize. | |
| 71 | + * | |
| 72 | + * @return the keysize. | |
| 73 | + */ | |
| 74 | + public int getKeysize() { | |
| 75 | + return keysize; | |
| 76 | + } | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * Returns the public-exponent value. | |
| 80 | + * | |
| 81 | + * @return the public-exponent value. | |
| 82 | + */ | |
| 83 | + public BigInteger getPublicExponent() { | |
| 84 | + return publicExponent; | |
| 85 | + } | |
| 86 | +} | |
Binary file not shown.
| @@ -0,0 +1,212 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2001, 2003, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This class specifies an RSA multi-prime private key, as defined in the | |
| 32 | + * PKCS#1 v2.1, using the Chinese Remainder Theorem (CRT) information | |
| 33 | + * values for efficiency. | |
| 34 | + * | |
| 35 | + * @author Valerie Peng | |
| 36 | + * | |
| 37 | + * | |
| 38 | + * @see java.security.Key | |
| 39 | + * @see java.security.KeyFactory | |
| 40 | + * @see KeySpec | |
| 41 | + * @see PKCS8EncodedKeySpec | |
| 42 | + * @see RSAPrivateKeySpec | |
| 43 | + * @see RSAPublicKeySpec | |
| 44 | + * @see RSAOtherPrimeInfo | |
| 45 | + * | |
| 46 | + * @since 1.4 | |
| 47 | + */ | |
| 48 | + | |
| 49 | +public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { | |
| 50 | + | |
| 51 | + private final BigInteger publicExponent; | |
| 52 | + private final BigInteger primeP; | |
| 53 | + private final BigInteger primeQ; | |
| 54 | + private final BigInteger primeExponentP; | |
| 55 | + private final BigInteger primeExponentQ; | |
| 56 | + private final BigInteger crtCoefficient; | |
| 57 | + private final RSAOtherPrimeInfo otherPrimeInfo[]; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Creates a new <code>RSAMultiPrimePrivateCrtKeySpec</code> | |
| 61 | + * given the modulus, publicExponent, privateExponent, | |
| 62 | + * primeP, primeQ, primeExponentP, primeExponentQ, | |
| 63 | + * crtCoefficient, and otherPrimeInfo as defined in PKCS#1 v2.1. | |
| 64 | + * | |
| 65 | + * <p>Note that the contents of <code>otherPrimeInfo</code> | |
| 66 | + * are copied to protect against subsequent modification when | |
| 67 | + * constructing this object. | |
| 68 | + * | |
| 69 | + * @param modulus the modulus n. | |
| 70 | + * @param publicExponent the public exponent e. | |
| 71 | + * @param privateExponent the private exponent d. | |
| 72 | + * @param primeP the prime factor p of n. | |
| 73 | + * @param primeQ the prime factor q of n. | |
| 74 | + * @param primeExponentP this is d mod (p-1). | |
| 75 | + * @param primeExponentQ this is d mod (q-1). | |
| 76 | + * @param crtCoefficient the Chinese Remainder Theorem | |
| 77 | + * coefficient q-1 mod p. | |
| 78 | + * @param otherPrimeInfo triplets of the rest of primes, null can be | |
| 79 | + * specified if there are only two prime factors (p and q). | |
| 80 | + * @exception NullPointerException if any of the parameters, i.e. | |
| 81 | + * <code>modulus</code>, | |
| 82 | + * <code>publicExponent</code>, <code>privateExponent</code>, | |
| 83 | + * <code>primeP</code>, <code>primeQ</code>, | |
| 84 | + * <code>primeExponentP</code>, <code>primeExponentQ</code>, | |
| 85 | + * <code>crtCoefficient</code>, is null. | |
| 86 | + * @exception IllegalArgumentException if an empty, i.e. 0-length, | |
| 87 | + * <code>otherPrimeInfo</code> is specified. | |
| 88 | + */ | |
| 89 | + public RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus, | |
| 90 | + BigInteger publicExponent, | |
| 91 | + BigInteger privateExponent, | |
| 92 | + BigInteger primeP, | |
| 93 | + BigInteger primeQ, | |
| 94 | + BigInteger primeExponentP, | |
| 95 | + BigInteger primeExponentQ, | |
| 96 | + BigInteger crtCoefficient, | |
| 97 | + RSAOtherPrimeInfo[] otherPrimeInfo) { | |
| 98 | + super(modulus, privateExponent); | |
| 99 | + if (modulus == null) { | |
| 100 | + throw new NullPointerException("the modulus parameter must be " + | |
| 101 | + "non-null"); | |
| 102 | + } | |
| 103 | + if (publicExponent == null) { | |
| 104 | + throw new NullPointerException("the publicExponent parameter " + | |
| 105 | + "must be non-null"); | |
| 106 | + } | |
| 107 | + if (privateExponent == null) { | |
| 108 | + throw new NullPointerException("the privateExponent parameter " + | |
| 109 | + "must be non-null"); | |
| 110 | + } | |
| 111 | + if (primeP == null) { | |
| 112 | + throw new NullPointerException("the primeP parameter " + | |
| 113 | + "must be non-null"); | |
| 114 | + } | |
| 115 | + if (primeQ == null) { | |
| 116 | + throw new NullPointerException("the primeQ parameter " + | |
| 117 | + "must be non-null"); | |
| 118 | + } | |
| 119 | + if (primeExponentP == null) { | |
| 120 | + throw new NullPointerException("the primeExponentP parameter " + | |
| 121 | + "must be non-null"); | |
| 122 | + } | |
| 123 | + if (primeExponentQ == null) { | |
| 124 | + throw new NullPointerException("the primeExponentQ parameter " + | |
| 125 | + "must be non-null"); | |
| 126 | + } | |
| 127 | + if (crtCoefficient == null) { | |
| 128 | + throw new NullPointerException("the crtCoefficient parameter " + | |
| 129 | + "must be non-null"); | |
| 130 | + } | |
| 131 | + this.publicExponent = publicExponent; | |
| 132 | + this.primeP = primeP; | |
| 133 | + this.primeQ = primeQ; | |
| 134 | + this.primeExponentP = primeExponentP; | |
| 135 | + this.primeExponentQ = primeExponentQ; | |
| 136 | + this.crtCoefficient = crtCoefficient; | |
| 137 | + if (otherPrimeInfo == null) { | |
| 138 | + this.otherPrimeInfo = null; | |
| 139 | + } else if (otherPrimeInfo.length == 0) { | |
| 140 | + throw new IllegalArgumentException("the otherPrimeInfo " + | |
| 141 | + "parameter must not be empty"); | |
| 142 | + } else { | |
| 143 | + this.otherPrimeInfo = otherPrimeInfo.clone(); | |
| 144 | + } | |
| 145 | + } | |
| 146 | + | |
| 147 | + /** | |
| 148 | + * Returns the public exponent. | |
| 149 | + * | |
| 150 | + * @return the public exponent. | |
| 151 | + */ | |
| 152 | + public BigInteger getPublicExponent() { | |
| 153 | + return this.publicExponent; | |
| 154 | + } | |
| 155 | + | |
| 156 | + /** | |
| 157 | + * Returns the primeP. | |
| 158 | + * | |
| 159 | + * @return the primeP. | |
| 160 | + */ | |
| 161 | + public BigInteger getPrimeP() { | |
| 162 | + return this.primeP; | |
| 163 | + } | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * Returns the primeQ. | |
| 167 | + * | |
| 168 | + * @return the primeQ. | |
| 169 | + */ | |
| 170 | + public BigInteger getPrimeQ() { | |
| 171 | + return this.primeQ; | |
| 172 | + } | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * Returns the primeExponentP. | |
| 176 | + * | |
| 177 | + * @return the primeExponentP. | |
| 178 | + */ | |
| 179 | + public BigInteger getPrimeExponentP() { | |
| 180 | + return this.primeExponentP; | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 184 | + * Returns the primeExponentQ. | |
| 185 | + * | |
| 186 | + * @return the primeExponentQ. | |
| 187 | + */ | |
| 188 | + public BigInteger getPrimeExponentQ() { | |
| 189 | + return this.primeExponentQ; | |
| 190 | + } | |
| 191 | + | |
| 192 | + /** | |
| 193 | + * Returns the crtCoefficient. | |
| 194 | + * | |
| 195 | + * @return the crtCoefficient. | |
| 196 | + */ | |
| 197 | + public BigInteger getCrtCoefficient() { | |
| 198 | + return this.crtCoefficient; | |
| 199 | + } | |
| 200 | + | |
| 201 | + /** | |
| 202 | + * Returns a copy of the otherPrimeInfo or null if there are | |
| 203 | + * only two prime factors (p and q). | |
| 204 | + * | |
| 205 | + * @return the otherPrimeInfo. Returns a new array each | |
| 206 | + * time this method is called. | |
| 207 | + */ | |
| 208 | + public RSAOtherPrimeInfo[] getOtherPrimeInfo() { | |
| 209 | + if (otherPrimeInfo == null) return null; | |
| 210 | + return otherPrimeInfo.clone(); | |
| 211 | + } | |
| 212 | +} | |
Binary file not shown.
| @@ -0,0 +1,120 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2001, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This class represents the triplet (prime, exponent, and coefficient) | |
| 32 | + * inside RSA's OtherPrimeInfo structure, as defined in the PKCS#1 v2.1. | |
| 33 | + * The ASN.1 syntax of RSA's OtherPrimeInfo is as follows: | |
| 34 | + * | |
| 35 | + * <pre> | |
| 36 | + * OtherPrimeInfo ::= SEQUENCE { | |
| 37 | + * prime INTEGER, | |
| 38 | + * exponent INTEGER, | |
| 39 | + * coefficient INTEGER | |
| 40 | + * } | |
| 41 | + * | |
| 42 | + * </pre> | |
| 43 | + * | |
| 44 | + * @author Valerie Peng | |
| 45 | + * | |
| 46 | + * | |
| 47 | + * @see RSAPrivateCrtKeySpec | |
| 48 | + * @see java.security.interfaces.RSAMultiPrimePrivateCrtKey | |
| 49 | + * | |
| 50 | + * @since 1.4 | |
| 51 | + */ | |
| 52 | + | |
| 53 | +public class RSAOtherPrimeInfo { | |
| 54 | + | |
| 55 | + private BigInteger prime; | |
| 56 | + private BigInteger primeExponent; | |
| 57 | + private BigInteger crtCoefficient; | |
| 58 | + | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Creates a new <code>RSAOtherPrimeInfo</code> | |
| 62 | + * given the prime, primeExponent, and | |
| 63 | + * crtCoefficient as defined in PKCS#1. | |
| 64 | + * | |
| 65 | + * @param prime the prime factor of n. | |
| 66 | + * @param primeExponent the exponent. | |
| 67 | + * @param crtCoefficient the Chinese Remainder Theorem | |
| 68 | + * coefficient. | |
| 69 | + * @exception NullPointerException if any of the parameters, i.e. | |
| 70 | + * <code>prime</code>, <code>primeExponent</code>, | |
| 71 | + * <code>crtCoefficient</code>, is null. | |
| 72 | + * | |
| 73 | + */ | |
| 74 | + public RSAOtherPrimeInfo(BigInteger prime, | |
| 75 | + BigInteger primeExponent, | |
| 76 | + BigInteger crtCoefficient) { | |
| 77 | + if (prime == null) { | |
| 78 | + throw new NullPointerException("the prime parameter must be " + | |
| 79 | + "non-null"); | |
| 80 | + } | |
| 81 | + if (primeExponent == null) { | |
| 82 | + throw new NullPointerException("the primeExponent parameter " + | |
| 83 | + "must be non-null"); | |
| 84 | + } | |
| 85 | + if (crtCoefficient == null) { | |
| 86 | + throw new NullPointerException("the crtCoefficient parameter " + | |
| 87 | + "must be non-null"); | |
| 88 | + } | |
| 89 | + this.prime = prime; | |
| 90 | + this.primeExponent = primeExponent; | |
| 91 | + this.crtCoefficient = crtCoefficient; | |
| 92 | + } | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * Returns the prime. | |
| 96 | + * | |
| 97 | + * @return the prime. | |
| 98 | + */ | |
| 99 | + public final BigInteger getPrime() { | |
| 100 | + return this.prime; | |
| 101 | + } | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * Returns the prime's exponent. | |
| 105 | + * | |
| 106 | + * @return the primeExponent. | |
| 107 | + */ | |
| 108 | + public final BigInteger getExponent() { | |
| 109 | + return this.primeExponent; | |
| 110 | + } | |
| 111 | + | |
| 112 | + /** | |
| 113 | + * Returns the prime's crtCoefficient. | |
| 114 | + * | |
| 115 | + * @return the crtCoefficient. | |
| 116 | + */ | |
| 117 | + public final BigInteger getCrtCoefficient() { | |
| 118 | + return this.crtCoefficient; | |
| 119 | + } | |
| 120 | +} | |
Binary file not shown.
| @@ -0,0 +1,143 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1998, 2003, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This class specifies an RSA private key, as defined in the PKCS#1 | |
| 32 | + * standard, using the Chinese Remainder Theorem (CRT) information values for | |
| 33 | + * efficiency. | |
| 34 | + * | |
| 35 | + * @author Jan Luehe | |
| 36 | + * | |
| 37 | + * | |
| 38 | + * @see java.security.Key | |
| 39 | + * @see java.security.KeyFactory | |
| 40 | + * @see KeySpec | |
| 41 | + * @see PKCS8EncodedKeySpec | |
| 42 | + * @see RSAPrivateKeySpec | |
| 43 | + * @see RSAPublicKeySpec | |
| 44 | + */ | |
| 45 | + | |
| 46 | +public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { | |
| 47 | + | |
| 48 | + private final BigInteger publicExponent; | |
| 49 | + private final BigInteger primeP; | |
| 50 | + private final BigInteger primeQ; | |
| 51 | + private final BigInteger primeExponentP; | |
| 52 | + private final BigInteger primeExponentQ; | |
| 53 | + private final BigInteger crtCoefficient; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * Creates a new <code>RSAPrivateCrtKeySpec</code> | |
| 59 | + * given the modulus, publicExponent, privateExponent, | |
| 60 | + * primeP, primeQ, primeExponentP, primeExponentQ, and | |
| 61 | + * crtCoefficient as defined in PKCS#1. | |
| 62 | + * | |
| 63 | + * @param modulus the modulus n | |
| 64 | + * @param publicExponent the public exponent e | |
| 65 | + * @param privateExponent the private exponent d | |
| 66 | + * @param primeP the prime factor p of n | |
| 67 | + * @param primeQ the prime factor q of n | |
| 68 | + * @param primeExponentP this is d mod (p-1) | |
| 69 | + * @param primeExponentQ this is d mod (q-1) | |
| 70 | + * @param crtCoefficient the Chinese Remainder Theorem | |
| 71 | + * coefficient q-1 mod p | |
| 72 | + */ | |
| 73 | + public RSAPrivateCrtKeySpec(BigInteger modulus, | |
| 74 | + BigInteger publicExponent, | |
| 75 | + BigInteger privateExponent, | |
| 76 | + BigInteger primeP, | |
| 77 | + BigInteger primeQ, | |
| 78 | + BigInteger primeExponentP, | |
| 79 | + BigInteger primeExponentQ, | |
| 80 | + BigInteger crtCoefficient) { | |
| 81 | + super(modulus, privateExponent); | |
| 82 | + this.publicExponent = publicExponent; | |
| 83 | + this.primeP = primeP; | |
| 84 | + this.primeQ = primeQ; | |
| 85 | + this.primeExponentP = primeExponentP; | |
| 86 | + this.primeExponentQ = primeExponentQ; | |
| 87 | + this.crtCoefficient = crtCoefficient; | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * Returns the public exponent. | |
| 92 | + * | |
| 93 | + * @return the public exponent | |
| 94 | + */ | |
| 95 | + public BigInteger getPublicExponent() { | |
| 96 | + return this.publicExponent; | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * Returns the primeP. | |
| 101 | + | |
| 102 | + * @return the primeP | |
| 103 | + */ | |
| 104 | + public BigInteger getPrimeP() { | |
| 105 | + return this.primeP; | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * Returns the primeQ. | |
| 110 | + * | |
| 111 | + * @return the primeQ | |
| 112 | + */ | |
| 113 | + public BigInteger getPrimeQ() { | |
| 114 | + return this.primeQ; | |
| 115 | + } | |
| 116 | + | |
| 117 | + /** | |
| 118 | + * Returns the primeExponentP. | |
| 119 | + * | |
| 120 | + * @return the primeExponentP | |
| 121 | + */ | |
| 122 | + public BigInteger getPrimeExponentP() { | |
| 123 | + return this.primeExponentP; | |
| 124 | + } | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * Returns the primeExponentQ. | |
| 128 | + * | |
| 129 | + * @return the primeExponentQ | |
| 130 | + */ | |
| 131 | + public BigInteger getPrimeExponentQ() { | |
| 132 | + return this.primeExponentQ; | |
| 133 | + } | |
| 134 | + | |
| 135 | + /** | |
| 136 | + * Returns the crtCoefficient. | |
| 137 | + * | |
| 138 | + * @return the crtCoefficient | |
| 139 | + */ | |
| 140 | + public BigInteger getCrtCoefficient() { | |
| 141 | + return this.crtCoefficient; | |
| 142 | + } | |
| 143 | +} | |
Binary file not shown.
| @@ -0,0 +1,77 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1998, 2001, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This class specifies an RSA private key. | |
| 32 | + * | |
| 33 | + * @author Jan Luehe | |
| 34 | + * | |
| 35 | + * | |
| 36 | + * @see java.security.Key | |
| 37 | + * @see java.security.KeyFactory | |
| 38 | + * @see KeySpec | |
| 39 | + * @see PKCS8EncodedKeySpec | |
| 40 | + * @see RSAPublicKeySpec | |
| 41 | + * @see RSAPrivateCrtKeySpec | |
| 42 | + */ | |
| 43 | + | |
| 44 | +public class RSAPrivateKeySpec implements KeySpec { | |
| 45 | + | |
| 46 | + private BigInteger modulus; | |
| 47 | + private BigInteger privateExponent; | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * Creates a new RSAPrivateKeySpec. | |
| 51 | + * | |
| 52 | + * @param modulus the modulus | |
| 53 | + * @param privateExponent the private exponent | |
| 54 | + */ | |
| 55 | + public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent) { | |
| 56 | + this.modulus = modulus; | |
| 57 | + this.privateExponent = privateExponent; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Returns the modulus. | |
| 62 | + * | |
| 63 | + * @return the modulus | |
| 64 | + */ | |
| 65 | + public BigInteger getModulus() { | |
| 66 | + return this.modulus; | |
| 67 | + } | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * Returns the private exponent. | |
| 71 | + * | |
| 72 | + * @return the private exponent | |
| 73 | + */ | |
| 74 | + public BigInteger getPrivateExponent() { | |
| 75 | + return this.privateExponent; | |
| 76 | + } | |
| 77 | +} | |
Binary file not shown.
| @@ -0,0 +1,77 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1998, 2001, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +import java.math.BigInteger; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * This class specifies an RSA public key. | |
| 32 | + * | |
| 33 | + * @author Jan Luehe | |
| 34 | + * | |
| 35 | + * | |
| 36 | + * @see java.security.Key | |
| 37 | + * @see java.security.KeyFactory | |
| 38 | + * @see KeySpec | |
| 39 | + * @see X509EncodedKeySpec | |
| 40 | + * @see RSAPrivateKeySpec | |
| 41 | + * @see RSAPrivateCrtKeySpec | |
| 42 | + */ | |
| 43 | + | |
| 44 | +public class RSAPublicKeySpec implements KeySpec { | |
| 45 | + | |
| 46 | + private BigInteger modulus; | |
| 47 | + private BigInteger publicExponent; | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * Creates a new RSAPublicKeySpec. | |
| 51 | + * | |
| 52 | + * @param modulus the modulus | |
| 53 | + * @param publicExponent the public exponent | |
| 54 | + */ | |
| 55 | + public RSAPublicKeySpec(BigInteger modulus, BigInteger publicExponent) { | |
| 56 | + this.modulus = modulus; | |
| 57 | + this.publicExponent = publicExponent; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Returns the modulus. | |
| 62 | + * | |
| 63 | + * @return the modulus | |
| 64 | + */ | |
| 65 | + public BigInteger getModulus() { | |
| 66 | + return this.modulus; | |
| 67 | + } | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * Returns the public exponent. | |
| 71 | + * | |
| 72 | + * @return the public exponent | |
| 73 | + */ | |
| 74 | + public BigInteger getPublicExponent() { | |
| 75 | + return this.publicExponent; | |
| 76 | + } | |
| 77 | +} | |
Binary file not shown.
| @@ -0,0 +1,86 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2005, 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 | + | |
| 26 | +package java.security.spec; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * This class represents the ASN.1 encoding of a public key, | |
| 30 | + * encoded according to the ASN.1 type <code>SubjectPublicKeyInfo</code>. | |
| 31 | + * The <code>SubjectPublicKeyInfo</code> syntax is defined in the X.509 | |
| 32 | + * standard as follows: | |
| 33 | + * | |
| 34 | + * <pre> | |
| 35 | + * SubjectPublicKeyInfo ::= SEQUENCE { | |
| 36 | + * algorithm AlgorithmIdentifier, | |
| 37 | + * subjectPublicKey BIT STRING } | |
| 38 | + * </pre> | |
| 39 | + * | |
| 40 | + * @author Jan Luehe | |
| 41 | + * | |
| 42 | + * | |
| 43 | + * @see java.security.Key | |
| 44 | + * @see java.security.KeyFactory | |
| 45 | + * @see KeySpec | |
| 46 | + * @see EncodedKeySpec | |
| 47 | + * @see PKCS8EncodedKeySpec | |
| 48 | + * | |
| 49 | + * @since 1.2 | |
| 50 | + */ | |
| 51 | + | |
| 52 | +public class X509EncodedKeySpec extends EncodedKeySpec { | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Creates a new X509EncodedKeySpec with the given encoded key. | |
| 56 | + * | |
| 57 | + * @param encodedKey the key, which is assumed to be | |
| 58 | + * encoded according to the X.509 standard. The contents of the | |
| 59 | + * array are copied to protect against subsequent modification. | |
| 60 | + * @exception NullPointerException if <code>encodedKey</code> | |
| 61 | + * is null. | |
| 62 | + */ | |
| 63 | + public X509EncodedKeySpec(byte[] encodedKey) { | |
| 64 | + super(encodedKey); | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Returns the key bytes, encoded according to the X.509 standard. | |
| 69 | + * | |
| 70 | + * @return the X.509 encoding of the key. Returns a new array | |
| 71 | + * each time this method is called. | |
| 72 | + */ | |
| 73 | + public byte[] getEncoded() { | |
| 74 | + return super.getEncoded(); | |
| 75 | + } | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * Returns the name of the encoding format associated with this | |
| 79 | + * key specification. | |
| 80 | + * | |
| 81 | + * @return the string <code>"X.509"</code>. | |
| 82 | + */ | |
| 83 | + public final String getFormat() { | |
| 84 | + return "X.509"; | |
| 85 | + } | |
| 86 | +} | |
| @@ -0,0 +1,34 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + AlgorithmParameterSpec.dis\ | |
| 5 | + DSAParameterSpec.dis\ | |
| 6 | + DSAPrivateKeySpec.dis\ | |
| 7 | + DSAPublicKeySpec.dis\ | |
| 8 | + ECField.dis\ | |
| 9 | + ECFieldF2m.dis\ | |
| 10 | + ECFieldFp.dis\ | |
| 11 | + ECGenParameterSpec.dis\ | |
| 12 | + ECParameterSpec.dis\ | |
| 13 | + ECPoint.dis\ | |
| 14 | + ECPrivateKeySpec.dis\ | |
| 15 | + ECPublicKeySpec.dis\ | |
| 16 | + EllipticCurve.dis\ | |
| 17 | + EncodedKeySpec.dis\ | |
| 18 | + InvalidKeySpecException.dis\ | |
| 19 | + InvalidParameterSpecException.dis\ | |
| 20 | + KeySpec.dis\ | |
| 21 | + MGF1ParameterSpec.dis\ | |
| 22 | + PKCS8EncodedKeySpec.dis\ | |
| 23 | + PSSParameterSpec.dis\ | |
| 24 | + RSAKeyGenParameterSpec.dis\ | |
| 25 | + RSAMultiPrimePrivateCrtKeySpec.dis\ | |
| 26 | + RSAOtherPrimeInfo.dis\ | |
| 27 | + RSAPrivateCrtKeySpec.dis\ | |
| 28 | + RSAPrivateKeySpec.dis\ | |
| 29 | + RSAPublicKeySpec.dis\ | |
| 30 | + X509EncodedKeySpec.dis\ | |
| 31 | + | |
| 32 | +DISBIN=$ROOT/java/dis/java/java/java/security/spec | |
| 33 | + | |
| 34 | +<$ROOT/mkfiles/mkjava | |
| @@ -0,0 +1,78 @@ | ||
| 1 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> | |
| 2 | +<html> | |
| 3 | +<head> | |
| 4 | +<!-- | |
| 5 | +Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 6 | +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 7 | + | |
| 8 | +This code is free software; you can redistribute it and/or modify it | |
| 9 | +under the terms of the GNU General Public License version 2 only, as | |
| 10 | +published by the Free Software Foundation. Oracle designates this | |
| 11 | +particular file as subject to the "Classpath" exception as provided | |
| 12 | +by Oracle in the LICENSE file that accompanied this code. | |
| 13 | + | |
| 14 | +This code is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 16 | +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 17 | +version 2 for more details (a copy is included in the LICENSE file that | |
| 18 | +accompanied this code). | |
| 19 | + | |
| 20 | +You should have received a copy of the GNU General Public License version | |
| 21 | +2 along with this work; if not, write to the Free Software Foundation, | |
| 22 | +Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 23 | + | |
| 24 | +Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 25 | +or visit www.oracle.com if you need additional information or have any | |
| 26 | +questions. | |
| 27 | +--> | |
| 28 | + | |
| 29 | +</head> | |
| 30 | +<body bgcolor="white"> | |
| 31 | + | |
| 32 | +Provides classes and interfaces for key specifications and algorithm | |
| 33 | +parameter specifications. | |
| 34 | + | |
| 35 | +<p>A key specification is a transparent representation of the key material | |
| 36 | +that constitutes a key. A key may be specified in an algorithm-specific | |
| 37 | +way, or in an algorithm-independent encoding format (such as ASN.1). | |
| 38 | +This package contains key specifications for DSA public and private keys, | |
| 39 | +RSA public and private keys, PKCS #8 private keys in DER-encoded format, | |
| 40 | +and X.509 public and private keys in DER-encoded format. | |
| 41 | + | |
| 42 | +<p>An algorithm parameter specification is a transparent representation | |
| 43 | +of the sets of parameters used with an algorithm. This package contains | |
| 44 | +an algorithm parameter specification for parameters used with the | |
| 45 | +DSA algorithm. | |
| 46 | + | |
| 47 | +<h2>Package Specification</h2> | |
| 48 | + | |
| 49 | +<ul> | |
| 50 | + <li>PKCS #1: RSA Encryption Standard, Version 1.5, November 1993</li> | |
| 51 | + <li>PKCS #8: Private-Key Information Syntax Standard, | |
| 52 | + Version 1.2, November 1993</li> | |
| 53 | + <li>Federal Information Processing Standards Publication (FIPS PUB) 186: | |
| 54 | + Digital Signature Standard (DSS)</li> | |
| 55 | +</ul> | |
| 56 | + | |
| 57 | +<h2>Related Documentation</h2> | |
| 58 | + | |
| 59 | +For documentation that includes information about algorithm parameter | |
| 60 | +and key specifications, please see: | |
| 61 | +<ul> | |
| 62 | + <li> | |
| 63 | + <a href= | |
| 64 | + "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html"> | |
| 65 | + <b>Java<FONT SIZE=-2><SUP>TM</SUP></FONT> | |
| 66 | + Cryptography Architecture API Specification and Reference | |
| 67 | + </b></a></li> | |
| 68 | + <li> | |
| 69 | + <a href= | |
| 70 | + "{@docRoot}/../technotes/guides/security/crypto/HowToImplAProvider.html"> | |
| 71 | + <b>How to Implement a Provider for the | |
| 72 | + Java<FONT SIZE=-2><SUP>TM</SUP></FONT> Cryptography Architecture | |
| 73 | + </b></a></li> | |
| 74 | +</ul> | |
| 75 | + | |
| 76 | +@since 1.2 | |
| 77 | +</body> | |
| 78 | +</html> | |