de.flexiprovider.api
Class KeyAgreement

java.lang.Object
  |
  +--javax.crypto.KeyAgreementSpi
        |
        +--de.flexiprovider.api.KeyAgreement
Direct Known Subclasses:
ECSVDPDHC

public abstract class KeyAgreement
extends javax.crypto.KeyAgreementSpi


Constructor Summary
KeyAgreement()
           
 
Method Summary
abstract  Key doPhase(PublicKey pubKey, boolean lastPhase)
          Execute the next phase of this key agreement with the given public key that was received from one of the other parties involved in this key agreement.
protected  java.security.Key engineDoPhase(java.security.Key key, boolean lastPhase)
          JCA adapter for FlexiAPI method doPhase(PublicKey, boolean): execute the next phase of this key agreement with the given key that was received from one of the other parties involved in this key agreement.
protected  byte[] engineGenerateSecret()
          JCA adapter for FlexiAPI method generateSecret() : generate a shared secret and return it as a byte array.
protected  int engineGenerateSecret(byte[] sharedSecret, int offset)
          JCA adapter for FlexiAPI method generateSecret(byte[], int): generate a shared secret and place it into the buffer sharedSecret, beginning at offset.
protected  javax.crypto.SecretKey engineGenerateSecret(java.lang.String algorithm)
          JCA adapter for FlexiAPI method generateSecret(String): generate a shared secret via the algorithm specified in algorithm.
protected  void engineInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom javaRand)
          JCA adapter for FlexiAPI method init(): initialize this KeyAgreementSpi with a key, algorithm parameters, and a source of randomness.
protected  void engineInit(java.security.Key key, java.security.SecureRandom javaRand)
          JCA adapter for FlexiAPI method init(): initialize this KeyAgreementSpi with a key and a source of randomness.
abstract  byte[] generateSecret()
          Generate a shared secret and return it as a byte array.
abstract  int generateSecret(byte[] sharedSecret, int offset)
          Generate a shared secret and place it into the buffer sharedSecret, beginning at offset.
abstract  SecretKey generateSecret(java.lang.String algorithm)
          Generate a shared secret via the algorithm specified in algorithm.
abstract  void init(PrivateKey privKey, AlgorithmParameterSpec params, SecureRandom random)
          Initialize this key agreement with a private key, algorithm parameters, and a source of randomness.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyAgreement

public KeyAgreement()
Method Detail

engineInit

protected final void engineInit(java.security.Key key,
                                java.security.SecureRandom javaRand)
                         throws java.security.InvalidKeyException
JCA adapter for FlexiAPI method init(): initialize this KeyAgreementSpi with a key and a source of randomness.
Overrides:
engineInit in class javax.crypto.KeyAgreementSpi
Parameters:
key - the secret key of the party initializing the key agreement
javaRand - the source of randomness
Throws:
java.security.InvalidKeyException - if the key is invalid.
java.lang.RuntimeException - if parameters are required for initialization.

engineInit

protected final void engineInit(java.security.Key key,
                                java.security.spec.AlgorithmParameterSpec params,
                                java.security.SecureRandom javaRand)
                         throws java.security.InvalidKeyException,
                                java.security.InvalidAlgorithmParameterException
JCA adapter for FlexiAPI method init(): initialize this KeyAgreementSpi with a key, algorithm parameters, and a source of randomness.
Overrides:
engineInit in class javax.crypto.KeyAgreementSpi
Parameters:
key - the secret key of the party initializing the key agreement
params - the algorithm parameters
javaRand - the source of randomness
Throws:
java.security.InvalidKeyException - if the key is invalid.
java.security.InvalidAlgorithmParameterException - if the parameters are invalid or null and parameters are needed for initialization.

engineGenerateSecret

protected final byte[] engineGenerateSecret()
                                     throws java.lang.IllegalStateException
JCA adapter for FlexiAPI method generateSecret() : generate a shared secret and return it as a byte array.
Overrides:
engineGenerateSecret in class javax.crypto.KeyAgreementSpi
Returns:
the shared secret as byte array.
Throws:
java.lang.IllegalStateException - if the object is not in doPhase.

engineGenerateSecret

protected final int engineGenerateSecret(byte[] sharedSecret,
                                         int offset)
                                  throws java.lang.IllegalStateException,
                                         javax.crypto.ShortBufferException
