Struct optee_utee::crypto_op::Digest [−][src]
pub struct Digest(_);
Expand description
An operation for digest the message.
Implementations
Accumulate message data for hashing. The message does not have to be block aligned. Subsequent calls to this function are possible. The operation may be in either initial or active state and becomes active.
Parameters
chunk
: Chunk of data to be hashed
Panics
- If the operation is not allocated with valid algorithms.
- if input data exceeds maximum length for algorithm.
- Hardware or cryptographic algorithm failure.
- If the Implementation detects any other error.
Finalize the message digest operation and produces the message hash. Afterwards the Message Digest operation is reset to initial state and can be reused.
Parameters
chunk
: Last chunk of data to be hashed.hash
: Output buffer filled with the message hash. This buffer should be large enough to hold the hash message. The real used size is returned by this function.
Example
let chunk = [0u8;8];
let chunk = [1u8;8];
let hash = [0u8;32];
match Digest::allocate(AlgorithmId::Sha256) {
Ok(operation) =>
{
operation.update(&chunk1);
match operation.do_final(&chunk2, hash) {
Ok(hash_len) => {
// ...
Ok(())
}
Err(e) => Err(e),
}
}
Err(e) => Err(e),
}
Errors
ShortBuffer
: If thehash
is too small. Operation is not finalized for this error.
Panics
- If the operation is not allocated with valid algorithms.
- if input data exceeds maximum length for algorithm.
- Hardware or cryptographic algorithm failure.
- If the Implementation detects any other error.
Allocate a new cryptographic operation and sets the mode and algorithm type.
Parameters
algo
: One of the algorithms that support Digest as listed in AlgorithmId.max_key_size
: The maximum key sizes of different algorithms as defined in TransientObjectType.
Example
match Digest::allocate(AlgorithmId::Sha256) {
Ok(operation) =>
{
// ...
Ok(())
}
Err(e) => Err(e),
}
Errors
OutOfMemory
: If not enough resources are available to allocate the object handle.NotSupported
: If the key size is not supported or the object type is not supported.
Panics
- If the Implementation detects any error associated with this function which is not explicitly associated with a defined return code for this function.
Return the characteristics of a Digest operation with multiple keys.
Parameters
info_buf
: The buffer is supposed to save multiple keys, and its size should be large enough before passed in. The number of keys about this operation can be calculated as: OperationInfoMultiple::size - size_of(OperationInfoMultiple) / size_of ( raw::TEE_OperationInfoKey)+1.
Example
match Digest::allocate(AlgorithmId::Md5, 128) {
Ok(operation) =>
{
let mut buffer = [0u32, 12];
match operation.info_multiple(&mut buffer) {
Ok(info_multiple) => {
// ...
Ok(())
}
Err(e) => Err(e),
}
}
Err(e) => Err(e),
}
Errors:
ShortBuffer
: If theinfo_buf
is not large enough to hold an OperationInfoMultiple and the corresponding keys.
Panics:
- If operation is not a valid opened object.
- If the Implementation detects any other error.
Reset the operation state to the state after initial allocate with the add addition of any keys which were configured subsequent to this so that current operation can be reused with the same keys.
Panics
- If operation is not a valid opened object.
- If the key has not been set yet.
- Hardware or cryptographic algorithm failure.
- If the Implementation detects any other error.
Copy an operation state to another operation. This also copies the key material associated with the source operation.
Parameters
src
: the source operation. 1.1) Ifsrc
has no key programmed, then the key of this operation is cleared. If there is a key programmed in srcOperation, then the maximum key size of current SHALL be greater than or equal to the actual key size of src.
Example
match Digest::allocate(AlgorithmId::Sha256) {
Ok(operation) =>
{
match Digest::allocate(AlgorithmId::Sha256) {
Ok(operation2) =>
{
// ...
operation.copy(operation2);
Ok(())
}
Err(e) => Err(e),
}
}
Err(e) => Err(e),
}
Panics
- If the operation or source operation is not a valid opened operation.
- If the alogirhtm or mode differe in two perations.
- If
src
has akey and its size is greater than the maximum key size of the operation. - Hardware or cryptographic algorithm failure.
- If the Implementation detects any other error.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Digest
impl !Send for Digest
impl !Sync for Digest
impl Unpin for Digest
impl UnwindSafe for Digest
Blanket Implementations
pub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
pub fn from(t: T) -> T
pub fn from(t: T) -> T
Performs the conversion.
pub fn into(self) -> U
pub fn into(self) -> U
Performs the conversion.