Mistake on this page?
Report an issue in GitHub or email us
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
CryptoCell HASH APIs

Modules

 CryptoCell Hash definitions
 
 CryptoCell HASH specific errors
 

Data Structures

struct  CRYS_HASHUserContext_t
 

Macros

#define CRYS_HASH_RESULT_SIZE_IN_WORDS   16
 
#define CRYS_HASH_MD5_DIGEST_SIZE_IN_BYTES   16
 
#define CRYS_HASH_MD5_DIGEST_SIZE_IN_WORDS   4
 
#define CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES   20
 
#define CRYS_HASH_SHA1_DIGEST_SIZE_IN_WORDS   5
 
#define CRYS_HASH_SHA224_DIGEST_SIZE_IN_WORDS   7
 
#define CRYS_HASH_SHA256_DIGEST_SIZE_IN_WORDS   8
 
#define CRYS_HASH_SHA384_DIGEST_SIZE_IN_WORDS   12
 
#define CRYS_HASH_SHA512_DIGEST_SIZE_IN_WORDS   16
 
#define CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES   28
 
#define CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES   32
 
#define CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES   48
 
#define CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES   64
 
#define CRYS_HASH_BLOCK_SIZE_IN_WORDS   16
 
#define CRYS_HASH_BLOCK_SIZE_IN_BYTES   64
 
#define CRYS_HASH_SHA512_BLOCK_SIZE_IN_WORDS   32
 
#define CRYS_HASH_SHA512_BLOCK_SIZE_IN_BYTES   128
 
#define CRYS_HASH_UPDATE_DATA_MAX_SIZE_IN_BYTES   (1 << 29)
 

Typedefs

typedef uint32_t CRYS_HASH_Result_t[16]
 
typedef struct CRYS_HASHUserContext_t CRYS_HASHUserContext_t
 

Enumerations

Functions

CRYSError_t CRYS_HASH_Init (CRYS_HASHUserContext_t *ContextID_ptr, CRYS_HASH_OperationMode_t OperationMode)
 This function initializes the HASH machine and the HASH Context. More...
 
CRYSError_t CRYS_HASH_Update (CRYS_HASHUserContext_t *ContextID_ptr, uint8_t *DataIn_ptr, size_t DataInSize)
 This function processes a block of data to be HASHed. More...
 
CRYSError_t CRYS_HASH_Finish (CRYS_HASHUserContext_t *ContextID_ptr, CRYS_HASH_Result_t HashResultBuff)
 This function finalizes the hashing process of data block. More...
 
CRYSError_t CRYS_HASH_Free (CRYS_HASHUserContext_t *ContextID_ptr)
 This function is a utility function that frees the context if the operation has failed. More...
 
CRYSError_t CRYS_HASH (CRYS_HASH_OperationMode_t OperationMode, uint8_t *DataIn_ptr, size_t DataSize, CRYS_HASH_Result_t HashResultBuff)
 This function processes a single buffer of data. More...
 

Detailed Description

This product supports the following HASH algorithms (or modes, according to product):

HASH calculation can be performed in either of the following two modes of operation:

The following is a typical HASH Block operation flow:

  1. CRYS_HASH_Init - this function initializes the HASH machine on the CRYS level by setting the context pointer that is used on the entire HASH operation.
  2. CRYS_HASH_Update - this function runs a HASH operation on a block of data allocated by the user. This function may be called as many times as required.
  3. CRYS_HASH_Finish - this function ends the HASH operation. It returns the digest result and clears the context.

Macro Definition Documentation

#define CRYS_HASH_BLOCK_SIZE_IN_BYTES   64

SHA1 hash block size in bytes

Definition at line 128 of file crys_hash.h.

#define CRYS_HASH_BLOCK_SIZE_IN_WORDS   16

SHA1 hash block size in words

Definition at line 125 of file crys_hash.h.

#define CRYS_HASH_MD5_DIGEST_SIZE_IN_BYTES   16

MD5 digest result size in bytes.

Definition at line 89 of file crys_hash.h.

#define CRYS_HASH_MD5_DIGEST_SIZE_IN_WORDS   4

MD5 digest result size in words.

Definition at line 92 of file crys_hash.h.

#define CRYS_HASH_RESULT_SIZE_IN_WORDS   16

The maximal hash result is 512 bits for SHA512.

Definition at line 86 of file crys_hash.h.

#define CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES   20

SHA-1 digest result size in bytes.

Definition at line 95 of file crys_hash.h.

#define CRYS_HASH_SHA1_DIGEST_SIZE_IN_WORDS   5

SHA-1 digest result size in words.

Definition at line 98 of file crys_hash.h.

#define CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES   28

SHA-256 digest result size in bytes

Definition at line 113 of file crys_hash.h.

#define CRYS_HASH_SHA224_DIGEST_SIZE_IN_WORDS   7

SHA-256 digest result size in words.

Definition at line 101 of file crys_hash.h.

#define CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES   32

SHA-256 digest result size in bytes

Definition at line 116 of file crys_hash.h.

#define CRYS_HASH_SHA256_DIGEST_SIZE_IN_WORDS   8

SHA-256 digest result size in words.

Definition at line 104 of file crys_hash.h.

#define CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES   48

SHA-384 digest result size in bytes

Definition at line 119 of file crys_hash.h.

#define CRYS_HASH_SHA384_DIGEST_SIZE_IN_WORDS   12

SHA-384 digest result size in words.

Definition at line 107 of file crys_hash.h.

#define CRYS_HASH_SHA512_BLOCK_SIZE_IN_BYTES   128

SHA2 hash block size in bytes

Definition at line 134 of file crys_hash.h.

