lcx_sha3.h | Developers

lcx_sha3.h

Back to the files list

SHA-3 (Secure Hash Algorithm 3) More...

Data Structures

struct  cx_sha3_s
 KECCAK, SHA3 and SHA3-XOF context. More...

Typedefs

typedef struct cx_sha3_s cx_sha3_t
 Convenience type. More...

Functions

cx_err_t cx_sha3_init_no_throw (cx_sha3_t *hash, size_t size)
 Initializes a SHA3 context. More...
static int cx_sha3_init (cx_sha3_t *hash, size_t size)
 Initializes a SHA3 context. More...
cx_err_t cx_keccak_init_no_throw (cx_sha3_t *hash, size_t size)
 Initializes a KECCAK context. More...
static int cx_keccak_init (cx_sha3_t *hash, size_t size)
 Initializes a KECCAK context. More...
cx_err_t cx_shake128_init_no_throw (cx_sha3_t *hash, size_t out_size)
 Initializes a SHA3-XOF context. More...
static int cx_shake128_init (cx_sha3_t *hash, unsigned int out_size)
 Initializes a SHA3-XOF context. More...
cx_err_t cx_shake256_init_no_throw (cx_sha3_t *hash, size_t out_size)
 Initializes a SHA3-XOF context. More...
static int cx_shake256_init (cx_sha3_t *hash, unsigned int out_size)
 Initializes a SHA3-XOF context. More...
cx_err_t cx_sha3_xof_init_no_throw (cx_sha3_t *hash, size_t size, size_t out_length)
 Initializes a SHA3-XOF context. More...
static int cx_sha3_xof_init (cx_sha3_t *hash, unsigned int size, unsigned int out_length)
 Initializes a SHA3-XOF context. More...

Detailed Description

SHA-3 (Secure Hash Algorithm 3)

SHA-3 specifies a family of secure hash functions based on an instance of the KECCAK algorithm. Refer to FIPS 202 for more details.

Typedef Documentation

cx_sha3_t

typedef struct cx_sha3_s cx_sha3_t

Convenience type.

See cx_sha3_s.

Function Documentation

cx_keccak_init()

static int cx_keccak_init ( cx_sha3_t hash,
size_t  size 
)

Initializes a KECCAK context.

Supported output sizes in bits:

  • 224
  • 256
  • 384
  • 512

This function throws an exception if the initialization fails.

Warning
It is recommended to use cx_keccak_init_no_throw rather than this function.
Parameters
[out]hashPointer to the KECCAK context. The context shall be in RAM.
[in]sizeLength of the hash output in bits.
Returns
KECCAK identifier.
Exceptions
CX_INVALID_PARAMETER

cx_keccak_init_no_throw()

cx_err_t cx_keccak_init_no_throw ( cx_sha3_t hash,
size_t  size 
)

Initializes a KECCAK context.

Supported output sizes in bits:

  • 224
  • 256
  • 384
  • 512
Parameters
[out]hashPointer to the KECCAK context. The context shall be in RAM.
[in]sizeLength of the hash output in bits.
Returns
Error code:
  • CX_OK on success
  • CX_INVALID_PARAMETER

cx_sha3_init()

static int cx_sha3_init ( cx_sha3_t hash,
size_t  size 
)

Initializes a SHA3 context.

Supported output sizes in bits:

  • 224
  • 256
  • 384
  • 512

This function throws an exception if the initialization fails.

Warning
It is recommended to use cx_sha3_init_no_throw rather than this function.
Parameters
[out]hashPointer to the SHA3 context. The context shall be in RAM.
[in]sizeLength of the hash output in bits.
Returns
SHA3 identifier.
Exceptions
CX_INVALID_PARAMETER

cx_sha3_init_no_throw()

cx_err_t cx_sha3_init_no_throw ( cx_sha3_t hash,
size_t  size 
)

Initializes a SHA3 context.

Supported output sizes in bits:

  • 224
  • 256
  • 384
  • 512
