Skip to content

Commit 0945535

Browse files
ajitku4xYogaraj-Alamenda
authored andcommitted
Bug Fixes in testapp and with disable flags.
- Fix RSA testapp issue when no operation provided. - Fix issue with disable flags and gcm testapp issue. - Add AES-CBC ENCRYPT_THEN_MAC limitation in README. Signed-off-by: Yogaraj Alamenda <yogarajx.alamenda@intel.com>
1 parent ce99c7c commit 0945535

File tree

7 files changed

+60
-7
lines changed

7 files changed

+60
-7
lines changed

docs/limitations.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@
4242
* AES-CBC-HMAC-SHA chained ciphers does not support pipeline feature when built with
4343
OpenSSL 3.0 as the corresponding support is not available in OpenSSL 3.0.
4444
* There is a known issue with OpenSSL s_server application using qatprovider on OpenSSL 3.0.
45+
* QAT Engine doesn't support ENCRYPT_THEN_MAC(default) mode of operation meaning
46+
when Encrypt then MAC is negotiated for symmetric ciphers say AES-CBC, the requests will not
47+
get offloaded via QAT_HW, instead uses OpenSSL SW. Disable ENCRYPT_THEN_MAC with the flag
48+
`SSL_OP_NO_ENCRYPT_THEN_MAC` programmatically using SSL_CTX_set_options() to offload
49+
symmetric chained ciphers via QAT_HW. Please note disabling ENCRYPT_THEN_MAC has security
50+
implications.

qat_evp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ int qat_digest_nids[] = {
175175
};
176176
const int num_digest_nids = sizeof(qat_digest_nids) / sizeof(qat_digest_nids[0]);
177177

178-
#ifndef ENABLE_QAT_HW_SMALL_PKT_OFFLOAD
178+
#ifdef QAT_HW
179+
# ifndef ENABLE_QAT_HW_SMALL_PKT_OFFLOAD
179180
typedef struct cipher_threshold_table_s {
180181
int nid;
181182
int threshold;
@@ -203,6 +204,7 @@ static PKT_THRESHOLD qat_pkt_threshold_table[] = {
203204

204205
static int pkt_threshold_table_size =
205206
(sizeof(qat_pkt_threshold_table) / sizeof(qat_pkt_threshold_table[0]));
207+
# endif
206208
#endif
207209

208210
static EC_KEY_METHOD *qat_ec_method = NULL;
@@ -840,7 +842,8 @@ void qat_free_EC_methods(void)
840842
}
841843
}
842844

