Interface KeyManager<P>
-
- All Known Subinterfaces:
PrivateKeyManager<P>
- All Known Implementing Classes:
LegacyKeyManagerImpl,PrfBasedDeriverKeyManager
public interface KeyManager<P>A KeyManager "understands" keys of a specific key type: it can generate keys of the supported type and create primitives for supported keys.A key type is identified by the global name of the protocol buffer that holds the corresponding key material, and is given by
typeUrl-field ofKeyData-protocol buffer.The template parameter
Pdenotes the primitive corresponding to the keys handled by this manager.- Since:
- 1.0.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default booleandoesSupport(java.lang.String typeUrl)Deprecated.UsegetKeyType()instead.java.lang.StringgetKeyType()Returns the type URL that identifies the key type of keys managed by this KeyManager.PgetPrimitive(com.google.protobuf.ByteString serializedKey)Constructs an instance of P for the key given inserializedKey, which must be a serialized key protocol buffer handled by this manager.default PgetPrimitive(com.google.protobuf.MessageLite key)Deprecated.UsegetPrimitive(serializedKey)instead.java.lang.Class<P>getPrimitiveClass()Returns the primitive class object of the P.default intgetVersion()Deprecated.Do not use it.default com.google.protobuf.MessageLitenewKey(com.google.protobuf.ByteString serializedKeyFormat)Deprecated.UsenewKeyData(serializedKeyFormat)instead.default com.google.protobuf.MessageLitenewKey(com.google.protobuf.MessageLite keyFormat)Deprecated.UsenewKeyData(serializedKeyFormat)instead.com.google.crypto.tink.proto.KeyDatanewKeyData(com.google.protobuf.ByteString serializedKeyFormat)Generates a newKeyDataaccording to specification inserializedKeyFormat.
-
-
-
Method Detail
-
getPrimitive
P getPrimitive(com.google.protobuf.ByteString serializedKey) throws java.security.GeneralSecurityException
Constructs an instance of P for the key given inserializedKey, which must be a serialized key protocol buffer handled by this manager.For primitives of type
Mac,Aead,PublicKeySign,PublicKeyVerify,DeterministicAead,HybridEncrypt, andHybridDecryptthis should be a primitive which ignores the output prefix and assumes "RAW".- Returns:
- the new constructed P
- Throws:
java.security.GeneralSecurityException- if the key given inserializedKeyis corrupted or not supported
-
getPrimitive
@Deprecated default P getPrimitive(com.google.protobuf.MessageLite key) throws java.security.GeneralSecurityException
Deprecated.UsegetPrimitive(serializedKey)instead.Constructs an instance of P for the key given inkey.For primitives of type
Mac,Aead,PublicKeySign,PublicKeyVerify,DeterministicAead,HybridEncrypt, andHybridDecryptthis should be a primitive which ignores the output prefix and assumes "RAW".This method is not used by Tink. It does not need to be implemented.
- Returns:
- the new constructed P
- Throws:
java.security.GeneralSecurityException- if the key given inkeyis corrupted or not supported
-
newKey
@Deprecated default com.google.protobuf.MessageLite newKey(com.google.protobuf.ByteString serializedKeyFormat) throws java.security.GeneralSecurityExceptionDeprecated.UsenewKeyData(serializedKeyFormat)instead.Generates a new key according to specification inserializedKeyFormat, which must be a serialized key format protocol buffer handled by this manager.This method is not used by Tink anymore. It does not need to be implemented.
- Returns:
- the new generated key
- Throws:
java.security.GeneralSecurityException- if the specified format is wrong or not supported
-
newKey
@Deprecated default com.google.protobuf.MessageLite newKey(com.google.protobuf.MessageLite keyFormat) throws java.security.GeneralSecurityExceptionDeprecated.UsenewKeyData(serializedKeyFormat)instead.Generates a new key according to specification inkeyFormat.This method is only used by
Registry.newKeywhich is deprecated and not used by Tink anymore. This method does not need to be implemented.- Returns:
- the new generated key
- Throws:
java.security.GeneralSecurityException- if the specified format is wrong or not supported
-
doesSupport
@Deprecated default boolean doesSupport(java.lang.String typeUrl)
Deprecated.UsegetKeyType()instead.Returns true iff this KeyManager supports key type identified bytypeUrl.This method is not used by Tink anymore. It does not need to be implemented.
-
getKeyType
java.lang.String getKeyType()
Returns the type URL that identifies the key type of keys managed by this KeyManager.
-
getVersion
@Deprecated default int getVersion()
Deprecated.Do not use it.Returns the version number of this KeyManager.This method is not used by Tink anymore. It does not need to be implemented.
-
getPrimitiveClass
java.lang.Class<P> getPrimitiveClass()
Returns the primitive class object of the P. Should be implemented asreturn P.class;when implementing a key manager for primitive {$code P}.- Returns:
P.class
-
newKeyData
com.google.crypto.tink.proto.KeyData newKeyData(com.google.protobuf.ByteString serializedKeyFormat) throws java.security.GeneralSecurityExceptionGenerates a newKeyDataaccording to specification inserializedKeyFormat.- Returns:
- the new generated key
- Throws:
java.security.GeneralSecurityException- if the specified format is wrong or not supported
-
-