From owner-svn-src-all@freebsd.org Wed Aug 26 21:28:47 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E324F3BCB3F; Wed, 26 Aug 2020 21:28:47 +0000 (UTC) (envelope-from jhb@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BcJrb5gPvz3RdD; Wed, 26 Aug 2020 21:28:47 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A2FA9197D6; Wed, 26 Aug 2020 21:28:47 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 07QLSlO9082654; Wed, 26 Aug 2020 21:28:47 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07QLSlUS082653; Wed, 26 Aug 2020 21:28:47 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202008262128.07QLSlUS082653@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 26 Aug 2020 21:28:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364840 - head/sys/opencrypto X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/opencrypto X-SVN-Commit-Revision: 364840 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2020 21:28:48 -0000 Author: jhb Date: Wed Aug 26 21:28:47 2020 New Revision: 364840 URL: https://svnweb.freebsd.org/changeset/base/364840 Log: Add freebsd32 compat support for CIOCCRYPTAEAD. Reviewed by: markj (earlier version) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D26179 Modified: head/sys/opencrypto/cryptodev.c Modified: head/sys/opencrypto/cryptodev.c ============================================================================== --- head/sys/opencrypto/cryptodev.c Wed Aug 26 21:19:05 2020 (r364839) +++ head/sys/opencrypto/cryptodev.c Wed Aug 26 21:28:47 2020 (r364840) @@ -103,6 +103,20 @@ struct crypt_op32 { u_int32_t iv; }; +struct crypt_aead32 { + u_int32_t ses; + u_int16_t op; + u_int16_t flags; + u_int len; + u_int aadlen; + u_int ivlen; + u_int32_t src; + u_int32_t dst; + u_int32_t aad; + u_int32_t tag; + u_int32_t iv; +}; + struct crparam32 { u_int32_t crp_p; u_int crp_nbits; @@ -122,6 +136,7 @@ struct crypt_kop32 { #define CIOCKEY32 _IOWR('c', 104, struct crypt_kop32) #define CIOCGSESSION232 _IOWR('c', 106, struct session2_op32) #define CIOCKEY232 _IOWR('c', 107, struct crypt_kop32) +#define CIOCCRYPTAEAD32 _IOWR('c', 109, struct crypt_aead32) static void session_op_from_32(const struct session_op32 *from, struct session2_op *to) @@ -196,6 +211,40 @@ crypt_op_to_32(const struct crypt_op *from, struct cry } static void +crypt_aead_from_32(const struct crypt_aead32 *from, struct crypt_aead *to) +{ + + CP(*from, *to, ses); + CP(*from, *to, op); + CP(*from, *to, flags); + CP(*from, *to, len); + CP(*from, *to, aadlen); + CP(*from, *to, ivlen); + PTRIN_CP(*from, *to, src); + PTRIN_CP(*from, *to, dst); + PTRIN_CP(*from, *to, aad); + PTRIN_CP(*from, *to, tag); + PTRIN_CP(*from, *to, iv); +} + +static void +crypt_aead_to_32(const struct crypt_aead *from, struct crypt_aead32 *to) +{ + + CP(*from, *to, ses); + CP(*from, *to, op); + CP(*from, *to, flags); + CP(*from, *to, len); + CP(*from, *to, aadlen); + CP(*from, *to, ivlen); + PTROUT_CP(*from, *to, src); + PTROUT_CP(*from, *to, dst); + PTROUT_CP(*from, *to, aad); + PTROUT_CP(*from, *to, tag); + PTROUT_CP(*from, *to, iv); +} + +static void crparam_from_32(const struct crparam32 *from, struct crparam *to) { @@ -388,6 +437,7 @@ cryptof_ioctl( struct session2_op sopc; #ifdef COMPAT_FREEBSD32 struct crypt_op copc; + struct crypt_aead aeadc; struct crypt_kop kopc; #endif }; @@ -419,6 +469,13 @@ cryptof_ioctl( data = &copc; crypt_op_from_32((struct crypt_op32 *)data32, &copc); break; + case CIOCCRYPTAEAD32: + cmd32 = cmd; + data32 = data; + cmd = CIOCCRYPTAEAD; + data = &aeadc; + crypt_aead_from_32((struct crypt_aead32 *)data32, &aeadc); + break; case CIOCKEY32: case CIOCKEY232: cmd32 = cmd; @@ -822,6 +879,10 @@ bail: case CIOCCRYPT32: if (error == 0) crypt_op_to_32(data, data32); + break; + case CIOCCRYPTAEAD32: + if (error == 0) + crypt_aead_to_32(data, data32); break; case CIOCKEY32: case CIOCKEY232: