From nobody Thu Nov 14 07:09:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632310575; cv=none; d=zohomail.com; s=zohoarc; b=XL0KubagclHgTb+LX3Yn0LSdUr7Mp5UwYLbHtviwvkkrldS5fGEnv9rLH9Dip0s+p2t70eF7nTLzHRqPUR8AvX1vPbpmLI1ECJHDpxlooRD+VYgBrdVJde9r89u9m5MUFniSltIJzDWf9iCbuE1euC2s+GSG5/qYtQiauRX1haM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632310575; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KNrnOuLZklH2L1bwTxJauREBPqntaVoNBRJET0za5kM=; b=Ej6f4N/LoLdfG+gTarUSxWb2aioFfoVSoXECLYsge22MAy2NBfvrhWDesmvPzZcN2CafqOlnpfagqPuBSNXbN+fM0x5DxPivqEZ/Cs/SaDLZhnKKjr73UszeggigQnwMrPXwmyNaVxbD7jQS8GrKOIrRzUOclsHd35uCMLVak+Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1632310575340902.9614429817108; Wed, 22 Sep 2021 04:36:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-rDUqxMrrMA-zyAvB6t5SZw-1; Wed, 22 Sep 2021 07:36:12 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1A2018D6A2C; Wed, 22 Sep 2021 11:36:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D17604EF71; Wed, 22 Sep 2021 11:36:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9B75A1806D03; Wed, 22 Sep 2021 11:36:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18MBZajY006618 for ; Wed, 22 Sep 2021 07:35:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D27E60843; Wed, 22 Sep 2021 11:35:36 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFD3160854 for ; Wed, 22 Sep 2021 11:35:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632310574; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=KNrnOuLZklH2L1bwTxJauREBPqntaVoNBRJET0za5kM=; b=YADaxQsz9dodMRpG9Ca+tbJMrnVJJCm8c2EnZbi/S7tn75uxk40GE1BGJnvz3Cj3Y7IbCA dGxEWrHxDdmXHoZMO+P4FJKyR3fE0su+zT3R4w3B6NEsP8ayvDg1vw6NvB0EDl/oJdI96j L5NKSCKo6qHOamifQxyRXhEqL88mzDM= X-MC-Unique: rDUqxMrrMA-zyAvB6t5SZw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/12] util: Remove use of virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC) Date: Wed, 22 Sep 2021 13:35:20 +0200 Message-Id: <3e138fba1aa1f9d784c88dcc6087b318612a61cc.1632310421.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632310576301100001 Content-Type: text/plain; charset="utf-8" It always returns true. Make the logic a bit simpler to see through. This completely removes 'virCryptoHaveCipher' as it's pointless in the current form. Signed-off-by: Peter Krempa --- src/libvirt_private.syms | 1 - src/qemu/qemu_domain.c | 3 +-- src/storage/storage_util.c | 6 ------ src/util/vircrypto.c | 27 --------------------------- src/util/vircrypto.h | 2 -- tests/vircryptotest.c | 5 ----- 6 files changed, 1 insertion(+), 43 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 25ee21463c..5e11eb1b5c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2092,7 +2092,6 @@ virConfWriteMem; virCryptoEncryptData; virCryptoHashBuf; virCryptoHashString; -virCryptoHaveCipher; # util/virdaemon.h diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5de7461fb3..0774374784 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1253,8 +1253,7 @@ qemuDomainSecretAESSetupFromSecret(qemuDomainObjPriva= te *priv, bool qemuDomainSupportsEncryptedSecret(qemuDomainObjPrivate *priv) { - return virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC) && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET) && + return virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET) && priv->masterKey; } diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 53792765ff..ce61f37172 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -839,12 +839,6 @@ storageBackendCreateQemuImgCheckEncryption(int format, _("no secret provided for luks encryption")); return -1; } - if (!virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("luks encryption usage requires encrypted " - "secret generation to be supported")); - return -1; - } } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("volume encryption unsupported with format %s"), = type); diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c index 78689721c3..23692d22fb 100644 --- a/src/util/vircrypto.c +++ b/src/util/vircrypto.c @@ -100,33 +100,6 @@ virCryptoHashString(virCryptoHash hash, } -/* virCryptoHaveCipher: - * @algorithm: Specific cipher algorithm desired - * - * Expected to be called prior to virCryptoEncryptData in order - * to determine whether the requested encryption option is available, - * so that "other" alternatives can be taken if the algorithm is - * not available. - * - * Returns true if we can support the encryption. - */ -bool -virCryptoHaveCipher(virCryptoCipher algorithm) -{ - switch (algorithm) { - - case VIR_CRYPTO_CIPHER_AES256CBC: - return true; - - case VIR_CRYPTO_CIPHER_NONE: - case VIR_CRYPTO_CIPHER_LAST: - break; - }; - - return false; -} - - /* virCryptoEncryptDataAESgntuls: * * Performs the AES gnutls encryption diff --git a/src/util/vircrypto.h b/src/util/vircrypto.h index bf002d42d5..5f079ac335 100644 --- a/src/util/vircrypto.h +++ b/src/util/vircrypto.h @@ -54,8 +54,6 @@ virCryptoHashString(virCryptoHash hash, ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) G_GNUC_WARN_UNUSED_RESULT; -bool virCryptoHaveCipher(virCryptoCipher algorithm); - int virCryptoEncryptData(virCryptoCipher algorithm, uint8_t *enckey, size_t enckeylen, uint8_t *iv, size_t ivlen, diff --git a/tests/vircryptotest.c b/tests/vircryptotest.c index 98af476156..9fbaf2f636 100644 --- a/tests/vircryptotest.c +++ b/tests/vircryptotest.c @@ -73,11 +73,6 @@ testCryptoEncrypt(const void *opaque) g_autofree uint8_t *ciphertext =3D NULL; size_t ciphertextlen =3D 0; - if (!virCryptoHaveCipher(data->algorithm)) { - fprintf(stderr, "cipher algorithm=3D%d unavailable\n", data->algor= ithm); - return EXIT_AM_SKIP; - } - enckey =3D g_new0(uint8_t, enckeylen); iv =3D g_new0(uint8_t, ivlen); --=20 2.31.1