From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abHAq-0006Ar-4e for qemu-devel@nongnu.org; Wed, 02 Mar 2016 19:31:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abHAo-0001J0-UX for qemu-devel@nongnu.org; Wed, 02 Mar 2016 19:31:24 -0500 References: <1456747261-22032-1-git-send-email-berrange@redhat.com> <1456747261-22032-4-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <56D785D1.6050800@redhat.com> Date: Wed, 2 Mar 2016 17:31:13 -0700 MIME-Version: 1.0 In-Reply-To: <1456747261-22032-4-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="DU9evFq4Ueb3dF1MdbMpi8MMnhiRIJV31" Subject: Re: [Qemu-devel] [PATCH v4 03/26] crypto: add support for generating initialization vectors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Fam Zheng , qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --DU9evFq4Ueb3dF1MdbMpi8MMnhiRIJV31 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/29/2016 05:00 AM, Daniel P. Berrange wrote: > There are a number of different algorithms that can be used > to generate initialization vectors for disk encryption. This > introduces a simple internal QCryptoBlockIV object to provide > a consistent internal API to the different algorithms. The > initially implemented algorithms are 'plain', 'plain64' and > 'essiv', each matching the same named algorithm provided > by the Linux kernel dm-crypt driver. >=20 > Signed-off-by: Daniel P. Berrange > --- > +++ b/crypto/ivgen-essiv.c > +static int qcrypto_ivgen_essiv_init(QCryptoIVGen *ivgen, > + const uint8_t *key, size_t nkey, > + Error **errp) > +{ > + uint8_t *salt; > + size_t nhash; > + size_t nsalt; > + QCryptoIVGenESSIV *essiv =3D g_new0(QCryptoIVGenESSIV, 1); > + > + /* Not neccessarily the same as nkey */ s/neccessarily/necessarily/ > +++ b/include/crypto/ivgen.h > + * > + * while (ndata) { > + * if (qcrypto_ivgen_calculate(ivgen, sector, iv, niv, errp) < 0) = { > + * goto error; > + * } > + * if (qcrypto_cipher_setiv(cipher, iv, niv, errp) < 0) { > + * goto error; > + * } > + * if (qcrypto_cipher_encrypt(cipher, > + * data + (sector * 512), > + * data + (sector * 512), > + * 512, errp) < 0) { Don't you reuse a single in/out buffer later in the series? If so, don't forget to update the comment at that time (the compiler will only catch code changes). > + * > + * - QCRYPTO_IVGEN_ALG_PLAIN > + * > + * The IVs are generated by the 32-bit truncated sector > + * number. This should never be used for block devices > + * that are larger than 2^32 sectors in size s/$/./ > + * All the other parameters are unused. > + * > +++ b/qapi/crypto.json > @@ -78,3 +78,22 @@ > { 'enum': 'QCryptoCipherMode', > 'prefix': 'QCRYPTO_CIPHER_MODE', > 'data': ['ecb', 'cbc']} > + > + > +## > +# QCryptoIVGenAlgorithm: > +# > +# The supported algorithms for generating initialization > +# vectors for full disk encryption. The 'plain' generator > +# should not be used for disks with sector numbers larger > +# than 2^32, except where compatibility with pre-existing > +# Linux dm-crypt volumes is required. > +# > +# @plain: 64-bit sector number truncated to 32-bits > +# @plain64: 64-bit sector number > +# @essiv: 64-bit sector number encrypted with a hash of the encryption= key > +# Since: 2.6 Worth warning that 'plain' and 'plain64' expose the encrypted disk to some weaknesses when compared to 'essiv'? Fixes are minor, so I'm okay if you add: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --DU9evFq4Ueb3dF1MdbMpi8MMnhiRIJV31 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJW14XRAAoJEKeha0olJ0NqCVMH/iAcvu/srwRR5hxEgWOQLoEJ UtUrI2tX95FntIVkzB/AAWXAGdcJ3xNsh9zFY4jrVzCOYuzQrNdt/i6MNZaDG5nX DxnrtAR8+IWESt6NrCacd3uUQ+9FAaB6ZUH1TfU728kQ4qXlXWLqzO57IzSI+T6+ xAjRwfp7CkdLS7teiN5XJiHIWtyeOaLyvi7UtmY8nK3iRoFplN3fsJdY8FiwHr9A iSj4Iy1ERoewzPu/H6msytUZEcb1VU2eG/ERdJODFyyMwy0CxGKZNKmSXWwZloqh WYUmvHAQYlJLsX+ZfxSqcdfU0h4HSsN3TrXQ0h+C201rqpVwb0ysWn6hqGiB+Vc= =4gTV -----END PGP SIGNATURE----- --DU9evFq4Ueb3dF1MdbMpi8MMnhiRIJV31--