#define CRYS_HASH_SHA512_BLOCK_SIZE_IN_WORDS   32

SHA2 hash block size in words

Definition at line 131 of file crys_hash.h.

#define CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES   64

SHA-512 digest result size in bytes

Definition at line 122 of file crys_hash.h.

#define CRYS_HASH_SHA512_DIGEST_SIZE_IN_WORDS   16

SHA-512 digest result size in words.

Definition at line 110 of file crys_hash.h.

#define CRYS_HASH_UPDATE_DATA_MAX_SIZE_IN_BYTES   (1 << 29)

Maximal data size for update operation.

Definition at line 137 of file crys_hash.h.

Typedef Documentation

typedef uint32_t CRYS_HASH_Result_t[16]

HASH result buffer.

Definition at line 162 of file crys_hash.h.

The user's context prototype - the argument type that is passed by the user to the HASH APIs. The context saves the state of the operation and must be saved by the user till the end of the APIs flow.

Enumeration Type Documentation

HASH operation mode

Enumerator
CRYS_HASH_SHA1_mode 

SHA1.

CRYS_HASH_SHA224_mode 

SHA224.

CRYS_HASH_SHA256_mode 

SHA256.

CRYS_HASH_SHA384_mode 

SHA384.

CRYS_HASH_SHA512_mode 

SHA512.

CRYS_HASH_MD5_mode 

MD5.

CRYS_HASH_NumOfModes 

Number of hash modes.

CRYS_HASH_OperationModeLast 

Reserved.

Definition at line 145 of file crys_hash.h.

Function Documentation

CRYSError_t CRYS_HASH ( CRYS_HASH_OperationMode_t  OperationMode,
uint8_t *  DataIn_ptr,
size_t  DataSize,
CRYS_HASH_Result_t  HashResultBuff 
)

This function processes a single buffer of data.

The function allocates an internal HASH Context, and initializes it with the cryptographic attributes that are needed for the HASH block operation (initialize H's value for the HASH algorithm). Then it processes the data block, calculating the HASH. Finally, it returns the data buffer's message digest.

Returns
CRYS_OK on success.
A non-zero value from crys_hash_error.h on failure.
Parameters
[in]OperationModeOne of the supported HASH modes, as defined in CRYS_HASH_OperationMode_t.
[in]DataIn_ptrPointer to the input data to be HASHed. The size of the scatter/gather list representing the data buffer is limited to 128 entries, and the size of each entry is limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB).
[in]DataSizeThe size of the data to be hashed in bytes.
[out]HashResultBuffPointer to a word-aligned 64 byte buffer. The actual size of the HASH result depends on CRYS_HASH_OperationMode_t.
CRYSError_t CRYS_HASH_Finish ( CRYS_HASHUserContext_t ContextID_ptr,
CRYS_HASH_Result_t  HashResultBuff 
)

This function finalizes the hashing process of data block.

It receives a handle to the HASH Context, which was previously initialized by CRYS_HASH_Init or by CRYS_HASH_Update. It "adds" a header to the data block according to the relevant HASH standard, and computes the final message digest.

Returns
CRYS_OK on success.
A non-zero value from crys_hash_error.h on failure.
Parameters
[in]ContextID_ptrPointer to the HASH context buffer allocated by the user that is used for the HASH machine operation.
[in]HashResultBuffPointer to the word-aligned 64 byte buffer. The actual size of the HASH result depends on CRYS_HASH_OperationMode_t.
CRYSError_t CRYS_HASH_Free ( CRYS_HASHUserContext_t ContextID_ptr)

This function is a utility function that frees the context if the operation has failed.

The function executes the following major steps:

  1. Checks the validity of all of the inputs of the function.
  2. Clears the user's context.
  3. Exits the handler with the OK code.
Returns
CRYS_OK on success.
A non-zero value from crys_hash_error.h on failure.
Parameters
[in]ContextID_ptrPointer to the HASH context buffer allocated by the user that is used for the HASH machine operation.
CRYSError_t CRYS_HASH_Init ( CRYS_HASHUserContext_t ContextID_ptr,
CRYS_HASH_OperationMode_t  OperationMode 
)

This function initializes the HASH machine and the HASH Context.

It receives as input a pointer to store the context handle to the HASH Context, and initializes the HASH Context with the cryptographic attributes that are needed for the HASH block operation (initializes H's value for the HASH algorithm).

Returns
CRYS_OK on success.
A non-zero value from crys_hash_error.h on failure.
Parameters
[in]ContextID_ptrPointer to the HASH context buffer allocated by the user that is used for the HASH machine operation.
[in]OperationModeOne of the supported HASH modes, as defined in CRYS_HASH_OperationMode_t.
CRYSError_t CRYS_HASH_Update ( CRYS_HASHUserContext_t ContextID_ptr,
uint8_t *  DataIn_ptr,
size_t  DataInSize 
)

This function processes a block of data to be HASHed.

It updates a HASH Context that was previously initialized by CRYS_HASH_Init or updated by a previous call to CRYS_HASH_Update.

Returns
CRYS_OK on success.
A non-zero value from crys_hash_error.h on failure.
Parameters
[in]ContextID_ptrPointer to the HASH context buffer allocated by the user, which is used for the HASH machine operation.
[in]DataIn_ptrPointer to the input data to be HASHed. it is a one contiguous memory block.
[in]DataInSizeByte size of the input data. Must be > 0. If not a multiple of the HASH block size (64 for MD5, SHA-1 and SHA-224/256, 128 for SHA-384/512), no further calls to CRYS_HASH_Update are allowed in this context, and only CRYS_HASH_Finish can be called to complete the computation.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.