Package com.helixframework.crypto.mac
Class MacKeysetHandleFactory
java.lang.Object
com.helixframework.crypto.mac.MacKeysetHandleFactory
Factory for creating a Tink
KeysetHandle.-
Method Summary
Modifier and TypeMethodDescriptioncom.google.crypto.tink.KeysetHandlecreate()Generates a newKeysetHandle.com.google.crypto.tink.KeysetHandlefromBytes(byte[] keyBytes) Creates aKeysetHandleinstance from the supplied bytes.com.google.crypto.tink.KeysetHandleCreates aKeysetHandleinstance from the supplied JSON string.static MacKeysetHandleFactoryGets the singleton instance ofMacKeysetHandleFactory.byte[]toBytes(com.google.crypto.tink.KeysetHandle keysetHandle) Converts the suppliedKeysetHandleto bytes.toJson(com.google.crypto.tink.KeysetHandle keysetHandle) Converts the suppliedKeysetHandleto a JSON string.
-
Method Details
-
getInstance
Gets the singleton instance ofMacKeysetHandleFactory.- Returns:
- singleton instance of
MacKeysetHandleFactory
-
create
Generates a newKeysetHandle.- Returns:
- a new keyset handle
- Throws:
GeneralSecurityException- if the keyset handle cannot be generated
-
toJson
Converts the suppliedKeysetHandleto a JSON string.- Parameters:
keysetHandle- keyset handle- Returns:
- a json string representation of the keyset handle
- Throws:
IOException- if the keyset handle cannot be converted to json
-
toBytes
Converts the suppliedKeysetHandleto bytes.- Parameters:
keysetHandle- keyset handle- Returns:
- a bytes representation of the keyset handle
- Throws:
IOException- if the keyset handle cannot be converted to json
-
fromBytes
public com.google.crypto.tink.KeysetHandle fromBytes(byte[] keyBytes) throws GeneralSecurityException, IOException Creates aKeysetHandleinstance from the supplied bytes.- Parameters:
keyBytes- key bytes- Returns:
- a
KeysetHandle - Throws:
GeneralSecurityException- if the keyset handle cannot be createdIOException- if there is an issue reading the bytes
-
fromJson
public com.google.crypto.tink.KeysetHandle fromJson(String keyJson) throws GeneralSecurityException, IOException Creates aKeysetHandleinstance from the supplied JSON string.- Parameters:
keyJson- key in JSON format- Returns:
- a
KeysetHandle - Throws:
GeneralSecurityException- if the keyset handle cannot be createdIOException- if there is an issue reading the json
-