Browse code

linux-secure: Add new algorithms to canister

- cfb, cmac, cts, ecdsa, ccm, gcm

Change-Id: Id045ecc605615e5dfed8945687e4e2e9fac14f1c
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/20061
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Keerthana K <keerthanak@vmware.com>

Vamsi Krishna Brahmajosyula authored on 2023/03/21 17:52:06
Showing 6 changed files
... ...
@@ -36,6 +36,7 @@
36 36
 #define SREL_INSN_TYPE_ADD_9				0xC		/* "1100" = Rel type 2, Addend 0 */
37 37
 #define SREL_INSN_TYPE_ADD_10				0xD		/* "1101" = Rel type 1, Addend 7 */
38 38
 #define SREL_INSN_TYPE_ADD_11				0xE		/* "1110" = Rel type 2, Addend 4 */
39
+#define SREL_INSN_TYPE_ADD_12				0xF		/* "1111" = Rel type 1, Addend 6 */
39 40
 
40 41
 static unsigned char *canister;
41 42
 /* Set at canister creation time by final linking */
... ...
@@ -225,6 +226,9 @@ static int canister_bytecode_interpreter(struct relocation *r, int *pos)
225 225
 		} else if (rel_add == SREL_INSN_TYPE_ADD_11) {
226 226
 			r->type = 2;
227 227
 			r->addend = 4;
228
+		} else if (rel_add == SREL_INSN_TYPE_ADD_12) {
229
+			r->type = 1;
230
+			r->addend = 6;
228 231
 		} else {
229 232
 			err = -ENOENT;
230 233
 			return err;
... ...
@@ -116,6 +116,7 @@
116 116
 #define SREL_INSN_TYPE_ADD_9				0xC		/* "1100" = Rel type 2, Addend 0 */
117 117
 #define SREL_INSN_TYPE_ADD_10				0xD		/* "1101" = Rel type 1, Addend 7 */
118 118
 #define SREL_INSN_TYPE_ADD_11				0xE		/* "1110" = Rel type 2, Addend 4 */
119
+#define SREL_INSN_TYPE_ADD_12				0xF		/* "1111" = Rel type 1, Addend 6 */
119 120
 
120 121
 
121 122
 /* Long Rel Instructions */
... ...
@@ -715,8 +716,10 @@ static void print_srel_insn(int nfd, unsigned short type, unsigned short symbol,
715 715
 		srel = srel | SREL_INSN_TYPE_ADD_10;
716 716
 	} else if (type == 2 && addend == 4) {
717 717
 		srel = srel | SREL_INSN_TYPE_ADD_11;
718
+	} else if (type == 1 && addend == 6) {
719
+		srel = srel | SREL_INSN_TYPE_ADD_12;
718 720
 	} else {
719
-		printf("WARNING: Unknown rel type and addend combination!!! %d %d\n", type, addend);
721
+		error("Unknown rel type and addend combination!!! %d %d\n", type, addend);
720 722
 	}
721 723
 	print_insn_byte_wise(srel, nfd);
722 724
 }
... ...
@@ -21,21 +21,27 @@ Canister creation patch.
21 21
 
22 22
 Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
23 23
 Signed-off-by: Keerthana K <keerthanak@vmware.com>
24
+Signed-off-by: Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com>
24 25
 ---
25 26
  arch/x86/crypto/aesni-intel_glue.c |  73 ++++++++++---------
26
- crypto/Makefile                    |  95 +++++++++++++++++++++++++
27
+ crypto/Makefile                    | 107 ++++++++++++++++++++++++++++
27 28
  crypto/algboss.c                   |   5 +-
29
+ crypto/ccm.c                       |   7 +-
30
+ crypto/cmac.c                      |   3 +-
28 31
  crypto/ctr.c                       |   3 +-
32
+ crypto/cts.c                       |   3 +-
29 33
  crypto/drbg.c                      |  50 ++++++++-----
30 34
  crypto/ecc.c                       |   5 +-
31 35
  crypto/ecdh.c                      |   5 +-
36
+ crypto/ecdsa.c                     |   3 +-
37
+ crypto/gcm.c                       |  11 +--
32 38
  crypto/hmac.c                      |   3 +-
33 39
  crypto/jitterentropy-kcapi.c       |  18 +++--
