⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ideakeygenerator.java

📁 面向应用的智能安全代理平台和工具包是一个综合网络应用的安全共性需求而设计和实现的一个通用性的网络信息安全应用支撑平台
💻 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");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -