From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web12.6331.1579165714631878016 for ; Thu, 16 Jan 2020 01:08:34 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WKXGdhTb; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579165713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nON1BZ9EO0Tqfivrtoz2Iow6zTYLsPv2Tk2ZHj19uB0=; b=WKXGdhTbYLvlIlymJEey8Nz8Zrxb35HLk9JP2bHVAsDOZUFF9niznHtwn8uE0mBA4Ml+Mm /MFgrVniCuyarclw2k52Vdi0nJ1Yk5Ss297w/O3LEPPaF+7lWcFatU7KE/jnJzUqJIECZT 3mmpi0hI8oLu+fJsoNESXwEgsLPa3KY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-ozirlgyuMQeeyqLyB5hs6g-1; Thu, 16 Jan 2020 04:08:30 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 870C78017CC; Thu, 16 Jan 2020 09:08:29 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-120.ams2.redhat.com [10.36.116.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 865155C3F8; Thu, 16 Jan 2020 09:08:28 +0000 (UTC) Subject: Re: [PATCH v3 1/2] CryptoPkg/BaseCryptLib: replace HmacXxxInit API with HmacXxxSetKey To: Jian J Wang , devel@edk2.groups.io Cc: Xiaoyu Lu References: <20200116061004.636-1-jian.j.wang@intel.com> <20200116061004.636-2-jian.j.wang@intel.com> From: "Laszlo Ersek" Message-ID: Date: Thu, 16 Jan 2020 10:08:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200116061004.636-2-jian.j.wang@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: ozirlgyuMQeeyqLyB5hs6g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Hi Jian, On 01/16/20 07:10, Jian J Wang wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1792 > > HmacXxxInit() is supposed to be initialize user supplied buffer as HMAC > context, as well as user supplied key. Currently it has no real use cases. > > Due to BZ1792, the user has no way to get correct size of context buffer > after it's fixed, and then cannot make use of HmacXxxInit to initialize > it. > > So it's decided to replace it with HmacXxxSetKey to keep the functionality > of supplying a key to HMAC, but drop all other initialization works. The > user can still get HMAC context via HmacXxxNew interface, which hides the > details about the context. > > Cc: Xiaoyu Lu > Cc: Laszlo Ersek > Signed-off-by: Jian J Wang > --- > CryptoPkg/Include/Library/BaseCryptLib.h | 94 ++++++------------- > .../Library/BaseCryptLib/Hmac/CryptHmacMd5.c | 27 ++---- > .../BaseCryptLib/Hmac/CryptHmacMd5Null.c | 8 +- > .../Library/BaseCryptLib/Hmac/CryptHmacSha1.c | 27 ++---- > .../BaseCryptLib/Hmac/CryptHmacSha1Null.c | 8 +- > .../BaseCryptLib/Hmac/CryptHmacSha256.c | 27 ++---- > .../BaseCryptLib/Hmac/CryptHmacSha256Null.c | 8 +- > .../BaseCryptLibNull/Hmac/CryptHmacMd5Null.c | 8 +- > .../BaseCryptLibNull/Hmac/CryptHmacSha1Null.c | 8 +- > .../Hmac/CryptHmacSha256Null.c | 8 +- > 10 files changed, 84 insertions(+), 139 deletions(-) > > diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h b/CryptoPkg/Include/Library/BaseCryptLib.h > index 8fe303a0b3..c5803ea673 100644 > --- a/CryptoPkg/Include/Library/BaseCryptLib.h > +++ b/CryptoPkg/Include/Library/BaseCryptLib.h [...] > @@ -1175,23 +1175,6 @@ HmacMd5Final ( > OUT UINT8 *HmacValue > ); > > -/** > - Retrieves the size, in bytes, of the context buffer required for HMAC-SHA1 operations. > - (NOTE: This API is deprecated. > - Use HmacSha1New() / HmacSha1Free() for HMAC-SHA1 Context operations.) > - > - If this interface is not supported, then return zero. > - > - @return The size, in bytes, of the context buffer required for HMAC-SHA1 operations. > - @retval 0 This interface is not supported. > - > -**/ > -UINTN > -EFIAPI > -HmacSha1GetContextSize ( > - VOID > - ); > - > /** > Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA1 use. > (1) This hunk belongs to patch#2. In other words, HmacSha1GetContextSize() should not be removed from the lib class header in patch#1. [...] > @@ -1325,23 +1308,6 @@ HmacSha1Final ( > OUT UINT8 *HmacValue > ); > > -/** > - Retrieves the size, in bytes, of the context buffer required for HMAC-SHA256 operations. > - (NOTE: This API is deprecated. > - Use HmacSha256New() / HmacSha256Free() for HMAC-SHA256 Context operations.) > - > - If this interface is not supported, then return zero. > - > - @return The size, in bytes, of the context buffer required for HMAC-SHA256 operations. > - @retval 0 This interface is not supported. > - > -**/ > -UINTN > -EFIAPI > -HmacSha256GetContextSize ( > - VOID > - ); > - > /** > Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use. > (2) This hunk belongs to patch#2. In other words, HmacSha256GetContextSize() should not be removed from the lib class header in patch#1. With the above two points addressed: Reviewed-by: Laszlo Ersek Thanks! Laszlo