?? ideakeygenerator.java
字號:
package au.net.aba.crypto.provider;
/*
* $Id: IDEAKeyGenerator.java,v 1.9 1999/01/18 04:59:31 leachbj Exp $
* $Author: leachbj $
*
* Copyright (C) 1996-1998 Australian Business Access Pty Ltd.
* All rights reserved.
*
* Use, modification, copying and distribution of this software is subject the
* terms and conditions of the ABA Public Licence. See the file
* "PUBLIC_LICENCE" for additional information.
*
* If you have not received a copy of the Public Licence, you must destroy all
* copies of this file immediately.
*
* $Source: /aba/CVSROOT/jdk1.1/src/au.net.aba/crypto/provider/IDEAKeyGenerator.java,v $
* $Revision: 1.9 $
* $Date: 1999/01/18 04:59:31 $
* $State: Exp $
*/
import java.security.InvalidAlgorithmParameterException;
import java.security.spec.AlgorithmParameterSpec;
import au.net.aba.crypto.spec.IDEAKeySpec;
import java.security.SecureRandom;
import javax.crypto.KeyGeneratorSpi;
import javax.crypto.SecretKey;
/**
* This class is used for generating random IDEA keys. This class
* should not be instantiated directly, instead use the
* javax.crypto.KeyGenerator interface.
* <p>
* There is no AlgorithmParameterSpec class defined for IDEA so this
* generator can only be initialised using the keysize,random
* initialisation.
* <p>
* The keysize is 128 bits.
*/
public class IDEAKeyGenerator extends KeyGeneratorSpi
{
public final static String ident = "$Id: IDEAKeyGenerator.java,v 1.9 1999/01/18 04:59:31 leachbj Exp $";
private SecureRandom rand;
/**
* Generates a secret key.
*
* @return a secret key representing a DES key.
*/
protected SecretKey engineGenerateKey()
{
byte[] bytes;
if (rand == null)
{
rand = new SecureRandom();
}
bytes = new byte[IDEAKeySpec.IDEA_KEY_LEN];
rand.nextBytes(bytes);
return new IDEAKey(bytes);
}
/**
* Since IDEA keys are of a fixed size, this method does
* nothing except set the random source.
*
* @param strength the strength of the key. This parameter is
* ignored.
* @param random the source of randomness for this key generator
*/
protected void engineInit(
int strength,
SecureRandom random)
{
rand = random;
}
/**
* Initialises the key generator with the given random source.
*
* @param random a source of random numbers for this generator.
*/
protected void engineInit(
SecureRandom random)
{
rand = random;
}
/**
* This method is not implemented as there is no AlgorithmParameterSpec
* defined for IDEA. (Use one of the other initialisation methods!)
*
* @param params the algorithm parameter specs for this
* generator.
* @param random a source of random numbers for this generator.
* @exception InvalidAlgorithmParameterException An invalid
* parameter specification is provided.
*/
protected void engineInit(
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidAlgorithmParameterException
{
throw new InvalidAlgorithmParameterException("Not Implemented");
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -