de.upb.swtpra05.group03.crypto
Class BobCrypto

java.lang.Object
  extended byde.upb.swtpra05.group03.crypto.Crypto
      extended byde.upb.swtpra05.group03.crypto.BobCrypto
Direct Known Subclasses:
ShuttleCrypto

public class BobCrypto
extends Crypto

crypto class used for the 'bob' role known from DiffieHellman example

Version:
$Revision: 1.3 $

Field Summary
private  javax.crypto.KeyAgreement keyAgree
          object used for the key agreement
private  java.security.KeyPairGenerator keyPairGen
          used to generate a public private key pair
private  java.security.SecureRandom random
          random number generator used for key agreement
 
Fields inherited from class de.upb.swtpra05.group03.crypto.Crypto
AGREEMENT_ALGORITHM, CIPHER_ALGORITHM, KEY_ALGORITHM, pubKeyFactory, SIGNATURE_ALGORITHM, signer, state, STATE_INIT, STATE_READY, STATE_WAITING, verifyer
 
Constructor Summary
BobCrypto()
          Constructor
 
Method Summary
 DataSigPair generatePublicKey(DataSigPair dsp)
          generates a public key for the key agreement by using the others public key and creates the secret key
 void reset()
          reset the state to INIT so a new key agreement can be made
 void saveSeed()
          saves the seed of the random number generator into a file
 
Methods inherited from class de.upb.swtpra05.group03.crypto.Crypto
decryptObject, encryptObject, genPublicKeyFromX509, getSecretKey, isReady, loadSigningKeys, setSecretKey, setSecretKey, sign, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyAgree

private final javax.crypto.KeyAgreement keyAgree
object used for the key agreement


random

private java.security.SecureRandom random
random number generator used for key agreement


keyPairGen

private final java.security.KeyPairGenerator keyPairGen
used to generate a public private key pair

Constructor Detail

BobCrypto

public BobCrypto()
          throws java.security.NoSuchAlgorithmException,
                 javax.crypto.NoSuchPaddingException
Constructor

Throws:
javax.crypto.NoSuchPaddingException
java.security.NoSuchAlgorithmException
Method Detail

generatePublicKey

public DataSigPair generatePublicKey(DataSigPair dsp)
                              throws java.security.SignatureException,
                                     java.security.NoSuchAlgorithmException,
                                     java.security.spec.InvalidKeySpecException,
                                     java.security.InvalidAlgorithmParameterException,
                                     java.security.InvalidKeyException
generates a public key for the key agreement by using the others public key and creates the secret key

Parameters:
dsp - object containing key and signature
Returns:
public key
Throws:
java.security.SignatureException
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException

saveSeed

public void saveSeed()
saves the seed of the random number generator into a file


reset

public void reset()
Description copied from class: Crypto
reset the state to INIT so a new key agreement can be made

Overrides:
reset in class Crypto