34 40
  crypto/rsa-pkcs1pad.c              |  13 ++--
35 41
  crypto/testmgr.c                   | 108 ++++++++++++++++-------------
36 42
  crypto/xts.c                       |   3 +-
37 43
  include/crypto/drbg.h              |   3 +-
38
- 13 files changed, 258 insertions(+), 126 deletions(-)
44
+ 18 files changed, 286 insertions(+), 137 deletions(-)
39 45
 
40 46
 diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
41 47
 index a5b0cb3ef..10420b2aa 100644
... ...
@@ -317,14 +323,14 @@ index a5b0cb3ef..10420b2aa 100644
317 317
  		err = skcipher_walk_done(&walk, 0);
318 318
  	}
319 319
 diff --git a/crypto/Makefile b/crypto/Makefile
320
-index f5a5fb946..9116be6df 100644
320
+index 9a8372781..688a58b30 100644
321 321
 --- a/crypto/Makefile
322 322
 +++ b/crypto/Makefile
323 323
 @@ -40,6 +40,13 @@ rsa_generic-y += rsaprivkey.asn1.o
324 324
  rsa_generic-y += rsa.o
325 325
  rsa_generic-y += rsa_helper.o
326 326
  rsa_generic-y += rsa-pkcs1pad.o
327
-+canister := $(rsa_generic-y)
327
++canister += $(rsa_generic-y)
328 328
 +# Disable latent entropy plugin and rap plugin for all canister objects.
329 329
 +CFLAGS_REMOVE_rsapubkey.asn1.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
330 330
 +CFLAGS_REMOVE_rsaprivkey.asn1.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
... ...
@@ -334,7 +340,16 @@ index f5a5fb946..9116be6df 100644
334 334
  
335 335
  $(obj)/sm2signature.asn1.o: $(obj)/sm2signature.asn1.c $(obj)/sm2signature.asn1.h
336 336
  $(obj)/sm2.o: $(obj)/sm2signature.asn1.h
337
-@@ -60,17 +67,28 @@ crypto_acompress-y += scompress.o
337
+@@ -53,22 +60,38 @@ $(obj)/ecdsasignature.asn1.o: $(obj)/ecdsasignature.asn1.c $(obj)/ecdsasignature
338
+ $(obj)/ecdsa.o: $(obj)/ecdsasignature.asn1.h
339
+ ecdsa_generic-y += ecdsa.o
340
+ ecdsa_generic-y += ecdsasignature.asn1.o
341
++canister += $(ecdsa_generic-y)
342
++CFLAGS_REMOVE_ecdsa.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
343
++CFLAGS_REMOVE_ecdsasignature.asn1.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
344
+ 
345
+ crypto_acompress-y := acompress.o
346
+ crypto_acompress-y += scompress.o
338 347
  obj-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
339 348
  
340 349
  cryptomgr-y := algboss.o testmgr.o
... ...
@@ -345,9 +360,10 @@ index f5a5fb946..9116be6df 100644
345 345
  obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
346 346
  crypto_user-y := crypto_user_base.o
347 347
  crypto_user-$(CONFIG_CRYPTO_STATS) += crypto_user_stat.o
348
- obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
349 348
 +canister += hmac.o
349
++canister += cmac.o
350 350
 +CFLAGS_REMOVE_hmac.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
351
++CFLAGS_REMOVE_cmac.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
351 352
  obj-$(CONFIG_CRYPTO_VMAC) += vmac.o
352 353
  obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
353 354
  obj-$(CONFIG_CRYPTO_NULL2) += crypto_null.o
... ...
@@ -363,7 +379,7 @@ index f5a5fb946..9116be6df 100644
363 363
  obj-$(CONFIG_CRYPTO_SHA3) += sha3_generic.o
364 364
  obj-$(CONFIG_CRYPTO_SM3) += sm3.o
365 365
  obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
366
-@@ -80,10 +98,18 @@ CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/b
366
+@@ -78,13 +101,29 @@ CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/b
367 367
  obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b_generic.o
368 368
  CFLAGS_blake2b_generic.o := -Wframe-larger-than=4096 #  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105930
369 369
  obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
... ...
@@ -371,9 +387,11 @@ index f5a5fb946..9116be6df 100644
371 371
 +canister += cbc.o
372 372
 +CFLAGS_REMOVE_ecb.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
