Skip to content

Commit 7a74199

Browse files
bjayanaxYogaraj-AlamendaponnamsxPremkumarxrbokkax
committed
FIPS 140-3 Certification requirements support.
- Self tests, Integrity tests, CAVP tests, Zeroization, Critical func tests, etc. - QAT_HW Algos: RSA, ECDSA, ECDH, ECDHX25519/X448, AES-GCM, DSA, DH, PRF, HKDF & SHA3 - QAT_SW Algos: RSA, ECDSA, ECDH, ECDHX25519, AES-GCM & SHA2. Signed-off-by: Jaya Naga Venkata Sudhakar <bavirisettyx.jaya.naga.venkata.sudhakar@intel.com> Co-authored-by: Yogaraj Alamenda <yogarajx.alamenda@intel.com> Co-authored-by: Ponnam Srinivas <ponnamx.srinivas@intel.com> Co-authored-by: Premkumar Shanmugam <premkumarx.shanmugam@intel.com> Co-authored-by: Ravali Bokka <ravalix.bokka@intel.com>
1 parent ac1eb90 commit 7a74199

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+9875
-496
lines changed

Makefile.am

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ if QAT_PROVIDER
5353
qat_prov_capabilities.c \
5454
qat_prov_chachapoly.c \
5555
qat_prov_sign_sm2.c
56+
if QAT_FIPS
57+
QAT_FIPS_SRC = qat_fips.c \
58+
qat_self_test_kats.c \
59+
qat_self_test_tls_prf.c \
60+
qat_prov_cmvp.c \
61+
qat_prov_sha2.c \
62+
qat_sw_sha2.c
63+
endif
5664
endif
5765

5866
if QAT_OPENSSL_3
@@ -136,6 +144,7 @@ endif
136144

137145
@LIBQATNAME@_la_SOURCES = ${QAT_COMMON_SRC} \
138146
${QAT_PROV_SRC} \
147+
${QAT_FIPS_SRC} \
139148
${QAT_ERR_SRC} \
140149
${QAT_HW_SRC} \
141150
${QAT_HW_MEM_SRC} \
@@ -204,4 +213,9 @@ else
204213
-rebuild -reindex `ls *.c | sed "s/qat_bssl_err.c//"`
205214
endif
206215

216+
if QAT_FIPS
217+
intkat:
218+
$(shell ./intkat.sh)
219+
endif
207220
include test.am
221+

configure.ac

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ AC_ARG_ENABLE(qat_sw_gcm,
9494
[Disable qat_sw AES-GCM acceleration]))
9595
AC_SUBST(enable_qat_sw_gcm)
9696

97+
AC_ARG_ENABLE(qat_sw_sha2,
98+
AS_HELP_STRING([--disable-qat_sw_sha2],
99+
[Disable qat_sw SHA2 acceleration]))
100+
101+
AC_SUBST(enable_qat_sw_sha2)
102+
97103
AC_ARG_ENABLE(qat_sw_rsa,
98104
AS_HELP_STRING([--disable-qat_sw_rsa],
99105
[Disable qat_sw RSA acceleration]))
@@ -284,6 +290,10 @@ AC_ARG_ENABLE(qat_plock,
284290
AS_HELP_STRING([--enable-qat_plock],
285291
[Enable plock, an optimized read-write lock which replaces pthread read/write lock]))
286292
AC_SUBST(enable_qat_plock)
293+
AC_ARG_ENABLE(qat_fips,
294+
AS_HELP_STRING([--enable-qat_fips],
295+
[Enables FIPS support]))
296+
AC_SUBST(enable_qat_fips)
287297

