Browse code

linux-secure: Add sha3 to canister

canister patches re-arrangements and cleanups.

Change-Id: Iea76e0d5cc6d3a7cc2e8e874e26a814e301a6185
Signed-off-by: Keerthana K <keerthanak@vmware.com>
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/c/photon/+/21066
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com>

Vamsi Krishna Brahmajosyula authored on 2023/06/26 19:48:48
Showing 13 changed files
... ...
@@ -64,6 +64,7 @@
64 64
 #include <crypto/scatterwalk.h>
65 65
 #include <crypto/sha1_base.h>
66 66
 #include <crypto/sha512_base.h>
67
+#include <crypto/sha3.h>
67 68
 
68 69
 static __ro_after_init bool alg_request_report = false;
69 70
 
... ...
@@ -481,4 +482,7 @@ EXPORT_SYMBOL(sha224_update);
481 481
 EXPORT_SYMBOL(sha256_final);
482 482
 EXPORT_SYMBOL(sha224_final);
483 483
 EXPORT_SYMBOL(sha256);
484
-/* End of Exports */
485 484
\ No newline at end of file
485
+EXPORT_SYMBOL(crypto_sha3_init);
486
+EXPORT_SYMBOL(crypto_sha3_update);
487
+EXPORT_SYMBOL(crypto_sha3_final);
488
+/* End of Exports */
... ...
@@ -1,7 +1,7 @@
1 1
 From f39f08830588a6fc9beb9f14217aed41dbbc888d Mon Sep 17 00:00:00 2001
2 2
 From: Alexey Makhalov <amakhalov@vmware.com>
3 3
 Date: Mon, 25 Jan 2021 19:34:10 -0800
4
-Subject: [PATCH 2/3] FIPS canister creation
4
+Subject: [PATCH 2/8] FIPS canister creation
5 5
 
6 6
 Canister creation patch.
7 7
  - Makefile changes to generate canister binary (fips_canister.o)
... ...
@@ -323,7 +323,7 @@ index a5b0cb3ef..10420b2aa 100644
323 323
  		err = skcipher_walk_done(&walk, 0);
324 324
  	}
325 325
 diff --git a/crypto/Makefile b/crypto/Makefile
326
-index 9a8372781..688a58b30 100644
326
+index c2ac25a65..cf8043262 100644
327 327
 --- a/crypto/Makefile
328 328
 +++ b/crypto/Makefile
329 329
 @@ -40,6 +40,13 @@ rsa_generic-y += rsaprivkey.asn1.o
... ...
@@ -340,7 +340,7 @@ index 9a8372781..688a58b30 100644
340 340
  
341 341
  $(obj)/sm2signature.asn1.o: $(obj)/sm2signature.asn1.c $(obj)/sm2signature.asn1.h
342 342
  $(obj)/sm2.o: $(obj)/sm2signature.asn1.h
343
-@@ -53,22 +60,38 @@ $(obj)/ecdsasignature.asn1.o: $(obj)/ecdsasignature.asn1.c $(obj)/ecdsasignature
343
+@@ -53,22 +60,40 @@ $(obj)/ecdsasignature.asn1.o: $(obj)/ecdsasignature.asn1.c $(obj)/ecdsasignature
344 344
  $(obj)/ecdsa.o: $(obj)/ecdsasignature.asn1.h
345 345
  ecdsa_generic-y += ecdsa.o
346 346
  ecdsa_generic-y += ecdsasignature.asn1.o
... ...
@@ -373,13 +373,15 @@ index 9a8372781..688a58b30 100644
373 373
 +canister += sha1_generic.o
374 374
 +canister += sha256_generic.o
375 375
 +canister += sha512_generic.o
376
++canister += sha3_generic.o
376 377
 +CFLAGS_REMOVE_sha1_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
377 378
 +CFLAGS_REMOVE_sha256_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
378 379
 +CFLAGS_REMOVE_sha512_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
379
- obj-$(CONFIG_CRYPTO_SHA3) += sha3_generic.o
380
++CFLAGS_REMOVE_sha3_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
380 381
  obj-$(CONFIG_CRYPTO_SM3) += sm3.o
381 382
  obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
382
-@@ -78,13 +101,29 @@ CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/b
383
+ obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
384
+@@ -77,13 +102,29 @@ CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/b
383 385
  obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b_generic.o
384 386
  CFLAGS_blake2b_generic.o := -Wframe-larger-than=4096 #  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105930
385 387
  obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
... ...
@@ -409,7 +411,7 @@ index 9a8372781..688a58b30 100644
409 409
  obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
410 410
  obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
411 411
  aegis128-y := aegis128-core.o
412
-@@ -111,6 +150,8 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
412
+@@ -110,6 +151,8 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
413 413
  
414 414
  obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
415 415
  obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
... ...
@@ -418,7 +420,7 @@ index 9a8372781..688a58b30 100644
418 418
  obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
419 419
  obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
420 420
  obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
421
-@@ -118,7 +159,9 @@ obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
421
+@@ -117,7 +160,9 @@ obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
422 422
  obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
423 423
  obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
424 424
  CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
... ...
@@ -428,7 +430,7 @@ index 9a8372781..688a58b30 100644
428 428
  obj-$(CONFIG_CRYPTO_SM4) += sm4.o
429 429
  obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
430 430
  obj-$(CONFIG_CRYPTO_AES_TI) += aes_ti.o
431
-@@ -148,10 +191,15 @@ obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
431
+@@ -147,10 +192,15 @@ obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
432 432
  obj-$(CONFIG_CRYPTO_842) += 842.o
433 433
  obj-$(CONFIG_CRYPTO_RNG2) += rng.o
434 434
  obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
... ...
@@ -444,7 +446,7 @@ index 9a8372781..688a58b30 100644
444 444
  obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
445 445
  obj-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
446 446
  obj-$(CONFIG_CRYPTO_POLYVAL) += polyval-generic.o
447
-@@ -162,11 +210,16 @@ obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
447
+@@ -161,11 +211,16 @@ obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
448 448
  obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
449 449
  obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
450 450
  obj-$(CONFIG_CRYPTO_OFB) += ofb.o
... ...
@@ -461,10 +463,11 @@ index 9a8372781..688a58b30 100644
461 461
  
462 462
  $(obj)/ecrdsa_params.asn1.o: $(obj)/ecrdsa_params.asn1.c $(obj)/ecrdsa_params.asn1.h
463 463
  $(obj)/ecrdsa_pub_key.asn1.o: $(obj)/ecrdsa_pub_key.asn1.c $(obj)/ecrdsa_pub_key.asn1.h
464
-@@ -191,6 +244,60 @@ obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
464
+@@ -189,6 +244,61 @@ obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
465
+ # Key derivation function
465 466
  #
466 467
  obj-$(CONFIG_CRYPTO_KDF800108_CTR) += kdf_sp800108.o
467
- 
468
++
468 469
 +aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o
469 470
 +aesni-intel-$(CONFIG_64BIT) += aesni-intel_avx-x86_64.o aes_ctrby8_avx-x86_64.o
470 471
 +OBJECT_FILES_NON_STANDARD_x86-aesni-intel_avx-x86_64.o := y
... ...
@@ -1558,4 +1561,5 @@ index af5ad51d3..f3e132d6f 100644
1558 1558
  	unsigned char *Vbuf;
1559 1559
  	/* hash: static value 10.1.1.1 1b) hmac / ctr: key */
1560 1560
 -- 
1561
-2.40.0
1561
+2.19.0
1562
+
... ...
@@ -1,7 +1,7 @@
1 1
 From 6dca4744eec08e19aaf344399833d9f482924267 Mon Sep 17 00:00:00 2001
2 2
 From: Keerthana K <keerthanak@vmware.com>
3 3
 Date: Wed, 29 Mar 2023 10:40:59 +0000
4
-Subject: [PATCH] aesni_intel: Remove static call
4
+Subject: [PATCH 3/8] aesni_intel: Remove static call
5 5
 
6 6
 Signed-off-by: Keerthana K <keerthanak@vmware.com>
7 7
 ---
... ...
@@ -1,16 +1,15 @@
1 1
 From 8661a32500fadfb5e0247b6f37a249952010d5d5 Mon Sep 17 00:00:00 2001
2 2
 From: Keerthana K <keerthanak@vmware.com>
3 3
 Date: Wed, 17 May 2023 15:35:53 +0000
4
-Subject: [PATCH 1/2] Disable retpoline_sites and return_sites sections in
5
- canister
4
+Subject: [PATCH 4/8] Disable retpoline_sites and return_sites sections in canister
6 5
 
7 6
 Signed-off-by: Keerthana K <keerthanak@vmware.com>
8 7
 ---
9 8
  arch/x86/crypto/aes_ctrby8_avx-x86_64.S  |  1 +
10 9
  arch/x86/crypto/aesni-intel_asm.S        |  1 +
11 10
  arch/x86/crypto/aesni-intel_avx-x86_64.S |  1 +
12
- crypto/Makefile                          | 82 ++++++++++++------------
13
- 4 files changed, 44 insertions(+), 41 deletions(-)
11
+ crypto/Makefile                          | 91 +++++++++++++-----------
12
+ 4 files changed, 52 insertions(+), 42 deletions(-)
14 13
 
15 14
 diff --git a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
16 15
 index 2402b9418..d81759263 100644
... ...
@@ -49,7 +48,7 @@ index 0852ab573..8bef0e67c 100644
49 49
  # constants in mergeable sections, linker can reorder and merge
50 50
  .section	.rodata.cst16.POLY, "aM", @progbits, 16
51 51
 diff --git a/crypto/Makefile b/crypto/Makefile
52
-index 688a58b30..f2b8ffec2 100644
52
+index cf8043262..0395dff4c 100644
53 53
 --- a/crypto/Makefile
54 54
 +++ b/crypto/Makefile
55 55
 @@ -42,11 +42,11 @@ rsa_generic-y += rsa_helper.o
... ...
@@ -101,20 +100,22 @@ index 688a58b30..f2b8ffec2 100644
101 101
  obj-$(CONFIG_CRYPTO_VMAC) += vmac.o
102 102
  obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
103 103
  obj-$(CONFIG_CRYPTO_NULL2) += crypto_null.o
104
-@@ -89,9 +89,9 @@ obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
105
- canister += sha1_generic.o
104
+@@ -90,10 +90,10 @@ canister += sha1_generic.o
106 105
  canister += sha256_generic.o
107 106
  canister += sha512_generic.o
107
+ canister += sha3_generic.o
108 108
 -CFLAGS_REMOVE_sha1_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
109 109
 -CFLAGS_REMOVE_sha256_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
110 110
 -CFLAGS_REMOVE_sha512_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
111
+-CFLAGS_REMOVE_sha3_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
111 112
 +CFLAGS_REMOVE_sha1_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
112 113
 +CFLAGS_REMOVE_sha256_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
113 114
 +CFLAGS_REMOVE_sha512_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
114
- obj-$(CONFIG_CRYPTO_SHA3) += sha3_generic.o
115
++CFLAGS_REMOVE_sha3_generic.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
115 116
  obj-$(CONFIG_CRYPTO_SM3) += sm3.o
116 117
  obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
117
-@@ -103,18 +103,18 @@ CFLAGS_blake2b_generic.o := -Wframe-larger-than=4096 #  https://gcc.gnu.org/bugz
118
+ obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
119
+@@ -104,18 +104,18 @@ CFLAGS_blake2b_generic.o := -Wframe-larger-than=4096 #  https://gcc.gnu.org/bugz
118 120
  obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
119 121
  canister += ecb.o
120 122
  canister += cbc.o
... ...
@@ -139,7 +140,7 @@ index 688a58b30..f2b8ffec2 100644
139 139
  obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
140 140
  obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
141 141
  obj-$(CONFIG_CRYPTO_KEYWRAP) += keywrap.o
142
-@@ -122,8 +122,8 @@ obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
142
+@@ -123,8 +123,8 @@ obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
143 143
  obj-$(CONFIG_CRYPTO_NHPOLY1305) += nhpoly1305.o
144 144
  canister += gcm.o
145 145
  canister += ccm.o
... ...
@@ -150,7 +151,7 @@ index 688a58b30..f2b8ffec2 100644
150 150
  obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
151 151
  obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
152 152
  aegis128-y := aegis128-core.o
153
-@@ -151,7 +151,7 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
153
+@@ -152,7 +152,7 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
154 154
  obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
155 155
  obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
156 156
  canister += des_generic.o
... ...
@@ -159,7 +160,7 @@ index 688a58b30..f2b8ffec2 100644
159 159
  obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
160 160
  obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
161 161
  obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
162
-@@ -161,7 +161,7 @@ obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
162
+@@ -162,7 +162,7 @@ obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
163 163
  CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
164 164
  canister += aes_generic.o
165 165
  CFLAGS_aes_generic.o := $(call cc-option,-fno-code-hoisting) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83356
... ...
@@ -168,7 +169,7 @@ index 688a58b30..f2b8ffec2 100644
168 168
  obj-$(CONFIG_CRYPTO_SM4) += sm4.o
169 169
  obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
170 170
  obj-$(CONFIG_CRYPTO_AES_TI) += aes_ti.o
171
-@@ -192,14 +192,14 @@ obj-$(CONFIG_CRYPTO_842) += 842.o
171
+@@ -193,14 +193,14 @@ obj-$(CONFIG_CRYPTO_842) += 842.o
172 172
  obj-$(CONFIG_CRYPTO_RNG2) += rng.o
173 173
  obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
174 174
  canister += drbg.o
... ...
@@ -186,7 +187,7 @@ index 688a58b30..f2b8ffec2 100644
186 186
  obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
187 187
  obj-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
188 188
  obj-$(CONFIG_CRYPTO_POLYVAL) += polyval-generic.o
189
-@@ -211,15 +211,15 @@ obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
189
+@@ -212,15 +212,15 @@ obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
190 190
  obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
191 191
  obj-$(CONFIG_CRYPTO_OFB) += ofb.o
192 192
  canister += ecc.o
... ...
@@ -205,7 +206,7 @@ index 688a58b30..f2b8ffec2 100644
205 205
  
206 206
  $(obj)/ecrdsa_params.asn1.o: $(obj)/ecrdsa_params.asn1.c $(obj)/ecrdsa_params.asn1.h
207 207
  $(obj)/ecrdsa_pub_key.asn1.o: $(obj)/ecrdsa_pub_key.asn1.c $(obj)/ecrdsa_pub_key.asn1.h
208
-@@ -247,30 +247,30 @@ obj-$(CONFIG_CRYPTO_KDF800108_CTR) += kdf_sp800108.o
208
+@@ -248,30 +248,37 @@ obj-$(CONFIG_CRYPTO_KDF800108_CTR) += kdf_sp800108.o
209 209
  aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o
210 210
  aesni-intel-$(CONFIG_64BIT) += aesni-intel_avx-x86_64.o aes_ctrby8_avx-x86_64.o
