unofficial-rtos-docs

Chapter 4 - NetX Duo Crypto API description

nx_crypto_initialize

Initializes the NetX Secure Library

Prototype

UINT nx_crypto_initialize(VOID);

Description

This function initializes the NetX Duo Crypto library module. Before using any of the other cryptographic functions, the application must call this function to perform initialization and to validate the integrity of the library. Failure to call this function before using other NetX Duo Crypto services will result in errors being returned.

Parameters

Return Values

Example

TODO

nx_crypto_module_state_get

Retrieve the current status of the FIPS-enabled module

Prototype

UINT nx_crypto_module_state_get(VOID);

Description

This service is only available in the FIPS build library. It returns the state of the current state of the NetX Duo Crypto library.

Parameters

Return Values

Example

TODO

_nx_crypto_method_aes_init

Initializes the AES crypto control block

Prototype

UINT _nx_crypto_method_aes_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the AES control block with the given key string. Once the AES control block is initialized, subsequent AES operation will be using the same key and key size.

Application may create multiple AES control blocks, each represents a session. A key is assigned to a control block. Subsequent encryption or decryption operation can reference to the same AES control block without the need to re-initialize the AES control block. If the key for the session is changed, application needs to re-initialize AES control block with the updated key.

Calling nx_crypto_method_aes_init automatically updates a previously configured key and key size to the new key.

Parameters

Return Values

_nx_crypto_method_aes_operation

Perform an AES operation (encryption or decryption).

Prototype

UINT _nx_crypto_method_aes_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status));

Description

This function performs AES encryption or decryption operation. The AES control block must have been initialized with _nx_crypto_method_aes_init. The AES algorithm to be performed is based on the algorithm specified in the method control block.

The input buffer size must be a multiple of 16 bytes. The size of the decrypted data is the same size of the input data size. If the encrypted data was padded to achieve an even multiple of the AES block size, the padding will be included in the output buffer and must be handled by the application.

This operation does not keep state information, and does not alter the key material in the AES control block.

When the op is NX_CRYPTO_SET_ADDITIONAL_DATA and algoritm is AES-CCM8, the input points to additional data and input_length_in_byte is the length of additional data.

Parameters

Return Values

_nx_crypto_method_aes_cleanup

Clean up the AES control block.

Prototype

UINT _nx_crypto_method_aes_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the AES control block after it determines this AES session is no longer needed.

Parameters

Return Values

_nx_crypto_method_3des_init

Initialize the 3DES control block.

Prototype

UINT _nx_crypto_method_3des_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the Triple DES (3DES) control block with the given three key strings. The key strings must be 8 bytes each. The three DES keys must be concatenated into contiguous memory of 24-byte buffer. For FIPS-compliant build, the three keys must be different from each or the function will return the NX_CRYPTO_INVALID_KEY error. Once the 3DES control block is initialized, subsequent 3DES operations will use the same keys.

An application may create multiple 3DES control blocks, each representing a session. A key is assigned to a control block and subsequent encryption or decryption operations can reference the same control block without needing to re-initialize. If the key for a session is changed, the application will need to re-initialize the control block with the updated key.

Calling _nx_crypto_method_3des_init automatically updates a previously configured key to the new keys.

Parameters

Return Value

_nx_crypto_method_3des_operation

Encrypt or Decrypt with 3DES.

Prototype

UINT _nx_crypto_method_3des_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs 3DES encryption or decryption operation. The 3DES control block must have been initialized with _nx_crypto_method_3des_init. The 3DES algorithm to be performed is based on the algorithm specified in the method control block.

The input buffer size must be a multiple of 8 bytes. The size of the decrypted data is the same size of the input data size. If the encrypted data was padded to achieve an even multiple of the 3DES block size, the padding will be included in the output buffer and must be handled by the application.

This operation does not keep state information, and does not alter the key material in the 3DES control block.

Parameters

Description

