1/* SPDX-License-Identifier: BSD-3-Clause */
2/* Copyright(c) 2007-2022 Intel Corporation */
3
4/**
5 *****************************************************************************
6 * @file lac_sym_qat_hash_defs_lookup.h
7 *
8 * @defgroup LacSymQatHashDefsLookup  Hash Defs Lookup
9 *
10 * @ingroup  LacSymQatHash
11 *
12 * API to be used for the hash defs lookup table.
13 *
14 *****************************************************************************/
15
16#ifndef LAC_SYM_QAT_HASH_DEFS_LOOKUP_P_H
17#define LAC_SYM_QAT_HASH_DEFS_LOOKUP_P_H
18
19#include "cpa.h"
20#include "cpa_cy_sym.h"
21
22/**
23******************************************************************************
24* @ingroup LacSymQatHashDefsLookup
25*      Finishing Hash algorithm
26* @description
27*      This define points to the last available hash algorithm
28* @NOTE: If a new algorithm is added to the api, this #define
29* MUST be updated to being the last hash algorithm in the struct
30* CpaCySymHashAlgorithm in the file cpa_cy_sym.h
31*****************************************************************************/
32#define CPA_CY_HASH_ALG_END CPA_CY_SYM_HASH_SM3
33
34/***************************************************************************/
35
36/**
37******************************************************************************
38* @ingroup LacSymQatHashDefsLookup
39*      hash algorithm specific structure
40* @description
41*      This structure contain constants specific to an algorithm.
42*****************************************************************************/
43typedef struct lac_sym_qat_hash_alg_info_s {
44	Cpa32U digestLength; /**< Digest length in bytes */
45	Cpa32U blockLength;  /**< Block length in bytes */
46	Cpa8U *initState;    /**< Initialiser state for hash algorithm */
47	Cpa32U stateSize;    /**< size of above state in bytes */
48} lac_sym_qat_hash_alg_info_t;
49
50/**
51******************************************************************************
52* @ingroup LacSymQatHashDefsLookup
53*      hash qat specific structure
54* @description
55*      This structure contain constants as defined by the QAT for an
56*      algorithm.
57*****************************************************************************/
58typedef struct lac_sym_qat_hash_qat_info_s {
59	Cpa32U algoEnc;      /**< QAT Algorithm encoding */
60	Cpa32U authCounter;  /**< Counter value for Auth */
61	Cpa32U state1Length; /**< QAT state1 length in bytes */
62	Cpa32U state2Length; /**< QAT state2 length in bytes */
63} lac_sym_qat_hash_qat_info_t;
64
65/**
66******************************************************************************
67* @ingroup LacSymQatHashDefsLookup
68*      hash defs structure
69* @description
70*      This type contains pointers to the hash algorithm structure and
71*      to the hash qat specific structure
72*****************************************************************************/
73typedef struct lac_sym_qat_hash_defs_s {
74	lac_sym_qat_hash_alg_info_t *algInfo;
75	/**< pointer to hash info structure */
76	lac_sym_qat_hash_qat_info_t *qatInfo;
77	/**< pointer to hash QAT info structure */
78} lac_sym_qat_hash_defs_t;
79
80/**
81*******************************************************************************
82* @ingroup LacSymQatHashDefsLookup
83*      initialise the hash lookup table
84*
85* @description
86*      This function initialises the digest lookup table.
87*
88* @note
89*      This function does not have a corresponding shutdown function.
90*
91* @return CPA_STATUS_SUCCESS   Operation successful
92* @return CPA_STATUS_RESOURCE  Allocating of hash lookup table failed
93*
94*****************************************************************************/
95CpaStatus LacSymQat_HashLookupInit(CpaInstanceHandle instanceHandle);
96
97/**
98*******************************************************************************
99* @ingroup LacSymQatHashDefsLookup
100*      get hash algorithm specific structure from lookup table
101*
102* @description
103*      This function looks up the hash lookup array for a structure
104*      containing data specific to a hash algorithm. The hashAlgorithm enum
105*      value MUST be in the correct range prior to calling this function.
106*
107* @param[in]  hashAlgorithm     Hash Algorithm
108* @param[out] ppHashAlgInfo     Hash Alg Info structure
109*
110* @return None
111*
112*****************************************************************************/
113void LacSymQat_HashAlgLookupGet(CpaInstanceHandle instanceHandle,
114				CpaCySymHashAlgorithm hashAlgorithm,
115				lac_sym_qat_hash_alg_info_t **ppHashAlgInfo);
116
117/**
118*******************************************************************************
119* @ingroup LacSymQatHashDefsLookup
120*      get hash defintions from lookup table.
121*
122* @description
123*      This function looks up the hash lookup array for a structure
124*      containing data specific to a hash algorithm. This includes both
125*      algorithm specific info and qat specific infro. The hashAlgorithm enum
126*      value MUST be in the correct range prior to calling this function.
127*
128* @param[in]  hashAlgorithm     Hash Algorithm
129* @param[out] ppHashDefsInfo    Hash Defs structure
130*
131* @return void
132*
133*****************************************************************************/
134void LacSymQat_HashDefsLookupGet(CpaInstanceHandle instanceHandle,
135				 CpaCySymHashAlgorithm hashAlgorithm,
136				 lac_sym_qat_hash_defs_t **ppHashDefsInfo);
137
138#endif /* LAC_SYM_QAT_HASH_DEFS_LOOKUP_P_H */
139