gnu.crypto.key

Class BaseKeyAgreementParty

Implemented Interfaces:
IKeyAgreementParty
Known Direct Subclasses:
DiffieHellmanKeyAgreement, ElGamalKeyAgreement, SRP6KeyAgreement

public abstract class BaseKeyAgreementParty
extends Object
implements IKeyAgreementParty

A base abstract class to facilitate implementations of concrete key agreement protocol handlers.
Version:
$Revision: 1.3 $

Field Summary

protected static BigInteger
TWO
protected boolean
complete
Whether the exchange has concluded or not.
protected boolean
initialised
Whether the instance is initialised or not.
protected IRandom
irnd
The optional IRandom instance to use.
protected String
name
The canonical name of the protocol.
protected SecureRandom
rnd
The optional SecureRandom instance to use.
protected int
step
The current step index of the protocol exchange.

Constructor Summary

BaseKeyAgreementParty(String name)

Method Summary

protected abstract void
engineInit(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(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.
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.

Field Details

TWO

protected static final BigInteger TWO

complete

protected boolean complete
Whether the exchange has concluded or not.

initialised

protected boolean initialised
Whether the instance is initialised or not.

irnd

protected IRandom irnd
The optional IRandom instance to use.

name

protected String name
The canonical name of the protocol.

rnd

protected SecureRandom rnd
The optional SecureRandom instance to use.

step

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

Constructor Details

BaseKeyAgreementParty

protected BaseKeyAgreementParty(String name)

Method Details

engineInit

protected abstract void engineInit(Map attributes)
            throws KeyAgreementException

engineProcessMessage

protected abstract OutgoingMessage engineProcessMessage(IncomingMessage in)
            throws KeyAgreementException

engineReset

protected abstract void engineReset()

engineSharedSecret

protected abstract byte[] engineSharedSecret()
            throws KeyAgreementException

getSharedSecret

public byte[] getSharedSecret()
            throws KeyAgreementException
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.

init

public void init(Map attributes)
            throws KeyAgreementException
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.

isComplete

public boolean isComplete()
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.

name

public String name()
Returns the canonical name of the key agreement protocol.
Specified by:
name in interface IKeyAgreementParty
Returns:
the canonical name of the key agreement protocol.

nextRandomBytes

protected void nextRandomBytes(byte[] buffer)
Fills the designated byte array with random data.
Parameters:
buffer - the byte array to fill with random data.

processMessage

public OutgoingMessage processMessage(IncomingMessage in)
            throws KeyAgreementException
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.

reset

public void reset()
Resets this instance for re-use with another set of attributes.
Specified by:
reset in interface IKeyAgreementParty

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