From nobody Mon Nov 08 09:53:48 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 3EA861843ABB; Mon, 8 Nov 2021 09:53:49 +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 4Hnmf50jFJz3L9w; Mon, 8 Nov 2021 09:53:49 +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 ED844767F; Mon, 8 Nov 2021 09:53:48 +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 1A89rmGl026196; Mon, 8 Nov 2021 09:53:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A89rmOq026195; Mon, 8 Nov 2021 09:53:48 GMT (envelope-from git) Date: Mon, 8 Nov 2021 09:53:48 GMT Message-Id: <202111080953.1A89rmOq026195@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: c4026909bdfe - main - ossl: Add support for ETA mode 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: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c4026909bdfef0394bd4db41d2d102f609ae92b8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=c4026909bdfef0394bd4db41d2d102f609ae92b8 commit c4026909bdfef0394bd4db41d2d102f609ae92b8 Author: Kornel Duleba AuthorDate: 2021-11-02 11:57:20 +0000 Commit: Wojciech Macek CommitDate: 2021-11-08 09:53:36 +0000 ossl: Add support for ETA mode Now that the AES-CBC is supported we can handle ETA requests. Sponsored by: Stormshield Obtained from: Semihalf Reviewed by: jhb Differential revision: https://reviews.freebsd.org/D32100 --- sys/crypto/openssl/ossl.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sys/crypto/openssl/ossl.c b/sys/crypto/openssl/ossl.c index f46b5a966bb1..f41ff09c371d 100644 --- a/sys/crypto/openssl/ossl.c +++ b/sys/crypto/openssl/ossl.c @@ -172,6 +172,13 @@ ossl_probesession(device_t dev, const struct crypto_session_params *csp) if (ossl_lookup_cipher(csp) == NULL) return (EINVAL); break; + case CSP_MODE_ETA: + if (!sc->has_aes || + csp->csp_cipher_alg == CRYPTO_CHACHA20 || + ossl_lookup_hash(csp) == NULL || + ossl_lookup_cipher(csp) == NULL) + return (EINVAL); + break; case CSP_MODE_AEAD: switch (csp->csp_cipher_alg) { case CRYPTO_CHACHA20_POLY1305: @@ -268,6 +275,10 @@ ossl_newsession(device_t dev, crypto_session_t cses, case CSP_MODE_CIPHER: error = ossl_newsession_cipher(s, csp); break; + case CSP_MODE_ETA: + ossl_newsession_hash(s, csp); + error = ossl_newsession_cipher(s, csp); + break; } return (error); @@ -341,6 +352,25 @@ out: return (error); } +static int +ossl_process_eta(struct ossl_session *s, struct cryptop *crp, + const struct crypto_session_params *csp) +{ + int error; + + if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { + error = s->cipher.cipher->process(&s->cipher, crp, csp); + if (error == 0) + error = ossl_process_hash(s, crp, csp); + } else { + error = ossl_process_hash(s, crp, csp); + if (error == 0) + error = s->cipher.cipher->process(&s->cipher, crp, csp); + } + + return (error); +} + static int ossl_process(device_t dev, struct cryptop *crp, int hint) { @@ -366,6 +396,9 @@ ossl_process(device_t dev, struct cryptop *crp, int hint) case CSP_MODE_CIPHER: error = s->cipher.cipher->process(&s->cipher, crp, csp); break; + case CSP_MODE_ETA: + error = ossl_process_eta(s, crp, csp); + break; case CSP_MODE_AEAD: if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) error = ossl_chacha20_poly1305_encrypt(crp, csp);