This function performs 3DES encryption. The 3DES control block must have been initialized with _nx_crypto_moethod_3des_init. This operation does not keep state information, and does not alter the key material in the 3DES control block. Note that padding is not added by this function so the caller will need to handle padding before invoking the encryption operation.

Return Values

_nx_crypto_method_3des_cleanup

Clean up the 3DES control block.

Prototype

UINT _nx_crypto_method_3des_cleanup(VOID *crypto_metadata);

Description

Application calls this function to clean up the 3DES control block after it determines this 3DES session is no longer needed.

Parameters

Return Values

_nx_crypto_method_drbg_init

Initializes the DRBG crypto control block

Prototype

UINT _nx_crypto_method_drbg_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the DRBG control block with the given key string. Once the DRBG control block is initialized, subsequent DRBG operation shall be using the same control block.

Application may create multiple DRBG control blocks, each represents a session. Initializing the DRBG control block starts a new hash computation session. Re-initializing the DRBG control block abandons the current session and stars a new one.

Parameters

Return Values

_nx_crypto_method_drbg_operation

Perform DRBG operation

Prototype

UINT __nx_crypto_method_drbg_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs DRBG operation. The DRBG control block must have been initialized with _nx_crypto_method_drbg_init. The DRBG algorithm to be performed is based on the algorithm specified in the method control block. By default AES-128 is used for DRBG.

When the operation is NX_CRYPTO_DRBG_OPTIONS_SET, the input points to NX_CRYPTO_DRBG_OPTIONS structure. When the operation is NX_CRYPTO_DRBG_INSTANTIATE, the key points to nonce, input points to personalization string. When the operation is NX_CRYPTO_DRBG_RESEED or NX_CRYPTO_DRBG_GENERATE, the input points to additional input.

Parameters

Return Values

_nx_crypto_method_drbg_cleanup

Clean up the DRBG control block.

Prototype

UINT _nx_crypto_method_drbg_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the DRBG control block after it determines this DRBG session is no longer needed.

Parameters

Return Values

_nx_crypto_method_ecdh_init

Initializes the ECDH crypto control block

Prototype

UINT _nx_crypto_method_ecdh_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the ECDH control block with the given key string. Once the ECDH control block is initialized, subsequent ECDH operation shall be using the same control block.

Application may create multiple ECDH control blocks, each represents a session. Initializing the ECDH control block starts a new hash computation session. Re-initializing the ECDH control block abandons the current session and stars a new one.

Parameters

Return Values

_nx_crypto_method_ecdh_operation

Perform ECDH operation

Prototype

UINT _nx_crypto_method_ecdh_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs ECDH operation. The ECDH control block must have been initialized with _nx_crypto_method_ecdh_init. The ECDH algorithm to be performed is based on the algorithm specified in the method control block.

When the operation is NX_CRYPTO_EC_CURVE_SET, the input points to Elliptic Curve crypto method. When the operation is NX_CRYPTO_EC_KEY_PAIR_GENERATE, the output points to NX_CRYPTO_EXTENDED_OUTPUT structure and the key pair is copied to nx_crypto_extended_output_data. When the operation is NX_CRYPTO_DH_SETUP, the public key is returned to nx_crypto_extended_output_data. When the operation is NX_CRYPTO_DH_KEY_PAIR_IMPORT, the input points to public key and key points to private key. When the operation is NX_CRYPTO_DH_PRIVATE_KEY_EXPORT, the private key is copied to nx_crypto_extended_output_data. When the operation is NX_CRYPTO_DH_CALCULATE, the input points to remote public key and the shared secret is copied to nx_crypto_extended_output_data.

Parameters

Return Values

_nx_crypto_method_ecdh_cleanup

Clean up the ECDH control block.

Prototype

UINT _nx_crypto_method_ecdh_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the ECDH control block after it determines this ECDH session is no longer needed.

Parameters

Return Values

_nx_crypto_method_ecdsa_init

Initializes the ECDSA crypto control block

Prototype

UINT _nx_crypto_method_ecdsa_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the ECDSA control block with the given key string. Once the ECDSA control block is initialized, subsequent ECDSA operation shall be using the same control block.

