Package org.mozilla.jss.crypto
Class KBKDFParameterSpec
java.lang.Object
org.mozilla.jss.util.NativeEnclosure
org.mozilla.jss.crypto.KBKDFParameterSpec
- All Implemented Interfaces:
AutoCloseable
,AlgorithmParameterSpec
,KeySpec
- Direct Known Subclasses:
KBKDFCounterParams
,KBKDFFeedbackParams
,KBKDFPipelineParams
public abstract class KBKDFParameterSpec
extends NativeEnclosure
implements AlgorithmParameterSpec, KeySpec
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected KBKDFDerivedKey[]
long
int
protected KBKDFDataParameter[]
protected long
Fields inherited from class org.mozilla.jss.util.NativeEnclosure
mPointer, mPointerSize
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Allocate native resources, setting mPointer and mPointerSize as appropriate.protected abstract void
void
addAdditionalDerivedKey
(KBKDFDerivedKey derived_key) Append (to the end) a new derived key.void
addParameter
(KBKDFDataParameter param) Appends (to the end) a new data parameter.protected void
Called to deallocate native resources; note that mPointer.close() is called afterwards.protected abstract void
void
setAdditionalDerivedKeys
(KBKDFDerivedKey[] additional_keys) Set an array of additional derived keys.void
setDerivedKeyAlgorithm
(long algo) Sets the algorithm for the derived key from a PKCS#11 value; see org.mozilla.jss.pkcs11.PKCS11Constants for constant values.void
Set the algorithm for the derived key from a PKCS11Algorithm enum value.void
setKeySize
(int keySize) Set the size of the derived key.void
setParameters
(KBKDFDataParameter[] params) Set parameters for key derivation.void
setPRF
(long prf) Set the underlying pseudo-random function from a PKCS#11 constant; see org.mozilla.jss.pkcs11.PKCS11Constants for permitted values.void
setPRF
(DigestAlgorithm prf) Set the underlying pseudo-random function from a DigestAlgorithm (HMACAlgorithm or CMACAlgorithm) instance.void
setPRF
(PKCS11Algorithm prf) Set the underlying pseudo-random function from a PKCS11Algorithm enum value.void
Set the base key used with the underlying PRF.protected abstract void
Validate all class members prior to acquiring native resources.Methods inherited from class org.mozilla.jss.util.NativeEnclosure
close, finalize, open
-
Field Details
-
prfKey
-
derivedKeyAlgorithm
public long derivedKeyAlgorithm -
keySize
public int keySize -
prf
protected long prf -
params
-
additional_keys
-
-
Constructor Details
-
KBKDFParameterSpec
public KBKDFParameterSpec()
-
-
Method Details
-
setPRF
Set the underlying pseudo-random function from a PKCS11Algorithm enum value.- Throws:
IllegalArgumentException
-
setPRF
Set the underlying pseudo-random function from a DigestAlgorithm (HMACAlgorithm or CMACAlgorithm) instance.- Throws:
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
Set the base key used with the underlying PRF. Must be importable to a JSS SymmetricKey or SecretKeyFacade.- Throws:
InvalidKeyException
-
setDerivedKeyAlgorithm
Set the algorithm for the derived key from a PKCS11Algorithm enum value.- Throws:
IllegalArgumentException
-
setDerivedKeyAlgorithm
Sets the algorithm for the derived key from a PKCS#11 value; see org.mozilla.jss.pkcs11.PKCS11Constants for constant values.- Throws:
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
Set parameters for key derivation. This overwrites all existing parameters. Note that params cannot be NULL.- Throws:
IllegalArgumentException
-
addParameter
Appends (to the end) a new data parameter.- Throws:
IllegalArgumentException
-
setAdditionalDerivedKeys
public void setAdditionalDerivedKeys(KBKDFDerivedKey[] additional_keys) throws IllegalArgumentException Set an array of additional derived keys.- Throws:
IllegalArgumentException
-
addAdditionalDerivedKey
Append (to the end) a new derived key.- Throws:
IllegalArgumentException
-
acquireNativeResources
Description copied from class:NativeEnclosure
Allocate native resources, setting mPointer and mPointerSize as appropriate.- Specified by:
acquireNativeResources
in classNativeEnclosure
- Throws:
Exception
-
releaseNativeResources
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 classNativeEnclosure
- Throws:
Exception
-
acquireNativeResourcesInternal
- Throws:
Exception
-
releaseNativeResourcesInternal
- Throws:
Exception
-
validateParameters
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:
IllegalArgumentException
-