From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biI9i-000136-Gy for qemu-devel@nongnu.org; Fri, 09 Sep 2016 05:31:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1biI9e-00059Q-QO for qemu-devel@nongnu.org; Fri, 09 Sep 2016 05:31:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biI9e-00059A-Ke for qemu-devel@nongnu.org; Fri, 09 Sep 2016 05:31:26 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AED2183F43 for ; Fri, 9 Sep 2016 09:31:25 +0000 (UTC) Date: Fri, 9 Sep 2016 10:31:22 +0100 From: "Daniel P. Berrange" Message-ID: <20160909093122.GC25802@redhat.com> Reply-To: "Daniel P. Berrange" References: <1473352047-908-1-git-send-email-berrange@redhat.com> <1473352047-908-7-git-send-email-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 6/6] crypto: support more hash algorithms for pbkdf List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org On Thu, Sep 08, 2016 at 12:57:38PM -0500, Eric Blake wrote: > On 09/08/2016 11:27 AM, Daniel P. Berrange wrote: > > Currently pbkdf is only supported with SHA1 and SHA256. Expand > > this to support all algorithms known to QEMU. > > > > Signed-off-by: Daniel P. Berrange > > --- > > crypto/pbkdf-gcrypt.c | 12 +++++++++- > > crypto/pbkdf-nettle.c | 61 ++++++++++++++++++++++++++++++++++++++++------- > > tests/test-crypto-pbkdf.c | 53 +++++++++++++++++++++++++++++++++++++++- > > 3 files changed, 115 insertions(+), 11 deletions(-) > > > > > > > if (hash >= G_N_ELEMENTS(hash_map) || > > hash_map[hash] == GCRY_MD_NONE) { > > - error_setg(errp, "Unexpected hash algorithm %d", hash); > > + error_setg_errno(errp, ENOSYS, > > + "PBKDF does not support hash algorithm %s", > > + QCryptoHashAlgorithm_lookup[hash]); > > Can this access beyond bounds if hash > G_N_ELEMENTS(hash_map)? I'm relying on fact that 'hash' came from QAPIs string -> enum convertor - nothing in QEMU lets users provide raw integer enum values - so will be guaranteed to be a valid enum value. > > +++ b/crypto/pbkdf-nettle.c > > > > > default: > > error_setg_errno(errp, ENOSYS, > > - "PBKDF does not support hash algorithm %d", hash); > > + "PBKDF does not support hash algorithm %s", > > + QCryptoHashAlgorithm_lookup[hash]); > > and again Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|