For the latest news and information visit
The GNU Crypto project

gnu.crypto.key
Class BaseKeyAgreementParty

java.lang.Object
  extended bygnu.crypto.key.BaseKeyAgreementParty
All Implemented Interfaces:
IKeyAgreementParty
Direct Known Subclasses:
DiffieHellmanKeyAgreement, ElGamalKeyAgreement, SRP6KeyAgreement

public abstract class BaseKeyAgreementParty
extends java.lang.Object
implements IKeyAgreementParty

A base abstract class to facilitate implementations of concrete key agreement protocol handlers.

Version:
$Revision: 1.2 $

Field Summary
protected  boolean complete
          Whether the exchange has concluded or not.
protected  boolean initialised
          Whether the instance is initialised or not.
protected  java.lang.String name
          The canonical name of the protocol.
protected  java.security.SecureRandom rnd
          The optional SecureRandom instance to use.
protected  int step
          The current step index of the protocol exchange.
protected static java.math.BigInteger TWO
           
 
Constructor Summary
protected BaseKeyAgreementParty(java.lang.String name)
           
 
Method Summary
protected abstract  void engineInit(java.util.Map attributes)
           
protected abstract  OutgoingMessage engineProcessMessage(IncomingMessage in)
           
protected abstract  void engineReset()
           
protected abstract  byte[] engineSharedSecret()
           
 byte[] getSharedSecret()
          Returns the byte array containing the shared secret as generated by this party.
 void init(java.util.Map attributes)
          Sets up the instance to operate with specific attributes.
 boolean isComplete()
          Returns true if the party in the key agreement protocol exchange has completed its part of the exchange.
 java.lang.String name()
          Returns the canonical name of the key agreement protocol.
protected  void nextRandomBytes(byte[] buffer)
          Fills the designated byte array with random data.
 OutgoingMessage processMessage(IncomingMessage in)
          Processes an incoming message at one end, generating a message that will be processed by the other party(ies).
 void reset()
          Resets this instance for re-use with another set of attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TWO

protected static final java.math.BigInteger TWO

name

protected java.lang.String name
The canonical name of the protocol.


initialised

protected boolean initialised
Whether the instance is initialised or not.


step

protected int step
The current step index of the protocol exchange.


complete

protected boolean complete
Whether the exchange has concluded or not.


rnd

protected java.security.SecureRandom rnd
The optional SecureRandom instance to use.

Constructor Detail

BaseKeyAgreementParty

protected BaseKeyAgreementParty(java.lang.String name)
Method Detail

name

public java.lang.String name()
Description copied from interface: IKeyAgreementParty

Returns the canonical name of the key agreement protocol.

Specified by:
name in interface IKeyAgreementParty
Returns:
the canonical name of the key agreement protocol.

init

public void init(java.util.Map attributes)
          throws KeyAgreementException
Description copied from interface: IKeyAgreementParty

Sets up the instance to operate with specific attributes.

Specified by:
init in interface IKeyAgreementParty
Parameters:
attributes - a map of name-values used by concrete implementations.
Throws:
KeyAgreementException - if an exception occurs during the setup.

processMessage

public OutgoingMessage processMessage(IncomingMessage in)
                               throws KeyAgreementException
Description copied from interface: IKeyAgreementParty

Processes an incoming message at one end, generating a message that will be processed by the other party(ies).

Specified by:
processMessage in interface IKeyAgreementParty
Parameters:
in - the incoming message.
Returns:
an outgoing message, or null if this is an intermediary step that does not cause any output.
Throws:
KeyAgreementException - if an exception occurs during the processing of the incoming message, or during the generation of the outgoing message.

isComplete

public boolean isComplete()
Description copied from interface: IKeyAgreementParty

Returns true if the party in the key agreement protocol exchange has completed its part of the exchange. If this is the case an IllegalStateException is thrown for any method invocation except init() or reset().

Specified by:
isComplete in interface IKeyAgreementParty
Returns:
true if this party has completed its part of the key agreement protocol exchange; false otherwise.

getSharedSecret

public byte[] getSharedSecret()
                       throws KeyAgreementException
Description copied from interface: IKeyAgreementParty

Returns the byte array containing the shared secret as generated by this party.

Specified by:
getSharedSecret in interface IKeyAgreementParty
Returns:
the generated shared secret.
Throws:
KeyAgreementException - if the key agreement is not yet initialised, or is initialised but the exchange is still in progress.

reset

public void reset()
Description copied from interface: IKeyAgreementParty
Resets this instance for re-use with another set of attributes.

Specified by:
reset in interface IKeyAgreementParty

engineInit

protected abstract void engineInit(java.util.Map attributes)
                            throws KeyAgreementException
Throws:
KeyAgreementException

engineProcessMessage

protected abstract OutgoingMessage engineProcessMessage(IncomingMessage in)
                                                 throws KeyAgreementException
Throws:
KeyAgreementException

engineSharedSecret

protected abstract byte[] engineSharedSecret()
                                      throws KeyAgreementException
Throws:
KeyAgreementException

engineReset

protected abstract void engineReset()

nextRandomBytes

protected void nextRandomBytes(byte[] buffer)
Fills the designated byte array with random data.

Parameters:
buffer - the byte array to fill with random data.

For the latest news and information visit
The GNU Crypto project

Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.