From nobody Sun Nov 24 11:34:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873223; cv=pass; d=zohomail.com; s=zohoarc; b=ag61ZrbJbnz5z4t8kepxKPbT544r66ikTOA8TkFTUNpSLQ68yjZbuMdcXdRy4SBXZtP7NOoqAlLqwOCykqr8bOaqRyT508/KM9sk7zYFD8em5lLj/Er8jDXp6bMdbccumFDd+hO4JfJjdRxEhpzKl5wCNRa/Apouln9e981z+7A= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873223; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IGKj/vm5VdsgbSXJTTkUy/L/9ssTMA5Zoz3FbIxWQeU=; b=i8b4voGEft9LqQH7LhLMDAhzo+1UX3BCkm8ivSk8fgZLT2bC3ujIZNYWQ8l4m19Xngg+e5ENaQl80/92xHPz6PS45o3ftQEh1lk/7IZc5uw+eFNXV110Jb4moLBJD/bFhFq46Mt5nkUdJNQ4ZlXgebKZ2KmtslRWAt6ZAtRN5/k= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873223569964.4033435863761; Mon, 5 Aug 2024 08:53:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb014-0007fS-OV; Mon, 05 Aug 2024 11:52:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb013-0007aX-Es; Mon, 05 Aug 2024 11:52:57 -0400 Received: from esa.hc4959-67.iphmx.com ([216.71.153.94]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb010-0003nI-R9; Mon, 05 Aug 2024 11:52:57 -0400 Received: from mail-bn8nam12lp2174.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.174]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:52:51 -0700 Received: from MW4PR04CA0365.namprd04.prod.outlook.com (2603:10b6:303:81::10) by MN0PR20MB7481.namprd20.prod.outlook.com (2603:10b6:208:4c2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Mon, 5 Aug 2024 15:52:47 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::ea) by MW4PR04CA0365.outlook.office365.com (2603:10b6:303:81::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27 via Frontend Transport; Mon, 5 Aug 2024 15:52:47 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:52:47 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:57:39 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:52:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873174; x=1754409174; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mLxDUVpOD72dMtrEN1LwWCo/uWnU7WeHsiIaFqrm2VU=; b=pqeyBpT7nIC7OvoDsHqoBAzHTP1UcSYy0IWy0YR9yZwYfdqH6/bhj8mr SCYaUVa2peeaLpN+HFfKey6BVlq729xygtqdPLBgM2nqj4EiEnulIzWjr GxF0GNOYh23GumwJ90na42oZ5pFKAjslCNzpQhRCtMFuAIFBXL26r8G6h 4=; X-CSE-ConnectionGUID: Km7AlsdSTn+NLKtccXh1pg== X-CSE-MsgGUID: VMG18DEOR7+HcNTLXvnlYg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SiuxVWEsRSRqGkE01BDc2J73SzAbfZu0NcWtibfltwwodipPWKeWWi+4ScLp2bqwXLH9GPS6S7UzMyw/T2kzDfH8IgpNcx3zNYhakvoddvq3bBnb0hfWJzPdkFWzoaRVw52LxPwbEFo/ytnlMek1L8faBhsVsSV8qwXCuu2gG7xeveS2NXpFaznuzt5emC1OwnhbPCG7MXCrQKmeBXg6iogEwMgS2Bz2lt5l/VGurgDBSGSdLGnJH/JolyPsD/s5mooX15VRLSQw3NECQsVSP8WdlZQFr322w2CfPpt41ltZ1PaVDSvxhKaZblPFyhEpsw+xXPgukZ5LcMhR9KRGYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IGKj/vm5VdsgbSXJTTkUy/L/9ssTMA5Zoz3FbIxWQeU=; b=Gss10H1LLe5XTThKdJDakRor9GUDrSc2Flbzk0hnpnAh/Hy5AjExBRrvFO81pcvw4aYus/R6CBclNWo7Ynf8aIjRRCcZWI/+K8RAcsYfb6xALOWbut6gE2C8JB0f859oEtZXlrNTYv3pXgU66OyAY6Y7ziAf+gM1MJnQ+ZyF24McpwIurmoZtb1QgHmNvfWPt8Fy/TmNFh9C11Iy5011h9CxqFYh0fsdnN38cjyqHzUgg7ejq99woLz1Z9dh/GA+WtSffPR6bZpIsBUdOJLb0nA+kx3nNk+C/vSArF5lBG9ZeBDlZYV2b+awZV+rrK/W1NduPspYxGB/plP6lu1oXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IGKj/vm5VdsgbSXJTTkUy/L/9ssTMA5Zoz3FbIxWQeU=; b=NG/uEC5W7Y5qtOH1bRBemI4fssDZ2uND8h1Wg/rQFWt2D6ZcLkn9FPzmL3fzQ6JJAFkDt4yiC+i0J7ZXFPsq3R0KocUAYM230BYpdl0tKqarZgtMYK12Skn2pmHSmAqTTckpAvjN5MJbkCRiIRjMjaOylITQfu8KiJw1eB54GJY= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: lKM39m3kTKuySbtufaDxjA== X-CSE-MsgGUID: LN3HHDwJRnKnpRC2X81ddg== X-CSE-ConnectionGUID: b23P30nHQkC1FwhDesi6Ag== X-CSE-MsgGUID: fkLDhRTkThi4OgAnEDZTww== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920678" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 01/12] crypto: accumulative hashing API Date: Mon, 5 Aug 2024 15:50:36 +0000 Message-Id: <20240805155047.3151540-2-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|MN0PR20MB7481:EE_ X-MS-Office365-Filtering-Correlation-Id: 6315083b-6ac8-4d34-4e43-08dcb566a721 STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9Uw8RZBvN/KwxmYwevbM7st+RehenRBuOA/VnM6HTcD2JW4poyUhe4enBrTR?= =?us-ascii?Q?ZwRKFe4V/Man2lkULpJmwumjV1vb7emSo11oRDK4obVcsCRhE7P3QZ1gb9O/?= =?us-ascii?Q?Z6sLPP1hVTvJ0i2A3LqfpQFcZC1X1EBb9KeqjpLwSjHuYDuR98FTXM/KEMSn?= =?us-ascii?Q?9m5vPqMi4BN32aOVm3MV86LqDeIRx3Lmf9SDdVB7KJiSBIwpVa9etxUqiLxo?= =?us-ascii?Q?iN18d5D2kQSO/3KCyropXBE/BHg5o2sPto+XjrJzzLYkwUgwAtmToJFKd7Zs?= =?us-ascii?Q?yrCAA6PBWEDIddM2P7q2tSIlJy04KhDaf2Cgsn27Vc2wXTLoLCbgGkyQ8wVg?= =?us-ascii?Q?jfI4+BYU64nJq/P/i8mmixnEfyqnhOi5tvHChNsg2SvVECwJa0nDLVvLzMy0?= =?us-ascii?Q?5K4ycdageZXHte0mUpTi/PvhXf0bDWgMV1e3kZWmAsfTZKXTJW+Snmdgwguh?= =?us-ascii?Q?uoVheGAPjpBD+vIR0qtNKMbSrer66sUI4PojRUt+nYRGSYlCYzlH4vVnKYQn?= =?us-ascii?Q?BQ4WL4aI8L9oBfU2kV4U9X8qIjagiujU5k0jytswiqhfAjfFlCl1VP7h8Q7P?= =?us-ascii?Q?kCuk5SJvTZCiTMikFG5AAMGRDrCveRWRDXU4RwbBi74GGVPlmVxcAuyzjrla?= =?us-ascii?Q?2OLkgW36LCCQCPhjx4VwWxSoyRACM/SDyMgJiAFm0mdjdF+79xw4uwWpLmjk?= =?us-ascii?Q?LftOXhMJy8v1gyFmR7ttpHcmjwx4icqnlRARRLTAAd1YDoFxg9tf0VuHMGBC?= =?us-ascii?Q?KWyvrzZ9zRR/Ug0+h+UIJHkpXmHhAa4+yoMoldt9F7eur+X0vxJ4pameYWbb?= =?us-ascii?Q?EZE8K105HCbKUv4hziU1YEjiFnvPiQjq7Mv8uKc0vvq8QPh1q6Wta79com3u?= =?us-ascii?Q?ellnA5YCfYtZd0jPi09SA6ehIUavzf6DfiVx3fd4zL1uy18I6Gj2KY46RlBJ?= =?us-ascii?Q?pFfbuibUo/tR9vp60sLrqj4PONJWlOgCJ9HmbqdX5/C4Yfn7BZXakDFomRT7?= =?us-ascii?Q?vQhRopcKRcQ58AEVV4q9O9x8bUYgzO9P8Jh3veVQfmx1CPM+RTlbegVDDxgg?= =?us-ascii?Q?K+Rln0D7Tj49I/x7leVLpbHdjlH3J58s5ajAbl7vDM4D6/qPOecGg+oH0ARU?= =?us-ascii?Q?Zt6Ms3gkL9scJepuvXq3iufpbU5+W7T0M2h7yBXq3MVQydkgD6fDd3xcl9f+?= =?us-ascii?Q?4VKEtX/rViAyh4knr/T7e5jsVn2Flj2zbodD+znpQSBmN9woctU2QLVb5sFU?= =?us-ascii?Q?djhzzkUOWf6In7PhMhwU9OQ1eWOydfXpJKgz/RbSvfbrwNuYY8OFbCoKj7Ea?= =?us-ascii?Q?HFgsNwYrSTC4HxIg/a7IGe4vqvvlXCy+WCi/z8//YPdYcxXRu2gFjtC5BpXf?= =?us-ascii?Q?D6KIXp+VbgY/xbfMeklgkRBgU2jD3fZ6RyoNhe90zaD/PT5qxd403c/I0RRz?= =?us-ascii?Q?oATBIkM9GlgF9Nc3XsS0UmoBWPGDudQA?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5hXara1XEAA92fxccxJEFXCv0AoHPaIt6CHfuafjbFzoS54qN/8HlDpZZAnz0gzMCbavh7sleBqm/22luWJS8aHystNFjAFqkbF/3yCv4lwif7HF1jjlxaIev2fKH0hvvqIuJEKHB9spawkCkCqMGDDpAQ2t3HXijOVD1K5gNUUSGmtrGqt5qJHyyf47NFYnPoeg7QeqX8luapS/c7MT1BxRqK6bsUHi1ns/JeYeXz+2sqSvvB4PiXqEDOMJFrk7u3D1G+S3OQLUNe1uUj00C6CvGHPVL0lwnGwgRw/m/TbiFvXr0myPgJs/agywhyf3ddHR3VApmcirQAxPYY1KzCD4Bhl9zU4aTcyNqC34mZF+iYb79csG/K89RbJMtWMyx0WLGMpLvR4/hMq7bOzmP1mY4p8bNFqX297jWxN+Sn4zaQXBbwthLzc9/poEV735ogeMLpJ166kaBrGF8eIsuS5lObKLI1u59lMsuigwPfUbdnJT1351R8i49uvWB+5b+ripAFKeAal0N3ADtGZz+mKnKSb3PgXtNAvcX7hjCrIsP7Jf98q9XJYRcQAleO6sREYSnyjhNKw4CKfvatgDu+GEKeXRqiPbms8SVYFYH40dW8W+IzInLy0vw1r9gkBs X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:52:47.1287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6315083b-6ac8-4d34-4e43-08dcb566a721 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR20MB7481 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.94; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873225416116600 Content-Type: text/plain; charset="utf-8" Changes the hash API to support accumulative hashing. Hash objects are created with "qcrypto_hash_new", updated with data with "qcrypto_hash_update", and the hash obtained with "qcrypto_hash_finalize". These changes bring the hashing API more in line with the hmac API. Signed-off-by: Alejandro Zeise --- crypto/hash.c | 136 +++++++++++++++++++++++++++++++----------- crypto/hashpriv.h | 19 ++++-- include/crypto/hash.h | 106 ++++++++++++++++++++++++++++++++ 3 files changed, 220 insertions(+), 41 deletions(-) diff --git a/crypto/hash.c b/crypto/hash.c index b0f8228bdc..5c60973bde 100644 --- a/crypto/hash.c +++ b/crypto/hash.c @@ -1,6 +1,7 @@ /* * QEMU Crypto hash algorithms * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (c) 2015 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -45,23 +46,20 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, size_t *resultlen, Error **errp) { -#ifdef CONFIG_AF_ALG - int ret; - /* - * TODO: - * Maybe we should treat some afalg errors as fatal - */ - ret =3D qcrypto_hash_afalg_driver.hash_bytesv(alg, iov, niov, - result, resultlen, - NULL); - if (ret =3D=3D 0) { - return ret; + int fail; + QCryptoHash *ctx =3D qcrypto_hash_new(alg, errp); + + if (ctx) { + fail =3D qcrypto_hash_update(ctx, iov, niov, errp) || + qcrypto_hash_finalize_bytes(ctx, result, resultlen, errp); + + /* Ensure context is always freed regardless of error */ + fail =3D qcrypto_hash_free(ctx) || fail; + } else { + fail =3D -1; } -#endif =20 - return qcrypto_hash_lib_driver.hash_bytesv(alg, iov, niov, - result, resultlen, - errp); + return fail; } =20 =20 @@ -77,30 +75,94 @@ int qcrypto_hash_bytes(QCryptoHashAlgorithm alg, return qcrypto_hash_bytesv(alg, &iov, 1, result, resultlen, errp); } =20 +int qcrypto_hash_update(QCryptoHash *hash, + const struct iovec *iov, + size_t niov, + Error **errp) +{ + return qcrypto_hash_lib_driver.hash_update(hash, iov, niov, errp); +} + +QCryptoHash *qcrypto_hash_new(QCryptoHashAlgorithm alg, Error **errp) +{ + return qcrypto_hash_lib_driver.hash_new(alg, errp); +} + +int qcrypto_hash_free(QCryptoHash *hash) +{ + return qcrypto_hash_lib_driver.hash_free(hash); +} + +int qcrypto_hash_finalize_bytes(QCryptoHash *hash, + uint8_t **result, + size_t *result_len, + Error **errp) +{ + return qcrypto_hash_lib_driver.hash_finalize(hash, result, result_len,= errp); +} + static const char hex[] =3D "0123456789abcdef"; =20 +int qcrypto_hash_finalize_digest(QCryptoHash *hash, + char **digest, + Error **errp) +{ + int ret; + uint8_t *result =3D NULL; + size_t resultlen =3D 0; + size_t i; + + ret =3D qcrypto_hash_finalize_bytes(hash, &result, &resultlen, errp); + if (ret =3D=3D 0) { + *digest =3D g_new0(char, (resultlen * 2) + 1); + for (i =3D 0 ; i < resultlen ; i++) { + (*digest)[(i * 2)] =3D hex[(result[i] >> 4) & 0xf]; + (*digest)[(i * 2) + 1] =3D hex[result[i] & 0xf]; + } + (*digest)[resultlen * 2] =3D '\0'; + g_free(result); + } + + return ret; +} + +int qcrypto_hash_finalize_base64(QCryptoHash *hash, + char **base64, + Error **errp) +{ + int ret; + uint8_t *result =3D NULL; + size_t resultlen =3D 0; + + ret =3D qcrypto_hash_finalize_bytes(hash, &result, &resultlen, errp); + if (ret =3D=3D 0) { + *base64 =3D g_base64_encode(result, resultlen); + g_free(result); + } + + return ret; +} + int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, const struct iovec *iov, size_t niov, char **digest, Error **errp) { - uint8_t *result =3D NULL; - size_t resultlen =3D 0; - size_t i; + bool fail; + QCryptoHash *ctx =3D qcrypto_hash_new(alg, errp); =20 - if (qcrypto_hash_bytesv(alg, iov, niov, &result, &resultlen, errp) < 0= ) { - return -1; - } + if (ctx) { + fail =3D qcrypto_hash_update(ctx, iov, niov, errp) || + qcrypto_hash_finalize_digest(ctx, digest, errp); =20 - *digest =3D g_new0(char, (resultlen * 2) + 1); - for (i =3D 0 ; i < resultlen ; i++) { - (*digest)[(i * 2)] =3D hex[(result[i] >> 4) & 0xf]; - (*digest)[(i * 2) + 1] =3D hex[result[i] & 0xf]; + /* Ensure context is always freed regardless of error */ + fail =3D qcrypto_hash_free(ctx) || fail; + } else { + fail =3D false; } - (*digest)[resultlen * 2] =3D '\0'; - g_free(result); - return 0; + + return fail; } =20 int qcrypto_hash_digest(QCryptoHashAlgorithm alg, @@ -120,16 +182,20 @@ int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, char **base64, Error **errp) { - uint8_t *result =3D NULL; - size_t resultlen =3D 0; + bool fail; + QCryptoHash *ctx =3D qcrypto_hash_new(alg, errp); + + if (ctx) { + fail =3D qcrypto_hash_update(ctx, iov, niov, errp) || + qcrypto_hash_finalize_base64(ctx, base64, errp); =20 - if (qcrypto_hash_bytesv(alg, iov, niov, &result, &resultlen, errp) < 0= ) { - return -1; + /* Ensure context is always freed regardless of error */ + fail =3D qcrypto_hash_free(ctx) || fail; + } else { + fail =3D 1; } =20 - *base64 =3D g_base64_encode(result, resultlen); - g_free(result); - return 0; + return fail; } =20 int qcrypto_hash_base64(QCryptoHashAlgorithm alg, diff --git a/crypto/hashpriv.h b/crypto/hashpriv.h index cee26ccb47..8a7d80619e 100644 --- a/crypto/hashpriv.h +++ b/crypto/hashpriv.h @@ -1,6 +1,7 @@ /* * QEMU Crypto hash driver supports * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (c) 2017 HUAWEI TECHNOLOGIES CO., LTD. * * Authors: @@ -15,15 +16,21 @@ #ifndef QCRYPTO_HASHPRIV_H #define QCRYPTO_HASHPRIV_H =20 +#include "crypto/hash.h" + typedef struct QCryptoHashDriver QCryptoHashDriver; =20 struct QCryptoHashDriver { - int (*hash_bytesv)(QCryptoHashAlgorithm alg, - const struct iovec *iov, - size_t niov, - uint8_t **result, - size_t *resultlen, - Error **errp); + QCryptoHash *(*hash_new)(QCryptoHashAlgorithm alg, Error **errp); + int (*hash_update)(QCryptoHash *hash, + const struct iovec *iov, + size_t niov, + Error **errp); + int (*hash_finalize)(QCryptoHash *hash, + uint8_t **result, + size_t *resultlen, + Error **errp); + int (*hash_free)(QCryptoHash *hash); }; =20 extern QCryptoHashDriver qcrypto_hash_lib_driver; diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 54d87aa2a1..96d080eeb5 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -1,6 +1,7 @@ /* * QEMU Crypto hash algorithms * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (c) 2015 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -25,6 +26,13 @@ =20 /* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */ =20 +typedef struct QCryptoHash QCryptoHash; +struct QCryptoHash { + QCryptoHashAlgorithm alg; + void *opaque; + void *driver; +}; + /** * qcrypto_hash_supports: * @alg: the hash algorithm @@ -120,6 +128,102 @@ int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, char **digest, Error **errp); =20 +/** + * qcrypto_hash_update: + * @hash: hash object from qcrypto_hash_new + * @iov: the array of memory regions to hash + * @niov: the length of @iov + * @errp: pointer to a NULL-initialized error object + * + * Updates the given hash object with all the memory regions + * present in @iov. + * + * Returns: 0 on success, -1 on error + */ +int qcrypto_hash_update(QCryptoHash *hash, + const struct iovec *iov, + size_t niov, + Error **errp); + +/** + * qcrypto_hash_finalize_digest: + * @hash: the hash object to finalize + * @digest: pointer to hold output hash + * @errp: pointer to a NULL-initialized error object + * + * Computes the hash from the given hash object. Hash object + * is expected to have its data updated from the qcrypto_hash_update funct= ion. + * The @digest pointer will be filled with the printable hex digest of the + * computed hash, which will be terminated by '\0'. The memory pointer + * in @digest must be released with a call to g_free() when + * no longer required. + * + * Returns: 0 on success, -1 on error + */ +int qcrypto_hash_finalize_digest(QCryptoHash *hash, + char **digest, + Error **errp); + +/** + * qcrypto_hash_finalize_base64: + * @hash_ctx: hash object to finalize + * @base64: pointer to store the hash result in + * @errp: pointer to a NULL-initialized error object + * + * Computes the hash from the given hash object. Hash object + * is expected to have it's data updated from the qcrypto_hash_update func= tion. + * The @base64 pointer will be filled with the base64 encoding of the comp= uted + * hash, which will be terminated by '\0'. The memory pointer in @base64 + * must be released with a call to g_free() when no longer required. + * + * Returns: 0 on success, -1 on error + */ +int qcrypto_hash_finalize_base64(QCryptoHash *hash, + char **base64, + Error **errp); + +/** + * qcrypto_hash_finalize_bytes: + * @hash_ctx: hash object to finalize + * @result: pointer to store the hash result in + * @result_len: Pointer to store the length of the result in + * @errp: pointer to a NULL-initialized error object + * + * Computes the hash from the given hash object. Hash object + * is expected to have it's data updated from the qcrypto_hash_update func= tion. + * The memory pointer in @result must be released with a call to g_free() + * when no longer required. + * + * Returns: 0 on success, -1 on error + */ +int qcrypto_hash_finalize_bytes(QCryptoHash *hash, + uint8_t **result, + size_t *result_len, + Error **errp); + +/** + * qcrypto_hash_new: + * @alg: the hash algorithm + * @errp: pointer to a NULL-initialized error object + * + * Creates a new hashing context for the chosen algorithm for + * usage with qcrypto_hash_update. + * + * Returns: New hash object with the given algorithm + */ +QCryptoHash *qcrypto_hash_new(QCryptoHashAlgorithm alg, + Error **errp); + +/** + * qcrypto_hash_free: + * @hash: hash object to free + * + * Frees a hashing context for the chosen algorithm. + * + * Returns: 0 on success, -1 on error + */ +int qcrypto_hash_free(QCryptoHash *hash); + /** * qcrypto_hash_digest: * @alg: the hash algorithm --=20 2.34.1 From nobody Sun Nov 24 11:34:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873223; cv=pass; d=zohomail.com; s=zohoarc; b=HPvQ8gGUv8M5V+Y4Fo4pLqTBXED/yeh1DQHVAIU6ZwBhwgRCT+upnjfn4MNixV91qEOUtrA/M8vjtK4EthuyA9t35ZX2iBtQ21fjayR04l6ziqgPOuzwV7gRLoqOpPZskOCrk4Ott9JpRCjWZkcAZXFIZ91XxPPzwtv5FB38k+g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873223; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VuIWH7hKv3rHqAI1K7OylgWYSlekB1h/ulCjPBW4OZo=; b=AEuyULkN4Oc4HjYGc1TbovB3S2b7EX/5ofOWModsa+qO4xjmV+NgYjp24zUgccKtjSiMjdsKuScBgP72TvKW+h5ikEcJzRUReP6x3YLr8ASfWkgteKc7cv3ko3eFxR3loMutRPL1SWAekVV+LgNmerqRheUEqhovOkdmhq9iqic= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873223580935.983597328503; Mon, 5 Aug 2024 08:53:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb017-0007rf-VS; Mon, 05 Aug 2024 11:53:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb015-0007j7-Ik; Mon, 05 Aug 2024 11:52:59 -0400 Received: from esa.hc4959-67.iphmx.com ([216.71.153.94]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb013-0003o3-QP; Mon, 05 Aug 2024 11:52:59 -0400 Received: from mail-co1nam11lp2168.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.168]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:52:55 -0700 Received: from MW4PR04CA0363.namprd04.prod.outlook.com (2603:10b6:303:81::8) by DM4PR20MB4968.namprd20.prod.outlook.com (2603:10b6:8:8a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 15:52:53 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::f1) by MW4PR04CA0363.outlook.office365.com (2603:10b6:303:81::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26 via Frontend Transport; Mon, 5 Aug 2024 15:52:53 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:52:52 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:57:44 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:52:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873177; x=1754409177; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yBUuwYe1RumimG7s1APfwYRTHe2/dVbSy6IAO5eoAGs=; b=Dy8tka0Yc8TUMVLRbN66boWM2Yo+2+kRJyR3aQAfdUJQa1Ah1r3HwVA/ MeRBQWejV937kl9zti3cBj0vy0C9nsAFDYs4z11jxhh5/TwzQiTkrXC1d E3f6z3zq4DJXtMIkergcxEde+0a4qlebvk0CXzQ7Qdb5Qmmz6IsH0lGhO Y=; X-CSE-ConnectionGUID: wX//03nyTlGTJ9S7RMqhZA== X-CSE-MsgGUID: GPR/6rbZTmOuE5pty/NrWA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N+aMH8XaDttC6/X9mQAYLcsmF2Gbq/SGjA1o9E7W08CUdGZP9BBC/ZckToGrhASytVihDqNBgCj8sLGiWj/z8/9J+23HO+xj9QWSoQeP9lJqRuQAswOoya1GNdSzApUknFvsa+nLiOtKHIDekQTLKGPMri0CfHNUT8ZE/SRz0vsIhpjZ49OpONYn05bDPU9iURNF7bIB8OsQzeR/+VaNaTPCJAm53CKQMbA/pBxZrJ8ZhO0UUZrIKuUWqA2hqx2/zPLqsV5OPRqFzi3C6VIDYiYJb/n579kD4PR0NEPsIkcTTWfXGEL2ltlfEHj0BE0sX3LpvFlCGw7hG6VaCM+nng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VuIWH7hKv3rHqAI1K7OylgWYSlekB1h/ulCjPBW4OZo=; b=vtZOWCx1T87W0WoqI0hNjwb5P/4KF7A7NLhp0SQIA1pstmCaiS6yTc4w2bsrulykmmmmrALYaZ0GYb4yUA84UyVwcD8S+0Ku4EDRBkx2pj1HFZlPTl9g7GC4HQpALbdhCL/m/WVfvCvgJ+0vcgGosTCahc5nbRGf4WbDbIh15TbHZ8fIGNKzTt76hv0FLoOeJLReZzfwLDiz7d6aWFGV1Ay+cDMsr2maxPigYZU7fPtqccelYRClAqqGHDT5c1RhDnm/HyVeQ1OIgAyCTuJ1LbociCdfI133SN4RpmuWKca4jJaLasjgtVMd5wah4W5aqBZ3x+LV7Mvot9g4g6PN5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VuIWH7hKv3rHqAI1K7OylgWYSlekB1h/ulCjPBW4OZo=; b=FpoZC6a7khV+1V/o+0VUelX1wLyb8oDbhshmeRb7q1OJzniM4irDqllEeyMnPLwQMde/XYT2cf6krDFM+EJi/9nky88Rb1zNGZj/hyFHl6SmYsnQNzKKPLqu9hhUIfleao3G4j4axA5lCFSIdb2LGEe3QU5Wc2VVjg2/9N2riug= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: NSBIonBsQFCkh9H4MlTsdg== X-CSE-MsgGUID: yR2Yd2e/Rr241zJRAlRhuA== X-CSE-ConnectionGUID: 3VAPqAfBT+ersI21d+pulg== X-CSE-MsgGUID: mjHBWRNqQDKi4vRROOg+lg== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920681" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 02/12] crypto/hash-glib: Remove old hash API implementation Date: Mon, 5 Aug 2024 15:50:37 +0000 Message-Id: <20240805155047.3151540-3-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|DM4PR20MB4968:EE_ X-MS-Office365-Filtering-Correlation-Id: 51303e72-7571-46a7-d8d1-08dcb566aa76 STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NN3geoq9ZSq1gbi/6D8ZNs7W8IPjlXuXYUK1Kip2jPTJ6nsGOrgmIgXhTQI+?= =?us-ascii?Q?L/B+eeWR2Ee6LyhhJCou2tMCYOdsUkJ4NQ5SIUYL1SyJZ4MpalIix79mF7d4?= =?us-ascii?Q?6N2wid6Ip6xfc7zC8sQtZBlje4EasTZkubvY231OgdWqd/74iUbak1JOVRLe?= =?us-ascii?Q?OsNoo7fIxjc+X/NtpbGf6KFtGS/6xPG+lvOnzivA4rX8/OXw63GbvhPlT0C7?= =?us-ascii?Q?VcxmR+QZs1oJz54ALzABGhcnZTwXiV+4z7Tl3UjppyVE16ee5PAQ+jm46hLk?= =?us-ascii?Q?JP2lY+RIycM61KTEST14AZQvRzRFhL1feMXkobofpMu1Obj3VtkbYVZHuZ9c?= =?us-ascii?Q?HZSImbBe2u/ms+QEv49rFLvhHJwRAemSuLpuK9SteUwWjTPebzors0/gJGxt?= =?us-ascii?Q?FIt9zApIZzDHCLExmBjPirO+Q7ZdnFrEsiqZls5s6OWewUD/Q6N40+OrGRi4?= =?us-ascii?Q?CFJ7b7xnliJygO0c2+hPaaxrPDoQrX5lWv8DQxtP6TuCtFPt1MqWy8deh7hL?= =?us-ascii?Q?NbzXHg8Jy6zr/XHfI1YCIwdfw7ZxAPmyixzQJIXDJdt2PNTYD/SpHfolNNTq?= =?us-ascii?Q?sLd7bs3QSVzpqElUBqDiVnLP0aa8Ggc+zXl8WybputiRjcNfoYXrZZBFrK3z?= =?us-ascii?Q?dqqPyw51WeBytgNxsuu4JIRiozIAzK/o4Je0zuyqFr5jFH1aNXF/RHxiDDRq?= =?us-ascii?Q?rF701lXkYQgWzHZiny5aZ+gUmc/QAvD6w8/zf+EKZG9YcRs/DFFe+4hSMsAm?= =?us-ascii?Q?hR8hhK1mSzDy+uKom1nRCeX+dpa3rsHJ0JLuEKZ8rUr8hPE2JnfHX6igbBqg?= =?us-ascii?Q?i9cF+RRdm3nctOSkLT4SaSbfqVSybEuZQi/wWhkZSggzeV4zuXmeujsrfTHx?= =?us-ascii?Q?gs1k9b67hJTwfok3Z2pM2K+iW4tJ3r9seVXArCRHm5iTSVcdc/3KYGYuaL69?= =?us-ascii?Q?CPYn22DEvW1a35wJXsyMrPjtCV6U2Z7c5O4/LOu+VojMN3LhdpilL3QsJwiI?= =?us-ascii?Q?GV6ll0artQspyYpLe5mP9D31/H+FEaBtwGGmlkqSxaQDhRS8ecsVuwvcln0S?= =?us-ascii?Q?DKz/ENpTTtZAGsQMvcL4PF2htNWhd8IxL24pgFAeEaBqseo4j4+LhKv+8d3J?= =?us-ascii?Q?QTUgz//o/3ohPCH4uTeJAbmikDTgxiZXnS8F60D36JePkeVwc0jqVDUhbgYC?= =?us-ascii?Q?0eLf9oHO5bRmH94t2zdFITUyxNWJtVVKwSskSoOr1E1es9bKmcbOhHCsyy4Y?= =?us-ascii?Q?PodG+ucyMYZamyxQn+w+uAngTXfFr0u3X1wJtdQV8ORYeyRUU+HMlPmMI98Y?= =?us-ascii?Q?3qlol/JIKvwCvZNWOO6tPTDeMiogPKNs0JekGO3uJaBA9JZfEd8iuuEMShe1?= =?us-ascii?Q?gqrM9pJjMpZMofMNJwVWgMcJ2nTeWw/JDzcpWPolYTaFt8r7JDVbN7MXgLD3?= =?us-ascii?Q?ukH65LbKyIflQC1VwU683OfZkoDGDEK5?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +KVWFSuiKDhInNdSUQXxCeSwUOGXJBM5CAjwwmq3ofp5zSplQaAuXFizRv7eMJnNMW/KI02JJM1AOFzViEFriFAFkbi9+iPpffOAoCry118o5wfhh9dj2Pi9ZpjZhvPNs3jogkq9sfkLYfwrkv3l5tAAMPUyXTA8i/TdmVZO/sPsyf+rVSihlmFJq7HIXlMaIX77NusW3nGIPZvvm35hj5VDQJF8u52QY78OJgdBjet5IsCIKLQ9u/mIAD20n1Gd4li6DILmXgKExg7rA01lBZURF8yEoqjQa8fKaid0CKMmbo80euZd+gWkdwA/5WUbieN9O4mw/ubeRcopg6eymgW+4zVvyvhwIkbRc3ik+6VvEsTiekQif1GkMqhPMaA6lelhfL1sRFxd2fR5lmN2FSrEUybbUC9rQc6ZwqVzUm9TTWV5+fdbq8npipDp4LwTHsgD84RYI+5R1MLD/DFVN40q3Rc38B1L5uK92zdL0F2iup197+5tQWDHWg1SbFsAnfku42RDEpT8QRA7ChpFfm8WpSB3vB92/han6UxmRtCJgb85bfb+ndWaRfgzgJ4qpUOeYFCHNLsaYh8wq1RvnMwof2caaF+R1uktl+eIQujBLrJC7CETcApaysilYlzq X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:52:52.5662 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51303e72-7571-46a7-d8d1-08dcb566aa76 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR20MB4968 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.94; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873225370116600 Content-Type: text/plain; charset="utf-8" Removes old implemention in the GLib hash driver. Will be replaced with a new implementation in accordance with the accumulative hashing changes in the patch series. Signed-off-by: Alejandro Zeise --- crypto/hash-glib.c | 53 ++-------------------------------------------- 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/crypto/hash-glib.c b/crypto/hash-glib.c index 82de9db705..ceaf346bf4 100644 --- a/crypto/hash-glib.c +++ b/crypto/hash-glib.c @@ -1,6 +1,7 @@ /* * QEMU Crypto hash algorithms * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (c) 2016 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -44,57 +45,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) } =20 =20 -static int -qcrypto_glib_hash_bytesv(QCryptoHashAlgorithm alg, - const struct iovec *iov, - size_t niov, - uint8_t **result, - size_t *resultlen, - Error **errp) -{ - int i, ret; - GChecksum *cs; - - if (!qcrypto_hash_supports(alg)) { - error_setg(errp, - "Unknown hash algorithm %d", - alg); - return -1; - } - - cs =3D g_checksum_new(qcrypto_hash_alg_map[alg]); - - for (i =3D 0; i < niov; i++) { - g_checksum_update(cs, iov[i].iov_base, iov[i].iov_len); - } - - ret =3D g_checksum_type_get_length(qcrypto_hash_alg_map[alg]); - if (ret < 0) { - error_setg(errp, "%s", - "Unable to get hash length"); - goto error; - } - if (*resultlen =3D=3D 0) { - *resultlen =3D ret; - *result =3D g_new0(uint8_t, *resultlen); - } else if (*resultlen !=3D ret) { - error_setg(errp, - "Result buffer size %zu is smaller than hash %d", - *resultlen, ret); - goto error; - } - - g_checksum_get_digest(cs, *result, resultlen); - - g_checksum_free(cs); - return 0; - - error: - g_checksum_free(cs); - return -1; -} - =20 QCryptoHashDriver qcrypto_hash_lib_driver =3D { - .hash_bytesv =3D qcrypto_glib_hash_bytesv, + }; --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873262; cv=pass; d=zohomail.com; s=zohoarc; b=h3otnwSMv/i8jtecF66qmDA1P6BEBBTjA+c4ikNCwt+2V42znHe/HWQRAAWZIjiL0G/3z4fhpBaDjYafrBtO9Ka4g3evsmNkhHNx0pDAo6paS8gr4R3grf0PElAYoHA2uMhjfbqs0t8aZFjLRtsOrjTD8aB/mhw/kBEKG/OFG7Q= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873262; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8QnmxkisCJ3tPcdaBGlITNYpaZwMJE+YupEMRQOuu/c=; b=dyMrdz4yPS28lhehRnhc+0w8cm4De000y96LCOtS9CtIh5tszJ6bZXP1Bs5jc6flbMyVjBqxdTHRNM/k68dQptnBbWEyceJv6ODa4AMaHqSZgBWK0xe8wfqXB8VykwuHoeg9EvknXpi1KMgVnjNTcCe8OIG2DRQIMXBAAQnX7gs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17228732623763.4387938658364874; Mon, 5 Aug 2024 08:54:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb01I-0008Eu-Eh; Mon, 05 Aug 2024 11:53:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01F-0008Bj-VM; Mon, 05 Aug 2024 11:53:10 -0400 Received: from esa.hc4959-67.iphmx.com ([139.138.35.140]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01C-0003pY-Dl; Mon, 05 Aug 2024 11:53:09 -0400 Received: from mail-dm6nam11lp2169.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.169]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:01 -0700 Received: from MW4PR04CA0383.namprd04.prod.outlook.com (2603:10b6:303:81::28) by DM4PR20MB4579.namprd20.prod.outlook.com (2603:10b6:8:5e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 15:52:58 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::2b) by MW4PR04CA0383.outlook.office365.com (2603:10b6:303:81::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27 via Frontend Transport; Mon, 5 Aug 2024 15:52:58 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:52:57 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:57:50 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:52:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873187; x=1754409187; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BOMcdhRBx+MFyzW9CBapslGt3DO6QxFzCCuTSIRWGKo=; b=iqTMwAPBWwNPoy1il/COlHBMsKdQZbGxs0pN/+8mtaSzT7TcoFTLB9vi redQ+iDs5EKdzuH8WjxqgJa6Emdp2ck0PTnpxSP3OwSTBiylUVJNddHL5 illtzj4QJZqFXlgQf5E7x5B/lRpbNRaQ7+ceqQQZZdfo/8DNCvPWVAMaE w=; X-CSE-ConnectionGUID: 5zhk4DCDQO+c+R7+COU5WQ== X-CSE-MsgGUID: dK8mxXLbRIOZcyLg3SuqCg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aPtRJogdr4+ysus0cgcV7ibX90xhQf4yHl5vogW6II5vxUnszoWGNNaos/T8WW3AsqPXePB7JHDVhfprxLXa8BJIxgMOdF9pbNPYp9rOLcfeI4uRHZ/aaDJcDtGYVsejgDH+Ud3mE9OpkZdD3kJDamDqlYPDjhFLdau0cznl6EgOdzwqO5E2QSD05JTwxsT7f5BIlNDvMJAaDNwp0+lOf88OAwUFsepxSiY41C65j11gE6MItWvLjh36OZ5Ht6jFKyexDX0WB0sbTKlvc3AsMNylmc0GVzduq9FlxqmDLuUc3Z8VSwDqToTDyYozVG64gDwjTfhuzIPMyKbae3rusA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8QnmxkisCJ3tPcdaBGlITNYpaZwMJE+YupEMRQOuu/c=; b=KtnT8awjHCWzAUwHiigdZvadeg20NZS+1PuxJMjB10ah2hwB7RiqXEoa7UkhzSOICmrl0VayedEHMMGn7EUL+X7A33dPq0Pt3A5kq9ZGYu5nskubXu5HrytRKg1wq9jprhnelQOm4Vu16uQ3pZKVQj+po0A9iqN13Q9r6CIzL8gsD1nwUB0LoV5KDnmtz1NIi+Qtxdv6kEk0FLpl4f4Inwe+ekY/U9Q6QCtn6N++P+oUKXCVQZ65thi3vGjiyyKzd5YwDNZZr6QTHtXEima3tIWq/5HUOk3RxtCUok2k/JIwLoZrH47OuPT/6ZABd9btBVOpvHqtHud3h6t+8Tt02g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8QnmxkisCJ3tPcdaBGlITNYpaZwMJE+YupEMRQOuu/c=; b=Bu3z7a08nU+PoBk4cnXx7LfpaOzoU8+uD9UkUCtt94VkFuHh5O4AWTYyUpOAcdv+WgBP5xHxS+RAvh3MDccR8ozNe1yewZ5kcxhHQHM3+7YITolEHXYxs+BYqVVQ76bnc9ESfU8aKLTNVwLaRE6XU8yPsO63dgjbRDQtXdUISdM= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: VTfTjCF+Syy/Qnad6JJfVA== X-CSE-MsgGUID: 9JYVQX2jTwuAFbGaXaTAAA== X-CSE-ConnectionGUID: 8AE/t9PjSWKZJ7uJpj9S2Q== X-CSE-MsgGUID: cYiHsETSQGSMr1PgvrGyoA== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920684" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 03/12] crypto/hash-glib: Implement new hash API Date: Mon, 5 Aug 2024 15:50:38 +0000 Message-Id: <20240805155047.3151540-4-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|DM4PR20MB4579:EE_ X-MS-Office365-Filtering-Correlation-Id: 515dbe6d-c015-4137-3d71-08dcb566ada6 STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wETu6vT2jRLlhfNfZruOZaQ4ttzS6WbOY8qsMAf2PLdvJcVFWia0J4EjJHFp?= =?us-ascii?Q?lzzn6JfVWuEFFELhS4T8e8G2Xz5Ek9QtgKbF4wxT3u87F9I3UG2hsulW3jnT?= =?us-ascii?Q?9nsvh0S8It1hXiDf5Mfqz4OAizWcDA3iyNhfbDvSbZ8KIdbqzP1kNMMtQJqe?= =?us-ascii?Q?EfsyPlBJig4k7uyp51s3PQWfMm7LR4y5dX/D4YKPh0Z+BjJjtEF5oH27KWPO?= =?us-ascii?Q?C9su8pQUUpo79qiMyh3ID/oaljQdXzjasCb/n4R1Bba2AF9eh9PNoTyPBvQF?= =?us-ascii?Q?i4oY7ntE75ed00dujern1aFeYWSH7/pl6ntuVoBsCRvOY675sQlUELkb4xwi?= =?us-ascii?Q?LvdVEjlDWPICNWMYRDXxfEzRztdttgz4gCWuUCw+BeWJYnnFCe6OaFiDtrSf?= =?us-ascii?Q?hWwnxZkXnhRG92H1PO7UDTMZt9hZ1FpupIYIhykO+YDJ6krDsExXHlkKF23i?= =?us-ascii?Q?pIihDKk+ZQKKga0Zu927KUJonjEPQ4vIFmIFLl600uOTsfxRqJQYsf9nFrfu?= =?us-ascii?Q?0BEdc4MaQOqwTeRh+HPK6lH0allXmlBbcrB3otSadeAlzOix5edvg1mL0Sjp?= =?us-ascii?Q?QkmXrRFjB+iQio8815cmb4C8jxmzQz6LhhSJoQdpIDm4wt2VR2qwUmvRA9Wi?= =?us-ascii?Q?JLJUsXY77MDJ7Xg3hvMZzAcEp/tQ3uqyPyf1Eyd5ITBkTIjko8aKRemCrk/v?= =?us-ascii?Q?Ws/cl+EGlkN/NCkdxmXaIsYg+bW3IkKCXeyfYvdLqCT+ZHawSdhnfVTKp76h?= =?us-ascii?Q?hh4V0C5QRDiPExF9ruaEbNW1IbZ+jvk2H0uSy3q7jUQs9TXcKefbJ3Qi9p3a?= =?us-ascii?Q?TYN+3jt1B4yRsT4UfLI+iHeKRflvxE8Veaw7kl4IIPpxjUZypOeSARBT/cCx?= =?us-ascii?Q?odSgg7xO6Qrp5b4bUw4XPRnmjVNAnt3khIl9uTij1pubjLv/YwpPNx9i8cnQ?= =?us-ascii?Q?832Z0zWitEiuRMS3ptZDpTTmbJ0ut1WjXVvxeJjr5VsCulaad5uBTjQNReFq?= =?us-ascii?Q?PVbnzyi2srBOtJwh/J2hXkk2BbWrzSGsvtO3qsSxA7TY+wIHRgT4JHa1+pjs?= =?us-ascii?Q?iwxTgT2AVBXOtRM5oALudLpcWkpSb6ZCCu2U2l+5lFuZ/4pqxL0VDDUOYge2?= =?us-ascii?Q?WnXNonHFU0l3u5xrxw/fVyqcwlYWb6InXa8tJy69REuQPEljwoOOfX/MGQOP?= =?us-ascii?Q?1JNEoV+//J315v28bVjGvZ626aJL73pUyc4OyNBLs21uGSezpBEWJ77ETWlf?= =?us-ascii?Q?bN0s7mMIdHQASwptXHIRnNm/oQA/MCrNgedgEg2kjKMEp3kkpD6Pr5hS2tto?= =?us-ascii?Q?sDIoq0M530Z05wEj67fZkWxXG3MB+CsuzUy1box3feywQGFQa0dhEVtlL7Ld?= =?us-ascii?Q?hRgaNtMiG8N3pA0KzGPH1bp5tRg/4/VVfKMxFzPxgYqzb3WjB8SuWDhqf8I0?= =?us-ascii?Q?7OXLXnqe2WA6kEEVFi0hRg/cpCY9SrEe?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: hSgT2N54Q32TTIxk//TrvW75/nD8hB5IaiLdSPxl6BDAEdMcPtmZaQ2zwysz+Z6yVXYjL/KELBXBsOQF4a6rju5LT9fanVWRK0yiqbKkmhIxI87SHhFKI+ybwBeZAa++1fJpGc0MVco5LhGQlQfwCm8dU4HJxfcsRGoyODDDIcmqtJfKJUNpdpalL00PtJFrQnHlmfK7alaDV3PMBq9IJOIA5tI/8Um31RrHlIQxo10xAfX3OWJF20UGEWRhgOeL3tfCa6w8RL/1evUdztC1CN9wlXfZ9ab+lna5JVegH2LiefbeHQKaFO1tPGQjqpS6mr/LPFHKYdSk/rQXlwSAkHkeyKoyvNxOPw/DNAT5QyMVkDQJNZO4skvw4h4morhP6SUEo1I9clGs5byQqaK75j4w56q3IT44d5GvjjszXCKhk9leTTsjg8W/5NTVQRKQF0OGPDUlykHCqFsOcsSgW+NcZZCim5PXC8uqZ9UPtLHg+7awd2AkA3+PVFcGrLDsdtSFt2+AYdtmkB1AZ9WayYh9mI9KP6hapPXn9+WPHZABZpM3hF+bOax6nUCnOrd+ql+Hs/TAylxyimvqEELSeUNjS6N2YQ0mmBQeTBFIXFEhTjtuOk6zCQonQGQt3eSl X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:52:57.9724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 515dbe6d-c015-4137-3d71-08dcb566ada6 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR20MB4579 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=139.138.35.140; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873263345116600 Content-Type: text/plain; charset="utf-8" Implements the new hashing API in the GLib hash driver. Supports creating/destroying a context, updating the context with input data and obtaining an output hash. Signed-off-by: Alejandro Zeise --- crypto/hash-glib.c | 77 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/crypto/hash-glib.c b/crypto/hash-glib.c index ceaf346bf4..4f343e7d61 100644 --- a/crypto/hash-glib.c +++ b/crypto/hash-glib.c @@ -44,8 +44,83 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) return false; } =20 +static +QCryptoHash *qcrypto_glib_hash_new(QCryptoHashAlgorithm alg, + Error **errp) +{ + QCryptoHash *hash =3D NULL; =20 + if (!qcrypto_hash_supports(alg)) { + error_setg(errp, + "Unknown hash algorithm %d", + alg); + } else { + hash =3D g_new(QCryptoHash, 1); + hash->alg =3D alg; + hash->opaque =3D g_checksum_new(qcrypto_hash_alg_map[alg]); + } =20 -QCryptoHashDriver qcrypto_hash_lib_driver =3D { + return hash; +} + +static +int qcrypto_glib_hash_free(QCryptoHash *hash) +{ + if (hash->opaque) { + g_checksum_free((GChecksum *) hash->opaque); + } + + g_free(hash); + + return 0; +} + + +static +int qcrypto_glib_hash_update(QCryptoHash *hash, + const struct iovec *iov, + size_t niov, + Error **errp) +{ + GChecksum *ctx =3D hash->opaque; =20 + for (int i =3D 0; i < niov; i++) { + g_checksum_update(ctx, iov[i].iov_base, iov[i].iov_len); + } + + return 0; +} + +static +int qcrypto_glib_hash_finalize(QCryptoHash *hash, + uint8_t **result, + size_t *result_len, + Error **errp) +{ + int ret; + GChecksum *ctx =3D hash->opaque; + + ret =3D g_checksum_type_get_length(qcrypto_hash_alg_map[hash->alg]); + printf("Hash length is %i\n", ret); + if (ret < 0) { + error_setg(errp, "%s", + "Unable to get hash length"); + *result_len =3D 0; + ret =3D -1; + } else { + *result_len =3D ret; + *result =3D g_new(uint8_t, *result_len); + + g_checksum_get_digest(ctx, *result, result_len); + ret =3D 0; + } + + return ret; +} + +QCryptoHashDriver qcrypto_hash_lib_driver =3D { + .hash_new =3D qcrypto_glib_hash_new, + .hash_free =3D qcrypto_glib_hash_free, + .hash_update =3D qcrypto_glib_hash_update, + .hash_finalize =3D qcrypto_glib_hash_finalize }; --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873224; cv=pass; d=zohomail.com; s=zohoarc; b=LYW9SsXcfaqU0ITbkJT4iAcGupgZ3G7a67uCITap9vWPZ+uh/E+ABV18AFhoDufh/3aPfZacLR4uQlq/TwFgfNzAedaBirIXBZQJtL6kvUcUECza3JgDT8IOHwmKxd2zcO9ko31GJ9JFGUQQerEZvBxAcX5Bc0xcHPC5atblOSo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873224; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gV0Vq6RIUYCjcnt5AzzAxj0H6gviNmO3a23VaMUJcPg=; b=C9AdgM0leYWGROXpylhKuOWtLbibiO4anWqiZCB7a/iiq+f/uWcLkq7tz/n8hlzm982tKY9ZinwiieoOL3+DLMhxLk0Se1vhBTyu2Lu/SwWxDGmJCfD7gsnCiI7Fdmn6ZLiWDNG1eajknODooYrlIWYO550tTYYkY6mu5n/CkKM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873223923648.2570620170426; Mon, 5 Aug 2024 08:53:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb01N-0008Ue-8u; Mon, 05 Aug 2024 11:53:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01J-0008Ix-D0; Mon, 05 Aug 2024 11:53:13 -0400 Received: from esa.hc4959-67.iphmx.com ([216.71.153.94]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01G-0003qW-H8; Mon, 05 Aug 2024 11:53:12 -0400 Received: from mail-bn7nam10lp2046.outbound.protection.outlook.com (HELO NAM10-BN7-obe.outbound.protection.outlook.com) ([104.47.70.46]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:06 -0700 Received: from MW4PR04CA0387.namprd04.prod.outlook.com (2603:10b6:303:81::32) by BY1PR20MB7408.namprd20.prod.outlook.com (2603:10b6:a03:4a6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.25; Mon, 5 Aug 2024 15:53:04 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::45) by MW4PR04CA0387.outlook.office365.com (2603:10b6:303:81::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26 via Frontend Transport; Mon, 5 Aug 2024 15:53:03 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:53:03 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:57:55 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:52:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873190; x=1754409190; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lFiy+n3NJhJIy0urdSThUoEGyqVFZkQWwKRP0mj1ccg=; b=jZ8u1JrUJrWBLzs8QKysg9+OMf11R71BMoy8JUn4DR0FpMSMMSgv6YK0 yp3yDNSQUw63CZIxKPSmQnc6KXdr/o+v9KME91D8+/0ABeOLzFeF8vzNc sVRWv4PJQpgmhvDzks2YGWw34u5REM+93yM2x/kOb8QBmXIxcvzVb9rNW Q=; X-CSE-ConnectionGUID: O+GVTX0wRc2MwsD86jEIyw== X-CSE-MsgGUID: pXapT5BiRZqtUScycUtQlg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Pn5YSKtXVz6cgWwUtIgICphL/eFgfemVwX40jFd+Own5VtSJg6fT5S0XD63BMnxpEwxmw1ItbGBXq2Eqe5DZC7R+HvEXbhOtA8qDLqevFWJNeQCRdUKmm2og4oTE2bVO+Ujm8W4QS1OpWOeXDMD7T8R7QH5j1lSkck2/bZWnDCXtapnGsoiwuCeee3LOsl7MqllZpyF1fbCvcPMk7kerhm6FZoh2tFnkwUa5OXvpWx4fyawku5/0Ub0cPKMvKjKszuWWQFi2gbbDjHzaPaq1TOBznQqfh0KPVChx5xfUHk9tCnDUXjJFUVjcrRXXe9tUlqhD92h9QSh0GFDRYI4saQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gV0Vq6RIUYCjcnt5AzzAxj0H6gviNmO3a23VaMUJcPg=; b=Oo6GsCwfyWybJuG0dFTQJ6AIoJ8/lgel5qyiSIx9WoUT3E3vPWAmBgmg0nzHRg6m+xOXAG1yZIluV7wBXqyjIRqaSLUx+ZoF1BlRq1Pi76oJbvk5b8QdfItENVhLerDbqi2ZF/T+fpp/8/70qTbj4v6q2fSq2Nehv+5YuT0RdB1T+vv1YxQZegALcobk3WM4P+7vc3qra+v/2VPdloLOjP+2wBK62fSW+wYSmz2NdQO8t8Yyg83B8AdtNfvK8YCtMBECxOlxzNVI0GdF87ipRaeJ2wUM+FH70lZPFiFTNNn11lgnuTG9/JZVK4t/UcaJGuq5zzh7gU/wA4T0wLmVEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gV0Vq6RIUYCjcnt5AzzAxj0H6gviNmO3a23VaMUJcPg=; b=GgHjPfmuDh9huL1SiG2zjlyYCoihVhftFixA//kp/QmrYEl/ylSj8JBe+3rctVwROtzaAtVicDQtCZ5xmw+o8PXMzvCow3rjROT0pWpO3cvXLN0AriIpXin9Vqs8FbdCSACIbNGr4jdy8+zPw3QjELFxzmpByUrnOldb0UBB6Rs= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: lqlldCstQl6yiSjehbOhYg== X-CSE-MsgGUID: DoXft9U7Sj20++d+ihy7Hw== X-CSE-ConnectionGUID: KefhWED3S1i5Y5WYRvbkKg== X-CSE-MsgGUID: otTftMa1T8a4TRZWXYardg== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920686" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 04/12] crypto/hash-gcrypt: Remove old hash API implementation Date: Mon, 5 Aug 2024 15:50:39 +0000 Message-Id: <20240805155047.3151540-5-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|BY1PR20MB7408:EE_ X-MS-Office365-Filtering-Correlation-Id: da73d2d4-452d-40b9-66ed-08dcb566b0da STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JT2vGaG+AD6VdyKi5/2ID66KlRy8vRPsM0acPS/Y5eG/7Lzkwf/JHtfh5nTT?= =?us-ascii?Q?B0RvVj1kS5eRknQV3oojyMP6e/uMzWHxpwbUuLi1GYKTBR/kLx5/p+lfUipK?= =?us-ascii?Q?i9Dce3J5pUhzRXIcOCx4XXdLlq/PblLlzE5ufOL9hnnuxyWOvnQJrngCOEi1?= =?us-ascii?Q?+NHHyId8VnQkewgmtBkhY0NJd4fYbir8FTyr/fECPzBxURE5xsI3W1KqRae4?= =?us-ascii?Q?v49OvlNRDCsKUfBqwy5OVxmu0JvxLNceLT/vNtMb682XmWwr9E0VnCA6R7eH?= =?us-ascii?Q?r20ahlzZRsSBaaYUYyteJtpjsHg3yzIaVO3JqyW0F2penbxs/4Bqj6HiNV8s?= =?us-ascii?Q?IANVkr7yjn/QjU26z7YtOQf0RgHg9R9pZTnv3OOTiyqxqopqrTLUcQ1qvDOt?= =?us-ascii?Q?oXIdVZA0eFVv58mQtmqx6pcjPwnJDW7rmBAebbgfKFjKTHRxnkxBhyLwy2C7?= =?us-ascii?Q?9gGRijaIMEQhEaUMEREllIrr7dXGpg/q1P6ThHUkVAQp3VhCLtaIp3jrbE/Z?= =?us-ascii?Q?4bBrq/2raKIHv1zTfa1rm3dF5kAhLFRY/seNB/AHWm+DMvmuFhAAmnKZJtcm?= =?us-ascii?Q?Us9cusGe52ZvjE3SbzQzkww0PhRxt1GyG36brXEGaJ9VaduWPY2DvsOtHr1o?= =?us-ascii?Q?gKrDM8ZDVji94jbyzhUE+GOpZH0gxwFGZgHcCvRojLSSgc0/dUgIJSx0CyYe?= =?us-ascii?Q?mueGBE9kOHLZBkGRTpEuryjZCav8o32ntnOHiKcj9Is/yyo8oeiD5f2TD+xy?= =?us-ascii?Q?g5eQlljqNyAyLAcWloV4RTSaghu+w7APDa5OUjpMur9bdxlsUP53I5Hngfms?= =?us-ascii?Q?j2AQORIp/5YvC92yFT8kkEmQpdjnBw6Ab8cnFLYddQ6THExA8HaiUOmqAgpq?= =?us-ascii?Q?NVdQ4k8s2vzVMePrfXAQGGaigbvBsV5q5Y21xzXf4j2cv3xc+++L6FDjiJ7m?= =?us-ascii?Q?AE1RotbBl0C3y1rvdusrr0bj2EtP8wW+pWhzm8ZdVP59Jnien8y/gkPc6qAe?= =?us-ascii?Q?fJg/cikDbtckfOhYEpdUiwhmapMV8aJfGhOsCIJKZPRpnm7xynEgck6vQ1aQ?= =?us-ascii?Q?U6kSyo8ml53VDr+Pe1mVpNovvuCtKmxtSMiKQcZKZCuQRqy4BZq7w2VfGWLj?= =?us-ascii?Q?irJNqajmPzpFYDyxjMMNokANXnq3y9Y4sQkJcmM32maGpxMyBTrOvmrEt1Rz?= =?us-ascii?Q?C/gczx11cg/gdhIOBI+uxYapemF4LSJHkdH+EBTDvii2tmeaKlzJFSsbbSLT?= =?us-ascii?Q?IyyTzwWo7nahTkhprlxYnrkTa0GS3JSzqCj2X1DsFUjQMmY8u3kvNRYOfq4B?= =?us-ascii?Q?8YCvAjUQwhRpjJZ6ELItlb8c4eHM6tpg1Tvu7jDg9iJE6JM9Lsfv5qYNCbLI?= =?us-ascii?Q?CXxYM7COx4eb/yltIHF4IGFmifqG23Z0dsVX3Vo/V+S24PPXbfYbPHyJ3B0m?= =?us-ascii?Q?2c6gcbBelg/LXg/58CICz9H8YPGycGkl?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: fZ9qUPhWMjXvwzfcK8gCrTO2vv6zXrsiEAjs9XalZxf4LTzJ3k1cyupZCZM7J0hn4lFR0Q5hl825AVU2ZOOZ5PHWb3s6w9D49MIZ2fL9XPnI2DtvKZ44pQvU6vYkdr2+Ym0o36RHldgVlyT+Dko7wRVwqbe1fadcaIuDFN8mBlUSfZUDpOpGipm+po0CJZG4mmMMFY/UjiSMc/4oprN+uxLpMagYia1lPv6Cq7xGBTCXK8Zm9BDAA/IJZkeg4lozOFOQqO5uipGkn72t9tu/taS4YQj5zE174XrN+HomBmLkiK9ItwY4BEqkEKJdhR5I9WA/TkwffMjOGe9aP9K5quJK/VdyTys5cUXOOYpDN0qOzB5uKT5/l+jTYkzp26n5G5SKHC5dv72mlDm23bxNLheSHDh+iCo+zNSKDdW7xJu/J0sPtltWUnQpqtCeqLzGtr1LkiOAB0er7gzJg5Nh/LGfqS+hmyjQBjM+7BWZxjowdhI+m748yegGxHcVqNlD5fdeZD+QsO4fpP3jjlEPjFoZD0hk7ohRvUKvHKHSiMCYjTatRt6Hrfx4dSUFH1RBjWhi34ibr2dHGCNVyKT7kUtGUZoUUqfwgid5u5+VoUE678jwPCPugU3RLX9ROzlU X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:53:03.3943 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da73d2d4-452d-40b9-66ed-08dcb566b0da X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR20MB7408 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.94; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873225369116600 Content-Type: text/plain; charset="utf-8" Removes old implemention in the gcrypt hash driver. Will be replaced with a new implementation in accordance with the accumulative hashing changes in the patch series. Signed-off-by: Alejandro Zeise --- crypto/hash-gcrypt.c | 66 +------------------------------------------- 1 file changed, 1 insertion(+), 65 deletions(-) diff --git a/crypto/hash-gcrypt.c b/crypto/hash-gcrypt.c index 829e48258d..6378879072 100644 --- a/crypto/hash-gcrypt.c +++ b/crypto/hash-gcrypt.c @@ -1,6 +1,7 @@ /* * QEMU Crypto hash algorithms * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (c) 2016 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -45,72 +46,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) } =20 =20 -static int -qcrypto_gcrypt_hash_bytesv(QCryptoHashAlgorithm alg, - const struct iovec *iov, - size_t niov, - uint8_t **result, - size_t *resultlen, - Error **errp) -{ - int i, ret; - gcry_md_hd_t md; - unsigned char *digest; - - if (!qcrypto_hash_supports(alg)) { - error_setg(errp, - "Unknown hash algorithm %d", - alg); - return -1; - } - - ret =3D gcry_md_open(&md, qcrypto_hash_alg_map[alg], 0); - - if (ret < 0) { - error_setg(errp, - "Unable to initialize hash algorithm: %s", - gcry_strerror(ret)); - return -1; - } - - for (i =3D 0; i < niov; i++) { - gcry_md_write(md, iov[i].iov_base, iov[i].iov_len); - } - - ret =3D gcry_md_get_algo_dlen(qcrypto_hash_alg_map[alg]); - if (ret <=3D 0) { - error_setg(errp, - "Unable to get hash length: %s", - gcry_strerror(ret)); - goto error; - } - if (*resultlen =3D=3D 0) { - *resultlen =3D ret; - *result =3D g_new0(uint8_t, *resultlen); - } else if (*resultlen !=3D ret) { - error_setg(errp, - "Result buffer size %zu is smaller than hash %d", - *resultlen, ret); - goto error; - } - - digest =3D gcry_md_read(md, 0); - if (!digest) { - error_setg(errp, - "No digest produced"); - goto error; - } - memcpy(*result, digest, *resultlen); - - gcry_md_close(md); - return 0; - - error: - gcry_md_close(md); - return -1; -} =20 =20 QCryptoHashDriver qcrypto_hash_lib_driver =3D { - .hash_bytesv =3D qcrypto_gcrypt_hash_bytesv, }; --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873251; cv=pass; d=zohomail.com; s=zohoarc; b=LzINzSgJeXAJAvk4Mx3lW/lFTAYPM3ucrfIblm0zcWbMEHie+LDMtC4keNwvYFOWlI9AkWMspNInGu49GT98bsVbr/Nr5XUin+bs82S7g1rEnbMJwXcrDLSiSZCdUnqSsaEhZn3bsleqQWQ8UppFZhvH83d5oPVJqGJ9q7c6VbE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873251; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CcxTJkFSmF4td/nDVFZ8Wot8FnhZLnRkYoyd25znfJo=; b=gQUe3JN/jK3EtdTxmLlU/5DWQZbAYi00H/mNZ6qCCmAVXuxZ+lsJG/yWwcosaivQ9qOllQTUtwLHRJKmXLPNgXFEYRejFPkxldxDoC3oWL5ZaT7faxEyv509JYBWvhwi0l7SzmbSlu78lBz2xIbFmzqOQ/y6qcxy3NZ7A7mjbdk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873251812361.33393284161536; Mon, 5 Aug 2024 08:54:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb01O-00009c-Mi; Mon, 05 Aug 2024 11:53:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01M-0008TP-1q; Mon, 05 Aug 2024 11:53:16 -0400 Received: from esa.hc4959-67.iphmx.com ([139.138.35.140]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01K-0003rd-4B; Mon, 05 Aug 2024 11:53:15 -0400 Received: from mail-dm6nam11lp2169.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.169]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:12 -0700 Received: from MW4PR04CA0374.namprd04.prod.outlook.com (2603:10b6:303:81::19) by IA0PR20MB6655.namprd20.prod.outlook.com (2603:10b6:208:492::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 15:53:09 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::3f) by MW4PR04CA0374.outlook.office365.com (2603:10b6:303:81::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26 via Frontend Transport; Mon, 5 Aug 2024 15:53:09 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:53:08 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:58:01 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:53:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873194; x=1754409194; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HaShWNvYIuqU6oggFyXFCD99FRibmZI1VM10rgstOpk=; b=kHw+m9uG07r/1R9Df8P444ZD9rSyAE1ZywKPYJzrY2IweRrLceODgraH dkKwfSoe7sIstWcbVu+DYj4TWda/7JwWz2ghsmSRt6YAF6aj733dtzn2/ P6MziFNzocwDu+vtK8fw6VKjPWGHuRNSPfZj7WRl6BbESmJj2eVDkdLnJ M=; X-CSE-ConnectionGUID: lYfj5XrHSDeRIiCqXcY8Kg== X-CSE-MsgGUID: J9lbigWVR6ycLOM2wyNLqA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x+WqO/FDZEpLxw8vO/CSu06T7ys6pTIkv3yABTHt5hf/weWlUpUzIzD93mNxRv2x92uf+EtpArCcO6YsDOrTDNIgTdKx9UbyexQc6Gk8wDmEZLR92+QvLe3HUFAhyxAv7+QNXys8ClDeMYVqwKtX5pu4ApZHk0HN29LeokqZ3zkeLKN7+Cp234K3GfDnJEFMg50J2OyE5SqNlUpIrjSNERdbukcobuhurBxkgGzBrm7PUujdaefyy1tF6CHX1sYIpBROD0bZtFHNRR9kKSPcJ0fSq0qQtJi6IefbbWhPYGIDVg+G3yFPDJeWWeo87PdDS2O19tfjfPeSnDazusQ6Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CcxTJkFSmF4td/nDVFZ8Wot8FnhZLnRkYoyd25znfJo=; b=JW5HzoP4xZDT6TheDBXnuKlYmmh8Wt2cYLNIYziRXlioIKApZolobrFmi8dmUFbfe8eSfgViug52E84rwRNBr5s5FucqoIFxp8gQ1HIC8qXu4o5x3uPbIgRAE9loehXQQQBiyO5EuVZhvbVu/OmRIdpol1x9nJtMPql2FiOTwtSw0T3BIQSFRiw7tpZXW6d+aZq+DZIhg2U1fSLEHScEddbnlEreabAb86QTw6RLysdSPrFXNhAKFG+adFYirWasXlrSBobTXpuSPHQjk1f4NjCJe7197gMGcciIadbyvPR1r9QZaPH1HKlMrWZpN5gdSbe3HyZAm7vHQ0Io6S2x0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CcxTJkFSmF4td/nDVFZ8Wot8FnhZLnRkYoyd25znfJo=; b=Fv2gQ61zind25sl1NkTyjbfYLLfbeB9W99vpTUg4XyBMwFO/aOuYbIjetGxsEr1oi27+tGWffE78Tsa0+4i+RRjR8jg2Fr2n/O4MCxYLk2c/abprEvPSBv5LYg3lU+1qsBIuKhdbLnGLJo6BVyt0YAv2ORoWc1GGLeQwOkwfBnM= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: OkF0lm8QSuGI8jQgUbIOkA== X-CSE-MsgGUID: SOlFfA1bQjqkJOZy5JknIw== X-CSE-ConnectionGUID: xBqxuv8QR26MnhRTCgxepg== X-CSE-MsgGUID: sWcv0xLaRvinbjTyInhr1g== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920689" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 05/12] crypto/hash-gcrypt: Implement new hash API Date: Mon, 5 Aug 2024 15:50:40 +0000 Message-Id: <20240805155047.3151540-6-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|IA0PR20MB6655:EE_ X-MS-Office365-Filtering-Correlation-Id: 336a3b22-70a4-4463-1f80-08dcb566b418 STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?EwTSwZNwcxOeArbK9yHdnaxlUTM05DHhK3YDm/ZVpFVMp5bjzYS8ilWRK/f3?= =?us-ascii?Q?PisOwadO0vo6QEx6UZ+plKk7gftkgAGzPBdQ2Qeq5BqGRJy1BrHd3GCwjulU?= =?us-ascii?Q?qgvJglWTQE4S87k5Vel2VVytTa5h8/30LgCtjdhHbuqe+Ig0c4bku5EVgUMU?= =?us-ascii?Q?FZhE4Enmk6guq6A8bkYc/JmoXGmTaPDrEf1MtbdNAvvzOYTRJ5uTLCI7uhlL?= =?us-ascii?Q?sJAZJY2+e0jv8QzJO3NOgGoXGf3GuSuNsGTxKhtd1y+Ni7rEEBJVSgVTP9TB?= =?us-ascii?Q?2UFF3jKPhiT/ijZwWMQaG7t51BExX/nt+p4Slm/on8bsLGsOTIBja1VOdsVZ?= =?us-ascii?Q?1B1uBuWtKiecD3DYilfRgbQoET+Yy4ane7HKNUNrklI1lm+Z7ufmQohNw2G4?= =?us-ascii?Q?apwnrHI58H0C9QkFkAkKomsnNQ9NrRQTm7jh/nFIxtmbaBz+yBeOKCiLdnzv?= =?us-ascii?Q?eH0R32GsUBAMWaeMlLNmXO9oV2ca/L5MmBfL1MoSg7+33ay/DkGyL6RT764p?= =?us-ascii?Q?7jtnUvEaB/n3JcF/feJGdd1Hff8yPfQiVgeciCKKhW4kLCIBRWexqakYZ3rZ?= =?us-ascii?Q?i0SVLkYcbhiZXS7Y8F0NFG9t9t45xp70Iza2jRrAmAtkooq2ZvUehjwwQQJs?= =?us-ascii?Q?aCopqZkYzAwntO6pxmKmzq6+6dZDYKhKK1fMJdP3+yl9I1qOZHW5zwfkyT0s?= =?us-ascii?Q?PzU98VVeVF4cyXRwwhWEeQnoBTNzlZ0hDmXksCM0JoU3qqkxf87CpwYC+osk?= =?us-ascii?Q?qr+PAMEOsod6QR0jRrl6PS6pyZ0VdDWDIIt1jJ9fcXHVknQcNebM3OrhPbpl?= =?us-ascii?Q?abcM9mmooH9NVZ9Yi6Am+LiQfAr0Xn04xI0P0z8sJFFAb1rHoMMo4jPsShmK?= =?us-ascii?Q?Yx8sI5TwVFx+UTgc44aNIWipgxjC+BI5k7dvNcXwYpuNshN3AMcTIdv/JGD7?= =?us-ascii?Q?jgcrGGM7Y43S8QxHDJ4xme1aGErEDjYVFw1lJj94fsvaHObqbkNoVSbhrIBC?= =?us-ascii?Q?nVYCxmchwB6ucEGUvYwkad6EIOuBqjE7glG8Rl9W+9hCMNfWhIlumYLYSQxF?= =?us-ascii?Q?pZXpD5A5zSIW/GjxSNW7ck3IXfi7fHjvQR2q0Lq7/8FkAhcLTFCsSHPWbhHs?= =?us-ascii?Q?JCMvC5FJBmkSRkhmMbBGAePABckfJ9KHEYKM01j3ofq18lVxjcH2+QsvUtT8?= =?us-ascii?Q?EgV5lTEoIwfmMvLI3kKgbeJXKh+cViz+hg19MfyfKp5AMP+9NC7+sSjrI8o2?= =?us-ascii?Q?uZXbyiFv+nrJzJDGKjcI/0lA41H0oOVWxk0p9UWrPndrqOxohBe2Nng0HQjl?= =?us-ascii?Q?hIFQDS8VANJpEwW5rAcw1nwoOZTdDMPYRdq6t0+3oduzpY2yyStizao1UMek?= =?us-ascii?Q?5zh5UETCYtmOvGWbUkGlYrV1ZwgKpoCx7y9GvoBnklnsg1BHtC+LB5MLNlFr?= =?us-ascii?Q?wAAB+o3+oPkC45jpDEIUYOxem1Ol4mZ9?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: c7exhZCsqX1y8QmLhsjnW8o3ihoIsjX3b1kg79Frl/R1xLpXJjH000GpppwFyBAqaeOhnApzSYgp452nk83++QrBnTyf62mmNYFqqgf/eLhU08Ga/vVpFM9rB6eq1mmsBOjcNqPWoamqrj1o0p3WO18L4+0XcGuagzniNOwkD/ZV/q8Motoz6dHmCcfJnv34USmo2IgLBkxBgm+6Ze0SOXEBb2KG4BjCGY9cMpDiPm30I6kRnZQvIaNz2113w67OawflbHcqfRHlyVECRvLqXLClZbF5vNwO7h97BorWLvA1tYuTpOkNVDoynpny9iUyIv/jasZ6w0DIYiVStLwoPkPBhSXIF1J3OnsimHbRWy4poWllaKVnlYJCAdzioBsHbk2tzasyP1KDfvqH1yHCcErlxqS2LTdixkeNvRYPQzXAMqvoWOBN/7r1JE5SbBn/SdN7AdQ/Xn0GsKDT5irLHZwIhVrkReSBGtGFQerChdkoM8KjP+6tBYLySCbcBAdwMRizR0LdpaFpq+GxpzLFmI/od3qcWAYIIkm3Dv2ahLGoIuQ31FRkEYN4ouFqxwyT1cqmRolGCMKfYZH23K4F7n19i/+O9wbpgfoanajMnLGMtq6PhGNhcwN6IMhEi89M X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:53:08.8319 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 336a3b22-70a4-4463-1f80-08dcb566b418 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR20MB6655 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=139.138.35.140; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873253288116600 Content-Type: text/plain; charset="utf-8" Implements the new hashing API in the gcrypt hash driver. Supports creating/destroying a context, updating the context with input data and obtaining an output hash. Signed-off-by: Alejandro Zeise --- crypto/hash-gcrypt.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/crypto/hash-gcrypt.c b/crypto/hash-gcrypt.c index 6378879072..830ae642b9 100644 --- a/crypto/hash-gcrypt.c +++ b/crypto/hash-gcrypt.c @@ -45,8 +45,86 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) return false; } =20 +static +QCryptoHash *qcrypto_gcrypt_hash_new(QCryptoHashAlgorithm alg, Error **err= p) +{ + QCryptoHash *hash =3D NULL; + + if (!qcrypto_hash_supports(alg)) { + error_setg(errp, + "Unknown hash algorithm %d", + alg); + } else { + hash =3D g_new(QCryptoHash, 1); + hash->alg =3D alg; + hash->opaque =3D g_new(gcry_md_hd_t, 1); + + gcry_md_open((gcry_md_hd_t *) hash->opaque, qcrypto_hash_alg_map[a= lg], 0); + } + + return hash; +} + +static +int qcrypto_gcrypt_hash_free(QCryptoHash *hash) +{ + gcry_md_hd_t *ctx =3D hash->opaque; + + if (ctx) { + gcry_md_close(*ctx); + g_free(ctx); + } + + g_free(hash); + + return 0; +} =20 =20 +static +int qcrypto_gcrypt_hash_update(QCryptoHash *hash, + const struct iovec *iov, + size_t niov, + Error **errp) +{ + gcry_md_hd_t *ctx =3D hash->opaque; + + for (int i =3D 0; i < niov; i++) { + gcry_md_write(*ctx, iov[i].iov_base, iov[i].iov_len); + } + + return 0; +} + +static +int qcrypto_gcrypt_hash_finalize(QCryptoHash *hash, + uint8_t **result, + size_t *result_len, + Error **errp) +{ + unsigned char *digest; + int ret =3D 0; + gcry_md_hd_t *ctx =3D hash->opaque; + + *result_len =3D gcry_md_get_algo_dlen(qcrypto_hash_alg_map[hash->alg]); + if (*result_len =3D=3D 0) { + error_setg(errp, "%s", + "Unable to get hash length"); + ret =3D -1; + } else { + *result =3D g_new(uint8_t, *result_len); + + /* Digest is freed by gcry_md_close(), copy it */ + digest =3D gcry_md_read(*ctx, 0); + memcpy(*result, digest, *result_len); + } + + return ret; +} =20 QCryptoHashDriver qcrypto_hash_lib_driver =3D { + .hash_new =3D qcrypto_gcrypt_hash_new, + .hash_free =3D qcrypto_gcrypt_hash_free, + .hash_update =3D qcrypto_gcrypt_hash_update, + .hash_finalize =3D qcrypto_gcrypt_hash_finalize }; --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873319; cv=pass; d=zohomail.com; s=zohoarc; b=WIgc1SBHRcAzXbxJvy9IWV0jh+hGmLJ+qCDQ5l6b2YuMwvcu5G1cKerzRD4dC7Z84z0idOXwMpFcqUSzboXTwJLNSSCf+K9JYmIKrSXb/pEhKDi2+slViWC4EfnFjY3IkJ6vE4RknF0PZ+QvCZQns0ntSMLktuB6NxplMM0vhgM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873319; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SUzGeR8IaTn1BGYcyb8C1iLOAOqxK+cVU/ApDR3f/6U=; b=haP8dR6H5aGRtWA4Ne3iEOHf4uTedQg/Sqg0LseYjhC4tmYr27tRHWXys+SkHI4/6mhT2abJwmifGKEOg0euYH8o4EDmc02Svj6QcmY0NY7fwTLsVYK9KtMSCQ6yMRQgsqNPFYNrm1JVOVvsLcXm+mocYccvb5Y3fHQcURNxErU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873319293738.6094492867777; Mon, 5 Aug 2024 08:55:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb01W-0000X8-1x; Mon, 05 Aug 2024 11:53:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01U-0000Tf-8Z; Mon, 05 Aug 2024 11:53:24 -0400 Received: from esa.hc4959-67.iphmx.com ([139.138.35.140]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01R-0003sn-Pr; Mon, 05 Aug 2024 11:53:23 -0400 Received: from mail-mw2nam10lp2040.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.40]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:19 -0700 Received: from MW4PR04CA0389.namprd04.prod.outlook.com (2603:10b6:303:81::34) by SJ1PR20MB4740.namprd20.prod.outlook.com (2603:10b6:a03:45d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.25; Mon, 5 Aug 2024 15:53:14 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::b8) by MW4PR04CA0389.outlook.office365.com (2603:10b6:303:81::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27 via Frontend Transport; Mon, 5 Aug 2024 15:53:14 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:53:14 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:58:06 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:53:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873201; x=1754409201; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t8bCdwUF9kmwTPWfGbGtm0+1UnJsvOn5om7BCq0kQ1Y=; b=IoXDTw3m4haSA/xZtr+eszpMWPi/q0VhFLtLiPwwtn3LWyrLSkXPIySk qOS5HHp/aNA4vhbYcPMO/Km/ThquooPy6R6596C6KAIThpKY5W1K+zj78 ccOg2WAFd/yn9hL8qeY6+z56W/QWplLDaWurGYytiZIDi3Q22H3rJ62Td Y=; X-CSE-ConnectionGUID: cTANsFggQjO+lAR6Gjnm8A== X-CSE-MsgGUID: v/EoU1A/RvGG/UdviDAAbg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jcoNXgrOrh5uStsmNjqzP2pUw1mO4iFq94FZERqFsS8XjkuFvPfhIcrhQDlsXhF+Ewg94AJV6wN09ml07HNtHfn8YVKCt9rcZ5QkdY2ofmfQlmjooxFxnQamtCbWCVTBlj8svm0l1acMU9sDtJnlw9Hsx2U/wcrujEqp+dlFdRLQERkFuCESDGaSwc/ieJwUBX+2crc+PvIZmhz6X5rxbbUefuQJ0WNSRm+1WvM6fzlmuiNF9ccG4uwhwO0LV7uhUsC87jPP0L9OdEybJINkRs1w3DAVyI/g0dAX194fTNwV+V65n0PhS7T4ZGXFj61UaBN5s+e+en4trk6ZWGUPKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SUzGeR8IaTn1BGYcyb8C1iLOAOqxK+cVU/ApDR3f/6U=; b=OEpD6Fh5WTriaRe7SD3SDuGinyQhXiBuQjmEI+jT0VsesoPGD0uBVhOQLijGekJkh+blbLSGERZ+NJlvmVO5rKlCu4nXg1ES5XtoKNDUI/bIqwXYaMKs0OEXMas6uegssWXa3ZaSlMMKsEGS5X8CjGEfhlIJdLAvPc1lm21jbVBS8ocPf9q4l1gApyvmNMfNIaA+X9ge7nTGcnQCchmmeBN/dKmlCX93SwN5uGkUpqu2t09s0VwGIiisxsD3bgazTuedcHqWKVm/XExlH4rPcrA4+dPkXxi0UHWf2pwwbSf0IeXv0yPjEF+0Gu/m7OSF+z1pfYLLZmFUtnQ6HclvTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SUzGeR8IaTn1BGYcyb8C1iLOAOqxK+cVU/ApDR3f/6U=; b=d6v55r+CpxpQgWU34IQ4nzRLqrOGROH4Tma00EytXbB2MDnW5E1s6X98jFf12OmDzPd3ppuWOboPS9YgBmbXv/z/mJjMPBmeJRc/rBfXUNMb3bZ8thvJkOSMGZrlqTAl/sMaR224Jc3JEmujBkxOX+za8Ema2JtrrBuDkZvcwBo= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: mWRiNZIvTwC+x24ud1Tvdw== X-CSE-MsgGUID: LaYwB6S7Qz+G2LngFzdnpA== X-CSE-ConnectionGUID: ULM0OGYeSt+my+idKatEHQ== X-CSE-MsgGUID: SdEreMh/TxW+qSbNQXVfRA== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920694" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 06/12] crypto/hash-gnutls: Remove old hash API Date: Mon, 5 Aug 2024 15:50:41 +0000 Message-Id: <20240805155047.3151540-7-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|SJ1PR20MB4740:EE_ X-MS-Office365-Filtering-Correlation-Id: 1843ad27-d465-43c5-2f26-08dcb566b758 STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IrOmOvLKgomzspvIrghKJ9lN64wA+9cdMRXLHhT6mX9V/u4T4KtUkukYt33J?= =?us-ascii?Q?CaQn9kXFaJDCmcVX1Mz5ZkZ6qx53V4hqSlORV7qd9hzzmXO93vo9HuKFLCP6?= =?us-ascii?Q?Qqd4iX+vb9cqDDI7tqcAfB15MoiCRai1OQdUEFsPU73sH010giaUk1ZWRHoc?= =?us-ascii?Q?SPkF8LdBa/yMyuiHb1zs9mzyxxkMOjCZ0UQf6Dn55yCqxR+l/9cBkFQwwBzF?= =?us-ascii?Q?EVb+XJb816NYesRgdLTPeHlWJCDXMivNJIt12IKgwMdjeZb46RS8eBJ/b4o9?= =?us-ascii?Q?MBNfS1HVio9PX8lTJyppRybrRP0owmgQ3LMTpCKqhYLPfuUCcrunG43SAyYN?= =?us-ascii?Q?GCUjYKSw7gwOAz7MkECU8yqr+UDr6vkaCCLJTcMSwVllxYRnTX8GJou3hpvl?= =?us-ascii?Q?g0/gGS/5+yPALC3MrsSIfEbA00YthLxx+XcdlfIZAYZbt9zP064ZNqsmwza8?= =?us-ascii?Q?pkKTFAT+MeVqyymo5HBiB/xmaOIwOqeDEw5WSXsMncIKWrG1yTSAwmtTsNjj?= =?us-ascii?Q?82f3ezarE5UTIIW7iuHtgBGmeuvu6UIEjf3/Sl0UUvRG+OTqTosu/T4oS7SR?= =?us-ascii?Q?w19hc16/Wqw260TQDaG4S1d+NG95e1HtgUuNgGl1j+KTaujR27mu3XhUQHUK?= =?us-ascii?Q?9j7jsyUb4q1omagGELNs0FcOqZU/oZaKJfALc4jKcB1FB9+iBO3qGiFfNaWI?= =?us-ascii?Q?91Ze31w2T4+f7uxYVUqtLYDz3CCcq+mnHjP0HOelMA/aabhBGzBqrFOpm/vB?= =?us-ascii?Q?3OWki8FE0rLQ9KZWl18OO4S/N7fllzPr+S+N1aZlyK6wQvDA5qHbfpsP1mUs?= =?us-ascii?Q?VrUKiDHz0Sb3+2FFHOxq+yfKZsKpUZsBqCaT4ZdKc5Mswc8xw/Dy9vN33wss?= =?us-ascii?Q?RFR40e0f00iYBPskSAcx6Y/oanqUAFsN8h/LvkrkreUl5fu/HMM31JM5DVgO?= =?us-ascii?Q?MQu/xOI5lbSGM7Axg0g6b1ruwuJapes491gzU3b1YKc3CyxlbR4+liLMJFDe?= =?us-ascii?Q?cX2uHEGAzRvVePLqSkerS8/R3BlskXky8DqdiiPWkpt1tUV4gWzPyxEy0K3H?= =?us-ascii?Q?tl0QBA4WqipE2D4iV7AOHaR0JAKAXizQlSKAXXYju+GHgQEVo2se2KxObBnw?= =?us-ascii?Q?ErwKmuuDHldV7ncywKgaxi0lNgB5H9xzXZYualmCl2wjj6vUdLQOlv3TUlTP?= =?us-ascii?Q?wkQQvLbfOIxro+EfxsOIupBEpuHIfMhf8g/VeKrGTAcs4VRkRbzWjO/Z335p?= =?us-ascii?Q?7vPw44Gby4fZhYHu5gVZVaKLUVwk+6eySyPhDNNfKdUPQHZArnd7MDo+Px3y?= =?us-ascii?Q?LKEnUpiHRA0yYJGwVc1YXmFscuPlgUQ6t7WFgUkZQKbaNNAGpoK/C2fZxnYC?= =?us-ascii?Q?3pnGpa52rod2K3iPHHUkbGKJrtONeDe6ArdXukWvqxoi297/MPhi34DTd+hR?= =?us-ascii?Q?KjfRtKEFtI0EKExvXoJSr4Bez6ZnaOQY?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: LchwE9gal3Rl1I/2lXGgm6alOAQf6q6z28ECj3L0Rubi1jt2QG5s8b+C4DUzWeOjRZJlFiZEFjC46iVSjRUGfmKy2eE+Cexf5nJfviPlfjP5An3bACCVwVU693uJT3LtpaZEG1eNCSCAOQfuO/a+wtwn/uhOCHx7mIVOlRP07pAyKxiSreYR1GHu6XJobJSH8zHB46CSaEjPDtKtrZFRUSvBlGTyj6T8LzzaMA14Ql/QVo/UwxUZsa4XkboPgr2SUB+vlA7upcUlrWLWruZ2bKn+GsZOElzTy9oNNvrK8Na65jEP3qtaxZAD+JBk0/AC9u75kJLWYRNkAS4rfdeJRKVvD4tE7bzFgkXodDcTMCk+XHXv9W6oxMGJOfrOMPjkrglf6VDpOTRuecS55gOXNtMre2C7NBfmeV6A/Okj3Ry8+GYp92mD20u7NAyJjjeODuvbvAIVC1w0rgVORkNi4DUjog80d6S86HVZDAzpKIc8Fk1ACjPSdBF/t7g5q+U+8UCo3yRe2g+MM7u3agYjMrR4hdlgB+dJv9i4J+QiY2ZC7Cs1ozy6R1fMGUyu/GXsnCLi8eKaQpRQ89DwTVLPeTtx0rOlgQrG9RaIW+j78X2hod8s/pfM0tZAUJjNlVD5 X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:53:14.2850 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1843ad27-d465-43c5-2f26-08dcb566b758 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR20MB4740 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=139.138.35.140; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873321520116600 Content-Type: text/plain; charset="utf-8" Removes old implemention in the gnutls hash driver. Will be replaced with a new implementation in accordance with the accumulative hashing changes in the patch series. Signed-off-by: Alejandro Zeise --- crypto/hash-gnutls.c | 46 +------------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/crypto/hash-gnutls.c b/crypto/hash-gnutls.c index 17911ac5d1..84ce7073f5 100644 --- a/crypto/hash-gnutls.c +++ b/crypto/hash-gnutls.c @@ -1,6 +1,7 @@ /* * QEMU Crypto hash algorithms * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (c) 2021 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -53,52 +54,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) } =20 =20 -static int -qcrypto_gnutls_hash_bytesv(QCryptoHashAlgorithm alg, - const struct iovec *iov, - size_t niov, - uint8_t **result, - size_t *resultlen, - Error **errp) -{ - int i, ret; - gnutls_hash_hd_t hash; - - if (!qcrypto_hash_supports(alg)) { - error_setg(errp, - "Unknown hash algorithm %d", - alg); - return -1; - } - - ret =3D gnutls_hash_get_len(qcrypto_hash_alg_map[alg]); - if (*resultlen =3D=3D 0) { - *resultlen =3D ret; - *result =3D g_new0(uint8_t, *resultlen); - } else if (*resultlen !=3D ret) { - error_setg(errp, - "Result buffer size %zu is smaller than hash %d", - *resultlen, ret); - return -1; - } - - ret =3D gnutls_hash_init(&hash, qcrypto_hash_alg_map[alg]); - if (ret < 0) { - error_setg(errp, - "Unable to initialize hash algorithm: %s", - gnutls_strerror(ret)); - return -1; - } - - for (i =3D 0; i < niov; i++) { - gnutls_hash(hash, iov[i].iov_base, iov[i].iov_len); - } - - gnutls_hash_deinit(hash, *result); - return 0; -} =20 =20 QCryptoHashDriver qcrypto_hash_lib_driver =3D { - .hash_bytesv =3D qcrypto_gnutls_hash_bytesv, }; --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873289; cv=pass; d=zohomail.com; s=zohoarc; b=JJqKvfV1u/qy/br0ocZxCRmgWfwK5gsflmNkqK4fRGvDHdXKkK1NYCioxYh4oV1khGQon9uhb6OBfjS0tOF3G90tql7bYdLtfqisgroK8/fBkewaeY8YK9YwU7QcPRw0+jIb/gwvYp4L9a2aUOxYJFkwSN0gyWsNctKN7CSpry0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873289; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aOYvdr86AJGApb+tVJ4SvGt/cR/kaTrtmhtw4SGXa3s=; b=Nc+xpaP1c2z6Nis/MJS/9WSOVIHfxSSkbw5k6M6B9efXmya83y0pwH4OJ+NvtZSsBdFeKEKMVszoA695OoA55M8DbHMwjVDU+VocYOOlggOvOJLC+gQ3RtBzujhizmJofiqIjmmtOyIU9t3+3toulqWs4UGVx9Zg+y0N6BNITcI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873289461626.6501966895535; Mon, 5 Aug 2024 08:54:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb01c-0000jm-FK; Mon, 05 Aug 2024 11:53:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01a-0000gp-Jm; Mon, 05 Aug 2024 11:53:30 -0400 Received: from esa.hc4959-67.iphmx.com ([139.138.35.140]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01X-0003sn-33; Mon, 05 Aug 2024 11:53:30 -0400 Received: from mail-co1nam11lp2169.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.169]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:25 -0700 Received: from MW4PR04CA0386.namprd04.prod.outlook.com (2603:10b6:303:81::31) by BY1PR20MB6383.namprd20.prod.outlook.com (2603:10b6:a03:534::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.19; Mon, 5 Aug 2024 15:53:20 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::8b) by MW4PR04CA0386.outlook.office365.com (2603:10b6:303:81::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26 via Frontend Transport; Mon, 5 Aug 2024 15:53:20 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:53:19 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:58:11 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:53:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873207; x=1754409207; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bRs0liTPBFA6qYQWf1OelMarrTkexSqqEHIrgbX4WR0=; b=O0rCYy/izasajE1k5oHhx5TNEuS5OMwq8M5joyEsNSM/Yid0MpHSBjaU zDFj4kBk3ERgOmMAsva/Uv0fB3KOzsL0mxoMYuGue5mnV9r7M0XkDaW/0 wnuFIrMAYrn4sYRUXrY23NLpatSzSYN7XTxth6TSWRDCHYk71Y3Psl+GI 0=; X-CSE-ConnectionGUID: YSpsXEktTuqRx8hEc726mw== X-CSE-MsgGUID: YK9TPRrAS06tSmE6MzXHJw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sdABMpPRL1UKMVokiyIGZQuFKKj54VcqmluN722N40qPIZIyxrtRTAkDB7joJ11cvfuxmA4z/jvVLQ0yVs6diMRFbkM45pPWfiEknz89t1Gf48Ym/lOtyo1+RM+GrDqqdQgEyt9ogCUS4rZzmJPe3HyREnXbBxiyTw3z9I037OBphT7SgnkKnyVLF4gEWkfu8N+xuVoy6zyXGDKyN6Y30qlVZP1N8vXkxX6djxPwBzEWeplaAX9Y+yHqbFAcnZuZqgZPvw3uPmShN17quZsx1kLHfamjAAhKThWiy6R9jfstNtYr2jZAozR1x5Maics6aNzyBc+1EosGeW8oVmwrQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aOYvdr86AJGApb+tVJ4SvGt/cR/kaTrtmhtw4SGXa3s=; b=AFySbXzKN5oGpQXnz4BvpZHj19lh/3JOqo9J5OpE8xjCv58n8rtlV9iMe/7mJZYDzP/KGehibUdZAsB3AJRoHiidI33LSOVFPLwi59tdGo9BpBN/JrSYhsFQK+mPnDr2G/1qvFsMD9XrbJOCKbyCBB3hhzuWCPUxHsrPbvAmXksWjSmvlqwC6oRSPLokINHpu73FfhtF2qtPJ95gyQrKue5gyTr601KGga+p6WY9/tkUhqWXSwcLGv9kRsehVXzMnNvLidMZJnPkQIANG0t6/StKSBSw/dxDLMYu9wD0UZar7yBlt3BvbA4SX615FOrdKGV4g16LVZPvummpNoliYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aOYvdr86AJGApb+tVJ4SvGt/cR/kaTrtmhtw4SGXa3s=; b=XSbHuf9gMF8GiLKlPZ95ovdB7g5R4LnlTv5HUmwPwnW3LLuYPCJbxwzIeL4iem9LD31nuLkryDVyzggwVku2kj0I40vuzL2vGDMvTrTwLXCoiOp8sRP1zZUAdlFyGxdKwsRWKTtjrpVCpdYT+EEMunVmxxMl4NaMZXSkKeKYMAM= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: djF8FtbNR7+DFiqIU/lJsA== X-CSE-MsgGUID: 3OR42Mp6T9uWS9pw6+Bv+Q== X-CSE-ConnectionGUID: g3RVv88rT1mOrtJqh3TA7g== X-CSE-MsgGUID: aaHg/7FgQJKf0sWe6y/vxA== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920697" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 07/12] crypto/hash-gnutls: Implement new hash API Date: Mon, 5 Aug 2024 15:50:42 +0000 Message-Id: <20240805155047.3151540-8-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|BY1PR20MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: 50acf748-ad41-4433-bb0f-08dcb566ba8e STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?p/Bzjteci5YMhP9YLrWe0WKCf+fsqtHmwAJTMYWHmo8DwjLBzAm3F1edUuf3?= =?us-ascii?Q?1aOZcCtGfh+T/yQi/7l4YsPa4pD5QOWOxvWOA9/+nMmIdWHtg9d0yQKfgxXL?= =?us-ascii?Q?sJW3TuTNHeeKrKBq4I+u9C/iHVomzgcM3xUJo3W++RxRbnVJwHTkhc/MjZc7?= =?us-ascii?Q?Os//CNY4aAcwd3cXBETnudfblxSDTvw5iahJHbFsnOMysXK3Y5uYfL1DG1ob?= =?us-ascii?Q?Ekwc0ogIgjlhV25QH1qJAx8npU8JURWuxoAo+Si6QZSVqfafe0strDoRAGZR?= =?us-ascii?Q?/pEYH6ql1hgdqd/KXlNaqNTHRq9WB9UX26jyHNdE/5hDhGcoQrfxAMxkHx52?= =?us-ascii?Q?snvinjon2JIAbZqT8JVSNFQ+AJ6gqgHx8h9p9MPB6jyYZ2hLrlAvxsSvFOFR?= =?us-ascii?Q?IaI2/BjVFJ3x5Z3JeqWhKd+pK4ipqjTyDEE3rWpP3vUSIcIrFQqGket2ZVt2?= =?us-ascii?Q?LlQKQ+LfD92hlNg8Ldf2zuu68+lFUlZTn7v0zcvheLNqxGmnQ/46APkXnIkA?= =?us-ascii?Q?ulDMOCtUtDK3CIJ0/5ycX2yZzfTA7oSQXCMorCyRosGWJyeofU/Y5l+vB5KB?= =?us-ascii?Q?wckNHThvvB22q2HXZot1rVKlXzqOE3PM9AInghbEN39QbLGFd2ztA0Q8aR04?= =?us-ascii?Q?4cpc/OAF6HAIxhPGS5g2uMYdGAQYXFw6HWng2hf16ZsbfgKTlHuoWi7e7UNf?= =?us-ascii?Q?J3mUjBB3HyyqDJA97wivCnlD7Fc0T8UOI9G+iGlLU1pj57rao9Oxb+i3GO08?= =?us-ascii?Q?3PNLzbHJjb8/HJAwgIBugEUkrRxc3ybEESTBYQF6J5NfJwvlXzZnJo62gSQh?= =?us-ascii?Q?t2Kmcs7Ztdvndmk9ToXonp9UzsokszNocjX0wOfGLHwmc12UjnLygNnCktA7?= =?us-ascii?Q?q9KmH1/wK1SdeyBEOjwfkMKEv9lrru3RaEXZkecrcXTbmtyRmchKFjimvJJ8?= =?us-ascii?Q?WkrKXUmGqBftY7GzgNgAOiMpLXmgXUm7JhXyMHXpD4kZy+KEqPdr94orhQ9Y?= =?us-ascii?Q?FusuAjXQk1AIRiz7DLRDCIWovVsGrUbesSqc6JpLPSAe6yWOlUU42SntVDOO?= =?us-ascii?Q?7/S5Srg2WSyxQrjzB1y3KfFJ6cx4uKhQ5P7tehwOT1p7jsFLOkym1Z5AjeFF?= =?us-ascii?Q?0zGOicNOaj1i6ZCKWbulU4znea5yLD2N2JyOUq/FIrHlZKYAemTgSenvL2EE?= =?us-ascii?Q?6bScIzwEyPOwohh2ti5YJ/GkGGxOsGsywHs3mZ3myOOgMtxxMnK27DbVCf5/?= =?us-ascii?Q?WSZBm+xQIT5Vw6NGuv5GPNV8D8e6iqoVI46RlxXDbRlqQEAeLwSQU+rB5uYZ?= =?us-ascii?Q?mbSxNI2KfvpEKt1XcLH33r8dEL+p6pKbURvWsAAhrrzILALx3AM04PkEdJQ4?= =?us-ascii?Q?+1h9RbwfQ53ShE16mKsqyDjUlCXPZLn2ctOJG1qN8wspsEbPt9unBq8FFVNS?= =?us-ascii?Q?6thYpJTi5KT5oeNklHVD6EWpODH/3JCi?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: suuTQjUPpxbi6SUHnFt/ALcQjrqaQsEeXBjU2U0vvAWwR/PexRrX2QtcMhwjS8smFxc0ufOEQ3SJ+X+OiW775EaanG8YRgTfuMzQTuCPVLexDTDuzbJPQtkc3hVQ9Dt0imFcYb/ZmNAefY+ZFTRNVsVr4iK71iSeOoMJ43zJ5RyBnEJ12ERykjQLJQdmNH5yzov3ML4RbSGWBIHP7AJS9gyiy6w4GO3WuRngeJJWYJIbviLr3OiYlgUlIhCx9R44LC8Ft2RZkX3mMMzThMM5SaGdA4G7lybg6E50b9H0sZd4SZ3Y0CZAGWW5LsHwvt7hCbd8R41LQvlj7mdVNgD9tmD4bRz+cuHXbko85ygOSpjsBdDK0lwIcVZP99VDVCOh1IjNrgjVFgEFi7fIPAXJDQGelIY68SMPEEK92zAeKB7Ety6hziaNleneAa4U5V4/Vj9ifnZePJ0waB05SRGjpf24hWUvRdzUAgxya6W7up1/0X0edbmBo+NjMktd7h9DLlHlLIJzS1kCdYg4/cjv6mW8LBG9SuLpQi4kJ1RJpyWbOpGhqeHo5EYDlE7d806yqptCXaYpqI1XX9QNOxlh5RbylRsO7NGIGXB2wu0loBlb03Qbofs5mhfDvqpevMk9 X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:53:19.6756 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 50acf748-ad41-4433-bb0f-08dcb566ba8e X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR20MB6383 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=139.138.35.140; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873291474116600 Content-Type: text/plain; charset="utf-8" Implements the new hashing API in the gnutls hash driver. Supports creating/destroying a context, updating the context with input data and obtaining an output hash. Signed-off-by: Alejandro Zeise --- crypto/hash-gnutls.c | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/crypto/hash-gnutls.c b/crypto/hash-gnutls.c index 84ce7073f5..a2ccd257c7 100644 --- a/crypto/hash-gnutls.c +++ b/crypto/hash-gnutls.c @@ -53,8 +53,81 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) return false; } =20 +static +QCryptoHash *qcrypto_gnutls_hash_new(QCryptoHashAlgorithm alg, Error **err= p) +{ + QCryptoHash *hash =3D NULL; + + if (!qcrypto_hash_supports(alg)) { + error_setg(errp, + "Unknown hash algorithm %d", + alg); + } else { + hash =3D g_new(QCryptoHash, 1); + hash->alg =3D alg; + hash->opaque =3D g_new(gnutls_hash_hd_t, 1); + + gnutls_hash_init(hash->opaque, qcrypto_hash_alg_map[alg]); + } + + return hash; +} + +static +int qcrypto_gnutls_hash_free(QCryptoHash *hash) +{ + gnutls_hash_hd_t *ctx =3D hash->opaque; + + g_free(ctx); + g_free(hash); + + return 0; +} =20 =20 +static +int qcrypto_gnutls_hash_update(QCryptoHash *hash, + const struct iovec *iov, + size_t niov, + Error **errp) +{ + int fail =3D 0; + gnutls_hash_hd_t *ctx =3D hash->opaque; + + for (int i =3D 0; i < niov; i++) { + fail =3D gnutls_hash(*ctx, iov[i].iov_base, iov[i].iov_len) || fai= l; + } + + return fail; +} + +static +int qcrypto_gnutls_hash_finalize(QCryptoHash *hash, + uint8_t **result, + size_t *result_len, + Error **errp) +{ + int ret =3D 0; + gnutls_hash_hd_t *ctx =3D hash->opaque; + + *result_len =3D gnutls_hash_get_len(qcrypto_hash_alg_map[hash->alg]); + if (*result_len =3D=3D 0) { + error_setg(errp, "%s", + "Unable to get hash length"); + ret =3D -1; + } else { + *result =3D g_new(uint8_t, *result_len); + + gnutls_hash_deinit(*ctx, *result); + } + + return ret; +} + =20 QCryptoHashDriver qcrypto_hash_lib_driver =3D { + .hash_new =3D qcrypto_gnutls_hash_new, + .hash_free =3D qcrypto_gnutls_hash_free, + .hash_update =3D qcrypto_gnutls_hash_update, + .hash_finalize =3D qcrypto_gnutls_hash_finalize }; --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873310; cv=pass; d=zohomail.com; s=zohoarc; b=lL68vvsQb5Ne2didExKAKNa7Zm6/qr6EEyQP7tUEb1jb7igdsqXEFFH5e63guE9fXrU7P8MqI/cPwW12MX60zGrCLgw+TfLvsaM1LD+ACXidJsfPfUxysUPoBGti2uhl9ED76zuriZwU4iwXWQ1VZ9JZkQkUkew4th5CFm1nQRk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873310; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VFbr4IDJWHmLiqfirPbZROscpP9gK+D4QLeaG5igLvM=; b=LMeNTlrTIkfQUX89n13w1KD8GR6OLZlIcEW+Cb5+WYCwqfWT/jb+XBW9tCDmf8+zG4AkZUZDIQ/FM6zkrx6LTQXSBPxkmPJ02+qGqqCrbsM2lg8KgoEZRfDyKxhKSmgPHjfInDBMDtKIAXkPqZ40CMwdYoxPlclLLXj+n77n83M= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172287331033513.953038178800853; Mon, 5 Aug 2024 08:55:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb01e-0000qq-8t; Mon, 05 Aug 2024 11:53:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01c-0000lN-P7; Mon, 05 Aug 2024 11:53:32 -0400 Received: from esa.hc4959-67.iphmx.com ([139.138.35.140]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01b-0003ue-1N; Mon, 05 Aug 2024 11:53:32 -0400 Received: from mail-mw2nam12lp2048.outbound.protection.outlook.com (HELO NAM12-MW2-obe.outbound.protection.outlook.com) ([104.47.66.48]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:28 -0700 Received: from MW4PR04CA0380.namprd04.prod.outlook.com (2603:10b6:303:81::25) by DM4PR20MB4703.namprd20.prod.outlook.com (2603:10b6:8:aa::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 15:53:25 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::10) by MW4PR04CA0380.outlook.office365.com (2603:10b6:303:81::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26 via Frontend Transport; Mon, 5 Aug 2024 15:53:25 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:53:25 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:58:17 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:53:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873210; x=1754409210; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4aukmjNZLOYAUtGh3i2jsQ2Ta316XlPTZ6e/png8yXw=; b=q0nqhhcpjMojovnubUxHCnexj2Rvu7EphXV+WFX+q/a0Yt/ZqMziF58I Z0yDFCWAT5Gj9/HvXDSWK+OLrRPrIrqwcIiHn0gieV0yUOS48iLEwZLo5 4j3xJ8ikmUVtMvlITCxmX7NL9BSM+3LTUHloGbNCv9NyF4NHWWKMwv544 k=; X-CSE-ConnectionGUID: fVVPxabRSmq3Fogi8cCMSQ== X-CSE-MsgGUID: iY1dCDbHS0ew1Cnza3M/Wg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LN6mo9jzFA/8aS1pdFLLcA4BcitUfRgkRDxCjEMxIVPrsdDHGY05m8SxAdVhB9HcFGWxEOa+scA/t/WW334YsSoy/MuL2cCCozj3ltFaXdqurSIRp/fjy6YkzDS+EVE0/X+cFMnbWwDhJmXK5cudwu2c4a82263Ie3V6KUKCu5Yl6O/4nZEuofbU/D5o54VnnhTNQEwfGSAWg0eIKSiIBpoNuAFkpa915iOfbTazAmPPDd0wezD5BqknBP92HIrl7y6qBFWvJ0MmKQqUYsDdudAVHSjozKBSEiVUkGRNJXetDQwuxLRFpTCzzSJzxk2MWcqi07kvITvBEEkzxvilFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VFbr4IDJWHmLiqfirPbZROscpP9gK+D4QLeaG5igLvM=; b=adabS9DOYcLHdtoyJ7WvP6hs7/j1gpAy6z6x23vsygAS3VKiv+o+DWpRtRvxU9fB5jDq0Oo1H2SJwYf0suyuarwiPBkZJqh2g8egcWjFCb2WPhDo/yjoTOBmRf5X3jN5DGVghge+bo4khN1CqG2IWanerl1Vxe7b24v9yI7Gk2pSrdWOHBInQi7ITDTBkDw2qlRL3djEr7uQOyHud0KZb6N0pN71OZev//ZrIvPPVaz22xNba/ehH4XOrvPM9QLi9pO/z6blKA+NZjxSe0Cv47dk7YTWHfcAwcnHflzwdQZL6YQ5IaVthBEwSnh+wyN9X4CKBO8Jl8QXzCfZzp3i2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VFbr4IDJWHmLiqfirPbZROscpP9gK+D4QLeaG5igLvM=; b=WN+uSsyEY8xrcaVcF+qFZQiZw1I+k47BGgWCHKOU5z6O6dZ5QiVXrHckkXptCsogV1YsqIw/qU7LWQkB9zxg30RJ2KLP/4xYELc6rlbuitfJt6t/MvvOptN1WdiY4MENDFlgTGbaJm0rPz8KtnOYOBGgpD24yCcx8+3wckjD9P8= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: HvL6uwxhTk2Nv/k+vBqFbQ== X-CSE-MsgGUID: EJxyGIaKS3a+sd+FY+GxJg== X-CSE-ConnectionGUID: Bx2ZDrgjQWmJJzBBXPfnOQ== X-CSE-MsgGUID: tdI0H+YfSI2KqJcCIRL4vg== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920700" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 08/12] crypto/hash-nettle: Remove old hash API Date: Mon, 5 Aug 2024 15:50:43 +0000 Message-Id: <20240805155047.3151540-9-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|DM4PR20MB4703:EE_ X-MS-Office365-Filtering-Correlation-Id: a690c78c-30e1-422b-0b76-08dcb566bdca STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yhKxJ7qREN59huyooQCyvbPwT0cHqSRqZTUdhno0vdrSkiCl11girYYlihtP?= =?us-ascii?Q?v03LHsH06cfQCGvnmnyKfeebU0Sgq4RedQEeuovdgMThvyPnyq7BmRrOkhwX?= =?us-ascii?Q?bHxU0pIqe19D21B1faY/pvyuMQyyRR1jTzapMXj46+FaRPwvmKhtiFEl19Zc?= =?us-ascii?Q?z506Z2SHmRGIwZUkx75XN65g6ftd5NMaHsoKXoai9Ya6myvfOhheFyzW5vZ/?= =?us-ascii?Q?u8IdL6kvWOIrfJCi1nRId/AQmC9XnQnL00e80xp0WaoTFYBOJoip9Nalp1bu?= =?us-ascii?Q?zYLc2GCbT3Dxj5vHoO1nI+s5fqewl6mn2pdFr3E3MtsJThzNGHKBJteZE3y7?= =?us-ascii?Q?s2WckXKkk1HiMccE8Sg7zOptzThdCbVyjdn1sXr4EDOeJQ5LenPBQ94zlq3i?= =?us-ascii?Q?6fVwWg4Im9WPIab/CpgZVyZp3ugjQMsqHDNppjt3vqZ7y5LfuMR88ZpbHqCw?= =?us-ascii?Q?G1yjFpwCqW3faUdwY5g/0OjPwbYHIZbtRasAaYObrSvJZz5kCRvVH4BJ0glJ?= =?us-ascii?Q?nyoZ8BRdgjAUdehWTYEj0nQVeBy5E7uT5qcyyHEqnvkFBP1ZgtpyhMzqPnX5?= =?us-ascii?Q?oIgHNI5p40e1aurPHCBLmTD8DWFFgPRjpgZn3CG/k8CiDk1+yzxBSNoIikBD?= =?us-ascii?Q?7OB77vF55W5Vu03YoBoJYmrF306F2RnGJVhP3BxvSWJukztYYLqcsrjcB6nw?= =?us-ascii?Q?V+3RbW9IwrbrLg+LI9JdUnpCZ0a/QQeHcySAC64+JwXUMwBu1HOt28dO5Oh+?= =?us-ascii?Q?s6ZtYoJKDbD2AuEwNWWWaM3TdCCxmXxfomhs8EWclz6iOhPq/8RazvfeIJij?= =?us-ascii?Q?DxPtxOZgCaTQFefmNmHqP6PW2M0cGKKQvu8Ze7x87vKR5T75i4rFRW+tiMCo?= =?us-ascii?Q?tFMCmJari0FrPygdkmIZ1Z88xJFeccfq5Fb31pxIsbR9tK/LpnqsjPFGjqrF?= =?us-ascii?Q?d9z1QT/GW6zBskPP9mVjWw+suEE18ijc5DT6swFWIZdzR7duzEu2w2uWoNdR?= =?us-ascii?Q?7HVAtIABDYgGQybWF3Y+fd5j/S2mGr2HI5uQICioIv+2QBr+csJFe6+2qjPp?= =?us-ascii?Q?HUsUE0UURqy2KwndnTTR/y6Plb9DTtqNmh7HZsWDB4OTWIknKDwx8rOPXXBf?= =?us-ascii?Q?1RovfS/1HdGQVm902BSoUqwbXXSlyvF9GBK8NjqbQf9tIoJWG6glhM+MswKt?= =?us-ascii?Q?2zvR/CnZ9hh7jtIdMAoqi4It2SCUNhJZ5DeOtu7OCjoGOFwK3ZXxmCV94GSO?= =?us-ascii?Q?tEik8Z3x+chYm0RK+yocYLcSUWurtgQilDoBRgnKfRlGmcKb4jR3vvwYjQFt?= =?us-ascii?Q?fTjTZ7I5Uu5beo+4Hh7Su9XFTzfPl5D+RBIM52jjaU3D21RuJR3LrisZEU7o?= =?us-ascii?Q?uFXrDCWTjvpIyG48eY70ngosjS3LL6jSpOnz3WW/6Pxf9/ol8nkuWI7MMQ6z?= =?us-ascii?Q?gg9uGaAqSmZ9ONYdQruT5K+iipVfb2sC?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: sLf2isyrZv4ZG0zYd2hXdwpcElLbgFEam9IRzWjyeR7pQNoTdvKjQIAxEPypD5lmqO6EzvL0phOweK+kCaF7bjGo88o/GvBxGFQUI7qU87rBd0F0w/X0KxDZwlmt/53OJfNs1KpBm65ea0j3v1nps8azxCLbMrvOWdC36XI4HVx56VEf0hyG+yjWPfJUFy4GF+pZgsyPSOZ7+vsF6OQdgmsetW+P392SGaKVgJvbvYLcLJU2Di7LIpg+PZ7BoK5vmoaM7Y/A+hFQqdDhFC3vxAf2WlAFBpy+8GQCj0dePwCLHcaA+zcYyuoUNfqrnBsk+sc9GtRCfx7ydOOB3DATi+67D3bmCyHcN0rASGblTM34UgthViRV49eFcY0GaFIkdAUIdXCiR4prBIO9Gd/tuQRQfg+CeEuSzCbV26V0iQu/F5mUizgq/lTcpWSOrIArAuFdWIjsWcBZsmK9vd56tXuwjAuMQjHDGQiQrzckId7+wbukNev6ty3oVord4OIfdWxg5+KBFwkccxSK2h+Mw/5WQOhJOIyvDsMbVNzjiYFA0IQGX0GQthlHBCd+gUJiagHcaT6ICXeMxJUfPXWd9AMICeX7h6FPMLrIlEFkMhHs8j5dtK8wANXETmZZqXGS X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:53:25.0975 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a690c78c-30e1-422b-0b76-08dcb566bdca X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR20MB4703 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=139.138.35.140; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873311532116600 Content-Type: text/plain; charset="utf-8" Removes old implemention in the nettle hash driver. Will be replaced with a new implementation in accordance with the accumulative hashing changes in the patch series. Signed-off-by: Alejandro Zeise --- crypto/hash-nettle.c | 52 +------------------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/crypto/hash-nettle.c b/crypto/hash-nettle.c index 1ca1a41062..dbf1d96dfe 100644 --- a/crypto/hash-nettle.c +++ b/crypto/hash-nettle.c @@ -1,6 +1,7 @@ /* * QEMU Crypto hash algorithms * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (c) 2016 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -104,58 +105,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm al= g) } =20 =20 -static int -qcrypto_nettle_hash_bytesv(QCryptoHashAlgorithm alg, - const struct iovec *iov, - size_t niov, - uint8_t **result, - size_t *resultlen, - Error **errp) -{ - size_t i; - union qcrypto_hash_ctx ctx; - - if (!qcrypto_hash_supports(alg)) { - error_setg(errp, - "Unknown hash algorithm %d", - alg); - return -1; - } - - qcrypto_hash_alg_map[alg].init(&ctx); - - for (i =3D 0; i < niov; i++) { - /* Some versions of nettle have functions - * declared with 'int' instead of 'size_t' - * so to be safe avoid writing more than - * UINT_MAX bytes at a time - */ - size_t len =3D iov[i].iov_len; - uint8_t *base =3D iov[i].iov_base; - while (len) { - size_t shortlen =3D MIN(len, UINT_MAX); - qcrypto_hash_alg_map[alg].write(&ctx, len, base); - len -=3D shortlen; - base +=3D len; - } - } - - if (*resultlen =3D=3D 0) { - *resultlen =3D qcrypto_hash_alg_map[alg].len; - *result =3D g_new0(uint8_t, *resultlen); - } else if (*resultlen !=3D qcrypto_hash_alg_map[alg].len) { - error_setg(errp, - "Result buffer size %zu is smaller than hash %zu", - *resultlen, qcrypto_hash_alg_map[alg].len); - return -1; - } - - qcrypto_hash_alg_map[alg].result(&ctx, *resultlen, *result); - - return 0; -} =20 =20 QCryptoHashDriver qcrypto_hash_lib_driver =3D { - .hash_bytesv =3D qcrypto_nettle_hash_bytesv, }; --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873310; cv=pass; d=zohomail.com; s=zohoarc; b=Te2ebZg9lLOW7+ENdVONLxLG/pFfN6HHok2mRl3gXHiFA7djZ75OJ7Kex7FwAu4WGkruXeDm5cPoReYbdpSaxm4f3eKjJPaPc2rkEze4ttY0UjATkNEzLlJAxdAunZwNVBi1Xa9QzDXauKQe/iRcIap5wr2QhpraR4xp/uyS0AE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873310; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OkkETshu4Tahurh9Otyue1OjYmjFHx7HywzpAfsFfvA=; b=Zib30R2+p6PEJddvutlxP0razKtsYr5Gpv/C3otTSWuuooWHzHVa+f7d/mrhHhqlwPucFftHq5pSLBidkB5l85DUjLUt88udnosocZyzQHApy+8z4xUHhw8jMTuE9xgC02PJzlha+3Lljg6GwgL45NYOslypPkDAeY1h1eChAAY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873310139909.1592612820465; Mon, 5 Aug 2024 08:55:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb020-0002RG-MW; Mon, 05 Aug 2024 11:53:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01o-0001bS-Sq; Mon, 05 Aug 2024 11:53:45 -0400 Received: from esa.hc4959-67.iphmx.com ([216.71.153.94]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01g-0003vb-JN; Mon, 05 Aug 2024 11:53:38 -0400 Received: from mail-dm6nam11lp2169.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.169]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:33 -0700 Received: from MW4PR04CA0380.namprd04.prod.outlook.com (2603:10b6:303:81::25) by MN0PR20MB7295.namprd20.prod.outlook.com (2603:10b6:208:4c6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.21; Mon, 5 Aug 2024 15:53:31 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::18) by MW4PR04CA0380.outlook.office365.com (2603:10b6:303:81::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26 via Frontend Transport; Mon, 5 Aug 2024 15:53:30 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:53:30 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:58:22 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:53:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873216; x=1754409216; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YAcpsHbRyjafddjdwq3SOJPAqP0qhBsQDpIJXGUFrD4=; b=Tu0w2jHJGFCqcACucp2luhuWkoA6X3pbHVkl26+ehmeWyGe40iJmMx4V xNFzAyGVbzpLd6cQ000voQjOP/Bc6HbzJIJ2C0dWjAi2d9RmxMwtVpMV+ u9QFZ5tmbqhE3fTatiVAyrVfv6cm83YrTBrvyVZTPI1DL+1wQ9j7TF4mm E=; X-CSE-ConnectionGUID: sknDlHmBTW6kTuLTTW//ZQ== X-CSE-MsgGUID: BHuKFwi5TV+EmaqQjzPpMw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ukcXA4w2wGbZJu8HxwombSBwOVfRNi6zU+GtL7UL466SxO8EEyjE31zY9gvCxUxB2hDEh9foON5XXLVUFK2biwHN7pydWL4pAJHcsKQAQyRGi2g0wtAd7X9nOUk6arJph6b6A2zBi73Gr/NIHutWR71fuHpElQxoEc2mZZy/DQ/oJRuiO1kipRCd9/rKdCQWf7SxBxBCs0/0WSsDSNqeUcXdJabbF1HR+798aZDp3X8jrBHdEMxVZM4OEeIZvrJUZyDIqcectiapNlEKQPa3DCpZ83pgeESamSqW99yT9mtOI3sWkTtKcIP12QkbvQEe3OVb19NNX82HcZPvd2gqXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OkkETshu4Tahurh9Otyue1OjYmjFHx7HywzpAfsFfvA=; b=kR8Gl7gi7Op9zp71cdVHe7/FZF1CFc6gwedTeoT0vryQRRzWpljnrXVPvnWYjih2ocDyr0b1TPvicPg+UbXfG2sQiCXZtmiB3tVhl9Fa6qSYDwmUqqz/kZyfR2TfuF12YUhdgDXGr6tzxxScY1aCjbqkmZag4fsFmVCGu5p030ZbCVuXFYc2hf+M6Q+djqIOSbU+zMdx+HQUGCF2ybI6I/gjgue/3pdL6fRbR3vinWsA+1vvZoGx5qSvUA3HlyBkW86CRLqx9eFbY8mvn7wBbBNV1BsTHbRQe8qwAuyi/9vuKxb4ccAUgg/DTid0Os9ssZQQxJ3GI5PFVH5YhuGpIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OkkETshu4Tahurh9Otyue1OjYmjFHx7HywzpAfsFfvA=; b=HSdMpYmozYCtNNFhmToiTn9+toFrX5Mh/CXpEMek2ggI3sK4Alo7CapKKKVZLdlBwLMvsd2+7MMtLSQwoqWsjJufWMFebI6VWS4VazmxzfCdVc5QZNhzuzPTIyGTHEFlx/Zefy20QRAH65STma7zIALUpe7OAF6q6mYPsnjDqEc= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: q97XCLWNRPmrSLawGTm+TQ== X-CSE-MsgGUID: 2hQxtgTRRdGFu85gIoALKg== X-CSE-ConnectionGUID: jehKeLENROKMeNOsFpFrbw== X-CSE-MsgGUID: 1w1V3s5ZT8yvlgGAFyHBdg== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920703" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 09/12] crypto/hash-nettle: Implement new hash API Date: Mon, 5 Aug 2024 15:50:44 +0000 Message-Id: <20240805155047.3151540-10-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|MN0PR20MB7295:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c5c9f7a-1a58-4cdf-9772-08dcb566c100 STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?A7pAufSjiE//STcc2lV2iQ0+sU+k9gCzMd6BIiwI38lkE4koRmbCzeS6nHqT?= =?us-ascii?Q?xRZyDS5W8JXQjnFSETE0piaqD9n1QZyNCFOQ0GfbDi6AF6WaKNS428AyRjBG?= =?us-ascii?Q?GGMApUaRf0GGVAhqvdt46iMrfrXCdGnPBE/0fu8lH4C1gRWtc1gDjVeGOS3q?= =?us-ascii?Q?utkatxIMUcjff/J2bpGcnhnYJEQ2nQaMXKl08lVO4p0Sg3/xHlWdvgzAVScg?= =?us-ascii?Q?YHJvQzrefkQswY3xzLZQDZ4FoQFYzqHCnl/WNlEb65AXuuuizelk+Rlv3klz?= =?us-ascii?Q?hSuAdg9L9enJSOWKFNdigk3gC+hbSDXuSrwEZIHZpdaN02wX/IYFjcOjSRQX?= =?us-ascii?Q?dtapuNTzz/w0DZnY4tl8wJq7FISvhjpN+Bn2ymWfDfGJN6PVioeFZZU0BruW?= =?us-ascii?Q?6bKtA5N2TNgbn8dRU6y/5hNliUOcYq4cwVEv40C1b38AUnZ8Q/sOdT4e45iB?= =?us-ascii?Q?YfhI8KiBHrUO+NgID44yxwb71yhRW/0kDpbHuqdWqXc3rhxs5A6YoFFEVhFz?= =?us-ascii?Q?5ReQu3ree+fMpdV2Y7fOEp4LF1yfw/Qs1w1AGRi4mfc2NWr0HPQeBKzEd7fD?= =?us-ascii?Q?bTQzUSW6eGQpIkD7a4IDukKeF+lC1FO7jCN2UwbZGZk6WkLbHUDhWnxfuR5A?= =?us-ascii?Q?IGmkfTAwHOnpHMQcT7wNhPT/PqiEprYRO6MdPUBbr8sUeHxCwCAdsef6Q/9B?= =?us-ascii?Q?RRjel21sAqq1ykezSYmHrIuEsUT3x0g3BruzoCgFnbdAq7PaypRP/2kH0wx4?= =?us-ascii?Q?0hpXw5QFQzdg1TR0hvICoAWaU6acsRfCLBl7BV3jyiVddqc+dceAThtScnmX?= =?us-ascii?Q?PwpjRF1dQjMRZ2EhCegbVB3+vrI/q+UK2atf5D+M7yqiTgQNMyrVCzuJb7Qp?= =?us-ascii?Q?vpDhlaxapCKAGxY4Ct18PxtTlV23OkLH05EAs8NqddpwqYsHaq4P0Pabvbpu?= =?us-ascii?Q?+EAegXOd8bA3rjqE3eHcxXnaYHeGanevkJ8T1gZTEJN4IqfwrKP5JFpFabv1?= =?us-ascii?Q?WgoRwdqWDj5z6Y38Fzx/khFSz0LiNQj+5dzfa8OXSTpYraFi4cljWaepDyno?= =?us-ascii?Q?DoBIYuJNH8kSxnhXH0eRRCeho1pkot9ueDbxm1FWsSHnL6R1VIbQdE2I24KQ?= =?us-ascii?Q?7w5K2+pEZunezkXvWc6eBVcnyqjJ7EdjCdQVM/REpYrrzrB3z/goURqtgVvr?= =?us-ascii?Q?mfs40FFnTzGC5Mtw6kZ1sAV9G8JPGB55XWpZnU21yBoFPUu1aGsMGEDjFOGB?= =?us-ascii?Q?6df8sLyA5IWEm8osqEzTj35dF7MUs23X87MgzUJr5RUQU4J8HBCnCmvsmTA/?= =?us-ascii?Q?TjH1FZqDfHXFBpASnXMC9GEVrim97pi1dC9ouO6iguzI/7usMktElPZz8M0V?= =?us-ascii?Q?ejOnMb9Jb2lvC0V5+kfB2j5pZnx9k64GQbO53whlwEHa5XBtky/kqoyouNbC?= =?us-ascii?Q?8h0fj0DLpo5YnzkNvY6qJLjROTzaakEY?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0qAbv+Qch0JsTy/jxjDzjiRlgsXwUUonx8LJDeG3Vbl3Th9uwsz2qR0h/aHTUo0ijgAL+CSIfw/oWzCYlsRzvhWwv6ZU2pxis9X7krW5EvfTTnXuqXQspTNXR18uOrANWmZzgqx1SkePiscw1gJy9tSwPfMRCu0SaotWZ9fALTpqmQWQeD6+2M7ZmoDZRBXVj4CcbxueTbqp0daB49Wq0wC+sphYN2vLt2cwPDcUuEOZRw7cNXFfTqFkhjfxjkb5v5xu1sHgXdlD3Ng1P4QHCvbgigpacvqVdvMJQUn7jAEdq5EjlH9w+h8vYAvdPJCG9N0m8cpnqc3QS+cP7Ckr5zmouvB1jM/GButruHvdvlKtjbKRwsJ5yArtUe7Bgtw4A7z+nSs3N18FqtgfWB1nM3EWNfqCugN+wIDP1cpW6v3vLwPRa7wklCia6PP5IZaYPeVq8przcMunD6p60UZoJ3wn6HH7WxiraaOXRK/jM6BII21j6mE3WMeNqmezG4+nUWUP1Jv5mphrB4AV3Mof8NVYTfgDPXNSyX/4b68zqmk99j0e8fAODXhyj8Z+6d6ZeUl3NO6KAznsR2dNNIh+3P7ZKzka2/o/njLW7dtPihX019rum5RkEZqwd5daAsJd X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:53:30.5038 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c5c9f7a-1a58-4cdf-9772-08dcb566c100 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR20MB7295 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.94; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873311535116600 Content-Type: text/plain; charset="utf-8" Implements the new hashing API in the nettle hash driver. Supports creating/destroying a context, updating the context with input data and obtaining an output hash. Signed-off-by: Alejandro Zeise --- crypto/hash-nettle.c | 81 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/crypto/hash-nettle.c b/crypto/hash-nettle.c index dbf1d96dfe..643f3d68b8 100644 --- a/crypto/hash-nettle.c +++ b/crypto/hash-nettle.c @@ -23,6 +23,7 @@ #include "qapi/error.h" #include "crypto/hash.h" #include "hashpriv.h" +#include #include #include #include @@ -105,7 +106,85 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm al= g) } =20 =20 +static +QCryptoHash *qcrypto_nettle_hash_new(QCryptoHashAlgorithm alg, Error **err= p) +{ + QCryptoHash *hash =3D NULL; + + if (!qcrypto_hash_supports(alg)) { + error_setg(errp, + "Unknown hash algorithm %d", + alg); + } else { + hash =3D g_new(QCryptoHash, 1); + hash->alg =3D alg; + hash->opaque =3D g_new(union qcrypto_hash_ctx, 1); + + qcrypto_hash_alg_map[alg].init(hash->opaque); + } + + return hash; +} + +static +int qcrypto_nettle_hash_free(QCryptoHash *hash) +{ + union qcrypto_hash_ctx *ctx =3D hash->opaque; + + g_free(ctx); + g_free(hash); + + return 0; +} + +static +int qcrypto_nettle_hash_update(QCryptoHash *hash, + const struct iovec *iov, + size_t niov, + Error **errp) +{ + union qcrypto_hash_ctx *ctx =3D hash->opaque; + + for (int i =3D 0; i < niov; i++) { + /* + * Some versions of nettle have functions + * declared with 'int' instead of 'size_t' + * so to be safe avoid writing more than + * UINT_MAX bytes at a time + */ + size_t len =3D iov[i].iov_len; + uint8_t *base =3D iov[i].iov_base; + while (len) { + size_t shortlen =3D MIN(len, UINT_MAX); + qcrypto_hash_alg_map[hash->alg].write(ctx, len, base); + len -=3D shortlen; + base +=3D len; + } + } + + return 0; +} + +static +int qcrypto_nettle_hash_finalize(QCryptoHash *hash, + uint8_t **result, + size_t *result_len, + Error **errp) +{ + union qcrypto_hash_ctx *ctx =3D hash->opaque; + + *result_len =3D qcrypto_hash_alg_map[hash->alg].len; + *result =3D g_new(uint8_t, *result_len); + + qcrypto_hash_alg_map[hash->alg].result(ctx, *result_len, *result); + + return 0; +} =20 =20 QCryptoHashDriver qcrypto_hash_lib_driver =3D { + .hash_new =3D qcrypto_nettle_hash_new, + .hash_free =3D qcrypto_nettle_hash_free, + .hash_update =3D qcrypto_nettle_hash_update, + .hash_finalize =3D qcrypto_nettle_hash_finalize }; --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873290; cv=pass; d=zohomail.com; s=zohoarc; b=H6zj73+APL0XQrYbRkAO7MZ9CFzaLMAM9XCmWEkHhxK3m+qEYSDEO4gjbAnMHzooDzsVOKV+Yy+0EpBQJElHxu74MnLKhrbP2F+4ef3DqK05iB19YbhzGglbN6OAGOrRweVg9J+NTkjI07Y1wUM+NQ9IXl6Iuj7ReZrmEd3caeM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873290; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=f6RNsShmzT8hf/U8O5y5PIS9KvRt7INqxfDhrBJ28V4=; b=KN49r7MaSUURTmlpouqIz1JmAAiUS97tPWOrTW2QPCsnyg9x82tD8Xi1+9Gu4XjdF45tBEX2Ab+UApe+3P3jbCzqPyNxpD9OA/FhOSUgSd6GLU4P7K6gX4EDClNtLzitZlsAwGH8ZvGdBxNGGfQXEnT22TiJBq6GUYQ1Pr+UOqA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873290404119.241554677154; Mon, 5 Aug 2024 08:54:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb02R-0004Lf-MI; Mon, 05 Aug 2024 11:54:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01r-0001rz-R5; Mon, 05 Aug 2024 11:53:49 -0400 Received: from esa.hc4959-67.iphmx.com ([216.71.153.94]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01p-0003xv-Dq; Mon, 05 Aug 2024 11:53:47 -0400 Received: from mail-mw2nam12lp2042.outbound.protection.outlook.com (HELO NAM12-MW2-obe.outbound.protection.outlook.com) ([104.47.66.42]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:40 -0700 Received: from MW4PR04CA0362.namprd04.prod.outlook.com (2603:10b6:303:81::7) by LV8PR20MB7182.namprd20.prod.outlook.com (2603:10b6:408:22e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.21; Mon, 5 Aug 2024 15:53:37 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::50) by MW4PR04CA0362.outlook.office365.com (2603:10b6:303:81::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27 via Frontend Transport; Mon, 5 Aug 2024 15:53:36 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:53:35 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:58:28 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:53:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873226; x=1754409226; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q8V4nZTWpLeJ6mnlkkch+mcRbWAOhaEqX9oQWzkg3rc=; b=GNUZ6h0YSy6sxgFJ4NRwaftTNNdTpMO0+3LwdBZdos1/jDxJhJo2r5Ok rgmjXuwiKa6cjYPBiKSrSni0baUW0cllO9LRlcrrpyKAvAMZnHDqIpkVz Td8RF8J2kQkSo30aq7XaoTBa1wAIcOvbv+SiYlMQdE4zhNG2QwOoY17Md o=; X-CSE-ConnectionGUID: EQQ0XoOpTniAfQ0NZjI/5A== X-CSE-MsgGUID: DRPD1NFkQU6I7n3JHmvHmQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q0/zc6mcGyKBDHecgYQEiHo6C7L7etwpSPfCuhEDwRTe5d3pRRUOpy2hYce4+k/hxWMQ5d8QSDvnWuvV09jgWd7fTbbGIJ0BnFzP/xZXFaM3I0uYbWt2Rcc+qQmCkm/0ZHaHMHqrUm+qPDxh+Iy5ZWWfYLbZ4h8EquJ8TTXbDHsuapzl/qCaPB4tVNjfM1UwxCyrpIBYC1zS2j8fYXU05Ait5vFEsRFD1jNe7wJROJmNn96estmTQYSVeH5CJHEd8bV8KelArcHJt5FkUqAh5d7Vv1ScNmUk/v+ER8cIKAOXNvnXTeqdUVyZkJB2Jg/QZ/xJnFkjwOhozhJ3FE/3tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f6RNsShmzT8hf/U8O5y5PIS9KvRt7INqxfDhrBJ28V4=; b=sDC1ZOskeYJ1WmfnrskVOFV/a9gOT9BT8JCZ2iATY3YvjJnsnuMhx8gua37I1YrV5Qxxpggh3pUuXFo0F++u2wLg0tl55iVyIpzbN9HWlCqHI016a6HhtNRoZJH3ZBRqgMib3RYoRteQYxtc4UEZ94sLgwpA2Ys8T0IEAXwnJfaukX7Y8x7ZYh8yNoKVVeHIVjm38Y9jxYHtvl1F1Rf4nFKaCTsuuB38j1PibRILbF+hyxd50JEDeqRS9spp1rN+kHf57he0DGJNNrywDfY1mnrg8jL/fMMwCqxK4a8St4Htsb16qIeNDd3VASljA3pn+aRv7LJ2uX1WGOiM93SSxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f6RNsShmzT8hf/U8O5y5PIS9KvRt7INqxfDhrBJ28V4=; b=bihWPPjXfbDOOQknNICAPpxzcGkY6/OgNw4/nMSZ0Bf0nDXhHIArXfiZ+DIUqzAwmYRbuvgMKzKGouunnT67Gqf1Yxe02K6SdvI0/xfqc/Ewk95dO0+N9y22mSYvouLgiZZeTNSzIySA5S1EaT76Io0lgVvYaCH31OfiX0zKqD8= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: +elo7vlkTYWnCb5xY9RZXg== X-CSE-MsgGUID: PYEgSyy1TNmRDDylaO6W3g== X-CSE-ConnectionGUID: foNXdDyqQ6i6HeyAvR3W4g== X-CSE-MsgGUID: +bnd2LqgTsehuxFmvDKFOw== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920704" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 10/12] crypto/hash-afalg: Update to new API Date: Mon, 5 Aug 2024 15:50:45 +0000 Message-Id: <20240805155047.3151540-11-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|LV8PR20MB7182:EE_ X-MS-Office365-Filtering-Correlation-Id: 04be3bc5-fc8b-43cf-8589-08dcb566c439 STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?s+rrfnuMxQx4Q/9w7p+YUn5FumtJ4TC6YQFSn0Kpu42qz0hGKVCyp58vzlr4?= =?us-ascii?Q?yzJkv/IDsFSZbGFR5O/IvRl7zVk/gE6OM/Tbr6DsS5Gx6bV9b5s+IChPMwId?= =?us-ascii?Q?nNg9au5K7EUDUYb3b3rEnTWo6Zeai50mcoJor3bVtX0xFPbSyMJ9qYKYrDAh?= =?us-ascii?Q?SJbW9XmmWt40znkRQ3uZwUjzf+XZYsWHu9/aj58J251ydk7ZDOLqgOrwOAxV?= =?us-ascii?Q?g4AM17XjQnc+RL7qbiLHDCoho9HGMIC9TEDxpX9smuHI1bcuxN9LxMOY3v29?= =?us-ascii?Q?QClNMfnil1sfLinoIhwZ69c1OLhyNl4dekgVHzDloL54w/AqtCEoG9ZC+jXK?= =?us-ascii?Q?yUnUGFJmPMvU8S3FhIEhuwsJwcwBmu7Kg+GI7oYkG3+rjdeNkQb2ogW0Nepq?= =?us-ascii?Q?DIk3HhjlW7a3BijubDWiTFsGJyB/IvJsRDawRB/J7QhMALB30R7QZG077JpG?= =?us-ascii?Q?dqR8VkRiJg0CTMMMF8r7J3RTBUtONLzIHMf2MjaksD9sXd8y8NMHBiM95cKL?= =?us-ascii?Q?H6FlISPV56y6ndu6aKilesdXHX8qhEqi73NXbd2bwk2p1Aev1C5kBEPwrFJV?= =?us-ascii?Q?4tQ/Yen+sz6Kzs15CYaebkTTlqIIH6NmBpeUQse6QGc0GBhdl6HxMu7fcC9H?= =?us-ascii?Q?dpNwvV3gwCgG0EDK2mRT4ts6+26CwVf+gOvMdTP27O0IXIjqV5Ynp0Z00HQ9?= =?us-ascii?Q?YD1MZAkd4J/bM8eOszBWp5daSNFN1Nc+V/o8+mv3rk0WBLsIPFwPhfpFgR+i?= =?us-ascii?Q?XU8Q6s1ZRhErxY3VfJAjZQypw5MdfqsQ+iIF7tCM1E1XRf+sbwpT7sys3HR9?= =?us-ascii?Q?fEvEg5DOhZwODEIrv6WRfw0TTY6PaXuHozYLhrN5u/Qz+Joi7T8syNCy6XOB?= =?us-ascii?Q?/4wHmaI/STaJNwk8hTNk8s3VU3hTf8bx/S/YjBv+f1lDQICI/XkrHl/ZeR1B?= =?us-ascii?Q?UwI4H9tQgZro4hj/fLOHPfAj2qlUBp/jrm64jJpbFXo9q7zZQzEGLGeI4nFu?= =?us-ascii?Q?Bld1H3WVK1e7r7x8wN+3DjedzPTac5HX+srqsGWEraJJvduS9BzonstfUIOt?= =?us-ascii?Q?p88p+Oz+NYGENEW/WPkGuUmmKvl3kkmWBO2jWufAQus7oSwkhF0CghkCwDhC?= =?us-ascii?Q?zCO+YZJQ3+bAFvoFwFhk2ieMIVrDcK39513pPU9Mv8S/sC4lywAUzFVHxOKz?= =?us-ascii?Q?EUa1+vRBJ2uY4FpHfFRFX8jwmyGefZWk/lYeEni2b42u1PozoG7iqth1OhL+?= =?us-ascii?Q?QqNzyB86+RItlh+R7k0cYrpS6dj+jbcglI6lQdNNVhNm6psxFhR/DUCotHgj?= =?us-ascii?Q?VESpa8mGZPfy6Ef3H6HV1REMqhWwR3eK0BRwYBJCmdbbThyke7vi5vbSDzUW?= =?us-ascii?Q?FA0WT8KokJmnOvk3ZbpIaIINtjOY0Jy+MHmF8YA0SoR1830pmpTxZopbG1HG?= =?us-ascii?Q?ki+mpk2m+r25KRg2kFzKhEUAAPPrBASF?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: v2i3Ci0Ae+0cpy2zQwemuuvitngZRDVJnSg33zhEELRG1ZDS2Tqq290Dad8TvU3x23XInBBn4rzv7zgTpglfjuvF5Skj4KNAyg3CYk9ghP2ieWOOFbLfT+8UMD88qB9GAbXM/XYIblwChAI8nG1X5jYAUpwQnI0f3q0MPnKB9mNh044M7lXXMbiPC/y5FzZ5iRx3xEUYpAzohVPTBwIVYw0HemaI3oyvf6Der3iR2cFmEFurTru+QU0QmuYXB8/bWyYNzJlIyL7r//6EpRuUF1sYysIU43O4o5hm34ZZe4+M7ndPCq6QUQuO9LAHxJyufHss/AULYvpAW8Upy+veQuvG/eaV9fmtXFPSUQsCOXGxqXWZd5kGaapnRs0g4Ee14bTCNYk2LUDxJt8Hdm4TdU4XpMNTySex8VpV1mzhfuqmLKwRd+zrMEYOAqcOhsiOzL/M6ctvLMOXUF2aGAnmdi0wHnyBw1PXh3O7LW10K4sM0y43OqR1X9/rCo2ewl8CKO6JwrHabc2RvdnojC4X0hNoZA7pvrCRq1kgyZ1II55HgF+O/3ELX+1nZjm7GbW+8p+bdRheeS05UFXD+k+J7PI4bgK5Uyllw6Nept7g+d+h67U3eH/PvWTfwebQvdUn X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:53:35.9413 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04be3bc5-fc8b-43cf-8589-08dcb566c439 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR20MB7182 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.94; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873291495116600 Content-Type: text/plain; charset="utf-8" Updates the AFAlg hash driver to support the new accumulative hashing changes as part of the patch series. Implements opening/closing of contexts, updating hash data and finalizing the hash digest. Signed-off-by: Alejandro Zeise --- crypto/hash-afalg.c | 154 +++++++++++++++++++++++++++++--------------- 1 file changed, 103 insertions(+), 51 deletions(-) diff --git a/crypto/hash-afalg.c b/crypto/hash-afalg.c index 3ebea39292..6cf222fb3b 100644 --- a/crypto/hash-afalg.c +++ b/crypto/hash-afalg.c @@ -1,6 +1,7 @@ /* * QEMU Crypto af_alg-backend hash/hmac support * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (c) 2017 HUAWEI TECHNOLOGIES CO., LTD. * * Authors: @@ -113,74 +114,116 @@ qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgorithm alg, return qcrypto_afalg_hash_hmac_ctx_new(alg, key, nkey, true, errp); } =20 -static int -qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlg *hmac, - QCryptoHashAlgorithm alg, - const struct iovec *iov, - size_t niov, uint8_t **result, - size_t *resultlen, - Error **errp) +static +QCryptoHash *qcrypto_afalg_hash_new(QCryptoHashAlgorithm alg, Error **errp) { - QCryptoAFAlg *afalg; - struct iovec outv; - int ret =3D 0; - bool is_hmac =3D (hmac !=3D NULL) ? true : false; - const int expect_len =3D qcrypto_hash_digest_len(alg); + /* Check if hash algorithm is supported */ + char *alg_name =3D qcrypto_afalg_hash_format_name(alg, false, NULL); + QCryptoHash *hash =3D NULL; =20 - if (*resultlen =3D=3D 0) { - *resultlen =3D expect_len; - *result =3D g_new0(uint8_t, *resultlen); - } else if (*resultlen !=3D expect_len) { + if (alg_name =3D=3D NULL) { error_setg(errp, - "Result buffer size %zu is not match hash %d", - *resultlen, expect_len); - return -1; + "Unknown hash algorithm %d", + alg); + } else { + hash =3D g_new(QCryptoHash, 1); + hash->alg =3D alg; + hash->opaque =3D qcrypto_afalg_hash_ctx_new(alg, errp); } =20 - if (is_hmac) { - afalg =3D hmac; - } else { - afalg =3D qcrypto_afalg_hash_ctx_new(alg, errp); - if (!afalg) { - return -1; - } + return hash; +} + +static +int qcrypto_afalg_hash_free(QCryptoHash *hash) +{ + QCryptoAFAlg *ctx =3D hash->opaque; + + if (ctx) { + qcrypto_afalg_comm_free(ctx); } =20 + g_free(hash); + + return 0; +} + +static +int qcrypto_afalg_send_to_kernel(QCryptoAFAlg *afalg, + const struct iovec *iov, + size_t niov, + Error **errp) +{ + int ret =3D 0; + /* send data to kernel's crypto core */ ret =3D iov_send_recv(afalg->opfd, iov, niov, 0, iov_size(iov, niov), true); if (ret < 0) { error_setg_errno(errp, errno, "Send data to afalg-core failed"); - goto out; - } - - /* hash && get result */ - outv.iov_base =3D *result; - outv.iov_len =3D *resultlen; - ret =3D iov_send_recv(afalg->opfd, &outv, 1, - 0, iov_size(&outv, 1), false); - if (ret < 0) { - error_setg_errno(errp, errno, "Recv result from afalg-core failed"= ); } else { + /* No error, so return 0 */ ret =3D 0; } =20 -out: - if (!is_hmac) { - qcrypto_afalg_comm_free(afalg); + return ret; +} + +static +int qcrypto_afalg_recv_from_kernel(QCryptoAFAlg *afalg, + QCryptoHashAlgorithm alg, + uint8_t **result, + size_t *result_len, + Error **errp) +{ + struct iovec outv; + int ret =3D 0; + const int expected_len =3D qcrypto_hash_digest_len(alg); + + if (*result_len =3D=3D 0) { + *result_len =3D expected_len; + *result =3D g_new0(uint8_t, *result_len); + } else if (*result_len !=3D expected_len) { + error_setg(errp, + "Result buffer size %zu is not match hash %d", + *result_len, expected_len); + ret =3D -1; + } + + if (ret =3D=3D 0) { + /* hash && get result */ + outv.iov_base =3D *result; + outv.iov_len =3D *result_len; + ret =3D iov_send_recv(afalg->opfd, &outv, 1, + 0, iov_size(&outv, 1), false); + if (ret < 0) { + error_setg_errno(errp, errno, "Recv result from afalg-core fai= led"); + } else { + ret =3D 0; + } } + return ret; } =20 -static int -qcrypto_afalg_hash_bytesv(QCryptoHashAlgorithm alg, - const struct iovec *iov, - size_t niov, uint8_t **result, - size_t *resultlen, - Error **errp) +static +int qcrypto_afalg_hash_update(QCryptoHash *hash, + const struct iovec *iov, + size_t niov, + Error **errp) +{ + return qcrypto_afalg_send_to_kernel((QCryptoAFAlg *) hash->opaque, + iov, niov, errp); +} + +static +int qcrypto_afalg_hash_finalize(QCryptoHash *hash, + uint8_t **result, + size_t *result_len, + Error **errp) { - return qcrypto_afalg_hash_hmac_bytesv(NULL, alg, iov, niov, result, - resultlen, errp); + return qcrypto_afalg_recv_from_kernel((QCryptoAFAlg *) hash->opaque, + hash->alg, result, result_len, e= rrp); } =20 static int @@ -190,9 +233,16 @@ qcrypto_afalg_hmac_bytesv(QCryptoHmac *hmac, size_t *resultlen, Error **errp) { - return qcrypto_afalg_hash_hmac_bytesv(hmac->opaque, hmac->alg, - iov, niov, result, resultlen, - errp); + int ret; + + ret =3D qcrypto_afalg_send_to_kernel(hmac->opaque, iov, niov, errp); + + if (ret =3D=3D 0) { + ret =3D qcrypto_afalg_recv_from_kernel(hmac->opaque, hmac->alg, re= sult, + resultlen, errp); + } + + return ret; } =20 static void qcrypto_afalg_hmac_ctx_free(QCryptoHmac *hmac) @@ -204,7 +253,10 @@ static void qcrypto_afalg_hmac_ctx_free(QCryptoHmac *h= mac) } =20 QCryptoHashDriver qcrypto_hash_afalg_driver =3D { - .hash_bytesv =3D qcrypto_afalg_hash_bytesv, + .hash_new =3D qcrypto_afalg_hash_new, + .hash_free =3D qcrypto_afalg_hash_free, + .hash_update =3D qcrypto_afalg_hash_update, + .hash_finalize =3D qcrypto_afalg_hash_finalize }; =20 QCryptoHmacDriver qcrypto_hmac_afalg_driver =3D { --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873341; cv=pass; d=zohomail.com; s=zohoarc; b=R6CJ9SzVPraj9vnMMAXK1nIWtkvsRELDuIJj0TE0W+t3OlBAWJ1QFyjS1gpBPYZnXEgxGuDvb/nckzeOubVzxUhWS+MrxZK4DjURW/LfsBDOITMvcDdfTs9rV9P2FJxAL/uP5urq1295t9CW56gF46PVQ3+7RG03D9yv0SZqNSY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873341; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=itQb05BoFQpUYXu/wIdi/KoIRkC1h7PlW21RutJWxxg=; b=grrpNhz6KpoPiXZV6xsuZleYYAyWQnMQ/ahvO9KzohSB6yIsV4skhsBjiWwJfbeHXzp5sESbNxiuMqOJFCUa6zVmDAh0WfFiXsE/h8rh3sUFPyzJzLBpj0f91GTX/MbWy8e/n4qBGKSXDwbPhO11/ZulDFiBYSB8hf07IYjjZRw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873341589968.2229487330087; Mon, 5 Aug 2024 08:55:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb02U-0004yo-EU; Mon, 05 Aug 2024 11:54:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb028-00034X-37; Mon, 05 Aug 2024 11:54:06 -0400 Received: from esa.hc4959-67.iphmx.com ([216.71.153.94]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb025-00041K-PV; Mon, 05 Aug 2024 11:54:03 -0400 Received: from mail-dm3nam02lp2041.outbound.protection.outlook.com (HELO NAM02-DM3-obe.outbound.protection.outlook.com) ([104.47.56.41]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:59 -0700 Received: from MW4PR04CA0376.namprd04.prod.outlook.com (2603:10b6:303:81::21) by BY1PR20MB7384.namprd20.prod.outlook.com (2603:10b6:a03:4a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 15:53:41 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::29) by MW4PR04CA0376.outlook.office365.com (2603:10b6:303:81::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27 via Frontend Transport; Mon, 5 Aug 2024 15:53:41 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:53:41 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:58:33 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:53:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873241; x=1754409241; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=82K72XH/udx3p1ujmycocFs1qs8OzQsY1UyiOBnG/iQ=; b=oj7+qUnQS0Jnx2A0ZwKgUBZPDmsNm2P41Oyv2zJuTLNayDwpZf4lGlS3 LHD9C3ip/rKHt+OKv8DPQvYi1evD9Xf/86CaptS1haunZc8NTwR2kWEZr 6hc2HRSHqPB8tN4uwzXkMPHSkLcu6NM9x1DBcdeL9oZNKWaqRCu7v+ASm s=; X-CSE-ConnectionGUID: fIFLO/QLTsafSq+8jXKEyQ== X-CSE-MsgGUID: lUu87QpSRDWK0ImGJbi/aw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mvgGksBiB9JkDRG7Zt2Aq8uMznPb3QhkVdNAa7WmoNuxbiwkrqroeKTo3VKeh+3yE5u7tH4FMNiL6je98kAM5FgfWWi2/6XOTMrDp33X4NIU7H+K8VjnTXtWrnzLrKz12XVTmWiKK8DP4En1/eZyxzWR7Y9KoK2Eu0xTXNXxwf1OEAUiMckFS/IO8nMz3EIUr1o2HiNQ27cvOEDVZ2n93JpYL+DfZVx4MZNl8HxTUe/MIGv37uuEaqK1ww1n9ZD0eBLJk9CqS+jxZ3Rdp3fefARDSOLnMQP8mNFlfjwYQ1HWxceP/LaVZCernweht2db4QOwqU6Ao5ylikH028Y5xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=itQb05BoFQpUYXu/wIdi/KoIRkC1h7PlW21RutJWxxg=; b=eS8pJdbQ3va2qsiXOZsUWV3cEtmpgOlXyNZDs1RMIFfXGOwxmfMwsJds1n3KOXjHxOQre+zb/Oh+hFl586lj/XOKROZFS6Dipn6qIhpG9lWVcmOm7nazdKyhrJMNjSkfQoReqJUiNcTB3cq2ThStcek2BfxVanZMhxp+cd0iP2DP04bYkvDEj8fkc7MfuGp41EpqDV+53iG1l7+3d1n/SKMfKGrTx3A2YRxgFA1Z9HZcLAhHidAOdJ0I+ZQXpdYhiKZRBa6xsnwKKeA9uEE70c3CBcvYpbsJe5a6E4Kn4aj+qJGt4QNMGaiTo2gaL+6HAlA/ZD+fVhkzAsmfI8gBRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=itQb05BoFQpUYXu/wIdi/KoIRkC1h7PlW21RutJWxxg=; b=VaoKVAxH1yfSY38efPly1WtJY1mW9w1x5KSm7b7FWBt3FdVgvndfgD/rHoCFLnu6Mk5UQudc6MvzqyOtFfYI9wfPGa7kiBRDhQtmxLUy/tlcv7A0up2Ce0wiA8P/i/g0XsLOoHzIffH2cIAJ08T4IhU968AvX3AvJfg6pk5JyDA= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: cbJQWtj3RCqFPfQJAnq0hA== X-CSE-MsgGUID: /oG6rhDvToeSh2LBnwxKfg== X-CSE-ConnectionGUID: jGTUoJKeSCSAAjYDA5jC0A== X-CSE-MsgGUID: La/c6Fn4SW+6j5MaAHktYg== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920707" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 11/12] tests/unit/test-crypto-hash: accumulative hashing Date: Mon, 5 Aug 2024 15:50:46 +0000 Message-Id: <20240805155047.3151540-12-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|BY1PR20MB7384:EE_ X-MS-Office365-Filtering-Correlation-Id: 728fa634-0224-4995-87eb-08dcb566c766 STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ydkPVDc43tdpFnFANTmlZBF8+OHTfEKxru2g6WCQq2OLAwMVQ0Xk4dUgLZ8T?= =?us-ascii?Q?U6cPh8vzIOZ8Q1qTkp+Gvk1qbK5E9B4lvdqxmA7u9DAa9gAwF3NwwV6hl2bI?= =?us-ascii?Q?643jDkbTINKhoIsW4megskUNEmWlnI4xjJSX+/JU6vnh/cHCfG1H6rkmsj3I?= =?us-ascii?Q?1NK3bA0pgwWxwgPsu6cT5ctfpUl0gTNjh3s/LhF1Nk7Sil92WtiCpLxQalqw?= =?us-ascii?Q?tJqInvtRbHAgOQf9TXXz12ynzQ3/0pVDzvD22wsvOnpNiJUxVYRD9b1jNR6e?= =?us-ascii?Q?hj/vytyT+Af60tXhRMvVva2+C45oD8mjr0K3eq1ZcgvXgqydVham9boc2bmU?= =?us-ascii?Q?bHJxL0y5wy1aP9JLRu33WEyQ9tAg3CpDJyVdGVApQZBu8K0k/t00Pm9pilps?= =?us-ascii?Q?NT4vxxbawUu54A8LJpXvniwti8rrOahbm4Vi+SjeGSiEC5aCKNVPPq3ai/+e?= =?us-ascii?Q?U79q95vL8NWgMGGk8WCHwyPbX0ryrI8cnVFf3xg/ALYmxos7KR1JcxaRM7/G?= =?us-ascii?Q?NIXOuHwo3oaaMdj0rTbgB8pe6986kWunGNUv0UCeoHkWj6A+/eazDZiDi/J4?= =?us-ascii?Q?A8QrPP9kym06KJTMwHV05ezhr36j4RiCFD5UpljRo6S0F364uuiof9nSTktb?= =?us-ascii?Q?UrAxwdCdIdSKl+N4Pu/4eTu+ILP3QykGlsz/9LS1DSUiTPyeSDuQtD9oawLM?= =?us-ascii?Q?UBLaUkMAIi2fjVoP6ai3qPOs1LrQosPpW/4bOpVDEkQlpWgZs6BhJtHNHrSq?= =?us-ascii?Q?BlKLWvwYXqtEe2/ECjnsTmErjOJeweVp4yIbwgJSIs5Yn5yE6nPA+PrGM6cl?= =?us-ascii?Q?MXQw0BgGoYpGi93mzzMtHcULdSoYddq+5ekTrgyqVSbKxRzUQ/YubSpemoqK?= =?us-ascii?Q?YjUNay+LdhU5jGk2VjKDpVxM+CqDSVxq/4KHrjvh2mMg9EWoBNhQ3gfw/gqy?= =?us-ascii?Q?bkHQWrrQMGmtMBBl3PXMCBfDykZPEyhp22xQMCcyHNvWcZJvkhTgknfcvPhs?= =?us-ascii?Q?7oaSoRN/qMD+Kjhh71QfL3h/V73rdvfVmjeKV51QniEaBuvP28NMxaHDBI8x?= =?us-ascii?Q?Y9UbR+2EX/ZZ6Qa1gEw7o+EVJkTWi6hjlGJhkGwvk+tf4AC2qq//f2iXyKY4?= =?us-ascii?Q?txy8glrR3yhHq3SxQNG4TZx5RCIllzLVTwQmrFmiehgefoLNH8LD3TAnNhVL?= =?us-ascii?Q?SPdPuQYjKL3hFdcBtMh6Bl4FckxfgEB3Sit5Ts8DTnkq8omiIxwCgh28FcLP?= =?us-ascii?Q?esZnS97wi0Tj5kE6xwnOohJ8xk8EHUmNg0hp+OelSTcg3A0DxOkRhkd1dg52?= =?us-ascii?Q?SM3rB/BvqST/LbGoTx5b0RWVDJfKK0LpqsJm+YxNDk0zmc6nRs3DJ3F5z2HU?= =?us-ascii?Q?cwJr9oqYrJ6g7CMSTfs5+Qp03h7kTqckZF/w4R00T480mHkX+2PM5AOtRhmO?= =?us-ascii?Q?wHZwXZWNuKFUHGjEe5Ta2d6BUBuHDWHK?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: TfSQoNrxAxE07TZphObqGYHNzosfM8IlSg5C4R5h0YKCak2MrHhYe/YyfPiyFZUBpV6SLxFytNKjGBEQZqLlCjajgSpb4A5UoQWpL9hScGFxVc30R3hdlShBpD2vH2r4suOzTNJBMN8UgrnTNmP56ti/0cM9dkoE7m4/BOCxGtp/Pjtuc8jta38HceNtUODAO3pbn+u2/452QDcZuj4A7FyeHal14aqoUn0iHNf6G7AmrzJd3p6dtMw7H56Q1FY5YTEA3tt7JDr/8Ed76osQdvOUuCmhTTx6xHzjpjsj2vnqPHDWXbSDD4SbM4x3ZcBISMChdRwBZpqOn7VMYLcmqk9QHPf5y1dpQPVRc2TvBa2yK167pSJU98/38xTP1lTXQWmY0DEoXzOD56IWzaLUN8rDGDRGAx8xtl1TysxLTOZ83RTk3F0EeVtF3SEEfLVYCEAUzVDXTmhEdgimSv4ONQO3JWS+FUFzkRrD2r3PDP+OMi76slkoox/BvwaWoumU+9Cr6Ns7vK5MUYY/uj9VxE8pfXsKwHmiB3nT3/BG0YaSfKOTpvA39IsRPNtShnHXa89ufUSaTUzDYxV5OpmNXjUDKtR7KgWyDd8AVRcM0eJITZtD7T8FAeHdx5p7RbG/ X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:53:41.3476 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 728fa634-0224-4995-87eb-08dcb566c766 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR20MB7384 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.94; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873343647116600 Content-Type: text/plain; charset="utf-8" Added an accumulative hashing test. Checks for functionality of the new hash create, update, finalize and free functions. Signed-off-by: Alejandro Zeise --- tests/unit/test-crypto-hash.c | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/unit/test-crypto-hash.c b/tests/unit/test-crypto-hash.c index 1f4abb822b..8f66ad4115 100644 --- a/tests/unit/test-crypto-hash.c +++ b/tests/unit/test-crypto-hash.c @@ -1,6 +1,7 @@ /* * QEMU Crypto hash algorithms * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (c) 2015 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -241,6 +242,54 @@ static void test_hash_base64(void) } } =20 +static void test_hash_accumulate(void) +{ + QCryptoHash *hash; + size_t i; + + for (i =3D 0; i < G_N_ELEMENTS(expected_outputs) ; i++) { + struct iovec iov[3] =3D { + { .iov_base =3D (char *)INPUT_TEXT1, .iov_len =3D strlen(INPUT= _TEXT1) }, + { .iov_base =3D (char *)INPUT_TEXT2, .iov_len =3D strlen(INPUT= _TEXT2) }, + { .iov_base =3D (char *)INPUT_TEXT3, .iov_len =3D strlen(INPUT= _TEXT3) }, + }; + uint8_t *result =3D NULL; + size_t resultlen =3D 0; + int ret; + size_t j; + + if (!qcrypto_hash_supports(i)) { + continue; + } + + hash =3D qcrypto_hash_new(i, &error_fatal); + g_assert(hash !=3D NULL); + + /* Add each iovec to the hash context separately */ + for (j =3D 0; j < 3; j++) { + ret =3D qcrypto_hash_update(hash, + &iov[j], 1, + &error_fatal); + + g_assert(ret =3D=3D 0); + } + + ret =3D qcrypto_hash_finalize_bytes(hash, &result, &resultlen, + &error_fatal); + + g_assert(ret =3D=3D 0); + g_assert(resultlen =3D=3D expected_lens[i]); + for (j =3D 0; j < resultlen; j++) { + g_assert(expected_outputs[i][j * 2] =3D=3D hex[(result[j] >> 4= ) & 0xf]); + g_assert(expected_outputs[i][j * 2 + 1] =3D=3D hex[result[j] &= 0xf]); + } + g_free(result); + + ret =3D qcrypto_hash_free(hash); + g_assert(ret =3D=3D 0); + } +} + int main(int argc, char **argv) { int ret =3D qcrypto_init(&error_fatal); @@ -252,5 +301,6 @@ int main(int argc, char **argv) g_test_add_func("/crypto/hash/prealloc", test_hash_prealloc); g_test_add_func("/crypto/hash/digest", test_hash_digest); g_test_add_func("/crypto/hash/base64", test_hash_base64); + g_test_add_func("/crypto/hash/accumulate", test_hash_accumulate); return g_test_run(); } --=20 2.34.1 From nobody Sun Nov 24 11:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass(p=reject dis=none) header.from=seagate.com ARC-Seal: i=2; a=rsa-sha256; t=1722873310; cv=pass; d=zohomail.com; s=zohoarc; b=PBe9eP++pD4oY65BEGaW7mb2T9XObLItWszPYYdmFU9q0f5lCvltVQDlZ0v90717KJ/lUBdo8iSGONJq3qrfBtIwHGnFlHtD5/PZCZP2KmxnqxpCmRfu892UIeG0pgwJsxviN24DZVzndGGD0Uuuk7+kT2ImaxWDuPzG8EEheTw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722873310; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I25AJqAsM94Uq8gEkIofuhgDPg0ApU6468m0GKyke+k=; b=P9IWoEQVXMvTZ5UlCnxzsvIcbA+SDxtNvLT/pD07KN6/qpLEh+bsh5AZatlOLxBuuXosgSZJhHr5UNO4H0W4SZ5oTPF39rkxZKjtlzIVpQMqgvAbjj7Hm7Iy1FQwIULHV3z58oBPc1SXfD0lx2zlWIBQZodTR7K546/8i3V9j7Y= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@seagate.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=seagate.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722873310520349.8517230991025; Mon, 5 Aug 2024 08:55:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb02T-0004m6-9Y; Mon, 05 Aug 2024 11:54:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01z-0002O4-5w; Mon, 05 Aug 2024 11:53:55 -0400 Received: from esa.hc4959-67.iphmx.com ([216.71.153.94]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sb01v-0003zt-St; Mon, 05 Aug 2024 11:53:54 -0400 Received: from mail-mw2nam04lp2168.outbound.protection.outlook.com (HELO NAM04-MW2-obe.outbound.protection.outlook.com) ([104.47.73.168]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 08:53:49 -0700 Received: from MW4PR04CA0388.namprd04.prod.outlook.com (2603:10b6:303:81::33) by MW5PR20MB4523.namprd20.prod.outlook.com (2603:10b6:303:19b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 15:53:47 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:81:cafe::3) by MW4PR04CA0388.outlook.office365.com (2603:10b6:303:81::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26 via Frontend Transport; Mon, 5 Aug 2024 15:53:47 +0000 Received: from lcopzesaa002.seagate.com (134.204.222.53) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 5 Aug 2024 15:53:46 +0000 Received: from lcopiesaa001.seagate.com ([10.230.120.52]) by lcopzesaa002.seagate.com with ESMTP; 05 Aug 2024 08:58:39 -0700 Received: from unknown (HELO cortana..) ([10.4.50.14]) by lcopiesaa001.seagate.com with ESMTP; 05 Aug 2024 08:53:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1722873231; x=1754409231; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=saA95osssa8AeMH7Yu9KKleRexPwEpxUkGPRk/wFjpM=; b=pARDEpSQ3q+EkoCiQhQtVkiLNEuVbllztt1thVSmcHToXOsThNSSMCDz tLe9+EU6JDsnhlruUz5kk2nv/H8aeAvHw9HJSe1a1GSKYSdGELWHyxFcb rVKVHaWHOqVwkF8Z3rjhsw9KyzFTg9QMuOuGhJiLf77tqNVO49gJ1yaWH A=; X-CSE-ConnectionGUID: dIZ8+kPbQ2GVk/7MmFmnoA== X-CSE-MsgGUID: pHxfDycmSLauNL+8ke+8BQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x7Iri8qW5Uj8tmaKAJiYd7mkMFPrLMiUMkkT6xFJpQkwQSe1hr2/rA4HTrmW+FoRortLrz656zj9XlHxlb7TTqBo/P/46SQqdL4vVthfcAZjD0ArpmrKgA1bmXsPJ/Hjqs8R+BVfT5/XgPST0OMnQXENUGHFNBfdD3ho/SFEJljHXLToH5yU38i+UZyuWAq59QMUBEIJrpM/esVjIMWMu+0pT+dttvyiw0+Oq3V8tBG6UcyuawzfUBVCaPJ9z27tabhiuQM/JDPSmxvzAKSy3qt8swX10sBMvXBWp4sBr4NE6lEvDoDyMjjBPrfMKAh2QiPt0iCAsJusIayuy6NK8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I25AJqAsM94Uq8gEkIofuhgDPg0ApU6468m0GKyke+k=; b=iaGuHO0gGABEJPcAdRpADwTnvny1azNpj82O3IMBHpAcYe4RFYVHhjI3bBD1DacaJL38MXUn2423BUQVOeVJOepOP+KSvHvcfq+OAXslmOu+CG0G77JQ24TMWKvv+LikwvOplVz9X7HP95SLSw5ZrwI+hCHAzK+8Hkgh2T/qcmXwfLLBOfPRmM5eypX9rJi/dy+5vlwS5kh1wps2uFi3yqn15/IcsxkAfbj1SJN9zq5/rPD/Bn6SlWEHAICwMOpF3VvyXNwfzPhJDX6zG9DGULRJjadvou5FOKiTzBaPXE9wY8hW3O6eEgkshDJok7B75mRbxvPJgAXqLzUckxXyxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 134.204.222.53) smtp.rcpttodomain=nongnu.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I25AJqAsM94Uq8gEkIofuhgDPg0ApU6468m0GKyke+k=; b=V7fjS7PW0d3N2PMdOuTAStyHW33AD+ZExTSSOIWvLsXP/jxqYYhoLzy0nznUpCXswtFXpL0slhYX14Ht7bCgD5pQFXnPKQtL7Wr9pSHy6RE2dglHVYEKWw/CYYP8qFQoCElUeMcrQvIFm5L01kh6FEbNHPfOp7f9j8HFw03bWuc= X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 134.204.222.53) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; X-CSE-ConnectionGUID: 1vnnKV2aSBuHEyE+rgBLXQ== X-CSE-MsgGUID: vKbHVfTDSqSVFHEvXSmQOg== X-CSE-ConnectionGUID: d0sgbfWyRQ6aM/V2TTjQGA== X-CSE-MsgGUID: KA3r4+R5TpObQkYavaqjNA== X-IronPort-AV: E=Sophos;i="6.09,265,1716274800"; d="scan'208";a="106920710" STX-Internal-Mailhost: TRUE From: Alejandro Zeise To: qemu-arm@nongnu.org Cc: alejandro.zeise@seagate.com, kris.conklin@seagate.com, jonathan.henze@seagate.com, evan.burgess@seagate.com, clg@kaod.org, peter.maydell@linaro.org, berrange@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v3 12/12] hw/misc/aspeed_hace: Fix SG Accumulative hashing Date: Mon, 5 Aug 2024 15:50:47 +0000 Message-Id: <20240805155047.3151540-13-alejandro.zeise@seagate.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240805155047.3151540-1-alejandro.zeise@seagate.com> References: <20240805155047.3151540-1-alejandro.zeise@seagate.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|MW5PR20MB4523:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a6ae526-9fc9-4902-d8b7-08dcb566caa1 STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0xFj/iTna5S+S89pMxV9DUv3VGWMkFM9D/JSmYPjoQqnyfhEgEmEOZB7vDYt?= =?us-ascii?Q?2hI/+oPFJVQyKvM6OE9yfVJxcVvpk1YZoNsqqA6N1VJuqYtr2Skn862qzFo/?= =?us-ascii?Q?4ELJbJa9/A6He/WTYEHBgWqoj6nciK4iK94pctpxI0lIe2YFWTbdnNU4kOzl?= =?us-ascii?Q?/YQijH/z50PUS87CYwirMsahH+hGUB3VdEJgqV7jaMhJDDPo7wbpNO4Vmruz?= =?us-ascii?Q?6FTQv5JRh6c7Iii5E7AkqefxtwFATqFxZN6P9/AOPgybLwQFPKSl/JMZ9W2w?= =?us-ascii?Q?IjY3bzsSUG/rL2BchBJVpeAOpQHVYZ2aD9tzSiRwORXf31zngcffffkBs5XT?= =?us-ascii?Q?GyPP7JtB45NKdV/vv4BcI6wVBaJyg78qDMBTbsDCrKZ+hafjSM4nQTFXD5w3?= =?us-ascii?Q?Q0U+zmr701aPpIoruLZqaxVEvTVTEjLZW597nRmOmSkNNv7AMG36rJ7dQHNI?= =?us-ascii?Q?fg1qgUvmKJxFH47CeLvs68A25zCSo87qzVQe3OHrEUEm/JsCBOjMQgnpZNqa?= =?us-ascii?Q?jrq7eaUrVO9GokwV6sEpYeQH180XpKgslL4VeU9UQOM1ViFUDGKiXGBeNRxL?= =?us-ascii?Q?jTf4sBD90yYY77P5G/a2T2KjEo0vwh8UCDITLmGOSfGIdyHZwmD7HS4XQuVk?= =?us-ascii?Q?WHlqfzxV60N4oq4BwA5gLUswv7KCguvDGYk3x1E/hEJ3RPiRgkhwWpiK7JsJ?= =?us-ascii?Q?x/kWTx+w1PZ4tHKwHH0WR1ZOl8VMaicXZ10qJyQmXS46jNBrDVUAu/u/KlMd?= =?us-ascii?Q?GinFEgZ6QHDklrq+Yh1BLz2EEZVAs/3FfRRkFiu1rVIQBDu0TNiDLkTVKewC?= =?us-ascii?Q?pycaD3lryg+GhqGtmvcABuCRSjhjSt53VLu9iIlIP1n/sbJJSXrqwML/QGGV?= =?us-ascii?Q?s2oULEBN1y1/rmuMxw9wnxjUN9dPUZMXKwptuJciGG/smj9Gd2J2aqURJnhQ?= =?us-ascii?Q?YdukQBtauMMZMp725K6l+Z71g4/xJq8guT7895kUX0g8zt+VR96sCMzPcdxM?= =?us-ascii?Q?wQuqrkrT+4QFLFXWFhfa9e4SsSK+X040WAP97On+1QGo3Iq7W/MU40mb5S72?= =?us-ascii?Q?+pOdRofkXSNVWcXbp0awBJZZjJJkBD71UwRp1zD8ZFaMulIipMgmcCRSK+FE?= =?us-ascii?Q?PKEIZ5iOgLf4jbgDotEcVHMuiQlufXKGb8MJWtI5txww+MoghVeYK2qrSYO5?= =?us-ascii?Q?QiQV0Fiq5aLCWeeeQuGtQ44Y6YJ1ipFA03yVVYpQ7LSKEGRIc1eY1p5yFTMX?= =?us-ascii?Q?MDgb4Cw1bPf+qgLGBOf2JeC1YmKqlgqVml/QleRLzMKho61MqB1j63EBhTsl?= =?us-ascii?Q?JYHtbYaT9dX/zDsawUm+H0GaZJDu54Q/mgodnQgN5Pi2av8ara5cEosEOkDx?= =?us-ascii?Q?UhpXPUT46h7Rq+9Pm4j0lED2o33mE8IvgULzzWLO7KwlsI2KwQ=3D=3D?= X-Forefront-Antispam-Report: CIP:134.204.222.53; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:lcopzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5L//RX8ZtDkX4rLtxgeN9tpyUJxrhYf77Kp6Beyy0HtyD1WQETmx07eOGzMWDjLO7Ypa8V2X5c4NJ2xeqYPBK54jEiNWfBbv5c0Q/c7gJe2nOaDS4C0X71+O4hZqU8H+lD5H0tcK0mb71vhRGh0pJtODnOjXwnhlEiN0eqQtdWT6NXvCb+RA/vcqABf6s1kmqEuethRo2YP/kguV7iJtjGYnP16FKkQ7j7IUEjUPGQWZ9kieCVlzmXQ7Irxfw+AH8HxHTuyamdkjX0P72MNvCC2Y8G2SxpjERS28Sb+i+sCB5B+U7xvAhDLDvU26ouohcCRHOQHdHrqoEtxOCKYLs/6KsFJMLmzJWV5gNVpxrB8g56ezN9tFsTs/K/qhfpp4RcCYkTH5G1dfJ1zRFiSk7TfgJ2drFzoarzCFyYcSrb9MPrL0IYwtqDye0i2Qs91t7+iB6nLebiwqsIIRgDlSELL3tFACBPTrUhz226NbFAFCOblWeBhtEAmOXNmABIb1edPDkfc4xMrfNueEpXU61YV1bQVk3jLSGfkSnLwMWLoBLhsD4t78+1Ig4GAbgLQxVonNUs1V7Ke6vm2IpXbhDnpVdpV+fW/2WwoKqGlWNGSg4iXdJlRdzOyy3yGdVSjf X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 15:53:46.7695 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a6ae526-9fc9-4902-d8b7-08dcb566caa1 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe; Ip=[134.204.222.53]; Helo=[lcopzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR20MB4523 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.94; envelope-from=alejandro.zeise@seagate.com; helo=esa.hc4959-67.iphmx.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @seagate.com) X-ZM-MESSAGEID: 1722873311563116600 Content-Type: text/plain; charset="utf-8" Make the Aspeed HACE module use the new qcrypto accumulative hashing functi= ons when in scatter-gather accumulative mode. A hash context will maintain a "running-hash" as each scatter-gather chunk is received. Previously each scatter-gather "chunk" was cached so the hash could be computed once the final chunk was received. However, the cache was a shallow copy, so once the guest overwrote the memory provided to HACE the final hash would not be correct. Possibly related to: https://gitlab.com/qemu-project/qemu/-/issues/1121 Buglink: https://github.com/openbmc/qemu/issues/36 Signed-off-by: Alejandro Zeise --- hw/misc/aspeed_hace.c | 92 ++++++++++++++++++----------------- include/hw/misc/aspeed_hace.h | 4 ++ 2 files changed, 52 insertions(+), 44 deletions(-) diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c index c06c04ddc6..5077204ee6 100644 --- a/hw/misc/aspeed_hace.c +++ b/hw/misc/aspeed_hace.c @@ -1,6 +1,7 @@ /* * ASPEED Hash and Crypto Engine * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (C) 2021 IBM Corp. * * Joel Stanley @@ -151,50 +152,28 @@ static int reconstruct_iov(AspeedHACEState *s, struct= iovec *iov, int id, return iov_count; } =20 -/** - * Generate iov for accumulative mode. - * - * @param s aspeed hace state object - * @param iov iov of the current request - * @param id index of the current iov - * @param req_len length of the current request - * - * @return count of iov - */ -static int gen_acc_mode_iov(AspeedHACEState *s, struct iovec *iov, int id, - hwaddr *req_len) -{ - uint32_t pad_offset; - uint32_t total_msg_len; - s->total_req_len +=3D *req_len; - - if (has_padding(s, &iov[id], *req_len, &total_msg_len, &pad_offset)) { - if (s->iov_count) { - return reconstruct_iov(s, iov, id, &pad_offset); - } - - *req_len -=3D s->total_req_len - total_msg_len; - s->total_req_len =3D 0; - iov[id].iov_len =3D *req_len; - } else { - s->iov_cache[s->iov_count].iov_base =3D iov->iov_base; - s->iov_cache[s->iov_count].iov_len =3D *req_len; - ++s->iov_count; - } - - return id + 1; -} - static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode, bool acc_mode) { struct iovec iov[ASPEED_HACE_MAX_SG]; + uint32_t total_msg_len; + uint32_t pad_offset; g_autofree uint8_t *digest_buf =3D NULL; size_t digest_len =3D 0; - int niov =3D 0; + bool sg_acc_mode_final_request =3D false; int i; void *haddr; =20 + if (acc_mode && s->hash_ctx =3D=3D NULL) { + s->hash_ctx =3D qcrypto_hash_new(algo, NULL); + if (s->hash_ctx =3D=3D NULL) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: qcrypto failed to create hash context\n", + __func__); + return; + } + } + if (sg_mode) { uint32_t len =3D 0; =20 @@ -226,8 +203,15 @@ static void do_hash_operation(AspeedHACEState *s, int = algo, bool sg_mode, } iov[i].iov_base =3D haddr; if (acc_mode) { - niov =3D gen_acc_mode_iov(s, iov, i, &plen); - + s->total_req_len +=3D plen; + + if (has_padding(s, &iov[i], plen, &total_msg_len, &pad_off= set)) { + /* Padding being present indicates the final request */ + sg_acc_mode_final_request =3D true; + iov[i].iov_len =3D pad_offset; + } else { + iov[i].iov_len =3D plen; + } } else { iov[i].iov_len =3D plen; } @@ -252,20 +236,38 @@ static void do_hash_operation(AspeedHACEState *s, int= algo, bool sg_mode, * required to check whether cache is empty. If no, we should * combine cached iov and the current iov. */ - uint32_t total_msg_len; - uint32_t pad_offset; s->total_req_len +=3D len; if (has_padding(s, iov, len, &total_msg_len, &pad_offset)) { - niov =3D reconstruct_iov(s, iov, 0, &pad_offset); + i =3D reconstruct_iov(s, iov, 0, &pad_offset); } } } =20 - if (niov) { - i =3D niov; - } + if (acc_mode) { + if (qcrypto_hash_update(s->hash_ctx, iov, i, NULL) < 0) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: qcrypto hash update failed\n", __func__); + return; + } + + if (sg_acc_mode_final_request) { + if (qcrypto_hash_finalize_bytes(s->hash_ctx, &digest_buf, + &digest_len, NULL)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: qcrypto failed to finalize hash\n", __f= unc__); + } =20 - if (qcrypto_hash_bytesv(algo, iov, i, &digest_buf, &digest_len, NULL) = < 0) { + if (qcrypto_hash_free(s->hash_ctx)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: qcrypto failed to free context\n", __fu= nc__); + } + + s->hash_ctx =3D NULL; + s->iov_count =3D 0; + s->total_req_len =3D 0; + } + } else if (qcrypto_hash_bytesv(algo, iov, i, &digest_buf, + &digest_len, NULL) < 0) { qemu_log_mask(LOG_GUEST_ERROR, "%s: qcrypto failed\n", __func__); return; } @@ -397,6 +396,11 @@ static void aspeed_hace_reset(DeviceState *dev) { struct AspeedHACEState *s =3D ASPEED_HACE(dev); =20 + if (s->hash_ctx !=3D NULL) { + qcrypto_hash_free(s->hash_ctx); + s->hash_ctx =3D NULL; + } + memset(s->regs, 0, sizeof(s->regs)); s->iov_count =3D 0; s->total_req_len =3D 0; diff --git a/include/hw/misc/aspeed_hace.h b/include/hw/misc/aspeed_hace.h index ecb1b67de8..4af9919195 100644 --- a/include/hw/misc/aspeed_hace.h +++ b/include/hw/misc/aspeed_hace.h @@ -1,6 +1,7 @@ /* * ASPEED Hash and Crypto Engine * + * Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates * Copyright (C) 2021 IBM Corp. * * SPDX-License-Identifier: GPL-2.0-or-later @@ -10,6 +11,7 @@ #define ASPEED_HACE_H =20 #include "hw/sysbus.h" +#include "crypto/hash.h" =20 #define TYPE_ASPEED_HACE "aspeed.hace" #define TYPE_ASPEED_AST2400_HACE TYPE_ASPEED_HACE "-ast2400" @@ -35,6 +37,8 @@ struct AspeedHACEState { =20 MemoryRegion *dram_mr; AddressSpace dram_as; + + QCryptoHash *hash_ctx; }; =20 =20 --=20 2.34.1