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

📄 publickeycertificatepacket.java

📁 面向应用的智能安全代理平台和工具包是一个综合网络应用的安全共性需求而设计和实现的一个通用性的网络信息安全应用支撑平台
💻 JAVA
字号:
package au.net.aba.pgp;

/*
 * $Id: PublicKeyCertificatePacket.java,v 1.4 1998/10/19 06:32:41 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/pgp/PublicKeyCertificatePacket.java,v $
 * $Revision: 1.4 $
 * $Date: 1998/10/19 06:32:41 $
 * $State: Exp $
 */

import java.io.*;
import java.security.*;

import javax.crypto.spec.*;

import java.security.*;
import java.security.spec.*;

//
// Public key certificate packet.
//

class PublicKeyCertificatePacket extends Packet
{
	public final static String ident = "$Id: PublicKeyCertificatePacket.java,v 1.4 1998/10/19 06:32:41 leachbj Exp $";

	public byte version;			// PGP version
	public long timestamp;			// creation timestamp
	public int validity;			// validity period
	public byte pkAlgorithm;		// public key scheme algorithm
	public Multiprecision modulus;		// public key modulus
	public Multiprecision exponent;	// public key exponent

	//
	// Construct from an input stream.
	//
	public PublicKeyCertificatePacket (InputStream input)
		throws IOException
	{
		// build packet input stream
		DataInputStream data = buildCipherPacketInputStream (
			input,(byte)0x06,
			"public key certificate packet expected");

		version = data.readByte ();
		timestamp = data.readUnsignedShort () << 16;
		timestamp |= data.readUnsignedShort ();
		validity = data.readUnsignedShort ();
		pkAlgorithm = data.readByte ();
		modulus = new Multiprecision (data);
		exponent = new Multiprecision (data);
	}
	/**
	 * return the PublicKey represented by this certificate packet.
	 *
	 * @param provider	algorithm provider for the key factory.
	 */
	public PublicKey getKey(
		String	provider)
		throws KeyException
	{
		RSAPublicKeySpec	spec;

		spec = new RSAPublicKeySpec(
				modulus.toBigInteger(),
				exponent.toBigInteger());

		try
		{
			KeyFactory	keyFact;

			keyFact = KeyFactory.getInstance("RSA", provider);

			return keyFact.generatePublic(spec);
		}
		catch (Exception e)
		{
			throw new KeyException(e.toString());
		}
	}
}

⌨️ 快捷键说明

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