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_hash_streaming_context_t
 Generic hash streaming context. Deprecated.
 
struct  sl_se_sha1_multipart_context_t
 SHA-1 streaming context. Safe to use.
 
struct  sl_se_sha1_streaming_context_t
 SHA-1 streaming context. Deprecated.
 
struct  sl_se_sha224_multipart_context_t
 SHA-224 streaming context. Safe to use.
 
struct  sl_se_sha224_streaming_context_t
 SHA-224 streaming context. Deprecated.
 
struct  sl_se_sha256_multipart_context_t
 SHA-256 streaming context. Safe to use.
 
struct  sl_se_sha256_streaming_context_t
 SHA-256 streaming context. Deprecated.
 
struct  sl_se_sha384_multipart_context_t
 SHA-384 streaming context. Safe to use.
 
struct  sl_se_sha384_streaming_context_t
 SHA-384 streaming context. Deprecated.
 
struct  sl_se_sha512_multipart_context_t
 SHA-512 streaming context. Safe to use.
 
struct  sl_se_sha512_streaming_context_t
 SHA-512 streaming context. Deprecated.
 

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_sha1_starts (sl_se_hash_streaming_context_t *hash_ctx, sl_se_command_context_t *cmd_ctx, sl_se_sha1_streaming_context_t *sha1_ctx) SL_DEPRECATED_API_SDK_3_3
 Deprecated, please switch to using sl_se_hash1_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.
 
sl_status_t sl_se_hash_sha224_starts (sl_se_hash_streaming_context_t *hash_ctx, sl_se_command_context_t *cmd_ctx, sl_se_sha224_streaming_context_t *sha224_ctx) SL_DEPRECATED_API_SDK_3_3
 Deprecated, please switch to using sl_se_hash224_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.
 
sl_status_t sl_se_hash_sha256_starts (sl_se_hash_streaming_context_t *hash_ctx, sl_se_command_context_t *cmd_ctx, sl_se_sha256_streaming_context_t *sha256_ctx) SL_DEPRECATED_API_SDK_3_3
 Deprecated, please switch to using sl_se_hash256_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.
 
sl_status_t sl_se_hash_sha384_starts (sl_se_hash_streaming_context_t *hash_ctx, sl_se_command_context_t *cmd_ctx, sl_se_sha384_streaming_context_t *sha384_ctx) SL_DEPRECATED_API_SDK_3_3
 Deprecated, please switch to using sl_se_hash384_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.
 
sl_status_t sl_se_hash_sha512_starts (sl_se_hash_streaming_context_t *hash_ctx, sl_se_command_context_t *cmd_ctx, sl_se_sha512_streaming_context_t *sha512_ctx) SL_DEPRECATED_API_SDK_3_3
 Deprecated, please switch to using sl_se_hash512_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.
 
sl_status_t sl_se_hash_starts (sl_se_hash_streaming_context_t *hash_ctx, sl_se_command_context_t *cmd_ctx, sl_se_hash_type_t hash_type, void *hash_type_ctx) SL_DEPRECATED_API_SDK_3_3
 Deprecated, please switch to using sl_se_hash_multipart_starts().
 
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_update (sl_se_hash_streaming_context_t *hash_ctx, const uint8_t *input, size_t input_len) SL_DEPRECATED_API_SDK_3_3
 Deprecated, please switch to using sl_se_hash_multipart_update().
 
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.
 
sl_status_t sl_se_hash_finish (sl_se_hash_streaming_context_t *hash_ctx, uint8_t *digest_out, size_t digest_len) SL_DEPRECATED_API_SDK_3_3
 Deprecated, please switch to using sl_se_hash_multipart_finish().
 

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_ctxPointer to an SE command context object.
[in]hash_typeWhich hashing algorithm to use.
[in]messagePointer to the message buffer to compute the hash/digest from.
[in]message_sizeNumber of bytes in message.
[out]digestPointer to block of memory to store the final digest.
[in]digest_lenThe 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_ctxPointer to a SHA1 streaming context object.
[in]cmd_ctxPointer to an SE command context object.
Returns
Status code, sl_status.h.

◆ sl_se_hash_sha1_starts()

sl_status_t sl_se_hash_sha1_starts ( sl_se_hash_streaming_context_t hash_ctx,
sl_se_command_context_t cmd_ctx,
sl_se_sha1_streaming_context_t sha1_ctx 
)

Deprecated, please switch to using sl_se_hash1_multipart_starts().

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_update() and sl_se_hash_finish().

Parameters
[in]hash_ctxPointer to a generic hash streaming context object.
[in]cmd_ctxPointer to an SE command context object.
[in]sha1_ctxPointer to a SHA1 streaming 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_ctxPointer to a SHA224 streaming context object.
[in]cmd_ctxPointer to an SE command context object.
Returns
Status code, sl_status.h.

◆ sl_se_hash_sha224_starts()

sl_status_t sl_se_hash_sha224_starts ( sl_se_hash_streaming_context_t hash_ctx,
sl_se_command_context_t cmd_ctx,
sl_se_sha224_streaming_context_t sha224_ctx 
)

