[PATCH v4 5/8] crypto: testmgr - support test with different ciphertext per encryption

2020-07-08 Thread Tianjia Zhang
achieve the test purpose. Signed-off-by: Tianjia Zhang --- crypto/testmgr.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 6863f911fcee..0dc94461c437 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -4025,7 +4025,7 @@ static

[PATCH v4 0/8] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-07-08 Thread Tianjia Zhang
tain the verify function. 2. extract the sm2 certificate code into a separate file. Tianjia Zhang (8): crypto: sm3 - export crypto_sm3_final function lib/mpi: Extend the MPI library lib/mpi: Introduce ec implementation to MPI library crypto: sm2 - introduce OSCCA SM2 asymmetric cipher alg

[PATCH v4 8/8] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm

2020-07-08 Thread Tianjia Zhang
Asymmetric digsig supports SM2-with-SM3 algorithm combination, so that IMA can also verify SM2's signature data. Signed-off-by: Tianjia Zhang --- security/integrity/digsig_asymmetric.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/security/inte

[PATCH v4 7/8] X.509: support OSCCA sm2-with-sm3 certificate verification

2020-07-08 Thread Tianjia Zhang
calculate ZA. Finally calculate the digest of the signature and complete the verification work. The calculation process of ZA is declared in specifications GM/T 0009-2012 and GM/T 0003.2-2012. Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/Makefile | 1 + crypto

[PATCH v4 3/8] lib/mpi: Introduce ec implementation to MPI library

2020-07-08 Thread Tianjia Zhang
The implementation of EC is introduced from libgcrypt as the basic algorithm of elliptic curve, which can be more perfectly integrated with MPI implementation. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang --- include/linux/mpi.h | 105

[PATCH v4 4/8] crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm

2020-07-08 Thread Tianjia Zhang
://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 oscca: http://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002386.shtml scctc: http://www.gmbz.org.cn/main/bzlb.html Signed-off-by: Tianjia Zhang --- crypto/Kconfig | 17 ++ crypto/Makefile | 8 + crypto/sm2.c | 473

[PATCH v4 6/8] X.509: support OSCCA certificate parse

2020-07-08 Thread Tianjia Zhang
standard elliptic curve public key, and the sm2 algorithm signs the hash generated by sm3. Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/x509_cert_parser.c | 14 +- include/linux/oid_registry.h | 6 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff

[PATCH v4 2/8] lib/mpi: Extend the MPI library

2020-07-08 Thread Tianjia Zhang
Expand the mpi library based on libgcrypt, and the ECC algorithm of mpi based on libgcrypt requires these functions. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang --- include/linux/mpi.h| 88 +++ lib/mpi/Makefile | 5

[PATCH v4 1/8] crypto: sm3 - export crypto_sm3_final function

2020-07-08 Thread Tianjia Zhang
Both crypto_sm3_update and crypto_sm3_finup have been exported, exporting crypto_sm3_final, to avoid having to use crypto_sm3_finup(desc, NULL, 0, dgst) to calculate the hash in some cases. Signed-off-by: Tianjia Zhang --- crypto/sm3_generic.c | 7 --- include/crypto/sm3.h | 2 ++ 2 files

[PATCH v5 0/8] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-07-09 Thread Tianjia Zhang
sig support sm2-with-sm3 algorithm. 2. remove unused sm2_set_priv_key(). 3. rebase on mainline. v2 changes: 1. simplify the sm2 algorithm and only retain the verify function. 2. extract the sm2 certificate code into a separate file. Tianjia Zhang (8): crypto: sm3 - export crypto_sm3_final

[PATCH v5 5/8] crypto: testmgr - support test with different ciphertext per encryption

2020-07-09 Thread Tianjia Zhang
achieve the test purpose. Signed-off-by: Tianjia Zhang --- crypto/testmgr.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 6863f911fcee..0dc94461c437 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -4025,7 +4025,7 @@ static

[PATCH v5 2/8] lib/mpi: Extend the MPI library

2020-07-09 Thread Tianjia Zhang
Expand the mpi library based on libgcrypt, and the ECC algorithm of mpi based on libgcrypt requires these functions. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang --- include/linux/mpi.h| 88 +++ lib/mpi/Makefile | 5

[PATCH v5 7/8] X.509: support OSCCA sm2-with-sm3 certificate verification

