hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/crypto/qat/qat_common/qat_asym_algs.c
....@@ -1,50 +1,5 @@
1
-/*
2
- This file is provided under a dual BSD/GPLv2 license. When using or
3
- redistributing this file, you may do so under either license.
4
-
5
- GPL LICENSE SUMMARY
6
- Copyright(c) 2014 Intel Corporation.
7
- This program is free software; you can redistribute it and/or modify
8
- it under the terms of version 2 of the GNU General Public License as
9
- published by the Free Software Foundation.
10
-
11
- This program is distributed in the hope that it will be useful, but
12
- WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- General Public License for more details.
15
-
16
- Contact Information:
17
- qat-linux@intel.com
18
-
19
- BSD LICENSE
20
- Copyright(c) 2014 Intel Corporation.
21
- Redistribution and use in source and binary forms, with or without
22
- modification, are permitted provided that the following conditions
23
- are met:
24
-
25
- * Redistributions of source code must retain the above copyright
26
- notice, this list of conditions and the following disclaimer.
27
- * Redistributions in binary form must reproduce the above copyright
28
- notice, this list of conditions and the following disclaimer in
29
- the documentation and/or other materials provided with the
30
- distribution.
31
- * Neither the name of Intel Corporation nor the names of its
32
- contributors may be used to endorse or promote products derived
33
- from this software without specific prior written permission.
34
-
35
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
-*/
47
-
1
+// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only)
2
+/* Copyright(c) 2014 - 2020 Intel Corporation */
483 #include <linux/module.h>
494 #include <crypto/internal/rsa.h>
505 #include <crypto/internal/akcipher.h>
....@@ -332,10 +287,10 @@
332287 } else {
333288 int shift = ctx->p_size - req->src_len;
334289
335
- qat_req->src_align = dma_zalloc_coherent(dev,
336
- ctx->p_size,
337
- &qat_req->in.dh.in.b,
338
- GFP_KERNEL);
290
+ qat_req->src_align = dma_alloc_coherent(dev,
291
+ ctx->p_size,
292
+ &qat_req->in.dh.in.b,
293
+ GFP_KERNEL);
339294 if (unlikely(!qat_req->src_align))
340295 return ret;
341296
....@@ -360,9 +315,9 @@
360315 goto unmap_src;
361316
362317 } else {
363
- qat_req->dst_align = dma_zalloc_coherent(dev, ctx->p_size,
364
- &qat_req->out.dh.r,
365
- GFP_KERNEL);
318
+ qat_req->dst_align = dma_alloc_coherent(dev, ctx->p_size,
319
+ &qat_req->out.dh.r,
320
+ GFP_KERNEL);
366321 if (unlikely(!qat_req->dst_align))
367322 goto unmap_src;
368323 }
....@@ -384,12 +339,12 @@
384339
385340 msg->pke_mid.src_data_addr = qat_req->phy_in;
386341 msg->pke_mid.dest_data_addr = qat_req->phy_out;
387
- msg->pke_mid.opaque = (uint64_t)(__force long)qat_req;
342
+ msg->pke_mid.opaque = (u64)(__force long)qat_req;
388343 msg->input_param_count = n_input_params;
389344 msg->output_param_count = 1;
390345
391346 do {
392
- ret = adf_send_message(ctx->inst->pke_tx, (uint32_t *)msg);
347
+ ret = adf_send_message(ctx->inst->pke_tx, (u32 *)msg);
393348 } while (ret == -EBUSY && ctr++ < 100);
394349
395350 if (!ret)
....@@ -447,7 +402,7 @@
447402 return -EINVAL;
448403
449404 ctx->p_size = params->p_size;
450
- ctx->p = dma_zalloc_coherent(dev, ctx->p_size, &ctx->dma_p, GFP_KERNEL);
405
+ ctx->p = dma_alloc_coherent(dev, ctx->p_size, &ctx->dma_p, GFP_KERNEL);
451406 if (!ctx->p)
452407 return -ENOMEM;
453408 memcpy(ctx->p, params->p, ctx->p_size);
....@@ -458,7 +413,7 @@
458413 return 0;
459414 }
460415
461
- ctx->g = dma_zalloc_coherent(dev, ctx->p_size, &ctx->dma_g, GFP_KERNEL);
416
+ ctx->g = dma_alloc_coherent(dev, ctx->p_size, &ctx->dma_g, GFP_KERNEL);
462417 if (!ctx->g)
463418 return -ENOMEM;
464419 memcpy(ctx->g + (ctx->p_size - params->g_size), params->g,
....@@ -503,8 +458,8 @@
503458 if (ret < 0)
504459 goto err_clear_ctx;
505460
506
- ctx->xa = dma_zalloc_coherent(dev, ctx->p_size, &ctx->dma_xa,
507
- GFP_KERNEL);
461
+ ctx->xa = dma_alloc_coherent(dev, ctx->p_size, &ctx->dma_xa,
462
+ GFP_KERNEL);
508463 if (!ctx->xa) {
509464 ret = -ENOMEM;
510465 goto err_clear_ctx;
....@@ -737,9 +692,9 @@
737692 } else {
738693 int shift = ctx->key_sz - req->src_len;
739694
740
- qat_req->src_align = dma_zalloc_coherent(dev, ctx->key_sz,
741
- &qat_req->in.rsa.enc.m,
742
- GFP_KERNEL);
695
+ qat_req->src_align = dma_alloc_coherent(dev, ctx->key_sz,
696
+ &qat_req->in.rsa.enc.m,
697
+ GFP_KERNEL);
743698 if (unlikely(!qat_req->src_align))
744699 return ret;
745700
....@@ -756,9 +711,9 @@
756711 goto unmap_src;
757712
758713 } else {
759
- qat_req->dst_align = dma_zalloc_coherent(dev, ctx->key_sz,
760
- &qat_req->out.rsa.enc.c,
761
- GFP_KERNEL);
714
+ qat_req->dst_align = dma_alloc_coherent(dev, ctx->key_sz,
715
+ &qat_req->out.rsa.enc.c,
716
+ GFP_KERNEL);
762717 if (unlikely(!qat_req->dst_align))
763718 goto unmap_src;
764719
....@@ -779,11 +734,11 @@
779734
780735 msg->pke_mid.src_data_addr = qat_req->phy_in;
781736 msg->pke_mid.dest_data_addr = qat_req->phy_out;
782
- msg->pke_mid.opaque = (uint64_t)(__force long)qat_req;
737
+ msg->pke_mid.opaque = (u64)(__force long)qat_req;
783738 msg->input_param_count = 3;
784739 msg->output_param_count = 1;
785740 do {
786
- ret = adf_send_message(ctx->inst->pke_tx, (uint32_t *)msg);
741
+ ret = adf_send_message(ctx->inst->pke_tx, (u32 *)msg);
787742 } while (ret == -EBUSY && ctr++ < 100);
788743
789744 if (!ret)
....@@ -881,9 +836,9 @@
881836 } else {
882837 int shift = ctx->key_sz - req->src_len;
883838
884
- qat_req->src_align = dma_zalloc_coherent(dev, ctx->key_sz,
885
- &qat_req->in.rsa.dec.c,
886
- GFP_KERNEL);
839
+ qat_req->src_align = dma_alloc_coherent(dev, ctx->key_sz,
840
+ &qat_req->in.rsa.dec.c,
841
+ GFP_KERNEL);
887842 if (unlikely(!qat_req->src_align))
888843 return ret;
889844
....@@ -900,9 +855,9 @@
900855 goto unmap_src;
901856
902857 } else {
903
- qat_req->dst_align = dma_zalloc_coherent(dev, ctx->key_sz,
904
- &qat_req->out.rsa.dec.m,
905
- GFP_KERNEL);
858
+ qat_req->dst_align = dma_alloc_coherent(dev, ctx->key_sz,
859
+ &qat_req->out.rsa.dec.m,
860
+ GFP_KERNEL);
906861 if (unlikely(!qat_req->dst_align))
907862 goto unmap_src;
908863
....@@ -927,7 +882,7 @@
927882
928883 msg->pke_mid.src_data_addr = qat_req->phy_in;
929884 msg->pke_mid.dest_data_addr = qat_req->phy_out;
930
- msg->pke_mid.opaque = (uint64_t)(__force long)qat_req;
885
+ msg->pke_mid.opaque = (u64)(__force long)qat_req;
931886 if (ctx->crt_mode)
932887 msg->input_param_count = 6;
933888 else
....@@ -935,7 +890,7 @@
935890
936891 msg->output_param_count = 1;
937892 do {
938
- ret = adf_send_message(ctx->inst->pke_tx, (uint32_t *)msg);
893
+ ret = adf_send_message(ctx->inst->pke_tx, (u32 *)msg);
939894 } while (ret == -EBUSY && ctr++ < 100);
940895
941896 if (!ret)
....@@ -989,7 +944,7 @@
989944 goto err;
990945
991946 ret = -ENOMEM;
992
- ctx->n = dma_zalloc_coherent(dev, ctx->key_sz, &ctx->dma_n, GFP_KERNEL);
947
+ ctx->n = dma_alloc_coherent(dev, ctx->key_sz, &ctx->dma_n, GFP_KERNEL);
993948 if (!ctx->n)
994949 goto err;
995950
....@@ -1018,7 +973,7 @@
1018973 return -EINVAL;
1019974 }
1020975
1021
- ctx->e = dma_zalloc_coherent(dev, ctx->key_sz, &ctx->dma_e, GFP_KERNEL);
976
+ ctx->e = dma_alloc_coherent(dev, ctx->key_sz, &ctx->dma_e, GFP_KERNEL);
1022977 if (!ctx->e)
1023978 return -ENOMEM;
1024979
....@@ -1044,7 +999,7 @@
1044999 goto err;
10451000
10461001 ret = -ENOMEM;
1047
- ctx->d = dma_zalloc_coherent(dev, ctx->key_sz, &ctx->dma_d, GFP_KERNEL);
1002
+ ctx->d = dma_alloc_coherent(dev, ctx->key_sz, &ctx->dma_d, GFP_KERNEL);
10481003 if (!ctx->d)
10491004 goto err;
10501005
....@@ -1077,7 +1032,7 @@
10771032 qat_rsa_drop_leading_zeros(&ptr, &len);
10781033 if (!len)
10791034 goto err;
1080
- ctx->p = dma_zalloc_coherent(dev, half_key_sz, &ctx->dma_p, GFP_KERNEL);
1035
+ ctx->p = dma_alloc_coherent(dev, half_key_sz, &ctx->dma_p, GFP_KERNEL);
10811036 if (!ctx->p)
10821037 goto err;
10831038 memcpy(ctx->p + (half_key_sz - len), ptr, len);
....@@ -1088,7 +1043,7 @@
10881043 qat_rsa_drop_leading_zeros(&ptr, &len);
10891044 if (!len)
10901045 goto free_p;
1091
- ctx->q = dma_zalloc_coherent(dev, half_key_sz, &ctx->dma_q, GFP_KERNEL);
1046
+ ctx->q = dma_alloc_coherent(dev, half_key_sz, &ctx->dma_q, GFP_KERNEL);
10921047 if (!ctx->q)
10931048 goto free_p;
10941049 memcpy(ctx->q + (half_key_sz - len), ptr, len);
....@@ -1099,8 +1054,8 @@
10991054 qat_rsa_drop_leading_zeros(&ptr, &len);
11001055 if (!len)
11011056 goto free_q;
1102
- ctx->dp = dma_zalloc_coherent(dev, half_key_sz, &ctx->dma_dp,
1103
- GFP_KERNEL);
1057
+ ctx->dp = dma_alloc_coherent(dev, half_key_sz, &ctx->dma_dp,
1058
+ GFP_KERNEL);
11041059 if (!ctx->dp)
11051060 goto free_q;
11061061 memcpy(ctx->dp + (half_key_sz - len), ptr, len);
....@@ -1111,8 +1066,8 @@
11111066 qat_rsa_drop_leading_zeros(&ptr, &len);
11121067 if (!len)
11131068 goto free_dp;
1114
- ctx->dq = dma_zalloc_coherent(dev, half_key_sz, &ctx->dma_dq,
1115
- GFP_KERNEL);
1069
+ ctx->dq = dma_alloc_coherent(dev, half_key_sz, &ctx->dma_dq,
1070
+ GFP_KERNEL);
11161071 if (!ctx->dq)
11171072 goto free_dp;
11181073 memcpy(ctx->dq + (half_key_sz - len), ptr, len);
....@@ -1123,8 +1078,8 @@
11231078 qat_rsa_drop_leading_zeros(&ptr, &len);
11241079 if (!len)
11251080 goto free_dq;
1126
- ctx->qinv = dma_zalloc_coherent(dev, half_key_sz, &ctx->dma_qinv,
1127
- GFP_KERNEL);
1081
+ ctx->qinv = dma_alloc_coherent(dev, half_key_sz, &ctx->dma_qinv,
1082
+ GFP_KERNEL);
11281083 if (!ctx->qinv)
11291084 goto free_dq;
11301085 memcpy(ctx->qinv + (half_key_sz - len), ptr, len);
....@@ -1300,8 +1255,6 @@
13001255 static struct akcipher_alg rsa = {
13011256 .encrypt = qat_rsa_enc,
13021257 .decrypt = qat_rsa_dec,
1303
- .sign = qat_rsa_dec,
1304
- .verify = qat_rsa_enc,
13051258 .set_pub_key = qat_rsa_setpubkey,
13061259 .set_priv_key = qat_rsa_setprivkey,
13071260 .max_size = qat_rsa_max_size,