@@ -198,31 +198,42 @@ void qat_create_ciphers(void)
198198
199199 for (i = 0 ; i < num_cc ; i ++ ) {
200200 if (info [i ].cipher == NULL ) {
201+ switch (info [i ].nid ) {
202+ case NID_aes_128_gcm :
203+ case NID_aes_192_gcm :
204+ case NID_aes_256_gcm :
201205#ifdef QAT_SW_IPSEC
202- if (info [i ].nid == NID_aes_128_gcm ||
203- info [i ].nid == NID_aes_192_gcm ||
204- info [i ].nid == NID_aes_256_gcm ) {
205- info [i ].cipher = (EVP_CIPHER * )
206- vaesgcm_create_cipher_meth (info [i ].nid , info [i ].keylen );
207- }
206+ if (qat_sw_ipsec )
207+ info [i ].cipher = (EVP_CIPHER * )
208+ vaesgcm_create_cipher_meth (info [i ].nid , info [i ].keylen );
209+ #else
210+ # ifdef ENABLE_QAT_HW_GCM
211+ if (qat_offload ) {
212+ if (info [i ].nid != NID_aes_192_gcm )
213+ info [i ].cipher = (EVP_CIPHER * )
214+ qat_create_gcm_cipher_meth (info [i ].nid , info [i ].keylen );
215+ }
216+ # endif
208217#endif
218+ break ;
209219
210220#ifdef QAT_HW
211- if (qat_offload ) {
212- if (info [i ].nid == NID_aes_128_gcm ||
213- info [i ].nid == NID_aes_256_gcm ) {
214- # ifdef ENABLE_QAT_HW_GCM
215- info [i ].cipher = (EVP_CIPHER * )
216- qat_create_gcm_cipher_meth (info [i ].nid , info [i ].keylen );
217- # endif
218- } else {
221+ case NID_aes_128_cbc_hmac_sha1 :
222+ case NID_aes_128_cbc_hmac_sha256 :
223+ case NID_aes_256_cbc_hmac_sha1 :
224+ case NID_aes_256_cbc_hmac_sha256 :
225+ if (qat_offload )
219226 info [i ].cipher = (EVP_CIPHER * )
220227 qat_create_cipher_meth (info [i ].nid , info [i ].keylen );
221- }
222- }
228+ break ;
223229#endif
230+ default :
231+ /* Do nothing */
232+ break ;
233+ }
224234 }
225235 }
236+
226237}
227238
228239void qat_free_ciphers (void )
@@ -231,16 +242,26 @@ void qat_free_ciphers(void)
231242
232243 for (i = 0 ; i < num_cc ; i ++ ) {
233244 if (info [i ].cipher != NULL ) {
234- if (info [i ].nid == NID_aes_128_gcm ||
235- info [i ].nid == NID_aes_192_gcm ||
236- info [i ].nid == NID_aes_256_gcm ) {
245+ switch (info [i ].nid ) {
246+ case NID_aes_128_gcm :
247+ case NID_aes_192_gcm :
248+ case NID_aes_256_gcm :
237249#ifndef DISABLE_QAT_SW_GCM
238250 EVP_CIPHER_meth_free (info [i ].cipher );
239251#endif
240- } else {
241- #if !defined(DISABLE_QAT_HW_CIPHERS ) || !defined(DISABLE_QAT_HW_GCM )
252+ #ifndef DISABLE_QAT_HW_GCM
253+ if (info [i ].nid != NID_aes_192_gcm )
254+ EVP_CIPHER_meth_free (info [i ].cipher );
255+ #endif
256+ break ;
257+ case NID_aes_128_cbc_hmac_sha1 :
258+ case NID_aes_128_cbc_hmac_sha256 :
259+ case NID_aes_256_cbc_hmac_sha1 :
260+ case NID_aes_256_cbc_hmac_sha256 :
261+ #ifndef DISABLE_QAT_HW_CIPHERS
242262 EVP_CIPHER_meth_free (info [i ].cipher );
243263#endif
264+ break ;
244265 }
245266 info [i ].cipher = NULL ;
246267 }
0 commit comments