pub trait KeyManager: Send + Sync {
// Required methods
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;
// Provided methods
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§
Sourcefn primitive(&self, serialized_key: &[u8]) -> Result<Primitive, TinkError>
fn primitive(&self, serialized_key: &[u8]) -> Result<Primitive, TinkError>
Construct a primitive instance for the key given in serialized_key
, which must be a
serialized key protocol buffer handled by this manager.
Sourcefn new_key(&self, serialized_key_format: &[u8]) -> Result<Vec<u8>, TinkError>
fn new_key(&self, serialized_key_format: &[u8]) -> Result<Vec<u8>, TinkError>
Generate a new key according to specification in serialized_key_format
, which must be
supported by this manager, returned as a serialized protocol buffer.
Sourcefn type_url(&self) -> &'static str
fn type_url(&self) -> &'static str
Return the type URL that identifes the key type of keys managed by this key manager.
Sourcefn key_material_type(&self) -> KeyMaterialType
fn key_material_type(&self) -> KeyMaterialType
Return the key material type handled by this key manager
Provided Methods§
Sourcefn 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
.
Sourcefn new_key_data(
&self,
serialized_key_format: &[u8],
) -> Result<KeyData, TinkError>
fn new_key_data( &self, serialized_key_format: &[u8], ) -> Result<KeyData, TinkError>
Generate a new KeyData
according to specification in
serialized_key_format
. This should be used solely by the key management API.
Sourcefn supports_private_keys(&self) -> bool
fn supports_private_keys(&self) -> bool
Indicate whether this KeyManager
understands private key types.