[][src]Struct sgx_tcrypto::SgxShaHandle

pub struct SgxShaHandle { /* fields omitted */ }

SHA algorithm context state.

This is a handle to the context state used by the cryptography library to perform an iterative SHA256 hash. The algorithm stores the intermediate results of performing the hash calculation over data sets.

Methods

impl SgxShaHandle[src]

pub fn new() -> Self[src]

Constructs a new, empty SgxShaHandle.

pub fn init(&self) -> SgxError[src]

init returns an allocated and initialized SHA algorithm context state.

This should be part of the Init, Update … Update, Final process when the SHA hash is to be performed over multiple datasets. If a complete dataset is available, the recommend call is rsgx_sha256_msg to perform the hash in a single call.

Description

Calling init is the first set in performing a SHA256 hash over multiple datasets. The caller does not allocate memory for the SHA256 state that this function returns. The state is specific to the implementation of the cryptography library; thus the allocation is performed by the library itself. If the hash over the desired datasets is completed or any error occurs during the hash calculation process, sgx_sha256_close should be called to free the state allocated by this algorithm.

Requirements

Library: libsgx_tcrypto.a

Errors

SGX_ERROR_INVALID_PARAMETER

The pointer is invalid.

SGX_ERROR_OUT_OF_MEMORY

Not enough memory is available to complete this operation.

SGX_ERROR_UNEXPECTED

The SHA256 state is not initialized properly due to an internal cryptography library failure.

pub fn update_msg<T>(&self, src: &T) -> SgxError where
    T: Copy + ContiguousMemory
[src]

update_msg performs a SHA256 hash over the input dataset provided.

This function supports an iterative calculation of the hash over multiple datasets where the sha_handle contains the intermediate results of the hash calculation over previous datasets.

Description

This function should be used as part of a SHA256 calculation over multiple datasets. If a SHA256 hash is needed over a single data set, function rsgx_sha256_msg should be used instead. Prior to calling this function on the first dataset, the init function must be called first to allocate and initialize the SHA256 state structure which will hold intermediate hash results over earlier datasets. The function get_hash should be used to obtain the hash after the final dataset has been processed by this function.

Parameters

src

A pointer to the input data stream to be hashed.

Requirements

Library: libsgx_tcrypto.a

Errors

SGX_ERROR_INVALID_PARAMETER

The pointer is invalid.

SGX_ERROR_INVALID_STATE

The SHA256 state is not initialized.

SGX_ERROR_UNEXPECTED

An internal cryptography library failure occurred while performing the SHA256 hash calculation.

pub fn update_slice<T>(&self, src: &[T]) -> SgxError where
    T: Copy + ContiguousMemory
[src]

update_slice performs a SHA256 hash over the input dataset provided.

pub fn get_hash(&self) -> SgxResult<sgx_sha256_hash_t>[src]

get_hash obtains the SHA256 hash after the final dataset has been processed.

Description

This function returns the hash after performing the SHA256 calculation over one or more datasets using the update function.

Requirements

Library: libsgx_tcrypto.a

Return value

The 256-bit hash that has been SHA256 calculated

Errors

SGX_ERROR_INVALID_PARAMETER

The pointer is invalid.

SGX_ERROR_INVALID_STATE

The SHA256 state is not initialized.

SGX_ERROR_UNEXPECTED

The SHA256 state passed in is likely problematic causing an internal cryptography library failure.

pub fn close(&self) -> SgxError[src]

close cleans up and deallocates the SHA256 state that was allocated in function init.

Description

Calling close is the last step after performing a SHA256 hash over multiple datasets. The caller uses this function to deallocate memory used to store the SHA256 calculation state.

Requirements

Library: libsgx_tcrypto.a

Errors

SGX_ERROR_INVALID_PARAMETER

The input handle is invalid.

Trait Implementations

impl Default for SgxShaHandle[src]

impl Drop for SgxShaHandle[src]

fn drop(&mut self)[src]

drop cleans up and deallocates the SHA256 state that was allocated in function init.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.