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