Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1286957ybe; Fri, 13 Sep 2019 14:08:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLsyyg0oHwBB6ePzTE9g6V8frveU5w300Q+7CO8tDWVZqJyTNJkbIZF14HQOT7RJJE7nc+ X-Received: by 2002:a05:6402:1598:: with SMTP id c24mr49917736edv.174.1568408908659; Fri, 13 Sep 2019 14:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568408908; cv=none; d=google.com; s=arc-20160816; b=FcPKgAAKEMR3SBKQZNp9eftRDdA388BupFuisGYf6y+hW9z1e9u+VILhLV8RJzFwg4 zGg1GkWESuuQWuHRDYOkEZqZUgc0bER3sz1ZSOco6bkcIV7hCZBchZssbvy8iPqE6Kig fMU6l4LFZcAydShSfuJmimLJusweXACFDKxbyOeMATr5wUE5YD5LQPI+Vz5juTsf4aIR /MrW7J9nk59kC3fRuhxIkTcFOwBWs9ehFZJVG9cSe57vyJu8DwM2amAtvnOl1mc57qMH 4H29b3aCQtrKaklAcE+iKT2VcVH11d3O7sMGFsMBFSG19qd1UwUd7Qd89uCyMSpZ5FCD WXYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=xx/hvQA7i9CvwqMbYOnLL/zTNy8rgTX2wzCAHVUWtu4=; b=qJK1qMM2FoiSh35C38AMngrcMKQXUKJe06vpT97yfNSAgpZSuh0te15JSXbDMgu5ik Rmf+c8U3yicZ9k+2w14YkaJMBydwL5X1LVpcEbq8TrjibgFqo0AKzhmu9fS6ApSUdiEj pighAL93PRthJm52ojg4GjYdo/g4q5ijQ+LmPDrwaef5kSkgxVJ860f6JyaQcNzfYz7X 3KczFB+xsV7qo8TPpTP2ItkwydUwVVAnGOqZIWDZ0JS8OMrmrX2LFFxBLy/9Xy5kTkld A0IubjguryOTQSXAmd68VnIXmse9BK1OopnV+poW5Yf/V5OZZbRE/mJF2qrjdEdvOTre k4qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cg24KZew; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a25si1426445edx.441.2019.09.13.14.08.04; Fri, 13 Sep 2019 14:08:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cg24KZew; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731154AbfIMVHk (ORCPT + 99 others); Fri, 13 Sep 2019 17:07:40 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:44698 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731110AbfIMVHj (ORCPT ); Fri, 13 Sep 2019 17:07:39 -0400 Received: by mail-ed1-f67.google.com with SMTP id p2so26963537edx.11 for ; Fri, 13 Sep 2019 14:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xx/hvQA7i9CvwqMbYOnLL/zTNy8rgTX2wzCAHVUWtu4=; b=cg24KZewgafbNasNmlVVsg1dvy0RkrOmXmxEPlMZe8EMLQpbYUDc9S9sQz5ZK7ravf WNONB113bo03709dqv9UoM//9gXvYaKd7pEUtPQtubWRTFRGbXJVxhI1E1ECqZEaNX1W OV9bDZEo1xUvQUl9Av/50IB9WKvqM4h1h/6QM0EdM9TEvpyWXMuGlcGpfzPZuf9k2iYL d3FuKpZn9Jr2r5FibgatQetyvajAF55ncbHtmq5gTTPK/dT5mLNaz/vSzVSMxk2DykDn hQLsoDMElJ1KFbbIYb6AeSUoONwV0v947MYorm8OzeBnOxZh+VG0LCUTmrdwNAvRUEAW eZMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xx/hvQA7i9CvwqMbYOnLL/zTNy8rgTX2wzCAHVUWtu4=; b=Qsj5xmX5QWUrmqNjXVs3rA3fFZ+6K7A+BCbJrCVFD8wGbiNvhLCwQbvg08awp/24Zw +omCD+eB50pmuzi12Y4vAw1zUz6kAhH/eJxTDaVWOCRbp44rNlIjyYga2L7Mjc5B6/MW LaXluy0L+kUSJ2b2Ovtthh7GsNad6qPXZXIpGcpkRlC9/oDBgvYQtGrBgIYxeysUyVXT er9U3DvG4KX+pZeiR4jNO/93DHTMup6lxhYapKvRBBvq1byI6iQWIf2QKH92SvMEz/AM weIcILMerErFY4rU8HA8Tp2QSMyVN6UJ1+Z1j35+wS1SbCbocZI/v97P0c8Axo9OghY+ YVuA== X-Gm-Message-State: APjAAAWXjofSPpBJcjkmIVIKIVbm9JFnRQY6eVPMeiylLFOrE1UgXWd0 K527CrDKyLAIfwVoTO1mSJGREJxm X-Received: by 2002:a17:906:2f92:: with SMTP id w18mr23045269eji.33.1568408856851; Fri, 13 Sep 2019 14:07:36 -0700 (PDT) Received: from localhost.localdomain.com ([188.204.2.113]) by smtp.gmail.com with ESMTPSA id e44sm1411296ede.34.2019.09.13.14.07.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 14:07:36 -0700 (PDT) From: Pascal van Leeuwen X-Google-Original-From: Pascal van Leeuwen To: linux-crypto@vger.kernel.org Cc: antoine.tenart@bootlin.com, herbert@gondor.apana.org.au, davem@davemloft.net, Pascal van Leeuwen Subject: [PATCH 2/3] crypto: inside-secure - Added support for authenc HMAC-SHA2/3DES-CBC Date: Fri, 13 Sep 2019 22:04:45 +0200 Message-Id: <1568405086-7898-3-git-send-email-pvanleeuwen@verimatrix.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568405086-7898-1-git-send-email-pvanleeuwen@verimatrix.com> References: <1568405086-7898-1-git-send-email-pvanleeuwen@verimatrix.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This patch adds support for the authenc(hmac(sha224),cbc(des3_ede)), authenc(hmac(sha256),cbc(des3_ede)), authenc(hmac(sha384),cbc(des3_ede)) and authenc(hmac(sha512),cbc(des3_ede)) aead's changes since v1: - nothing Signed-off-by: Pascal van Leeuwen --- drivers/crypto/inside-secure/safexcel.c | 4 + drivers/crypto/inside-secure/safexcel.h | 4 + drivers/crypto/inside-secure/safexcel_cipher.c | 136 +++++++++++++++++++++++++ 3 files changed, 144 insertions(+) diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c index 462dbf6..36523dd 100644 --- a/drivers/crypto/inside-secure/safexcel.c +++ b/drivers/crypto/inside-secure/safexcel.c @@ -1196,6 +1196,10 @@ static int safexcel_request_ring_irq(void *pdev, int irqid, &safexcel_alg_hmac_sha3_384, &safexcel_alg_hmac_sha3_512, &safexcel_alg_authenc_hmac_sha1_cbc_des, + &safexcel_alg_authenc_hmac_sha256_cbc_des3_ede, + &safexcel_alg_authenc_hmac_sha224_cbc_des3_ede, + &safexcel_alg_authenc_hmac_sha512_cbc_des3_ede, + &safexcel_alg_authenc_hmac_sha384_cbc_des3_ede, }; static int safexcel_register_algorithms(struct safexcel_crypto_priv *priv) diff --git a/drivers/crypto/inside-secure/safexcel.h b/drivers/crypto/inside-secure/safexcel.h index fe00b87..b1703e3 100644 --- a/drivers/crypto/inside-secure/safexcel.h +++ b/drivers/crypto/inside-secure/safexcel.h @@ -902,5 +902,9 @@ int safexcel_hmac_setkey(const char *alg, const u8 *key, unsigned int keylen, extern struct safexcel_alg_template safexcel_alg_hmac_sha3_384; extern struct safexcel_alg_template safexcel_alg_hmac_sha3_512; extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_des; +extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des3_ede; +extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des3_ede; +extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des3_ede; +extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des3_ede; #endif diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c index 91cab26..a80e4f2 100644 --- a/drivers/crypto/inside-secure/safexcel_cipher.c +++ b/drivers/crypto/inside-secure/safexcel_cipher.c @@ -1846,6 +1846,142 @@ struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_des3_ede = { }, }; +static int safexcel_aead_sha256_des3_cra_init(struct crypto_tfm *tfm) +{ + struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); + + safexcel_aead_sha256_cra_init(tfm); + ctx->alg = SAFEXCEL_3DES; /* override default */ + return 0; +} + +struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des3_ede = { + .type = SAFEXCEL_ALG_TYPE_AEAD, + .algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_256, + .alg.aead = { + .setkey = safexcel_aead_setkey, + .encrypt = safexcel_aead_encrypt, + .decrypt = safexcel_aead_decrypt, + .ivsize = DES3_EDE_BLOCK_SIZE, + .maxauthsize = SHA256_DIGEST_SIZE, + .base = { + .cra_name = "authenc(hmac(sha256),cbc(des3_ede))", + .cra_driver_name = "safexcel-authenc-hmac-sha256-cbc-des3_ede", + .cra_priority = SAFEXCEL_CRA_PRIORITY, + .cra_flags = CRYPTO_ALG_ASYNC | + CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = DES3_EDE_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct safexcel_cipher_ctx), + .cra_alignmask = 0, + .cra_init = safexcel_aead_sha256_des3_cra_init, + .cra_exit = safexcel_aead_cra_exit, + .cra_module = THIS_MODULE, + }, + }, +}; + +static int safexcel_aead_sha224_des3_cra_init(struct crypto_tfm *tfm) +{ + struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); + + safexcel_aead_sha224_cra_init(tfm); + ctx->alg = SAFEXCEL_3DES; /* override default */ + return 0; +} + +struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des3_ede = { + .type = SAFEXCEL_ALG_TYPE_AEAD, + .algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_256, + .alg.aead = { + .setkey = safexcel_aead_setkey, + .encrypt = safexcel_aead_encrypt, + .decrypt = safexcel_aead_decrypt, + .ivsize = DES3_EDE_BLOCK_SIZE, + .maxauthsize = SHA224_DIGEST_SIZE, + .base = { + .cra_name = "authenc(hmac(sha224),cbc(des3_ede))", + .cra_driver_name = "safexcel-authenc-hmac-sha224-cbc-des3_ede", + .cra_priority = SAFEXCEL_CRA_PRIORITY, + .cra_flags = CRYPTO_ALG_ASYNC | + CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = DES3_EDE_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct safexcel_cipher_ctx), + .cra_alignmask = 0, + .cra_init = safexcel_aead_sha224_des3_cra_init, + .cra_exit = safexcel_aead_cra_exit, + .cra_module = THIS_MODULE, + }, + }, +}; + +static int safexcel_aead_sha512_des3_cra_init(struct crypto_tfm *tfm) +{ + struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); + + safexcel_aead_sha512_cra_init(tfm); + ctx->alg = SAFEXCEL_3DES; /* override default */ + return 0; +} + +struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des3_ede = { + .type = SAFEXCEL_ALG_TYPE_AEAD, + .algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_512, + .alg.aead = { + .setkey = safexcel_aead_setkey, + .encrypt = safexcel_aead_encrypt, + .decrypt = safexcel_aead_decrypt, + .ivsize = DES3_EDE_BLOCK_SIZE, + .maxauthsize = SHA512_DIGEST_SIZE, + .base = { + .cra_name = "authenc(hmac(sha512),cbc(des3_ede))", + .cra_driver_name = "safexcel-authenc-hmac-sha512-cbc-des3_ede", + .cra_priority = SAFEXCEL_CRA_PRIORITY, + .cra_flags = CRYPTO_ALG_ASYNC | + CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = DES3_EDE_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct safexcel_cipher_ctx), + .cra_alignmask = 0, + .cra_init = safexcel_aead_sha512_des3_cra_init, + .cra_exit = safexcel_aead_cra_exit, + .cra_module = THIS_MODULE, + }, + }, +}; + +static int safexcel_aead_sha384_des3_cra_init(struct crypto_tfm *tfm) +{ + struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); + + safexcel_aead_sha384_cra_init(tfm); + ctx->alg = SAFEXCEL_3DES; /* override default */ + return 0; +} + +struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des3_ede = { + .type = SAFEXCEL_ALG_TYPE_AEAD, + .algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_512, + .alg.aead = { + .setkey = safexcel_aead_setkey, + .encrypt = safexcel_aead_encrypt, + .decrypt = safexcel_aead_decrypt, + .ivsize = DES3_EDE_BLOCK_SIZE, + .maxauthsize = SHA384_DIGEST_SIZE, + .base = { + .cra_name = "authenc(hmac(sha384),cbc(des3_ede))", + .cra_driver_name = "safexcel-authenc-hmac-sha384-cbc-des3_ede", + .cra_priority = SAFEXCEL_CRA_PRIORITY, + .cra_flags = CRYPTO_ALG_ASYNC | + CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = DES3_EDE_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct safexcel_cipher_ctx), + .cra_alignmask = 0, + .cra_init = safexcel_aead_sha384_des3_cra_init, + .cra_exit = safexcel_aead_cra_exit, + .cra_module = THIS_MODULE, + }, + }, +}; + static int safexcel_aead_sha1_des_cra_init(struct crypto_tfm *tfm) { struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); -- 1.8.3.1