diff options
| author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-10 21:46:48 +0000 |
|---|---|---|
| committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-10 21:46:48 +0000 |
| commit | ce57ab760f69de6db452def7ffbf5b114a2d8694 (patch) | |
| tree | ea38c56431c5d4528fb54254c3f8e50f517bede3 /libjava/classpath/gnu/javax/crypto/jce/cipher | |
| parent | 50996fe55769882de3f410896032c887f0ff0d04 (diff) | |
| download | ppe42-gcc-ce57ab760f69de6db452def7ffbf5b114a2d8694.tar.gz ppe42-gcc-ce57ab760f69de6db452def7ffbf5b114a2d8694.zip | |
Imported GNU Classpath 0.90
* scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore.
* gnu/classpath/jdwp/VMFrame.java (SIZE): New constant.
* java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5.
* java/lang/Math.java: New override file.
* java/lang/Character.java: Merged from Classpath.
(start, end): Now 'int's.
(canonicalName): New field.
(CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants.
(UnicodeBlock): Added argument.
(of): New overload.
(forName): New method.
Updated unicode blocks.
(sets): Updated.
* sources.am: Regenerated.
* Makefile.in: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111942 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/javax/crypto/jce/cipher')
15 files changed, 2829 insertions, 0 deletions
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java new file mode 100644 index 00000000000..ba7466fc39c --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java @@ -0,0 +1,104 @@ +/* AESSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; +import gnu.javax.crypto.jce.spec.BlockCipherParameterSpec; + +import java.security.AlgorithmParameters; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.SecureRandom; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.InvalidParameterSpecException; + +/** + * The implementation of the AES <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class AESSpi extends CipherAdapter +{ + + // Constructors. + // ----------------------------------------------------------------------- + + public AESSpi() + { + super(Registry.AES_CIPHER, 16); + } + + // Methods from CipherAdapter + // ----------------------------------------------------------------------- + + protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, + SecureRandom random) throws InvalidKeyException, + InvalidAlgorithmParameterException + { + if (params instanceof BlockCipherParameterSpec) + { + if (((BlockCipherParameterSpec) params).getBlockSize() != 16) + { + throw new InvalidAlgorithmParameterException( + "AES block size must be 16 bytes"); + } + } + super.engineInit(opmode, key, params, random); + } + + protected void engineInit(int opmode, Key key, AlgorithmParameters params, + SecureRandom random) throws InvalidKeyException, + InvalidAlgorithmParameterException + { + AlgorithmParameterSpec spec = null; + try + { + if (params != null) + { + spec = params.getParameterSpec(BlockCipherParameterSpec.class); + } + } + catch (InvalidParameterSpecException ipse) + { + } + engineInit(opmode, key, spec, random); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java new file mode 100644 index 00000000000..8fc1fe4cbbf --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java @@ -0,0 +1,208 @@ +/* ARCFourSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; +import gnu.javax.crypto.prng.ARCFour; +import gnu.java.security.prng.IRandom; +import gnu.java.security.prng.LimitReachedException; +import gnu.javax.crypto.prng.PRNGFactory; + +import java.security.AlgorithmParameters; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.spec.AlgorithmParameterSpec; + +import java.util.HashMap; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.CipherSpi; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.ShortBufferException; + +/** + * The <i>Service Provider Interface</i> (<b>SPI</b>) for the ARCFOUR + * stream cipher. + * + * @version $Revision: 1.1 $ + */ +public class ARCFourSpi extends CipherSpi +{ + + // Constants and variables. + // ----------------------------------------------------------------------- + + private IRandom keystream; + + // Constructors. + // ----------------------------------------------------------------------- + + public ARCFourSpi() + { + super(); + keystream = PRNGFactory.getInstance(Registry.ARCFOUR_PRNG); + } + + // Methods implementing CipherSpi. + // ----------------------------------------------------------------------- + + protected int engineGetBlockSize() + { + return 0; // stream cipher. + } + + protected void engineSetMode(String s) throws NoSuchAlgorithmException + { + // ignored. + } + + protected void engineSetPadding(String s) throws NoSuchPaddingException + { + // ignored. + } + + protected byte[] engineGetIV() + { + return null; + } + + protected int engineGetOutputSize(int in) + { + return in; + } + + protected AlgorithmParameters engineGetParameters() + { + return null; + } + + protected void engineInit(int mode, Key key, SecureRandom r) + throws InvalidKeyException + { + if (mode != Cipher.ENCRYPT_MODE && mode != Cipher.DECRYPT_MODE) + { + throw new IllegalArgumentException( + "arcfour is for encryption or decryption only"); + } + if (key == null || !key.getFormat().equalsIgnoreCase("RAW")) + { + throw new InvalidKeyException("key must be non-null raw bytes"); + } + HashMap attrib = new HashMap(); + attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, key.getEncoded()); + keystream.init(attrib); + } + + protected void engineInit(int mode, Key key, AlgorithmParameterSpec p, + SecureRandom r) throws InvalidKeyException, + InvalidAlgorithmParameterException + { + engineInit(mode, key, r); + } + + protected void engineInit(int mode, Key key, AlgorithmParameters p, + SecureRandom r) throws InvalidKeyException, + InvalidAlgorithmParameterException + { + engineInit(mode, key, r); + } + + protected byte[] engineUpdate(byte[] in, int offset, int length) + { + if (length < 0 || offset < 0 || length + offset > in.length) + { + throw new ArrayIndexOutOfBoundsException(); + } + byte[] result = new byte[length]; + try + { + for (int i = 0; i < length; i++) + { + result[i] = (byte) (in[i + offset] ^ keystream.nextByte()); + } + } + catch (LimitReachedException wontHappen) + { + } + return result; + } + + protected int engineUpdate(byte[] in, int inOffset, int length, byte[] out, + int outOffset) throws ShortBufferException + { + if (length < 0 || inOffset < 0 || length + inOffset > in.length + || outOffset < 0) + { + throw new ArrayIndexOutOfBoundsException(); + } + if (outOffset + length > out.length) + { + throw new ShortBufferException(); + } + try + { + for (int i = 0; i < length; i++) + { + out[i + outOffset] = (byte) (in[i + inOffset] ^ keystream.nextByte()); + } + } + catch (LimitReachedException wontHappen) + { + } + return length; + } + + protected byte[] engineDoFinal(byte[] in, int offset, int length) + throws IllegalBlockSizeException, BadPaddingException + { + return engineUpdate(in, offset, length); + } + + protected int engineDoFinal(byte[] in, int inOffset, int length, byte[] out, + int outOffset) throws ShortBufferException, + IllegalBlockSizeException, BadPaddingException + { + return engineUpdate(in, inOffset, length, out, outOffset); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java new file mode 100644 index 00000000000..ac2f596c863 --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java @@ -0,0 +1,59 @@ +/* AnubisSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the Anubis <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class AnubisSpi extends CipherAdapter +{ + + // Constructors. + // -------------------------------------------------------------------- + + public AnubisSpi() + { + super(Registry.ANUBIS_CIPHER); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java new file mode 100644 index 00000000000..d1a28616d0d --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java @@ -0,0 +1,59 @@ +/* BlowfishSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the Blowfish <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class BlowfishSpi extends CipherAdapter +{ + + // Constructors. + // -------------------------------------------------------------------- + + public BlowfishSpi() + { + super(Registry.BLOWFISH_CIPHER); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java new file mode 100644 index 00000000000..b1d4cf70374 --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java @@ -0,0 +1,68 @@ +/* Cast5Spi.java -- + Copyright (C) 2003, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the <code>CAST5</code> (a.k.a. CAST-128) <i>Service + * Provider Interface</i> (<b>SPI</b>) Adapter. + * + * @version Revision: $ + */ +public class Cast5Spi extends CipherAdapter +{ + + // Constants and variables + // ------------------------------------------------------------------------- + + // Constructor(s) + // ------------------------------------------------------------------------- + + public Cast5Spi() + { + super(Registry.CAST5_CIPHER); + } + + // Class methods + // ------------------------------------------------------------------------- + + // Instance methods + // ------------------------------------------------------------------------- +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java new file mode 100644 index 00000000000..9667a67fff8 --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java @@ -0,0 +1,507 @@ +/* CipherAdapter.java -- + Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.javax.crypto.cipher.IBlockCipher; +import gnu.javax.crypto.cipher.CipherFactory; +import gnu.javax.crypto.jce.spec.BlockCipherParameterSpec; +import gnu.javax.crypto.mode.IMode; +import gnu.javax.crypto.mode.ModeFactory; +import gnu.javax.crypto.pad.IPad; +import gnu.javax.crypto.pad.PadFactory; +import gnu.javax.crypto.pad.WrongPaddingException; + +import java.security.AlgorithmParameters; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.InvalidParameterSpecException; +import java.util.HashMap; +import java.util.Map; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.CipherSpi; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.ShortBufferException; +import javax.crypto.spec.IvParameterSpec; + +/** + * <p>The implementation of a generic {@link Cipher} <i>Adapter</i> class to + * wrap GNU Crypto cipher instances.</p> + * + * <p>This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for + * the {@link Cipher} class, which provides the functionality of symmetric-key + * block ciphers, such as the AES.<p> + * + * <p>This base class defines all of the abstract methods in {@link CipherSpi}, + * but does not define the (non-abstract) key wrapping functions that extended + * the base cipher SPI, and these methods thus immediately throw an + * {@link UnsupportedOperationException}. If a cipher implementation provides + * this functionality, or if it in fact accepts parameters other than the key + * and the initialization vector, the subclass should override those methods. + * Otherwise a subclass need only call the {@link #CipherAdapter(String)} + * constructor with the name of the cipher.</p> + * + * @version $Revision: 1.1 $ + */ +class CipherAdapter extends CipherSpi +{ + + // Constants and variables. + // ------------------------------------------------------------------------- + + /** Our cipher instance. */ + protected IBlockCipher cipher; + + /** Our mode instance. */ + protected IMode mode; + + /** Our padding instance. */ + protected IPad pad; + + /** The current key size. */ + protected int keyLen; + + /** Our attributes map. */ + protected Map attributes; + + /** An incomplete block. */ + protected byte[] partBlock; + + /** The number of bytes in {@link #partBlock}. */ + protected int partLen; + + /** The length of blocks we are processing. */ + protected int blockLen; + + // Constructor(s) + // ------------------------------------------------------------------------- + + /** + * <p>Protected constructor to be called by subclasses. The cipher name + * argument should be the appropriate one listed in {@link gnu.crypto.Registry}. + * The basic cipher instance is created, along with an instance of the + * {@link gnu.crypto.mode.ECB} mode and no padding.</p> + * + * @param cipherName The cipher to instantiate. + * @param blockLen The block length to use. + */ + protected CipherAdapter(String cipherName, int blockLen) + { + cipher = CipherFactory.getInstance(cipherName); + attributes = new HashMap(); + this.blockLen = blockLen; + mode = ModeFactory.getInstance("ECB", cipher, blockLen); + attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(blockLen)); + } + + /** + * <p>Creates a new cipher adapter with the default block size.</p> + * + * @param cipherName The cipher to instantiate. + */ + protected CipherAdapter(String cipherName) + { + cipher = CipherFactory.getInstance(cipherName); + blockLen = cipher.defaultBlockSize(); + attributes = new HashMap(); + mode = ModeFactory.getInstance("ECB", cipher, blockLen); + attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(blockLen)); + } + + // Instance methods implementing javax.crypto.CipherSpi. + // ------------------------------------------------------------------------- + + protected void engineSetMode(String modeName) throws NoSuchAlgorithmException + { + if (modeName.length() >= 3 + && modeName.substring(0, 3).equalsIgnoreCase("CFB")) + { + if (modeName.length() > 3) + { + try + { + int bs = Integer.parseInt(modeName.substring(3)); + attributes.put(IMode.MODE_BLOCK_SIZE, new Integer(bs / 8)); + } + catch (NumberFormatException nfe) + { + throw new NoSuchAlgorithmException(modeName); + } + modeName = "CFB"; + } + } + else + { + attributes.remove(IMode.MODE_BLOCK_SIZE); + } + mode = ModeFactory.getInstance(modeName, cipher, blockLen); + if (mode == null) + { + throw new NoSuchAlgorithmException(modeName); + } + } + + protected void engineSetPadding(String padName) throws NoSuchPaddingException + { + if (padName.equalsIgnoreCase("NoPadding")) + { + pad = null; + return; + } + pad = PadFactory.getInstance(padName); + if (pad == null) + { + throw new NoSuchPaddingException(padName); + } + } + + protected int engineGetBlockSize() + { + if (cipher != null) + { + return blockLen; + } + return 0; + } + + protected int engineGetOutputSize(int inputLen) + { + final int blockSize = mode.currentBlockSize(); + return ((inputLen + partLen) / blockSize) * blockSize; + } + + protected byte[] engineGetIV() + { + byte[] iv = (byte[]) attributes.get(IMode.IV); + if (iv == null) + { + return null; + } + return (byte[]) iv.clone(); + } + + protected AlgorithmParameters engineGetParameters() + { + BlockCipherParameterSpec spec = new BlockCipherParameterSpec( + (byte[]) attributes.get(IMode.IV), + cipher.currentBlockSize(), + keyLen); + AlgorithmParameters params; + try + { + params = AlgorithmParameters.getInstance("BlockCipherParameters"); + params.init(spec); + } + catch (NoSuchAlgorithmException nsae) + { + return null; + } + catch (InvalidParameterSpecException ipse) + { + return null; + } + return params; + } + + protected void engineInit(int opmode, Key key, SecureRandom random) + throws InvalidKeyException + { + switch (opmode) + { + case Cipher.ENCRYPT_MODE: + attributes.put(IMode.STATE, new Integer(IMode.ENCRYPTION)); + break; + case Cipher.DECRYPT_MODE: + attributes.put(IMode.STATE, new Integer(IMode.DECRYPTION)); + break; + } + if (!key.getFormat().equalsIgnoreCase("RAW")) + { + throw new InvalidKeyException("bad key format " + key.getFormat()); + } + byte[] kb = key.getEncoded(); + if (keyLen == 0) + { + keyLen = kb.length; + } + else if (keyLen < kb.length) + { + byte[] kbb = kb; + kb = new byte[keyLen]; + System.arraycopy(kbb, 0, kb, 0, keyLen); + } + attributes.put(IBlockCipher.KEY_MATERIAL, kb); + reset(); + } + + protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, + SecureRandom random) throws InvalidKeyException, + InvalidAlgorithmParameterException + { + if (params == null) + { + byte[] iv = new byte[blockLen]; + random.nextBytes(iv); + attributes.put(IMode.IV, iv); + blockLen = cipher.defaultBlockSize(); + attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(blockLen)); + keyLen = 0; + } + else if (params instanceof BlockCipherParameterSpec) + { + attributes.put( + IBlockCipher.CIPHER_BLOCK_SIZE, + new Integer( + ((BlockCipherParameterSpec) params).getBlockSize())); + attributes.put(IMode.IV, ((BlockCipherParameterSpec) params).getIV()); + keyLen = ((BlockCipherParameterSpec) params).getKeySize(); + blockLen = ((BlockCipherParameterSpec) params).getBlockSize(); + } + else if (params instanceof IvParameterSpec) + { + attributes.put(IMode.IV, ((IvParameterSpec) params).getIV()); + blockLen = cipher.defaultBlockSize(); + attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(blockLen)); + keyLen = 0; + } + engineInit(opmode, key, random); + } + + protected void engineInit(int opmode, Key key, AlgorithmParameters params, + SecureRandom random) throws InvalidKeyException, + InvalidAlgorithmParameterException + { + AlgorithmParameterSpec spec = null; + try + { + if (params != null) + { + spec = params.getParameterSpec(BlockCipherParameterSpec.class); + } + } + catch (InvalidParameterSpecException ignored) + { + } + engineInit(opmode, key, spec, random); + } + + protected byte[] engineUpdate(byte[] input, int off, int len) + { + final int blockSize = mode.currentBlockSize(); + final int count = (partLen + len) / blockSize; + final byte[] out = new byte[count * blockSize]; + try + { + engineUpdate(input, off, len, out, 0); + } + catch (ShortBufferException x) + { // should not happen + x.printStackTrace(System.err); + } + return out; + } + + // protected int + // engineUpdate(byte[] in, int inOff, int inLen, byte[] out, int outOff) + // throws ShortBufferException + // { + // int blockSize = mode.currentBlockSize(); + // int count = (partLen + inLen) / blockSize; + // if (count * blockSize > out.length - outOff) { + // throw new ShortBufferException(); + // } + // byte[] buf; + // if (partLen > 0 && count > 0) { + // buf = new byte[partLen + inLen]; + // System.arraycopy(partBlock, 0, buf, 0, partLen); + // if (in != null && inLen > 0) { + // System.arraycopy(in, inOff, buf, partLen, inLen); + // } + // partLen = 0; + // inOff = 0; + // } else { + // buf = in; + // } + // for (int i = 0; i < count; i++) { + // mode.update(buf, i * blockSize + inOff, out, i * blockSize + outOff); + // } + // if (inOff + inLen > count * blockSize) { + // partLen = (inOff + inLen) - (count * blockSize); + // System.arraycopy(in, count * blockSize, partBlock, 0, partLen); + // } + // return count * blockSize; + // } + + protected int engineUpdate(byte[] in, int inOff, int inLen, byte[] out, + int outOff) throws ShortBufferException + { + if (inLen == 0) + { // nothing to process + return 0; + } + final int blockSize = mode.currentBlockSize(); + final int blockCount = (partLen + inLen) / blockSize; + final int result = blockCount * blockSize; + if (result > out.length - outOff) + { + throw new ShortBufferException(); + } + if (blockCount == 0) + { // not enough bytes for even 1 block + System.arraycopy(in, inOff, partBlock, partLen, inLen); + partLen += inLen; + return 0; + } + final byte[] buf; + // we have enough bytes for at least 1 block + if (partLen == 0) + { // if no cached bytes use input + buf = in; + } + else + { // prefix input with cached bytes + buf = new byte[partLen + inLen]; + System.arraycopy(partBlock, 0, buf, 0, partLen); + if (in != null && inLen > 0) + { + System.arraycopy(in, inOff, buf, partLen, inLen); + } + inOff = 0; + } + for (int i = 0; i < blockCount; i++) + { // update blockCount * blockSize + mode.update(buf, inOff, out, outOff); + inOff += blockSize; + outOff += blockSize; + } + partLen += inLen - result; + if (partLen > 0) + { // cache remaining bytes from buf + System.arraycopy(buf, inOff, partBlock, 0, partLen); + } + return result; + } + + protected byte[] engineDoFinal(byte[] input, int off, int len) + throws IllegalBlockSizeException, BadPaddingException + { + final byte[] result; + final byte[] buf = engineUpdate(input, off, len); + if (pad != null) + { + switch (((Integer) attributes.get(IMode.STATE)).intValue()) + { + case IMode.ENCRYPTION: + byte[] padding = pad.pad(partBlock, 0, partLen); + byte[] buf2 = engineUpdate(padding, 0, padding.length); + result = new byte[buf.length + buf2.length]; + System.arraycopy(buf, 0, result, 0, buf.length); + System.arraycopy(buf2, 0, result, buf.length, buf2.length); + break; + case IMode.DECRYPTION: + int padLen; + try + { + padLen = pad.unpad(buf, 0, buf.length); + } + catch (WrongPaddingException wpe) + { + throw new BadPaddingException(wpe.getMessage()); + } + result = new byte[buf.length - padLen]; + System.arraycopy(buf, 0, result, 0, result.length); + break; + default: + throw new IllegalStateException(); + } + } + else + { + if (partLen > 0) + { + throw new IllegalBlockSizeException(partLen + " trailing bytes"); + } + result = buf; + } + + try + { + reset(); + } + catch (InvalidKeyException ike) + { + // Should not happen; if we initialized it with the current + // parameters before, we should be able to do it again. + throw new Error(ike); + } + return result; + } + + protected int engineDoFinal(byte[] in, int inOff, int inLen, byte[] out, + int outOff) throws BadPaddingException, + IllegalBlockSizeException, ShortBufferException + { + byte[] buf = engineDoFinal(in, inOff, inLen); + if (out.length + outOff < buf.length) + { + throw new ShortBufferException(); + } + System.arraycopy(buf, 0, out, outOff, buf.length); + return buf.length; + } + + private void reset() throws InvalidKeyException + { + mode.reset(); + mode.init(attributes); + if (pad != null) + { + pad.reset(); + pad.init(blockLen); + } + partBlock = new byte[blockLen]; + partLen = 0; + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java new file mode 100644 index 00000000000..f3ec8220a7f --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java @@ -0,0 +1,59 @@ +/* DESSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the DES <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class DESSpi extends CipherAdapter +{ + + // Constructors. + // -------------------------------------------------------------------- + + public DESSpi() + { + super(Registry.DES_CIPHER); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java new file mode 100644 index 00000000000..7f43dd010fa --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java @@ -0,0 +1,59 @@ +/* KhazadSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the Khazad <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class KhazadSpi extends CipherAdapter +{ + + // Constructors. + // -------------------------------------------------------------------- + + public KhazadSpi() + { + super(Registry.KHAZAD_CIPHER); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java new file mode 100644 index 00000000000..0876c9585a3 --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java @@ -0,0 +1,59 @@ +/* NullCipherSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the Null cipher <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class NullCipherSpi extends CipherAdapter +{ + + // Constructors. + // ----------------------------------------------------------------------- + + public NullCipherSpi() + { + super(Registry.NULL_CIPHER); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java new file mode 100644 index 00000000000..28b327d8365 --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java @@ -0,0 +1,1352 @@ +/* PBES2.java -- + Copyright (C) 2003, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.javax.crypto.prng.IPBE; +import gnu.java.security.prng.IRandom; +import gnu.java.security.prng.LimitReachedException; +import gnu.javax.crypto.prng.PRNGFactory; + +import java.security.AlgorithmParameters; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.SecureRandom; +import java.security.spec.AlgorithmParameterSpec; +import java.util.HashMap; + +import javax.crypto.interfaces.PBEKey; +import javax.crypto.spec.SecretKeySpec; + +/** + * <p>.</p> + * + * @version $Revision: 1.1 $ + */ +public abstract class PBES2 extends CipherAdapter +{ + + // Constants and variables + // ------------------------------------------------------------------------- + + /** The HMac (PRF) algorithm name. */ + protected String macName; + + // Constructor(s) + // ------------------------------------------------------------------------- + + protected PBES2(String cipherName, int blockLen, String macName) + { + super(cipherName, blockLen); + this.macName = macName; + } + + protected PBES2(String cipherName, String macName) + { + super(cipherName); + this.macName = macName; + } + + // Instance methods + // ------------------------------------------------------------------------- + + protected void engineInit(int opmode, Key key, SecureRandom random) + throws InvalidKeyException + { + if (!(key instanceof PBEKey)) + throw new InvalidKeyException("not a PBE key"); + + super.engineInit(opmode, genkey((PBEKey) key), random); + } + + protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, + SecureRandom random) throws InvalidKeyException, + InvalidAlgorithmParameterException + { + if (!(key instanceof PBEKey)) + throw new InvalidKeyException("not a PBE key"); + + super.engineInit(opmode, genkey((PBEKey) key), params, random); + } + + protected void engineInit(int opmode, Key key, AlgorithmParameters params, + SecureRandom random) throws InvalidKeyException, + InvalidAlgorithmParameterException + { + if (!(key instanceof PBEKey)) + throw new InvalidKeyException("not a PBE key"); + + super.engineInit(opmode, genkey((PBEKey) key), params, random); + } + + private SecretKeySpec genkey(PBEKey key) throws InvalidKeyException + { + IRandom kdf = PRNGFactory.getInstance("PBKDF2-" + macName); + if (kdf == null) + { + throw new IllegalArgumentException("no such KDF: PBKDF2-" + macName); + } + HashMap attrib = new HashMap(); + attrib.put(IPBE.ITERATION_COUNT, new Integer(key.getIterationCount())); + attrib.put(IPBE.PASSWORD, key.getPassword()); + attrib.put(IPBE.SALT, key.getSalt()); + try + { + kdf.init(attrib); + } + catch (IllegalArgumentException iae) + { + throw new InvalidKeyException(iae.toString()); + } + byte[] dk = new byte[mode.defaultKeySize()]; + try + { + kdf.nextBytes(dk, 0, dk.length); + } + catch (LimitReachedException shouldNotHappen) + { + // throw new Error(shouldNotHappen); + throw new Error(String.valueOf(shouldNotHappen)); + } + return new SecretKeySpec(dk, cipher.name()); + } + + // Inner classe(s) + // ========================================================================= + + public static class HMacSHA1 extends PBES2 + { + + // Constructor(s) + // --------------------------------------------------------------------- + + public HMacSHA1(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-SHA1"); + } + + public HMacSHA1(String cipher) + { + super(cipher, "HMAC-SHA1"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacSHA1 + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacSHA1 + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacSHA1 + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacSHA1 + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacSHA1 + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacSHA1 + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacSHA1 + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacSHA1 + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacSHA1 + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacSHA1 + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacMD5 extends PBES2 + { + + // Constructor(s) + // ---------------------------------------------------------------------- + + public HMacMD5(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-MD5"); + } + + public HMacMD5(String cipher) + { + super(cipher, "HMAC-MD5"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacMD5 + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacMD5 + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacMD5 + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacMD5 + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacMD5 + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacMD5 + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacMD5 + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacMD5 + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacMD5 + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacMD5 + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacMD2 extends PBES2 + { + + // Constructor(s) + // ---------------------------------------------------------------------- + + public HMacMD2(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-MD2"); + } + + public HMacMD2(String cipher) + { + super(cipher, "HMAC-MD2"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacMD2 + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacMD2 + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacMD2 + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacMD2 + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacMD2 + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacMD2 + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacMD2 + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacMD2 + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacMD2 + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacMD2 + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacMD4 extends PBES2 + { + + // Constructor(s) + // ---------------------------------------------------------------------- + + public HMacMD4(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-MD4"); + } + + public HMacMD4(String cipher) + { + super(cipher, "HMAC-MD4"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacMD4 + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacMD4 + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacMD4 + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacMD4 + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacMD4 + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacMD4 + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacMD4 + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacMD4 + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacMD4 + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacMD4 + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacHaval extends PBES2 + { + + // Constructor(s) + // --------------------------------------------------------------------- + + public HMacHaval(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-HAVAL"); + } + + public HMacHaval(String cipher) + { + super(cipher, "HMAC-HAVAL"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacHaval + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacHaval + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacHaval + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacHaval + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacHaval + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacHaval + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacHaval + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacHaval + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacHaval + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacHaval + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacRipeMD128 extends PBES2 + { + + // Constructor(s) + // ---------------------------------------------------------------------- + + public HMacRipeMD128(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-RIPEMD128"); + } + + public HMacRipeMD128(String cipher) + { + super(cipher, "HMAC-RIPEMD128"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacRipeMD128 + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacRipeMD128 + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacRipeMD128 + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacRipeMD128 + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacRipeMD128 + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacRipeMD128 + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacRipeMD128 + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacRipeMD128 + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacRipeMD128 + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacRipeMD128 + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacRipeMD160 extends PBES2 + { + + // Constructor(s) + // ---------------------------------------------------------------------- + + public HMacRipeMD160(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-RIPEMD160"); + } + + public HMacRipeMD160(String cipher) + { + super(cipher, "HMAC-RIPEMD160"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacRipeMD160 + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacRipeMD160 + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacRipeMD160 + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacRipeMD160 + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacRipeMD160 + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacRipeMD160 + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacRipeMD160 + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacRipeMD160 + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacRipeMD160 + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacRipeMD160 + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacSHA256 extends PBES2 + { + + // Constructor(s) + // --------------------------------------------------------------------- + + public HMacSHA256(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-SHA-256"); + } + + public HMacSHA256(String cipher) + { + super(cipher, "HMAC-SHA-256"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacSHA256 + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacSHA256 + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacSHA256 + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacSHA256 + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacSHA256 + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacSHA256 + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacSHA256 + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacSHA256 + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacSHA256 + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacSHA256 + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacSHA384 extends PBES2 + { + + // Constructor(s) + // --------------------------------------------------------------------- + + public HMacSHA384(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-SHA-384"); + } + + public HMacSHA384(String cipher) + { + super(cipher, "HMAC-SHA-384"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacSHA384 + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacSHA384 + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacSHA384 + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacSHA384 + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacSHA384 + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacSHA384 + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacSHA384 + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacSHA384 + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacSHA384 + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacSHA384 + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacSHA512 extends PBES2 + { + + // Constructor(s) + // --------------------------------------------------------------------- + + public HMacSHA512(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-SHA-512"); + } + + public HMacSHA512(String cipher) + { + super(cipher, "HMAC-SHA-512"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacSHA512 + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacSHA512 + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacSHA512 + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacSHA512 + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacSHA512 + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacSHA512 + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacSHA512 + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacSHA512 + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacSHA512 + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacSHA512 + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacTiger extends PBES2 + { + + // Constructor(s) + // --------------------------------------------------------------------- + + public HMacTiger(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-TIGER"); + } + + public HMacTiger(String cipher) + { + super(cipher, "HMAC-TIGER"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacTiger + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacTiger + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacTiger + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacTiger + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacTiger + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacTiger + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacTiger + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacTiger + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacTiger + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacTiger + { + public Twofish() + { + super("Twofish"); + } + } + } + + public static class HMacWhirlpool extends PBES2 + { + + // Constructor(s) + // ---------------------------------------------------------------------- + + public HMacWhirlpool(String cipher, int blockLen) + { + super(cipher, blockLen, "HMAC-WHIRLPOOL"); + } + + public HMacWhirlpool(String cipher) + { + super(cipher, "HMAC-WHIRLPOOL"); + } + + // Inner classe(s) + // ====================================================================== + + public static class AES extends HMacWhirlpool + { + public AES() + { + super("AES"); + } + } + + public static class Anubis extends HMacWhirlpool + { + public Anubis() + { + super("Anubis"); + } + } + + public static class Blowfish extends HMacWhirlpool + { + public Blowfish() + { + super("Blowfish"); + } + } + + public static class Cast5 extends HMacWhirlpool + { + public Cast5() + { + super("Cast5"); + } + } + + public static class DES extends HMacWhirlpool + { + public DES() + { + super("DES"); + } + } + + public static class Khazad extends HMacWhirlpool + { + public Khazad() + { + super("Khazad"); + } + } + + public static class Serpent extends HMacWhirlpool + { + public Serpent() + { + super("Serpent"); + } + } + + public static class Square extends HMacWhirlpool + { + public Square() + { + super("Square"); + } + } + + public static class TripleDES extends HMacWhirlpool + { + public TripleDES() + { + super("TripleDES"); + } + } + + public static class Twofish extends HMacWhirlpool + { + public Twofish() + { + super("Twofish"); + } + } + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java new file mode 100644 index 00000000000..1a67f934b9e --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java @@ -0,0 +1,59 @@ +/* RijndaelSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the Rijndael <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class RijndaelSpi extends CipherAdapter +{ + + // Constructors. + // -------------------------------------------------------------------- + + public RijndaelSpi() + { + super(Registry.RIJNDAEL_CIPHER, 16); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java new file mode 100644 index 00000000000..394a0ce0a66 --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java @@ -0,0 +1,59 @@ +/* SerpentSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the Serpent <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class SerpentSpi extends CipherAdapter +{ + + // Constructors. + // -------------------------------------------------------------------- + + public SerpentSpi() + { + super(Registry.SERPENT_CIPHER); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java new file mode 100644 index 00000000000..bb59cd224ce --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java @@ -0,0 +1,59 @@ +/* SquareSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the Square <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class SquareSpi extends CipherAdapter +{ + + // Constructors. + // -------------------------------------------------------------------- + + public SquareSpi() + { + super(Registry.SQUARE_CIPHER); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java new file mode 100644 index 00000000000..cec30f6537d --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java @@ -0,0 +1,59 @@ +/* TripleDESSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the Triple-DES <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class TripleDESSpi extends CipherAdapter +{ + + // Constructors. + // -------------------------------------------------------------------- + + public TripleDESSpi() + { + super(Registry.TRIPLEDES_CIPHER); + } +}
\ No newline at end of file diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java new file mode 100644 index 00000000000..34f2d95d60a --- /dev/null +++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java @@ -0,0 +1,59 @@ +/* TwofishSpi.java -- + Copyright (C) 2002, 2006 Free Software Foundation, Inc. + +This file is a part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +GNU Classpath 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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.crypto.jce.cipher; + +import gnu.java.security.Registry; + +/** + * The implementation of the Twofish <i>Service Provider Interface</i> + * (<b>SPI</b>) adapter. + * + * @version $Revision: 1.1 $ + */ +public final class TwofishSpi extends CipherAdapter +{ + + // Constructors. + // -------------------------------------------------------------------- + + public TwofishSpi() + { + super(Registry.TWOFISH_CIPHER); + } +}
\ No newline at end of file |

