Description

Provides cryptographic hash functions (SHA-1, SHA-224, SHA-256, SHA-384, SHA-512).

Provides API for one-way hashing functions.

Data Structures

struct sl_se_sha1_multipart_context_t
SHA-1 streaming context.
struct sl_se_sha224_multipart_context_t
SHA-224 streaming context.
struct sl_se_sha256_multipart_context_t
SHA-256 streaming context.
struct sl_se_sha384_multipart_context_t
SHA-384 streaming context.
struct sl_se_sha512_multipart_context_t
SHA-512 streaming context.

Functions

sl_status_t sl_se_hash ( sl_se_command_context_t *cmd_ctx, sl_se_hash_type_t hash_type, const uint8_t *message, unsigned int message_size, uint8_t *digest, size_t digest_len)
Produce a message digest (a hash block) using the input data.
sl_status_t sl_se_hash_sha1_multipart_starts ( sl_se_sha1_multipart_context_t *sha1_ctx, sl_se_command_context_t *cmd_ctx)
Prepare a SHA1 hash streaming command context object.
sl_status_t sl_se_hash_sha224_multipart_starts ( sl_se_sha224_multipart_context_t *sha224_ctx, sl_se_command_context_t *cmd_ctx)
Prepare a SHA224 hash streaming command context object.
sl_status_t sl_se_hash_sha256_multipart_starts ( sl_se_sha256_multipart_context_t *sha256_ctx, sl_se_command_context_t *cmd_ctx)
Prepare a SHA256 hash streaming command context object.
sl_status_t sl_se_hash_sha384_multipart_starts ( sl_se_sha384_multipart_context_t *sha384_ctx, sl_se_command_context_t *cmd_ctx)
Prepare a SHA384 streaming command context object.
sl_status_t sl_se_hash_sha512_multipart_starts ( sl_se_sha512_multipart_context_t *sha512_ctx, sl_se_command_context_t *cmd_ctx)
Prepare a SHA512 streaming command context object.
sl_status_t sl_se_hash_multipart_starts (void *hash_type_ctx, sl_se_command_context_t *cmd_ctx, sl_se_hash_type_t hash_type)
Prepare a hash streaming command context object.
sl_status_t sl_se_hash_multipart_update (void *hash_type_ctx, sl_se_command_context_t *cmd_ctx, const uint8_t *input, size_t input_len)
Feeds an input buffer into an ongoing hash computation.
sl_status_t sl_se_hash_multipart_finish (void *hash_type_ctx, sl_se_command_context_t *cmd_ctx, uint8_t *digest_out, size_t digest_len)
Finish a hash streaming operation and return the resulting hash digest.

Macros

#define SL_SE_HASH_STREAMING_INIT_DEFAULT { NULL, 0, 0, NULL }
Default streaming hash context.
#define SL_SE_SHA1_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }
SHA1 streaming hash context.
#define SL_SE_SHA224_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }
SHA224 streaming hash context.
#define SL_SE_SHA256_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }
SHA256 streaming hash context.
#define SL_SE_SHA384_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }
SHA384 streaming hash context.
#define SL_SE_SHA512_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }
SHA512 streaming hash context.

Enumerations

enum sl_se_hash_type_t {
SL_SE_HASH_NONE ,
SL_SE_HASH_SHA1 ,
SL_SE_HASH_SHA224 ,
SL_SE_HASH_SHA256 ,
SL_SE_HASH_SHA384 ,
SL_SE_HASH_SHA512
}
Hash algorithms.

Function Documentation

sl_se_hash()

sl_status_t sl_se_hash ( sl_se_command_context_t * cmd_ctx,
sl_se_hash_type_t hash_type,
const uint8_t * message,
unsigned int message_size,
uint8_t * digest,
size_t digest_len
)

Produce a message digest (a hash block) using the input data.

This function generates a message digest adhering to the given inputs. For instance, if the algorithm is chosen to be SHA-256, it will generate a 32 bytes message digest computed based on the input message. This function supports SHA-1, SHA-256 and SHA-512 algorithms.

Parameters
[in] cmd_ctx Pointer to an SE command context object.
[in] hash_type Which hashing algorithm to use.
[in] message Pointer to the message buffer to compute the hash/digest from.
[in] message_size Number of bytes in message.
[out] digest Pointer to block of memory to store the final digest.
[in] digest_len The length of the message digest (hash), must be at least the size of the corresponding hash type.
Returns
Status code, sl_status.h.

sl_se_hash_sha1_multipart_starts()

sl_status_t sl_se_hash_sha1_multipart_starts ( sl_se_sha1_multipart_context_t * sha1_ctx,
sl_se_command_context_t * cmd_ctx
)

Prepare a SHA1 hash streaming command context object.

Prepare a SHA1 hash streaming command context object to be used in subsequent calls to hash streaming functions sl_se_hash_multipart_update() and sl_se_hash_multipart_finish() .

Parameters
[in] sha1_ctx Pointer to a SHA1 streaming context object.
[in] cmd_ctx Pointer to an SE command context object.
Returns
Status code, sl_status.h.

sl_se_hash_sha224_multipart_starts()

sl_status_t sl_se_hash_sha224_multipart_starts ( sl_se_sha224_multipart_context_t * sha224_ctx,
sl_se_command_context_t * cmd_ctx
)

Prepare a SHA224 hash streaming command context object.

Prepare a SHA224 hash streaming command context object to be used in subsequent calls to hash streaming functions sl_se_hash_multipart_update() and sl_se_hash_multipart_finish() .

Parameters
[in] sha224_ctx Pointer to a SHA224 streaming context object.
[in] cmd_ctx Pointer to an SE command context object.
Returns
Status code, sl_status.h.

sl_se_hash_sha256_multipart_starts()