2020-07-09 Thread Tianjia Zhang
calculate ZA. Finally calculate the digest of the signature and complete the verification work. The calculation process of ZA is declared in specifications GM/T 0009-2012 and GM/T 0003.2-2012. Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/Makefile | 1 + crypto

[PATCH v5 6/8] X.509: support OSCCA certificate parse

2020-07-09 Thread Tianjia Zhang
standard elliptic curve public key, and the sm2 algorithm signs the hash generated by sm3. Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/x509_cert_parser.c | 14 +- include/linux/oid_registry.h | 6 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff

[PATCH v5 4/8] crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm

2020-07-09 Thread Tianjia Zhang
://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 oscca: http://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002386.shtml scctc: http://www.gmbz.org.cn/main/bzlb.html Signed-off-by: Tianjia Zhang --- crypto/Kconfig | 17 ++ crypto/Makefile | 8 + crypto/sm2.c | 473

[PATCH v5 3/8] lib/mpi: Introduce ec implementation to MPI library

2020-07-09 Thread Tianjia Zhang
The implementation of EC is introduced from libgcrypt as the basic algorithm of elliptic curve, which can be more perfectly integrated with MPI implementation. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang --- include/linux/mpi.h | 105

[PATCH v5 8/8] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm

2020-07-09 Thread Tianjia Zhang
Asymmetric digsig supports SM2-with-SM3 algorithm combination, so that IMA can also verify SM2's signature data. Signed-off-by: Tianjia Zhang --- security/integrity/digsig_asymmetric.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/security/inte

[PATCH v5 1/8] crypto: sm3 - export crypto_sm3_final function

2020-07-09 Thread Tianjia Zhang
Both crypto_sm3_update and crypto_sm3_finup have been exported, exporting crypto_sm3_final, to avoid having to use crypto_sm3_finup(desc, NULL, 0, dgst) to calculate the hash in some cases. Signed-off-by: Tianjia Zhang --- crypto/sm3_generic.c | 7 --- include/crypto/sm3.h | 2 ++ 2 files

Re: [PATCH v5 2/8] lib/mpi: Extend the MPI library

2020-07-12 Thread Tianjia Zhang
On 2020/7/10 21:12, Marcelo Henrique Cerri wrote: Hi, Tianjia. On Thu, Jul 09, 2020 at 04:40:09PM +0800, Tianjia Zhang wrote: Expand the mpi library based on libgcrypt, and the ECC algorithm of mpi based on libgcrypt requires these functions. Some other algorithms will be developed based on

[PATCH] crypto: mediatek - Fix wrong return value in mtk_desc_ring_alloc()

2020-08-02 Thread Tianjia Zhang
In case of memory allocation failure, a negative error code should be returned. Fixes: 785e5c616c849 ("crypto: mediatek - Add crypto driver support for some MediaTek chips") Cc: Ryder Lee Signed-off-by: Tianjia Zhang --- drivers/crypto/mediatek/mtk-platform.c | 4 ++-- 1 file

[PATCH v6 8/8] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm

2020-09-03 Thread Tianjia Zhang
Asymmetric digsig supports SM2-with-SM3 algorithm combination, so that IMA can also verify SM2's signature data. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- security/integrity/digsig_asymmetric.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --

[PATCH v6 3/8] lib/mpi: Introduce ec implementation to MPI library

2020-09-03 Thread Tianjia Zhang
The implementation of EC is introduced from libgcrypt as the basic algorithm of elliptic curve, which can be more perfectly integrated with MPI implementation. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang

[PATCH v6 1/8] crypto: sm3 - export crypto_sm3_final function

2020-09-03 Thread Tianjia Zhang
Both crypto_sm3_update and crypto_sm3_finup have been exported, exporting crypto_sm3_final, to avoid having to use crypto_sm3_finup(desc, NULL, 0, dgst) to calculate the hash in some cases. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/sm3_generic.c | 7 --- include

[PATCH v6 5/8] crypto: testmgr - support test with different ciphertext per encryption

2020-09-03 Thread Tianjia Zhang
achieve the test purpose. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/testmgr.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 23c27fc96394..cd002a030af5 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c

[PATCH v6 0/8] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-09-03 Thread Tianjia Zhang
ate code into a separate file. Tianjia Zhang (8): crypto: sm3 - export crypto_sm3_final function lib/mpi: Extend the MPI library lib/mpi: Introduce ec implementation to MPI library crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm crypto: testmgr - support test with different

