From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1t9r-0002TF-F2 for qemu-devel@nongnu.org; Mon, 08 Jun 2015 05:15:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z1t9o-00025R-7W for qemu-devel@nongnu.org; Mon, 08 Jun 2015 05:15:51 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:44753) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1t9n-0001dL-Ew for qemu-devel@nongnu.org; Mon, 08 Jun 2015 05:15:48 -0400 Message-ID: <55755D0D.90200@huawei.com> Date: Mon, 8 Jun 2015 17:14:53 +0800 From: Gonglei MIME-Version: 1.0 References: <1433252721-19610-1-git-send-email-berrange@redhat.com> <1433252721-19610-5-git-send-email-berrange@redhat.com> In-Reply-To: <1433252721-19610-5-git-send-email-berrange@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 04/10] crypto: introduce generic cipher API & built-in implementation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Gerd Hoffmann , Richard Henderson On 2015/6/2 21:45, Daniel P. Berrange wrote: > + > +static int qcrypto_cipher_encrypt_des_rfb(QCryptoCipher *cipher, > + const void *in, > + void *out, > + size_t len, > + Error **errp) > +{ > + QCryptoCipherBuiltin *ctxt = cipher->opaque; > + size_t i; > + > + deskey(ctxt->state.desrfb.key, EN0); > + Why not move the below check to top of deskey() ? and... > + if (len % 8) { > + error_setg(errp, _("Buffer size must be multiple of 8 not %zu"), > + len); > + return -1; > + } > + > + for (i = 0; i < len; i += 8) { > + des((void *)in + i, out + i); > + } > + > + return 0; > +} > + > + > +static int qcrypto_cipher_decrypt_des_rfb(QCryptoCipher *cipher, > + const void *in, > + void *out, > + size_t len, > + Error **errp) > +{ > + QCryptoCipherBuiltin *ctxt = cipher->opaque; > + size_t i; > + > + deskey(ctxt->state.desrfb.key, DE1); > + ...the same. > + if (len % 8) { > + error_setg(errp, _("Buffer size must be multiple of 8 not %zu"), > + len); > + return -1; > + } > + > + for (i = 0; i < len; i += 8) { > + des((void *)in + i, out + i); > + } > + > + return 0; > +} Regards, -Gonglei