843-
#ifndef ENABLE_QAT_HW_SMALL_PKT_OFFLOAD
845+
#ifdef QAT_HW
846+
# ifndef ENABLE_QAT_HW_SMALL_PKT_OFFLOAD
844847
/******************************************************************************
845848
* function:
846849
* qat_pkt_threshold_table_set_threshold(const char *cn, int threshold)
@@ -898,4 +901,5 @@ int qat_pkt_threshold_table_get_threshold(int nid)
898901
WARN("nid %d not found in threshold table", nid);
899902
return 0;
900903
}
904+
# endif
901905
#endif

test/tests.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct test_params_t {
8585
int verify_only;
8686
int encrypt_only;
8787
int decrypt_only;
88+
int rsa_all;
8889
int async_jobs;
8990
ASYNC_JOB **jobs;
9091
ASYNC_WAIT_CTX **awcs;
@@ -101,6 +102,7 @@ struct async_additional_args_rsa {
101102
int verify_only;
102103
int encrypt_only;
103104
int decrypt_only;
105+
int rsa_all;
104106
int padding;
105107
};
106108

test/tests_aes128_gcm.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ static int run_aesgcm128_update(void *args)
121121

122122
EVP_CIPHER_CTX *ctx = NULL;
123123
EVP_CIPHER_CTX *dec_ctx = NULL;
124+
#ifndef QAT_OPENSSL_PROVIDER
125+
const EVP_CIPHER *c = ENGINE_get_cipher(e, NID_aes_128_gcm);
126+
127+
if (!c) {
128+
INFO("AES-128-GCM cipher disabled in QAT_Engine\n");
129+
e = NULL;
130+
}
131+
#endif
124132

125133
if (plaintext == NULL || ciphertext == NULL || dec_cipher == NULL) {
126134
INFO("# FAIL: [%s] --- Initial parameters malloc failed ! \n",
@@ -419,6 +427,12 @@ static int run_aesgcm128_tls(void *args)
419427

420428
EVP_CIPHER_CTX *ctx = NULL;
421429
EVP_CIPHER_CTX *dec_ctx = NULL;
430+
const EVP_CIPHER *c = ENGINE_get_cipher(e, NID_aes_128_gcm);
431+
432+
if (!c) {
433+
INFO("AES-128-GCM disabled in QAT_Engine\n");
434+
e = NULL;
435+
}
422436

423437
if (input == NULL) {
424438
INFO("# FAIL: [%s] --- Initial parameters malloc failed ! \n",

test/tests_aes256_gcm.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ static int run_aesgcm256_update(void *args)
126126

127127
EVP_CIPHER_CTX *ctx = NULL;
128128
EVP_CIPHER_CTX *dec_ctx = NULL;
129+
#ifndef QAT_OPENSSL_PROVIDER
130+
const EVP_CIPHER *c = ENGINE_get_cipher(e, NID_aes_256_gcm);
131+
132+
if (!c) {
133+
INFO("AES-256-GCM disabled in QAT_Engine\n");
134+
e = NULL;
135+
}
136+
#endif
129137

130138
if (plaintext == NULL || ciphertext == NULL || dec_cipher == NULL) {
131139
INFO("# FAIL: [%s] --- Initial parameters malloc failed ! \n",
@@ -432,6 +440,14 @@ static int run_aesgcm256_tls(void *args)
432440

433441
EVP_CIPHER_CTX *ctx = NULL;
434442
EVP_CIPHER_CTX *dec_ctx = NULL;
443+
#ifndef QAT_OPENSSL_PROVIDER
444+
const EVP_CIPHER *c = ENGINE_get_cipher(e, NID_aes_256_gcm);
445+
446+
if (!c) {
447+
INFO("AES-256-GCM disabled in QAT_Engine\n");
448+
e = NULL;
449+
}
450+
#endif
435451

436452
if (input == NULL) {
437453
INFO("# FAIL: [%s] --- Initial parameters malloc failed ! \n",

test/tests_aes_cbc_hmac_sha.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static inline int set_pkt_threshold(ENGINE *e, const char* cipher, int thr)
164164
ret = ENGINE_ctrl_cmd(e, "SET_CRYPTO_SMALL_PACKET_OFFLOAD_THRESHOLD",
165165
0, (void *)thr_str, NULL, 0);
166166
if (ret != 1)
167-
FAIL_MSG("Failed to set threshold %d for cipher %s\n", thr, cipher);
167+
WARN("Not able to set threshold %d for cipher %s\n", thr, cipher);
168168

169169
return ret;
170170
}
@@ -1143,6 +1143,11 @@ static int run_aes_cbc_hmac_sha(void *pointer)
11431143
*/
11441144
if (ti.e != NULL) {
11451145
ret = set_pkt_threshold(ti.e, ti.c->name, 0);
1146+
/* Set engine to NULL as threshhold will fail if NID not supported*/
1147+
if (ret != 1) {
1148+
ti.e = NULL;
1149+
ret = 1;
1150+
}
11461151
if (ret != 1)
11471152
return 0;
11481153
}

test/tests_rsa.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,9 @@ static int run_rsa(void *args)
21642164
int verify_only = extra_args->verify_only;
21652165
int encrypt_only = extra_args->encrypt_only;
21662166
int decrypt_only = extra_args->decrypt_only;
2167+
#ifndef QAT_OPENSSL_PROVIDER
2168+
int rsa_all = extra_args->rsa_all;
2169+
#endif
21672170
int pad = extra_args->padding;
21682171

21692172
#ifdef QAT_OPENSSL_PROVIDER
@@ -2570,7 +2573,7 @@ static int run_rsa(void *args)
25702573
}
25712574
} /* count for-loop */
25722575

2573-
if (encrypt_only || decrypt_only) {
2576+
if (encrypt_only || decrypt_only || rsa_all) {
25742577
/* Compare and verify the encrypted and decrypted message */
25752578
if (verify) {
25762579
if (memcmp(ptext, expectedPtext, plen))
@@ -2591,7 +2594,7 @@ static int run_rsa(void *args)
25912594
}
25922595
}
25932596

2594-
if (sign_only || verify_only || status) {
2597+
if (sign_only || verify_only || status || rsa_all) {
25952598
/* Compare and verify the signed and verified message */
25962599
if (verify) {
25972600
if (memcmp(verMsg, HashData, verLen)) {
@@ -2802,12 +2805,15 @@ static void rsa_tests_triage(TEST_PARAMS *args, int sign_only,
28022805
extra_args.encrypt_only = encrypt_only;
28032806
extra_args.decrypt_only = decrypt_only;
28042807

2808+
if (!sign_only && !verify_only && !encrypt_only && !decrypt_only) {
2809+
extra_args.rsa_all = 1;
2810+
}
28052811
for (i = 0; i < sizeof(padding) / sizeof(padding[0]); i++) {
28062812
extra_args.padding = padding[i];
28072813
if (((padding[i] == RSA_PKCS1_OAEP_PADDING) &&
2808-
(sign_only || verify_only)) ||
2814+
(sign_only || verify_only || extra_args.rsa_all)) ||
28092815
((padding[i] == RSA_X931_PADDING) &&
2810-
(encrypt_only || decrypt_only)))
2816+
(encrypt_only || decrypt_only || extra_args.rsa_all)))
28112817
continue;
28122818
if (!args->enable_async)
28132819
run_rsa(args);

0 commit comments

Comments
 (0)