Class KBKDFParameterSpec

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.security.spec.AlgorithmParameterSpec, java.security.spec.KeySpec
    Direct Known Subclasses:
    KBKDFCounterParams, KBKDFFeedbackParams, KBKDFPipelineParams

    public abstract class KBKDFParameterSpec
    extends NativeEnclosure
    implements java.security.spec.AlgorithmParameterSpec, java.security.spec.KeySpec
    • Field Detail

      • derivedKeyAlgorithm

        public long derivedKeyAlgorithm
      • keySize

        public int keySize
      • prf

        protected long prf
    • Constructor Detail

      • KBKDFParameterSpec

        public KBKDFParameterSpec()
    • Method Detail

      • setPRF

        public void setPRF​(PKCS11Algorithm prf)
                    throws java.lang.IllegalArgumentException
        Set the underlying pseudo-random function from a PKCS11Algorithm enum value.
        Throws:
        java.lang.IllegalArgumentException
      • setPRF

        public void setPRF​(DigestAlgorithm prf)
                    throws java.lang.IllegalArgumentException
        Set the underlying pseudo-random function from a DigestAlgorithm (HMACAlgorithm or CMACAlgorithm) instance.
        Throws:
        java.lang.IllegalArgumentException
      • setPRF

        public void setPRF​(long prf)
        Set the underlying pseudo-random function from a PKCS#11 constant; see org.mozilla.jss.pkcs11.PKCS11Constants for permitted values.
      • setPRFKey

        public void setPRFKey​(javax.crypto.SecretKey key)
                       throws java.security.InvalidKeyException
        Set the base key used with the underlying PRF. Must be importable to a JSS SymmetricKey or SecretKeyFacade.
        Throws:
        java.security.InvalidKeyException
      • setDerivedKeyAlgorithm

        public void setDerivedKeyAlgorithm​(PKCS11Algorithm algo)
                                    throws java.lang.IllegalArgumentException
        Set the algorithm for the derived key from a PKCS11Algorithm enum value.
        Throws:
        java.lang.IllegalArgumentException
      • setDerivedKeyAlgorithm

        public void setDerivedKeyAlgorithm​(long algo)
                                    throws java.lang.IllegalArgumentException
        Sets the algorithm for the derived key from a PKCS#11 value; see org.mozilla.jss.pkcs11.PKCS11Constants for constant values.
        Throws:
        java.lang.IllegalArgumentException
      • setKeySize

        public void setKeySize​(int keySize)
        Set the size of the derived key. If zero, will attempt to use the derived key algorithm's default key size.
      • setParameters

        public void setParameters​(KBKDFDataParameter[] params)
                           throws java.lang.IllegalArgumentException
        Set parameters for key derivation. This overwrites all existing parameters. Note that params cannot be NULL.
        Throws:
        java.lang.IllegalArgumentException
      • addParameter

        public void addParameter​(KBKDFDataParameter param)
                          throws java.lang.IllegalArgumentException
        Appends (to the end) a new data parameter.
        Throws:
        java.lang.IllegalArgumentException
      • setAdditionalDerivedKeys

        public void setAdditionalDerivedKeys​(KBKDFDerivedKey[] additional_keys)
                                      throws java.lang.IllegalArgumentException
        Set an array of additional derived keys.
        Throws:
        java.lang.IllegalArgumentException
      • addAdditionalDerivedKey

        public void addAdditionalDerivedKey​(KBKDFDerivedKey derived_key)
                                     throws java.lang.IllegalArgumentException
        Append (to the end) a new derived key.
        Throws:
        java.lang.IllegalArgumentException
      • acquireNativeResources

        protected void acquireNativeResources()
                                       throws java.lang.Exception
        Description copied from class: NativeEnclosure
        Allocate native resources, setting mPointer and mPointerSize as appropriate.
        Specified by:
        acquireNativeResources in class NativeEnclosure
        Throws:
        java.lang.Exception
      • releaseNativeResources

        protected void releaseNativeResources()
                                       throws java.lang.Exception
        Description copied from class: NativeEnclosure
        Called to deallocate native resources; note that mPointer.close() is called afterwards. If mPointer.close() should be a no-op, extend from StaticVoidRef and do any required cleanup here.
        Specified by:
        releaseNativeResources in class NativeEnclosure
        Throws:
        java.lang.Exception
      • acquireNativeResourcesInternal

        protected abstract void acquireNativeResourcesInternal()
                                                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • releaseNativeResourcesInternal

        protected abstract void releaseNativeResourcesInternal()
                                                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • validateParameters

        protected abstract void validateParameters()
                                            throws java.lang.IllegalArgumentException
        Validate all class members prior to acquiring native resources. This is implemented by the derived KBKDF modes in an effort to give useful exceptions before derivation, instead of vague errors during derivation.
        Throws:
        java.lang.IllegalArgumentException