Trait tink_core::registry::KeyManager
source · [−]pub trait KeyManager: Send + Sync {
fn primitive(&self, serialized_key: &[u8]) -> Result<Primitive, TinkError>;
fn new_key(
&self,
serialized_key_format: &[u8]
) -> Result<Vec<u8>, TinkError>;
fn type_url(&self) -> &'static str;
fn key_material_type(&self) -> KeyMaterialType;
fn does_support(&self, type_url: &str) -> bool { ... }
fn new_key_data(
&self,
serialized_key_format: &[u8]
) -> Result<KeyData, TinkError> { ... }
fn supports_private_keys(&self) -> bool { ... }
fn public_key_data(
&self,
_serialized_key: &[u8]
) -> Result<KeyData, TinkError> { ... }
}
Expand description
KeyManager
“understands” keys of a specific key types: it can generate keys of a 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 type_url
-field
of KeyData
-protocol buffer.
Required methods
Construct a primitive instance for the key given in serialized_key
, which must be a
serialized key protocol buffer handled by this manager.
Generate a new key according to specification in serialized_key_format
, which must be
supported by this manager, returned as a serialized protocol buffer.
Return the type URL that identifes the key type of keys managed by this key manager.
fn key_material_type(&self) -> KeyMaterialType
fn key_material_type(&self) -> KeyMaterialType
Return the key material type handled by this key manager
Provided methods
fn does_support(&self, type_url: &str) -> bool
fn does_support(&self, type_url: &str) -> bool
Return true iff this KeyManager
supports key type identified by type_url
.
Generate a new KeyData
according to specification in
serialized_key_format
. This should be used solely by the key management API.
fn supports_private_keys(&self) -> bool
fn supports_private_keys(&self) -> bool
Indicate whether this KeyManager
understands private key types.