[PATCH v6 2/8] lib/mpi: Extend the MPI library

2020-09-03 Thread Tianjia Zhang
Expand the mpi library based on libgcrypt, and the ECC algorithm of mpi based on libgcrypt requires these functions. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- include/linux/mpi.h| 87 +++ lib/mpi

[PATCH v6 7/8] X.509: support OSCCA sm2-with-sm3 certificate verification

2020-09-03 Thread Tianjia Zhang
calculate ZA. Finally calculate the digest of the signature and complete the verification work. The calculation process of ZA is declared in specifications GM/T 0009-2012 and GM/T 0003.2-2012. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/asymmetric_keys/Makefile | 1

[PATCH v6 6/8] X.509: support OSCCA certificate parse

2020-09-03 Thread Tianjia Zhang
standard elliptic curve public key, and the sm2 algorithm signs the hash generated by sm3. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/asymmetric_keys/x509_cert_parser.c | 14 +- include/linux/oid_registry.h | 6 ++ 2 files changed, 19 insertions

[PATCH v6 4/8] crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm

2020-09-03 Thread Tianjia Zhang
://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 oscca: http://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002386.shtml scctc: http://www.gmbz.org.cn/main/bzlb.html Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/Kconfig | 17 ++ crypto/Makefile | 8

Re: [PATCH v6 7/8] X.509: support OSCCA sm2-with-sm3 certificate verification

2020-09-13 Thread Tianjia Zhang
Hi Gilad, On 9/13/20 3:12 PM, Gilad Ben-Yossef wrote: Hi, On Thu, Sep 3, 2020 at 4:13 PM Tianjia Zhang wrote: The digital certificate format based on SM2 crypto algorithm as specified in GM/T 0015-2012. It was published by State Encryption Management Bureau, China. The method of

Re: [PATCH v6 0/8] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-09-14 Thread Tianjia Zhang
Hi, On 9/11/20 12:24 PM, Herbert Xu wrote: On Thu, Sep 03, 2020 at 09:12:34PM +0800, Tianjia Zhang wrote: --- v6 changes: 1. remove mpi_sub_ui function from mpi library. 2. rebase on mainline. This series is still missing acks for patches 6-8. Without them it cannot proceed. Thanks

Re: [PATCH v6 5/8] crypto: testmgr - support test with different ciphertext per encryption

2020-09-18 Thread Tianjia Zhang
On 9/18/20 2:47 PM, Herbert Xu wrote: On Thu, Sep 03, 2020 at 09:12:39PM +0800, Tianjia Zhang wrote: Some asymmetric algorithms will get different ciphertext after each encryption, such as SM2, and let testmgr support the testing of such algorithms. In struct akcipher_testvec, set c and

[PATCH v7 00/10] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-09-20 Thread Tianjia Zhang
3. rebase on mainline. v2 changes: 1. simplify the sm2 algorithm and only retain the verify function. 2. extract the sm2 certificate code into a separate file. Tianjia Zhang (10): crypto: sm3 - export crypto_sm3_final function lib/mpi: Extend the MPI library lib/mpi: Introduce ec implem

[PATCH v7 07/10] crypto: sm2 - add SM2 test vectors to testmgr

2020-09-20 Thread Tianjia Zhang
Add testmgr test vectors for SM2 algorithm. These vectors come from `openssl pkeyutl -sign` and libgcrypt. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/testmgr.c | 6 + crypto/testmgr.h | 59 2 files changed, 65

[PATCH v7 10/10] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm

2020-09-20 Thread Tianjia Zhang
Asymmetric digsig supports SM2-with-SM3 algorithm combination, so that IMA can also verify SM2's signature data. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang Reviewed-by: Mimi Zohar Reviewed-by: Vitaly Chikunov --- security/integrity/digsig_asymmetric.c | 14 +++--- 1

[PATCH v7 03/10] lib/mpi: Introduce ec implementation to MPI library

2020-09-20 Thread Tianjia Zhang
The implementation of EC is introduced from libgcrypt as the basic algorithm of elliptic curve, which can be more perfectly integrated with MPI implementation. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang

[PATCH v7 02/10] lib/mpi: Extend the MPI library

