public final class KeysetHandle extends Object
Keyset, to limit the exposure of actual
protocol buffers that hold sensitive key material.
This class allows reading and writing encrypted keysets. Users that want to read or write can
use the restricted API CleartextKeysetHandle. Users can also load keysets that don't
contain any secret key material with NoSecretKeysetHandle.
| Modifier and Type | Method and Description |
|---|---|
static void |
assertEnoughEncryptedKeyMaterial(EncryptedKeyset keyset)
Validates that an encrypted keyset contains enough key material to build a keyset on.
|
static void |
assertEnoughKeyMaterial(Keyset keyset)
Validates that an keyset handle contains enough key material to build a keyset on.
|
static KeysetHandle |
generateNew(KeyTemplate keyTemplate) |
KeysetInfo |
getKeysetInfo() |
KeysetHandle |
getPublicKeysetHandle()
If the managed keyset contains private keys, returns a
KeysetHandle of the public keys. |
static KeysetHandle |
read(KeysetReader reader,
Aead masterKey)
Tries to create a
KeysetHandle from an encrypted keyset obtained via reader. |
String |
toString()
Extracts and returns the string representation of the
KeysetInfo of the managed keyset. |
void |
write(KeysetWriter keysetWriter,
Aead masterKey)
Serializes, encrypts with
masterKey and writes the keyset to outputStream. |
public KeysetInfo getKeysetInfo()
KeysetInfo that doesn't contain actual key
material.public static final KeysetHandle generateNew(KeyTemplate keyTemplate) throws GeneralSecurityException
KeysetHandle that contains a single fresh key generated according to
keyTemplate.GeneralSecurityExceptionpublic static final KeysetHandle read(KeysetReader reader, Aead masterKey) throws GeneralSecurityException, IOException
KeysetHandle from an encrypted keyset obtained via reader.
Users that need to load cleartext keysets can use CleartextKeysetHandle.
KeysetHandle from encryptedKeysetProto that was encrypted with
masterKeyGeneralSecurityException - if cannot decrypt the keyset or it doesn't contain encrypted
key materialIOExceptionpublic void write(KeysetWriter keysetWriter, Aead masterKey) throws GeneralSecurityException, IOException
masterKey and writes the keyset to outputStream.GeneralSecurityExceptionIOExceptionpublic KeysetHandle getPublicKeysetHandle() throws GeneralSecurityException
KeysetHandle of the public keys.GenernalSecurityException - if the managed keyset is null or if it contains any
non-private keys.GeneralSecurityExceptionpublic String toString()
KeysetInfo of the managed keyset.public static void assertEnoughKeyMaterial(Keyset keyset) throws GeneralSecurityException
GeneralSecurityExceptionpublic static void assertEnoughEncryptedKeyMaterial(EncryptedKeyset keyset) throws GeneralSecurityException
GeneralSecurityException