Package org.conscrypt

Class OpenSSLBaseDHKeyAgreement<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int mExpectedResultLength
      Expected length (in bytes) of the agreed key (mResult).
      private T mPrivateKey
      OpenSSL handle of the private key.
      private byte[] mResult
      Agreed key.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      private void checkCompleted()  
      protected abstract int computeKey​(byte[] buffer, T theirPublicKey, T ourPrivateKey)
      Given the public key theirPublicKey and the private key ourPrivateKey write the shared secret to buffer and return the actual output size.
      protected abstract T convertPrivateKey​(java.security.PrivateKey key)  
      protected abstract T convertPublicKey​(java.security.PublicKey key)  
      java.security.Key engineDoPhase​(java.security.Key key, boolean lastPhase)  
      protected byte[] engineGenerateSecret()  
      protected int engineGenerateSecret​(byte[] sharedSecret, int offset)  
      protected javax.crypto.SecretKey engineGenerateSecret​(java.lang.String algorithm)  
      protected void engineInit​(java.security.Key key, java.security.SecureRandom random)  
      protected void engineInit​(java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)  
      protected abstract int getOutputSize​(T key)
      Returns the expected result length for the given key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • mPrivateKey

        private T mPrivateKey
        OpenSSL handle of the private key. Only available after the engine has been initialized.
      • mExpectedResultLength

        private int mExpectedResultLength
        Expected length (in bytes) of the agreed key (mResult). Only available after the engine has been initialized.
    • Constructor Detail

      • OpenSSLBaseDHKeyAgreement

        protected OpenSSLBaseDHKeyAgreement()
    • Method Detail

      • engineDoPhase

        public java.security.Key engineDoPhase​(java.security.Key key,
                                               boolean lastPhase)
                                        throws java.security.InvalidKeyException
        Specified by:
        engineDoPhase in class javax.crypto.KeyAgreementSpi
        Throws:
        java.security.InvalidKeyException
      • convertPublicKey

        protected abstract T convertPublicKey​(java.security.PublicKey key)
                                       throws java.security.InvalidKeyException
        Throws:
        java.security.InvalidKeyException
      • convertPrivateKey

        protected abstract T convertPrivateKey​(java.security.PrivateKey key)
                                        throws java.security.InvalidKeyException
        Throws:
        java.security.InvalidKeyException
      • computeKey

        protected abstract int computeKey​(byte[] buffer,
                                          T theirPublicKey,
                                          T ourPrivateKey)
                                   throws java.security.InvalidKeyException
        Given the public key theirPublicKey and the private key ourPrivateKey write the shared secret to buffer and return the actual output size.
        Throws:
        java.security.InvalidKeyException
      • engineGenerateSecret

        protected int engineGenerateSecret​(byte[] sharedSecret,
                                           int offset)
                                    throws javax.crypto.ShortBufferException
        Specified by:
        engineGenerateSecret in class javax.crypto.KeyAgreementSpi
        Throws:
        javax.crypto.ShortBufferException
      • engineGenerateSecret

        protected byte[] engineGenerateSecret()
        Specified by:
        engineGenerateSecret in class javax.crypto.KeyAgreementSpi
      • engineGenerateSecret

        protected javax.crypto.SecretKey engineGenerateSecret​(java.lang.String algorithm)
        Specified by:
        engineGenerateSecret in class javax.crypto.KeyAgreementSpi
      • engineInit

        protected void engineInit​(java.security.Key key,
                                  java.security.SecureRandom random)
                           throws java.security.InvalidKeyException
        Specified by:
        engineInit in class javax.crypto.KeyAgreementSpi
        Throws:
        java.security.InvalidKeyException
      • getOutputSize

        protected abstract int getOutputSize​(T key)
        Returns the expected result length for the given key.
      • engineInit

        protected void engineInit​(java.security.Key key,
                                  java.security.spec.AlgorithmParameterSpec params,
                                  java.security.SecureRandom random)
                           throws java.security.InvalidKeyException,
                                  java.security.InvalidAlgorithmParameterException
        Specified by:
        engineInit in class javax.crypto.KeyAgreementSpi
        Throws:
        java.security.InvalidKeyException
        java.security.InvalidAlgorithmParameterException
      • checkCompleted

        private void checkCompleted()