2020-09-20 Thread Tianjia Zhang
Expand the mpi library based on libgcrypt, and the ECC algorithm of mpi based on libgcrypt requires these functions. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- include/linux/mpi.h| 87 +++ lib/mpi

[PATCH v7 05/10] crypto: testmgr - support test with different ciphertext per encryption

2020-09-20 Thread Tianjia Zhang
achieve the test purpose. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/testmgr.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 23c27fc96394..cd002a030af5 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c

[PATCH v7 01/10] crypto: sm3 - export crypto_sm3_final function

2020-09-20 Thread Tianjia Zhang
Both crypto_sm3_update and crypto_sm3_finup have been exported, exporting crypto_sm3_final, to avoid having to use crypto_sm3_finup(desc, NULL, 0, dgst) to calculate the hash in some cases. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/sm3_generic.c | 7 --- include

[PATCH v7 04/10] crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm

2020-09-20 Thread Tianjia Zhang
://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 oscca: http://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002386.shtml scctc: http://www.gmbz.org.cn/main/bzlb.html Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/Kconfig | 17 ++ crypto/Makefile | 8

[PATCH v7 09/10] X.509: support OSCCA SM2-with-SM3 certificate verification

2020-09-20 Thread Tianjia Zhang
calculate ZA. Finally calculate the digest of the signature and complete the verification work. The calculation process of ZA is declared in specifications GM/T 0009-2012 and GM/T 0003.2-2012. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang Reviewed-by: Gilad Ben-Yossef --- crypto

[PATCH v7 06/10] crypto: testmgr - Fix potential memory leak in test_akcipher_one()

2020-09-20 Thread Tianjia Zhang
When the 'key' allocation fails, the 'req' will not be released, which will cause memory leakage on this path. This patch adds a 'free_req' tag used to solve this problem, and two new err values are added to reflect the real reason of the error. Signed-off-by: Tianji

[PATCH v7 08/10] X.509: support OSCCA certificate parse

2020-09-20 Thread Tianjia Zhang
standard elliptic curve public key, and the sm2 algorithm signs the hash generated by sm3. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang Reviewed-by: Vitaly Chikunov --- crypto/asymmetric_keys/x509_cert_parser.c | 27 ++- include/linux/oid_registry.h | 6

Re: [PATCH] lib/mpi: Fix unused variable warnings

2020-09-25 Thread Tianjia Zhang
Hi Herbert, Thanks for your patch, I will do a test later. By the way, did you add special compilation parameters? I compile normally without warnings in gcc 6.5 and 9.3. Best regards, Tianjia On 9/25/20 4:19 PM, Herbert Xu wrote: On Mon, Sep 21, 2020 at 12:20:55AM +0800, Tianjia Zhang

Re: [PATCH] lib/mpi: Fix unused variable warnings

2020-09-25 Thread Tianjia Zhang
Hi Herbert, Thanks for your patch, The changes look good. I have tested this patch, so, Tested-by: Tianjia Zhang Best regards, Tianjia On 9/25/20 4:19 PM, Herbert Xu wrote: On Mon, Sep 21, 2020 at 12:20:55AM +0800, Tianjia Zhang wrote: Expand the mpi library based on libgcrypt, and the ECC

[PATCH] X.509: fix error return value on the failed path

2020-10-05 Thread Tianjia Zhang
When memory allocation fails, an appropriate return value should be set. Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification") Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/public_key_sm2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletio

[PATCH] crypto: sm2 - remove unnecessary reset operations

2020-10-15 Thread Tianjia Zhang
This is an algorithm optimization. The reset operation when setting the public key is repeated and redundant, so remove it. At the same time, `sm2_ecc_os2ec()` is optimized to make the function more simpler and more in line with the Linux code style. Signed-off-by: Tianjia Zhang --- crypto/sm2

[PATCH] crypto: ecrdsa - use subsys_initcall instead of module_init

2020-10-15 Thread Tianjia Zhang
All templates and generic algorithms have been registered in subsys_initcall instead of module_init. The ecrdsa algorithm happened to be missed. Here is a fix for it. Cc: Vitaly Chikunov Signed-off-by: Tianjia Zhang --- crypto/ecrdsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion

Re: [PATCH v2 0/7] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-05-29 Thread Tianjia Zhang
On 2020/4/16 14:01, Herbert Xu wrote: On Thu, Apr 02, 2020 at 08:34:57PM +0800, Tianjia Zhang wrote: Hello all, This new module implement the OSCCA certificate and SM2 public key algorithm. It was published by State Encryption Management Bureau, China. List of specifications for OSCCA

