qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]