Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci/qat qat(4): Simplify iv generation logic with cp...
details: https://anonhg.NetBSD.org/src/rev/da13abb82528
branches: trunk
changeset: 972978:da13abb82528
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Jun 14 23:23:12 2020 +0000
description:
qat(4): Simplify iv generation logic with cprng_fast.
diffstat:
sys/dev/pci/qat/qat.c | 17 +++--------------
1 files changed, 3 insertions(+), 14 deletions(-)
diffs (44 lines):
diff -r a70df3d71927 -r da13abb82528 sys/dev/pci/qat/qat.c
--- a/sys/dev/pci/qat/qat.c Sun Jun 14 23:22:09 2020 +0000
+++ b/sys/dev/pci/qat/qat.c Sun Jun 14 23:23:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: qat.c,v 1.5 2020/03/05 15:33:13 msaitoh Exp $ */
+/* $NetBSD: qat.c,v 1.6 2020/06/14 23:23:12 riastradh Exp $ */
/*
* Copyright (c) 2019 Internet Initiative Japan, Inc.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: qat.c,v 1.5 2020/03/05 15:33:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: qat.c,v 1.6 2020/06/14 23:23:12 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1577,24 +1577,13 @@
qat_crypto_load_iv(struct qat_sym_cookie *qsc, struct cryptop *crp,
struct cryptodesc *crde, struct qat_crypto_desc const *desc)
{
- uint32_t rand;
uint32_t ivlen = desc->qcd_cipher_blk_sz;
- int i;
if (crde->crd_flags & CRD_F_IV_EXPLICIT) {
memcpy(qsc->qsc_iv_buf, crde->crd_iv, ivlen);
} else {
if (crde->crd_flags & CRD_F_ENCRYPT) {
- for (i = 0; i + sizeof(rand) <= ivlen;
- i += sizeof(rand)) {
- rand = cprng_fast32();
- memcpy(qsc->qsc_iv_buf + i, &rand, sizeof(rand));
- }
- if (sizeof(qsc->qsc_iv_buf) % sizeof(rand) != 0) {
- rand = cprng_fast32();
- memcpy(qsc->qsc_iv_buf + i, &rand,
- sizeof(qsc->qsc_iv_buf) - i);
- }
+ cprng_fast(qsc->qsc_iv_buf, ivlen);
} else if (crp->crp_flags & CRYPTO_F_IMBUF) {
/* get iv from buf */
m_copydata(qsc->qsc_buf, crde->crd_inject, ivlen,
Home |
Main Index |
Thread Index |
Old Index