[PATCH v3 6/8] X.509: support OSCCA certificate parse

2020-06-09 Thread Tianjia Zhang
standard elliptic curve public key, and the sm2 algorithm signs the hash generated by sm3. Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/x509_cert_parser.c | 14 +- include/linux/oid_registry.h | 6 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff

[PATCH v3 1/8] crypto: sm3 - export crypto_sm3_final function

2020-06-09 Thread Tianjia Zhang
Both crypto_sm3_update and crypto_sm3_finup have been exported, exporting crypto_sm3_final, to avoid having to use crypto_sm3_finup(desc, NULL, 0, dgst) to calculate the hash in some cases. Signed-off-by: Tianjia Zhang --- crypto/sm3_generic.c | 7 --- include/crypto/sm3.h | 2 ++ 2 files

[PATCH v3 2/8] lib/mpi: Extend the MPI library

2020-06-09 Thread Tianjia Zhang
Expand the mpi library based on libgcrypt, and the ECC algorithm of mpi based on libgcrypt requires these functions. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang --- include/linux/mpi.h| 88 +++ lib/mpi/Makefile | 5

[PATCH v3 8/8] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm

2020-06-09 Thread Tianjia Zhang
Asymmetric digsig supports SM2-with-SM3 algorithm combination, so that IMA can also verify SM2's signature data. Signed-off-by: Tianjia Zhang --- security/integrity/digsig_asymmetric.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/security/inte

[PATCH v3 5/8] crypto: testmgr - support test with different ciphertext per encryption

2020-06-09 Thread Tianjia Zhang
achieve the test purpose. Signed-off-by: Tianjia Zhang --- crypto/testmgr.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 6863f911fcee..0dc94461c437 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -4025,7 +4025,7 @@ static

[PATCH v3 3/8] lib/mpi: Introduce ec implementation to MPI library

2020-06-09 Thread Tianjia Zhang
The implementation of EC is introduced from libgcrypt as the basic algorithm of elliptic curve, which can be more perfectly integrated with MPI implementation. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang --- include/linux/mpi.h | 105

[PATCH v3 7/8] X.509: support OSCCA sm2-with-sm3 certificate verification

2020-06-09 Thread Tianjia Zhang
calculate ZA. Finally calculate the digest of the signature and complete the verification work. The calculation process of ZA is declared in specifications GM/T 0009-2012 and GM/T 0003.2-2012. Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/Makefile | 1 + crypto

[PATCH v3 0/8] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-06-09 Thread Tianjia Zhang
v3 changes: 1. integrity asymmetric digsig support sm2-with-sm3 algorithm. 2. remove unused sm2_set_priv_key(). 3. rebase on mainline. v2 changes: 1. simplify the sm2 algorithm and only retain the verify function. 2. extract the sm2 certificate code into a separate file. Tianjia Zhang (8)

[PATCH v3 4/8] crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm

2020-06-09 Thread Tianjia Zhang
://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 oscca: http://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002386.shtml scctc: http://www.gmbz.org.cn/main/bzlb.html Signed-off-by: Tianjia Zhang --- crypto/Kconfig | 17 ++ crypto/Makefile | 8 + crypto/sm2.c | 473

Re: [PATCH v3 0/8] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-06-16 Thread Tianjia Zhang
On 2020/6/10 4:58, Vitaly Chikunov wrote: Tianjia, On Tue, Jun 09, 2020 at 09:48:47PM +0800, Tianjia Zhang wrote: Hello all, This new module implement the OSCCA certificate and SM2 public key algorithm. It was published by State Encryption Management Bureau, China. List of specifications

[PATCH] crypto: public_key: Remove redundant header file from public_key.h

2020-11-18 Thread Tianjia Zhang
The akcipher.h header file was originally introduced in SM2, and then the definition of SM2 was moved to the existing code. This header file is left and should be removed. Signed-off-by: Tianjia Zhang --- include/crypto/public_key.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include

Re: [PATCH] crypto: ecrdsa - use subsys_initcall instead of module_init

