net.sourceforge.jcetaglib.lib
Class DHKeyAgreement

java.lang.Object
  extended bynet.sourceforge.jcetaglib.lib.DHKeyAgreement

public class DHKeyAgreement
extends java.lang.Object

Diffie-Hellman key agreement

Version:
$Id: DHKeyAgreement.java,v 1.3 2004/04/15 07:28:25 hamgert Exp $
Author:
Gert Van Ham, hamgert@users.sourceforge.net, http://jcetaglib.sourceforge.net

Constructor Summary
DHKeyAgreement()
           
 
Method Summary
static java.security.PublicKey bytesToPublicKey(byte[] keyBytes)
          convert byte representation of a public key to a PublicKey object
static java.security.KeyPair generateDHKeyPair()
          Generate DH keypair based on SKIP Modulus
static java.security.Key generateSessionKey(java.security.PublicKey pubkey, java.security.PrivateKey privkey, java.lang.String algorithm, int length)
          Create session key from DH keypair
static byte[] publicKeyToBytes(java.security.PublicKey pub)
          get a byte presentation of a PublicKey object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DHKeyAgreement

public DHKeyAgreement()
Method Detail

generateDHKeyPair

public static java.security.KeyPair generateDHKeyPair()
                                               throws java.security.NoSuchAlgorithmException,
                                                      java.security.NoSuchProviderException,
                                                      java.security.InvalidAlgorithmParameterException
Generate DH keypair based on SKIP Modulus

Returns:
DH keypair
Throws:
java.security.NoSuchAlgorithmException - unknown algorithm
java.security.NoSuchProviderException - unknown provider
java.security.InvalidAlgorithmParameterException

generateSessionKey

public static java.security.Key generateSessionKey(java.security.PublicKey pubkey,
                                                   java.security.PrivateKey privkey,
                                                   java.lang.String algorithm,
                                                   int length)
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.security.InvalidKeyException
Create session key from DH keypair

Parameters:
pubkey - public key other party
privkey - own private key
algorithm - block cipher algorithm
length - block cipher length in bits
Returns:
session key
Throws:
java.security.NoSuchAlgorithmException - unknown algorithm
java.security.InvalidKeyException - key is not valid

publicKeyToBytes

public static byte[] publicKeyToBytes(java.security.PublicKey pub)
get a byte presentation of a PublicKey object

Parameters:
pub - the public key
Returns:
byte representation of a public key

bytesToPublicKey

public static java.security.PublicKey bytesToPublicKey(byte[] keyBytes)
                                                throws java.security.NoSuchAlgorithmException,
                                                       java.security.spec.InvalidKeySpecException
convert byte representation of a public key to a PublicKey object

Parameters:
keyBytes - byte representation of a public key
Returns:
PublicKey object
Throws:
java.security.NoSuchAlgorithmException - unknown algorithm
java.security.spec.InvalidKeySpecException