Application may create multiple ECDSA control blocks, each represents a session. Initializing the ECDSA control block starts a new hash computation session. Re-initializing the ECDSA control block abandons the current session and stars a new one.

Parameters

Return Values

_nx_crypto_method_ecdsa_operation

Perform ECDSA operation

Prototype

UINT _nx_crypto_method_ecdsa_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs ECDSA operation. The ECDSA control block must have been initialized with _nx_crypto_method_ecdsa_init. The ECDSA algorithm to be performed is based on the algorithm specified in the method control block.

When the operation is NX_CRYPTO_EC_CURVE_SET, the input points to Elliptic Curve crypto method. When the operation is NX_CRYPTO_EC_KEY_PAIR_GENERATE, the output points to NX_CRYPTO_EXTENDED_OUTPUT structure and the key pair is copied to nx_crypto_extended_output_data.

Parameters

Return Values

_nx_crypto_method_ecdsa_cleanup

Clean up the ECDSA control block.

Prototype

UINT _nx_crypto_method_ecdsa_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the ECDSA control block after it determines this ECDSA session is no longer needed.

Parameters

Return Values

_nx_crypto_method_hmac_md5_init

Initializes the HMAC MD5 crypto control block

Prototype

UINT _nx_crypto_method_hmac_md5_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the HMAC MD5 control block with the given key string. Once the HMAC MD5 control block is initialized, subsequent HMAC MD5 operation shall be using the same control block.

Application may create multiple HMAC MD5 control blocks, each represents a session. Initializing the HMAC MD5 control block starts a new hash computation session. Re-initializing the HMAC MD5 control block abandons the current session and stars a new one.

Parameters

Return Values

_nx_crypto_method_hmac_md5_operation

Perform an HMAC MD5 hash operation.

Prototype

UINT _nx_crypto_method_hmac_md5_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs HMAC MD5 hash operation. The HMAC MD5 control block must have been initialized with _nx_crypto_method_hmac_md5_init. The HMAC MD5 algorithm to be performed is based on the algorithm specified in the method control block.

For the final NX_CRYPTO_HASH_CALCULATE operation, the output buffer size must be 16 bytes.

This operation does not keep state information, and does not alter the key material in the HMAC MD5 control block.

Parameters

Return Values

_nx_crypto_method_hmac_sha1_init

Initializes the HMAC SHA1 crypto control block

Prototype

UINT _nx_crypto_method_hmac_sha1_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the HMAC SHA1 control block with the given key string. Once the HMAC SHA1 control block is initialized, subsequent HMAC SHA1 operation shall be using the same control block.

Application may create multiple HMAC SHA1 control blocks, each represents a session. Initializing the HMAC SHA1 control block starts a new hash computation session. Re-initializing the HMAC SHA1 control block abandons the current session and stars a new one.

Parameters

Return Values

_nx_crypto_method_hmac_sha1_operation

Perform HMAC SHA1 hash operation

Prototype

UINT _nx_crypto_method_hmac_sha1_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs HMAC SHA1 hash operation. The HMAC SHA1 control block must have been initialized with _nx_crypto_method_hmac_sha1_init. The HMAC SHA1 algorithm to be performed is based on the algorithm specified in the method control block.

For the final NX_CRYPTO_HASH_CALCULATE operation, the output buffer size must be 20 bytes.

Parameters

Return Values

_nx_crypto_method_hmac_sha1_cleanup

Clean up the HMAC SHA1 control block.

Prototype

UINT _nx_crypto_method_hmac_sha1_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the HMAC SHA1 control block after it determines this HMAC SHA1 session is no longer needed.

Parameters

Return Values

_nx_crypto_method_hmac_sha256_init

Initializes the HMAC SHA256 crypto control block

Prototype

UINT _nx_crypto_method_hmac_sha256_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the HMAC SHA256 control block with the given key string. Once the HMAC SHA256 control block is initialized, subsequent HMAC SHA256 operation shall be using the same control block.

