[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 for-2.10 03/18] crypto: cipher: introduce qcr
From: |
Gonglei (Arei) |
Subject: |
Re: [Qemu-devel] [PATCH v2 for-2.10 03/18] crypto: cipher: introduce qcrypto_cipher_ctx_new for nettle-backend |
Date: |
Fri, 21 Apr 2017 11:56:22 +0000 |
> -----Original Message-----
> From: longpeng
> Sent: Monday, April 17, 2017 9:33 AM
> To: address@hidden
> Cc: Gonglei (Arei); Huangweidong (C); address@hidden;
> address@hidden; address@hidden; address@hidden; longpeng
> Subject: [PATCH v2 for-2.10 03/18] crypto: cipher: introduce
> qcrypto_cipher_ctx_new for nettle-backend
>
> Extracts qcrypto_cipher_ctx_new() from qcrypto_cipher_new() for
> nettle-backend impls.
>
> Signed-off-by: Longpeng(Mike) <address@hidden>
> ---
> crypto/cipher-nettle.c | 41 +++++++++++++++++++++++++++++------------
> 1 file changed, 29 insertions(+), 12 deletions(-)
>
Reviewed-by: Gonglei <address@hidden>
> diff --git a/crypto/cipher-nettle.c b/crypto/cipher-nettle.c
> index e04e3a1..e6d6e6c 100644
> --- a/crypto/cipher-nettle.c
> +++ b/crypto/cipher-nettle.c
> @@ -262,12 +262,12 @@ static void
> nettle_cipher_free_ctx(QCryptoCipherNettle *ctx)
> }
>
>
> -QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
> - QCryptoCipherMode mode,
> - const uint8_t *key, size_t nkey,
> - Error **errp)
> +static QCryptoCipherNettle
> *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
> +
> QCryptoCipherMode mode,
> + const uint8_t
> *key,
> + size_t nkey,
> + Error **errp)
> {
> - QCryptoCipher *cipher;
> QCryptoCipherNettle *ctx;
> uint8_t *rfbkey;
>
> @@ -287,12 +287,7 @@ QCryptoCipher
> *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
> return NULL;
> }
>
> - cipher = g_new0(QCryptoCipher, 1);
> - cipher->alg = alg;
> - cipher->mode = mode;
> -
> ctx = g_new0(QCryptoCipherNettle, 1);
> - cipher->opaque = ctx;
>
> switch (alg) {
> case QCRYPTO_CIPHER_ALG_DES_RFB:
> @@ -436,10 +431,10 @@ QCryptoCipher
> *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
>
> ctx->iv = g_new0(uint8_t, ctx->blocksize);
>
> - return cipher;
> + return ctx;
>
> error:
> - qcrypto_cipher_free(cipher);
> + nettle_cipher_free_ctx(ctx);
> return NULL;
> }
>
> @@ -561,3 +556,25 @@ int qcrypto_cipher_setiv(QCryptoCipher *cipher,
> memcpy(ctx->iv, iv, niv);
> return 0;
> }
> +
> +
> +QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
> + QCryptoCipherMode mode,
> + const uint8_t *key, size_t nkey,
> + Error **errp)
> +{
> + QCryptoCipher *cipher;
> + QCryptoCipherNettle *ctx;
> +
> + ctx = qcrypto_cipher_ctx_new(alg, mode, key, nkey, errp);
> + if (!ctx) {
> + return NULL;
> + }
> +
> + cipher = g_new0(QCryptoCipher, 1);
> + cipher->alg = alg;
> + cipher->mode = mode;
> + cipher->opaque = ctx;
> +
> + return cipher;
> +}
> --
> 1.8.3.1
>
- [Qemu-devel] [PATCH v2 for-2.10 08/18] crypto: hmac: introduce qcrypto_hmac_ctx_new for gcrypt-backend, (continued)
- [Qemu-devel] [PATCH v2 for-2.10 08/18] crypto: hmac: introduce qcrypto_hmac_ctx_new for gcrypt-backend, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 10/18] crypto: hmac: introduce qcrypto_hmac_ctx_new for glib-backend, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 18/18] tests: crypto: add hmac speed benchmark support, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 02/18] crypto: cipher: introduce qcrypto_cipher_ctx_new for gcrypt-backend, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 12/18] crypto: introduce some common functions for af_alg backend, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 03/18] crypto: cipher: introduce qcrypto_cipher_ctx_new for nettle-backend, Longpeng(Mike), 2017/04/16
- Re: [Qemu-devel] [PATCH v2 for-2.10 03/18] crypto: cipher: introduce qcrypto_cipher_ctx_new for nettle-backend,
Gonglei (Arei) <=
- [Qemu-devel] [PATCH v2 for-2.10 06/18] crypto: hash: add hash driver framework, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 09/18] crypto: hmac: introduce qcrypto_hmac_ctx_new for nettle-backend, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 17/18] tests: crypto: add hash speed benchmark support, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 11/18] crypto: hmac: add hmac driver framework, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 16/18] tests: crypto: add cipher speed benchmark support, Longpeng(Mike), 2017/04/16
- [Qemu-devel] [PATCH v2 for-2.10 15/18] crypto: hmac: add af_alg hmac support, Longpeng(Mike), 2017/04/16