From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web10.22390.1600263101990813432 for ; Wed, 16 Sep 2020 06:31:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ETCZZtyD; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600263101; 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=73sNH46j5TQM/wYjBkHDVStDmMdFey0WqFN1/Ugl/zs=; b=ETCZZtyDldA9+pM+hWbFQtvnrtT6w9SOVbpzJXoPO0v1rR9vp3xuiVyv9ENycITi6CL5R6 GI12wUSNSv166qgiOKjQ5LtY1oDT1hLftuS5USJzU8RA6JAdJpApk3g9LUGA15iWENsYV7 /duzClsCG7HkxLD8xXIpjoahECwMeK0= 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-224-caF_mSZYO2iJRcGNHML6ZA-1; Wed, 16 Sep 2020 09:31:39 -0400 X-MC-Unique: caF_mSZYO2iJRcGNHML6ZA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 098361800D4A; Wed, 16 Sep 2020 13:31:38 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-213.ams2.redhat.com [10.36.113.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id A20BC5DEC1; Wed, 16 Sep 2020 13:31:36 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v3 1/3] CryptoPkg/BaseCryptLib: Add EVP (Envelope) Digest interface From: "Laszlo Ersek" To: "Yao, Jiewen" , "devel@edk2.groups.io" , "Zurcher, Christopher J" Cc: "Wang, Jian J" , "Lu, XiaoyuX" References: <1096735a-182d-6ea1-99c2-d06e3caf4523@redhat.com> Message-ID: Date: Wed, 16 Sep 2020 15:31:35 +0200 MIME-Version: 1.0 In-Reply-To: <1096735a-182d-6ea1-99c2-d06e3caf4523@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US On 09/16/20 14:39, Laszlo Ersek wrote: > On 09/16/20 14:07, Yao, Jiewen wrote: >> I overlooked the behavior that NULL DigestValue will take side effect to free Context. >> >> Hi Christopher >> May I understand why we need free the context? >> This does not align with other existing HASH or HMAC functions. > > I requested that. > > It makes no sense to keep a finalized context. > > In other words, it makes no sense to separate finalization from freeing. > A context that has been finalized is unusable for anything except freeing. To clarify my point about (DigestValue==NULL): the freeing of the context is not tied to (DigestValue==NULL). When finalizing the context, the context should *always* be freed. (DigestValue==NULL) only decides whether we *only* free the context, or we store the computed digest *in addition to* freeing the context. So the unconditional part of the finalization is the freeing; the conditional part is the storing of the digest. Thanks Laszlo