[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 04/10] crypto: introduce generic cipher API &
From: |
Gonglei |
Subject: |
Re: [Qemu-devel] [PATCH v2 04/10] crypto: introduce generic cipher API & built-in implementation |
Date: |
Mon, 8 Jun 2015 17:14:53 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
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
- [Qemu-devel] [PATCH v2 00/10] Consolidate crypto APIs & implementations, Daniel P. Berrange, 2015/06/02
- [Qemu-devel] [PATCH v2 01/10] crypto: introduce new module for computing hash digests, Daniel P. Berrange, 2015/06/02
- [Qemu-devel] [PATCH v2 03/10] crypto: move built-in D3DES implementation into crypto/, Daniel P. Berrange, 2015/06/02
- [Qemu-devel] [PATCH v2 02/10] crypto: move built-in AES implementation into crypto/, Daniel P. Berrange, 2015/06/02
- [Qemu-devel] [PATCH v2 05/10] crypto: add a gcrypt cipher implementation, Daniel P. Berrange, 2015/06/02
- [Qemu-devel] [PATCH v2 07/10] block: convert quorum blockdrv to use crypto APIs, Daniel P. Berrange, 2015/06/02
- [Qemu-devel] [PATCH v2 04/10] crypto: introduce generic cipher API & built-in implementation, Daniel P. Berrange, 2015/06/02
- Re: [Qemu-devel] [PATCH v2 04/10] crypto: introduce generic cipher API & built-in implementation,
Gonglei <=
- [Qemu-devel] [PATCH v2 06/10] crypto: add a nettle cipher implementation, Daniel P. Berrange, 2015/06/02
- [Qemu-devel] [PATCH v2 08/10] ui: convert VNC websockets to use crypto APIs, Daniel P. Berrange, 2015/06/02
- [Qemu-devel] [PATCH v2 09/10] block: convert qcow/qcow2 to use generic cipher API, Daniel P. Berrange, 2015/06/02
- [Qemu-devel] [PATCH v2 10/10] ui: convert VNC to use generic cipher API, Daniel P. Berrange, 2015/06/02