373 373
 +CFLAGS_REMOVE_cbc.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
374
- obj-$(CONFIG_CRYPTO_CFB) += cfb.o
374
++canister += cfb.o
375
++CFLAGS_REMOVE_cfb.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
375 376
  obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
376
- obj-$(CONFIG_CRYPTO_CTS) += cts.o
377
++canister += cts.o
378
++CFLAGS_REMOVE_cts.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
377 379
  obj-$(CONFIG_CRYPTO_LRW) += lrw.o
378 380
 +canister += xts.o
379 381
 +canister += ctr.o
... ...
@@ -382,7 +400,16 @@ index f5a5fb946..9116be6df 100644
382 382
  obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
383 383
  obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
384 384
  obj-$(CONFIG_CRYPTO_KEYWRAP) += keywrap.o
385
-@@ -117,6 +143,8 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
385
+ obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
386
+ obj-$(CONFIG_CRYPTO_NHPOLY1305) += nhpoly1305.o
387
++canister += gcm.o
388
++canister += ccm.o
389
++CFLAGS_REMOVE_gcm.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
390
++CFLAGS_REMOVE_ccm.o += -DLATENT_ENTROPY_PLUGIN -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -fplugin-arg-rap_plugin-check=call
391
+ obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
392
+ obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
393
+ aegis128-y := aegis128-core.o
394
+@@ -111,6 +150,8 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
386 395
  
387 396
  obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
388 397
  obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
... ...
@@ -391,7 +418,7 @@ index f5a5fb946..9116be6df 100644
391 391
  obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
392 392
  obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
393 393
  obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
394
-@@ -124,7 +152,9 @@ obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
394
+@@ -118,7 +159,9 @@ obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
395 395
  obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
396 396
  obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
397 397
  CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
... ...
@@ -401,7 +428,7 @@ index f5a5fb946..9116be6df 100644
401 401
  obj-$(CONFIG_CRYPTO_SM4) += sm4.o
402 402
  obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
403 403
  obj-$(CONFIG_CRYPTO_AES_TI) += aes_ti.o
404
-@@ -154,10 +184,15 @@ obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
404
+@@ -148,10 +191,15 @@ obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
405 405
  obj-$(CONFIG_CRYPTO_842) += 842.o
406 406
  obj-$(CONFIG_CRYPTO_RNG2) += rng.o
407 407
  obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
... ...
@@ -417,7 +444,7 @@ index f5a5fb946..9116be6df 100644
417 417
  obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
418 418
  obj-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
419 419
  obj-$(CONFIG_CRYPTO_POLYVAL) += polyval-generic.o
420
-@@ -168,11 +203,16 @@ obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
420
+@@ -162,11 +210,16 @@ obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
421 421
  obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
422 422
  obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
423 423
  obj-$(CONFIG_CRYPTO_OFB) += ofb.o
... ...
@@ -434,11 +461,10 @@ index f5a5fb946..9116be6df 100644
434 434
  
435 435
  $(obj)/ecrdsa_params.asn1.o: $(obj)/ecrdsa_params.asn1.c $(obj)/ecrdsa_params.asn1.h
436 436
  $(obj)/ecrdsa_pub_key.asn1.o: $(obj)/ecrdsa_pub_key.asn1.c $(obj)/ecrdsa_pub_key.asn1.h
437
-@@ -197,6 +237,61 @@ obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
437
+@@ -191,6 +244,60 @@ obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
438 438
  #
439 439
  obj-$(CONFIG_CRYPTO_KDF800108_CTR) += kdf_sp800108.o
440 440
  
441
-+
442 441
 +aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o
443 442
 +aesni-intel-$(CONFIG_64BIT) += aesni-intel_avx-x86_64.o aes_ctrby8_avx-x86_64.o
444 443
 +OBJECT_FILES_NON_STANDARD_x86-aesni-intel_avx-x86_64.o := y
... ...
@@ -526,6 +552,66 @@ index eb5fe84ef..62bb3eb18 100644
526 526
  	if (!param)
527 527
  		goto err_put_module;
528 528
  
