Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1005540ybe; Fri, 13 Sep 2019 09:35:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqziEOycQ911ypo3S3/HbXA1ImHSCWuX2aK7nQSwuXU4k3WAz1dyr/6sTazMWKS0fmw2Ufi2 X-Received: by 2002:aa7:d4c8:: with SMTP id t8mr4338483edr.158.1568392540008; Fri, 13 Sep 2019 09:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568392539; cv=none; d=google.com; s=arc-20160816; b=RKrLuz3phD0uPTT/HubQUAubrJPX+WWPQQ8C+XwolgqXgmXYet8zJaLmckwDhAVWGy h4M15pAp4noVbpOZeQG9ccV3sFZ3ZxikKePFWh2+l3+LbrscU/9+CZqIJO6eiPLFi7qe 0H3heiAnlgjEzFIUa1RSmJHRH+rO5K+jLOTzVxMbjFV974St93wo2YP3m2v7ok9CihrR z5YB9WskuG7njalJ3IjTlVD41OhMc4pGlO8WfdvvK/80xxuwswHFfFcMHmMZSTuH/1ki oIDo01zWdvkcDrCZUbrounGzcFreTcPx9+17U+RxdX6kiIWOeshpb0b6vdVWFQERaO0i BF0Q== 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=cVUwAljGiZksQubTUeS6DFZTcWZ4ZZEez2CiuBcwBaA=; b=E6RDqGhBUvah0rwFHasqztS4U1Qk/flc+b2T/ebtjNUwqK6wY51/VDY5/U58djjdDM wYqeaCRAHtCjyXG7vdQia057gtxBgS73KdbtIrHj1yuWYn+IignhmrVicLc+7qjmCBPq dGC0pUSaPCSJnjZNuZfYHGJBWwWtCcBll1maive1Z0gsuPSPM7yf7jIQkUB4UD+aPh81 NOt+TN29m1pMa/e1ogmsQcjgPGH7MdgaisCVu12n5YP1dOCWxFUS8sSQh1hHCd/rAocO pOKPN1nIfSNL7QXvb5kd9ukBtC7JVPQX6MQmwB+RrbNSewc1+PAO5e2KTeUnS6HuUYwv jjng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DedgKSAm; 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 u23si12676377eja.305.2019.09.13.09.35.14; Fri, 13 Sep 2019 09:35:39 -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=DedgKSAm; 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 S2390886AbfIMPGT (ORCPT + 99 others); Fri, 13 Sep 2019 11:06:19 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:34921 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390884AbfIMPGT (ORCPT ); Fri, 13 Sep 2019 11:06:19 -0400 Received: by mail-ed1-f65.google.com with SMTP id f24so9727357edv.2 for ; Fri, 13 Sep 2019 08:06:17 -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=cVUwAljGiZksQubTUeS6DFZTcWZ4ZZEez2CiuBcwBaA=; b=DedgKSAmI0J55klWRpgwLMsFgjwrj208u3VzRw2HNnYgmSVYc1lxVRJJ/q32wdXxem DXc0y87G4SsoAIptsjpqZ1PAJaiTt/biheyTN1S6RWXXy64b07rc3o8wr/2ofWNlGhfO rswkBA70cZ6j6KwQE7FNH/jR2VMaGWMVUmu2Ua9w9fnwJ60X/4/DzWbWJKU3lzVfRb+t +EueD22OZvo/mC4LYh8Aoz7mJ1aYPwGH+z6mGYgbfga3P0plsndO7L+EfrTx9OVwoaj8 OEFu7g/LiH3GvksFhFL3pwLSIg7OIa/WzDVBTPE0F+q+7HPPt+qzuT5XTM4lvc8O4uRI xxTQ== 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=cVUwAljGiZksQubTUeS6DFZTcWZ4ZZEez2CiuBcwBaA=; b=JRSt3jhBtW8+6EgR47YXuns6C9/ac9fb6IJ76iBg4Ki0FpcnGUibSueGmpQu6xme+P zsJIfCrc9I1kI3eylEU7yWq+WkUmqhW+13YsKDuTYtSCOllNlg9Otx1tqffODjWb5ZrO QcMyHHbTp8ELOjCnzrsFoTX5yxorSotYl2V6TG78/rCrGfG+EddkIT9FiaDjS3VnZbFw b9f08pSptvVtwnDJGTpBXK3necp9TxTu/Sbg5SQ8RfM/SfT3z53YMXmtfGyOxgFCvOzn sMLydEdGHQv0+J+YTdk7wtrTu3PqtTefFRuuB96S7l6XSKC21fqTCtsv394Bkin1BwfH F8sA== X-Gm-Message-State: APjAAAXvT9DNzQzq8377wYlgRr/jkm4licZRaLYuZiFhoYyogffmC3Mq V7RBwYBbUqpyWBphfMzHacf7QCjP X-Received: by 2002:a17:906:9716:: with SMTP id k22mr39811130ejx.284.1568387176293; Fri, 13 Sep 2019 08:06:16 -0700 (PDT) Received: from localhost.localdomain.com ([188.204.2.113]) by smtp.gmail.com with ESMTPSA id ly10sm3206654ejb.59.2019.09.13.08.06.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 08:06:15 -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 3/3] crypto: inside-secure - Added support for authenc HMAC-SHA2/DES-CBC Date: Fri, 13 Sep 2019 16:03:26 +0200 Message-Id: <1568383406-8009-4-git-send-email-pvanleeuwen@verimatrix.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568383406-8009-1-git-send-email-pvanleeuwen@verimatrix.com> References: <1568383406-8009-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(des)), authenc(hmac(sha256),cbc(des)), authenc(hmac(sha384),cbc(des)) and authenc(hmac(sha512),cbc(des)) aead's 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 4222ffa..1e05b5f 100644 --- a/drivers/crypto/inside-secure/safexcel.c +++ b/drivers/crypto/inside-secure/safexcel.c @@ -1200,6 +1200,10 @@ static int safexcel_request_ring_irq(void *pdev, int irqid, &safexcel_alg_authenc_hmac_sha224_cbc_des3_ede, &safexcel_alg_authenc_hmac_sha512_cbc_des3_ede, &safexcel_alg_authenc_hmac_sha384_cbc_des3_ede, + &safexcel_alg_authenc_hmac_sha256_cbc_des, + &safexcel_alg_authenc_hmac_sha224_cbc_des, + &safexcel_alg_authenc_hmac_sha512_cbc_des, + &safexcel_alg_authenc_hmac_sha384_cbc_des, }; 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 fd6798f..fc16d5a 100644 --- a/drivers/crypto/inside-secure/safexcel.h +++ b/drivers/crypto/inside-secure/safexcel.h @@ -900,5 +900,9 @@ int safexcel_hmac_setkey(const char *alg, const u8 *key, unsigned int keylen, 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; +extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des; +extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des; +extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des; +extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des; #endif diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c index 0d26bea..71233ff 100644 --- a/drivers/crypto/inside-secure/safexcel_cipher.c +++ b/drivers/crypto/inside-secure/safexcel_cipher.c @@ -2035,6 +2035,142 @@ struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_des = { }, }; +static int safexcel_aead_sha256_des_cra_init(struct crypto_tfm *tfm) +{ + struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); + + safexcel_aead_sha256_cra_init(tfm); + ctx->alg = SAFEXCEL_DES; /* override default */ + return 0; +} + +struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des = { + .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 = DES_BLOCK_SIZE, + .maxauthsize = SHA256_DIGEST_SIZE, + .base = { + .cra_name = "authenc(hmac(sha256),cbc(des))", + .cra_driver_name = "safexcel-authenc-hmac-sha256-cbc-des", + .cra_priority = SAFEXCEL_CRA_PRIORITY, + .cra_flags = CRYPTO_ALG_ASYNC | + CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = DES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct safexcel_cipher_ctx), + .cra_alignmask = 0, + .cra_init = safexcel_aead_sha256_des_cra_init, + .cra_exit = safexcel_aead_cra_exit, + .cra_module = THIS_MODULE, + }, + }, +}; + +static int safexcel_aead_sha224_des_cra_init(struct crypto_tfm *tfm) +{ + struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); + + safexcel_aead_sha224_cra_init(tfm); + ctx->alg = SAFEXCEL_DES; /* override default */ + return 0; +} + +struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des = { + .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 = DES_BLOCK_SIZE, + .maxauthsize = SHA224_DIGEST_SIZE, + .base = { + .cra_name = "authenc(hmac(sha224),cbc(des))", + .cra_driver_name = "safexcel-authenc-hmac-sha224-cbc-des", + .cra_priority = SAFEXCEL_CRA_PRIORITY, + .cra_flags = CRYPTO_ALG_ASYNC | + CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = DES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct safexcel_cipher_ctx), + .cra_alignmask = 0, + .cra_init = safexcel_aead_sha224_des_cra_init, + .cra_exit = safexcel_aead_cra_exit, + .cra_module = THIS_MODULE, + }, + }, +}; + +static int safexcel_aead_sha512_des_cra_init(struct crypto_tfm *tfm) +{ + struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); + + safexcel_aead_sha512_cra_init(tfm); + ctx->alg = SAFEXCEL_DES; /* override default */ + return 0; +} + +struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des = { + .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 = DES_BLOCK_SIZE, + .maxauthsize = SHA512_DIGEST_SIZE, + .base = { + .cra_name = "authenc(hmac(sha512),cbc(des))", + .cra_driver_name = "safexcel-authenc-hmac-sha512-cbc-des", + .cra_priority = SAFEXCEL_CRA_PRIORITY, + .cra_flags = CRYPTO_ALG_ASYNC | + CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = DES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct safexcel_cipher_ctx), + .cra_alignmask = 0, + .cra_init = safexcel_aead_sha512_des_cra_init, + .cra_exit = safexcel_aead_cra_exit, + .cra_module = THIS_MODULE, + }, + }, +}; + +static int safexcel_aead_sha384_des_cra_init(struct crypto_tfm *tfm) +{ + struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); + + safexcel_aead_sha384_cra_init(tfm); + ctx->alg = SAFEXCEL_DES; /* override default */ + return 0; +} + +struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des = { + .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 = DES_BLOCK_SIZE, + .maxauthsize = SHA384_DIGEST_SIZE, + .base = { + .cra_name = "authenc(hmac(sha384),cbc(des))", + .cra_driver_name = "safexcel-authenc-hmac-sha384-cbc-des", + .cra_priority = SAFEXCEL_CRA_PRIORITY, + .cra_flags = CRYPTO_ALG_ASYNC | + CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = DES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct safexcel_cipher_ctx), + .cra_alignmask = 0, + .cra_init = safexcel_aead_sha384_des_cra_init, + .cra_exit = safexcel_aead_cra_exit, + .cra_module = THIS_MODULE, + }, + }, +}; + static int safexcel_aead_sha1_ctr_cra_init(struct crypto_tfm *tfm) { struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); -- 1.8.3.1