Skip to content

Commit 804c1cc

Browse files
Fix API version for QAT_HW 2.0 driver & bug fixes.
Co-authored-by: Nagha Abirami <naghax.abirami@intel.com> Signed-off-by: Yogaraj Alamenda <yogarajx.alamenda@intel.com>
1 parent 8042faa commit 804c1cc

13 files changed

+45
-22
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ AM_CFLAGS = $(cflags_cc_opt) $(cflags_qat_hw_intree) \
149149
$(cflags_mem_driver) $(cflags_openssl_3) \
150150
$(cflags_boringssl) $(cflags_qat_hw) \
151151
$(cflags_qat_sw) $(cflags_qat_sw_ipsec) \
152-
$(cflags_common)
152+
$(cflags_common) $(cflags_qat_debug)
153153

154154
if QAT_BORINGSSL
155155
bin_PROGRAMS = qatengine_test

configure.ac

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ then
405405
if test "x$enable_qat_hw" != "xno"
406406
then
407407
AC_SUBST([cflags_qat_hw], ["-DQAT_HW"])
408+
AC_CHECK_FILE(${with_qat_hw_dir}/quickassist/lookaside/access_layer/src/common/crypto/kpt/crypto/lac_kpt_crypto_qat_comms.c,
409+
[cflags_qat_hw="${cflags_qat_hw} -DQAT20_OOT"], [])
408410
AC_MSG_NOTICE([QAT_HW acceleration enabled])
409411
else
410412
AC_MSG_NOTICE([QAT_HW acceleration disabled])
@@ -608,9 +610,6 @@ AM_CONDITIONAL([QAT_PLOCK], [test "x$enable_qat_plock" != "x"])
608610
AS_IF([test "x$enable_qat_sw_heuristic_timeout" = "xyes" -a "x$cflags_qat_sw" != "x"],
609611
[cflags_common="${cflags_common} -DQAT_SW_HEURISTIC_TIMEOUT"; AC_MSG_NOTICE([QAT_SW Heuristic Timeout enabled])])
610612

611-
AS_IF([test "x$with_qat_debug_file" != "x"],
612-
[cflags_common="${cflags_common} -DQAT_DEBUG_FILE_PATH=\$(with_qat_debug_file)"; AC_MSG_NOTICE([Debugs to file enabled])])
613-
614613
AS_IF([test "x$with_qat_engine_id" != "x"],
615614
[cflags_common="${cflags_common} -DQAT_ENGINE_ID=\$(with_qat_engine_id)"; AC_MSG_NOTICE([Using engine id other than default])])
616615

@@ -640,6 +639,13 @@ then
640639
AC_SUBST([QAT_LD_LIB], ["\$(with_ld_opt)"])
641640
fi
642641

642+
# Write logs to a debug file
643+
if test "x$with_qat_debug_file" != "x"
644+
then
645+
AC_SUBST([cflags_qat_debug], ["-DQAT_DEBUG_FILE_PATH=\$(with_qat_debug_file)"])
646+
AC_MSG_NOTICE([Debugs to file enabled])
647+
fi
648+
643649
#QAT_HW Memory Driver
644650
if test "x$cflags_qat_hw" != "x"
645651
then

qat_evp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ const EVP_CIPHER *qat_create_gcm_cipher_meth(int nid, int keylen)
748748

749749
if (!qat_sw_gcm_offload && !qat_hw_gcm_offload) {
750750
DEBUG("OpenSSL SW AES_GCM_%d registration succeeded\n", keylen*8);
751+
EVP_CIPHER_meth_free(c);
751752
return qat_gcm_cipher_sw_impl(nid);
752753
}
753754

qat_hw_chachapoly.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ const EVP_CIPHER *chachapoly_cipher_meth(int nid, int keylen)
164164
} else {
165165
qat_hw_chacha_poly_offload = 0;
166166
DEBUG("QAT HW CHACHA POLY is disabled, using OpenSSL SW\n");
167+
EVP_CIPHER_meth_free(c);
167168
return EVP_chacha20_poly1305();
168169
}
169170
# else

qat_hw_ciphers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ const EVP_CIPHER *qat_create_cipher_meth(int nid, int keylen)
275275
} else {
276276
qat_hw_aes_cbc_hmac_sha_offload = 0;
277277
DEBUG("QAT HW AES_CBC_%d_HMAC_SHA is disabled, using OpenSSL SW\n", keylen*8);
278+
EVP_CIPHER_meth_free(c);
278279
return qat_chained_cipher_sw_impl(nid);
279280
}
280281
}

qat_hw_ec.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ CpaCyEcFieldType qat_get_field_type(const EC_GROUP *group)
101101
return CPA_CY_EC_FIELD_TYPE_BINARY;
102102
}
103103