JCA adapter for FlexiAPI method generateSecret(byte[], int): generate a shared secret and place it into the buffer sharedSecret, beginning at offset.
Overrides:
engineGenerateSecret in class javax.crypto.KeyAgreementSpi
Parameters:
sharedSecret - the buffer to hold the shared secret
offset - the offset in sharedSecret where the shared secret will be stored
Returns:
the number of bytes written in sharedSecret
Throws:
java.lang.IllegalStateException - if the key agreement scheme has not been initialized properly.
javax.crypto.ShortBufferException - if sharedSecret is too small to to hold the shared secret

engineGenerateSecret

protected final javax.crypto.SecretKey engineGenerateSecret(java.lang.String algorithm)
                                                     throws java.lang.IllegalStateException,
                                                            java.security.NoSuchAlgorithmException
JCA adapter for FlexiAPI method generateSecret(String): generate a shared secret via the algorithm specified in algorithm.
Overrides:
engineGenerateSecret in class javax.crypto.KeyAgreementSpi
Parameters:
algorithm - the desired algorithm for the generation of the secret
Returns:
the shared secret
Throws:
java.lang.IllegalStateException - if the key agreement scheme has not been initialized properly.
java.security.NoSuchAlgorithmException - if algorithm is invalid.

engineDoPhase

protected final java.security.Key engineDoPhase(java.security.Key key,
                                                boolean lastPhase)
                                         throws java.security.InvalidKeyException,
                                                java.lang.IllegalStateException
JCA adapter for FlexiAPI method doPhase(PublicKey, boolean): execute the next phase of this key agreement with the given key that was received from one of the other parties involved in this key agreement.
Overrides:
engineDoPhase in class javax.crypto.KeyAgreementSpi
Parameters:
key - the public key of the other party
lastPhase - true if this is the last phase of the key agreement. After the last phase only generateSecret may be called.
Returns:
the shared secret
Throws:
java.lang.IllegalStateException - if the key agreement scheme has not been initialized properly.
java.security.InvalidKeyException - if the key is invalid.

init

public abstract void init(PrivateKey privKey,
                          AlgorithmParameterSpec params,
                          SecureRandom random)
                   throws InvalidKeyException,
                          InvalidAlgorithmParameterException
Initialize this key agreement with a private key, algorithm parameters, and a source of randomness.
Parameters:
privKey - the private key of the party initializing the key agreement
params - the algorithm parameters
random - the source of randomness
Throws:
InvalidKeyException - if the key is invalid.
InvalidAlgorithmParameterException - if the parameters are invalid.

generateSecret

public abstract byte[] generateSecret()
                               throws java.lang.IllegalStateException
Generate a shared secret and return it as a byte array.
Returns:
the shared secret as byte array.
Throws:
java.lang.IllegalStateException - if the key agreement scheme has not been initialized properly.

generateSecret

public abstract int generateSecret(byte[] sharedSecret,
                                   int offset)
                            throws java.lang.IllegalStateException,
                                   ShortBufferException
Generate a shared secret and place it into the buffer sharedSecret, beginning at offset.
Parameters:
sharedSecret - the buffer to hold the shared secret
offset - the offset in sharedSecret where the shared secret will be stored
Returns:
the number of bytes written in sharedSecret
Throws:
java.lang.IllegalStateException - if the key agreement scheme has not been initialized properly.
ShortBufferException - if sharedSecret is too small to to hold the shared secret

generateSecret

public abstract SecretKey generateSecret(java.lang.String algorithm)
                                  throws java.lang.IllegalStateException,
                                         NoSuchAlgorithmException
Generate a shared secret via the algorithm specified in algorithm.
Parameters:
algorithm - the desired algorithm for the generation of the secret
Returns:
the shared secret
Throws:
java.lang.IllegalStateException - if the key agreement scheme has not been initialized properly.
NoSuchAlgorithmException - if algorithm is invalid.

doPhase

public abstract Key doPhase(PublicKey pubKey,
                            boolean lastPhase)
                     throws InvalidKeyException,
                            java.lang.IllegalStateException
Execute the next phase of this key agreement with the given public key that was received from one of the other parties involved in this key agreement.
Parameters:
pubKey - the public key of the other party
lastPhase - true if this is the last phase of the key agreement. After the last phase only generateSecret may be called.
Returns:
the shared secret
Throws:
java.lang.IllegalStateException - if the key agreement scheme has not been initialized properly.
InvalidKeyException - if the key is invalid.