Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_hash_defs.h
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | |||||
* SHA3_256 digest length in bytes */ | * SHA3_256 digest length in bytes */ | ||||
#define LAC_HASH_SHA3_256_STATE_SIZE 32 | #define LAC_HASH_SHA3_256_STATE_SIZE 32 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* SHA3_256 state size */ | * SHA3_256 state size */ | ||||
/* Constants for SHA3_384 algorithm */ | /* Constants for SHA3_384 algorithm */ | ||||
#define LAC_HASH_SHA3_384_BLOCK_SIZE 104 | #define LAC_HASH_SHA3_384_BLOCK_SIZE 104 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* * SHA3_384 block size in bytes */ | * SHA3_384 block size in bytes */ | ||||
#define LAC_HASH_SHA3_384_DIGEST_SIZE 48 | #define LAC_HASH_SHA3_384_DIGEST_SIZE 48 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* * SHA3_384 digest length in bytes */ | * SHA3_384 digest length in bytes */ | ||||
#define LAC_HASH_SHA3_384_STATE_SIZE 48 | #define LAC_HASH_SHA3_384_STATE_SIZE 48 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* * SHA3_384 state size */ | * SHA3_384 state size */ | ||||
/* Constants for SHA3_512 algorithm */ | /* Constants for SHA3_512 algorithm */ | ||||
#define LAC_HASH_SHA3_512_BLOCK_SIZE 72 | #define LAC_HASH_SHA3_512_BLOCK_SIZE 72 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* * * SHA3_512 block size in bytes */ | * SHA3_512 block size in bytes */ | ||||
#define LAC_HASH_SHA3_512_DIGEST_SIZE 64 | #define LAC_HASH_SHA3_512_DIGEST_SIZE 64 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* * * SHA3_512 digest length in bytes */ | * SHA3_512 digest length in bytes */ | ||||
#define LAC_HASH_SHA3_512_STATE_SIZE 64 | #define LAC_HASH_SHA3_512_STATE_SIZE 64 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* * * SHA3_512 state size */ | * SHA3_512 state size */ | ||||
/* Constants for SHAKE_128 algorithm */ | #define LAC_HASH_SHA3_STATEFUL_STATE_SIZE 200 | ||||
#define LAC_HASH_SHAKE_128_BLOCK_SIZE 168 | |||||
/**< @ingroup LacHashDefs | |||||
* * * SHAKE_128 block size in bytes */ | |||||
#define LAC_HASH_SHAKE_128_DIGEST_SIZE 0xFFFFFFFF | |||||
/**< @ingroup LacHashDefs | |||||
* * * SHAKE_128 digest length in bytes ((2^32)-1)*/ | |||||
/* Constants for SHAKE_256 algorithm */ | /* Constants for SM3 algorithm */ | ||||
#define LAC_HASH_SHAKE_256_BLOCK_SIZE 136 | #define LAC_HASH_SM3_BLOCK_SIZE 64 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* * * SHAKE_256 block size in bytes */ | * SM3 block size in bytes */ | ||||
#define LAC_HASH_SHAKE_256_DIGEST_SIZE 0xFFFFFFFF | #define LAC_HASH_SM3_DIGEST_SIZE 32 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* * * SHAKE_256 digest length in bytes ((2^ 32)-1)*/ | * SM3 digest length */ | ||||
#define LAC_HASH_SM3_STATE_SIZE 32 | |||||
/**< @ingroup LacHashDefs | |||||
* SM3 state size */ | |||||
/* Constants for POLY algorithm */ | /* Constants for POLY algorithm */ | ||||
#define LAC_HASH_POLY_BLOCK_SIZE 64 | #define LAC_HASH_POLY_BLOCK_SIZE 64 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* POLY block size in bytes */ | * POLY block size in bytes */ | ||||
#define LAC_HASH_POLY_DIGEST_SIZE 16 | #define LAC_HASH_POLY_DIGEST_SIZE 16 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* POLY digest length */ | * POLY digest length */ | ||||
#define LAC_HASH_POLY_STATE_SIZE 0 | #define LAC_HASH_POLY_STATE_SIZE 0 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* POLY state size */ | * POLY state size */ | ||||
/* Constants for SM3 algorithm */ | |||||
#define LAC_HASH_SM3_BLOCK_SIZE 64 | |||||
/**< @ingroup LacHashDefs | |||||
* SM3 block size in bytes */ | |||||
#define LAC_HASH_SM3_DIGEST_SIZE 32 | |||||
/**< @ingroup LacHashDefs | |||||
* SM3 digest length */ | |||||
#define LAC_HASH_SM3_STATE_SIZE 32 | |||||
/**< @ingroup LacHashDefs | |||||
* SM3 state size */ | |||||
/* Constants for XCBC precompute algorithm */ | /* Constants for XCBC precompute algorithm */ | ||||
#define LAC_HASH_XCBC_PRECOMP_KEY_NUM 3 | #define LAC_HASH_XCBC_PRECOMP_KEY_NUM 3 | ||||
/**< @ingroup LacHashDefs | /**< @ingroup LacHashDefs | ||||
* The Pre-compute operation involves deriving 3 128-bit | * The Pre-compute operation involves deriving 3 128-bit | ||||
* keys (K1, K2 and K3) */ | * keys (K1, K2 and K3) */ | ||||
/* Constants for XCBC MAC algorithm */ | /* Constants for XCBC MAC algorithm */ | ||||
#define LAC_HASH_XCBC_MAC_BLOCK_SIZE 16 | #define LAC_HASH_XCBC_MAC_BLOCK_SIZE 16 | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
* This is set to the block size of SHA512. */ | * This is set to the block size of SHA512. */ | ||||
#define LAC_MAX_INNER_OUTER_PREFIX_SIZE_BYTES 255 | #define LAC_MAX_INNER_OUTER_PREFIX_SIZE_BYTES 255 | ||||
/**< Maximum size of the inner and outer prefix for nested hashing operations. | /**< Maximum size of the inner and outer prefix for nested hashing operations. | ||||
* This is got from the maximum size supported by the accelerator which stores | * This is got from the maximum size supported by the accelerator which stores | ||||
* the size in an 8bit field */ | * the size in an 8bit field */ | ||||
#define LAC_MAX_HASH_STATE_STORAGE_SIZE \ | #define LAC_MAX_HASH_STATE_STORAGE_SIZE \ | ||||
(sizeof(icp_qat_hw_auth_counter_t) + LAC_HASH_SHA512_STATE_SIZE) | (sizeof(icp_qat_hw_auth_counter_t) + LAC_HASH_SHA3_STATEFUL_STATE_SIZE) | ||||
/**< Maximum size of the hash state storage section of the hash state prefix | /**< Maximum size of the hash state storage section of the hash state prefix | ||||
* buffer */ | * buffer */ | ||||
#define LAC_MAX_HASH_STATE_BUFFER_SIZE_BYTES \ | #define LAC_MAX_HASH_STATE_BUFFER_SIZE_BYTES \ | ||||
LAC_MAX_HASH_STATE_STORAGE_SIZE + \ | LAC_MAX_HASH_STATE_STORAGE_SIZE + \ | ||||
(LAC_ALIGN_POW2_ROUNDUP(LAC_MAX_INNER_OUTER_PREFIX_SIZE_BYTES, \ | (LAC_ALIGN_POW2_ROUNDUP(LAC_MAX_INNER_OUTER_PREFIX_SIZE_BYTES, \ | ||||
LAC_QUAD_WORD_IN_BYTES) * \ | LAC_QUAD_WORD_IN_BYTES) * \ | ||||
2) | 2) | ||||
/**< Maximum size of the hash state prefix buffer will be for nested hash when | /**< Maximum size of the hash state prefix buffer will be for nested hash when | ||||
* there is the maximum sized inner prefix and outer prefix */ | * there is the maximum sized inner prefix and outer prefix */ | ||||
#define LAC_MAX_AAD_SIZE_BYTES 256 | #define LAC_MAX_AAD_SIZE_BYTES 256 | ||||
/**< Maximum size of AAD in bytes */ | /**< Maximum size of AAD in bytes */ | ||||
#define IS_HMAC_ALG(algorithm) \ | #define IS_HMAC_ALG(algorithm) \ | ||||
((algorithm == CPA_CY_SYM_HASH_MD5) || \ | ((algorithm == CPA_CY_SYM_HASH_MD5) || \ | ||||
(algorithm == CPA_CY_SYM_HASH_SHA1) || \ | (algorithm == CPA_CY_SYM_HASH_SHA1) || \ | ||||
(algorithm == CPA_CY_SYM_HASH_SHA224) || \ | (algorithm == CPA_CY_SYM_HASH_SHA224) || \ | ||||
(algorithm == CPA_CY_SYM_HASH_SHA256) || \ | (algorithm == CPA_CY_SYM_HASH_SHA256) || \ | ||||
(algorithm == CPA_CY_SYM_HASH_SHA384) || \ | (algorithm == CPA_CY_SYM_HASH_SHA384) || \ | ||||
(algorithm == CPA_CY_SYM_HASH_SHA512) || \ | (algorithm == CPA_CY_SYM_HASH_SHA512) || \ | ||||
(algorithm == CPA_CY_SYM_HASH_SHA3_224) || \ | (algorithm == CPA_CY_SYM_HASH_SM3)) || \ | ||||
(algorithm == CPA_CY_SYM_HASH_SHA3_256) || \ | (LAC_HASH_IS_SHA3(algorithm)) | ||||
(algorithm == CPA_CY_SYM_HASH_SHA3_384) || \ | |||||
(algorithm == CPA_CY_SYM_HASH_SHA3_512) || \ | |||||
(algorithm == CPA_CY_SYM_HASH_SM3)) | |||||
/**< @ingroup LacSymQatHash | /**< @ingroup LacSymQatHash | ||||
* Macro to detect if the hash algorithm is a HMAC algorithm */ | * Macro to detect if the hash algorithm is a HMAC algorithm */ | ||||
#define IS_HASH_MODE_1(qatHashMode) (ICP_QAT_HW_AUTH_MODE1 == qatHashMode) | #define IS_HASH_MODE_1(qatHashMode) (ICP_QAT_HW_AUTH_MODE1 == qatHashMode) | ||||
/**< @ingroup LacSymQatHash | /**< @ingroup LacSymQatHash | ||||
* Macro to detect is qat hash mode is set to 1 (precompute mode) | * Macro to detect is qat hash mode is set to 1 (precompute mode) | ||||
* only used with algorithms in hash mode CPA_CY_SYM_HASH_MODE_AUTH */ | * only used with algorithms in hash mode CPA_CY_SYM_HASH_MODE_AUTH */ | ||||
Show All 12 Lines | |||||
#define IS_HASH_MODE_2_NESTED(qatHashMode, hashMode) \ | #define IS_HASH_MODE_2_NESTED(qatHashMode, hashMode) \ | ||||
((IS_HASH_MODE_2(qatHashMode)) && \ | ((IS_HASH_MODE_2(qatHashMode)) && \ | ||||
(CPA_CY_SYM_HASH_MODE_NESTED == hashMode)) | (CPA_CY_SYM_HASH_MODE_NESTED == hashMode)) | ||||
/**< @ingroup LacSymQatHash | /**< @ingroup LacSymQatHash | ||||
* Macro to check for qat hash mode is set to 2 and the LAC hash mode is | * Macro to check for qat hash mode is set to 2 and the LAC hash mode is | ||||
* Nested. This applies to TLS. This is used to differentiate between | * Nested. This applies to TLS. This is used to differentiate between | ||||
* TLS and HMAC */ | * TLS and HMAC */ | ||||
#define LAC_HASH_IS_SHA3(algo) \ | |||||
((algo == CPA_CY_SYM_HASH_SHA3_224) || \ | |||||
(algo == CPA_CY_SYM_HASH_SHA3_256) || \ | |||||
(algo == CPA_CY_SYM_HASH_SHA3_384) || \ | |||||
(algo == CPA_CY_SYM_HASH_SHA3_512)) | |||||
/**< @ingroup LacSymQatHash | |||||
* Macro to check if the hash algorithm is SHA3 */ | |||||
#endif /* LAC_SYM_HASH_DEFS_H */ | #endif /* LAC_SYM_HASH_DEFS_H */ |