2020-11-29 Thread Tianjia Zhang
Hi Herbert, On 10/15/20 8:05 PM, Herbert Xu wrote: On Thu, Oct 15, 2020 at 07:02:41PM +0800, Tianjia Zhang wrote: All templates and generic algorithms have been registered in subsys_initcall instead of module_init. The ecrdsa algorithm happened to be missed. Here is a fix for it. That is

Re: [PATCH] crypto: ecrdsa - use subsys_initcall instead of module_init

2020-11-29 Thread Tianjia Zhang
On 11/30/20 10:24 AM, Herbert Xu wrote: On Mon, Nov 30, 2020 at 10:21:56AM +0800, Tianjia Zhang wrote: That is true only if there are non-generic implementations of the algorithms, which is not the case here. Please explain the real reason why this is needed. This is a generic algorithm

Re: Null pointer dereference in public key verification (related to SM2 introduction)

2021-01-07 Thread Tianjia Zhang
Hi, Sorry, I just read this email. I will submit the fix patch as soon as possible. Thanks for reporting. Best regards, Tianjia On 1/7/21 3:27 PM, Tee Hao Wei wrote: On 2/12/20 8:24 pm, Tobias Markus wrote: Hi David, I'm afraid I can't provide an exactly matching disassembly of the functi

[PATCH] X.509: Fix crash caused by NULL pointer

2021-01-07 Thread Tianjia Zhang
ply check this situation and fixes the crash caused by NULL pointer. Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification") Cc: sta...@vger.kernel.org # v5.10+ Reported-by: Tobias Markus Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/public_key.c |

Re: [PATCH] crypto: public_key: check that pkey_algo is non-NULL before passing it to strcmp()

2021-01-12 Thread Tianjia Zhang
Hi, I have fixed this problem last week. Still thanks for your fixing. patch is here: https://lkml.org/lkml/2021/1/7/201 Best regards, Tianjia On 1/13/21 12:10 AM, Toke Høiland-Jørgensen wrote: When public_key_verify_signature() is called from asymmetric_key_verify_signature(), the pkey_algo f

Re: [PATCH] X.509: Fix crash caused by NULL pointer

2021-01-12 Thread Tianjia Zhang
On 1/7/21 6:58 PM, David Howells wrote: Tianjia Zhang wrote: On the following call path, `sig->pkey_algo` is not assigned in asymmetric_key_verify_signature(), which causes runtime crash in public_key_verify_signature(). keyctl_pkey_verify asymmetric_key_verify_signat

Re: [PATCH v6 4/4] ima: Support EC keys for signature verification

2021-02-01 Thread Tianjia Zhang
keys, we change the selection of the encoding type to be driven by the key's signature scheme rather than by the hash type. Signed-off-by: Stefan Berger Reviewed-by: Vitaly Chikunov Cc: Mimi Zohar Cc: Dmitry Kasatkin Cc: linux-integr...@vger.kernel.org Cc: Vitaly Chikunov Cc: Tianjia Zhan

Re: [PATCH v6 2/4] x509: Detect sm2 keys by their parameters OID