288298
AC_ARG_ENABLE(qat_ntls,
289299
AS_HELP_STRING([--enable-qat_ntls],
@@ -501,6 +511,7 @@ then
501511
AC_SUBST([enable_qat_sw_sm2], ["no"])
502512
AC_SUBST([enable_qat_sw_sm4_cbc], ["no"])
503513
AC_SUBST([enable_qat_sw_heuristic_timeout], ["no"])
514+
AC_SUBST([enable_qat_sw_sha2], ["no"])
504515
fi
505516
fi
506517

@@ -579,6 +590,8 @@ if test "x$cflags_qat_sw_ipsec" != "x"
579590
then
580591
AS_IF([test "x$enable_qat_sw_gcm" != "xno"],
581592
[cflags_qat_sw_ipsec+=" -DENABLE_QAT_SW_GCM"; AC_MSG_NOTICE([Accelerating GCM to Software (IPSec_mb)])])
593+
AS_IF([test "x$enable_qat_sw_sha2" != "xno"],
594+
[cflags_qat_sw_ipsec+=" -DENABLE_QAT_SW_SHA2"; AC_MSG_NOTICE([Accelerating SHA2 to Software (IPSec_mb)])])
582595
fi
583596

584597
if test "x$cflags_qat_hw" != "x" -a "x$cflags_qat_sw" != "x"
@@ -617,6 +630,10 @@ AS_IF([test "x$enable_qat_plock" = "xyes"],
617630
[cflags_common="${cflags_common} -DQAT_PLOCK"; AC_MSG_NOTICE([plock enabled])])
618631
AM_CONDITIONAL([QAT_PLOCK], [test "x$enable_qat_plock" != "x"])
619632

633+
AS_IF([test "x$enable_qat_fips" = "xyes"],
634+
[cflags_common="${cflags_common} -DENABLE_QAT_FIPS"; AC_MSG_NOTICE([FIPS Support enabled])])
635+
AM_CONDITIONAL([QAT_FIPS], [test "x$enable_qat_fips" != "x"])
636+
620637
AS_IF([test "x$enable_qat_sw_heuristic_timeout" = "xyes" -a "x$cflags_qat_sw" != "x"],
621638
[cflags_common="${cflags_common} -DQAT_SW_HEURISTIC_TIMEOUT"; AC_MSG_NOTICE([QAT_SW Heuristic Timeout enabled])])
622639

docs/config_options.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ The following is a list of the options that can be used with the
118118
interface. Currently RSA, ECDSA, ECDH, ECX and AES-GCM algorithms are
119119
only supported (disabled by default).
120120
121+
--enable-qat_fips
122+
Enables FIPS support when provider is enabled. Valid only
123+
when built against OpenSSL 3.0 along with the flag `--enable-qat_provider`,
124+
(disabled by default).
125+
121126
--disable-qat_hw_rsa/--enable-qat_hw_rsa
122127
Disable/Enable Intel(R) QAT Hardware RSA acceleration (enabled by default).
123128

docs/features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Please refer [here](qat_hw_algo.md) for supported platforms list and default beh
5353
## Common Features to qat_hw & qat_sw
5454
* [QAT_HW & QAT_SW Co-existence with runtime configuration](qat_common.md#qat-hw-and-qat-sw-co-existence)
5555
* [OpenSSL 3.0 Provider Support](qat_common.md#openssl-30-provider-support)
56+
* [FIPS Support](qat_common.md#fips-support)
5657

5758
Note: RSA Padding schemes are handled by OpenSSL\* or BoringSSL\* rather than accelerated, so the
5859
engine supports the same padding schemes as OpenSSL\* or BoringSSL\* does natively.

docs/qat_common.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,19 @@ Example OpenSSL Speed command to test using qatprovider:
136136
./openssl speed -provider qatprovider -elapsed -async_jobs 72 rsa2048
137137
* QAT_SW
138138
./openssl speed -provider qatprovider -elapsed -async_jobs 8 rsa2048
139+
140+
# FIPS 140-3 Certification requirements Support
141+
142+
Intel&reg; QAT OpenSSL\* Engine contains changes to fulfill FIPS 140-3 Level 1 Certification requirements
143+
using QAT Provider against OpenSSL 3.0
144+
The FIPS support can be enabled using the configure flag `--enable-qat_fips`
145+
only with OpenSSL 3.0 using provider interface which needs to be enabled using `--enable-qat_provider`.
146+
147+
When FIPS flag is enabled along with provider for OpenSSL3.0, it will run self tests, integrity tests
148+
and will satisfy other FIPS 140-3 CMVP & CAVP requirements.
149+
The FIPS is build as RPM using the spec file fips/qatengine_fips.spec with QAT_HW & QAT_SW Coexistence
150+
enabled along with other flags enabled.
151+
152+
## Support Algorithms in FIPS mode
153+
QAT_HW target: RSA, ECDSA, ECDH, ECDHX25519, ECDHX448, AES_GCM, DSA, DH, PRF, HKDF & SHA3 algorithms.
154+
QAT_SW target: RSA, ECDSA, ECDH, ECDHX25519, AES_GCM & SHA2 algorithms.

e_qat.c

Lines changed: 78 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
#endif /* QAT_BORINGSSL */
125125
#endif
126126

127+
#ifdef QAT_SW_IPSEC
128+
# if defined(ENABLE_QAT_FIPS) && defined(ENABLE_QAT_SW_SHA2)
129+
# include "qat_sw_sha2.h"
130+
# endif
131+
#endif
132+
127133
/* OpenSSL Includes */
128134
#include <openssl/err.h>
129135
#include <openssl/objects.h>
@@ -137,7 +143,6 @@
137143
# define Genu 0x756e6547
138144
# define ineI 0x49656e69
139145
# define ntel 0x6c65746e
140-
141146
# define VAES_BIT 9
142147
# define VPCLMULQDQ_BIT 10
143148
# define AVX512F_BIT 16
@@ -149,6 +154,11 @@
149154
# define QAT_ENGINE_ID qatengine
150155
#endif
151156

157+
#ifdef ENABLE_QAT_FIPS
158+
int qat_fips_key_zeroize;
159+
int qat_fips_kat_test;
160+
#endif
161+
152162
/* Qat engine id declaration */
153163
const char *engine_qat_id = STR(QAT_ENGINE_ID);
154164
#if defined(QAT_HW) && defined(QAT_SW)
@@ -184,6 +194,14 @@ int qat_hw_sm4_cbc_offload = 0;
184194
int qat_sw_sm2_offload = 0;
185195
int qat_hw_sha_offload = 0;
186196
int qat_hw_sm3_offload = 0;
197+
# ifdef ENABLE_QAT_FIPS
198+
int qat_sw_sha_offload = 0;
199+
# endif
200+
# ifdef QAT_OPENSSL_PROVIDER
201+
int qat_hw_dsa_offload = 0;
202+
int qat_hw_dh_offload = 0;
203+
int qat_hw_ecx_448_offload = 0;
204+
# endif
187205
int qat_sw_sm3_offload = 0;
188206
int qat_sw_sm4_cbc_offload = 0;
189207
int qat_sw_sm4_gcm_offload = 0;
@@ -216,11 +234,13 @@ pthread_cond_t qat_poll_condition = PTHREAD_COND_INITIALIZER;
216234
# define QAT_CONFIG_SECTION_NAME_SIZE 64
217235
char qat_config_section_name[QAT_CONFIG_SECTION_NAME_SIZE] = "SHIM";
218236
char *ICPConfigSectionName_libcrypto = qat_config_section_name;
219-
220237
int enable_inline_polling = 0;
221238
int enable_event_driven_polling = 0;
222239
int enable_instance_for_thread = 0;
223240
int disable_qat_offload = 0;
241+
/* By default Software fallback disabled in QAT FIPs mode.
242+
* Always enable_sw_fallback is zero in QAT FIPs mode.
243+
*/
224244
int enable_sw_fallback = 0;
225245
CpaInstanceHandle *qat_instance_handles = NULL;
226246
Cpa16U qat_num_instances = 0;
@@ -565,13 +585,18 @@ int qat_engine_init(ENGINE *e)
565585
#ifdef QAT_HW
566586
if (qat_hw_offload) {
567587
if (!qat_hw_init(e)) {
568-
# ifdef QAT_SW /* Co-Existence mode: Don't return failure when QAT HW initialization Failed. */
588+
# ifdef ENABLE_QAT_FIPS
589+
fprintf(stderr, "QAT_HW initialization Failed\n");
590+
return 0;
591+
# else
592+
# ifdef QAT_SW /* Co-Existence mode: Don't return failure when QAT HW initialization Failed. */
569593
fallback_to_qat_sw = 1;
570594
WARN("QAT HW initialization Failed, switching to QAT SW.\n");
571-
# else
595+
# else
572596
fprintf(stderr, "QAT HW initialization Failed.\n");
573597
qat_pthread_mutex_unlock();
574598
return 0;
599+
# endif
575600
# endif
576601
}
577602
}
@@ -580,8 +605,13 @@ int qat_engine_init(ENGINE *e)
580605
#ifdef QAT_SW
581606
if (qat_sw_offload) {
582607
if (!qat_sw_init(e)) {
608+
# ifdef ENABLE_QAT_FIPS
609+
fprintf(stderr, "QAT_SW initialization Failed\n");
610+
return 0;
611+
# else
583612
WARN("QAT SW initialization Failed, switching to OpenSSL.\n");
584613
fallback_to_openssl = 1;
614+
# endif
585615
}
586616
}
587617
#endif
@@ -625,7 +655,6 @@ int qat_engine_finish_int(ENGINE *e, int reset_globals)
625655
if (qat_sw_offload)
626656
ret = qat_sw_finish_int(e, reset_globals);
627657
#endif
628-
629658
engine_inited = 0;
630659

631660
if (reset_globals == QAT_RESET_GLOBALS) {
@@ -1092,10 +1121,10 @@ int bind_qat(ENGINE *e, const char *id)
10921121
return ret;
10931122
}
10941123

1095-
if (!ENGINE_set_EC(e, qat_get_EC_methods())) {
1096-
WARN("ENGINE_set_EC failed\n");
1097-
return ret;
1098-
}
1124+
if (!ENGINE_set_EC(e, qat_get_EC_methods())) {
1125+
WARN("ENGINE_set_EC failed\n");
1126+
return ret;
1127+
}
10991128

11001129
if (!ENGINE_set_pkey_meths(e, qat_pkey_methods)) {
11011130
WARN("ENGINE_set_pkey_meths failed\n");
@@ -1137,31 +1166,43 @@ int bind_qat(ENGINE *e, const char *id)
11371166
if (qat_hw_offload) {
11381167
# ifdef ENABLE_QAT_HW_RSA
11391168
qat_hw_rsa_offload = 1;
1140-
DEBUG("QAT_HW RSA for Provider Enabled\n");
1169+
INFO("QAT_HW RSA for Provider Enabled\n");
11411170
# endif
11421171
# ifdef ENABLE_QAT_HW_ECDSA
11431172
qat_hw_ecdsa_offload = 1;
1144-
DEBUG("QAT_HW ECDSA for Provider Enabled\n");
1173+
INFO("QAT_HW ECDSA for Provider Enabled\n");
11451174
# endif
11461175
# ifdef ENABLE_QAT_HW_ECDH
11471176
qat_hw_ecdh_offload = 1;
1148-
DEBUG("QAT_HW ECDH for Provider Enabled\n");
1177+
INFO("QAT_HW ECDH for Provider Enabled\n");
1178+
# endif
1179+
# ifdef ENABLE_QAT_HW_DSA
1180+
qat_hw_dsa_offload = 1;
1181+
INFO("QAT_HW DSA for Provider Enabled\n");
1182+
# endif
1183+
# ifdef ENABLE_QAT_HW_DH
1184+
qat_hw_dh_offload = 1;
1185+
INFO("QAT_HW DH for Provider Enabled\n");
11491186
# endif
11501187
# ifdef ENABLE_QAT_HW_ECX
11511188
qat_hw_ecx_offload = 1;
1152-
DEBUG("QAT_HW ECX for Provider Enabled\n");
1189+
INFO("QAT_HW ECX25519 for Provider Enabled\n");
1190+
# endif
1191+
# ifdef ENABLE_QAT_HW_ECX
1192+
qat_hw_ecx_448_offload = 1;
1193+
INFO("QAT_HW ECX448 for Provider Enabled\n");
11531194
# endif
11541195
# ifdef ENABLE_QAT_HW_PRF
11551196
qat_hw_prf_offload = 1;
1156-
DEBUG("QAT_HW PRF for Provider Enabled\n");
1197+
INFO("QAT_HW PRF for Provider Enabled\n");
11571198
# endif
11581199
# ifdef ENABLE_QAT_HW_HKDF
11591200
qat_hw_hkdf_offload = 1;
1160-
DEBUG("QAT_HW HKDF for Provider Enabled\n");
1201+
INFO("QAT_HW HKDF for Provider Enabled\n");
11611202
# endif
11621203
# ifdef ENABLE_QAT_HW_SHA3
11631204
qat_hw_sha_offload = 1;
1164-
DEBUG("QAT_HW SHA3 for Provider Enabled\n");
1205+
INFO("QAT_HW SHA3 for Provider Enabled\n");
11651206
# endif
11661207
# ifdef ENABLE_QAT_HW_GCM
11671208
if (!qat_sw_gcm_offload) {
@@ -1178,7 +1219,7 @@ int bind_qat(ENGINE *e, const char *id)
11781219
mbx_get_algo_info(MBX_ALGO_RSA_3K) &&
11791220
mbx_get_algo_info(MBX_ALGO_RSA_4K)) {
11801221
qat_sw_rsa_offload = 1;
1181-
DEBUG("QAT_SW RSA for Provider Enabled\n");
1222+
INFO("QAT_SW RSA for Provider Enabled\n");
11821223
}
11831224
# endif
11841225

@@ -1187,7 +1228,7 @@ int bind_qat(ENGINE *e, const char *id)
11871228
mbx_get_algo_info(MBX_ALGO_ECDSA_NIST_P256) &&
11881229
mbx_get_algo_info(MBX_ALGO_ECDSA_NIST_P384)) {
11891230
qat_sw_ecdsa_offload = 1;
1190-
DEBUG("QAT_SW ECDSA for Provider Enabled\n");
1231+
INFO("QAT_SW ECDSA for Provider Enabled\n");
11911232
}
11921233
# endif
11931234

@@ -1196,26 +1237,42 @@ int bind_qat(ENGINE *e, const char *id)
11961237
mbx_get_algo_info(MBX_ALGO_ECDHE_NIST_P256) &&
11971238
mbx_get_algo_info(MBX_ALGO_ECDHE_NIST_P384)) {
11981239
qat_sw_ecdh_offload = 1;
1199-
DEBUG("QAT_SW ECDH for Provider Enabled\n");
1240+
INFO("QAT_SW ECDH for Provider Enabled\n");
12001241
}
12011242
# endif
12021243

12031244
# ifdef ENABLE_QAT_SW_ECX
12041245
if (!qat_hw_ecx_offload &&
12051246
mbx_get_algo_info(MBX_ALGO_X25519)) {
12061247
qat_sw_ecx_offload = 1;
1207-
DEBUG("QAT_SW X25519 for Provider Enabled\n");
1248+
INFO("QAT_SW X25519 for Provider Enabled\n");
12081249
}
12091250
# endif
12101251

12111252
# ifdef ENABLE_QAT_SW_GCM
12121253
qat_sw_gcm_offload = 1;
12131254
DEBUG("QAT_SW GCM for Provider Enabled\n");
1255+
# endif
1256+
# if defined(ENABLE_QAT_FIPS) && defined (ENABLE_QAT_SW_SHA2)
1257+
qat_sw_sha_offload = 1;
1258+
INFO("QAT_SW SHA2 for Provider Enabled\n");
1259+
1260+
if(!sha_init_ipsec_mb_mgr()) {
1261+
WARN("SHA IPSec_Mb Manager Initialization failed\n");
1262+
return 0;
1263+
}
12141264
# endif
12151265
}
12161266
/* Create static structures for ciphers now
12171267
* as this function will be called by a single thread. */
12181268
qat_create_ciphers();
1269+
# ifndef QAT_DEBUG
1270+
if (qat_sw_gcm_offload && !qat_hw_gcm_offload)
1271+
INFO("QAT_SW GCM for Provider Enabled\n");
1272+
1273+
if (qat_hw_gcm_offload && !qat_sw_gcm_offload)
1274+
INFO("QAT_HW GCM for Provider Enabled\n");
1275+
# endif
12191276
#endif
12201277

12211278
#ifndef QAT_BORINGSSL
@@ -1255,7 +1312,7 @@ int bind_qat(ENGINE *e, const char *id)
12551312

12561313
#ifndef OPENSSL_NO_DYNAMIC_ENGINE
12571314
IMPLEMENT_DYNAMIC_BIND_FN(bind_qat)
1258-
IMPLEMENT_DYNAMIC_CHECK_FN()
1315+
IMPLEMENT_DYNAMIC_CHECK_FN()
12591316
#endif /* ndef OPENSSL_NO_DYNAMIC_ENGINE */
12601317
/* initialize Qat Engine if OPENSSL_NO_DYNAMIC_ENGINE*/
12611318
#ifdef OPENSSL_NO_DYNAMIC_ENGINE

0 commit comments

Comments
 (0)