From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvWIF-0007us-4d for qemu-devel@nongnu.org; Thu, 21 May 2015 15:38:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvWIA-0007ua-0K for qemu-devel@nongnu.org; Thu, 21 May 2015 15:38:11 -0400 Received: from mail-qk0-x234.google.com ([2607:f8b0:400d:c09::234]:34603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvWI9-0007uP-SO for qemu-devel@nongnu.org; Thu, 21 May 2015 15:38:05 -0400 Received: by qkgx75 with SMTP id x75so64316035qkg.1 for ; Thu, 21 May 2015 12:38:05 -0700 (PDT) Sender: Richard Henderson Message-ID: <555E3419.5060902@twiddle.net> Date: Thu, 21 May 2015 12:38:01 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1432205817-16414-1-git-send-email-berrange@redhat.com> <1432205817-16414-7-git-send-email-berrange@redhat.com> In-Reply-To: <1432205817-16414-7-git-send-email-berrange@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 06/10] crypto: add a nettle cipher 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 On 05/21/2015 03:56 AM, Daniel P. Berrange wrote: > +static uint8_t *qcrypto_cipher_munge_des_rfb_key(const uint8_t *key, > + size_t nkey) > +{ > + uint8_t *ret = g_new0(uint8_t, nkey); > + size_t i; > + for (i = 0; i < nkey; i++) { > + uint8_t r = key[i]; > + r = (r & 0xf0)>>4 | (r & 0x0f)<<4; > + r = (r & 0xcc)>>2 | (r & 0x33)<<2; > + r = (r & 0xaa)>>1 | (r & 0x55)<<1; > + ret[i] = r; > + } > + return ret; > +} > + Surely you can share this between the gcrypt and nettle files and not duplicate it... r~