From nobody Thu Oct 21 17:07:05 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 36FF31806EDA; Thu, 21 Oct 2021 17:07:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HZv6M190Cz4hLK; Thu, 21 Oct 2021 17:07:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E9F8F1EF2D; Thu, 21 Oct 2021 17:07:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19LH754M080399; Thu, 21 Oct 2021 17:07:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH75Ha080398; Thu, 21 Oct 2021 17:07:05 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:05 GMT Message-Id: <202110211707.19LH75Ha080398@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 11db133ecad7 - stable/13 - cryptodev: Use 'csp' in the handlers for requests. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 11db133ecad7930dd4f289815e2a1b531390f124 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=11db133ecad7930dd4f289815e2a1b531390f124 commit 11db133ecad7930dd4f289815e2a1b531390f124 Author: John Baldwin AuthorDate: 2021-10-06 21:08:46 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:25 +0000 cryptodev: Use 'csp' in the handlers for requests. - Retire cse->mode and use csp->csp_mode instead. - Use csp->csp_cipher_algorithm instead of the ivsize when checking for the fixup for the IV length for AES-XTS. Reviewed by: markj Sponsored by: Chelsio Communications, The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32103 (cherry picked from commit b4e0a27c5be5090a9db16dd0ad417543b1fb0c4a) --- sys/opencrypto/cryptodev.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 81c6dcd01e2a..9f581e68fe92 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -3,13 +3,16 @@ /*- * Copyright (c) 2001 Theo de Raadt * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2014-2021 The FreeBSD Foundation * All rights reserved. * * Portions of this software were developed by John-Mark Gurney * under sponsorship of the FreeBSD Foundation and * Rubicon Communications, LLC (Netgate). * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -325,7 +328,6 @@ struct csession { struct enc_xform *txform; int hashsize; int ivsize; - int mode; void *key; void *mackey; @@ -679,7 +681,6 @@ cse_create(struct fcrypt *fcr, struct session2_op *sop) refcount_init(&cse->refs, 1); cse->key = key; cse->mackey = mackey; - cse->mode = csp.csp_mode; cse->cses = cses; cse->txform = txform; if (thash != NULL) @@ -808,6 +809,7 @@ cryptodev_cb(struct cryptop *crp) static int cryptodev_op(struct csession *cse, const struct crypt_op *cop) { + const struct crypto_session_params *csp; struct cryptop_data *cod = NULL; struct cryptop *crp = NULL; char *dst; @@ -857,7 +859,8 @@ cryptodev_op(struct csession *cse, const struct crypt_op *cop) if (cse->hashsize) crp->crp_digest_start = cop->len; - switch (cse->mode) { + csp = crypto_get_params(cse->cses); + switch (csp->csp_mode) { case CSP_MODE_COMPRESS: switch (cop->op) { case COP_ENCRYPT: @@ -1023,6 +1026,7 @@ bail: static int cryptodev_aead(struct csession *cse, struct crypt_aead *caead) { + const struct crypto_session_params *csp; struct cryptop_data *cod = NULL; struct cryptop *crp = NULL; char *dst; @@ -1085,7 +1089,8 @@ cryptodev_aead(struct csession *cse, struct crypt_aead *caead) else crp->crp_digest_start = crp->crp_payload_start + caead->len; - switch (cse->mode) { + csp = crypto_get_params(cse->cses); + switch (csp->csp_mode) { case CSP_MODE_AEAD: case CSP_MODE_ETA: switch (caead->op) { @@ -1123,9 +1128,9 @@ cryptodev_aead(struct csession *cse, struct crypt_aead *caead) * Permit a 16-byte IV for AES-XTS, but only use the * first 8 bytes as a block number. */ - if (cse->mode == CSP_MODE_ETA && - caead->ivlen == AES_BLOCK_LEN && - cse->ivsize == AES_XTS_IV_LEN) + if (csp->csp_mode == CSP_MODE_ETA && + csp->csp_cipher_alg == CRYPTO_AES_XTS && + caead->ivlen == AES_BLOCK_LEN) caead->ivlen = AES_XTS_IV_LEN; if (cse->ivsize == 0) {