Re: [PATCH] cryptodev: Handle unexpected request to avoid crash

2023-05-25 Thread Lei He
+error_report("cryptodev: Unexpected sym operation"); > +return -VIRTIO_CRYPTO_NOTSUPP; > +} > switch (op_info->op_code) { > case VIRTIO_CRYPTO_CIPHER_ENCRYPT: > CryptodevSymStatIncEncrypt(backend, len); > -- > 2.34.1 > Reviewed-by: Lei He Best regards, Lei He -- helei.si...@bytedance.com

[PATCH 0/2] cryptodev: fix memory leak

2022-11-02 Thread Lei He
- Avoid using g_autoptr to free memory that not allocated in the same function. - Fix memory-leak when 'virtio_crypto_handle_request' returns no-zero value. - When error occurred, always pass negative status to function 'vritio_crypto_req_complete'. Lei He (2): cryptodev: av

[PATCH 2/2] cryptodev: fix memory-leak occurs on error path

2022-11-02 Thread Lei He
- Fix memory-leak when 'virtio_crypto_handle_request' returns non-zero value. - When error occurred, always pass negative status to function 'virtio_crypto_req_complete'. Signed-off-by: Lei He --- hw/virtio/virtio-crypto.c | 9 ++--- 1 file changed, 6 insertions(+),

[PATCH 1/2] cryptodev: avoid unreasonable use of g_autoptr

2022-11-02 Thread Lei He
Avoid using g_autoptr to free memory that not allocated in the same function, just use g_free instead. Signed-off-by: Lei He --- hw/virtio/virtio-crypto.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c

Re: Re: [PATCH v2 1/4] virtio-crypto: Support asynchronous mode

2022-11-02 Thread Lei He
On 2022/11/2 03:51, Michael S. Tsirkin wrote: On Tue, Nov 01, 2022 at 06:37:26AM -0400, Michael S. Tsirkin wrote: On Sat, Oct 08, 2022 at 04:50:27PM +0800, Lei He wrote: virtio-crypto: Modify the current interface of virtio-crypto device to support asynchronous mode. Signed-off-by: lei he

[PATCH v3 4/4] cryptodev: Add a lkcf-backend for cryptodev

2022-11-02 Thread Lei He
cryptodev: Added a new type of backend named lkcf-backend for cryptodev. This backend upload asymmetric keys to linux kernel, and let kernel do the accelerations if possible. The lkcf stands for Linux Kernel Cryptography Framework. Signed-off-by: lei he Reviewed-by: Michael S. Tsirkin

[PATCH v3 0/4] Add a new backend for cryptodev

2022-11-02 Thread Lei He
end for cryptodev. I tested the backend with a QAT card, the qps of RSA-2048-decryption is about 25k/s, and the main-loop becomes the bottleneck. The qps using OpenSSL directly is about 6k/s (with 6 vCPUs). We will support IO-thread for cryptodev in another series later. Lei He (4): virtio

[PATCH v3 3/4] crypto: Support export akcipher to pkcs8

2022-11-02 Thread Lei He
crypto: support export RSA private keys with PKCS#8 standard. So that users can upload this private key to linux kernel. Signed-off-by: lei he Reviewed-by: Michael S. Tsirkin Reviewed-by: Daniel P. Berrangé --- crypto/akcipher.c | 18 ++ crypto/rsakey.c | 42

[PATCH v3 2/4] crypto: Support DER encodings

2022-11-02 Thread Lei He
Add encoding interfaces for DER encoding: 1. support decoding of 'bit string', 'octet string', 'object id' and 'context specific tag' for DER encoder. 2. implemented a simple DER encoder. 3. add more testsuits for DER encoder. Signed-off-by: lei he Revi

[PATCH v3 1/4] virtio-crypto: Support asynchronous mode

2022-11-02 Thread Lei He
virtio-crypto: Modify the current interface of virtio-crypto device to support asynchronous mode. Signed-off-by: lei he Reviewed-by: Michael S. Tsirkin --- backends/cryptodev-builtin.c| 69 ++--- backends/cryptodev-vhost-user.c | 51 -- backends/cryptodev.c| 44

Re: Re: [PATCH v2 1/4] virtio-crypto: Support asynchronous mode

2022-11-01 Thread Lei He
On 2022/11/2 03:51, Michael S. Tsirkin wrote: On Tue, Nov 01, 2022 at 06:37:26AM -0400, Michael S. Tsirkin wrote: On Sat, Oct 08, 2022 at 04:50:27PM +0800, Lei He wrote: virtio-crypto: Modify the current interface of virtio-crypto device to support asynchronous mode. Signed-off-by: lei he

Re: [PATCH v2 0/4] Add a new backend for cryptodev

2022-10-24 Thread Lei He
On 2022/10/8 16:50, Lei He wrote: v1 --> v2: - Fix compile errors when neither 'nettle' nor 'gcrypt' are enabled. - Trivial changes to error codes when neither 'nettle' nor 'gcrypt' are enabled. Hi, lei: Daniel has reviewed the crypto part of th

Re: [External] Re: [PATCH 0/4] Add a new backend for cryptodev

2022-10-08 Thread Lei He
On 2022/10/7 22:25, Michael S. Tsirkin wrote: On Mon, Sep 19, 2022 at 11:53:16AM +0800, Lei He wrote: This patch adds a new backend called LKCF to cryptodev, LKCF stands for Linux Kernel Cryptography Framework. If a cryptographic accelerator that supports LKCF is installed on the the host (you

[PATCH v2 3/4] crypto: Support export akcipher to pkcs8

2022-10-08 Thread Lei He
crypto: support export RSA private keys with PKCS#8 standard. So that users can upload this private key to linux kernel. Signed-off-by: lei he --- crypto/akcipher.c | 18 ++ crypto/rsakey.c | 42 ++ crypto/rsakey.h

[PATCH v2 1/4] virtio-crypto: Support asynchronous mode

2022-10-08 Thread Lei He
virtio-crypto: Modify the current interface of virtio-crypto device to support asynchronous mode. Signed-off-by: lei he --- backends/cryptodev-builtin.c| 69 ++--- backends/cryptodev-vhost-user.c | 51 +-- backends/cryptodev.c| 44 +++--- hw/virtio/virtio-crypto.c

[PATCH v2 4/4] cryptodev: Add a lkcf-backend for cryptodev

2022-10-08 Thread Lei He
cryptodev: Added a new type of backend named lkcf-backend for cryptodev. This backend upload asymmetric keys to linux kernel, and let kernel do the accelerations if possible. The lkcf stands for Linux Kernel Cryptography Framework. Signed-off-by: lei he --- backends/cryptodev-lkcf.c | 645

[PATCH v2 2/4] crypto: Support DER encodings

2022-10-08 Thread Lei He
Add encoding interfaces for DER encoding: 1. support decoding of 'bit string', 'octet string', 'object id' and 'context specific tag' for DER encoder. 2. implemented a simple DER encoder. 3. add more testsuits for DER encoder. Signed-off-by: lei he

[PATCH v2 0/4] Add a new backend for cryptodev

2022-10-08 Thread Lei He
ew backend for cryptodev. I tested the backend with a QAT card, the qps of RSA-2048-decryption is about 25k/s, and the main-loop becomes the bottleneck. The qps using OpenSSL directly is about 6k/s (with 6 vCPUs). We will support IO-thread for cryptodev in another series later. Lei He (

PING: [PATCH 0/4] Add a new backend for cryptodev

2022-09-25 Thread Lei He
On 2022/9/19 11:53, Lei He wrote: This patch adds a new backend called LKCF to cryptodev, LKCF stands for Linux Kernel Cryptography Framework. If a cryptographic accelerator that supports LKCF is installed on the the host (you can see which algorithms are supported in host's LKCF by exec

[PATCH 3/4] crypto: Support export akcipher to pkcs8

2022-09-18 Thread Lei He
crypto: support export RSA private keys with PKCS#8 standard. So that users can upload this private key to linux kernel. Signed-off-by: lei he --- crypto/akcipher.c | 17 + crypto/rsakey.c | 42 ++ crypto/rsakey.h

[PATCH 4/4] cryptodev: Add a lkcf-backend for cryptodev

2022-09-18 Thread Lei He
cryptodev: Added a new type of backend named lkcf-backend for cryptodev. This backend upload asymmetric keys to linux kernel, and let kernel do the accelerations if possible. The lkcf stands for Linux Kernel Cryptography Framework. Signed-off-by: lei he --- backends/cryptodev-lkcf.c | 640

[PATCH 1/4] virtio-crypto: Support asynchronous mode

2022-09-18 Thread Lei He
virtio-crypto: Modify the current interface of virtio-crypto device to support asynchronous mode. Signed-off-by: lei he --- backends/cryptodev-builtin.c| 69 ++--- backends/cryptodev-vhost-user.c | 51 +-- backends/cryptodev.c| 44 +++--- hw/virtio/virtio-crypto.c

[PATCH 2/4] crypto: Support DER encodings

2022-09-18 Thread Lei He
Add encoding interfaces for DER encoding: 1. support decoding of 'bit string', 'octet string', 'object id' and 'context specific tag' for DER encoder. 2. implemented a simple DER encoder. 3. add more testsuits for DER encoder. Signed-off-by: lei he

[PATCH 0/4] Add a new backend for cryptodev

2022-09-18 Thread Lei He
6 vCPUs). We will support IO-thread for cryptodev in another series later. Lei He (4): virtio-crypto: Support asynchronous mode crypto: Support DER encodings crypto: Support export akcipher to pkcs8 cryptodev: Add a lkcf-backend for cryptodev backends/cryptodev-builtin.c| 69 +++--

[PATCH] virtio-crypto: support asynchronous mode

2022-08-16 Thread Lei He
virtio-crypto: Modify the current interface of virtio-crypto device to support asynchronous mode. Signed-off-by: lei he --- backends/cryptodev-builtin.c| 69 ++--- backends/cryptodev-vhost-user.c | 51 +-- backends/cryptodev.c| 44 +++--- hw/virtio/virtio-crypto.c

PING: [PATCH v2 0/7] crypto: Introduce ECDSA algorithm

2022-06-30 Thread Lei He
> On Jun 22, 2022, at 5:15 PM, Lei He wrote: > > This patch introduced ECDSA algorithm for crypto. > > V1 -> V2: > - The reserved function prefix '_' is no longer used. > - When parsing ECDSA key: 1) set errp as early as possible, > 2) use g_autopt

[PATCH v2 5/7] crypto: Implement ECDSA algorithm by hogweed

2022-06-22 Thread Lei He
Implement ECDSA algorithm by hogweed and nettle. Signed-off-by: lei he Reviewed-by: Daniel P. Berrangé --- crypto/akcipher-nettle.c.inc | 282 +++ 1 file changed, 282 insertions(+) diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc

[PATCH v2 4/7] crypto: Add ECDSA key parser

2022-06-22 Thread Lei He
Add ECDSA key parser and ECDSA signature parser. Signed-off-by: lei he --- crypto/ecdsakey-builtin.c.inc | 248 ++ crypto/ecdsakey.c | 118 crypto/ecdsakey.h | 66 +++ crypto/meson.build

[PATCH v2 0/7] crypto: Introduce ECDSA algorithm

2022-06-22 Thread Lei He
encoding the signature now. - Minor tweaks to code style and typo fix. V1: - make the built-in ASN.1 decoder support more ASN.1 types. - support ECDSA key and signature parsing. - implement the ECDSA algorithm using nettle and gcrypt respectively. Lei He (7): crypto: Introduce ECDSA algorithm

[PATCH v2 1/7] crypto: Introduce ECDSA algorithm API

2022-06-22 Thread Lei He
Introduce ECDSA related structures to qapi-crypto. Signed-off-by: lei he Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- qapi/crypto.json | 28 ++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/qapi/crypto.json b/qapi

[PATCH v2 6/7] crypto: Implement ECDSA algorithm by gcrypt

2022-06-22 Thread Lei He
Implement ECDSA algorithm by gcrypt Signed-off-by: lei he Reviewed-by: Daniel P. Berrangé --- crypto/akcipher-gcrypt.c.inc | 409 +++ 1 file changed, 409 insertions(+) diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index

[PATCH v2 7/7] crypto: Add test suite for ECDSA algorithm

2022-06-22 Thread Lei He
1. add test suite for ecdsa algorithm. 2. use qcrypto_akcihper_max_xxx_len to help create buffers in Signed-off-by: lei he Reviewed-by: Daniel P. Berrangé --- tests/unit/test-crypto-akcipher.c | 338 -- 1 file changed, 323 insertions(+), 15 deletions

[PATCH v2 3/7] crypto: Remove "qemu/osdep.h" in rsakey.h

2022-06-22 Thread Lei He
Move 'include "qemu/osdep.h"' from rsakey.h to rsakey.c. Signed-off-by: lei he Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- crypto/rsakey.c | 1 + crypto/rsakey.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/rsakey

[PATCH v2 2/7] crypto: Support more ASN.1 types

2022-06-22 Thread Lei He
1. support decoding of 'bit string','octet string', 'object id', and 'context specific tag' for DER decoder. 2. support encoding of int and sequence for DER decoder. 3. add test suites for the above changes. Signed-off-by: lei he Reviewed-b

[PATCH 5/7] crypto: Implement ECDSA algorithm by hogweed

2022-06-13 Thread Lei He
Implement ECDSA algorithm by hogweed and nettle. Signed-off-by: lei he --- crypto/akcipher-nettle.c.inc | 268 +++ 1 file changed, 268 insertions(+) diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc index 02699e6e6d..94d6e0b629

[PATCH 7/7] crypto: Add test suite for ECDSA algorithm

2022-06-13 Thread Lei He
1. add test suite for ecdsa algorithm. 2. use qcrypto_akcihper_max_xxx_len to help create buffers in test code. Signed-off-by: lei he --- tests/unit/test-crypto-akcipher.c | 227 +++--- 1 file changed, 212 insertions(+), 15 deletions(-) diff --git a/tests/unit

[PATCH 3/7] crypto: remove "qemu/osdep.h" in rsakey.h

2022-06-13 Thread Lei He
Move 'include "qemu/osdep.h"' from rsakey.h to rsakey.c. Signed-off-by: lei he --- crypto/rsakey.c | 1 + crypto/rsakey.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/rsakey.c b/crypto/rsakey.c index cc40e072f0..dcdbd9ec57 100644 --- a/crypto/r

[PATCH 2/7] crypto: Support more ASN.1 types

2022-06-13 Thread Lei He
1. support decoding of 'bit string','octet string', 'object id', and 'context specific tag' for DER decoder. 2. support encoding of int and sequence for DER decoder. 3. add test suites for the above changes. Signed-off-by: lei he

[PATCH 4/7] crypto: Add ECDSA key parser

2022-06-13 Thread Lei He
Add ECDSA key parser and ECDSA signautre parser. Signed-off-by: lei he --- crypto/ecdsakey-builtin.c.inc | 248 ++ crypto/ecdsakey.c | 118 crypto/ecdsakey.h | 66 +++ crypto/meson.build

[PATCH 6/7] crypto: Implement ECDSA algorithm by gcrypt

2022-06-13 Thread Lei He
Implement ECDSA algorithm by gcrypt Signed-off-by: lei he --- crypto/akcipher-gcrypt.c.inc | 400 +++ 1 file changed, 400 insertions(+) diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index abb1fb272e..24377bbec6 100644 --- a

[PATCH 1/7] crypto: Introduce ECDSA algorithm API

2022-06-13 Thread Lei He
Introduce ECDSA related structures to qapi-crypto. Signed-off-by: lei he --- qapi/crypto.json | 28 ++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index 653e6e3f3d..c2fcdaa13a 100644 --- a/qapi/crypto.json +++ b

[PATCH 0/7] crypto: Introduce ECDSA algorithm

2022-06-13 Thread Lei He
This patch introduced ECDSA algorithm for crypto: 1. make the built-in ASN.1 decoder support more ASN.1 types. 2. support ECDSA key and signature parsing. 3. implement the ECDSA algorithm using nettle and gcrypt respectively. Lei He (7): crypto: Introduce ECDSA algorithm API crypto: Support

[PATCH 9/9] crypto: Introduce RSA algorithm

2022-05-25 Thread Lei He
UB_KEY_ID 0 /tmp/data enc=pkcs1 >/tmp/enc.pub echo "Dec with priv key..." keyctl pkey_decrypt $PRIV_KEY_ID 0 /tmp/enc.pub enc=pkcs1 >/tmp/dec cmp /tmp/data /tmp/dec echo "Verify with pub key..." keyctl pkey_verify $PUB_KEY_ID 0 /tmp/data /tmp/sig en

[PATCH 7/9] test/crypto: Add test suite for crypto akcipher

2022-05-25 Thread Lei He
Add unit test and benchmark test for crypto akcipher. Signed-off-by: lei he Signed-off-by: zhenwei pi Reviewed-by: Daniel P. Berrangé --- crypto/akcipher-nettle.c.inc| 14 +- tests/bench/benchmark-crypto-akcipher.c | 137 ++ tests/bench/meson.build | 1

[PATCH 6/9] crypto: Implement RSA algorithm by gcrypt

2022-05-25 Thread Lei He
Added gcryt implementation of RSA algorithm, RSA algorithm implemented by gcrypt has a higher priority than nettle because it supports raw padding. Signed-off-by: lei he --- crypto/akcipher-gcrypt.c.inc | 595 +++ crypto/akcipher.c| 4 +- 2

[PATCH 8/9] tests/crypto: Add test suite for RSA keys

2022-05-25 Thread Lei He
As Daniel suggested, Add tests suite for rsakey, as a way to prove that we can handle DER errors correctly. Signed-off-by: lei he Reviewed-by: Daniel P. Berrangé --- tests/unit/test-crypto-akcipher.c | 285 +- 1 file changed, 282 insertions(+), 3 deletions

[PATCH 4/9] crypto: add ASN.1 DER decoder

2022-05-25 Thread Lei He
Add an ANS.1 DER decoder which is used to parse asymmetric cipher keys Signed-off-by: zhenwei pi Signed-off-by: lei he --- crypto/der.c | 189 crypto/der.h | 81 crypto/meson.build | 1 + tests/unit

[PATCH 5/9] crypto: Implement RSA algorithm by hogweed

2022-05-25 Thread Lei He
Implement RSA algorithm by hogweed from nettle. Thus QEMU supports a 'real' RSA backend to handle request from guest side. It's important to test RSA offload case without OS & hardware requirement. Signed-off-by: lei he Signed-off-by: zhenwei pi --- crypto/akcipher

[PATCH 2/9] qapi: crypto-akcipher: Introduce akcipher types to qapi

2022-05-25 Thread Lei He
Introduce akcipher types, also include RSA related types. Reviewed-by: Daniel P. Berrangé Signed-off-by: Lei He Signed-off-by: zhenwei pi --- qapi/crypto.json | 64 1 file changed, 64 insertions(+) diff --git a/qapi/crypto.json b/qapi

[PATCH 1/9] virtio-crypto: header update

2022-05-25 Thread Lei He
From: zhenwei pi Update header from linux, support akcipher service. Reviewed-by: Daniel P. Berrangé Reviewed-by: Gonglei Signed-off-by: lei he Signed-off-by: zhenwei pi --- include/standard-headers/linux/virtio_crypto.h | 82 +- 1 file changed, 81 insertions(+), 1

[PATCH v7 0/9] Introduce akcipher service for virtio-crypto

2022-05-25 Thread Lei He
- Introduce akcipher class. - Introduce ASN1 decoder into QEMU. - Implement RSA backend by nettle/hogweed. Lei He (6): qapi: crypto-akcipher: Introduce akcipher types to qapi crypto: add ASN.1 DER decoder crypto: Implement RSA algorithm by hogweed crypto: Implement RSA algorithm by gcrypt

[PATCH 3/9] crypto: Introduce akcipher crypto class

2022-05-25 Thread Lei He
From: zhenwei pi Introduce new akcipher crypto class 'QCryptoAkCIpher', which supports basic asymmetric operations: encrypt, decrypt, sign and verify. Suggested by Daniel P. Berrangé, also add autoptr cleanup for the new class. Thanks to Daniel! Co-developed-by: lei he Signed-off-

[PATCH] error-report: fix crash when compute iso8061 time

2022-04-27 Thread Lei He
g_date_time_new_now_utc() instead, and add a check for NULL result. Signed-off-by: Lei He --- util/error-report.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/util/error-report.c b/util/error-report.c index dbadaf206d..d3c150661d 100644 --- a/util/error-report.c +++ b/util