104-
#if CPA_CY_API_VERSION_NUM_MAJOR >= 3
104+
#if defined(QAT20_OOT) || defined(QAT_HW_INTREE)
105105
int qat_get_curve(CpaCyEcFieldType fieldType)
106106
{
107107
if (fieldType == CPA_CY_EC_FIELD_TYPE_PRIME)
@@ -140,7 +140,7 @@ int qat_ecdh_compute_key(unsigned char **outX, size_t *outlenX,
140140

141141
int inst_num = QAT_INVALID_INSTANCE;
142142
BIGNUM *xP = NULL, *yP = NULL;
143-
# if CPA_CY_API_VERSION_NUM_MAJOR >= 3
143+
# if defined(QAT20_OOT) || defined(QAT_HW_INTREE)
144144
CpaCyEcGenericPointMultiplyOpData *pOpData = NULL;
145145
# else
146146
CpaCyEcPointMultiplyOpData *opData = NULL;
@@ -184,7 +184,7 @@ int qat_ecdh_compute_key(unsigned char **outX, size_t *outlenX,
184184
return ret;
185185
}
186186

187-
# if CPA_CY_API_VERSION_NUM_MAJOR >= 3
187+
# if defined(QAT20_OOT) || defined(QAT_HW_INTREE)
188188
pOpData = (CpaCyEcGenericPointMultiplyOpData *)
189189
OPENSSL_zalloc(sizeof(CpaCyEcGenericPointMultiplyOpData));
190190
if (pOpData == NULL) {
@@ -300,7 +300,7 @@ int qat_ecdh_compute_key(unsigned char **outX, size_t *outlenX,
300300
goto err;
301301
}
302302

303-
# if CPA_CY_API_VERSION_NUM_MAJOR >= 3
303+
# if defined(QAT20_OOT) || defined(QAT_HW_INTREE)
304304
pOpData->pCurve->parameters.weierstrassParameters.fieldType = qat_get_field_type(group);
305305
pOpData->pCurve->curveType = qat_get_curve(pOpData->pCurve->parameters.weierstrassParameters.fieldType);
306306

@@ -423,7 +423,7 @@ int qat_ecdh_compute_key(unsigned char **outX, size_t *outlenX,
423423
}
424424

425425
CRYPTO_QAT_LOG("KX - %s\n", __func__);
426-
# if CPA_CY_API_VERSION_NUM_MAJOR >= 3
426+
# if defined(QAT20_OOT) || defined(QAT_HW_INTREE)
427427
DUMP_EC_GENERIC_POINT_MULTIPLY(qat_instance_handles[inst_num], pOpData, pResultX, pResultY);
428428
status = cpaCyEcGenericPointMultiply(qat_instance_handles[inst_num],
429429
qat_ecCallbackFn,
@@ -595,7 +595,7 @@ int qat_ecdh_compute_key(unsigned char **outX, size_t *outlenX,
595595
OPENSSL_free(pResultY);
596596
}
597597

598-
# if CPA_CY_API_VERSION_NUM_MAJOR >= 3
598+
# if defined(QAT20_OOT) || defined(QAT_HW_INTREE)
599599
if (pOpData) {
600600
QAT_CHK_CLNSE_QMFREE_NONZERO_FLATBUFF(pOpData->k);
601601
QAT_CHK_QMFREE_FLATBUFF(pOpData->xP);

qat_hw_prf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
* down in the driver.
7272
*/
7373
# ifdef ENABLE_QAT_HW_PRF
74-
# if CPA_CY_API_VERSION_NUM_MAJOR > 2
74+
# if defined(QAT20_OOT) || defined(QAT_HW_INTREE)
7575
# define QAT_TLS1_PRF_SECRET_MAXBUF 1024
7676
# else
7777
# define QAT_TLS1_PRF_SECRET_MAXBUF 512

qat_hw_rsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
#else
8989
# define RSA_QAT_RANGE_MIN 2048
9090
#endif
91-
#if CPA_CY_API_VERSION_NUM_MAJOR > 2
91+
#if defined(QAT20_OOT) || defined(QAT_HW_INTREE)
9292
# define RSA_QAT_RANGE_MAX 8192
9393
#else
9494
# define RSA_QAT_RANGE_MAX 4096

qat_hw_sha3.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ const EVP_MD *qat_create_sha3_meth(int nid , int key_type)
163163
} else {
164164
qat_hw_sha_offload = 0;
165165
DEBUG("QAT HW SHA3 is disabled, using OpenSSL SW\n");
166+
EVP_MD_meth_free(c);
166167
return qat_sha3_sw_impl(nid);
167168
}
168169
#else
@@ -983,15 +984,14 @@ static int qat_sha3_final(EVP_MD_CTX *ctx, unsigned char *md)
983984

984985
/* Copy digest result into "md" buffer. */
985986
memcpy(md, sha3_ctx->digest_data, sha3_ctx->md_size);
987+
memset(sha3_ctx->digest_data, 0x00, sha3_ctx->md_size);
986988

989+
#ifndef QAT_OPENSSL_PROVIDER
987990
if (!qat_sha3_cleanup(ctx)) {
988991
WARN("qat_sha3_cleanup failed\n");
989992
QATerr(QAT_F_QAT_SHA3_FINAL, ERR_R_INTERNAL_ERROR);
990993
return 0;
991994
}
992-
993-
#ifdef QAT_OPENSSL_PROVIDER
994-
OPENSSL_clear_free(sha3_ctx, sizeof(qat_sha3_ctx));
995995
#endif
996996
return 1;
997997
}

qat_prov_bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static int bio_core_new(BIO *bio)
186186
return 1;
187187
}
188188

189-
static BIO_METHOD *ossl_prov_ctx_get0_core_bio_method(QAT_PROV_CTX *ctx)
189+
BIO_METHOD *ossl_prov_ctx_get0_core_bio_method(QAT_PROV_CTX *ctx)
190190
{
191191
if (ctx == NULL)
192192
return NULL;

0 commit comments

Comments
 (0)