From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7C13B42981; Wed, 19 Apr 2023 01:10:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B7C240DF8; Wed, 19 Apr 2023 01:10:06 +0200 (CEST) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id 968714021F for ; Wed, 19 Apr 2023 01:10:04 +0200 (CEST) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-247399d518dso1247601a91.0 for ; Tue, 18 Apr 2023 16:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bloombase-com.20221208.gappssmtp.com; s=20221208; t=1681859403; x=1684451403; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=pX71VWYwrpqHgCwrh+vG16UhUFhKI0vy28w9tIHYdbQ=; b=qcep2enx7c8+BTGWe1plDAvjEfnn1slhRjXSaEvPeAZPUvpOOiajr0rQiErfjACqgZ QHjGRPaG73tlGrFAo9QBpU3VCmFZogvQ/jE7lk3yx0m+q8EJMeaC4kxKPsGRG4BdsBoA L+pnIwIJKB2qnPEjMIfSdLKq3uoLQ3PRu8MOdGvIzKua/WoAN5tgTMbL7BISjB07nbhX 3yvZwJH9wwaeaBlwBtGJ4lAqRpuyW96nr0jB5FPIWh6BcW9kTlOWsrFDvzPm2I2gfFaP FE+DWCzOiHfc2HSeME6vuPoBKc9axlXbxSUfeZogujF1JYAbTikt9iZoiKZPUhhj4N9Y 6cdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681859403; x=1684451403; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pX71VWYwrpqHgCwrh+vG16UhUFhKI0vy28w9tIHYdbQ=; b=VL6aMoeTnCLS0o+uDyDT1xfkedfie+FqX7Y2BllVHGRR/c5nBzOVzGoWooT5AwNn4a EX9tfeJTV3DeAoOsBqqTwM6UwhVLqBon/MyROvs0Lv1/ipFaqPP4cA2bj5EOrHZkQk1e uavMaaa4b8BqGuqLvXMJ8pJu6+GJZOyjTRw/dD1F9SvNbfwJs6N0yPHSzSUYNT5kwuNk NL9MXtTd+sLUGSHXz46J5LIwWYBHzQxUzINQ6ygUhx6u8uvXT4JfZW8+rd+Vw92ZK3Oy CpnbHBZf9lVsROYTxF/9tnsoygwF8oDX8kQVqkMbSv9lz5XKyVhFBFplN19M2fvpdsz5 PEjg== X-Gm-Message-State: AAQBX9flNyx1vi9/zFHvaci3UjrcN4VmuIaaSNGvGi5/hQVJocYWeuCP HV2647h8Iu1IuPuwvUmxnJJTXVs9cCsou/eCs4KMfA== X-Google-Smtp-Source: AKy350bF/mwqw9ph7v6fN9mSocUI3+CNLbjHIMDqSHOS6y0yozoedOxBEeBOCVO4vT1i+6P4O2p2Hw== X-Received: by 2002:a17:90a:72c8:b0:246:9bad:2354 with SMTP id l8-20020a17090a72c800b002469bad2354mr883805pjk.43.1681859403426; Tue, 18 Apr 2023 16:10:03 -0700 (PDT) Received: from localhost.localdomain ([184.67.102.198]) by smtp.gmail.com with ESMTPSA id n2-20020a17090a4e0200b00246774a9addsm88786pjh.48.2023.04.18.16.10.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 16:10:02 -0700 (PDT) From: Michael Leung To: dev@dpdk.org Subject: [PATCH] crypto/openssl: add aes-xts support Date: Tue, 18 Apr 2023 16:09:47 -0700 Message-Id: <20230418230947.240459-1-michael.leung@bloombase.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add aes-128-xts and aes-256-xts support for crypto openssl pmd. As xts mode we got 2 key, the key length is multiplied by two, i.e. 32 and 64. Signed-off-by: Michael Leung --- drivers/crypto/openssl/openssl_pmd_private.h | 2 +- drivers/crypto/openssl/rte_openssl_pmd.c | 13 +++++++++++++ drivers/crypto/openssl/rte_openssl_pmd_ops.c | 20 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/openssl/openssl_pmd_private.h b/drivers/crypto/openssl/openssl_pmd_private.h index ed6841e460..85a8316edc 100644 --- a/drivers/crypto/openssl/openssl_pmd_private.h +++ b/drivers/crypto/openssl/openssl_pmd_private.h @@ -103,7 +103,7 @@ struct openssl_session { /**< cipher algorithm */ struct { - uint8_t data[32]; + uint8_t data[64]; /**< key data */ size_t length; /**< key length in bytes */ diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 384d262621..e9cbc60da7 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -240,6 +240,18 @@ get_cipher_algo(enum rte_crypto_cipher_algorithm sess_algo, size_t keylen, res = -EINVAL; } break; + case RTE_CRYPTO_CIPHER_AES_XTS: + switch (keylen) { + case 32: + *algo = EVP_aes_128_xts(); + break; + case 64: + *algo = EVP_aes_256_xts(); + break; + default: + res = -EINVAL; + } + break; default: res = -EINVAL; break; @@ -483,6 +495,7 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess, case RTE_CRYPTO_CIPHER_3DES_CBC: case RTE_CRYPTO_CIPHER_AES_CBC: case RTE_CRYPTO_CIPHER_AES_CTR: + case RTE_CRYPTO_CIPHER_AES_XTS: sess->cipher.mode = OPENSSL_CIPHER_LIB; sess->cipher.algo = xform->cipher.algo; sess->cipher.ctx = EVP_CIPHER_CTX_new(); diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index 29ad1b9505..c016b1926f 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -309,6 +309,26 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = { }, } }, } }, + { /* AES XTS */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_AES_XTS, + .block_size = 16, + .key_size = { + .min = 32, + .max = 64, + .increment = 32 // only 32 & 64 (128/256-bit) + }, + .iv_size = { + .min = 16, + .max = 16, + .increment = 0 + } + }, } + }, } + }, { /* AES GCM */ .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, {.sym = { -- 2.25.1