From patchwork Fri Aug 28 17:05:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 248591 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp1256322ilg; Fri, 28 Aug 2020 10:05:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXcKSumucQceTUs3QSr6SGV6nTUzsjuv3Na6Go14Eshst0HMOEP59scwHQjdpFoeKU8//d X-Received: by 2002:a25:3bce:: with SMTP id i197mr3824294yba.426.1598634340495; Fri, 28 Aug 2020 10:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598634340; cv=none; d=google.com; s=arc-20160816; b=vJZ0zc3/rAiivv1JQ4qSnZ6PGbfk5LBSIyhke+jaubGsabr+46yUFRSeOaksWBfZUw LtmNLojEj1HzfRhJnYJidat72pYnphGwd3biL81MSbwhpB7b2nVXpxJOTi779Hjluewy 5UuUMcmV4Tq08bDQ3I6LeW8QIMb8FZUio0rg5L20hk1o/3VQEdKrb8tX8L+9epcFOs2p ncoQigosxuK2tYULLjKTWLAO3S0A+Uz/hk1UghN79+8SUstZExfeqbMtccsKpi4nK0IC mWWv2t46vaZFGE1EPLxKmoE4umOzf6GtTdresXE3yFVcVF/LE7MBTHuKSBUOCvEu9Nky iYQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=o+wKj1Jv8fml/03sdKVYIYEOnnCMhd3pvDGOCXnWYO8=; b=GFapN//c4exxufCIYAMGUh/YE9upjdhakh5nXSk9BojinuGD4QLjjRuWW13OgKigKu hchByq1hj8+veizkGiPU/bOe/58Tu15bwzr7j0WxGpNHD1hbS21QjHNxSFlQ+//LyTDC AsH70mQt119IGt+qjy3f8Bu92saVOrAtBx8xG/XiPuMVx/O829yBpe+RtwRZyc5755cK +chzysZsJLJhvknaYAofOUNfMYZUO65vbEQ5bllsghJbrvw0s8pDY8lKmpC5k5TPon3n wz0JdijkjJ51vfOrzbpTxqRgOufFOpz32PXei7nu3tXlKEh5r+l++xDvEipUtbBUWn4h qY4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cDQ1XqQP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x20si1593959ybd.409.2020.08.28.10.05.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Aug 2020 10:05:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cDQ1XqQP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBhop-0003Xi-Vq for patch@linaro.org; Fri, 28 Aug 2020 13:05:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBhof-0003Xb-Lu for qemu-devel@nongnu.org; Fri, 28 Aug 2020 13:05:29 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:44043) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kBhod-000307-Uy for qemu-devel@nongnu.org; Fri, 28 Aug 2020 13:05:29 -0400 Received: by mail-pg1-x536.google.com with SMTP id m34so712153pgl.11 for ; Fri, 28 Aug 2020 10:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=o+wKj1Jv8fml/03sdKVYIYEOnnCMhd3pvDGOCXnWYO8=; b=cDQ1XqQPoHGaRI0qavA9lB9PbfUmtXSiGwSumx1v1Gjlpof0VGOzp7oZI0ia+B0+Yn x8b/T39k4NO1U9RrlxE9dFL751wNUMkvQAUGH158vEE/MhUFarkquN0dJ4PZ8WxQyo5A zvHdxitXEzUizih5/GoYQUcau+QqAJLdOncMirI0qhRJddyxWZG6N3mT11shQhZ65L/n W8KI//A/mS2DMrXTnWN5gKtcA3oGPHhA+AxgTOtpIl/OznxPZjszXOb2vwcV3fVT4Scd AfTT2LcHicnaYrW4VbkwIsrieFfwzl56ostdzTu3n+0edXwjvT1hIxJg1lrUCH7XNbQn VHew== 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:mime-version :content-transfer-encoding; bh=o+wKj1Jv8fml/03sdKVYIYEOnnCMhd3pvDGOCXnWYO8=; b=XZt4xcAlOHC8aoZ21FLUIceqFxgh2Benqaq61vt+PMB66KidZYQEczB36YJ3FNwmWr 9CccOIfdD+EGP51W1n1FRCFQHJsbPg8LIAGWcUfnyxgOMrZ9sKOoccSUfcwlqTinM5iZ mg41VxSzFkTIxX6jMMJE9rbkucNJVoZ7gHmKzs33j0S8JRdcfmZH8iJie2yTuUC7ZTEE wgdbveu1Suw0Bel60Q2nsLMUNfPxDtAoErLk4jDLu3Q0LIwHKkdvYP5Pf6XdIziq1eMx eh9dG1dxw9s4DkDvf5MFz5ordXTfCQzITA/X918vYYaE3IRVd3PUMwsGctkIlTuOm6r3 12dg== X-Gm-Message-State: AOAM531Wdz37m/9r+T3vxTiaHMk+T1Jc5GHVoKM9cmdSgefmtZ8xTfFm t7uFkHp+tjz0h4sa29q1aF9XmoTFQuLDjw== X-Received: by 2002:a63:b24b:: with SMTP id t11mr1742974pgo.233.1598634325641; Fri, 28 Aug 2020 10:05:25 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id q12sm2277495pff.196.2020.08.28.10.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 10:05:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 00/16] crypto/cipher: Class hierarchy cleanups Date: Fri, 28 Aug 2020 10:05:07 -0700 Message-Id: <20200828170523.418603-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Mostly this is intended to cleanup the class hierarchy used for the ciphers. We currently have multiple levels of dispatch, and multiple separate allocations. The final patches rearrange this to one level of indirect call, and all memory allocated contiguously. But on the way there are a number of other misc cleanups. Changes in v2: * Dropped move of QCryptoCipher typedef. * Moved QCryptoCipherDriver typedef to include/crypto/cipher.h. * Renamed included files to *.c.inc. * Fixed errors with old versions of nettle and gcrypt. Based-on: <20200828132716.279782-1-berrange@redhat.com> ("crypto: fix build with gcrypt") which does at least allow *-softmmu builds to complete, though I still have issues with *-linux-user. r~ Richard Henderson (16): crypto: Assume blocksize is a power of 2 crypto: Rename cipher include files to .c.inc crypto: Remove redundant includes crypto/nettle: Fix xts_encrypt arguments crypto: Move QCryptoCipherDriver typedef to crypto/cipher.h crypto: Use the correct const type for driver crypto: Allocate QCryptoCipher with the subclass crypto: Move cipher->driver init to qcrypto_*_cipher_ctx_new crypto: Constify cipher data tables crypto/builtin: Remove odd-sized AES block handling crypto/builtin: Merge qcrypto_cipher_aes_{ecb,xts}_{en,de}crypt crypto/builtin: Move AES_cbc_encrypt into cipher-builtin.inc.c crypto/builtin: Split and simplify AES_encrypt_cbc crypto/builtin: Split QCryptoCipherBuiltin into subclasses crypto/nettle: Split QCryptoCipherNettle into subclasses crypto/gcrypt: Split QCryptoCipherGcrypt into subclasses crypto/afalgpriv.h | 3 + crypto/cipherpriv.h | 6 +- include/crypto/aes.h | 4 - include/crypto/cipher.h | 4 +- crypto/aes.c | 51 -- crypto/cipher-afalg.c | 25 +- crypto/cipher-builtin.c | 532 ------------ crypto/cipher-nettle.c | 733 ----------------- crypto/cipher.c | 44 +- crypto/cipher-builtin.c.inc | 435 ++++++++++ .../{cipher-gcrypt.c => cipher-gcrypt.c.inc} | 509 ++++++------ crypto/cipher-nettle.c.inc | 760 ++++++++++++++++++ 12 files changed, 1481 insertions(+), 1625 deletions(-) delete mode 100644 crypto/cipher-builtin.c delete mode 100644 crypto/cipher-nettle.c create mode 100644 crypto/cipher-builtin.c.inc rename crypto/{cipher-gcrypt.c => cipher-gcrypt.c.inc} (52%) create mode 100644 crypto/cipher-nettle.c.inc -- 2.25.1