Parameters
[out]hashPointer to the SHA3 context. The context shall be in RAM.
[in]sizeLength of the hash output in bits.
Returns
Error code:
  • CX_OK on success
  • CX_INVALID_PARAMETER

cx_sha3_xof_init()

static int cx_sha3_xof_init ( cx_sha3_t hash,
unsigned int  size,
unsigned int  out_length 
)

Initializes a SHA3-XOF context.

This can be used to initialize either SHAKE128 or SHAKE256. Supported output sizes in bits:

  • 256
  • 512

This function throws an exception if the computation doesn't succeed.

Warning
It is recommended to use cx_sha3_xof_init_no_throw rather than this function.
Parameters
[out]hashPointer to the context. The context shall be in RAM.
[in]sizeLength of SHA3 digest in bits.
[in]out_lengthLength of the output in bytes.
Returns
Either SHAKE128 or SHAKE256 identifier.
Exceptions
CX_INVALID_PARAMETER

cx_sha3_xof_init_no_throw()

cx_err_t cx_sha3_xof_init_no_throw ( cx_sha3_t hash,
size_t  size,
size_t  out_length 
)

Initializes a SHA3-XOF context.

This can be used to initialize either SHAKE128 or SHAKE256. Supported output sizes in bits:

  • 256
  • 512
Parameters
[out]hashPointer to the context. The context shall be in RAM.
[in]sizeLength of SHA3 digest in bits.
[in]out_lengthLength of the output in bytes.
Returns
Error code:
  • CX_OK on success
  • CX_INVALID_PARAMETER

cx_shake128_init()

static int cx_shake128_init ( cx_sha3_t hash,
unsigned int  out_size 
)

Initializes a SHA3-XOF context.

SHAKE128 is a SHA3-XOF (Extendable Output Function based on SHA3) with a 128-bit security. Supported output sizes in bits:

  • 256
  • 512

This function throws an exception if the initialization doesn't succeed.

Warning
It is recommended to use cx_shake128_init_no_throw rather than this function.
Parameters
[out]hashPointer to the context. The context shall be in RAM.
[in]out_sizeLength of the output in bits.
Returns
SHAKE128 identifier.
Exceptions
CX_INVALID_PARAMETER

cx_shake128_init_no_throw()

cx_err_t cx_shake128_init_no_throw ( cx_sha3_t hash,
size_t  out_size 
)

Initializes a SHA3-XOF context.

SHAKE128 is a SHA3-XOF (Extendable Output Function based on SHA3) with a 128-bit security. Supported output sizes in bits:

  • 256
  • 512
Parameters
[out]hashPointer to the context. The context shall be in RAM.
[in]out_sizeLength of the output in bits.
Returns
Error code:
  • CX_OK on success
  • CX_INVALID_PARAMETER

cx_shake256_init()

static int cx_shake256_init ( cx_sha3_t hash,
unsigned int  out_size 
)

Initializes a SHA3-XOF context.

SHAKE256 is a SHA3-XOF (Extendable Output Function based on SHA3) with a 256-bit security. Supported output sizes in bits:

  • 256
  • 512

This function throws an exception if the initialization doesn't succeed.

Warning
It is recommended to use cx_shake256_init_no_throw rather than this function.
Parameters
[out]hashPointer to the context. The context shall be in RAM.
[in]out_sizeLength of the output in bits.
Returns
SHA256 identifier.
Exceptions
CX_INVALID_PARAMETER

cx_shake256_init_no_throw()

cx_err_t cx_shake256_init_no_throw ( cx_sha3_t hash,
size_t  out_size 
)

Initializes a SHA3-XOF context.

SHAKE256 is a SHA3-XOF (Extendable Output Function based on SHA3) with a 256-bit security. Supported output sizes in bits:

  • 256
  • 512
Parameters
[out]hashPointer to the context. The context shall be in RAM.
[in]out_sizeLength of the output in bits.
Returns
Error code:
  • CX_OK on success
  • CX_INVALID_PARAMETER

Back to the files list


Did you find this page helpful?


How would you improve this page for developers?



Getting Started
Theme Features
Customization

Nano Apps