529
+diff --git a/crypto/ccm.c b/crypto/ccm.c
530
+index 6b815ece5..a22f6ec26 100644
531
+--- a/crypto/ccm.c
532
+@@ -15,6 +15,7 @@
533
+ #include <linux/kernel.h>
534
+ #include <linux/module.h>
535
+ #include <linux/slab.h>
536
++#include "fips_canister_wrapper.h"
537
+ 
538
+ struct ccm_instance_ctx {
539
+ 	struct crypto_skcipher_spawn ctr;
540
+@@ -459,7 +460,7 @@ static int crypto_ccm_create_common(struct crypto_template *tmpl,
541
+ 	if (err)
542
+ 		return err;
543
+ 
544
+-	inst = kzalloc(sizeof(*inst) + sizeof(*ictx), GFP_KERNEL);
545
++	inst = fcw_kzalloc(sizeof(*inst) + sizeof(*ictx), GFP_KERNEL);
546
+ 	if (!inst)
547
+ 		return -ENOMEM;
548
+ 	ictx = aead_instance_ctx(inst);
549
+@@ -716,7 +717,7 @@ static int crypto_rfc4309_create(struct crypto_template *tmpl,
550
+ 	if (err)
551
+ 		return err;
552
+ 
553
+-	inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
554
++	inst = fcw_kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
555
+ 	if (!inst)
556
+ 		return -ENOMEM;
557
+ 
558
+@@ -872,7 +873,7 @@ static int cbcmac_create(struct crypto_template *tmpl, struct rtattr **tb)
559
+ 	if (err)
560
+ 		return err;
561
+ 
562
+-	inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
563
++	inst = fcw_kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
564
+ 	if (!inst)
565
+ 		return -ENOMEM;
566
+ 	spawn = shash_instance_ctx(inst);
567
+diff --git a/crypto/cmac.c b/crypto/cmac.c
568
+index f4a5d3bfb..4ec1c1cc8 100644
569
+--- a/crypto/cmac.c
570
+@@ -16,6 +16,7 @@
571
+ #include <linux/err.h>
572
+ #include <linux/kernel.h>
573
+ #include <linux/module.h>
574
++#include "fips_canister_wrapper.h"
575
+ 
576
+ /*
577
+  * +------------------------
578
+@@ -233,7 +234,7 @@ static int cmac_create(struct crypto_template *tmpl, struct rtattr **tb)
579
+ 	if (err)
580
+ 		return err;
581
+ 
582
+-	inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
583
++	inst = fcw_kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
584
+ 	if (!inst)
585
+ 		return -ENOMEM;
586
+ 	spawn = shash_instance_ctx(inst);
529 587
 diff --git a/crypto/ctr.c b/crypto/ctr.c
530 588
 index 23c698b22..1906d0f8c 100644
531 589
 --- a/crypto/ctr.c
... ...
@@ -547,8 +633,29 @@ index 23c698b22..1906d0f8c 100644
547 547
  	if (!inst)
548 548
  		return -ENOMEM;
549 549
  
550
+diff --git a/crypto/cts.c b/crypto/cts.c
551
+index 3766d47eb..06706abef 100644
552
+--- a/crypto/cts.c
553
+@@ -51,6 +51,7 @@
554
+ #include <crypto/scatterwalk.h>
555
+ #include <linux/slab.h>
556
+ #include <linux/compiler.h>
557
++#include "fips_canister_wrapper.h"
558
+ 
559
+ struct crypto_cts_ctx {
560
+ 	struct crypto_skcipher *child;
561
+@@ -333,7 +334,7 @@ static int crypto_cts_create(struct crypto_template *tmpl, struct rtattr **tb)
562
+ 	if (err)
563
+ 		return err;
564
+ 
565
+-	inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
566
++	inst = fcw_kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
567
+ 	if (!inst)
568
+ 		return -ENOMEM;
569
+ 
550 570
 diff --git a/crypto/drbg.c b/crypto/drbg.c
551
-index 9baf2ec07..83555a497 100644
571
+index 9d70c407d..04624249a 100644
552 572
 --- a/crypto/drbg.c
553 573
 +++ b/crypto/drbg.c
554 574
 @@ -101,6 +101,7 @@
... ...
@@ -672,7 +779,7 @@ index 9baf2ec07..83555a497 100644
672 672
  					 GFP_KERNEL);
673 673
  	if (!drbg->outscratchpadbuf) {
674 674
  		drbg_fini_sym_kernel(drbg);
675
-@@ -1975,14 +1976,19 @@ static int drbg_kcapi_init(struct crypto_tfm *tfm)
675
+@@ -1973,14 +1974,19 @@ static int drbg_kcapi_init(struct crypto_tfm *tfm)
676 676
  {
677 677
  	struct drbg_state *drbg = crypto_tfm_ctx(tfm);
678 678
  
... ...
@@ -694,7 +801,7 @@ index 9baf2ec07..83555a497 100644
694 694
  }
695 695
  
696 696
  /*
697
-@@ -2073,11 +2079,16 @@ static inline int __init drbg_healthcheck_sanity(void)
697
+@@ -2071,11 +2077,16 @@ static inline int __init drbg_healthcheck_sanity(void)
698 698
  	drbg_convert_tfm_core("drbg_nopr_hmac_sha256", &coreref, &pr);
699 699
  #endif
700 700
  
... ...
@@ -713,7 +820,7 @@ index 9baf2ec07..83555a497 100644
713 713
  	drbg->core = &drbg_cores[coreref];
714 714
  	drbg->reseed_threshold = drbg_max_requests(drbg);
715 715
  
716
-@@ -2108,6 +2119,7 @@ static inline int __init drbg_healthcheck_sanity(void)
716
+@@ -2106,6 +2117,7 @@ static inline int __init drbg_healthcheck_sanity(void)
717 717
  	pr_devel("DRBG: Sanity tests for failure code paths successfully "
718 718
  		 "completed\n");
719 719
  
... ...
@@ -752,7 +859,7 @@ index b2a412d94..016f785b8 100644
752 752
  	if (!p)
753 753
  		return NULL;
754 754
 diff --git a/crypto/ecdh.c b/crypto/ecdh.c
755
-index e4857d534..3daa0fcde 100644
755
+index 80afee323..75ae30323 100644
756 756
 --- a/crypto/ecdh.c
757 757
 +++ b/crypto/ecdh.c
758 758
 @@ -11,6 +11,7 @@
... ...
@@ -778,6 +885,84 @@ index e4857d534..3daa0fcde 100644
778 778
  		if (!shared_secret)
779 779
  			goto free_pubkey;
780 780
  
781
+diff --git a/crypto/ecdsa.c b/crypto/ecdsa.c
782
+index fbd76498a..13eb687bf 100644
783
+--- a/crypto/ecdsa.c
784
+@@ -12,6 +12,7 @@
785
+ #include <linux/scatterlist.h>
786
+ 
787
+ #include "ecdsasignature.asn1.h"
788
++#include "fips_canister_wrapper.h"
789
+ 
790
+ struct ecc_ctx {
791
+ 	unsigned int curve_id;
792
+@@ -151,7 +152,7 @@ static int ecdsa_verify(struct akcipher_request *req)
793
+ 	if (unlikely(!ctx->pub_key_set))
794
+ 		return -EINVAL;
795
+ 
796
+-	buffer = kmalloc(req->src_len + req->dst_len, GFP_KERNEL);
797
++	buffer = fcw_kmalloc(req->src_len + req->dst_len, GFP_KERNEL);
798
+ 	if (!buffer)
799
+ 		return -ENOMEM;
800
+ 
801
+diff --git a/crypto/gcm.c b/crypto/gcm.c
802
+index 338ee0769..ae81153a3 100644
803
+--- a/crypto/gcm.c
804
+@@ -18,6 +18,7 @@
805
+ #include <linux/kernel.h>
806
+ #include <linux/module.h>
807
+ #include <linux/slab.h>
808
++#include "fips_canister_wrapper.h"
809
+ 
810
+ struct gcm_instance_ctx {
811
+ 	struct crypto_skcipher_spawn ctr;
812
+@@ -113,7 +114,7 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key,
813
+ 	if (err)
814
+ 		return err;
815
+ 
816
+-	data = kzalloc(sizeof(*data) + crypto_skcipher_reqsize(ctr),
817
++	data = fcw_kzalloc(sizeof(*data) + crypto_skcipher_reqsize(ctr),
818
+ 		       GFP_KERNEL);
819
+ 	if (!data)
820
+ 		return -ENOMEM;
821
+@@ -589,7 +590,7 @@ static int crypto_gcm_create_common(struct crypto_template *tmpl,
822
+ 	if (err)
823
+ 		return err;
824
+ 
825
+-	inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
826
++	inst = fcw_kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
827
+ 	if (!inst)
828
+ 		return -ENOMEM;
829
+ 	ctx = aead_instance_ctx(inst);
830
+@@ -837,7 +838,7 @@ static int crypto_rfc4106_create(struct crypto_template *tmpl,
831
+ 	if (err)
832
+ 		return err;
833
+ 
834
+-	inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
835
++	inst = fcw_kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
836
+ 	if (!inst)
837
+ 		return -ENOMEM;
838
+ 
839
+@@ -1052,7 +1053,7 @@ static int crypto_rfc4543_create(struct crypto_template *tmpl,
840
+ 	if (err)
841
+ 		return err;
842
+ 
843
+-	inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
844
++	inst = fcw_kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
845
+ 	if (!inst)
846
+ 		return -ENOMEM;
847
+ 
848
+@@ -1135,7 +1136,7 @@ static int __init crypto_gcm_module_init(void)
849
+ {
850
+ 	int err;
851
+ 
852
+-	gcm_zeroes = kzalloc(sizeof(*gcm_zeroes), GFP_KERNEL);
853
++	gcm_zeroes = fcw_kzalloc(sizeof(*gcm_zeroes), GFP_KERNEL);
854
+ 	if (!gcm_zeroes)
855
+ 		return -ENOMEM;
856
+ 
781 857
 diff --git a/crypto/hmac.c b/crypto/hmac.c
782 858
 index 3610ff0b6..7c289df3b 100644
783 859
 --- a/crypto/hmac.c
... ...
@@ -940,7 +1125,7 @@ index 3285e3af4..826dd0833 100644
940 940
  		return -ENOMEM;
941 941
  
942 942
 diff --git a/crypto/testmgr.c b/crypto/testmgr.c
943
-index 07523e76d..1cc688534 100644
943
+index aa0025b0c..98422b8da 100644
944 944
 --- a/crypto/testmgr.c
945 945
 +++ b/crypto/testmgr.c
946 946
 @@ -37,6 +37,7 @@
... ...
@@ -1236,7 +1421,7 @@ index 07523e76d..1cc688534 100644
1236 1236
  	if (!decomp_out) {
1237 1237
  		kfree(output);
1238 1238
  		return -ENOMEM;
1239
-@@ -3501,7 +3502,7 @@ static int test_cprng(struct crypto_rng *tfm,
1239
+@@ -3530,7 +3531,7 @@ static int test_cprng(struct crypto_rng *tfm,
1240 1240
  
1241 1241
  	seedsize = crypto_rng_seedsize(tfm);
1242 1242
  
... ...
@@ -1245,7 +1430,7 @@ index 07523e76d..1cc688534 100644
1245 1245
  	if (!seed) {
1246 1246
  		printk(KERN_ERR "alg: cprng: Failed to allocate seed space "
1247 1247
  		       "for %s\n", algo);
1248
-@@ -3693,7 +3694,7 @@ static int drbg_cavs_test(const struct drbg_testvec *test, int pr,
1248
+@@ -3722,7 +3723,7 @@ static int drbg_cavs_test(const struct drbg_testvec *test, int pr,
1249 1249
  	struct crypto_rng *drng;
1250 1250
  	struct drbg_test_data test_data;
1251 1251
  	struct drbg_string addtl, pers, testentropy;
... ...
@@ -1254,7 +1439,7 @@ index 07523e76d..1cc688534 100644
1254 1254
  
1255 1255
  	if (!buf)
1256 1256
  		return -ENOMEM;
1257
-@@ -3793,7 +3794,7 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
1257
+@@ -3822,7 +3823,7 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
1258 1258
  	int err = -ENOMEM;
1259 1259
  	struct scatterlist src, dst;
1260 1260
  
... ...
@@ -1263,7 +1448,7 @@ index 07523e76d..1cc688534 100644
1263 1263
  	if (!req)
1264 1264
  		return err;
1265 1265
  
1266
-@@ -3804,7 +3805,7 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
1266
+@@ -3833,7 +3834,7 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
1267 1267
  		goto free_req;
1268 1268
  
1269 1269
  	out_len_max = crypto_kpp_maxsize(tfm);
... ...
@@ -1272,7 +1457,7 @@ index 07523e76d..1cc688534 100644
1272 1272
  	if (!output_buf) {
1273 1273
  		err = -ENOMEM;
1274 1274
  		goto free_req;
1275
-@@ -3982,13 +3983,13 @@ static int test_akcipher_one(struct crypto_akcipher *tfm,
1275
+@@ -4011,13 +4012,13 @@ static int test_akcipher_one(struct crypto_akcipher *tfm,
1276 1276
  	if (testmgr_alloc_buf(xbuf))
1277 1277
  		return err;
1278 1278
  
... ...
@@ -1288,7 +1473,7 @@ index 07523e76d..1cc688534 100644
1288 1288
  		      GFP_KERNEL);
1289 1289
  	if (!key)
1290 1290
  		goto free_req;
1291
-@@ -4011,7 +4012,7 @@ static int test_akcipher_one(struct crypto_akcipher *tfm,
1291
+@@ -4040,7 +4041,7 @@ static int test_akcipher_one(struct crypto_akcipher *tfm,
1292 1292
  	 */
1293 1293
  	err = -ENOMEM;
1294 1294
  	out_len_max = crypto_akcipher_maxsize(tfm);
... ...
@@ -1297,7 +1482,7 @@ index 07523e76d..1cc688534 100644
1297 1297
  	if (!outbuf_enc)
1298 1298
  		goto free_key;
1299 1299
  
1300
-@@ -4088,7 +4089,7 @@ static int test_akcipher_one(struct crypto_akcipher *tfm,
1300
+@@ -4117,7 +4118,7 @@ static int test_akcipher_one(struct crypto_akcipher *tfm,
1301 1301
  		err = 0;
1302 1302
  		goto free_all;
1303 1303
  	}
... ...
@@ -1306,7 +1491,7 @@ index 07523e76d..1cc688534 100644
1306 1306
  	if (!outbuf_dec) {
1307 1307
  		err = -ENOMEM;
1308 1308
  		goto free_all;
1309
-@@ -5785,13 +5786,22 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
1309
+@@ -5814,13 +5815,22 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
1310 1310
  	int i;
1311 1311
  	int j;
1312 1312
  	int rc;
... ...
@@ -1373,5 +1558,4 @@ index af5ad51d3..f3e132d6f 100644
1373 1373
  	unsigned char *Vbuf;
1374 1374
  	/* hash: static value 10.1.1.1 1b) hmac / ctr: key */
1375 1375
 -- 
1376
-2.30.5
1377
-
1376
+2.40.0
... ...
@@ -5117,7 +5117,7 @@ CONFIG_CRYPTO_RSA=y
5117 5117
 # CONFIG_CRYPTO_DH is not set
5118 5118
 CONFIG_CRYPTO_ECC=y
5119 5119
 CONFIG_CRYPTO_ECDH=y
5120
-# CONFIG_CRYPTO_ECDSA is not set
5120
+CONFIG_CRYPTO_ECDSA=y
5121 5121
 # CONFIG_CRYPTO_ECRDSA is not set
5122 5122
 # CONFIG_CRYPTO_SM2 is not set
5123 5123
 # CONFIG_CRYPTO_CURVE25519 is not set
... ...
@@ -5151,7 +5151,7 @@ CONFIG_CRYPTO_DES=y
5151 5151
 CONFIG_CRYPTO_ARC4=m
5152 5152
 # CONFIG_CRYPTO_CHACHA20 is not set
5153 5153
 CONFIG_CRYPTO_CBC=y
5154
-# CONFIG_CRYPTO_CFB is not set
5154
+CONFIG_CRYPTO_CFB=y
5155 5155
 CONFIG_CRYPTO_CTR=y
5156 5156
 CONFIG_CRYPTO_CTS=m
5157 5157
 CONFIG_CRYPTO_ECB=y
... ...
@@ -5168,7 +5168,7 @@ CONFIG_CRYPTO_XTS=y
5168 5168
 #
5169 5169
 # CONFIG_CRYPTO_AEGIS128 is not set
5170 5170
 # CONFIG_CRYPTO_CHACHA20POLY1305 is not set
5171
-CONFIG_CRYPTO_CCM=m
5171
+CONFIG_CRYPTO_CCM=y
5172 5172
 CONFIG_CRYPTO_GCM=m
5173 5173
 CONFIG_CRYPTO_SEQIV=m
5174 5174
 CONFIG_CRYPTO_ECHAINIV=m
5175 5175
new file mode 100644
... ...
@@ -0,0 +1,297 @@
0
+From 6210be8ad27fcc388eeb4f38526e517ff17e42a0 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/2] 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          | 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
+--- 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..9a8372781 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,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.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
+--- a/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
+--- a/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
+-- 
292
+2.40.0
... ...
@@ -16,7 +16,7 @@
16 16
 Summary:        Kernel
17 17
 Name:           linux-secure
18 18
 Version:        6.1.10
19
-Release:        7%{?kat_build:.kat}%{?dist}
19
+Release:        8%{?kat_build:.kat}%{?dist}
20 20
 License:        GPLv2
21 21
 URL:            http://www.kernel.org
22 22
 Group:          System Environment/Kernel
... ...
@@ -119,7 +119,7 @@ Patch512: 0003-FIPS-broken-kattest.patch
119 119
 %endif
120 120
 
121 121
 %if 0%{?canister_build}
122
-Patch10000:      6.1-0001-FIPS-canister-binary-usage.patch
122
+Patch10000:      6.1.10-8-0001-FIPS-canister-binary-usage.patch
123 123
 Patch10001:      0002-FIPS-canister-creation.patch
124 124
 Patch10003:      0004-aesni_intel_glue-Revert-static-calls-with-indirect-c.patch
125 125
 Patch10004:      0001-scripts-kallsyms-Extra-kallsyms-parsing.patch
... ...
@@ -252,6 +252,13 @@ sed -i "s/CONFIG_BUG_ON_DATA_CORRUPTION=y/# CONFIG_BUG_ON_DATA_CORRUPTION is not
252 252
 sed -i "s/CONFIG_CRYPTO_AEAD=m/CONFIG_CRYPTO_AEAD=y/" .config
253 253
 sed -i "s/CONFIG_CRYPTO_SIMD=m/CONFIG_CRYPTO_SIMD=y/" .config
254 254
 sed -i "s/CONFIG_CRYPTO_AES_NI_INTEL=m/CONFIG_CRYPTO_AES_NI_INTEL=y/" .config
255
+sed -i "s/CONFIG_CRYPTO_CMAC=m/CONFIG_CRYPTO_CMAC=y/" .config
256
+sed -i "s/CONFIG_CRYPTO_CTS=m/CONFIG_CRYPTO_CTS=y/" .config
257
+sed -i "s/CONFIG_CRYPTO_CCM=m/CONFIG_CRYPTO_CCM=y/" .config
258
+sed -i "s/CONFIG_CRYPTO_GHASH=m/CONFIG_CRYPTO_GHASH=y/" .config
259
+sed -i "s/CONFIG_CRYPTO_GF128MUL=m/CONFIG_CRYPTO_GF128MUL=y/" .config
260
+sed -i "s/CONFIG_CRYPTO_NULL=m/CONFIG_CRYPTO_NULL=y/" .config
261
+sed -i "s/CONFIG_CRYPTO_GCM=m/CONFIG_CRYPTO_GCM=y/" .config
255 262
 
256 263
 sed -i "0,/FIPS_CANISTER_VERSION.*$/s/FIPS_CANISTER_VERSION.*$/FIPS_CANISTER_VERSION \"%{lkcm_version}\"/" crypto/fips_integrity.c
257 264
 sed -i "0,/FIPS_KERNEL_VERSION.*$/s/FIPS_KERNEL_VERSION.*$/FIPS_KERNEL_VERSION \"%{version}-%{release}-secure\"/" crypto/fips_integrity.c
... ...
@@ -369,6 +376,9 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg
369 369
 %endif
370 370
 
371 371
 %changelog
372
+* Thu Mar 23 2023 Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com> 6.1.10-8
373
+- Add new algorithms to canister.
374
+- cfb, cmac, cts, ecdsa, ccm, gcm
372 375
 * Tue Mar 21 2023 Shreenidhi Shedi <sshedi@vmware.com> 6.1.10-7
373 376
 - Fix initramfs trigger
374 377
 * Thu Mar 16 2023 Keerthana K <keerthanak@vmware.com> 6.1.10-6