hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/crypto/bcm/util.c
....@@ -1,17 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2016 Broadcom
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License, version 2, as
6
- * published by the Free Software Foundation (the "GPL").
7
- *
8
- * This program is distributed in the hope that it will be useful, but
9
- * WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- * General Public License version 2 (GPLv2) for more details.
12
- *
13
- * You should have received a copy of the GNU General Public License
14
- * version 2 (GPLv2) along with this source code.
154 */
165
176 #include <linux/debugfs.h>
....@@ -201,46 +190,6 @@
201190 char ctx[];
202191 };
203192
204
-/* do a synchronous decrypt operation */
205
-int do_decrypt(char *alg_name,
206
- void *key_ptr, unsigned int key_len,
207
- void *iv_ptr, void *src_ptr, void *dst_ptr,
208
- unsigned int block_len)
209
-{
210
- struct scatterlist sg_in[1], sg_out[1];
211
- struct crypto_blkcipher *tfm =
212
- crypto_alloc_blkcipher(alg_name, 0, CRYPTO_ALG_ASYNC);
213
- struct blkcipher_desc desc = {.tfm = tfm, .flags = 0 };
214
- int ret = 0;
215
- void *iv;
216
- int ivsize;
217
-
218
- flow_log("%s() name:%s block_len:%u\n", __func__, alg_name, block_len);
219
-
220
- if (IS_ERR(tfm))
221
- return PTR_ERR(tfm);
222
-
223
- crypto_blkcipher_setkey((void *)tfm, key_ptr, key_len);
224
-
225
- sg_init_table(sg_in, 1);
226
- sg_set_buf(sg_in, src_ptr, block_len);
227
-
228
- sg_init_table(sg_out, 1);
229
- sg_set_buf(sg_out, dst_ptr, block_len);
230
-
231
- iv = crypto_blkcipher_crt(tfm)->iv;
232
- ivsize = crypto_blkcipher_ivsize(tfm);
233
- memcpy(iv, iv_ptr, ivsize);
234
-
235
- ret = crypto_blkcipher_decrypt(&desc, sg_out, sg_in, block_len);
236
- crypto_free_blkcipher(tfm);
237
-
238
- if (ret < 0)
239
- pr_err("aes_decrypt failed %d\n", ret);
240
-
241
- return ret;
242
-}
243
-
244193 /**
245194 * do_shash() - Do a synchronous hash operation in software
246195 * @name: The name of the hash algorithm
....@@ -282,7 +231,6 @@
282231 goto do_shash_err;
283232 }
284233 sdesc->shash.tfm = hash;
285
- sdesc->shash.flags = 0x0;
286234
287235 if (key_len > 0) {
288236 rc = crypto_shash_setkey(hash, key, key_len);
....@@ -418,88 +366,88 @@
418366
419367 ipriv = filp->private_data;
420368 out_offset = 0;
421
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
369
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
422370 "Number of SPUs.........%u\n",
423371 ipriv->spu.num_spu);
424
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
372
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
425373 "Current sessions.......%u\n",
426374 atomic_read(&ipriv->session_count));
427
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
375
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
428376 "Session count..........%u\n",
429377 atomic_read(&ipriv->stream_count));
430
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
378
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
431379 "Cipher setkey..........%u\n",
432380 atomic_read(&ipriv->setkey_cnt[SPU_OP_CIPHER]));
433
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
381
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
434382 "Cipher Ops.............%u\n",
435383 atomic_read(&ipriv->op_counts[SPU_OP_CIPHER]));
436384 for (alg = 0; alg < CIPHER_ALG_LAST; alg++) {
437385 for (mode = 0; mode < CIPHER_MODE_LAST; mode++) {
438386 op_cnt = atomic_read(&ipriv->cipher_cnt[alg][mode]);
439387 if (op_cnt) {
440
- out_offset += snprintf(buf + out_offset,
388
+ out_offset += scnprintf(buf + out_offset,
441389 out_count - out_offset,
442390 " %-13s%11u\n",
443391 spu_alg_name(alg, mode), op_cnt);
444392 }
445393 }
446394 }
447
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
395
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
448396 "Hash Ops...............%u\n",
449397 atomic_read(&ipriv->op_counts[SPU_OP_HASH]));
450398 for (alg = 0; alg < HASH_ALG_LAST; alg++) {
451399 op_cnt = atomic_read(&ipriv->hash_cnt[alg]);
452400 if (op_cnt) {
453
- out_offset += snprintf(buf + out_offset,
401
+ out_offset += scnprintf(buf + out_offset,
454402 out_count - out_offset,
455403 " %-13s%11u\n",
456404 hash_alg_name[alg], op_cnt);
457405 }
458406 }
459
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
407
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
460408 "HMAC setkey............%u\n",
461409 atomic_read(&ipriv->setkey_cnt[SPU_OP_HMAC]));
462
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
410
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
463411 "HMAC Ops...............%u\n",
464412 atomic_read(&ipriv->op_counts[SPU_OP_HMAC]));
465413 for (alg = 0; alg < HASH_ALG_LAST; alg++) {
466414 op_cnt = atomic_read(&ipriv->hmac_cnt[alg]);
467415 if (op_cnt) {
468
- out_offset += snprintf(buf + out_offset,
416
+ out_offset += scnprintf(buf + out_offset,
469417 out_count - out_offset,
470418 " %-13s%11u\n",
471419 hash_alg_name[alg], op_cnt);
472420 }
473421 }
474
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
422
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
475423 "AEAD setkey............%u\n",
476424 atomic_read(&ipriv->setkey_cnt[SPU_OP_AEAD]));
477425
478
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
426
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
479427 "AEAD Ops...............%u\n",
480428 atomic_read(&ipriv->op_counts[SPU_OP_AEAD]));
481429 for (alg = 0; alg < AEAD_TYPE_LAST; alg++) {
482430 op_cnt = atomic_read(&ipriv->aead_cnt[alg]);
483431 if (op_cnt) {
484
- out_offset += snprintf(buf + out_offset,
432
+ out_offset += scnprintf(buf + out_offset,
485433 out_count - out_offset,
486434 " %-13s%11u\n",
487435 aead_alg_name[alg], op_cnt);
488436 }
489437 }
490
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
438
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
491439 "Bytes of req data......%llu\n",
492440 (u64)atomic64_read(&ipriv->bytes_out));
493
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
441
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
494442 "Bytes of resp data.....%llu\n",
495443 (u64)atomic64_read(&ipriv->bytes_in));
496
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
444
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
497445 "Mailbox full...........%u\n",
498446 atomic_read(&ipriv->mb_no_spc));
499
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
447
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
500448 "Mailbox send failures..%u\n",
501449 atomic_read(&ipriv->mb_send_fail));
502
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
450
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
503451 "Check ICV errors.......%u\n",
504452 atomic_read(&ipriv->bad_icv));
505453 if (ipriv->spu.spu_type == SPU_TYPE_SPUM)
....@@ -507,7 +455,7 @@
507455 spu_ofifo_ctrl = ioread32(ipriv->spu.reg_vbase[i] +
508456 SPU_OFIFO_CTRL);
509457 fifo_len = spu_ofifo_ctrl & SPU_FIFO_WATERMARK;
510
- out_offset += snprintf(buf + out_offset,
458
+ out_offset += scnprintf(buf + out_offset,
511459 out_count - out_offset,
512460 "SPU %d output FIFO high water.....%u\n",
513461 i, fifo_len);