Struct sgx_tcrypto::SgxShaHandle[][src]

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]

Constructs a new, empty SgxShaHandle.

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.

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.

update_slice performs a SHA256 hash over the input dataset provided.

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.

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]

Returns the "default value" for a type. Read more

impl Drop for SgxShaHandle
[src]

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

Auto Trait Implementations

impl !Send for SgxShaHandle

impl !Sync for SgxShaHandle