Application may create multiple HMAC SHA256 control blocks, each represents a session. Initializing the HMAC SH256 control block starts a new hash computation session. Re-initializing the HMAC SHA256 control block abandons the current session and stars a new one with a new key.

Parameters

Return Values

_nx_crypto_method_hmac_sha256_operation

Perform HMAC SHA256 hash operation

Prototype

UINT _nx_crypto_method_hmac_sha256_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs HMAC SHA256 hash operation. The HMAC SHA256 control block must have been initialized with _nx_crypto_method_hmac_sha256_init. The HMAC SHA256 algorithm to be performed is based on the algorithm specified in the method control block.

For the final NX_CRYPTO_HASH_CALCULATE operation, the output buffer size must be 32 bytes for SHA256, or 28 bytes for SHA224.

Parameters

Return Values

_nx_crypto_method_hmac_sha256_cleanup

Clean up the HMAC SHA256 control block.

Prototype

UINT _nx_crypto_method_hmac_sha256_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the HMAC SHA256 control block after it determines this HMAC SHA256 session is no longer needed.

Parameters

Return Values

_nx_crypto_method_hmac_sha512_init

Initializes the HMAC SHA512 crypto control block

Prototype

UINT _nx_crypto_method_hmac_sha512_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the HMAC SHA512 control block with the given key string. Once the HMAC SHA512 control block is initialized, subsequent HMAC SHA512 operation shall be using the same control block.

Application may create multiple HMAC SHA512 control blocks, each represents a session. Initializing the HMAC SH512 control block starts a new hash computation session. Re-initializing the HMAC SHA512 control block abandons the current session and stars a new one with a new key.

Parameters

Return Values

_nx_crypto_method_hmac_sha512_operation

Perform HMAC SHA512 hash operation

Prototype

UINT _nx_crypto_method_hmac_sha512_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs HMAC SHA512 hash operation. The HMAC SHA512 control block must have been initialized with _nx_crypto_method_hmac_sha512_init. The HMAC SHA512 algorithm to be performed is based on the algorithm specified in the method control block.

For the final NX_CRYPTO_HASH_CALCULATE operation, the output buffer size must be 64 bytes for SHA512, or 48 bytes for SHA384.

Parameters

Return Values

_nx_crypto_method_hmac_sha512_cleanup

Clean up the HMAC SHA512 control block.

Prototype

UINT _nx_crypto_method_hmac_sha512_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the HMAC SHA512 control block after it determines this HMAC SHA512 session is no longer needed.

Parameters

Return Values

Example

_nx_crypto_method_md5_init

Initializes the MD5 crypto control block

Prototype

UINT _nx_crypto_method_md5_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the MD5 control block with the given key string. Once the MD5 control block is initialized, subsequent MD5 operation shall be using the same control block.

Application may create multiple MD5 control blocks, each represents a session. Initializing the MD5 control block starts a new hash computation session. Re-initializing the MD5 control block abandons the current session and stars a new one.

Parameters

Return Values

Example

_nx_crypto_method_md5_operation

Perform an MD5 hash operation.

Prototype

UINT _nx_crypto_method_md5_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs MD5 hash operation. The MD5 control block must have been initialized with _nx_crypto_method_md5_init. The MD5 algorithm to be performed is based on the algorithm specified in the method control block.

For the final NX_CRYPTO_HASH_CALCULATE operation, the output buffer size must be 16 bytes.

This operation does not keep state information and does not alter the key material in the MD5 control block.

Parameters

Return Values

_nx_crypto_method_md5_cleanup

Clean up the MD5 control block.

Prototype

UINT _nx_crypto_method_md5_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the MD5 control block after it determines this MD5 session is no longer needed.

Parameters

Return Values

_nx_crypto_method_sha1_init

Initializes the SHA1 crypto control block

Prototype

UINT _nx_crypto_method_sha1_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the SHA1 control block with the given key string. Once the SHA1 control block is initialized, subsequent SHA1 operation shall be using the same control block.

