From 1516d54906fd413c02328d8bb21a6af38dfd4d07 Mon Sep 17 00:00:00 2001 From: "Aaron M. Renn" Date: Fri, 21 Aug 1998 02:09:40 +0000 Subject: Initial Checkin --- java/security/interfaces/DSAKey.java | 44 +++++++++++ java/security/interfaces/DSAKeyPairGenerator.java | 75 ++++++++++++++++++ java/security/interfaces/DSAParams.java | 66 ++++++++++++++++ java/security/interfaces/DSAPrivateKey.java | 61 ++++++++++++++ java/security/interfaces/DSAPublicKey.java | 61 ++++++++++++++ java/security/interfaces/Makefile.am | 8 ++ java/security/interfaces/RSAPrivateCrtKey.java | 96 +++++++++++++++++++++++ java/security/interfaces/RSAPrivateKey.java | 56 +++++++++++++ java/security/interfaces/RSAPublicKey.java | 56 +++++++++++++ 9 files changed, 523 insertions(+) create mode 100644 java/security/interfaces/DSAKey.java create mode 100644 java/security/interfaces/DSAKeyPairGenerator.java create mode 100644 java/security/interfaces/DSAParams.java create mode 100644 java/security/interfaces/DSAPrivateKey.java create mode 100644 java/security/interfaces/DSAPublicKey.java create mode 100644 java/security/interfaces/Makefile.am create mode 100644 java/security/interfaces/RSAPrivateCrtKey.java create mode 100644 java/security/interfaces/RSAPrivateKey.java create mode 100644 java/security/interfaces/RSAPublicKey.java diff --git a/java/security/interfaces/DSAKey.java b/java/security/interfaces/DSAKey.java new file mode 100644 index 000000000..bcfb78a4d --- /dev/null +++ b/java/security/interfaces/DSAKey.java @@ -0,0 +1,44 @@ +/************************************************************************* +/* DSAKey.java -- Interface for Digital Signature Algorith key +/* +/* Copyright (c) 1998 Free Software Foundation, Inc. +/* Written by Aaron M. Renn (arenn@urbanophile.com) +/* +/* This library is free software; you can redistribute it and/or modify +/* it under the terms of the GNU Library General Public License as published +/* by the Free Software Foundation, either version 2 of the License, or +/* (at your option) any later verion. +/* +/* This library is distributed in the hope that it will be useful, but +/* WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU Library General Public License for more details. +/* +/* You should have received a copy of the GNU Library General Public License +/* along with this library; if not, write to the Free Software Foundation +/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA +/*************************************************************************/ + +package java.security.interfaces; + +/** + * This interface is implemented by a class to return the parameters + * of a Digital Signature Algorithm (DSA) public or private key. + * + * @version 0.0 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface DSAKey +{ + +/** + * This method returns non-secret parameters of the DSA key + * + * @return The DSA parameters + */ +public abstract DSAParams +getParams(); + +} // interface DSAKey + diff --git a/java/security/interfaces/DSAKeyPairGenerator.java b/java/security/interfaces/DSAKeyPairGenerator.java new file mode 100644 index 000000000..d8dc26eea --- /dev/null +++ b/java/security/interfaces/DSAKeyPairGenerator.java @@ -0,0 +1,75 @@ +/************************************************************************* +/* DSAKeyPairGenerator.java -- Initialize a DSA key generator +/* +/* Copyright (c) 1998 Free Software Foundation, Inc. +/* Written by Aaron M. Renn (arenn@urbanophile.com) +/* +/* This library is free software; you can redistribute it and/or modify +/* it under the terms of the GNU Library General Public License as published +/* by the Free Software Foundation, either version 2 of the License, or +/* (at your option) any later verion. +/* +/* This library is distributed in the hope that it will be useful, but +/* WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU Library General Public License for more details. +/* +/* You should have received a copy of the GNU Library General Public License +/* along with this library; if not, write to the Free Software Foundation +/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA +/*************************************************************************/ + +package java.security.interfaces; + +import java.security.SecureRandom; +import java.security.InvalidParameterException; + +/** + * This interface contains methods for intializing a Digital Signature + * Algorithm key generation engine. The initialize methods may be called + * any number of times. If no explicity initialization call is made, then + * the engine defaults to generating 1024-bit keys using pre-calculated + * base, prime, and subprime values. + * + * @version 0.0 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface DSAKeyPairGenerator +{ + +/** + * Initializes the key generator with the specified DSA parameters and + * random bit source + * + * @param params The DSA parameters to use + * @param random The random bit source to use + * + * @exception InvalidParameterException If the parameters passed are not valid + */ +public abstract void +initialize(DSAParams params, SecureRandom random) throws InvalidParameterException; + +/*************************************************************************/ + +/** + * Initializes the key generator to a give modulus. If the genParams + * value is true then new base, prime, and subprime values + * will be generated for the given modulus. If not, the pre-calculated + * values will be used. If no pre-calculated values exist for the specified + * modulus, an exception will be thrown. It is guaranteed that there will + * always be pre-calculated values for all modulus values between 512 and + * 1024 bits inclusives. + * + * @param modlen The modulus length + * @param genParams true to generate new DSA parameters, false otherwise + * @param random The random bit source to use + * + * @exception InvalidParameterException If a parameter is invalid + */ +public abstract void +initialize(int modlen, boolean genParams, SecureRandom random) + throws InvalidParameterException; + +} // interface DSAKeyPairGenerator + diff --git a/java/security/interfaces/DSAParams.java b/java/security/interfaces/DSAParams.java new file mode 100644 index 000000000..13edd2062 --- /dev/null +++ b/java/security/interfaces/DSAParams.java @@ -0,0 +1,66 @@ +/************************************************************************* +/* DSAParams.java -- Digital Signature Algorithm parameter access +/* +/* Copyright (c) 1998 Free Software Foundation, Inc. +/* Written by Aaron M. Renn (arenn@urbanophile.com) +/* +/* This library is free software; you can redistribute it and/or modify +/* it under the terms of the GNU Library General Public License as published +/* by the Free Software Foundation, either version 2 of the License, or +/* (at your option) any later verion. +/* +/* This library is distributed in the hope that it will be useful, but +/* WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU Library General Public License for more details. +/* +/* You should have received a copy of the GNU Library General Public License +/* along with this library; if not, write to the Free Software Foundation +/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA +/*************************************************************************/ + +package java.security.interfaces; + +import java.math.BigInteger; + +/** + * This interface allows the Digital Signature Algorithm (DSA) parameters + * to be queried. + * + * @version 0.0 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface DSAParams +{ + +/** + * Returns the base, or 'g' value + * + * @return The DSA base value + */ +public abstract BigInteger +getG(); + +/*************************************************************************/ + +/** + * Returns the prime, or 'p' value + * + * @return The DSA prime value + */ +public abstract BigInteger +getP(); + +/*************************************************************************/ + +/** + * Returns the subprime, or 'q' value + * + * @return The DSA subprime value + */ +public abstract BigInteger +getQ(); + +} // interface DSAParams + diff --git a/java/security/interfaces/DSAPrivateKey.java b/java/security/interfaces/DSAPrivateKey.java new file mode 100644 index 000000000..f3b913cf4 --- /dev/null +++ b/java/security/interfaces/DSAPrivateKey.java @@ -0,0 +1,61 @@ +/************************************************************************* +/* DSAPrivateKey.java -- A Digital Signature Algorithm private key +/* +/* Copyright (c) 1998 Free Software Foundation, Inc. +/* Written by Aaron M. Renn (arenn@urbanophile.com) +/* +/* This library is free software; you can redistribute it and/or modify +/* it under the terms of the GNU Library General Public License as published +/* by the Free Software Foundation, either version 2 of the License, or +/* (at your option) any later verion. +/* +/* This library is distributed in the hope that it will be useful, but +/* WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU Library General Public License for more details. +/* +/* You should have received a copy of the GNU Library General Public License +/* along with this library; if not, write to the Free Software Foundation +/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA +/*************************************************************************/ + +package java.security.interfaces; + +import java.security.PrivateKey; +import java.math.BigInteger; + +/** + * This interface models a Digital Signature Algorithm (DSA) private key + * + * @version 0.0 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface DSAPrivateKey extends DSAKey, PrivateKey +{ + +/*************************************************************************/ + +/** + * Static Variables + */ + +/** + * This is the serialization UID for this interface + */ +public static final long serialVersionUID = 0L; + +/*************************************************************************/ + +/** + * Instance Methods + */ + +/** + * This method returns the value of the DSA private key + */ +public abstract BigInteger +getX(); + +} // interface DSAPrivateKey + diff --git a/java/security/interfaces/DSAPublicKey.java b/java/security/interfaces/DSAPublicKey.java new file mode 100644 index 000000000..0218878da --- /dev/null +++ b/java/security/interfaces/DSAPublicKey.java @@ -0,0 +1,61 @@ +/************************************************************************* +/* DSAPublicKey.java -- A Digital Signature Algorithm public key +/* +/* Copyright (c) 1998 Free Software Foundation, Inc. +/* Written by Aaron M. Renn (arenn@urbanophile.com) +/* +/* This library is free software; you can redistribute it and/or modify +/* it under the terms of the GNU Library General Public License as published +/* by the Free Software Foundation, either version 2 of the License, or +/* (at your option) any later verion. +/* +/* This library is distributed in the hope that it will be useful, but +/* WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU Library General Public License for more details. +/* +/* You should have received a copy of the GNU Library General Public License +/* along with this library; if not, write to the Free Software Foundation +/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA +/*************************************************************************/ + +package java.security.interfaces; + +import java.security.PublicKey; +import java.math.BigInteger; + +/** + * This interface models a Digital Signature Algorithm (DSA) public key + * + * @version 0.0 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface DSAPublicKey extends DSAKey, PublicKey +{ + +/*************************************************************************/ + +/** + * Static Variables + */ + +/** + * This is the serialization UID for this interface + */ +public static final long serialVersionUID = 0L; + +/*************************************************************************/ + +/** + * Instance Methods + */ + +/** + * This method returns the value of the DSA public key + */ +public abstract BigInteger +getY(); + +} // interface DSAPublicKey + diff --git a/java/security/interfaces/Makefile.am b/java/security/interfaces/Makefile.am new file mode 100644 index 000000000..be7c2ff15 --- /dev/null +++ b/java/security/interfaces/Makefile.am @@ -0,0 +1,8 @@ +## Input file for automake to generate the Makefile.in used by configure + +javasecintrdir = $(datadir)/java/security/interfaces + +javasecintr_JAVA = DSAKey.java DSAKeyPairGenerator.java DSAParams.java \ + DSAPrivateKey.java DSAPublicKey.java \ + RSAPrivateCrtKey.java RSAPrivateKey.java RSAPublicKey.java + diff --git a/java/security/interfaces/RSAPrivateCrtKey.java b/java/security/interfaces/RSAPrivateCrtKey.java new file mode 100644 index 000000000..8e55ca8b6 --- /dev/null +++ b/java/security/interfaces/RSAPrivateCrtKey.java @@ -0,0 +1,96 @@ +/************************************************************************* +/* RSAPrivateCrtKey.java -- An RSA private key in CRT format +/* +/* Copyright (c) 1998 Free Software Foundation, Inc. +/* Written by Aaron M. Renn (arenn@urbanophile.com) +/* +/* This library is free software; you can redistribute it and/or modify +/* it under the terms of the GNU Library General Public License as published +/* by the Free Software Foundation, either version 2 of the License, or +/* (at your option) any later verion. +/* +/* This library is distributed in the hope that it will be useful, but +/* WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU Library General Public License for more details. +/* +/* You should have received a copy of the GNU Library General Public License +/* along with this library; if not, write to the Free Software Foundation +/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA +/*************************************************************************/ + +package java.security.interfaces; + +import java.math.BigInteger; + +/** + * This interface provides access to information about an RSA private + * key in Chinese Remainder Theorem (CRT) format. + * + * @version 0.0 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface RSAPrivateCrtKey extends RSAPrivateKey +{ + +/** + * Returns the public exponent for this key + * + * @return The public exponent for this key + */ +public abstract BigInteger +getPublicExponent(); + +/*************************************************************************/ + +/** + * Returns the primeP value + * + * @return The primeP value + */ +public abstract BigInteger +getPrimeP(); + +/*************************************************************************/ + +/** + * Returns the primeQ value + * + * @return The primeQ value + */ +public abstract BigInteger +getPrimeQ(); + +/*************************************************************************/ + +/** + * Returns the primeExponentP + * + * @return The primeExponentP + */ +public abstract BigInteger +getPrimeExponentP(); + +/*************************************************************************/ + +/** + * Returns the primeExponentQ + * + * @return The primeExponentQ + */ +public abstract BigInteger +getPrimeExponentQ(); + +/*************************************************************************/ + +/** + * Returns the CRT coefficient + * + * @return The CRT coefficient + */ +public abstract BigInteger +getCrtCoefficient(); + +} // interface RSAPrivateCrtKey + diff --git a/java/security/interfaces/RSAPrivateKey.java b/java/security/interfaces/RSAPrivateKey.java new file mode 100644 index 000000000..3d36a1812 --- /dev/null +++ b/java/security/interfaces/RSAPrivateKey.java @@ -0,0 +1,56 @@ +/************************************************************************* +/* RSAPrivateKey.java -- An RSA private key +/* +/* Copyright (c) 1998 Free Software Foundation, Inc. +/* Written by Aaron M. Renn (arenn@urbanophile.com) +/* +/* This library is free software; you can redistribute it and/or modify +/* it under the terms of the GNU Library General Public License as published +/* by the Free Software Foundation, either version 2 of the License, or +/* (at your option) any later verion. +/* +/* This library is distributed in the hope that it will be useful, but +/* WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU Library General Public License for more details. +/* +/* You should have received a copy of the GNU Library General Public License +/* along with this library; if not, write to the Free Software Foundation +/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA +/*************************************************************************/ + +package java.security.interfaces; + +import java.security.PrivateKey; +import java.math.BigInteger; + +/** + * This interface provides access to information about an RSA private key. + * + * @version 0.0 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface RSAPrivateKey extends PrivateKey +{ + +/** + * Returns the modulus of the private key + * + * @return The modulus of the private key + */ +public abstract BigInteger +getModulus(); + +/*************************************************************************/ + +/** + * Returns the private exponent value for this key + * + * @return The private exponent value for this key + */ +public abstract BigInteger +getPrivateExponent(); + +} // interface RSAPrivateKey + diff --git a/java/security/interfaces/RSAPublicKey.java b/java/security/interfaces/RSAPublicKey.java new file mode 100644 index 000000000..e3756dcac --- /dev/null +++ b/java/security/interfaces/RSAPublicKey.java @@ -0,0 +1,56 @@ +/************************************************************************* +/* RSAPublicKey.java -- An RSA public key +/* +/* Copyright (c) 1998 Free Software Foundation, Inc. +/* Written by Aaron M. Renn (arenn@urbanophile.com) +/* +/* This library is free software; you can redistribute it and/or modify +/* it under the terms of the GNU Library General Public License as published +/* by the Free Software Foundation, either version 2 of the License, or +/* (at your option) any later verion. +/* +/* This library is distributed in the hope that it will be useful, but +/* WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU Library General Public License for more details. +/* +/* You should have received a copy of the GNU Library General Public License +/* along with this library; if not, write to the Free Software Foundation +/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA +/*************************************************************************/ + +package java.security.interfaces; + +import java.security.PublicKey; +import java.math.BigInteger; + +/** + * This interface provides access to information about an RSA public key. + * + * @version 0.0 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface RSAPublicKey extends PublicKey +{ + +/** + * Returns the modulus of the public key + * + * @return The modulus of the public key + */ +public abstract BigInteger +getModulus(); + +/*************************************************************************/ + +/** + * Returns the public exponent value for this key + * + * @return The public exponent value for this key + */ +public abstract BigInteger +getPublicExponent(); + +} // interface RSAPublicKey + -- cgit v1.2.1