Class WfEncryptionKey
java.lang.Object
org.whiteflagprotocol.java.crypto.WfEncryptionKey
- All Implemented Interfaces:
Destroyable
Whiteflag encryption key class
This class represents a Whiteflag encryption key. Instances of this class represent the raw key, either pre-shared or negotiated, from which the actual key material for encryption methods 1 and 2 is created.
- Since:
- 1.1
- Whiteflag version:
- v1-draft.6
- Whiteflag standard x-reference:
- 5.2.3 Key and Token Derivation, 5.2.4 Message Encryption
-
Field Summary
Modifier and TypeFieldDescriptionfinal WfEncryptionMethod
The encryption method for which this key is valid -
Constructor Summary
ConstructorDescriptionWfEncryptionKey
(byte[] rawPreSharedKey) Constructs a new Whiteflag encryption key from a raw pre-shared keyWfEncryptionKey
(byte[] rawPublicKey, WfECDHKeyPair ecdhKeyPair) Constructs a new Whiteflag encryption key through ECDH key negotiationWfEncryptionKey
(String rawPreSharedKey) Constructs a new Whiteflag encryption key from a raw pre-shared keyWfEncryptionKey
(String rawPublicKey, WfECDHKeyPair ecdhKeyPair) Constructs a new Whiteflag encryption key through ECDH key negotiationWfEncryptionKey
(ECPublicKey ecPublicKey, WfECDHKeyPair ecdhKeyPair) Constructs a new Whiteflag encryption key through ECDH key negotiation -
Method Summary
Modifier and TypeMethodDescriptionfinal void
destroy()
Destroys this Whiteflag cipher by clearing the encryption keyfinal WfEncryptionMethod
Returns the encryption methodfinal SecretKey
getSecretKey
(byte[] context) Derive the secret cryptographic key from this Whiteflag encryption keyfinal SecretKey
getSecretKey
(String context) Derive the secret cryptographic key from this Whiteflag encryption keyfinal boolean
Determine if this Whiteflag cipher has been destroyed.
-
Field Details
-
method
The encryption method for which this key is valid
-
-
Constructor Details
-
WfEncryptionKey
Constructs a new Whiteflag encryption key from a raw pre-shared key- Parameters:
rawPreSharedKey
- a hexadecimal string with the raw pre-shared encryption key
-
WfEncryptionKey
public WfEncryptionKey(byte[] rawPreSharedKey) Constructs a new Whiteflag encryption key from a raw pre-shared key- Parameters:
rawPreSharedKey
- a byte array with the raw pre-shared encryption key
-
WfEncryptionKey
Constructs a new Whiteflag encryption key through ECDH key negotiation- Parameters:
rawPublicKey
- a hexadecimal string with an originator's raw 264-bit compressed public ECDH keyecdhKeyPair
- the own ECDH key pair object- Throws:
WfCryptoException
- if the encryption key cannot be createdIllegalStateException
- if the key pair has been destroyed
-
WfEncryptionKey
Constructs a new Whiteflag encryption key through ECDH key negotiation- Parameters:
rawPublicKey
- a byte array with an originator's raw 264-bit compressed public ECDH keyecdhKeyPair
- the own ECDH key pair object- Throws:
WfCryptoException
- if the encryption key cannot be createdIllegalStateException
- if the key pair has been destroyed
-
WfEncryptionKey
Constructs a new Whiteflag encryption key through ECDH key negotiation- Parameters:
ecPublicKey
- a ECDH public keyecdhKeyPair
- the own ECDH key pair object- Throws:
WfCryptoException
- if the encryption key cannot be createdIllegalStateException
- if the key pair has been destroyed
-
-
Method Details
-
destroy
public final void destroy()Destroys this Whiteflag cipher by clearing the encryption key- Specified by:
destroy
in interfaceDestroyable
-
isDestroyed
public final boolean isDestroyed()Determine if this Whiteflag cipher has been destroyed.- Specified by:
isDestroyed
in interfaceDestroyable
- Returns:
- TRUE if destroyed, else FALSE
-
getEncryptionMethod
Returns the encryption method- Returns:
- a string with the encryption method indicator
-
getSecretKey
Derive the secret cryptographic key from this Whiteflag encryption key- Parameters:
context
- a hexadecimal string with information to bind the derived key to the intended context- Returns:
- a java SecretKey object with the secret cryptographic key
- Throws:
IllegalArgumentException
- if the encryption key has been destroyed
-
getSecretKey
Derive the secret cryptographic key from this Whiteflag encryption key- Parameters:
context
- a byte array with information to bind the derived key to the intended context- Returns:
- a java SecretKey object with the secret cryptographic key
- Throws:
IllegalArgumentException
- if the encryption key has been destroyed
-