Application may create multiple SHA1 control blocks, each represents a session. Initializing the SHA1 control block starts a new hash computation session. Re-initializing the SHA1 control block abandons the current session and stars a new one.

Parameters

Return Values

_nx_crypto_method_sha1_operation

Perform SHA1 hash operation

Prototype

UINT _nx_crypto_method_sha1_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs SHA1 hash operation. The SHA1 control block must have been initialized with _nx_crypto_method_sha1_init. The SHA1 algorithm to be performed is based on the algorithm specified in the method control block.

For the final NX_CRYPTO_HASH_CALCULATE operation, the output buffer size must be 20 bytes.

Parameters

Return Values

Example

_nx_crypto_method_sha1_cleanup

Clean up the SHA1 control block.

Prototype

UINT _nx_crypto_method_sha1_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the SHA1 control block after it determines this SHA1 session is no longer needed.

Parameters

Return Values

_nx_crypto_method_sha256_init

Initializes the SHA256 crypto control block

Prototype

UINT _nx_crypto_method_sha256_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size)

Description

This function initializes the SHA256 control block with the given key string. Once the SHA256 control block is initialized, subsequent SHA256 operation shall be using the same control block.

Application may create multiple SHA256 control blocks, each represents a session. Initializing the SHA256 control block starts a new hash computation session. Re-initializing the SHA256 control block abandons the current session and stars a new one.

Parameters

Return Values

_nx_crypto_method_sha256_operation

Perform SHA256 hash operation

Prototype

UINT _nx_crypto_method_sha256_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT
    status));

Description

This function performs SHA256 hash operation. The SHA256 control block must have been initialized with _nx_crypto_method_sha256_init. The SHA256 algorithm to be performed is based on the algorithm specified in the method control block.

For the final NX_CRYPTO_HASH_CALCULATE operation, the output buffer size must be 32 bytes for SHA256, or 28 bytes for SHA224.

Parameters

Return Values

_nx_crypto_method_sha256_cleanup

Clean up the SHA256 control block.

Prototype

UINT _nx_crypto_method_sha256_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the SHA256 control block after it determines this SHA256 session is no longer needed.

Parameters

Return Values

_nx_crypto_method_sha512_init

Initializes the SHA512 crypto control block

Prototype

UINT _nx_crypto_method_sha512_init(
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    VOID **handle,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size);

Description

This function initializes the SHA512 control block with the given key string. Once the SHA512 control block is initialized, subsequent SHA512 operation shall be using the same control block.

Application may create multiple SHA512 control blocks, each represents a session. Initializing the SHA512 control block starts a new hash computation session. Re-initializing the SHA512 control block abandons the current session and stars a new one.

Parameters

Return Values

_nx_crypto_method_sha512_operation

Perform SHA512 hash operation

Prototype

UINT _nx_crypto_method_sha512_operation(UINT op,
    VOID *handle,
    struct NX_CRYPTO_METHOD_STRUCT *method,
    UCHAR *key,
    NX_CRYPTO_KEY_SIZE key_size_in_bits,
    UCHAR *input,
    ULONG input_length_in_byte,
    UCHAR *iv_ptr,
    UCHAR *output,
    ULONG output_length_in_byte,
    VOID *crypto_metadata,
    ULONG crypto_metadata_size,
    VOID *packet_ptr,
    VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status));

Description

This function performs SHA512 hash operation. The SHA512 control block must have been initialized with _nx_crypto_method_sha512_init. The SHA512 algorithm to be performed is based on the algorithm specified in the method control block.

For the final NX_CRYPTO_HASH_CALCULATE operation, the output buffer size must be 64 bytes for SHA512, or 48 bytes for SHA384.

Parameters

Return Values

_nx_crypto_method_sha512_cleanup

Clean up the SHA512 control block.

Prototype

UINT _nx_crypto_method_sha512_cleanup(VOID* crypto_metadata);

Description

Application calls this function to clean up the SHA512 control block after it determines this SHA512 session is no longer needed.

Parameters

Return Values