Deprecated, please switch to using sl_se_hash224_multipart_starts().

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_update() and sl_se_hash_finish().

Parameters
[in]hash_ctxPointer to a generic hash streaming context object.
[in]cmd_ctxPointer to an SE command context object.
[in]sha224_ctxPointer to a SHA224 streaming 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_ctxPointer to a SHA256 streaming context object.
[in]cmd_ctxPointer to an SE command context object.
Returns
Status code, sl_status.h.

◆ sl_se_hash_sha256_starts()

sl_status_t sl_se_hash_sha256_starts ( sl_se_hash_streaming_context_t hash_ctx,
sl_se_command_context_t cmd_ctx,
sl_se_sha256_streaming_context_t sha256_ctx 
)

Deprecated, please switch to using sl_se_hash256_multipart_starts().

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_update() and sl_se_hash_finish().

Parameters
[in]hash_ctxPointer to a generic hash streaming context object.
[in]cmd_ctxPointer to an SE command context object.
[in]sha256_ctxPointer to a SHA256 streaming 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_ctxPointer to a SHA384 streaming context object.
[in]cmd_ctxPointer to an SE command context object.
Returns
Status code, sl_status.h.

◆ sl_se_hash_sha384_starts()

sl_status_t sl_se_hash_sha384_starts ( sl_se_hash_streaming_context_t hash_ctx,
sl_se_command_context_t cmd_ctx,
sl_se_sha384_streaming_context_t sha384_ctx 
)

Deprecated, please switch to using sl_se_hash384_multipart_starts().

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_update() and sl_se_hash_finish().

Parameters
[in]hash_ctxPointer to a generic hash streaming context object.
[in]cmd_ctxPointer to an SE command context object.
[in]sha384_ctxPointer to a SHA384 streaming 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_ctxPointer to a SHA512 streaming context object.
[in]cmd_ctxPointer to an SE command context object.
Returns
Status code, sl_status.h.

◆ sl_se_hash_sha512_starts()

sl_status_t sl_se_hash_sha512_starts ( sl_se_hash_streaming_context_t hash_ctx,
sl_se_command_context_t cmd_ctx,
sl_se_sha512_streaming_context_t sha512_ctx 
)

Deprecated, please switch to using sl_se_hash512_multipart_starts().

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_update() and sl_se_hash_finish().

Parameters
[in]hash_ctxPointer to a generic hash streaming context object.
[in]cmd_ctxPointer to an SE command context object.
[in]sha512_ctxPointer to a SHA512 streaming 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_ctxPointer to a hash streaming context object specific to the hash type specified by hash_type.
[in]cmd_ctxPointer to an SE command context object.
[in]hash_typeType of hash algoritm
Returns
Status code, sl_status.h.

◆ sl_se_hash_starts()

sl_status_t sl_se_hash_starts ( sl_se_hash_streaming_context_t hash_ctx,
sl_se_command_context_t cmd_ctx,
sl_se_hash_type_t  hash_type,
void *  hash_type_ctx 
)

Deprecated, please switch to using sl_se_hash_multipart_starts().

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_update() and sl_se_hash_finish().

Parameters
[in]hash_ctxPointer to a generic hash streaming context object.
[in]cmd_ctxPointer to an SE command context object.
[in]hash_typeType of hash algoritm
[in]hash_type_ctxPointer to a hash streaming context object specific to the hash type specified by hash_type.
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_ctxPointer to a hash streaming context object specific to the hash type specified by hash_type.
[in]cmd_ctxPointer to an SE command context object.
[in]inputBuffer holding the input data, must be at least ilen bytes wide.
[in]input_lenThe length of the input data in bytes.
Returns
Status code, sl_status.h.

◆ sl_se_hash_update()

sl_status_t sl_se_hash_update ( sl_se_hash_streaming_context_t hash_ctx,
const uint8_t *  input,
size_t  input_len 
)

Deprecated, please switch to using sl_se_hash_multipart_update().

Feeds an input buffer into an ongoing hash computation.

This function is called between sl_se_hash_starts() and sl_se_hash_finish(). This function can be called repeatedly.

Parameters
[in]hash_ctxPointer to a generic hash streaming context object.
[in]inputBuffer holding the input data, must be at least ilen bytes wide.
[in]input_lenThe 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_ctxPointer to a hash streaming context object specific to the hash type specified by hash_type.
[in]cmd_ctxPointer to an SE command context object.
[out]digest_outBuffer for holding the message digest (hash), must be at least the size of the corresponding message digest type.
[in]digest_lenThe 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_finish()

sl_status_t sl_se_hash_finish ( sl_se_hash_streaming_context_t hash_ctx,
uint8_t *  digest_out,
size_t  digest_len 
)

Deprecated, please switch to using sl_se_hash_multipart_finish().

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

This function is called after sl_se_hash_update().

Parameters
[in]hash_ctxPointer to a generic hash streaming context object.
[out]digest_outBuffer for holding the message digest (hash), must be at least the size of the corresponding message digest type.
[in]digest_lenThe 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.