hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/crypto/gcm.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * GCM: Galois/Counter Mode.
34 *
45 * Copyright (c) 2007 Nokia Siemens Networks - Mikko Herranen <mh1@iki.fi>
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published
8
- * by the Free Software Foundation.
96 */
107
118 #include <crypto/gf128mul.h>
....@@ -16,7 +13,6 @@
1613 #include <crypto/scatterwalk.h>
1714 #include <crypto/gcm.h>
1815 #include <crypto/hash.h>
19
-#include "internal.h"
2016 #include <linux/err.h>
2117 #include <linux/init.h>
2218 #include <linux/kernel.h>
....@@ -50,7 +46,7 @@
5046
5147 struct crypto_rfc4543_ctx {
5248 struct crypto_aead *child;
53
- struct crypto_skcipher *null;
49
+ struct crypto_sync_skcipher *null;
5450 u8 nonce[4];
5551 };
5652
....@@ -114,8 +110,6 @@
114110 crypto_skcipher_set_flags(ctr, crypto_aead_get_flags(aead) &
115111 CRYPTO_TFM_REQ_MASK);
116112 err = crypto_skcipher_setkey(ctr, key, keylen);
117
- crypto_aead_set_flags(aead, crypto_skcipher_get_flags(ctr) &
118
- CRYPTO_TFM_RES_MASK);
119113 if (err)
120114 return err;
121115
....@@ -144,31 +138,15 @@
144138 crypto_ahash_set_flags(ghash, crypto_aead_get_flags(aead) &
145139 CRYPTO_TFM_REQ_MASK);
146140 err = crypto_ahash_setkey(ghash, (u8 *)&data->hash, sizeof(be128));
147
- crypto_aead_set_flags(aead, crypto_ahash_get_flags(ghash) &
148
- CRYPTO_TFM_RES_MASK);
149
-
150141 out:
151
- kzfree(data);
142
+ kfree_sensitive(data);
152143 return err;
153144 }
154145
155146 static int crypto_gcm_setauthsize(struct crypto_aead *tfm,
156147 unsigned int authsize)
157148 {
158
- switch (authsize) {
159
- case 4:
160
- case 8:
161
- case 12:
162
- case 13:
163
- case 14:
164
- case 15:
165
- case 16:
166
- break;
167
- default:
168
- return -EINVAL;
169
- }
170
-
171
- return 0;
149
+ return crypto_gcm_check_authsize(authsize);
172150 }
173151
174152 static void crypto_gcm_init_common(struct aead_request *req)
....@@ -247,7 +225,7 @@
247225 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
248226 struct ahash_request *ahreq = &pctx->u.ahreq;
249227 struct crypto_gcm_ghash_ctx *gctx = &pctx->ghash_ctx;
250
- u128 lengths;
228
+ be128 lengths;
251229
252230 lengths.a = cpu_to_be64(req->assoclen * 8);
253231 lengths.b = cpu_to_be64(gctx->cryptlen * 8);
....@@ -600,54 +578,37 @@
600578 const char *ctr_name,
601579 const char *ghash_name)
602580 {
603
- struct crypto_attr_type *algt;
581
+ u32 mask;
604582 struct aead_instance *inst;
605
- struct skcipher_alg *ctr;
606
- struct crypto_alg *ghash_alg;
607
- struct hash_alg_common *ghash;
608583 struct gcm_instance_ctx *ctx;
584
+ struct skcipher_alg *ctr;
585
+ struct hash_alg_common *ghash;
609586 int err;
610587
611
- algt = crypto_get_attr_type(tb);
612
- if (IS_ERR(algt))
613
- return PTR_ERR(algt);
588
+ err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_AEAD, &mask);
589
+ if (err)
590
+ return err;
614591
615
- if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
616
- return -EINVAL;
617
-
618
- ghash_alg = crypto_find_alg(ghash_name, &crypto_ahash_type,
619
- CRYPTO_ALG_TYPE_HASH,
620
- CRYPTO_ALG_TYPE_AHASH_MASK |
621
- crypto_requires_sync(algt->type,
622
- algt->mask));
623
- if (IS_ERR(ghash_alg))
624
- return PTR_ERR(ghash_alg);
625
-
626
- ghash = __crypto_hash_alg_common(ghash_alg);
627
-
628
- err = -ENOMEM;
629592 inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
630593 if (!inst)
631
- goto out_put_ghash;
632
-
594
+ return -ENOMEM;
633595 ctx = aead_instance_ctx(inst);
634
- err = crypto_init_ahash_spawn(&ctx->ghash, ghash,
635
- aead_crypto_instance(inst));
596
+
597
+ err = crypto_grab_ahash(&ctx->ghash, aead_crypto_instance(inst),
598
+ ghash_name, 0, mask);
636599 if (err)
637600 goto err_free_inst;
601
+ ghash = crypto_spawn_ahash_alg(&ctx->ghash);
638602
639603 err = -EINVAL;
640604 if (strcmp(ghash->base.cra_name, "ghash") != 0 ||
641605 ghash->digestsize != 16)
642
- goto err_drop_ghash;
606
+ goto err_free_inst;
643607
644
- crypto_set_skcipher_spawn(&ctx->ctr, aead_crypto_instance(inst));
645
- err = crypto_grab_skcipher(&ctx->ctr, ctr_name, 0,
646
- crypto_requires_sync(algt->type,
647
- algt->mask));
608
+ err = crypto_grab_skcipher(&ctx->ctr, aead_crypto_instance(inst),
609
+ ctr_name, 0, mask);
648610 if (err)
649
- goto err_drop_ghash;
650
-
611
+ goto err_free_inst;
651612 ctr = crypto_spawn_skcipher_alg(&ctx->ctr);
652613
653614 /* The skcipher algorithm must be CTR mode, using 16-byte blocks. */
....@@ -655,21 +616,19 @@
655616 if (strncmp(ctr->base.cra_name, "ctr(", 4) != 0 ||
656617 crypto_skcipher_alg_ivsize(ctr) != 16 ||
657618 ctr->base.cra_blocksize != 1)
658
- goto out_put_ctr;
619
+ goto err_free_inst;
659620
660621 err = -ENAMETOOLONG;
661622 if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
662623 "gcm(%s", ctr->base.cra_name + 4) >= CRYPTO_MAX_ALG_NAME)
663
- goto out_put_ctr;
624
+ goto err_free_inst;
664625
665626 if (snprintf(inst->alg.base.cra_driver_name, CRYPTO_MAX_ALG_NAME,
666627 "gcm_base(%s,%s)", ctr->base.cra_driver_name,
667
- ghash_alg->cra_driver_name) >=
628
+ ghash->base.cra_driver_name) >=
668629 CRYPTO_MAX_ALG_NAME)
669
- goto out_put_ctr;
630
+ goto err_free_inst;
670631
671
- inst->alg.base.cra_flags = (ghash->base.cra_flags |
672
- ctr->base.cra_flags) & CRYPTO_ALG_ASYNC;
673632 inst->alg.base.cra_priority = (ghash->base.cra_priority +
674633 ctr->base.cra_priority) / 2;
675634 inst->alg.base.cra_blocksize = 1;
....@@ -689,20 +648,11 @@
689648 inst->free = crypto_gcm_free;
690649
691650 err = aead_register_instance(tmpl, inst);
692
- if (err)
693
- goto out_put_ctr;
694
-
695
-out_put_ghash:
696
- crypto_mod_put(ghash_alg);
697
- return err;
698
-
699
-out_put_ctr:
700
- crypto_drop_skcipher(&ctx->ctr);
701
-err_drop_ghash:
702
- crypto_drop_ahash(&ctx->ghash);
651
+ if (err) {
703652 err_free_inst:
704
- kfree(inst);
705
- goto out_put_ghash;
653
+ crypto_gcm_free(inst);
654
+ }
655
+ return err;
706656 }
707657
708658 static int crypto_gcm_create(struct crypto_template *tmpl, struct rtattr **tb)
....@@ -721,12 +671,6 @@
721671 return crypto_gcm_create_common(tmpl, tb, ctr_name, "ghash");
722672 }
723673
724
-static struct crypto_template crypto_gcm_tmpl = {
725
- .name = "gcm",
726
- .create = crypto_gcm_create,
727
- .module = THIS_MODULE,
728
-};
729
-
730674 static int crypto_gcm_base_create(struct crypto_template *tmpl,
731675 struct rtattr **tb)
732676 {
....@@ -744,18 +688,11 @@
744688 return crypto_gcm_create_common(tmpl, tb, ctr_name, ghash_name);
745689 }
746690
747
-static struct crypto_template crypto_gcm_base_tmpl = {
748
- .name = "gcm_base",
749
- .create = crypto_gcm_base_create,
750
- .module = THIS_MODULE,
751
-};
752
-
753691 static int crypto_rfc4106_setkey(struct crypto_aead *parent, const u8 *key,
754692 unsigned int keylen)
755693 {
756694 struct crypto_rfc4106_ctx *ctx = crypto_aead_ctx(parent);
757695 struct crypto_aead *child = ctx->child;
758
- int err;
759696
760697 if (keylen < 4)
761698 return -EINVAL;
....@@ -766,26 +703,18 @@
766703 crypto_aead_clear_flags(child, CRYPTO_TFM_REQ_MASK);
767704 crypto_aead_set_flags(child, crypto_aead_get_flags(parent) &
768705 CRYPTO_TFM_REQ_MASK);
769
- err = crypto_aead_setkey(child, key, keylen);
770
- crypto_aead_set_flags(parent, crypto_aead_get_flags(child) &
771
- CRYPTO_TFM_RES_MASK);
772
-
773
- return err;
706
+ return crypto_aead_setkey(child, key, keylen);
774707 }
775708
776709 static int crypto_rfc4106_setauthsize(struct crypto_aead *parent,
777710 unsigned int authsize)
778711 {
779712 struct crypto_rfc4106_ctx *ctx = crypto_aead_ctx(parent);
713
+ int err;
780714
781
- switch (authsize) {
782
- case 8:
783
- case 12:
784
- case 16:
785
- break;
786
- default:
787
- return -EINVAL;
788
- }
715
+ err = crypto_rfc4106_check_authsize(authsize);
716
+ if (err)
717
+ return err;
789718
790719 return crypto_aead_setauthsize(ctx->child, authsize);
791720 }
....@@ -833,8 +762,11 @@
833762
834763 static int crypto_rfc4106_encrypt(struct aead_request *req)
835764 {
836
- if (req->assoclen != 16 && req->assoclen != 20)
837
- return -EINVAL;
765
+ int err;
766
+
767
+ err = crypto_ipsec_check_assoclen(req->assoclen);
768
+ if (err)
769
+ return err;
838770
839771 req = crypto_rfc4106_crypt(req);
840772
....@@ -843,8 +775,11 @@
843775
844776 static int crypto_rfc4106_decrypt(struct aead_request *req)
845777 {
846
- if (req->assoclen != 16 && req->assoclen != 20)
847
- return -EINVAL;
778
+ int err;
779
+
780
+ err = crypto_ipsec_check_assoclen(req->assoclen);
781
+ if (err)
782
+ return err;
848783
849784 req = crypto_rfc4106_crypt(req);
850785
....@@ -892,34 +827,25 @@
892827 static int crypto_rfc4106_create(struct crypto_template *tmpl,
893828 struct rtattr **tb)
894829 {
895
- struct crypto_attr_type *algt;
830
+ u32 mask;
896831 struct aead_instance *inst;
897832 struct crypto_aead_spawn *spawn;
898833 struct aead_alg *alg;
899
- const char *ccm_name;
900834 int err;
901835
902
- algt = crypto_get_attr_type(tb);
903
- if (IS_ERR(algt))
904
- return PTR_ERR(algt);
905
-
906
- if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
907
- return -EINVAL;
908
-
909
- ccm_name = crypto_attr_alg_name(tb[1]);
910
- if (IS_ERR(ccm_name))
911
- return PTR_ERR(ccm_name);
836
+ err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_AEAD, &mask);
837
+ if (err)
838
+ return err;
912839
913840 inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
914841 if (!inst)
915842 return -ENOMEM;
916843
917844 spawn = aead_instance_ctx(inst);
918
- crypto_set_aead_spawn(spawn, aead_crypto_instance(inst));
919
- err = crypto_grab_aead(spawn, ccm_name, 0,
920
- crypto_requires_sync(algt->type, algt->mask));
845
+ err = crypto_grab_aead(spawn, aead_crypto_instance(inst),
846
+ crypto_attr_alg_name(tb[1]), 0, mask);
921847 if (err)
922
- goto out_free_inst;
848
+ goto err_free_inst;
923849
924850 alg = crypto_spawn_aead_alg(spawn);
925851
....@@ -927,11 +853,11 @@
927853
928854 /* Underlying IV size must be 12. */
929855 if (crypto_aead_alg_ivsize(alg) != GCM_AES_IV_SIZE)
930
- goto out_drop_alg;
856
+ goto err_free_inst;
931857
932858 /* Not a stream cipher? */
933859 if (alg->base.cra_blocksize != 1)
934
- goto out_drop_alg;
860
+ goto err_free_inst;
935861
936862 err = -ENAMETOOLONG;
937863 if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
....@@ -940,9 +866,8 @@
940866 snprintf(inst->alg.base.cra_driver_name, CRYPTO_MAX_ALG_NAME,
941867 "rfc4106(%s)", alg->base.cra_driver_name) >=
942868 CRYPTO_MAX_ALG_NAME)
943
- goto out_drop_alg;
869
+ goto err_free_inst;
944870
945
- inst->alg.base.cra_flags = alg->base.cra_flags & CRYPTO_ALG_ASYNC;
946871 inst->alg.base.cra_priority = alg->base.cra_priority;
947872 inst->alg.base.cra_blocksize = 1;
948873 inst->alg.base.cra_alignmask = alg->base.cra_alignmask;
....@@ -964,31 +889,18 @@
964889 inst->free = crypto_rfc4106_free;
965890
966891 err = aead_register_instance(tmpl, inst);
967
- if (err)
968
- goto out_drop_alg;
969
-
970
-out:
892
+ if (err) {
893
+err_free_inst:
894
+ crypto_rfc4106_free(inst);
895
+ }
971896 return err;
972
-
973
-out_drop_alg:
974
- crypto_drop_aead(spawn);
975
-out_free_inst:
976
- kfree(inst);
977
- goto out;
978897 }
979
-
980
-static struct crypto_template crypto_rfc4106_tmpl = {
981
- .name = "rfc4106",
982
- .create = crypto_rfc4106_create,
983
- .module = THIS_MODULE,
984
-};
985898
986899 static int crypto_rfc4543_setkey(struct crypto_aead *parent, const u8 *key,
987900 unsigned int keylen)
988901 {
989902 struct crypto_rfc4543_ctx *ctx = crypto_aead_ctx(parent);
990903 struct crypto_aead *child = ctx->child;
991
- int err;
992904
993905 if (keylen < 4)
994906 return -EINVAL;
....@@ -999,11 +911,7 @@
999911 crypto_aead_clear_flags(child, CRYPTO_TFM_REQ_MASK);
1000912 crypto_aead_set_flags(child, crypto_aead_get_flags(parent) &
1001913 CRYPTO_TFM_REQ_MASK);
1002
- err = crypto_aead_setkey(child, key, keylen);
1003
- crypto_aead_set_flags(parent, crypto_aead_get_flags(child) &
1004
- CRYPTO_TFM_RES_MASK);
1005
-
1006
- return err;
914
+ return crypto_aead_setkey(child, key, keylen);
1007915 }
1008916
1009917 static int crypto_rfc4543_setauthsize(struct crypto_aead *parent,
....@@ -1055,9 +963,9 @@
1055963 unsigned int authsize = crypto_aead_authsize(aead);
1056964 unsigned int nbytes = req->assoclen + req->cryptlen -
1057965 (enc ? 0 : authsize);
1058
- SKCIPHER_REQUEST_ON_STACK(nreq, ctx->null);
966
+ SYNC_SKCIPHER_REQUEST_ON_STACK(nreq, ctx->null);
1059967
1060
- skcipher_request_set_tfm(nreq, ctx->null);
968
+ skcipher_request_set_sync_tfm(nreq, ctx->null);
1061969 skcipher_request_set_callback(nreq, req->base.flags, NULL, NULL);
1062970 skcipher_request_set_crypt(nreq, req->src, req->dst, nbytes, NULL);
1063971
....@@ -1066,12 +974,14 @@
1066974
1067975 static int crypto_rfc4543_encrypt(struct aead_request *req)
1068976 {
1069
- return crypto_rfc4543_crypt(req, true);
977
+ return crypto_ipsec_check_assoclen(req->assoclen) ?:
978
+ crypto_rfc4543_crypt(req, true);
1070979 }
1071980
1072981 static int crypto_rfc4543_decrypt(struct aead_request *req)
1073982 {
1074
- return crypto_rfc4543_crypt(req, false);
983
+ return crypto_ipsec_check_assoclen(req->assoclen) ?:
984
+ crypto_rfc4543_crypt(req, false);
1075985 }
1076986
1077987 static int crypto_rfc4543_init_tfm(struct crypto_aead *tfm)
....@@ -1081,7 +991,7 @@
1081991 struct crypto_aead_spawn *spawn = &ictx->aead;
1082992 struct crypto_rfc4543_ctx *ctx = crypto_aead_ctx(tfm);
1083993 struct crypto_aead *aead;
1084
- struct crypto_skcipher *null;
994
+ struct crypto_sync_skcipher *null;
1085995 unsigned long align;
1086996 int err = 0;
1087997
....@@ -1132,48 +1042,37 @@
11321042 static int crypto_rfc4543_create(struct crypto_template *tmpl,
11331043 struct rtattr **tb)
11341044 {
1135
- struct crypto_attr_type *algt;
1045
+ u32 mask;
11361046 struct aead_instance *inst;
1137
- struct crypto_aead_spawn *spawn;
11381047 struct aead_alg *alg;
11391048 struct crypto_rfc4543_instance_ctx *ctx;
1140
- const char *ccm_name;
11411049 int err;
11421050
1143
- algt = crypto_get_attr_type(tb);
1144
- if (IS_ERR(algt))
1145
- return PTR_ERR(algt);
1146
-
1147
- if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
1148
- return -EINVAL;
1149
-
1150
- ccm_name = crypto_attr_alg_name(tb[1]);
1151
- if (IS_ERR(ccm_name))
1152
- return PTR_ERR(ccm_name);
1051
+ err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_AEAD, &mask);
1052
+ if (err)
1053
+ return err;
11531054
11541055 inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
11551056 if (!inst)
11561057 return -ENOMEM;
11571058
11581059 ctx = aead_instance_ctx(inst);
1159
- spawn = &ctx->aead;
1160
- crypto_set_aead_spawn(spawn, aead_crypto_instance(inst));
1161
- err = crypto_grab_aead(spawn, ccm_name, 0,
1162
- crypto_requires_sync(algt->type, algt->mask));
1060
+ err = crypto_grab_aead(&ctx->aead, aead_crypto_instance(inst),
1061
+ crypto_attr_alg_name(tb[1]), 0, mask);
11631062 if (err)
1164
- goto out_free_inst;
1063
+ goto err_free_inst;
11651064
1166
- alg = crypto_spawn_aead_alg(spawn);
1065
+ alg = crypto_spawn_aead_alg(&ctx->aead);
11671066
11681067 err = -EINVAL;
11691068
11701069 /* Underlying IV size must be 12. */
11711070 if (crypto_aead_alg_ivsize(alg) != GCM_AES_IV_SIZE)
1172
- goto out_drop_alg;
1071
+ goto err_free_inst;
11731072
11741073 /* Not a stream cipher? */
11751074 if (alg->base.cra_blocksize != 1)
1176
- goto out_drop_alg;
1075
+ goto err_free_inst;
11771076
11781077 err = -ENAMETOOLONG;
11791078 if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
....@@ -1182,9 +1081,8 @@
11821081 snprintf(inst->alg.base.cra_driver_name, CRYPTO_MAX_ALG_NAME,
11831082 "rfc4543(%s)", alg->base.cra_driver_name) >=
11841083 CRYPTO_MAX_ALG_NAME)
1185
- goto out_drop_alg;
1084
+ goto err_free_inst;
11861085
1187
- inst->alg.base.cra_flags = alg->base.cra_flags & CRYPTO_ALG_ASYNC;
11881086 inst->alg.base.cra_priority = alg->base.cra_priority;
11891087 inst->alg.base.cra_blocksize = 1;
11901088 inst->alg.base.cra_alignmask = alg->base.cra_alignmask;
....@@ -1203,26 +1101,34 @@
12031101 inst->alg.encrypt = crypto_rfc4543_encrypt;
12041102 inst->alg.decrypt = crypto_rfc4543_decrypt;
12051103
1206
- inst->free = crypto_rfc4543_free,
1104
+ inst->free = crypto_rfc4543_free;
12071105
12081106 err = aead_register_instance(tmpl, inst);
1209
- if (err)
1210
- goto out_drop_alg;
1211
-
1212
-out:
1107
+ if (err) {
1108
+err_free_inst:
1109
+ crypto_rfc4543_free(inst);
1110
+ }
12131111 return err;
1214
-
1215
-out_drop_alg:
1216
- crypto_drop_aead(spawn);
1217
-out_free_inst:
1218
- kfree(inst);
1219
- goto out;
12201112 }
12211113
1222
-static struct crypto_template crypto_rfc4543_tmpl = {
1223
- .name = "rfc4543",
1224
- .create = crypto_rfc4543_create,
1225
- .module = THIS_MODULE,
1114
+static struct crypto_template crypto_gcm_tmpls[] = {
1115
+ {
1116
+ .name = "gcm_base",
1117
+ .create = crypto_gcm_base_create,
1118
+ .module = THIS_MODULE,
1119
+ }, {
1120
+ .name = "gcm",
1121
+ .create = crypto_gcm_create,
1122
+ .module = THIS_MODULE,
1123
+ }, {
1124
+ .name = "rfc4106",
1125
+ .create = crypto_rfc4106_create,
1126
+ .module = THIS_MODULE,
1127
+ }, {
1128
+ .name = "rfc4543",
1129
+ .create = crypto_rfc4543_create,
1130
+ .module = THIS_MODULE,
1131
+ },
12261132 };
12271133
12281134 static int __init crypto_gcm_module_init(void)
....@@ -1235,45 +1141,22 @@
12351141
12361142 sg_init_one(&gcm_zeroes->sg, gcm_zeroes->buf, sizeof(gcm_zeroes->buf));
12371143
1238
- err = crypto_register_template(&crypto_gcm_base_tmpl);
1144
+ err = crypto_register_templates(crypto_gcm_tmpls,
1145
+ ARRAY_SIZE(crypto_gcm_tmpls));
12391146 if (err)
1240
- goto out;
1147
+ kfree(gcm_zeroes);
12411148
1242
- err = crypto_register_template(&crypto_gcm_tmpl);
1243
- if (err)
1244
- goto out_undo_base;
1245
-
1246
- err = crypto_register_template(&crypto_rfc4106_tmpl);
1247
- if (err)
1248
- goto out_undo_gcm;
1249
-
1250
- err = crypto_register_template(&crypto_rfc4543_tmpl);
1251
- if (err)
1252
- goto out_undo_rfc4106;
1253
-
1254
- return 0;
1255
-
1256
-out_undo_rfc4106:
1257
- crypto_unregister_template(&crypto_rfc4106_tmpl);
1258
-out_undo_gcm:
1259
- crypto_unregister_template(&crypto_gcm_tmpl);
1260
-out_undo_base:
1261
- crypto_unregister_template(&crypto_gcm_base_tmpl);
1262
-out:
1263
- kfree(gcm_zeroes);
12641149 return err;
12651150 }
12661151
12671152 static void __exit crypto_gcm_module_exit(void)
12681153 {
12691154 kfree(gcm_zeroes);
1270
- crypto_unregister_template(&crypto_rfc4543_tmpl);
1271
- crypto_unregister_template(&crypto_rfc4106_tmpl);
1272
- crypto_unregister_template(&crypto_gcm_tmpl);
1273
- crypto_unregister_template(&crypto_gcm_base_tmpl);
1155
+ crypto_unregister_templates(crypto_gcm_tmpls,
1156
+ ARRAY_SIZE(crypto_gcm_tmpls));
12741157 }
12751158
1276
-module_init(crypto_gcm_module_init);
1159
+subsys_initcall(crypto_gcm_module_init);
12771160 module_exit(crypto_gcm_module_exit);
12781161
12791162 MODULE_LICENSE("GPL");