From patchwork Thu Aug 13 03:25:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 247662 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp929216ilo; Wed, 12 Aug 2020 20:34:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvUAdyIloU+Z1GWaVVtWyhGP+iM73GjXKLp29rd98UUGgzybANjfnIsIafq/hwDfKyDHrb X-Received: by 2002:a25:138a:: with SMTP id 132mr3836149ybt.334.1597289685695; Wed, 12 Aug 2020 20:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597289685; cv=none; d=google.com; s=arc-20160816; b=l6hvMMChCieldNwRvbJZyypZZlbJzDh7FkE/ib9ukZ/peHUrQn7rrGP24knjdqAszb IR9hCCu60EImnnX/LEQGIPZpmBdcDBF7RgkrnpXk3jv4pRAehj+wuH1f7+s+5P5ldvI0 L3ln7KhfSrIq6GBCx5xerLAFr2xWlzfniKOqGX7EYJOWvfl3wxRyT2O1G2J5QJmhoVKt RMCrZMPNAOcG//XMVWgIat19D2PwgIgq70sOCSE4txSRCtxkAKYOI1Rn75JDlJ/bHniS zfMQHuvKFZ9qBBYsEQmyf1v5kLWDf48IhwOS9j1qc3TlCRyJ+Bne0iD0KL0TzEx5nMpV u2jQ== 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:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=b5OUwYC1ijM0U3q76fWa5pbJW4qjaynWy6iI0RpDBZA=; b=DpQ8nwyNl8wMhtU6Hlc2CSvvDdXq4geIsymxTwxAp2VzyUstmsM+e3jlQoH7q3Sb/u RZGzxFXYtxzSs08sBEytL46SFfcFkMKkYa6vYcSz2QnMvR8bqCaMckp+n/ob9r5QMiE7 XJ6ERdI92bL9kKG/z5LbhOVSexnps6WegQ30yqku2btGkP228jSUxTp1Gj5LVnb2nUvJ kHRID9pPRZ8evrGIfChfw3MHKjo5+Zc21v7VfvDE4WaIeHdwXzdH+4d/JRabHLokM6ap yz+SHEboZcH6/QVG7xBKO+jdYT7W4jq5vP644+KMrZSNk7ZoKpLRFOJqXyWlJKrgyqiT LlWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z34Qg9RJ; 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 o187si4386654ybb.475.2020.08.12.20.34.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 20:34:45 -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=Z34Qg9RJ; 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]:46584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k640r-0000OX-4T for patch@linaro.org; Wed, 12 Aug 2020 23:34:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k63sG-0004wk-UD for qemu-devel@nongnu.org; Wed, 12 Aug 2020 23:25:52 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:41904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k63sF-00008K-1I for qemu-devel@nongnu.org; Wed, 12 Aug 2020 23:25:52 -0400 Received: by mail-pl1-x641.google.com with SMTP id f10so2006232plj.8 for ; Wed, 12 Aug 2020 20:25:50 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=b5OUwYC1ijM0U3q76fWa5pbJW4qjaynWy6iI0RpDBZA=; b=Z34Qg9RJYkEGdiY8XgVqi5Rc5YXJmKhvp33kAxFpafyAZJcer9i6qQqe5bkcdo1123 wmcEValt0eaYNOsBVIPqFDALa7qXq8tCmde4lsGeALatZ4PgBJy83EpjMuTqugHAzZs9 EyOE7fz5CzRPvpLAeADS/lnTqHYuQANFitytZxK2BCQMuQhy1UezCPrO6/zkXKEZkBiv 9VIsXEIlKKsgC4M6AaLZ2dbff7QgakTa0rPqoSSG94yh8nuzbLlrGGB8TJsPPP2HjngJ RovYJHOMWgweqgiTIABSk8EF7F+ufVXFLkkgNPSr9z+Xf1GpVlXE5aDfjD658YQh5JJR kfQg== 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:mime-version:content-transfer-encoding; bh=b5OUwYC1ijM0U3q76fWa5pbJW4qjaynWy6iI0RpDBZA=; b=RJspRT5JKqytaFqqLHVq3PNMTxLANOFDl3R9/nrSIOu1Eksn3YC2RankJcArtf/+S4 7G6Sc2QlUpqHqUoZu6kTyCxWC6vzfOlhHq1sYS82GnCO09afc+56Bpb9/dNcgz6eflRS J5cAOTo2B0n7Chqi+tOfkaV6Y4jwS3EXgg3s0jmhpLchFTPneECSIlbRU+LniIdl52so p6RFLekBTJuO2br6nUmlMgecUuKyshl/a+7UDwoUoJ5ZDBuK8NScRiaVLhmCilW9a7/0 thDRtjTaXyHXMqKdjSh9NY4lBBLQwsuZcyootM2RR4v9OLDZ3ZmoM04sc5q3foDYhl/V eCGw== X-Gm-Message-State: AOAM531CYB/xZeNPi3Igl1Dt1azq2i3Um1vSvloUG8u02i2Oxm2wfmiL 3LKRjwQAlc35sNo1XPjOMTOfu9cc1SA= X-Received: by 2002:a17:90b:784:: with SMTP id l4mr2813640pjz.96.1597289149308; Wed, 12 Aug 2020 20:25:49 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id m19sm3633164pgd.21.2020.08.12.20.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2020 20:25:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/17] crypto: Use the correct const type for driver Date: Wed, 12 Aug 2020 20:25:27 -0700 Message-Id: <20200813032537.2888593-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200813032537.2888593-1-richard.henderson@linaro.org> References: <20200813032537.2888593-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x641.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" This allows the in memory structures to be read-only. Signed-off-by: Richard Henderson --- crypto/cipherpriv.h | 2 +- include/crypto/cipher.h | 2 +- crypto/cipher-afalg.c | 2 +- crypto/cipher-builtin.inc.c | 2 +- crypto/cipher-gcrypt.inc.c | 2 +- crypto/cipher-nettle.inc.c | 2 +- crypto/cipher.c | 12 ++++++------ 7 files changed, 12 insertions(+), 12 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé diff --git a/crypto/cipherpriv.h b/crypto/cipherpriv.h index 9228c9fc3a..b73be33bd2 100644 --- a/crypto/cipherpriv.h +++ b/crypto/cipherpriv.h @@ -47,7 +47,7 @@ qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgorithm alg, const uint8_t *key, size_t nkey, Error **errp); -extern struct QCryptoCipherDriver qcrypto_cipher_afalg_driver; +extern const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver; #endif diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index 95a0412911..022a8d1157 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -78,7 +78,7 @@ struct QCryptoCipher { QCryptoCipherAlgorithm alg; QCryptoCipherMode mode; void *opaque; - void *driver; + const QCryptoCipherDriver *driver; }; /** diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c index cd72284690..5c7c44761b 100644 --- a/crypto/cipher-afalg.c +++ b/crypto/cipher-afalg.c @@ -218,7 +218,7 @@ static void qcrypto_afalg_comm_ctx_free(QCryptoCipher *cipher) qcrypto_afalg_comm_free(cipher->opaque); } -struct QCryptoCipherDriver qcrypto_cipher_afalg_driver = { +const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver = { .cipher_encrypt = qcrypto_afalg_cipher_encrypt, .cipher_decrypt = qcrypto_afalg_cipher_decrypt, .cipher_setiv = qcrypto_afalg_cipher_setiv, diff --git a/crypto/cipher-builtin.inc.c b/crypto/cipher-builtin.inc.c index 56d45b0227..156f32f1c7 100644 --- a/crypto/cipher-builtin.inc.c +++ b/crypto/cipher-builtin.inc.c @@ -522,7 +522,7 @@ qcrypto_builtin_cipher_setiv(QCryptoCipher *cipher, } -static struct QCryptoCipherDriver qcrypto_cipher_lib_driver = { +static const struct QCryptoCipherDriver qcrypto_cipher_lib_driver = { .cipher_encrypt = qcrypto_builtin_cipher_encrypt, .cipher_decrypt = qcrypto_builtin_cipher_decrypt, .cipher_setiv = qcrypto_builtin_cipher_setiv, diff --git a/crypto/cipher-gcrypt.inc.c b/crypto/cipher-gcrypt.inc.c index a62839914b..18850fadb9 100644 --- a/crypto/cipher-gcrypt.inc.c +++ b/crypto/cipher-gcrypt.inc.c @@ -413,7 +413,7 @@ qcrypto_gcrypt_cipher_setiv(QCryptoCipher *cipher, } -static struct QCryptoCipherDriver qcrypto_cipher_lib_driver = { +static const struct QCryptoCipherDriver qcrypto_cipher_lib_driver = { .cipher_encrypt = qcrypto_gcrypt_cipher_encrypt, .cipher_decrypt = qcrypto_gcrypt_cipher_decrypt, .cipher_setiv = qcrypto_gcrypt_cipher_setiv, diff --git a/crypto/cipher-nettle.inc.c b/crypto/cipher-nettle.inc.c index 0404cfc6da..6ecce5e8ea 100644 --- a/crypto/cipher-nettle.inc.c +++ b/crypto/cipher-nettle.inc.c @@ -724,7 +724,7 @@ qcrypto_nettle_cipher_setiv(QCryptoCipher *cipher, } -static struct QCryptoCipherDriver qcrypto_cipher_lib_driver = { +static const struct QCryptoCipherDriver qcrypto_cipher_lib_driver = { .cipher_encrypt = qcrypto_nettle_cipher_encrypt, .cipher_decrypt = qcrypto_nettle_cipher_decrypt, .cipher_setiv = qcrypto_nettle_cipher_setiv, diff --git a/crypto/cipher.c b/crypto/cipher.c index deae82c264..d3ef856009 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c @@ -165,7 +165,7 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, { QCryptoCipher *cipher; void *ctx = NULL; - QCryptoCipherDriver *drv = NULL; + const QCryptoCipherDriver *drv = NULL; #ifdef CONFIG_AF_ALG ctx = qcrypto_afalg_cipher_ctx_new(alg, mode, key, nkey, NULL); @@ -187,7 +187,7 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, cipher->alg = alg; cipher->mode = mode; cipher->opaque = ctx; - cipher->driver = (void *)drv; + cipher->driver = drv; return cipher; } @@ -199,7 +199,7 @@ int qcrypto_cipher_encrypt(QCryptoCipher *cipher, size_t len, Error **errp) { - QCryptoCipherDriver *drv = cipher->driver; + const QCryptoCipherDriver *drv = cipher->driver; return drv->cipher_encrypt(cipher, in, out, len, errp); } @@ -210,7 +210,7 @@ int qcrypto_cipher_decrypt(QCryptoCipher *cipher, size_t len, Error **errp) { - QCryptoCipherDriver *drv = cipher->driver; + const QCryptoCipherDriver *drv = cipher->driver; return drv->cipher_decrypt(cipher, in, out, len, errp); } @@ -219,14 +219,14 @@ int qcrypto_cipher_setiv(QCryptoCipher *cipher, const uint8_t *iv, size_t niv, Error **errp) { - QCryptoCipherDriver *drv = cipher->driver; + const QCryptoCipherDriver *drv = cipher->driver; return drv->cipher_setiv(cipher, iv, niv, errp); } void qcrypto_cipher_free(QCryptoCipher *cipher) { - QCryptoCipherDriver *drv; + const QCryptoCipherDriver *drv; if (cipher) { drv = cipher->driver; drv->cipher_free(cipher);