211 211
  OBJECT_FILES_NON_STANDARD_x86-aesni-intel_avx-x86_64.o := y
... ...
@@ -213,6 +214,7 @@ index 688a58b30..f2b8ffec2 100644
213 213
 +CFLAGS_REMOVE_x86-aesni-intel_glue.o = -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
214 214
  
215 215
 -crypto/x86-%.o: arch/x86/crypto/%.c $(recordmcount_source) $(objtool_dep)
216
++
216 217
 +crypto/x86-%.o: arch/x86/crypto/%.c $(recordmcount_source) $(objtool_dep) FORCE
217 218
  	$(call cmd,force_checksrc)
218 219
  	$(call if_changed_rule,cc_o_c)
... ...
@@ -228,9 +230,13 @@ index 688a58b30..f2b8ffec2 100644
228 228
 -CFLAGS_REMOVE_lib-crypto-sha1.o = -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
229 229
 -crypto/lib-crypto-%.o: lib/crypto/%.c $(recordmcount_source) $(objtool_dep)
230 230
 +CFLAGS_REMOVE_lib-crypto-aes.o = -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
231
++
231 232
 +CFLAGS_REMOVE_lib-crypto-des.o = -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
233
++
232 234
 +CFLAGS_REMOVE_lib-crypto-sha256.o = -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
235
++
233 236
 +CFLAGS_REMOVE_lib-crypto-sha1.o = -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
237
++
234 238
 +crypto/lib-crypto-%.o: lib/crypto/%.c $(recordmcount_source) $(objtool_dep) FORCE
235 239
  	$(call cmd,force_checksrc)
236 240
  	$(call if_changed_rule,cc_o_c)
... ...
@@ -239,14 +245,16 @@ index 688a58b30..f2b8ffec2 100644
239 239
  CFLAGS_crypto_self_test.o += -DFIPS_NOT_ALLOWED=fcw_fips_not_allowed_alg
240 240
 -CFLAGS_REMOVE_crypto_self_test.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
241 241
 +CFLAGS_REMOVE_crypto_self_test.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
242
++
242 243
  
243 244
  canister += fips_integrity.o
244 245
 -CFLAGS_REMOVE_fips_integrity.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
245 246
 +CFLAGS_REMOVE_fips_integrity.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call $(RETPOLINE_CFLAGS) $(RETHUNK_CFLAGS)
247
++
246 248
  
247 249
  extra-y += $(canister)
248 250
  $(obj)/canister.o: $(addprefix crypto/x86-,$(aesni-intel-y)) $(addprefix crypto/lib-crypto-,$(lib-crypto-y)) $(addprefix $(obj)/,$(canister))
249
-@@ -287,7 +287,7 @@ $(src)/canister_relocs.c: $(obj)/canister.o $(obj)/gen_canister_relocs FORCE
251
+@@ -288,7 +295,7 @@ $(src)/canister_relocs.c: $(obj)/canister.o $(obj)/gen_canister_relocs FORCE
250 252
  clean-files += canister_relocs.c
251 253
  clean-files += fips_canister-kallsyms
252 254
  targets += canister_relocs.o
... ...
@@ -1,7 +1,7 @@
1 1
 From 426a6da48e195c99d2b217611cf99da054d917b2 Mon Sep 17 00:00:00 2001
2 2
 From: Keerthana K <keerthanak@vmware.com>
3 3
 Date: Wed, 17 May 2023 16:11:40 +0000
4
-Subject: [PATCH 2/2] Move __bug_table section to fips_canister_wrapper
4
+Subject: [PATCH 5/8] Move __bug_table section to fips_canister_wrapper
5 5
 
6 6
 Signed-off-by: Keerthana K <keerthanak@vmware.com>
7 7
 ---
... ...
@@ -29,13 +29,13 @@ Signed-off-by: Keerthana K <keerthanak@vmware.com>
29 29
  crypto/testmgr.c                   | 110 ++++++++++++++---------------
30 30
  crypto/xts.c                       |   2 +-
31 31
  lib/crypto/sha256.c                |   6 +-
32
- 27 files changed, 182 insertions(+), 174 deletions(-)
32
+ 24 files changed, 182 insertions(+), 174 deletions(-)
33 33
 
34 34
 diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
35
-index a6da1abb9..1b89d3c78 100644
35
+index 0628c2bca..6a4378bac 100644
36 36
 --- a/arch/x86/crypto/aesni-intel_glue.c
37 37
 +++ b/arch/x86/crypto/aesni-intel_glue.c
38
-@@ -37,6 +37,10 @@
38
+@@ -38,6 +38,10 @@
39 39
  
40 40
  void fcw_kernel_fpu_begin(void);
41 41
  void fcw_kernel_fpu_end(void);
... ...
@@ -46,7 +46,7 @@ index a6da1abb9..1b89d3c78 100644
46 46
  
47 47
  #define AESNI_ALIGN	16
48 48
  #define AESNI_ALIGN_ATTR __attribute__ ((__aligned__(AESNI_ALIGN)))
49
-@@ -608,7 +612,7 @@ static int xctr_crypt(struct skcipher_request *req)
49
+@@ -590,7 +594,7 @@ static int xctr_crypt(struct skcipher_request *req)
50 50
  		byte_ctr += walk.nbytes - nbytes;
51 51
  
