Package javax.crypto

Class KeyAgreementSpi

    • Constructor Detail

      • KeyAgreementSpi

        public KeyAgreementSpi()
        Creates a new KeyAgreementSpi instance.
    • Method Detail

      • engineDoPhase

        protected abstract Key engineDoPhase​(Key key,
                                             boolean lastPhase)
                                      throws InvalidKeyException,
                                             IllegalStateException
        Does the next (or the last) phase of the key agreement, using the specified key.
        Parameters:
        key - the key received from the other party for this phase.
        lastPhase - set to true if this is the last phase of this key agreement.
        Returns:
        the intermediate key from this phase or null if there is no intermediate key for this phase.
        Throws:
        InvalidKeyException - if the specified key cannot be used in this key agreement or this phase,
        IllegalStateException - if this instance has not been initialized.
      • engineGenerateSecret

        protected abstract byte[] engineGenerateSecret()
                                                throws IllegalStateException
        Generates the shared secret.
        Returns:
        the generated shared secret.
        Throws:
        IllegalStateException - if this key agreement is not complete.
      • engineGenerateSecret

        protected abstract int engineGenerateSecret​(byte[] sharedSecret,
                                                    int offset)
                                             throws IllegalStateException,
                                                    ShortBufferException
        Generates the shared secret and stores it into the buffer sharedSecred at offset.
        Parameters:
        sharedSecret - the buffer to store the shared secret.
        offset - the offset in the buffer.
        Returns:
        the number of bytes stored in the buffer.
        Throws:
        IllegalStateException - if this key agreement is not complete.
        ShortBufferException - if the specified buffer is too small for the shared secret.
      • engineInit

        protected abstract void engineInit​(Key key,
                                           SecureRandom random)
                                    throws InvalidKeyException
        Initializes this KeyAgreementSpi with the specified key and the specified randomness source.
        Parameters:
        key - the key to initialize this key agreement.
        random - the source for any randomness needed.
        Throws:
        InvalidKeyException - if the specified key cannot be used to initialize this key agreement.