2021-02-01 Thread Tianjia Zhang
); + /* * sprint_OID - Print an Object Identifier into a buffer * @data: The encoded OID to print Great job, I'm just curious why we need to add a new function, this seems unnecessary, if possible, please add Reviewed-by: Tianjia Zhang Best regards, Tianjia

Re: [PATCH v9 2/9] x509: Detect sm2 keys by their parameters OID

2021-03-04 Thread Tianjia Zhang
Sjd9GWIe98Ll9J0dquxgCktp9DrTAPBgNVHRMBAf8EBTADAQH/MAoG CCqBHM9VAYN1A0cAMEQCIAvLWIfGFq85u/vVMLc5H1D/DnrNS0VhSkQA4daRO4tc AiABbeWENcQZDZLWTuqG9P2KDPOoNqV/QV/+0XjMAVblhg== -END CERTIFICATE----- If you can, please add: Tested-by: Tianjia Zhang good luck! Tianjia

Re: [PATCH v10 5/9] x509: Detect sm2 keys by their parameters OID

2021-03-04 Thread Tianjia Zhang
-off-by: Stefan Berger Reviewed-by: Tianjia Zhang --- crypto/asymmetric_keys/x509_cert_parser.c | 12 +++- include/linux/oid_registry.h | 1 + lib/oid_registry.c| 13 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crypto

Re: [PATCH v9 2/9] x509: Detect sm2 keys by their parameters OID

2021-03-07 Thread Tianjia Zhang
Hi, On 3/5/21 11:04 PM, Stefan Berger wrote: On 3/5/21 2:37 AM, Tianjia Zhang wrote: Hi, On 3/4/21 7:46 AM, Stefan Berger wrote: Tianjia,     can you say whether SM2 support works for you before and after applying this patch? I cannot verify it with an sm2 key I have created using a

[PATCH] init/Kconfig: Support sign module with SM3 hash algorithm

2021-03-23 Thread Tianjia Zhang
The kernel module signature supports the option to use the SM3 secure hash (OSCCA GM/T 0004-2012 SM3). Signed-off-by: Tianjia Zhang --- Documentation/admin-guide/module-signing.rst | 5 +++-- crypto/asymmetric_keys/pkcs7_parser.c| 7 +++ init/Kconfig

Re: [PATCH] init/Kconfig: Support sign module with SM3 hash algorithm

2021-03-24 Thread Tianjia Zhang
Hi, On 3/24/21 12:43 AM, Randy Dunlap wrote: On 3/23/21 1:35 AM, Tianjia Zhang wrote: The kernel module signature supports the option to use the SM3 secure hash (OSCCA GM/T 0004-2012 SM3). Signed-off-by: Tianjia Zhang --- Documentation/admin-guide/module-signing.rst | 5 +++-- crypto

Re: [PATCH] init/Kconfig: Support sign module with SM3 hash algorithm

2021-03-24 Thread Tianjia Zhang
Hi, On 3/24/21 6:14 AM, Ard Biesheuvel wrote: On Tue, 23 Mar 2021 at 09:36, Tianjia Zhang wrote: The kernel module signature supports the option to use the SM3 secure hash (OSCCA GM/T 0004-2012 SM3). Signed-off-by: Tianjia Zhang A secure hash is not the same as a signature. Looking at

[PATCH v2 1/2] pkcs7: make parser enable SM2 and SM3 algorithms combination

2021-03-24 Thread Tianjia Zhang
Support parsing the message signature of the SM2 and SM3 algorithm combination. This group of algorithms has been well supported. One of the main users is module signature verification. Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/pkcs7_parser.c | 7 +++ 1 file changed, 7

[PATCH v2 0/2] support sign module with SM2-with-SM3 algorithm

2021-03-24 Thread Tianjia Zhang
rithm sign-file sm3 private.pem cert.pem test.ko test.ko.signed At this point, we should built the CA certificate into the kernel, and then we can load the SM2-with-SM3 signed module normally. --- v2 change: - split one patch into twos. - richer commit log. Tianjia Zhang (2): pkcs7: make parse

[PATCH v2 2/2] init/Kconfig: support sign module with SM2-with-SM3 algorithm

2021-03-24 Thread Tianjia Zhang
cert.pem test.ko test.ko.signed At this point, we should built the CA certificate into the kernel, and then we can load the SM2-with-SM3 signed module normally. Signed-off-by: Tianjia Zhang --- Documentation/admin-guide/module-signing.rst | 5 +++-- init/Kconfig

[PATCH] crypto: sm3 - use the more precise type u32 instead of unsigned int

2021-03-25 Thread Tianjia Zhang
In the process of calculating the hash, use the more accurate type 'u32' instead of the original 'unsigned int' to avoid ambiguity. Signed-off-by: Tianjia Zhang --- crypto/sm3_generic.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cr

Re: [PATCH] crypto: sm3 - use the more precise type u32 instead of unsigned int

2021-04-06 Thread Tianjia Zhang
On 3/26/21 5:38 PM, Gilad Ben-Yossef wrote: Hi, Thank you for the patch! On Fri, Mar 26, 2021 at 5:21 AM Tianjia Zhang wrote: In the process of calculating the hash, use the more accurate type 'u32' instead of the original 'unsigned int' to avoid ambiguity. I don&

Re: [PATCH v2 0/2] support sign module with SM2-with-SM3 algorithm

2021-04-06 Thread Tianjia Zhang
ping. Thanks, Tianjia On 3/24/21 8:15 PM, Tianjia Zhang wrote: The kernel module signature supports the option to use the SM3 secure hash (OSCCA GM/T 0004-2012 SM3). SM2 and SM3 always appear in pairs. The former is used for signing and the latter is used for hash calculation. To sign a