sl_status_t sl_se_hash_sha256_multipart_starts ( sl_se_sha256_multipart_context_t * sha256_ctx,
sl_se_command_context_t * cmd_ctx
)

Prepare a SHA256 hash streaming command context object.

Prepare a SHA256 hash streaming command context object to be used in subsequent calls to hash streaming functions sl_se_hash_multipart_update() and sl_se_hash_multipart_finish() .

Parameters
[in] sha256_ctx Pointer to a SHA256 streaming context object.
[in] cmd_ctx Pointer to an SE command context object.
Returns
Status code, sl_status.h.

sl_se_hash_sha384_multipart_starts()

sl_status_t sl_se_hash_sha384_multipart_starts ( sl_se_sha384_multipart_context_t * sha384_ctx,
sl_se_command_context_t * cmd_ctx
)

Prepare a SHA384 streaming command context object.

Prepare a SHA384 hash streaming command context object to be used in subsequent calls to hash streaming functions sl_se_hash_multipart_update() and sl_se_hash_multipart_finish() .

Parameters
[in] sha384_ctx Pointer to a SHA384 streaming context object.
[in] cmd_ctx Pointer to an SE command context object.
Returns
Status code, sl_status.h.

sl_se_hash_sha512_multipart_starts()

sl_status_t sl_se_hash_sha512_multipart_starts ( sl_se_sha512_multipart_context_t * sha512_ctx,
sl_se_command_context_t * cmd_ctx
)

Prepare a SHA512 streaming command context object.

Prepare a SHA512 hash streaming command context object to be used in subsequent calls to hash streaming functions sl_se_hash_multipart_update() and sl_se_hash_multipart_finish() .

Parameters
[in] sha512_ctx Pointer to a SHA512 streaming context object.
[in] cmd_ctx Pointer to an SE command context object.
Returns
Status code, sl_status.h.

sl_se_hash_multipart_starts()

sl_status_t sl_se_hash_multipart_starts ( void * hash_type_ctx,
sl_se_command_context_t * cmd_ctx,
sl_se_hash_type_t hash_type
)

Prepare a hash streaming command context object.

Prepare a hash (message digest) streaming command context object to be used in subsequent calls to hash streaming functions sl_se_hash_multipart_update() and sl_se_hash_multipart_finish() .

Parameters
[in] hash_type_ctx Pointer to a hash streaming context object specific to the hash type specified by hash_type .
[in] cmd_ctx Pointer to an SE command context object.
[in] hash_type Type of hash algoritm
Returns
Status code, sl_status.h.

sl_se_hash_multipart_update()

sl_status_t sl_se_hash_multipart_update ( void * hash_type_ctx,
sl_se_command_context_t * cmd_ctx,
const uint8_t * input,
size_t input_len
)

Feeds an input buffer into an ongoing hash computation.

This function is called between sl_se_hash_multipart_starts() and sl_se_hash_multipart_finish() . This function can be called repeatedly.

Parameters
[in] hash_type_ctx Pointer to a hash streaming context object specific to the hash type specified by hash_type .
[in] cmd_ctx Pointer to an SE command context object.
[in] input Buffer holding the input data, must be at least ilen bytes wide.
[in] input_len The length of the input data in bytes.
Returns
Status code, sl_status.h.

sl_se_hash_multipart_finish()

sl_status_t sl_se_hash_multipart_finish ( void * hash_type_ctx,
sl_se_command_context_t * cmd_ctx,
uint8_t * digest_out,
size_t digest_len
)

Finish a hash streaming operation and return the resulting hash digest.

This function is called after sl_se_hash_multipart_update() .

Parameters
[in] hash_type_ctx Pointer to a hash streaming context object specific to the hash type specified by hash_type .
[in] cmd_ctx Pointer to an SE command context object.
[out] digest_out Buffer for holding the message digest (hash), must be at least the size of the corresponding message digest type.
[in] digest_len The length of the message digest (hash), must be at least the size of the corresponding hash type.
Returns
Status code, sl_status.h.

Macro Definition Documentation

SL_SE_HASH_STREAMING_INIT_DEFAULT

#define SL_SE_HASH_STREAMING_INIT_DEFAULT   { NULL, 0, 0, NULL }

Default streaming hash context.

SL_SE_SHA1_STREAMING_INIT_DEFAULT

#define SL_SE_SHA1_STREAMING_INIT_DEFAULT   { { 0 }, { 0 }, { 0 } }

SHA1 streaming hash context.

SL_SE_SHA224_STREAMING_INIT_DEFAULT

#define SL_SE_SHA224_STREAMING_INIT_DEFAULT   { { 0 }, { 0 }, { 0 } }

SHA224 streaming hash context.

SL_SE_SHA256_STREAMING_INIT_DEFAULT

#define SL_SE_SHA256_STREAMING_INIT_DEFAULT   { { 0 }, { 0 }, { 0 } }

SHA256 streaming hash context.

SL_SE_SHA384_STREAMING_INIT_DEFAULT

#define SL_SE_SHA384_STREAMING_INIT_DEFAULT   { { 0 }, { 0 }, { 0 } }

SHA384 streaming hash context.

SL_SE_SHA512_STREAMING_INIT_DEFAULT

#define SL_SE_SHA512_STREAMING_INIT_DEFAULT   { { 0 }, { 0 }, { 0 } }

SHA512 streaming hash context.

Enumeration Type Documentation

sl_se_hash_type_t

Hash algorithms.

Enumerator
SL_SE_HASH_NONE

No hash.

SL_SE_HASH_SHA1

SHA-1.

SL_SE_HASH_SHA224

SHA-224.

SL_SE_HASH_SHA256

SHA-256.

SL_SE_HASH_SHA384

SHA-384.

SL_SE_HASH_SHA512

SHA-512.