52 52
  		if (walk.nbytes == walk.total && nbytes > 0) {
... ...
@@ -55,7 +55,7 @@ index a6da1abb9..1b89d3c78 100644
55 55
  			block[0] ^= cpu_to_le32(1 + byte_ctr / AES_BLOCK_SIZE);
56 56
  			aesni_enc(ctx, keystream, (u8 *)block);
57 57
  			crypto_xor_cpy(walk.dst.virt.addr + walk.nbytes -
58
-@@ -654,7 +658,7 @@ static int common_rfc4106_set_key(struct crypto_aead *aead, const u8 *key,
58
+@@ -636,7 +640,7 @@ static int common_rfc4106_set_key(struct crypto_aead *aead, const u8 *key,
59 59
  	/*Account for 4 byte nonce at the end.*/
60 60
  	key_len -= 4;
61 61
  
... ...
@@ -64,7 +64,7 @@ index a6da1abb9..1b89d3c78 100644
64 64
  
65 65
  	return aes_set_key_common(crypto_aead_tfm(aead),
66 66
  				  &ctx->aes_key_expanded, key, key_len) ?:
67
-@@ -697,8 +701,6 @@ static int generic_gcmaes_set_authsize(struct crypto_aead *tfm,
67
+@@ -679,8 +683,6 @@ static int generic_gcmaes_set_authsize(struct crypto_aead *tfm,
68 68
  	return 0;
69 69
  }
70 70
  
... ...
@@ -73,7 +73,7 @@ index a6da1abb9..1b89d3c78 100644
73 73
  static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req,
74 74
  			      unsigned int assoclen, u8 *hash_subkey,
75 75
  			      u8 *iv, void *aes_ctx, u8 *auth_tag,
76
-@@ -725,7 +727,7 @@ static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req,
76
+@@ -705,7 +707,7 @@ static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req,
77 77
  	/* Linearize assoc, if not already linear */
78 78
  	if (req->src->length >= assoclen && req->src->length) {
79 79
  		scatterwalk_start(&assoc_sg_walk, req->src);
... ...
@@ -82,7 +82,7 @@ index a6da1abb9..1b89d3c78 100644
82 82
  	} else {
83 83
  		gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
84 84
  			      GFP_KERNEL : GFP_ATOMIC;
85
-@@ -1157,7 +1159,7 @@ static int generic_gcmaes_encrypt(struct aead_request *req)
85
+@@ -1177,7 +1179,7 @@ static int generic_gcmaes_encrypt(struct aead_request *req)
86 86
  	u8 *iv = PTR_ALIGN(&ivbuf[0], AESNI_ALIGN);
87 87
  	__be32 counter = cpu_to_be32(1);
88 88
  
... ...
@@ -91,7 +91,7 @@ index a6da1abb9..1b89d3c78 100644
91 91
  	*((__be32 *)(iv+12)) = counter;
92 92
  
93 93
  	return gcmaes_encrypt(req, req->assoclen, ctx->hash_subkey, iv,
94
-@@ -1173,7 +1175,7 @@ static int generic_gcmaes_decrypt(struct aead_request *req)
94
+@@ -1193,7 +1195,7 @@ static int generic_gcmaes_decrypt(struct aead_request *req)
95 95
  	u8 ivbuf[16 + (AESNI_ALIGN - 8)] __aligned(8);
96 96
  	u8 *iv = PTR_ALIGN(&ivbuf[0], AESNI_ALIGN);
97 97
  
... ...
@@ -673,7 +673,7 @@ index 04624249a..e294af604 100644
673 673
  
674 674
  	alg->base.cra_priority = priority;
675 675
 diff --git a/crypto/ecc.c b/crypto/ecc.c
676
-index 016f785b8..714ff4e6d 100644
676
+index 016f785b8..ff9a0f156 100644
677 677
 --- a/crypto/ecc.c
678 678
 +++ b/crypto/ecc.c
679 679
 @@ -210,10 +210,7 @@ EXPORT_SYMBOL(vli_from_le64);
... ...
@@ -881,7 +881,7 @@ index 56e8a80aa..381b82530 100644
881 881
  
882 882
  /*
883 883
 diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c
884
-index 826dd0833..88039140f 100644
884
+index 826dd0833..f15e2bff2 100644
885 885
 --- a/crypto/rsa-pkcs1pad.c
886 886
 +++ b/crypto/rsa-pkcs1pad.c
887 887
 @@ -166,7 +166,7 @@ static void pkcs1pad_sg_set_buf(struct scatterlist *sg, void *buf, size_t len,
... ...
@@ -1054,7 +1054,7 @@ index 3f98fab3f..0105e631a 100644
1054 1054
  
1055 1055
  			iv_len = crypto_skcipher_ivsize(tfm);
1056 1056
 diff --git a/crypto/testmgr.c b/crypto/testmgr.c
1057
-index 98422b8da..592ce69c3 100644
1057
+index 98422b8da..65fcb40b4 100644
1058 1058
 --- a/crypto/testmgr.c
1059 1059
 +++ b/crypto/testmgr.c
1060 1060
 @@ -587,7 +587,7 @@ static int build_test_sglist(struct test_sglist *tsgl,
1061 1061
new file mode 100644
... ...
@@ -0,0 +1,57 @@
0
+From 06e988b1547114c603a337f10c8a6f944b911f24 Mon Sep 17 00:00:00 2001
1
+From: Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com>
2
+Date: Sun, 5 Mar 2023 18:43:14 +0530
3
+Subject: [PATCH 7/8] crypto: Add prandom, module_kthread_exit to canister
4
+ wrapper
5
+
6
+prandom_u32_max is a static inline function whose definition changed
7
+across versions.
8
+
9
+module_put_and_kthread_exit is not available in older kernels,
10
+module_put_and_exit was used earlier, added specific implementation
11
+in wrapper.
12
+
13
+Signed-off-by: Keerthana K <keerthanak@vmware.com>
14
+---
15
+ crypto/algboss.c      | 4 ++--
16
+ crypto/rsa-pkcs1pad.c | 2 +-
17
+ 2 files changed, 3 insertions(+), 3 deletions(-)
18
+
19
+diff --git a/crypto/algboss.c b/crypto/algboss.c
20
+index 328e000e6..757e5222f 100644
21
+--- a/crypto/algboss.c
22
+@@ -68,7 +68,7 @@ static int cryptomgr_probe(void *data)
23
+ 	complete_all(&param->larval->completion);
24
+ 	crypto_alg_put(&param->larval->alg);
25
+ 	kfree(param);
26
+-	module_put_and_kthread_exit(0);
27
++	fcw_module_put_and_kthread_exit(0);
28
+ }
29
+ 
30
+ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
31
+@@ -191,7 +191,7 @@ static int cryptomgr_test(void *data)
32
+ 	crypto_alg_tested(param->driver, err);
33
+ 
34
+ 	kfree(param);
35
+-	module_put_and_kthread_exit(0);
36
++	fcw_module_put_and_kthread_exit(0);
37
+ }
38
+ 
39
+ static int cryptomgr_schedule_test(struct crypto_alg *alg)
40
+diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c
41
+index f15e2bff2..979472edf 100644
42
+--- a/crypto/rsa-pkcs1pad.c
43
+@@ -254,7 +254,7 @@ static int pkcs1pad_encrypt(struct akcipher_request *req)
44
+ 	ps_end = ctx->key_size - req->src_len - 2;
45
+ 	req_ctx->in_buf[0] = 0x02;
46
+ 	for (i = 1; i < ps_end; i++)
47
+-		req_ctx->in_buf[i] = 1 + prandom_u32_max(255);
48
++		req_ctx->in_buf[i] = 1 + fcw_prandom_u32_max(255);
49
+ 	req_ctx->in_buf[ps_end] = 0x00;
50
+ 
51
+ 	pkcs1pad_sg_set_buf(req_ctx->in_sg, req_ctx->in_buf,
52
+-- 
53
+2.19.0
54
+
0 55
new file mode 100644
... ...
@@ -0,0 +1,565 @@
0
+From 45555b8e8ae2d97bf2e7f9425491e6bb83aa8b57 Mon Sep 17 00:00:00 2001
1
+From: Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com>
2
+Date: Mon, 22 May 2023 13:27:58 +0530
3
+Subject: [PATCH 8/8] crypto: Remove EXPORT_SYMBOL, EXPORT_SYMBOL_GPL from
4
+ canister
5
+
6
+Signed-off-by: Keerthana K <keerthanak@vmware.com
7
+---
8
+ crypto/aes_generic.c    |  5 -----
9
+ crypto/ecc.c            | 20 --------------------
10
+ crypto/ecdh_helper.c    |  5 +----
11
+ crypto/rsa_helper.c     |  2 --
12
+ crypto/sha1_generic.c   |  3 ---
13
+ crypto/sha256_generic.c |  4 ----
14
+ crypto/sha3_generic.c   |  8 +++-----
15
+ crypto/sha512_generic.c |  4 ----
16
+ crypto/testmgr.c        |  2 --
17
+ lib/crypto/aes.c        |  6 ------
18
+ lib/crypto/des.c        |  6 ------
19
+ lib/crypto/sha1.c       |  2 --
20
+ lib/crypto/sha256.c     |  5 -----
21
+ 13 files changed, 4 insertions(+), 68 deletions(-)
22
+
23
+diff --git a/crypto/aes_generic.c b/crypto/aes_generic.c
24
+index 27ab27931..f73022bed 100644
25
+--- a/crypto/aes_generic.c
26
+@@ -1118,9 +1118,6 @@ static const u32 crypto_il_tab[4][256] ____cacheline_aligned = {
27
+ 	}
28
+ };
29
+ 
30
+-EXPORT_SYMBOL_GPL(crypto_ft_tab);
31
+-EXPORT_SYMBOL_GPL(crypto_it_tab);
32
+-
33
+ /**
34
+  * crypto_aes_set_key - Set the AES key.
35
+  * @tfm:	The %crypto_tfm that is used in the context.
36
+@@ -1140,8 +1137,6 @@ int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
37
+ 
38
+ 	return aes_expandkey(ctx, in_key, key_len);
39
+ }
40
+-EXPORT_SYMBOL_GPL(crypto_aes_set_key);
41
+-
42
+ /* encrypt a block of text */
43
+ 
44
+ #define f_rn(bo, bi, n, k)	do {				\
45
+diff --git a/crypto/ecc.c b/crypto/ecc.c
46
+index ff9a0f156..f220aaac0 100644
47
+--- a/crypto/ecc.c
48
+@@ -50,7 +50,6 @@ const struct ecc_curve *ecc_get_curve25519(void)
49
+ {
50
+ 	return &ecc_25519;
51
+ }
52
+-EXPORT_SYMBOL(ecc_get_curve25519);
53
+ 
54
+ const struct ecc_curve *ecc_get_curve(unsigned int curve_id)
55
+ {
56
+@@ -66,7 +65,6 @@ const struct ecc_curve *ecc_get_curve(unsigned int curve_id)
57
+ 		return NULL;
58
+ 	}
59
+ }
60
+-EXPORT_SYMBOL(ecc_get_curve);
61
+ 
62
+ static u64 *ecc_alloc_digits_space(unsigned int ndigits)
63
+ {
64
+@@ -108,7 +106,6 @@ struct ecc_point *ecc_alloc_point(unsigned int ndigits)
65
+ 	kfree(p);
66
+ 	return NULL;
67
+ }
68
+-EXPORT_SYMBOL(ecc_alloc_point);
69
+ 
70
+ void ecc_free_point(struct ecc_point *p)
71
+ {
72
+@@ -119,7 +116,6 @@ void ecc_free_point(struct ecc_point *p)
73
+ 	kfree_sensitive(p->y);
74
+ 	kfree_sensitive(p);
75
+ }
76
+-EXPORT_SYMBOL(ecc_free_point);
77
+ 
78
+ static void vli_clear(u64 *vli, unsigned int ndigits)
79
+ {
80
+@@ -141,7 +137,6 @@ bool vli_is_zero(const u64 *vli, unsigned int ndigits)
81
+ 
82
+ 	return true;
83
+ }
84
+-EXPORT_SYMBOL(vli_is_zero);
85
+ 
86
+ /* Returns nonzero if bit of vli is set. */
87
+ static u64 vli_test_bit(const u64 *vli, unsigned int bit)
88
+@@ -184,7 +179,6 @@ unsigned int vli_num_bits(const u64 *vli, unsigned int ndigits)
89
+ 
90
+ 	return ((num_digits - 1) * 64 + i);
91
+ }
92
+-EXPORT_SYMBOL(vli_num_bits);
93
+ 
94
+ /* Set dest from unaligned bit string src. */
95
+ void vli_from_be64(u64 *dest, const void *src, unsigned int ndigits)
96
+@@ -195,7 +189,6 @@ void vli_from_be64(u64 *dest, const void *src, unsigned int ndigits)
97
+ 	for (i = 0; i < ndigits; i++)
98
+ 		dest[i] = get_unaligned_be64(&from[ndigits - 1 - i]);
99
+ }
100
+-EXPORT_SYMBOL(vli_from_be64);
101
+ 
102
+ void vli_from_le64(u64 *dest, const void *src, unsigned int ndigits)
103
+ {
104
+@@ -205,7 +198,6 @@ void vli_from_le64(u64 *dest, const void *src, unsigned int ndigits)
105
+ 	for (i = 0; i < ndigits; i++)
106
+ 		dest[i] = get_unaligned_le64(&from[i]);
107
+ }
108
+-EXPORT_SYMBOL(vli_from_le64);
109
+ 
110
+ /* Sets dest = src. */
111
+ static void vli_set(u64 *dest, const u64 *src, unsigned int ndigits)
112
+@@ -227,7 +219,6 @@ int vli_cmp(const u64 *left, const u64 *right, unsigned int ndigits)
113
+ 
114
+ 	return 0;
115
+ }
116
+-EXPORT_SYMBOL(vli_cmp);
117
+ 
118
+ /* Computes result = in << c, returning carry. Can modify in place
119
+  * (if result == in). 0 < shift < 64.
120
+@@ -324,7 +315,6 @@ u64 vli_sub(u64 *result, const u64 *left, const u64 *right,
121
+ 
122
+ 	return borrow;
123
+ }
124
+-EXPORT_SYMBOL(vli_sub);
125
+ 
126
+ /* Computes result = left - right, returning borrow. Can modify in place. */
127
+ static u64 vli_usub(u64 *result, const u64 *left, u64 right,
128
+@@ -959,7 +949,6 @@ void vli_mod_mult_slow(u64 *result, const u64 *left, const u64 *right,
129
+ 	vli_mult(product, left, right, ndigits);
130
+ 	vli_mmod_slow(result, product, mod, ndigits);
131
+ }
132
+-EXPORT_SYMBOL(vli_mod_mult_slow);
133
+ 
134
+ /* Computes result = (left * right) % curve_prime. */
135
+ static void vli_mod_mult_fast(u64 *result, const u64 *left, const u64 *right,
136
+@@ -1059,7 +1048,6 @@ void vli_mod_inv(u64 *result, const u64 *input, const u64 *mod,
137
+ 
138
+ 	vli_set(result, u, ndigits);
139
+ }
140
+-EXPORT_SYMBOL(vli_mod_inv);
141
+ 
142
+ /* ------ Point operations ------ */
143
+ 
144
+@@ -1069,7 +1057,6 @@ bool ecc_point_is_zero(const struct ecc_point *point)
145
+ 	return (vli_is_zero(point->x, point->ndigits) &&
146
+ 		vli_is_zero(point->y, point->ndigits));
147
+ }
148
+-EXPORT_SYMBOL(ecc_point_is_zero);
149
+ 
150
+ /* Point multiplication algorithm using Montgomery's ladder with co-Z
151
+  * coordinates. From https://eprint.iacr.org/2011/338.pdf
152
+@@ -1411,7 +1398,6 @@ void ecc_point_mult_shamir(const struct ecc_point *result,
153
+ 	vli_mod_inv(z, z, curve->p, ndigits);
154
+ 	apply_z(rx, ry, z, curve);
155
+ }
156
+-EXPORT_SYMBOL(ecc_point_mult_shamir);
157
+ 
158
+ static int __ecc_is_key_valid(const struct ecc_curve *curve,
159
+ 			      const u64 *private_key, unsigned int ndigits)
160
+@@ -1449,7 +1435,6 @@ int ecc_is_key_valid(unsigned int curve_id, unsigned int ndigits,
161
+ 
162
+ 	return __ecc_is_key_valid(curve, private_key, ndigits);
163
+ }
164
+-EXPORT_SYMBOL(ecc_is_key_valid);
165
+ 
166
+ /*
167
+  * ECC private keys are generated using the method of extra random bits,
168
+@@ -1502,7 +1487,6 @@ int ecc_gen_privkey(unsigned int curve_id, unsigned int ndigits, u64 *privkey)
169
+ 
170
+ 	return 0;
171
+ }
172
+-EXPORT_SYMBOL(ecc_gen_privkey);
173
+ 
174
+ int ecc_make_pub_key(unsigned int curve_id, unsigned int ndigits,
175
+ 		     const u64 *private_key, u64 *public_key)
176
+@@ -1541,7 +1525,6 @@ int ecc_make_pub_key(unsigned int curve_id, unsigned int ndigits,
177
+ out:
178
+ 	return ret;
179
+ }
180
+-EXPORT_SYMBOL(ecc_make_pub_key);
181
+ 
182
+ /* SP800-56A section 5.6.2.3.4 partial verification: ephemeral keys only */
183
+ int ecc_is_pubkey_valid_partial(const struct ecc_curve *curve,
184
+@@ -1574,7 +1557,6 @@ int ecc_is_pubkey_valid_partial(const struct ecc_curve *curve,
185
+ 
186
+ 	return 0;
187
+ }
188
+-EXPORT_SYMBOL(ecc_is_pubkey_valid_partial);
189
+ 
190
+ /* SP800-56A section 5.6.2.3.3 full verification */
191
+ int ecc_is_pubkey_valid_full(const struct ecc_curve *curve,
192
+@@ -1601,7 +1583,6 @@ int ecc_is_pubkey_valid_full(const struct ecc_curve *curve,
193
+ 
194
+ 	return ret;
195
+ }
196
+-EXPORT_SYMBOL(ecc_is_pubkey_valid_full);
197
+ 
198
+ static int get_jitter_ent_random_bytes(u64 *buf, unsigned int len)
199
+ {
200
+@@ -1685,6 +1666,5 @@ int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits,
201
+ out:
202
+ 	return ret;
203
+ }
204
+-EXPORT_SYMBOL(crypto_ecdh_shared_secret);
205
+ 
206
+ MODULE_LICENSE("Dual BSD/GPL");
207
+diff --git a/crypto/ecdh_helper.c b/crypto/ecdh_helper.c
208
+index 5dac6b348..78cd5252f 100644
209
+--- a/crypto/ecdh_helper.c
210
+@@ -29,7 +29,6 @@ unsigned int crypto_ecdh_key_len(const struct ecdh *params)
211
+ {
212
+ 	return ECDH_KPP_SECRET_MIN_SIZE + params->key_size;
213
+ }
214
+-EXPORT_SYMBOL_GPL(crypto_ecdh_key_len);
215
+ 
216
+ int crypto_ecdh_encode_key(char *buf, unsigned int len,
217
+ 			   const struct ecdh *params)
218
+@@ -52,7 +51,6 @@ int crypto_ecdh_encode_key(char *buf, unsigned int len,
219
+ 
220
+ 	return 0;
221
+ }
222
+-EXPORT_SYMBOL_GPL(crypto_ecdh_encode_key);
223
+ 
224
+ int crypto_ecdh_decode_key(const char *buf, unsigned int len,
225
+ 			   struct ecdh *params)
226
+@@ -80,5 +78,4 @@ int crypto_ecdh_decode_key(const char *buf, unsigned int len,
227
+ 	params->key = (void *)ptr;
228
+ 
229
+ 	return 0;
230
+-}
231
+-EXPORT_SYMBOL_GPL(crypto_ecdh_decode_key);
232
++}
233
+\ No newline at end of file
234
+diff --git a/crypto/rsa_helper.c b/crypto/rsa_helper.c
235
+index 94266f290..9deb71e13 100644
236
+--- a/crypto/rsa_helper.c
237
+@@ -164,7 +164,6 @@ int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key,
238
+ {
239
+ 	return asn1_ber_decoder(&rsapubkey_decoder, rsa_key, key, key_len);
240
+ }
241
+-EXPORT_SYMBOL_GPL(rsa_parse_pub_key);
242
+ 
243
+ /**
244
+  * rsa_parse_priv_key() - decodes the BER encoded buffer and stores in the
245
+@@ -183,4 +182,3 @@ int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
246
+ {
247
+ 	return asn1_ber_decoder(&rsaprivkey_decoder, rsa_key, key, key_len);
248
+ }
249
+-EXPORT_SYMBOL_GPL(rsa_parse_priv_key);
250
+diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c
251
+index 193345133..c5efc0a3a 100644
252
+--- a/crypto/sha1_generic.c
253
+@@ -26,7 +26,6 @@ const u8 sha1_zero_message_hash[SHA1_DIGEST_SIZE] = {
254
+ 	0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90,
255
+ 	0xaf, 0xd8, 0x07, 0x09
256
+ };
257
+-EXPORT_SYMBOL_GPL(sha1_zero_message_hash);
258
+ 
259
+ static void sha1_generic_block_fn(struct sha1_state *sst, u8 const *src,
260
+ 				  int blocks)
261
+@@ -45,7 +44,6 @@ int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
262
+ {
263
+ 	return fcw_sha1_base_do_update(desc, data, len, sha1_generic_block_fn);
264
+ }
265
+-EXPORT_SYMBOL(crypto_sha1_update);
266
+ 
267
+ static int sha1_final(struct shash_desc *desc, u8 *out)
268
+ {
269
+@@ -59,7 +57,6 @@ int crypto_sha1_finup(struct shash_desc *desc, const u8 *data,
270
+ 	fcw_sha1_base_do_update(desc, data, len, sha1_generic_block_fn);
271
+ 	return sha1_final(desc, out);
272
+ }
273
+-EXPORT_SYMBOL(crypto_sha1_finup);
274
+ 
275
+ static struct shash_alg alg = {
276
+ 	.digestsize	=	SHA1_DIGEST_SIZE,
277
+diff --git a/crypto/sha256_generic.c b/crypto/sha256_generic.c
278
+index bf147b01e..c1147386d 100644
279
+--- a/crypto/sha256_generic.c
280
+@@ -23,7 +23,6 @@ const u8 sha224_zero_message_hash[SHA224_DIGEST_SIZE] = {
281
+ 	0xb0, 0x1f, 0x82, 0x8e, 0xa6, 0x2a, 0xc5, 0xb3, 0xe4,
282
+ 	0x2f
283
+ };
284
+-EXPORT_SYMBOL_GPL(sha224_zero_message_hash);
285
+ 
286
+ const u8 sha256_zero_message_hash[SHA256_DIGEST_SIZE] = {
287
+ 	0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14,
288
+@@ -31,7 +30,6 @@ const u8 sha256_zero_message_hash[SHA256_DIGEST_SIZE] = {
289
+ 	0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c,
290
+ 	0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55
291
+ };
292
+-EXPORT_SYMBOL_GPL(sha256_zero_message_hash);
293
+ 
294
+ int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
295
+ 			  unsigned int len)
296
+@@ -39,7 +37,6 @@ int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
297
+ 	sha256_update(shash_desc_ctx(desc), data, len);
298
+ 	return 0;
299
+ }
300
+-EXPORT_SYMBOL(crypto_sha256_update);
301
+ 
302
+ static int crypto_sha256_final(struct shash_desc *desc, u8 *out)
303
+ {
304
+@@ -56,7 +53,6 @@ int crypto_sha256_finup(struct shash_desc *desc, const u8 *data,
305
+ 	sha256_update(shash_desc_ctx(desc), data, len);
306
+ 	return crypto_sha256_final(desc, hash);
307
+ }
308
+-EXPORT_SYMBOL(crypto_sha256_finup);
309
+ 
310
+ static struct shash_alg sha256_algs[2] = { {
311
+ 	.digestsize	=	SHA256_DIGEST_SIZE,
312
+diff --git a/crypto/sha3_generic.c b/crypto/sha3_generic.c
313
+index 3e4069935..7d107460b 100644
314
+--- a/crypto/sha3_generic.c
315
+@@ -14,6 +14,7 @@
316
+ #include <linux/types.h>
317
+ #include <crypto/sha3.h>
318
+ #include <asm/unaligned.h>
319
++#include "fips_canister_wrapper.h"
320
+ 
321
+ /*
322
+  * On some 32-bit architectures (h8300), GCC ends up using
323
+@@ -170,7 +171,6 @@ int crypto_sha3_init(struct shash_desc *desc)
324
+ 	memset(sctx->st, 0, sizeof(sctx->st));
325
+ 	return 0;
326
+ }
327
+-EXPORT_SYMBOL(crypto_sha3_init);
328
+ 
329
+ int crypto_sha3_update(struct shash_desc *desc, const u8 *data,
330
+ 		       unsigned int len)
331
+@@ -185,7 +185,7 @@ int crypto_sha3_update(struct shash_desc *desc, const u8 *data,
332
+ 	if ((sctx->partial + len) > (sctx->rsiz - 1)) {
333
+ 		if (sctx->partial) {
334
+ 			done = -sctx->partial;
335
+-			memcpy(sctx->buf + sctx->partial, data,
336
++			fcw_memcpy(sctx->buf + sctx->partial, data,
337
+ 			       done + sctx->rsiz);
338
+ 			src = sctx->buf;
339
+ 		}
340
+@@ -203,12 +203,11 @@ int crypto_sha3_update(struct shash_desc *desc, const u8 *data,
341
+ 
342
+ 		sctx->partial = 0;
343
+ 	}
344
+-	memcpy(sctx->buf + sctx->partial, src, len - done);
345
++	fcw_memcpy(sctx->buf + sctx->partial, src, len - done);
346
+ 	sctx->partial += (len - done);
347
+ 
348
+ 	return 0;
349
+ }
350
+-EXPORT_SYMBOL(crypto_sha3_update);
351
+ 
352
+ int crypto_sha3_final(struct shash_desc *desc, u8 *out)
353
+ {
354
+@@ -235,7 +234,6 @@ int crypto_sha3_final(struct shash_desc *desc, u8 *out)
355
+ 	memset(sctx, 0, sizeof(*sctx));
356
+ 	return 0;
357
+ }
358
+-EXPORT_SYMBOL(crypto_sha3_final);
359
+ 
360
+ static struct shash_alg algs[] = { {
361
+ 	.digestsize		= SHA3_224_DIGEST_SIZE,
362
+diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c
363
+index 07e27910c..32ff5a0b1 100644
364
+--- a/crypto/sha512_generic.c
365
+@@ -27,7 +27,6 @@ const u8 sha384_zero_message_hash[SHA384_DIGEST_SIZE] = {
366
+ 	0x27, 0x4e, 0xde, 0xbf, 0xe7, 0x6f, 0x65, 0xfb,
367
+ 	0xd5, 0x1a, 0xd2, 0xf1, 0x48, 0x98, 0xb9, 0x5b
368
+ };
369
+-EXPORT_SYMBOL_GPL(sha384_zero_message_hash);
370
+ 
371
+ const u8 sha512_zero_message_hash[SHA512_DIGEST_SIZE] = {
372
+ 	0xcf, 0x83, 0xe1, 0x35, 0x7e, 0xef, 0xb8, 0xbd,
373
+@@ -39,7 +38,6 @@ const u8 sha512_zero_message_hash[SHA512_DIGEST_SIZE] = {
374
+ 	0x63, 0xb9, 0x31, 0xbd, 0x47, 0x41, 0x7a, 0x81,
375
+ 	0xa5, 0x38, 0x32, 0x7a, 0xf9, 0x27, 0xda, 0x3e
376
+ };
377
+-EXPORT_SYMBOL_GPL(sha512_zero_message_hash);
378
+ 
379
+ static inline u64 Ch(u64 x, u64 y, u64 z)
380
+ {
381
+@@ -160,7 +158,6 @@ int crypto_sha512_update(struct shash_desc *desc, const u8 *data,
382
+ {
383
+ 	return fcw_sha512_base_do_update(desc, data, len, sha512_generic_block_fn);
384
+ }
385
+-EXPORT_SYMBOL(crypto_sha512_update);
386
+ 
387
+ static int sha512_final(struct shash_desc *desc, u8 *hash)
388
+ {
389
+@@ -174,7 +171,6 @@ int crypto_sha512_finup(struct shash_desc *desc, const u8 *data,
390
+ 	fcw_sha512_base_do_update(desc, data, len, sha512_generic_block_fn);
391
+ 	return sha512_final(desc, hash);
392
+ }
393
+-EXPORT_SYMBOL(crypto_sha512_finup);
394
+ 
395
+ static struct shash_alg sha512_algs[2] = { {
396
+ 	.digestsize	=	SHA512_DIGEST_SIZE,
397
+diff --git a/crypto/testmgr.c b/crypto/testmgr.c
398
+index 65fcb40b4..b8d9fe797 100644
399
+--- a/crypto/testmgr.c
400
+@@ -5904,5 +5904,3 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
401
+ }
402
+ 
403
+ #endif /* CONFIG_CRYPTO_MANAGER_DISABLE_TESTS */
404
+-
405
+-EXPORT_SYMBOL_GPL(alg_test);
406
+diff --git a/lib/crypto/aes.c b/lib/crypto/aes.c
407
+index 827fe8992..30a61e0d4 100644
408
+--- a/lib/crypto/aes.c
409
+@@ -85,9 +85,6 @@ static volatile const u8 __cacheline_aligned aes_inv_sbox[] = {
410
+ extern const u8 crypto_aes_sbox[256] __alias(aes_sbox);
411
+ extern const u8 crypto_aes_inv_sbox[256] __alias(aes_inv_sbox);
412
+ 
413
+-EXPORT_SYMBOL(crypto_aes_sbox);
414
+-EXPORT_SYMBOL(crypto_aes_inv_sbox);
415
+-
416
+ static u32 mul_by_x(u32 w)
417
+ {
418
+ 	u32 x = w & 0x7f7f7f7f;
419
+@@ -247,7 +244,6 @@ int aes_expandkey(struct crypto_aes_ctx *ctx, const u8 *in_key,
420
+ 
421
+ 	return 0;
422
+ }
423
+-EXPORT_SYMBOL(aes_expandkey);
424
+ 
425
+ /**
426
+  * aes_encrypt - Encrypt a single AES block
427
+@@ -298,7 +294,6 @@ void aes_encrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in)
428
+ 	put_unaligned_le32(subshift(st1, 2) ^ rkp[6], out + 8);
429
+ 	put_unaligned_le32(subshift(st1, 3) ^ rkp[7], out + 12);
430
+ }
431
+-EXPORT_SYMBOL(aes_encrypt);
432
+ 
433
+ /**
434
+  * aes_decrypt - Decrypt a single AES block
435
+@@ -349,7 +344,6 @@ void aes_decrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in)
436
+ 	put_unaligned_le32(inv_subshift(st1, 2) ^ rkp[6], out + 8);
437
+ 	put_unaligned_le32(inv_subshift(st1, 3) ^ rkp[7], out + 12);
438
+ }
439
+-EXPORT_SYMBOL(aes_decrypt);
440
+ 
441
+ MODULE_DESCRIPTION("Generic AES library");
442
+ MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
443
+diff --git a/lib/crypto/des.c b/lib/crypto/des.c
444
+index ef5bb8822..bc9e7c386 100644
445
+--- a/lib/crypto/des.c
446
+@@ -703,7 +703,6 @@ int des_expand_key(struct des_ctx *ctx, const u8 *key, unsigned int keylen)
447
+ 
448
+ 	return des_ekey(ctx->expkey, key) ? 0 : -ENOKEY;
449
+ }
450
+-EXPORT_SYMBOL_GPL(des_expand_key);
451
+ 
452
+ /*
453
+  * Decryption key expansion
454
+@@ -797,7 +796,6 @@ void des_encrypt(const struct des_ctx *ctx, u8 *dst, const u8 *src)
455
+ 	put_unaligned_le32(R, dst);
456
+ 	put_unaligned_le32(L, dst + 4);
457
+ }
458
+-EXPORT_SYMBOL_GPL(des_encrypt);
459
+ 
460
+ void des_decrypt(const struct des_ctx *ctx, u8 *dst, const u8 *src)
461
+ {
462
+@@ -818,7 +816,6 @@ void des_decrypt(const struct des_ctx *ctx, u8 *dst, const u8 *src)
463
+ 	put_unaligned_le32(R, dst);
464
+ 	put_unaligned_le32(L, dst + 4);
465
+ }
466
+-EXPORT_SYMBOL_GPL(des_decrypt);
467
+ 
468
+ int des3_ede_expand_key(struct des3_ede_ctx *ctx, const u8 *key,
469
+ 			unsigned int keylen)
470
+@@ -839,7 +836,6 @@ int des3_ede_expand_key(struct des3_ede_ctx *ctx, const u8 *key,
471
+ 
472
+ 	return err;
473
+ }
474
+-EXPORT_SYMBOL_GPL(des3_ede_expand_key);
475
+ 
476
+ void des3_ede_encrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src)
477
+ {
478
+@@ -868,7 +864,6 @@ void des3_ede_encrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src)
479
+ 	put_unaligned_le32(R, dst);
480
+ 	put_unaligned_le32(L, dst + 4);
481
+ }
482
+-EXPORT_SYMBOL_GPL(des3_ede_encrypt);
483
+ 
484
+ void des3_ede_decrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src)
485
+ {
486
+@@ -897,6 +892,5 @@ void des3_ede_decrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src)
487
+ 	put_unaligned_le32(R, dst);
488
+ 	put_unaligned_le32(L, dst + 4);
489
+ }
490
+-EXPORT_SYMBOL_GPL(des3_ede_decrypt);
491
+ 
492
+ MODULE_LICENSE("GPL");
493
+diff --git a/lib/crypto/sha1.c b/lib/crypto/sha1.c
494
+index 1aebe7be9..9b2f423f0 100644
495
+--- a/lib/crypto/sha1.c
496
+@@ -121,7 +121,6 @@ void sha1_transform(__u32 *digest, const char *data, __u32 *array)
497
+ 	digest[3] += D;
498
+ 	digest[4] += E;
499
+ }
500
+-EXPORT_SYMBOL(sha1_transform);
501
+ 
502
+ /**
503
+  * sha1_init - initialize the vectors for a SHA1 digest
504
+@@ -135,6 +134,5 @@ void sha1_init(__u32 *buf)
505
+ 	buf[3] = 0x10325476;
506
+ 	buf[4] = 0xc3d2e1f0;
507
+ }
508
+-EXPORT_SYMBOL(sha1_init);
509
+ 
510
+ MODULE_LICENSE("GPL");
511
+diff --git a/lib/crypto/sha256.c b/lib/crypto/sha256.c
512
+index 12fb96b0f..9e14f49b5 100644
513
+--- a/lib/crypto/sha256.c
514
+@@ -151,13 +151,11 @@ void sha256_update(struct sha256_state *sctx, const u8 *data, unsigned int len)
515
+ 	}
516
+ 	fcw_memcpy(sctx->buf + partial, src, len - done);
517
+ }
518
+-EXPORT_SYMBOL(sha256_update);
519
+ 
520
+ void sha224_update(struct sha256_state *sctx, const u8 *data, unsigned int len)
521
+ {
522
+ 	sha256_update(sctx, data, len);
523
+ }
524
+-EXPORT_SYMBOL(sha224_update);
525
+ 
526
+ static void __sha256_final(struct sha256_state *sctx, u8 *out, int digest_words)
527
+ {
528
+@@ -190,13 +188,11 @@ void sha256_final(struct sha256_state *sctx, u8 *out)
529
+ {
530
+ 	__sha256_final(sctx, out, 8);
531
+ }
532
+-EXPORT_SYMBOL(sha256_final);
533
+ 
534
+ void sha224_final(struct sha256_state *sctx, u8 *out)
535
+ {
536
+ 	__sha256_final(sctx, out, 7);
537
+ }
538
+-EXPORT_SYMBOL(sha224_final);
539
+ 
540
+ void sha256(const u8 *data, unsigned int len, u8 *out)
541
+ {
542
+@@ -206,6 +202,5 @@ void sha256(const u8 *data, unsigned int len, u8 *out)
543
+ 	sha256_update(&sctx, data, len);
544
+ 	sha256_final(&sctx, out);
545
+ }
546
+-EXPORT_SYMBOL(sha256);
547
+ 
548
+ MODULE_LICENSE("GPL");
549
+-- 
550
+2.19.0
551
+
0 552
new file mode 100644
... ...
@@ -0,0 +1,301 @@
0
+From 3304cb30e6067af1ccc59fdcb7a9c03033ef770f Mon Sep 17 00:00:00 2001
1
+From: Keerthana K <keerthanak@vmware.com>
2
+Date: Mon, 11 Jan 2021 16:46:43 +0000
3
+Subject: [PATCH 1/8] FIPS canister binary usage
4
+
5
+Build with fips canister and skip building crypto algorithms.
6
+Invoke fips canister integrity check during kernel startup.
7
+
8
+This patch can be used at two stages:
9
+ 1. Prerequisite patch for canister creation.
10
+ 2. Binary canister usage time.
11
+
12
+Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
13
+Signed-off-by: Keerthana K <keerthanak@vmware.com>
14
+Signed-off-by: Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com>
15
+---
16
+ arch/x86/crypto/Makefile |   4 --
17
+ crypto/Makefile          | 115 +++++++++++++++++++++++++++++++--------
18
+ init/main.c              |   3 +
19
+ lib/crypto/Makefile      |  12 ----
20
+ 4 files changed, 94 insertions(+), 40 deletions(-)
21
+
22
+diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
23
+index 3b1d701a4..3836c4e30 100644
24
+--- a/arch/x86/crypto/Makefile
25
+@@ -46,10 +46,6 @@ obj-$(CONFIG_CRYPTO_CHACHA20_X86_64) += chacha-x86_64.o
26
+ chacha-x86_64-y := chacha-avx2-x86_64.o chacha-ssse3-x86_64.o chacha_glue.o
27
+ chacha-x86_64-$(CONFIG_AS_AVX512) += chacha-avx512vl-x86_64.o
28
+ 
29
+-obj-$(CONFIG_CRYPTO_AES_NI_INTEL) += aesni-intel.o
30
+-aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o
31
+-aesni-intel-$(CONFIG_64BIT) += aesni-intel_avx-x86_64.o aes_ctrby8_avx-x86_64.o
32
+-
33
+ obj-$(CONFIG_CRYPTO_SHA1_SSSE3) += sha1-ssse3.o
34
+ sha1-ssse3-y := sha1_avx2_x86_64_asm.o sha1_ssse3_asm.o sha1_ssse3_glue.o
35
+ sha1-ssse3-$(CONFIG_AS_SHA1_NI) += sha1_ni_asm.o
36
+diff --git a/crypto/Makefile b/crypto/Makefile
37
+index d7fcab76d..c2ac25a65 100644
38
+--- a/crypto/Makefile
39
+@@ -40,7 +40,6 @@ rsa_generic-y += rsaprivkey.asn1.o
40
+ rsa_generic-y += rsa.o
41
+ rsa_generic-y += rsa_helper.o
42
+ rsa_generic-y += rsa-pkcs1pad.o
43
+-obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
44
+ 
45
+ $(obj)/sm2signature.asn1.o: $(obj)/sm2signature.asn1.c $(obj)/sm2signature.asn1.h
46
+ $(obj)/sm2.o: $(obj)/sm2signature.asn1.h
47
+@@ -49,13 +48,11 @@ sm2_generic-y += sm2signature.asn1.o
48
+ sm2_generic-y += sm2.o
49
+ 
50
+ obj-$(CONFIG_CRYPTO_SM2) += sm2_generic.o
51
+-obj-$(CONFIG_CRYPTO_SELF_TEST) += crypto_self_test.o
52
+ 
53
+ $(obj)/ecdsasignature.asn1.o: $(obj)/ecdsasignature.asn1.c $(obj)/ecdsasignature.asn1.h
54
+ $(obj)/ecdsa.o: $(obj)/ecdsasignature.asn1.h
55
+ ecdsa_generic-y += ecdsa.o
56
+ ecdsa_generic-y += ecdsasignature.asn1.o
57
+-obj-$(CONFIG_CRYPTO_ECDSA) += ecdsa_generic.o
58
+ 
59
+ crypto_acompress-y := acompress.o
60
+ crypto_acompress-y += scompress.o
61
+@@ -63,22 +60,15 @@ obj-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
62
+ 
63
+ cryptomgr-y := algboss.o testmgr.o
64
+ 
65
+-obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
66
+ obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
67
+ crypto_user-y := crypto_user_base.o
68
+ crypto_user-$(CONFIG_CRYPTO_STATS) += crypto_user_stat.o
69
+-obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
70
+-obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
71
+ obj-$(CONFIG_CRYPTO_VMAC) += vmac.o
72
+ obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
73
+ obj-$(CONFIG_CRYPTO_NULL2) += crypto_null.o
74
+ obj-$(CONFIG_CRYPTO_MD4) += md4.o
75
+ obj-$(CONFIG_CRYPTO_MD5) += md5.o
76
+ obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
77
+-obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o
78
+-obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o
79
+-obj-$(CONFIG_CRYPTO_SHA512) += sha512_generic.o
80
+-obj-$(CONFIG_CRYPTO_SHA3) += sha3_generic.o
81
+ obj-$(CONFIG_CRYPTO_SM3) += sm3.o
82
+ obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
83
+ obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
84
+@@ -87,21 +77,13 @@ CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/b
85
+ obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b_generic.o
86
+ CFLAGS_blake2b_generic.o := -Wframe-larger-than=4096 #  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105930
87
+ obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
88
+-obj-$(CONFIG_CRYPTO_ECB) += ecb.o
89
+-obj-$(CONFIG_CRYPTO_CBC) += cbc.o
90
+-obj-$(CONFIG_CRYPTO_CFB) += cfb.o
91
+ obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
92
+-obj-$(CONFIG_CRYPTO_CTS) += cts.o
93
+ obj-$(CONFIG_CRYPTO_LRW) += lrw.o
94
+-obj-$(CONFIG_CRYPTO_XTS) += xts.o
95
+-obj-$(CONFIG_CRYPTO_CTR) += ctr.o
96
+ obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
97
+ obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
98
+ obj-$(CONFIG_CRYPTO_KEYWRAP) += keywrap.o
99
+ obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
100
+ obj-$(CONFIG_CRYPTO_NHPOLY1305) += nhpoly1305.o
101
+-obj-$(CONFIG_CRYPTO_GCM) += gcm.o
102
+-obj-$(CONFIG_CRYPTO_CCM) += ccm.o
103
+ obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
104
+ obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
105
+ aegis128-y := aegis128-core.o
106
+@@ -128,7 +110,6 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
107
+ 
108
+ obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
109
+ obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
110
+-obj-$(CONFIG_CRYPTO_DES) += des_generic.o
111
+ obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
112
+ obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
113
+ obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
114
+@@ -136,7 +117,6 @@ obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
115
+ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
116
+ obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
117
+ CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
118
+-obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
119
+ CFLAGS_aes_generic.o := $(call cc-option,-fno-code-hoisting) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83356
120
+ obj-$(CONFIG_CRYPTO_SM4) += sm4.o
121
+ obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
122
+@@ -167,8 +147,6 @@ obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
123
+ obj-$(CONFIG_CRYPTO_842) += 842.o
124
+ obj-$(CONFIG_CRYPTO_RNG2) += rng.o
125
+ obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
126
+-obj-$(CONFIG_CRYPTO_DRBG) += drbg.o
127
+-obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
128
+ CFLAGS_jitterentropy.o = -O0
129
+ KASAN_SANITIZE_jitterentropy.o = n
130
+ UBSAN_SANITIZE_jitterentropy.o = n
131
+@@ -183,13 +161,11 @@ obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
132
+ obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
133
+ obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
134
+ obj-$(CONFIG_CRYPTO_OFB) += ofb.o
135
+-obj-$(CONFIG_CRYPTO_ECC) += ecc.o
136
+ obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o
137
+ obj-$(CONFIG_CRYPTO_CURVE25519) += curve25519-generic.o
138
+ 
139
+ ecdh_generic-y += ecdh.o
140
+ ecdh_generic-y += ecdh_helper.o
141
+-obj-$(CONFIG_CRYPTO_ECDH) += ecdh_generic.o
142
+ 
143
+ $(obj)/ecrdsa_params.asn1.o: $(obj)/ecrdsa_params.asn1.c $(obj)/ecrdsa_params.asn1.h
144
+ $(obj)/ecrdsa_pub_key.asn1.o: $(obj)/ecrdsa_pub_key.asn1.c $(obj)/ecrdsa_pub_key.asn1.h
145
+@@ -213,3 +189,94 @@ obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
146
+ # Key derivation function
147
+ #
148
+ obj-$(CONFIG_CRYPTO_KDF800108_CTR) += kdf_sp800108.o
149
++obj-$(CONFIG_CRYPTO_FIPS) += fips_canister_wrapper_asm.o fips_canister_wrapper.o fips_canister.o
150
++
151
++ifdef CONFIG_CRYPTO_FIPS
152
++ifneq ($(CONFIG_CRYPTO_FIPS),y)
153
++  $(error FIPS canister requires CONFIG_CRYPTO_FIPS=y)
154
++endif
155
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_AEAD)),y)
156
++  $(error FIPS canister requires CONFIG_CRYPTO_AEAD=y)
157
++endif
158
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_RSA)),y)
159
++  $(error FIPS canister requires CONFIG_CRYPTO_RSA=y)
160
++endif
161
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_MANAGER)),y)
162
++  $(error FIPS canister requires CONFIG_CRYPTO_MANAGER=y)
163
++endif
164
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_MANAGER2)),y)
165
++  $(error FIPS canister requires CONFIG_CRYPTO_MANAGER2=y)
166
++endif
167
++ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
168
++  $(error FIPS canister requires CONFIG_CRYPTO_MANAGER_DISABLE_TESTS to be unset)
169
++endif
170
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_HMAC)),y)
171
++  $(error FIPS canister requires CONFIG_CRYPTO_HMAC=y)
172
++endif
173
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_SHA256)),y)
174
++  $(error FIPS canister requires CONFIG_CRYPTO_SHA256=y)
175
++endif
176
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_SHA512)),y)
177
++  $(error FIPS canister requires CONFIG_CRYPTO_SHA512=y)
178
++endif
179
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_AES)),y)
180
++  $(error FIPS canister requires CONFIG_CRYPTO_AES=y)
181
++endif
182
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_DES)),y)
183
++  $(error FIPS canister requires CONFIG_CRYPTO_DES=y)
184
++endif
185
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_ECB)),y)
186
++  $(error FIPS canister requires CONFIG_CRYPTO_ECB=y)
187
++endif
188
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CBC)),y)
189
++  $(error FIPS canister requires CONFIG_CRYPTO_CBC=y)
190
++endif
191
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_XTS)),y)
192
++  $(error FIPS canister requires CONFIG_CRYPTO_XTS=y)
193
++endif
194
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CTR)),y)
195
++  $(error FIPS canister requires CONFIG_CRYPTO_CTR=y)
196
++endif
197
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_DRBG)),y)
198
++  $(error FIPS canister requires CONFIG_CRYPTO_DRBG=y)
199
++endif
200
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_DRBG_HASH)),y)
201
++  $(error FIPS canister requires CONFIG_CRYPTO_DRBG_HASH=y)
202
++endif
203
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_DRBG_CTR)),y)
204
++  $(error FIPS canister requires CONFIG_CRYPTO_DRBG_CTR=y)
205
++endif
206
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_JITTERENTROPY)),y)
207
++  $(error FIPS canister requires CONFIG_CRYPTO_JITTERENTROPY=y)
208
++endif
209
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_ECC)),y)
210
++  $(error FIPS canister requires CONFIG_CRYPTO_ECC=y)
211
++endif
212
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_ECDH)),y)
213
++  $(error FIPS canister requires CONFIG_CRYPTO_ECDH=y)
214
++endif
215
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_AES_NI_INTEL)),y)
216
++  $(error FIPS canister requires CONFIG_CRYPTO_AES_NI_INTEL=y)
217
++endif
218
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CFB)),y)
219
++  $(error FIPS canister requires CONFIG_CRYPTO_CFB=y)
220
++endif
221
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CMAC)),y)
222
++  $(error FIPS canister requires CONFIG_CRYPTO_CMAC=y)
223
++endif
224
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CTS)),y)
225
++  $(error FIPS canister requires CONFIG_CRYPTO_CTS=y)
226
++endif
227
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_ECDSA)),y)
228
++  $(error FIPS canister requires CONFIG_CRYPTO_ECDSA=y)
229
++endif
230
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CCM)),y)
231
++  $(error FIPS canister requires CONFIG_CRYPTO_CCM=y)
232
++endif
233
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_GCM)),y)
234
++  $(error FIPS canister requires CONFIG_CRYPTO_GCM=y)
235
++endif
236
++ifneq ($(subst Y,y,$(CONFIG_CRYPTO_SHA3)),y)
237
++  $(error FIPS canister requires CONFIG_CRYPTO_SHA3=y)
238
++endif
239
++endif
240
+diff --git a/init/main.c b/init/main.c
241
+index aa21add5f..4db7e4edd 100644
242
+--- a/init/main.c
243
+@@ -885,6 +885,8 @@ static int __init early_randomize_kstack_offset(char *buf)
244
+ early_param("randomize_kstack_offset", early_randomize_kstack_offset);
245
+ #endif
246
+ 
247
++extern int fips_integrity_init(void);
248
++
249
+ void __init __weak arch_call_rest_init(void)
250
+ {
251
+ 	rest_init();
252
+@@ -986,6 +988,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
253
+ 	/* Architectural and non-timekeeping rng init, before allocator init */
254
+ 	random_init_early(command_line);
255
+ 
256
++	fips_integrity_init();
257
+ 	/*
258
+ 	 * These use large bootmem allocations and must precede
259
+ 	 * kmem_cache_init()
260
+diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
261
+index c852f067a..84ec57dba 100644
262
+--- a/lib/crypto/Makefile
263
+@@ -7,9 +7,6 @@ libcryptoutils-y				:= memneq.o utils.o
264
+ obj-y						+= chacha.o
265
+ obj-$(CONFIG_CRYPTO_LIB_CHACHA_GENERIC)		+= libchacha.o
266
+ 
267
+-obj-$(CONFIG_CRYPTO_LIB_AES)			+= libaes.o
268
+-libaes-y					:= aes.o
269
+-
270
+ obj-$(CONFIG_CRYPTO_LIB_ARC4)			+= libarc4.o
271
+ libarc4-y					:= arc4.o
272
+ 
273
+@@ -29,20 +26,11 @@ libcurve25519-generic-y				+= curve25519-generic.o
274
+ obj-$(CONFIG_CRYPTO_LIB_CURVE25519)		+= libcurve25519.o
275
+ libcurve25519-y					+= curve25519.o
276
+ 
277
+-obj-$(CONFIG_CRYPTO_LIB_DES)			+= libdes.o
278
+-libdes-y					:= des.o
279
+-
280
+ obj-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC)	+= libpoly1305.o
281
+ libpoly1305-y					:= poly1305-donna32.o
282
+ libpoly1305-$(CONFIG_ARCH_SUPPORTS_INT128)	:= poly1305-donna64.o
283
+ libpoly1305-y					+= poly1305.o
284
+ 
285
+-obj-$(CONFIG_CRYPTO_LIB_SHA1)			+= libsha1.o
286
+-libsha1-y					:= sha1.o
287
+-
288
+-obj-$(CONFIG_CRYPTO_LIB_SHA256)			+= libsha256.o
289
+-libsha256-y					:= sha256.o
290
+-
291
+ ifneq ($(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS),y)
292
+ libblake2s-y					+= blake2s-selftest.o
293
+ libchacha20poly1305-y				+= chacha20poly1305-selftest.o
294
+-- 
295
+2.19.0
296
+
... ...
@@ -5188,7 +5188,7 @@ CONFIG_CRYPTO_MD5=y
5188 5188
 CONFIG_CRYPTO_SHA1=y
5189 5189
 CONFIG_CRYPTO_SHA256=y
5190 5190
 CONFIG_CRYPTO_SHA512=y
5191
-# CONFIG_CRYPTO_SHA3 is not set
5191
+CONFIG_CRYPTO_SHA3=y
5192 5192
 # CONFIG_CRYPTO_SM3_GENERIC is not set
5193 5193
 # CONFIG_CRYPTO_STREEBOG is not set
5194 5194
 # CONFIG_CRYPTO_VMAC is not set
5195 5195
deleted file mode 100644
... ...
@@ -1,56 +0,0 @@
1
-From 06e988b1547114c603a337f10c8a6f944b911f24 Mon Sep 17 00:00:00 2001
2
-From: Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com>
3
-Date: Sun, 5 Mar 2023 18:43:14 +0530
4
-Subject: [PATCH] crypto: Add prandom, module_kthread_exit to canister
5
- wrapper
6
-
7
-prandom_u32_max is a static inline function whose definition changed
8
-across versions.
9
-
10
-module_put_and_kthread_exit is not available in older kernels,
11
-module_put_and_exit was used earlier, added specific implementation
12
-in wrapper.
13
-
14
- crypto/algboss.c                   |  4 +--
15
- crypto/rsa-pkcs1pad.c              |  2 +-
16
- 8 files changed, 76 insertions(+), 10 deletions(-)
17
-
18
- 
19
-diff --git a/crypto/algboss.c b/crypto/algboss.c
20
-index 62bb3eb18..a2db2afb6 100644
21
-+++ b/crypto/algboss.c
22
-@@ -68,7 +68,7 @@ static int cryptomgr_probe(void *data)
23
- 	complete_all(&param->larval->completion);
24
- 	crypto_alg_put(&param->larval->alg);
25
- 	kfree(param);
26
--	module_put_and_kthread_exit(0);
27
-+	fcw_module_put_and_kthread_exit(0);
28
- }
29
- 
30
- static int cryptomgr_schedule_probe(struct crypto_larval *larval)
31
-@@ -191,7 +191,7 @@ static int cryptomgr_test(void *data)
32
- 	crypto_alg_tested(param->driver, err);
33
- 
34
- 	kfree(param);
35
--	module_put_and_kthread_exit(0);
36
-+	fcw_module_put_and_kthread_exit(0);
37
- }
38
- 
39
- static int cryptomgr_schedule_test(struct crypto_alg *alg)
40
-diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c
41
-index 826dd0833..d8f711404 100644
42
-+++ b/crypto/rsa-pkcs1pad.c
43
-@@ -254,7 +254,7 @@ static int pkcs1pad_encrypt(struct akcipher_request *req)
44
- 	ps_end = ctx->key_size - req->src_len - 2;
45
- 	req_ctx->in_buf[0] = 0x02;
46
- 	for (i = 1; i < ps_end; i++)
47
--		req_ctx->in_buf[i] = 1 + prandom_u32_max(255);
48
-+		req_ctx->in_buf[i] = 1 + fcw_prandom_u32_max(255);
49
- 	req_ctx->in_buf[ps_end] = 0x00;
50
- 
51
- 	pkcs1pad_sg_set_buf(req_ctx->in_sg, req_ctx->in_buf,
52
-2.39.2
53 1
deleted file mode 100644
... ...
@@ -1,511 +0,0 @@
1
-From 45555b8e8ae2d97bf2e7f9425491e6bb83aa8b57 Mon Sep 17 00:00:00 2001
2
-From: Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com>
3
-Date: Mon, 22 May 2023 13:27:58 +0530
4
-Subject: [PATCH] crypto: Remove EXPORT_SYMBOL, EXPORT_SYMBOL_GPL from canister
5
-
6
- crypto/aes_generic.c    |  5 -----
7
- crypto/ecc.c            | 20 --------------------
8
- crypto/ecdh_helper.c    |  5 +----
9
- crypto/rsa_helper.c     |  2 --
10
- crypto/sha1_generic.c   |  3 ---
11
- crypto/sha256_generic.c |  4 ----
12
- crypto/sha512_generic.c |  4 ----
13
- crypto/testmgr.c        |  2 --
14
- lib/crypto/aes.c        |  6 ------
15
- lib/crypto/des.c        |  6 ------
16
- lib/crypto/sha1.c       |  2 --
17
- lib/crypto/sha256.c     |  5 -----
18
- 12 files changed, 1 insertion(+), 63 deletions(-)
19
-
20
-diff --git a/crypto/aes_generic.c b/crypto/aes_generic.c
21
-index 27ab27931..f73022bed 100644
22
-+++ b/crypto/aes_generic.c
23
-@@ -1118,9 +1118,6 @@ static const u32 crypto_il_tab[4][256] ____cacheline_aligned = {
24
- 	}
25
- };
26
- 
27
--EXPORT_SYMBOL_GPL(crypto_ft_tab);
28
--EXPORT_SYMBOL_GPL(crypto_it_tab);
29
--
30
- /**
31
-  * crypto_aes_set_key - Set the AES key.
32
-  * @tfm:	The %crypto_tfm that is used in the context.
33
-@@ -1140,8 +1137,6 @@ int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
34
- 
35
- 	return aes_expandkey(ctx, in_key, key_len);
36
- }
37
--EXPORT_SYMBOL_GPL(crypto_aes_set_key);
38
--
39
- /* encrypt a block of text */
40
- 
41
- #define f_rn(bo, bi, n, k)	do {				\
42
-diff --git a/crypto/ecc.c b/crypto/ecc.c
43
-index 714ff4e6d..20937fd57 100644
44
-+++ b/crypto/ecc.c
45
-@@ -50,7 +50,6 @@ const struct ecc_curve *ecc_get_curve25519(void)
46
- {
47
- 	return &ecc_25519;
48
- }
49
--EXPORT_SYMBOL(ecc_get_curve25519);
50
- 
51
- const struct ecc_curve *ecc_get_curve(unsigned int curve_id)
52
- {
53
-@@ -66,7 +65,6 @@ const struct ecc_curve *ecc_get_curve(unsigned int curve_id)
54
- 		return NULL;
55
- 	}
56
- }
57
--EXPORT_SYMBOL(ecc_get_curve);
58
- 
59
- static u64 *ecc_alloc_digits_space(unsigned int ndigits)
60
- {
61
-@@ -108,7 +106,6 @@ struct ecc_point *ecc_alloc_point(unsigned int ndigits)
62
- 	kfree(p);
63
- 	return NULL;
64
- }
65
--EXPORT_SYMBOL(ecc_alloc_point);
66
- 
67
- void ecc_free_point(struct ecc_point *p)
68
- {
69
-@@ -119,7 +116,6 @@ void ecc_free_point(struct ecc_point *p)
70
- 	kfree_sensitive(p->y);
71
- 	kfree_sensitive(p);
72
- }
73
--EXPORT_SYMBOL(ecc_free_point);
74
- 
75
- static void vli_clear(u64 *vli, unsigned int ndigits)
76
- {
77
-@@ -141,7 +137,6 @@ bool vli_is_zero(const u64 *vli, unsigned int ndigits)
78
- 
79
- 	return true;
80
- }
81
--EXPORT_SYMBOL(vli_is_zero);
82
- 
83
- /* Returns nonzero if bit of vli is set. */
84
- static u64 vli_test_bit(const u64 *vli, unsigned int bit)
85
-@@ -184,7 +179,6 @@ unsigned int vli_num_bits(const u64 *vli, unsigned int ndigits)
86
- 
87
- 	return ((num_digits - 1) * 64 + i);
88
- }
89
--EXPORT_SYMBOL(vli_num_bits);
90
- 
91
- /* Set dest from unaligned bit string src. */
92
- void vli_from_be64(u64 *dest, const void *src, unsigned int ndigits)
93
-@@ -195,7 +189,6 @@ void vli_from_be64(u64 *dest, const void *src, unsigned int ndigits)
94
- 	for (i = 0; i < ndigits; i++)
95
- 		dest[i] = get_unaligned_be64(&from[ndigits - 1 - i]);
96
- }
97
--EXPORT_SYMBOL(vli_from_be64);
98
- 
99
- void vli_from_le64(u64 *dest, const void *src, unsigned int ndigits)
100
- {
101
-@@ -205,7 +198,6 @@ void vli_from_le64(u64 *dest, const void *src, unsigned int ndigits)
102
- 	for (i = 0; i < ndigits; i++)
103
- 		dest[i] = get_unaligned_le64(&from[i]);
104
- }
105
--EXPORT_SYMBOL(vli_from_le64);
106
- 
107
- /* Sets dest = src. */
108
- static void vli_set(u64 *dest, const u64 *src, unsigned int ndigits)
109
-@@ -227,7 +219,6 @@ int vli_cmp(const u64 *left, const u64 *right, unsigned int ndigits)
110
- 
111
- 	return 0;
112
- }
113
--EXPORT_SYMBOL(vli_cmp);
114
- 
115
- /* Computes result = in << c, returning carry. Can modify in place
116
-  * (if result == in). 0 < shift < 64.
117
-@@ -324,7 +315,6 @@ u64 vli_sub(u64 *result, const u64 *left, const u64 *right,
118
- 
119
- 	return borrow;
120
- }
121
--EXPORT_SYMBOL(vli_sub);
122
- 
123
- /* Computes result = left - right, returning borrow. Can modify in place. */
124
- static u64 vli_usub(u64 *result, const u64 *left, u64 right,
125
-@@ -959,7 +949,6 @@ void vli_mod_mult_slow(u64 *result, const u64 *left, const u64 *right,
126
- 	vli_mult(product, left, right, ndigits);
127
- 	vli_mmod_slow(result, product, mod, ndigits);
128
- }
129
--EXPORT_SYMBOL(vli_mod_mult_slow);
130
- 
131
- /* Computes result = (left * right) % curve_prime. */
132
- static void vli_mod_mult_fast(u64 *result, const u64 *left, const u64 *right,
133
-@@ -1059,7 +1048,6 @@ void vli_mod_inv(u64 *result, const u64 *input, const u64 *mod,
134
- 
135
- 	vli_set(result, u, ndigits);
136
- }
137
--EXPORT_SYMBOL(vli_mod_inv);
138
- 
139
- /* ------ Point operations ------ */
140
- 
141
-@@ -1069,7 +1057,6 @@ bool ecc_point_is_zero(const struct ecc_point *point)
142
- 	return (vli_is_zero(point->x, point->ndigits) &&
143
- 		vli_is_zero(point->y, point->ndigits));
144
- }
145
--EXPORT_SYMBOL(ecc_point_is_zero);
146
- 
147
- /* Point multiplication algorithm using Montgomery's ladder with co-Z
148
-  * coordinates. From https://eprint.iacr.org/2011/338.pdf
149
-@@ -1411,7 +1398,6 @@ void ecc_point_mult_shamir(const struct ecc_point *result,
150
- 	vli_mod_inv(z, z, curve->p, ndigits);
151
- 	apply_z(rx, ry, z, curve);
152
- }
153
--EXPORT_SYMBOL(ecc_point_mult_shamir);
154
- 
155
- static int __ecc_is_key_valid(const struct ecc_curve *curve,
156
- 			      const u64 *private_key, unsigned int ndigits)
157
-@@ -1449,7 +1435,6 @@ int ecc_is_key_valid(unsigned int curve_id, unsigned int ndigits,
158
- 
159
- 	return __ecc_is_key_valid(curve, private_key, ndigits);
160
- }
161
--EXPORT_SYMBOL(ecc_is_key_valid);
162
- 
163
- /*
164
-  * ECC private keys are generated using the method of extra random bits,
165
-@@ -1502,7 +1487,6 @@ int ecc_gen_privkey(unsigned int curve_id, unsigned int ndigits, u64 *privkey)
166
- 
167
- 	return 0;
168
- }
169
--EXPORT_SYMBOL(ecc_gen_privkey);
170
- 
171
- int ecc_make_pub_key(unsigned int curve_id, unsigned int ndigits,
172
- 		     const u64 *private_key, u64 *public_key)
173
-@@ -1541,7 +1525,6 @@ int ecc_make_pub_key(unsigned int curve_id, unsigned int ndigits,
174
- out:
175
- 	return ret;
176
- }
177
--EXPORT_SYMBOL(ecc_make_pub_key);
178
- 
179
- /* SP800-56A section 5.6.2.3.4 partial verification: ephemeral keys only */
180
- int ecc_is_pubkey_valid_partial(const struct ecc_curve *curve,
181
-@@ -1574,7 +1557,6 @@ int ecc_is_pubkey_valid_partial(const struct ecc_curve *curve,
182
- 
183
- 	return 0;
184
- }
185
--EXPORT_SYMBOL(ecc_is_pubkey_valid_partial);
186
- 
187
- /* SP800-56A section 5.6.2.3.3 full verification */
188
- int ecc_is_pubkey_valid_full(const struct ecc_curve *curve,
189
-@@ -1601,7 +1583,6 @@ int ecc_is_pubkey_valid_full(const struct ecc_curve *curve,
190
- 
191
- 	return ret;
192
- }
193
--EXPORT_SYMBOL(ecc_is_pubkey_valid_full);
194
- 
195
- static int get_jitter_ent_random_bytes(u64 *buf, unsigned int len)
196
- {
197
-@@ -1685,6 +1666,5 @@ int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits,
198
- out:
199
- 	return ret;
200
- }
201
--EXPORT_SYMBOL(crypto_ecdh_shared_secret);
202
- 
203
- MODULE_LICENSE("Dual BSD/GPL");
204
-diff --git a/crypto/ecdh_helper.c b/crypto/ecdh_helper.c
205
-index 5dac6b348..78cd5252f 100644
206
-+++ b/crypto/ecdh_helper.c
207
-@@ -29,7 +29,6 @@ unsigned int crypto_ecdh_key_len(const struct ecdh *params)
208
- {
209
- 	return ECDH_KPP_SECRET_MIN_SIZE + params->key_size;
210
- }
211
--EXPORT_SYMBOL_GPL(crypto_ecdh_key_len);
212
- 
213
- int crypto_ecdh_encode_key(char *buf, unsigned int len,
214
- 			   const struct ecdh *params)
215
-@@ -52,7 +51,6 @@ int crypto_ecdh_encode_key(char *buf, unsigned int len,
216
- 
217
- 	return 0;
218
- }
219
--EXPORT_SYMBOL_GPL(crypto_ecdh_encode_key);
220
- 
221
- int crypto_ecdh_decode_key(const char *buf, unsigned int len,
222
- 			   struct ecdh *params)
223
-@@ -80,5 +78,4 @@ int crypto_ecdh_decode_key(const char *buf, unsigned int len,
224
- 	params->key = (void *)ptr;
225
- 
226
- 	return 0;
227
--}
228
--EXPORT_SYMBOL_GPL(crypto_ecdh_decode_key);
229
-+}
230
-\ No newline at end of file
231
-diff --git a/crypto/rsa_helper.c b/crypto/rsa_helper.c
232
-index 94266f290..9deb71e13 100644
233
-+++ b/crypto/rsa_helper.c
234
-@@ -164,7 +164,6 @@ int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key,
235
- {
236
- 	return asn1_ber_decoder(&rsapubkey_decoder, rsa_key, key, key_len);
237
- }
238
--EXPORT_SYMBOL_GPL(rsa_parse_pub_key);
239
- 
240
- /**
241
-  * rsa_parse_priv_key() - decodes the BER encoded buffer and stores in the
242
-@@ -183,4 +182,3 @@ int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
243
- {
244
- 	return asn1_ber_decoder(&rsaprivkey_decoder, rsa_key, key, key_len);
245
- }
246
--EXPORT_SYMBOL_GPL(rsa_parse_priv_key);
247
-diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c
248
-index 193345133..c5efc0a3a 100644
249
-+++ b/crypto/sha1_generic.c
250
-@@ -26,7 +26,6 @@ const u8 sha1_zero_message_hash[SHA1_DIGEST_SIZE] = {
251
- 	0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90,
252
- 	0xaf, 0xd8, 0x07, 0x09
253
- };
254
--EXPORT_SYMBOL_GPL(sha1_zero_message_hash);
255
- 
256
- static void sha1_generic_block_fn(struct sha1_state *sst, u8 const *src,
257
- 				  int blocks)
258
-@@ -45,7 +44,6 @@ int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
259
- {
260
- 	return fcw_sha1_base_do_update(desc, data, len, sha1_generic_block_fn);
261
- }
262
--EXPORT_SYMBOL(crypto_sha1_update);
263
- 
264
- static int sha1_final(struct shash_desc *desc, u8 *out)
265
- {
266
-@@ -59,7 +57,6 @@ int crypto_sha1_finup(struct shash_desc *desc, const u8 *data,
267
- 	fcw_sha1_base_do_update(desc, data, len, sha1_generic_block_fn);
268
- 	return sha1_final(desc, out);
269
- }
270
--EXPORT_SYMBOL(crypto_sha1_finup);
271
- 
272
- static struct shash_alg alg = {
273
- 	.digestsize	=	SHA1_DIGEST_SIZE,
274
-diff --git a/crypto/sha256_generic.c b/crypto/sha256_generic.c
275
-index bf147b01e..c1147386d 100644
276
-+++ b/crypto/sha256_generic.c
277
-@@ -23,7 +23,6 @@ const u8 sha224_zero_message_hash[SHA224_DIGEST_SIZE] = {
278
- 	0xb0, 0x1f, 0x82, 0x8e, 0xa6, 0x2a, 0xc5, 0xb3, 0xe4,
279
- 	0x2f
280
- };
281
--EXPORT_SYMBOL_GPL(sha224_zero_message_hash);
282
- 
283
- const u8 sha256_zero_message_hash[SHA256_DIGEST_SIZE] = {
284
- 	0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14,
285
-@@ -31,7 +30,6 @@ const u8 sha256_zero_message_hash[SHA256_DIGEST_SIZE] = {
286
- 	0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c,
287
- 	0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55
288
- };
289
--EXPORT_SYMBOL_GPL(sha256_zero_message_hash);
290
- 
291
- int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
292
- 			  unsigned int len)
293
-@@ -39,7 +37,6 @@ int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
294
- 	sha256_update(shash_desc_ctx(desc), data, len);
295
- 	return 0;
296
- }
297
--EXPORT_SYMBOL(crypto_sha256_update);
298
- 
299
- static int crypto_sha256_final(struct shash_desc *desc, u8 *out)
300
- {
301
-@@ -56,7 +53,6 @@ int crypto_sha256_finup(struct shash_desc *desc, const u8 *data,
302
- 	sha256_update(shash_desc_ctx(desc), data, len);
303
- 	return crypto_sha256_final(desc, hash);
304
- }
305
--EXPORT_SYMBOL(crypto_sha256_finup);
306
- 
307
- static struct shash_alg sha256_algs[2] = { {
308
- 	.digestsize	=	SHA256_DIGEST_SIZE,
309
-diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c
310
-index 07e27910c..32ff5a0b1 100644
311
-+++ b/crypto/sha512_generic.c
312
-@@ -27,7 +27,6 @@ const u8 sha384_zero_message_hash[SHA384_DIGEST_SIZE] = {
313
- 	0x27, 0x4e, 0xde, 0xbf, 0xe7, 0x6f, 0x65, 0xfb,
314
- 	0xd5, 0x1a, 0xd2, 0xf1, 0x48, 0x98, 0xb9, 0x5b
315
- };
316
--EXPORT_SYMBOL_GPL(sha384_zero_message_hash);
317
- 
318
- const u8 sha512_zero_message_hash[SHA512_DIGEST_SIZE] = {
319
- 	0xcf, 0x83, 0xe1, 0x35, 0x7e, 0xef, 0xb8, 0xbd,
320
-@@ -39,7 +38,6 @@ const u8 sha512_zero_message_hash[SHA512_DIGEST_SIZE] = {
321
- 	0x63, 0xb9, 0x31, 0xbd, 0x47, 0x41, 0x7a, 0x81,
322
- 	0xa5, 0x38, 0x32, 0x7a, 0xf9, 0x27, 0xda, 0x3e
323
- };
324
--EXPORT_SYMBOL_GPL(sha512_zero_message_hash);
325
- 
326
- static inline u64 Ch(u64 x, u64 y, u64 z)
327
- {
328
-@@ -160,7 +158,6 @@ int crypto_sha512_update(struct shash_desc *desc, const u8 *data,
329
- {
330
- 	return fcw_sha512_base_do_update(desc, data, len, sha512_generic_block_fn);
331
- }
332
--EXPORT_SYMBOL(crypto_sha512_update);
333
- 
334
- static int sha512_final(struct shash_desc *desc, u8 *hash)
335
- {
336
-@@ -174,7 +171,6 @@ int crypto_sha512_finup(struct shash_desc *desc, const u8 *data,
337
- 	fcw_sha512_base_do_update(desc, data, len, sha512_generic_block_fn);
338
- 	return sha512_final(desc, hash);
339
- }
340
--EXPORT_SYMBOL(crypto_sha512_finup);
341
- 
342
- static struct shash_alg sha512_algs[2] = { {
343
- 	.digestsize	=	SHA512_DIGEST_SIZE,
344
-diff --git a/crypto/testmgr.c b/crypto/testmgr.c
345
-index 592ce69c3..eb7a53003 100644
346
-+++ b/crypto/testmgr.c
347
-@@ -5904,5 +5904,3 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
348
- }
349
- 
350
- #endif /* CONFIG_CRYPTO_MANAGER_DISABLE_TESTS */
351
--
352
--EXPORT_SYMBOL_GPL(alg_test);
353
-diff --git a/lib/crypto/aes.c b/lib/crypto/aes.c
354
-index 827fe8992..30a61e0d4 100644
355
-+++ b/lib/crypto/aes.c
356
-@@ -85,9 +85,6 @@ static volatile const u8 __cacheline_aligned aes_inv_sbox[] = {
357
- extern const u8 crypto_aes_sbox[256] __alias(aes_sbox);
358
- extern const u8 crypto_aes_inv_sbox[256] __alias(aes_inv_sbox);
359
- 
360
--EXPORT_SYMBOL(crypto_aes_sbox);
361
--EXPORT_SYMBOL(crypto_aes_inv_sbox);
362
--
363
- static u32 mul_by_x(u32 w)
364
- {
365
- 	u32 x = w & 0x7f7f7f7f;
366
-@@ -247,7 +244,6 @@ int aes_expandkey(struct crypto_aes_ctx *ctx, const u8 *in_key,
367
- 
368
- 	return 0;
369
- }
370
--EXPORT_SYMBOL(aes_expandkey);
371
- 
372
- /**
373
-  * aes_encrypt - Encrypt a single AES block
374
-@@ -298,7 +294,6 @@ void aes_encrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in)
375
- 	put_unaligned_le32(subshift(st1, 2) ^ rkp[6], out + 8);
376
- 	put_unaligned_le32(subshift(st1, 3) ^ rkp[7], out + 12);
377
- }
378
--EXPORT_SYMBOL(aes_encrypt);
379
- 
380
- /**
381
-  * aes_decrypt - Decrypt a single AES block
382
-@@ -349,7 +344,6 @@ void aes_decrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in)
383
- 	put_unaligned_le32(inv_subshift(st1, 2) ^ rkp[6], out + 8);
384
- 	put_unaligned_le32(inv_subshift(st1, 3) ^ rkp[7], out + 12);
385
- }
386
--EXPORT_SYMBOL(aes_decrypt);
387
- 
388
- MODULE_DESCRIPTION("Generic AES library");
389
- MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
390
-diff --git a/lib/crypto/des.c b/lib/crypto/des.c
391
-index ef5bb8822..bc9e7c386 100644
392
-+++ b/lib/crypto/des.c
393
-@@ -703,7 +703,6 @@ int des_expand_key(struct des_ctx *ctx, const u8 *key, unsigned int keylen)
394
- 
395
- 	return des_ekey(ctx->expkey, key) ? 0 : -ENOKEY;
396
- }
397
--EXPORT_SYMBOL_GPL(des_expand_key);
398
- 
399
- /*
400
-  * Decryption key expansion
401
-@@ -797,7 +796,6 @@ void des_encrypt(const struct des_ctx *ctx, u8 *dst, const u8 *src)
402
- 	put_unaligned_le32(R, dst);
403
- 	put_unaligned_le32(L, dst + 4);
404
- }
405
--EXPORT_SYMBOL_GPL(des_encrypt);
406
- 
407
- void des_decrypt(const struct des_ctx *ctx, u8 *dst, const u8 *src)
408
- {
409
-@@ -818,7 +816,6 @@ void des_decrypt(const struct des_ctx *ctx, u8 *dst, const u8 *src)
410
- 	put_unaligned_le32(R, dst);
411
- 	put_unaligned_le32(L, dst + 4);
412
- }
413
--EXPORT_SYMBOL_GPL(des_decrypt);
414
- 
415
- int des3_ede_expand_key(struct des3_ede_ctx *ctx, const u8 *key,
416
- 			unsigned int keylen)
417
-@@ -839,7 +836,6 @@ int des3_ede_expand_key(struct des3_ede_ctx *ctx, const u8 *key,
418
- 
419
- 	return err;
420
- }
421
--EXPORT_SYMBOL_GPL(des3_ede_expand_key);
422
- 
423
- void des3_ede_encrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src)
424
- {
425
-@@ -868,7 +864,6 @@ void des3_ede_encrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src)
426
- 	put_unaligned_le32(R, dst);
427
- 	put_unaligned_le32(L, dst + 4);
428
- }
429
--EXPORT_SYMBOL_GPL(des3_ede_encrypt);
430
- 
431
- void des3_ede_decrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src)
432
- {
433
-@@ -897,6 +892,5 @@ void des3_ede_decrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src)
434
- 	put_unaligned_le32(R, dst);
435
- 	put_unaligned_le32(L, dst + 4);
436
- }
437
--EXPORT_SYMBOL_GPL(des3_ede_decrypt);
438
- 
439
- MODULE_LICENSE("GPL");
440
-diff --git a/lib/crypto/sha1.c b/lib/crypto/sha1.c
441
-index 1aebe7be9..9b2f423f0 100644
442
-+++ b/lib/crypto/sha1.c
443
-@@ -121,7 +121,6 @@ void sha1_transform(__u32 *digest, const char *data, __u32 *array)
444
- 	digest[3] += D;
445
- 	digest[4] += E;
446
- }
447
--EXPORT_SYMBOL(sha1_transform);
448
- 
449
- /**
450
-  * sha1_init - initialize the vectors for a SHA1 digest
451
-@@ -135,6 +134,5 @@ void sha1_init(__u32 *buf)
452
- 	buf[3] = 0x10325476;
453
- 	buf[4] = 0xc3d2e1f0;
454
- }
455
--EXPORT_SYMBOL(sha1_init);
456
- 
457
- MODULE_LICENSE("GPL");
458
-diff --git a/lib/crypto/sha256.c b/lib/crypto/sha256.c
459
-index 12fb96b0f..9e14f49b5 100644
460
-+++ b/lib/crypto/sha256.c
461
-@@ -151,13 +151,11 @@ void sha256_update(struct sha256_state *sctx, const u8 *data, unsigned int len)
462
- 	}
463
- 	fcw_memcpy(sctx->buf + partial, src, len - done);
464
- }
465
--EXPORT_SYMBOL(sha256_update);
466
- 
467
- void sha224_update(struct sha256_state *sctx, const u8 *data, unsigned int len)
468
- {
469
- 	sha256_update(sctx, data, len);
470
- }
471
--EXPORT_SYMBOL(sha224_update);
472
- 
473
- static void __sha256_final(struct sha256_state *sctx, u8 *out, int digest_words)
474
- {
475
-@@ -190,13 +188,11 @@ void sha256_final(struct sha256_state *sctx, u8 *out)
476
- {
477
- 	__sha256_final(sctx, out, 8);
478
- }
479
--EXPORT_SYMBOL(sha256_final);
480
- 
481
- void sha224_final(struct sha256_state *sctx, u8 *out)
482
- {
483
- 	__sha256_final(sctx, out, 7);
484
- }
485
--EXPORT_SYMBOL(sha224_final);
486
- 
487
- void sha256(const u8 *data, unsigned int len, u8 *out)
488
- {
489
-@@ -206,6 +202,5 @@ void sha256(const u8 *data, unsigned int len, u8 *out)
490
- 	sha256_update(&sctx, data, len);
491
- 	sha256_final(&sctx, out);
492
- }
493
--EXPORT_SYMBOL(sha256);
494
- 
495
- MODULE_LICENSE("GPL");
496
-2.40.1
497
-
498 1
deleted file mode 100644
... ...
@@ -1,297 +0,0 @@
1
-From 6210be8ad27fcc388eeb4f38526e517ff17e42a0 Mon Sep 17 00:00:00 2001
2
-From: Keerthana K <keerthanak@vmware.com>
3
-Date: Mon, 11 Jan 2021 16:46:43 +0000
4
-Subject: [PATCH 1/2] FIPS canister binary usage
5
-
6
-Build with fips canister and skip building crypto algorithms.
7
-Invoke fips canister integrity check during kernel startup.
8
-
9
-This patch can be used at two stages:
10
- 1. Prerequisite patch for canister creation.
11
- 2. Binary canister usage time.
12
-
13
-Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
14
-Signed-off-by: Keerthana K <keerthanak@vmware.com>
15
-Signed-off-by: Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com>
16
- arch/x86/crypto/Makefile |   4 --
17
- crypto/Makefile          | 112 +++++++++++++++++++++++++++++++--------
18
- init/main.c              |   3 ++
19
- lib/crypto/Makefile      |  12 -----
20
- 4 files changed, 92 insertions(+), 39 deletions(-)
21
-
22
-diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
23
-index 3b1d701a4..3836c4e30 100644
24
-+++ b/arch/x86/crypto/Makefile
25
-@@ -46,10 +46,6 @@ obj-$(CONFIG_CRYPTO_CHACHA20_X86_64) += chacha-x86_64.o
26
- chacha-x86_64-y := chacha-avx2-x86_64.o chacha-ssse3-x86_64.o chacha_glue.o
27
- chacha-x86_64-$(CONFIG_AS_AVX512) += chacha-avx512vl-x86_64.o
28
- 
29
--obj-$(CONFIG_CRYPTO_AES_NI_INTEL) += aesni-intel.o
30
--aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o
31
--aesni-intel-$(CONFIG_64BIT) += aesni-intel_avx-x86_64.o aes_ctrby8_avx-x86_64.o
32
--
33
- obj-$(CONFIG_CRYPTO_SHA1_SSSE3) += sha1-ssse3.o
34
- sha1-ssse3-y := sha1_avx2_x86_64_asm.o sha1_ssse3_asm.o sha1_ssse3_glue.o
35
- sha1-ssse3-$(CONFIG_AS_SHA1_NI) += sha1_ni_asm.o
36
-diff --git a/crypto/Makefile b/crypto/Makefile
37
-index d7fcab76d..9a8372781 100644
38
-+++ b/crypto/Makefile
39
-@@ -40,7 +40,6 @@ rsa_generic-y += rsaprivkey.asn1.o
40
- rsa_generic-y += rsa.o
41
- rsa_generic-y += rsa_helper.o
42
- rsa_generic-y += rsa-pkcs1pad.o
43
--obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
44
- 
45
- $(obj)/sm2signature.asn1.o: $(obj)/sm2signature.asn1.c $(obj)/sm2signature.asn1.h
46
- $(obj)/sm2.o: $(obj)/sm2signature.asn1.h
47
-@@ -49,13 +48,11 @@ sm2_generic-y += sm2signature.asn1.o
48
- sm2_generic-y += sm2.o
49
- 
50
- obj-$(CONFIG_CRYPTO_SM2) += sm2_generic.o
51
--obj-$(CONFIG_CRYPTO_SELF_TEST) += crypto_self_test.o
52
- 
53
- $(obj)/ecdsasignature.asn1.o: $(obj)/ecdsasignature.asn1.c $(obj)/ecdsasignature.asn1.h
54
- $(obj)/ecdsa.o: $(obj)/ecdsasignature.asn1.h
55
- ecdsa_generic-y += ecdsa.o
56
- ecdsa_generic-y += ecdsasignature.asn1.o
57
--obj-$(CONFIG_CRYPTO_ECDSA) += ecdsa_generic.o
58
- 
59
- crypto_acompress-y := acompress.o
60
- crypto_acompress-y += scompress.o
61
-@@ -63,21 +60,15 @@ obj-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
62
- 
63
- cryptomgr-y := algboss.o testmgr.o
64
- 
65
--obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
66
- obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
67
- crypto_user-y := crypto_user_base.o
68
- crypto_user-$(CONFIG_CRYPTO_STATS) += crypto_user_stat.o
69
--obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
70
--obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
71
- obj-$(CONFIG_CRYPTO_VMAC) += vmac.o
72
- obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
73
- obj-$(CONFIG_CRYPTO_NULL2) += crypto_null.o
74
- obj-$(CONFIG_CRYPTO_MD4) += md4.o
75
- obj-$(CONFIG_CRYPTO_MD5) += md5.o
76
- obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
77
--obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o
78
--obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o
79
--obj-$(CONFIG_CRYPTO_SHA512) += sha512_generic.o
80
- obj-$(CONFIG_CRYPTO_SHA3) += sha3_generic.o
81
- obj-$(CONFIG_CRYPTO_SM3) += sm3.o
82
- obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
83
-@@ -87,21 +78,13 @@ CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/b
84
- obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b_generic.o
85
- CFLAGS_blake2b_generic.o := -Wframe-larger-than=4096 #  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105930
86
- obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
87
--obj-$(CONFIG_CRYPTO_ECB) += ecb.o
88
--obj-$(CONFIG_CRYPTO_CBC) += cbc.o
89
--obj-$(CONFIG_CRYPTO_CFB) += cfb.o
90
- obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
91
--obj-$(CONFIG_CRYPTO_CTS) += cts.o
92
- obj-$(CONFIG_CRYPTO_LRW) += lrw.o
93
--obj-$(CONFIG_CRYPTO_XTS) += xts.o
94
--obj-$(CONFIG_CRYPTO_CTR) += ctr.o
95
- obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
96
- obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
97
- obj-$(CONFIG_CRYPTO_KEYWRAP) += keywrap.o
98
- obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
99
- obj-$(CONFIG_CRYPTO_NHPOLY1305) += nhpoly1305.o
100
--obj-$(CONFIG_CRYPTO_GCM) += gcm.o
101
--obj-$(CONFIG_CRYPTO_CCM) += ccm.o
102
- obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
103
- obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
104
- aegis128-y := aegis128-core.o
105
-@@ -128,7 +111,6 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
106
- 
107
- obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
108
- obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
109
--obj-$(CONFIG_CRYPTO_DES) += des_generic.o
110
- obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
111
- obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
112
- obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
113
-@@ -136,7 +118,6 @@ obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
114
- obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
115
- obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
116
- CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
117
--obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
118
- CFLAGS_aes_generic.o := $(call cc-option,-fno-code-hoisting) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83356
119
- obj-$(CONFIG_CRYPTO_SM4) += sm4.o
120
- obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
121
-@@ -167,8 +148,6 @@ obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
122
- obj-$(CONFIG_CRYPTO_842) += 842.o
123
- obj-$(CONFIG_CRYPTO_RNG2) += rng.o
124
- obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
125
--obj-$(CONFIG_CRYPTO_DRBG) += drbg.o
126
--obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
127
- CFLAGS_jitterentropy.o = -O0
128
- KASAN_SANITIZE_jitterentropy.o = n
129
- UBSAN_SANITIZE_jitterentropy.o = n
130
-@@ -183,13 +162,11 @@ obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
131
- obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
132
- obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
133
- obj-$(CONFIG_CRYPTO_OFB) += ofb.o
134
--obj-$(CONFIG_CRYPTO_ECC) += ecc.o
135
- obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o
136
- obj-$(CONFIG_CRYPTO_CURVE25519) += curve25519-generic.o
137
- 
138
- ecdh_generic-y += ecdh.o
139
- ecdh_generic-y += ecdh_helper.o
140
--obj-$(CONFIG_CRYPTO_ECDH) += ecdh_generic.o
141
- 
142
- $(obj)/ecrdsa_params.asn1.o: $(obj)/ecrdsa_params.asn1.c $(obj)/ecrdsa_params.asn1.h
143
- $(obj)/ecrdsa_pub_key.asn1.o: $(obj)/ecrdsa_pub_key.asn1.c $(obj)/ecrdsa_pub_key.asn1.h
144
-@@ -213,3 +190,92 @@ obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
145
- # Key derivation function
146
- #
147
- obj-$(CONFIG_CRYPTO_KDF800108_CTR) += kdf_sp800108.o
148
-+
149
-+obj-$(CONFIG_CRYPTO_FIPS) += fips_canister_wrapper_asm.o fips_canister_wrapper.o fips_canister.o
150
-+
151
-+ifdef CONFIG_CRYPTO_FIPS
152
-+ifneq ($(CONFIG_CRYPTO_FIPS),y)
153
-+  $(error FIPS canister requires CONFIG_CRYPTO_FIPS=y)
154
-+endif
155
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_AEAD)),y)
156
-+  $(error FIPS canister requires CONFIG_CRYPTO_AEAD=y)
157
-+endif
158
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_RSA)),y)
159
-+  $(error FIPS canister requires CONFIG_CRYPTO_RSA=y)
160
-+endif
161
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_MANAGER)),y)
162
-+  $(error FIPS canister requires CONFIG_CRYPTO_MANAGER=y)
163
-+endif
164
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_MANAGER2)),y)
165
-+  $(error FIPS canister requires CONFIG_CRYPTO_MANAGER2=y)
166
-+endif
167
-+ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
168
-+  $(error FIPS canister requires CONFIG_CRYPTO_MANAGER_DISABLE_TESTS to be unset)
169
-+endif
170
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_HMAC)),y)
171
-+  $(error FIPS canister requires CONFIG_CRYPTO_HMAC=y)
172
-+endif
173
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_SHA256)),y)
174
-+  $(error FIPS canister requires CONFIG_CRYPTO_SHA256=y)
175
-+endif
176
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_SHA512)),y)
177
-+  $(error FIPS canister requires CONFIG_CRYPTO_SHA512=y)
178
-+endif
179
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_AES)),y)
180
-+  $(error FIPS canister requires CONFIG_CRYPTO_AES=y)
181
-+endif
182
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_DES)),y)
183
-+  $(error FIPS canister requires CONFIG_CRYPTO_DES=y)
184
-+endif
185
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_ECB)),y)
186
-+  $(error FIPS canister requires CONFIG_CRYPTO_ECB=y)
187
-+endif
188
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CBC)),y)
189
-+  $(error FIPS canister requires CONFIG_CRYPTO_CBC=y)
190
-+endif
191
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_XTS)),y)
192
-+  $(error FIPS canister requires CONFIG_CRYPTO_XTS=y)
193
-+endif
194
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CTR)),y)
195
-+  $(error FIPS canister requires CONFIG_CRYPTO_CTR=y)
196
-+endif
197
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_DRBG)),y)
198
-+  $(error FIPS canister requires CONFIG_CRYPTO_DRBG=y)
199
-+endif
200
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_DRBG_HASH)),y)
201
-+  $(error FIPS canister requires CONFIG_CRYPTO_DRBG_HASH=y)
202
-+endif
203
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_DRBG_CTR)),y)
204
-+  $(error FIPS canister requires CONFIG_CRYPTO_DRBG_CTR=y)
205
-+endif
206
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_JITTERENTROPY)),y)
207
-+  $(error FIPS canister requires CONFIG_CRYPTO_JITTERENTROPY=y)
208
-+endif
209
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_ECC)),y)
210
-+  $(error FIPS canister requires CONFIG_CRYPTO_ECC=y)
211
-+endif
212
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_ECDH)),y)
213
-+  $(error FIPS canister requires CONFIG_CRYPTO_ECDH=y)
214
-+endif
215
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_AES_NI_INTEL)),y)
216
-+  $(error FIPS canister requires CONFIG_CRYPTO_AES_NI_INTEL=y)
217
-+endif
218
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CFB)),y)
219
-+  $(error FIPS canister requires CONFIG_CRYPTO_CFB=y)
220
-+endif
221
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CMAC)),y)
222
-+  $(error FIPS canister requires CONFIG_CRYPTO_CMAC=y)
223
-+endif
224
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CTS)),y)
225
-+  $(error FIPS canister requires CONFIG_CRYPTO_CTS=y)
226
-+endif
227
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_ECDSA)),y)
228
-+  $(error FIPS canister requires CONFIG_CRYPTO_ECDSA=y)
229
-+endif
230
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_CCM)),y)
231
-+  $(error FIPS canister requires CONFIG_CRYPTO_CCM=y)
232
-+endif
233
-+ifneq ($(subst Y,y,$(CONFIG_CRYPTO_GCM)),y)
234
-+  $(error FIPS canister requires CONFIG_CRYPTO_GCM=y)
235
-+endif
236
-+endif
237
-diff --git a/init/main.c b/init/main.c
238
-index aa21add5f..4db7e4edd 100644
239
-+++ b/init/main.c
240
-@@ -885,6 +885,8 @@ static int __init early_randomize_kstack_offset(char *buf)
241
- early_param("randomize_kstack_offset", early_randomize_kstack_offset);
242
- #endif
243
- 
244
-+extern int fips_integrity_init(void);
245
-+
246
- void __init __weak arch_call_rest_init(void)
247
- {
248
- 	rest_init();
249
-@@ -986,6 +988,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
250
- 	/* Architectural and non-timekeeping rng init, before allocator init */
251
- 	random_init_early(command_line);
252
- 
253
-+	fips_integrity_init();
254
- 	/*
255
- 	 * These use large bootmem allocations and must precede
256
- 	 * kmem_cache_init()
257
-diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
258
-index c852f067a..84ec57dba 100644
259
-+++ b/lib/crypto/Makefile
260
-@@ -7,9 +7,6 @@ libcryptoutils-y				:= memneq.o utils.o
261
- obj-y						+= chacha.o
262
- obj-$(CONFIG_CRYPTO_LIB_CHACHA_GENERIC)		+= libchacha.o
263
- 
264
--obj-$(CONFIG_CRYPTO_LIB_AES)			+= libaes.o
265
--libaes-y					:= aes.o
266
--
267
- obj-$(CONFIG_CRYPTO_LIB_ARC4)			+= libarc4.o
268
- libarc4-y					:= arc4.o
269
- 
270
-@@ -29,20 +26,11 @@ libcurve25519-generic-y				+= curve25519-generic.o
271
- obj-$(CONFIG_CRYPTO_LIB_CURVE25519)		+= libcurve25519.o
272
- libcurve25519-y					+= curve25519.o
273
- 
274
--obj-$(CONFIG_CRYPTO_LIB_DES)			+= libdes.o
275
--libdes-y					:= des.o
276
--
277
- obj-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC)	+= libpoly1305.o
278
- libpoly1305-y					:= poly1305-donna32.o
279
- libpoly1305-$(CONFIG_ARCH_SUPPORTS_INT128)	:= poly1305-donna64.o
280
- libpoly1305-y					+= poly1305.o
281
- 
282
--obj-$(CONFIG_CRYPTO_LIB_SHA1)			+= libsha1.o
283
--libsha1-y					:= sha1.o
284
--
285
--obj-$(CONFIG_CRYPTO_LIB_SHA256)			+= libsha256.o
286
--libsha256-y					:= sha256.o
287
--
288
- ifneq ($(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS),y)
289
- libblake2s-y					+= blake2s-selftest.o
290
- libchacha20poly1305-y				+= chacha20poly1305-selftest.o
291
-2.40.0
... ...
@@ -16,7 +16,7 @@
16 16
 Summary:        Kernel
17 17
 Name:           linux-secure
18 18
 Version:        6.1.10
19
-Release:        15%{?kat_build:.kat}%{?dist}
19
+Release:        16%{?kat_build:.kat}%{?dist}
20 20
 License:        GPLv2
21 21
 URL:            http://www.kernel.org
22 22
 Group:          System Environment/Kernel
... ...
@@ -124,14 +124,18 @@ Patch512: 0003-FIPS-broken-kattest.patch
124 124
 %endif
125 125
 
126 126
 %if 0%{?canister_build}
127
-Patch10000: 6.1.10-14-0001-FIPS-canister-binary-usage.patch
128
-Patch10001: 0002-FIPS-canister-creation.patch
129
-Patch10002: 0003-aesni_intel-Remove-static-call.patch
130
-Patch10003: 0004-Disable-retpoline_sites-and-return_sites-section-in-.patch
131
-Patch10004: 0005-Move-__bug_table-section-to-fips_canister_wrapper.patch
132
-Patch10005: 0001-scripts-kallsyms-Extra-kallsyms-parsing.patch
133
-Patch10006: 0001-crypto-Move-printk-prandom-module_kthread_exit-to-ca.patch
134
-Patch10007: 0001-crypto-Remove-EXPORT_SYMBOL-EXPORT_SYMBOL_GPL-from-c.patch
127
+# Below patches are common for fips and canister_build flags
128
+# 0001-FIPS-canister-binary-usage.patch is renamed as <ver-rel>-0001-FIPS-canister-binary-usage.patch
129
+# in both places until final canister binary is released
130
+Patch10000: 6.1.10-16-0001-FIPS-canister-binary-usage.patch
131
+Patch10001: 0001-scripts-kallsyms-Extra-kallsyms-parsing.patch
132
+# Below patches are specific to canister_build flag
133
+Patch10002: 0002-FIPS-canister-creation.patch
134
+Patch10003: 0003-aesni_intel-Remove-static-call.patch
135
+Patch10004: 0004-Disable-retpoline_sites-and-return_sites-section-in-.patch
136
+Patch10005: 0005-Move-__bug_table-section-to-fips_canister_wrapper.patch
137
+Patch10006: 0006-crypto-Add-prandom-module_kthread_exit-to-canister-w.patch
138
+Patch10007: 0007-crypto-Remove-EXPORT_SYMBOL-EXPORT_SYMBOL_GPL-from-c.patch
135 139
 %endif
136 140
 
137 141
 BuildArch:      x86_64
... ...
@@ -390,6 +394,8 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg
390 390
 %endif
391 391
 
392 392
 %changelog
393
+* Thu Jun 29 2023 Keerthana K <keerthanak@vmware.com> 6.1.10-16
394
+- Add SHA3 to canister and canister patches re-arrangements and cleanups.
393 395
 * Wed Jun 21 2023 Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com> 6.1.10-15
394 396
 - Fix build when not building canister
395 397
 * Mon May 22 2023 Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com> 6.1.10-14