crypto: add rsa pss support for x509
Subsystems (9)
cover crypto: add rsa pss support for x509
From: Hongbo Li <[email protected]>
This series of patches adds support for x509 cert signed by RSA with PSS encoding method. RSA PSS is described in rfc8017.
This series of patches adds support for x509 cert signed by RSA with PSS encoding method. RSA PSS is described in rfc8017.
Patch1 make x509 support rsa pss algo and parse hash parameter.
Patch2 add rsa pss template.
Patch3 add test vector for rsa pss.
Patch4 is the ecdsa ima patch borrowed from Stefan Berge's ecdsa
patch series, rsa-pss's ima patch is made on top of this patch.
Patch5 is the rsa-pss's ima patch.
Test by the following script, it tests different saltlen, hash, mgfhash.
keyctl newring test @u
while :; do
for modbits in 1024 2048 4096; do
if [ $modbits -eq 1024 ]; then
saltlen=(-1 -2 0 20 32 48 64 94)
elif [ $modbits -eq 2048 ]; then
saltlen=(-1 -2 0 20 32 48 64 222)
else
saltlen=(-1 -2 0 20 32 48 64 478)
fi
for slen in ${saltlen[@]}; do
for hash in sha1 sha224 sha256 sha384 sha512; do
for mgfhash in sha1 sha224 sha256 sha384 sha512; do
certfile="cert.der"
echo slen $slen
openssl req \
-x509 \
-${hash} \
-newkey rsa:$modbits \
-keyout key.pem \
-days 365 \
-subj '/CN=test' \
-nodes \
-sigopt rsa_padding_mode:pss \
-sigopt rsa_mgf1_md:$mgfhash \
-sigopt rsa_pss_saltlen:${slen} \
-outform der \
-out ${certfile} 2>/dev/null
exp=0
id=$(keyctl padd asymmetric testkey %keyring:test < "${certfile}")
rc=$?
if [ $rc -ne $exp ]; then
case "$exp" in
0) echo "Error: Could not load rsa-pss certificate!";;
esac
echo "modbits $modbits sha: $hash mgfhash $mgfhash saltlen: $slen"
exit 1
else
case "$rc" in
0) echo "load cert: keyid: $id modbits $modbits hash: $hash mgfhash $mgfhash saltlen $slen"
esac
fi
done
done
done
donedone
Hongbo Li (5):
x509: add support for rsa-pss
crypto: support rsa-pss encoding
crypto: add rsa pss test vector
crypto: ecdsa ima support
ima: add support for rsa pss verification
crypto/Makefile | 7 +- crypto/asymmetric_keys/Makefile | 7 +- crypto/asymmetric_keys/public_key.c | 5 ++ crypto/asymmetric_keys/x509_cert_parser.c | 71 ++++++++++++++++- crypto/rsa.c | 14 ++-- crypto/rsa_helper.c | 127 ++++++++++++++++++++++++++++++ crypto/testmgr.c | 7 ++ crypto/testmgr.h | 87 ++++++++++++++++++++ include/crypto/internal/rsa.h | 25 +++++- include/keys/asymmetric-type.h | 6 ++ include/linux/oid_registry.h | 2 + security/integrity/digsig_asymmetric.c | 34 ++++---- 12 files changed, 363 insertions(+), 29 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/5 x509: add support for rsa-pss
From: Hongbo Li <[email protected]>
This patch make x509 support rsa-pss, because the sha algo is in signature, so we need to parse the sha parameter, and skip other params.
--- crypto/asymmetric_keys/Makefile | 7 ++- crypto/asymmetric_keys/public_key.c | 5 +++ crypto/asymmetric_keys/x509_cert_parser.c | 71 +++++++++++++++++++++++++++++-- include/linux/oid_registry.h | 2 + 4 files changed, 80 insertions(+), 5 deletions(-)
crypto/asymmetric_keys/Makefile +6 -1
@@ -20,15 +20,20 @@ obj-$(CONFIG_X509_CERTIFICATE_PARSER) += x509_key_parser.o x509_key_parser-y := \ x509.asn1.o \ x509_akid.asn1.o \ + x509_rsapss_params.asn1.o \ x509_cert_parser.o \ x509_public_key.o $(obj)/x509_cert_parser.o: \ $(obj)/x509.asn1.h \ - $(obj)/x509_akid.asn1.h + $(obj)/x509_akid.asn1.h \ + $(obj)/x509_rsapss_params.asn1.h + $(obj)/x509.asn1.o: $(obj)/x509.asn1.c $(obj)/x509.asn1.h $(obj)/x509_akid.asn1.o: $(obj)/x509_akid.asn1.c $(obj)/x509_akid.asn1.h +$(obj)/x509_rsapss_params.asn1.o: \ + $(obj)/x509_rsapss_params.asn1.c $(obj)/x509_rsapss_params.asn1.h # # PKCS#8 private key handling
crypto/asymmetric_keys/public_key.c +5 -0
@@ -83,6 +83,11 @@ int software_key_determine_akcipher(const char *encoding,"pkcs1pad(%s,%s)" , pkey->pkey_algo, hash_algo);return n >=CRYPTO_MAX_ALG_NAME ? -EINVAL :0 ; + }else if (strcmp (encoding,"pss" ) ==0 ) { + n =snprintf (alg_name,CRYPTO_MAX_ALG_NAME , +"psspad(%s)" , + pkey->pkey_algo); +return n >=CRYPTO_MAX_ALG_NAME ? -EINVAL :0 ; }if (strcmp (encoding,"raw" ) ==0 ) {
crypto/asymmetric_keys/x509_cert_parser.c +67 -4
108 lines not on this page · raw message
include/linux/oid_registry.h +2 -0
@@ -28,6 +28,8 @@ enum OID { OID_md3WithRSAEncryption,/* 1.2.840.113549.1.1.3 */ OID_md4WithRSAEncryption,/* 1.2.840.113549.1.1.4 */ OID_sha1WithRSAEncryption,/* 1.2.840.113549.1.1.5 */ + OID_rsa_mgf1,/* 1.2.840.113549.1.1.8 */ + OID_rsa_pss,/* 1.2.840.113549.1.1.10 */ OID_sha256WithRSAEncryption,/* 1.2.840.113549.1.1.11 */ OID_sha384WithRSAEncryption,/* 1.2.840.113549.1.1.12 */ OID_sha512WithRSAEncryption, /* 1.2.840.113549.1.1.13 */
Signature · 1 line
1.8.3.1
kernel test robot
build botRe: [PATCH 1/5] x509: add support for rsa-pss
Thank you for the patch! Yet something to improve:
Hi Hongbo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on crypto/master]
[also build test ERROR on security/next-testing linus/master v5.12-rc6 next-20210406] [cannot apply to cryptodev/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Hongbo-Li/crypto-add-rsa-pss-support-for-x509/20210406-211503 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git master config: alpha-randconfig-p001-20210406 (attached as .config) compiler: alpha-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5aa0c74e8d4a650e359aec1790c35c2c26fb618f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hongbo-Li/crypto-add-rsa-pss-support-for-x509/20210406-211503 git checkout 5aa0c74e8d4a650e359aec1790c35c2c26fb618f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=alpha
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> make[3]: *** No rule to make target 'crypto/asymmetric_keys/x509_rsapss_params.asn1.c', needed by 'crypto/asymmetric_keys/x509_rsapss_params.asn1.o'.
make[3]: *** No rule to make target 'crypto/asymmetric_keys/x509_rsapss_params.asn1.h', needed by 'crypto/asymmetric_keys/x509_rsapss_params.asn1.o'. make[3]: Target '__build' not remade because of errors.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 2/5 crypto: support rsa-pss encoding
In reply to Hongbo LiFrom: Hongbo Li <[email protected]>
This patch add the support of rsa-pss encoding which is described rfc8017.
Similar to rsa-pkcs1, we create a pss template.
--- crypto/Makefile | 7 ++- crypto/rsa.c | 14 ++--- crypto/rsa_helper.c | 127 ++++++++++++++++++++++++++++++++++++++++++ include/crypto/internal/rsa.h | 25 ++++++++- 4 files changed, 164 insertions(+), 9 deletions(-)
crypto/Makefile +6 -1
@@ -33,13 +33,18 @@ obj-$(CONFIG_CRYPTO_DH) += dh_generic.o $(obj)/rsapubkey.asn1.o: $(obj)/rsapubkey.asn1.c $(obj)/rsapubkey.asn1.h $(obj)/rsaprivkey.asn1.o: $(obj)/rsaprivkey.asn1.c $(obj)/rsaprivkey.asn1.h -$(obj)/rsa_helper.o: $(obj)/rsapubkey.asn1.h $(obj)/rsaprivkey.asn1.h +$(obj)/rsapss_params.asn1.o: $(obj)/rsapss_params.asn1.c \ + $(obj)/rsapss_params.asn1.h +$(obj)/rsa_helper.o: $(obj)/rsapubkey.asn1.h $(obj)/rsaprivkey.asn1.h \ + $(obj)/rsapss_params.asn1.h rsa_generic-y := rsapubkey.asn1.o rsa_generic-y += rsaprivkey.asn1.o +rsa_generic-y += rsapss_params.asn1.o rsa_generic-y += rsa.o rsa_generic-y += rsa_helper.o rsa_generic-y += rsa-pkcs1pad.o +rsa_generic-y += rsa-psspad.o obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o $(obj)/sm2signature.asn1.o: $(obj)/sm2signature.asn1.c $(obj)/sm2signature.asn1.h
crypto/rsa.c +7 -7
@@ -6,18 +6,11 @@*/ #include <linux/module.h> -#include <linux/mpi.h> #include <crypto/internal/rsa.h> #include <crypto/internal/akcipher.h> #include <crypto/akcipher.h> #include <crypto/algapi.h> -struct rsa_mpi_key { -MPI n; -MPI e; -MPI d; -}; -/* * RSAEP function [RFC3447 sec 5.1.1] * c = m^e mod n;
@@ -269,12 +262,19 @@ static int rsa_init(void)return err; } + err =crypto_register_template (&rsa_psspad_tmpl); +if (err) { +crypto_unregister_akcipher (&rsa); +return err; + } +return 0 ; }static void rsa_exit (void ) {crypto_unregister_template (&rsa_pkcs1pad_tmpl); +crypto_unregister_template (&rsa_psspad_tmpl);crypto_unregister_akcipher (&rsa); }
crypto/rsa_helper.c +127 -0
142 lines not on this page · raw message
include/crypto/internal/rsa.h +24 -1
@@ -8,6 +8,12 @@#ifndef _RSA_HELPER_#define _RSA_HELPER_#include <linux/types.h> +#include <linux/mpi.h> +#include <linux/oid_registry.h> +#include <crypto/sha2.h> + +#define RSA_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE +#define RSA_PSS_DEFAULT_SALT_LEN 20/** * rsa_key - RSA key structure
@@ -47,11 +53,28 @@ struct rsa_key { size_t qinv_sz; }; +struct rsa_mpi_key { +MPI n; +MPI e; +MPI d; +}; + +struct rsa_pss_ctx { +struct crypto_akcipher *child; +unsigned int key_size; +const char *hash_algo; +const char *mgf_algo; +const char *mgf_hash_algo; +u32 salt_len; +}; +int rsa_parse_pub_key (struct rsa_key *rsa_key,const void *key,unsigned int key_len);int rsa_parse_priv_key (struct rsa_key *rsa_key,const void *key,unsigned int key_len); - +int rsa_parse_pss_params (struct rsa_pss_ctx *ctx,const void *params, +unsigned int params_len);extern struct crypto_template rsa_pkcs1pad_tmpl; +extern struct crypto_template rsa_psspad_tmpl;#endif
Signature · 1 line
1.8.3.1
kernel test robot
build botRe: [PATCH 2/5] crypto: support rsa-pss encoding
Thank you for the patch! Yet something to improve:
Hi Hongbo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on crypto/master]
[also build test ERROR on security/next-testing linus/master v5.12-rc6 next-20210406] [cannot apply to cryptodev/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Hongbo-Li/crypto-add-rsa-pss-support-for-x509/20210406-211503 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git master config: m68k-defconfig (attached as .config) compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/951e694ffaeb62069494bc7bc94c296183f4ed49
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hongbo-Li/crypto-add-rsa-pss-support-for-x509/20210406-211503 git checkout 951e694ffaeb62069494bc7bc94c296183f4ed49
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
make[2]: *** No rule to make target 'crypto//seqiv.o', needed by 'crypto//seqiv.mod'. make[2]: *** No rule to make target 'crypto//echainiv.o', needed by 'crypto//echainiv.mod'. make[2]: *** No rule to make target 'crypto//dh.o', needed by 'crypto//dh_generic.o'. make[2]: *** No rule to make target 'crypto//dh_helper.o', needed by 'crypto//dh_generic.o'. make[2]: *** No rule to make target 'crypto//rsapubkey.asn1.c', needed by 'crypto//rsapubkey.asn1.o'. make[2]: *** No rule to make target 'crypto//rsapubkey.asn1.h', needed by 'crypto//rsapubkey.asn1.o'. make[2]: *** No rule to make target 'crypto//rsaprivkey.asn1.c', needed by 'crypto//rsaprivkey.asn1.o'. make[2]: *** No rule to make target 'crypto//rsaprivkey.asn1.h', needed by 'crypto//rsaprivkey.asn1.o'. make[2]: *** No rule to make target 'crypto//rsapss_params.asn1.c', needed by 'crypto//rsapss_params.asn1.o'. make[2]: *** No rule to make target 'crypto//rsapss_params.asn1.h', needed by 'crypto//rsapss_params.asn1.o'. make[2]: *** No rule to make target 'crypto//rsa.o', needed by 'crypto//rsa_generic.o'. make[2]: *** No rule to make target 'crypto//rsa-pkcs1pad.o', needed by 'crypto//rsa_generic.o'.
>> make[2]: *** No rule to make target 'crypto//rsa-psspad.o', needed by 'crypto//rsa_generic.o'.
make[2]: *** No rule to make target 'crypto//sm2signature.asn1.c', needed by 'crypto//sm2signature.asn1.o'. make[2]: *** No rule to make target 'crypto//sm2signature.asn1.h', needed by 'crypto//sm2signature.asn1.o'. make[2]: *** No rule to make target 'crypto//crypto_user_base.o', needed by 'crypto//crypto_user.o'. make[2]: *** No rule to make target 'crypto//cmac.o', needed by 'crypto//cmac.mod'.
make[2]: *** No rule to make target 'crypto//hmac.o', needed by 'crypto//hmac.mod'.
make[2]: *** No rule to make target 'crypto//vmac.o', needed by 'crypto//vmac.mod'.
make[2]: *** No rule to make target 'crypto//md4.o', needed by 'crypto//md4.mod'.
make[2]: *** No rule to make target 'crypto//md5.o', needed by 'crypto//md5.mod'.
make[2]: *** No rule to make target 'crypto//rmd160.o', needed by 'crypto//rmd160.mod'. make[2]: *** No rule to make target 'crypto//sha1_generic.o', needed by 'crypto//sha1_generic.mod'. make[2]: *** No rule to make target 'crypto//sha256_generic.o', needed by 'crypto//sha256_generic.mod'. make[2]: *** No rule to make target 'crypto//sha512_generic.o', needed by 'crypto//sha512_generic.mod'. make[2]: *** No rule to make target 'crypto//sha3_generic.o', needed by 'crypto//sha3_generic.mod'. make[2]: *** No rule to make target 'crypto//sm3_generic.o', needed by 'crypto//sm3_generic.mod'. make[2]: *** No rule to make target 'crypto//streebog_generic.o', needed by 'crypto//streebog_generic.mod'. make[2]: *** No rule to make target 'crypto//wp512.o', needed by 'crypto//wp512.mod'. make[2]: *** No rule to make target 'crypto//blake2b_generic.o', needed by 'crypto//blake2b_generic.mod'. make[2]: *** No rule to make target 'crypto//blake2s_generic.o', needed by 'crypto//blake2s_generic.mod'. make[2]: *** No rule to make target 'crypto//gf128mul.o', needed by 'crypto//gf128mul.mod'. make[2]: *** No rule to make target 'crypto//ecb.o', needed by 'crypto//ecb.mod'.
make[2]: *** No rule to make target 'crypto//cbc.o', needed by 'crypto//cbc.mod'.
make[2]: *** No rule to make target 'crypto//cfb.o', needed by 'crypto//cfb.mod'.
make[2]: *** No rule to make target 'crypto//cts.o', needed by 'crypto//cts.mod'.
make[2]: *** No rule to make target 'crypto//lrw.o', needed by 'crypto//lrw.mod'.
make[2]: *** No rule to make target 'crypto//xts.o', needed by 'crypto//xts.mod'.
make[2]: *** No rule to make target 'crypto//ctr.o', needed by 'crypto//ctr.mod'.
make[2]: *** No rule to make target 'crypto//keywrap.o', needed by 'crypto//keywrap.mod'. make[2]: *** No rule to make target 'crypto//adiantum.o', needed by 'crypto//adiantum.mod'. make[2]: *** No rule to make target 'crypto//nhpoly1305.o', needed by 'crypto//nhpoly1305.mod'. make[2]: *** No rule to make target 'crypto//gcm.o', needed by 'crypto//gcm.mod'.
make[2]: *** No rule to make target 'crypto//ccm.o', needed by 'crypto//ccm.mod'.
make[2]: *** No rule to make target 'crypto//chacha20poly1305.o', needed by 'crypto//chacha20poly1305.mod'. make[2]: *** No rule to make target 'crypto//aegis128-core.o', needed by 'crypto//aegis128.o'. make[2]: *** No rule to make target 'crypto//cryptd.o', needed by 'crypto//cryptd.mod'. make[2]: *** No rule to make target 'crypto//des_generic.o', needed by 'crypto//des_generic.mod'. make[2]: *** No rule to make target 'crypto//fcrypt.o', needed by 'crypto//fcrypt.mod'. make[2]: *** No rule to make target 'crypto//blowfish_generic.o', needed by 'crypto//blowfish_generic.mod'. make[2]: *** No rule to make target 'crypto//blowfish_common.o', needed by 'crypto//blowfish_common.mod'. make[2]: *** No rule to make target 'crypto//twofish_generic.o', needed by 'crypto//twofish_generic.mod'. make[2]: *** No rule to make target 'crypto//twofish_common.o', needed by 'crypto//twofish_common.mod'. make[2]: *** No rule to make target 'crypto//serpent_generic.o', needed by 'crypto//serpent_generic.mod'. make[2]: *** No rule to make target 'crypto//sm4_generic.o', needed by 'crypto//sm4_generic.mod'. make[2]: *** No rule to make target 'crypto//aes_ti.o', needed by 'crypto//aes_ti.mod'. make[2]: *** No rule to make target 'crypto//camellia_generic.o', needed by 'crypto//camellia_generic.mod'. make[2]: *** No rule to make target 'crypto//cast_common.o', needed by 'crypto//cast_common.mod'. make[2]: *** No rule to make target 'crypto//cast5_generic.o', needed by 'crypto//cast5_generic.mod'. make[2]: *** No rule to make target 'crypto//cast6_generic.o', needed by 'crypto//cast6_generic.mod'. make[2]: *** No rule to make target 'crypto//arc4.o', needed by 'crypto//arc4.mod'.
make[2]: *** No rule to make target 'crypto//tea.o', needed by 'crypto//tea.mod'.
make[2]: *** No rule to make target 'crypto//khazad.o', needed by 'crypto//khazad.mod'. make[2]: *** No rule to make target 'crypto//anubis.o', needed by 'crypto//anubis.mod'. make[2]: *** No rule to make target 'crypto//seed.o', needed by 'crypto//seed.mod'.
make[2]: *** No rule to make target 'crypto//chacha_generic.o', needed by 'crypto//chacha_generic.mod'. make[2]: *** No rule to make target 'crypto//poly1305_generic.o', needed by 'crypto//poly1305_generic.mod'. make[2]: *** No rule to make target 'crypto//deflate.o', needed by 'crypto//deflate.mod'. make[2]: *** No rule to make target 'crypto//michael_mic.o', needed by 'crypto//michael_mic.mod'. make[2]: *** No rule to make target 'crypto//authenc.o', needed by 'crypto//authenc.mod'. make[2]: *** No rule to make target 'crypto//authencesn.o', needed by 'crypto//authencesn.mod'. make[2]: *** No rule to make target 'crypto//lzo.o', needed by 'crypto//lzo.mod'.
make[2]: *** No rule to make target 'crypto//lzo-rle.o', needed by 'crypto//lzo-rle.mod'. make[2]: *** No rule to make target 'crypto//lz4.o', needed by 'crypto//lz4.mod'.
make[2]: *** No rule to make target 'crypto//lz4hc.o', needed by 'crypto//lz4hc.mod'. make[2]: *** No rule to make target 'crypto//xxhash_generic.o', needed by 'crypto//xxhash_generic.mod'. make[2]: *** No rule to make target 'crypto//842.o', needed by 'crypto//842.mod'.
make[2]: *** No rule to make target 'crypto//ansi_cprng.o', needed by 'crypto//ansi_cprng.mod'. make[2]: *** No rule to make target 'crypto//drbg.o', needed by 'crypto//drbg.mod'.
make[2]: *** No rule to make target 'crypto//jitterentropy.o', needed by 'crypto//jitterentropy_rng.o'. make[2]: *** No rule to make target 'crypto//jitterentropy-kcapi.o', needed by 'crypto//jitterentropy_rng.o'. make[2]: *** No rule to make target 'crypto//tcrypt.o', needed by 'crypto//tcrypt.mod'. make[2]: *** No rule to make target 'crypto//ghash-generic.o', needed by 'crypto//ghash-generic.mod'. make[2]: *** No rule to make target 'crypto//af_alg.o', needed by 'crypto//af_alg.mod'. make[2]: *** No rule to make target 'crypto//algif_hash.o', needed by 'crypto//algif_hash.mod'. make[2]: *** No rule to make target 'crypto//algif_skcipher.o', needed by 'crypto//algif_skcipher.mod'. make[2]: *** No rule to make target 'crypto//algif_rng.o', needed by 'crypto//algif_rng.mod'. make[2]: *** No rule to make target 'crypto//algif_aead.o', needed by 'crypto//algif_aead.mod'. make[2]: *** No rule to make target 'crypto//zstd.o', needed by 'crypto//zstd.mod'.
make[2]: *** No rule to make target 'crypto//ofb.o', needed by 'crypto//ofb.mod'.
make[2]: *** No rule to make target 'crypto//ecc.o', needed by 'crypto//ecc.mod'.
make[2]: *** No rule to make target 'crypto//essiv.o', needed by 'crypto//essiv.mod'. make[2]: *** No rule to make target 'crypto//curve25519-generic.o', needed by 'crypto//curve25519-generic.mod'. make[2]: *** No rule to make target 'crypto//ecdh.o', needed by 'crypto//ecdh_generic.o'. make[2]: *** No rule to make target 'crypto//ecdh_helper.o', needed by 'crypto//ecdh_generic.o'. make[2]: *** No rule to make target 'crypto//ecrdsa_params.asn1.h', needed by 'crypto//ecrdsa.o'. make[2]: *** No rule to make target 'crypto//ecrdsa_pub_key.asn1.h', needed by 'crypto//ecrdsa.o'. make[2]: *** No rule to make target 'crypto//ecrdsa_params.asn1.c', needed by 'crypto//ecrdsa_params.asn1.o'. make[2]: *** No rule to make target 'crypto//ecrdsa_pub_key.asn1.c', needed by 'crypto//ecrdsa_pub_key.asn1.o'. make[2]: *** No rule to make target 'crypto//xor.o', needed by 'crypto//xor.mod'.
make[2]: Target '__build' not remade because of errors.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 3/5 crypto: add rsa pss test vector
In reply to Hongbo LiFrom: Hongbo Li <[email protected]>
This patch adds the test vector for rsa with pss encoding.
--- crypto/testmgr.c | 7 +++++ crypto/testmgr.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)
crypto/testmgr.c +7 -0
@@ -5194,6 +5194,13 @@ static int alg_test_null(const struct alg_test_desc *desc, .test = alg_test_null, .fips_allowed = 1, }, { + .alg = "psspad(rsa)", + .test = alg_test_akcipher, + .fips_allowed = 1, + .suite = { + .akcipher = __VECS(psspad_rsa_tv_template) + } + }, { .alg = "poly1305", .test = alg_test_hash, .suite = {
crypto/testmgr.h +87 -0
93 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 4/5 crypto: ecdsa ima support
In reply to Hongbo LiFrom: Hongbo Li <[email protected]>
This patch is borrowed from Stefan Berger's ecdsa patch series, will be removed when ecdsa is merged into kernel.
--- include/keys/asymmetric-type.h | 6 ++++++ security/integrity/digsig_asymmetric.c | 29 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-)
include/keys/asymmetric-type.h +6 -0
@@ -72,6 +72,12 @@ const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key)return key->payload.data[asym_key_ids]; } +static inline +const struct public_key *asymmetric_key_public_key (const struct key *key) +{ +return key->payload.data[asym_crypto]; +} + extern struct key *find_asymmetric_key(struct key *keyring, const struct asymmetric_key_id *id_0, const struct asymmetric_key_id *id_1,
security/integrity/digsig_asymmetric.c +14 -15
@@ -84,6 +84,7 @@ int asymmetric_verify(struct key *keyring, const char *sig, {struct public_key_signature pks;struct signature_v2_hdr *hdr = (struct signature_v2_hdr *)sig; +const struct public_key *pk;struct key *key;int ret;
@@ -105,23 +106,21 @@ int asymmetric_verify(struct key *keyring, const char *sig,memset (&pks,0 ,sizeof (pks)); pks.hash_algo = hash_algo_name[hdr->hash_algo]; -switch (hdr->hash_algo) { -case HASH_ALGO_STREEBOG_256 : -case HASH_ALGO_STREEBOG_512 : -/* EC-RDSA and Streebog should go together. */ - pks.pkey_algo ="ecrdsa" ; - pks.encoding ="raw" ; -break ; -case HASH_ALGO_SM3_256 : -/* SM2 and SM3 should go together. */ - pks.pkey_algo ="sm2" ; - pks.encoding ="raw" ; -break ; -default : - pks.pkey_algo ="rsa" ; + + pk =asymmetric_key_public_key (key); + pks.pkey_algo = pk->pkey_algo; +if (!strcmp (pk->pkey_algo,"rsa" )) { pks.encoding ="pkcs1" ; -break ; + }else if (!strncmp (pk->pkey_algo,"ecdsa-" ,6 )) { +/* edcsa-nist-p192 etc. */ + pks.encoding ="x962" ; + }else if (!strcmp (pk->pkey_algo,"ecrdsa" ) || + !strcmp (pk->pkey_algo,"sm2" )) { + pks.encoding ="raw" ; + }else { +return -ENOPKG ; } + pks.digest = (u8 *)data; pks.digest_size = datalen; pks.s = hdr->sig;
Signature · 1 line
1.8.3.1
PATCH 5/5 ima: add support for rsa pss verification
In reply to Hongbo LiFrom: Hongbo Li <[email protected]>
This patch adds support for ima verification for rsa with pss encoding.
And a patch for ima-evm-utils will be sent later.
--- security/integrity/digsig_asymmetric.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
security/integrity/digsig_asymmetric.c +6 -1
@@ -85,6 +85,7 @@ int asymmetric_verify(struct key *keyring, const char *sig,struct public_key_signature pks;struct signature_v2_hdr *hdr = (struct signature_v2_hdr *)sig;const struct public_key *pk; +struct public_key_signature *cert_sig;struct key *key;int ret;
@@ -110,7 +111,11 @@ int asymmetric_verify(struct key *keyring, const char *sig, pk =asymmetric_key_public_key (key); pks.pkey_algo = pk->pkey_algo;if (!strcmp (pk->pkey_algo,"rsa" )) { - pks.encoding ="pkcs1" ; + cert_sig = key->payload.data[asym_auth]; +if (cert_sig) + pks.encoding = cert_sig->encoding; +else + pks.encoding ="pkcs1" ; }else if (!strncmp (pk->pkey_algo,"ecdsa-" ,6 )) {/* edcsa-nist-p192 etc. */ pks.encoding ="x962" ;
Signature · 1 line
1.8.3.1
Jarkko Sakkinen
maintainerQuoted 4 lines · Hongbo Li
From: Hongbo Li <[email protected]>
This series of patches adds support for x509 cert signed by RSA with PSS encoding method. RSA PSS is described in rfc8017.
Please also briefly describe it here AND also provide link to the RFC. In the way this currently is, it is too time consuming to review the patch set.
/Jarkko
Quoted 93 lines
This series of patches adds support for x509 cert signed by RSA with PSS encoding method. RSA PSS is described in rfc8017.
Patch1 make x509 support rsa pss algo and parse hash parameter.
Patch2 add rsa pss template.
Patch3 add test vector for rsa pss.
Patch4 is the ecdsa ima patch borrowed from Stefan Berge's ecdsa
patch series, rsa-pss's ima patch is made on top of this patch.Patch5 is the rsa-pss's ima patch.
Test by the following script, it tests different saltlen, hash, mgfhash.
keyctl newring test @u
while :; do
for modbits in 1024 2048 4096; do if [ $modbits -eq 1024 ]; then saltlen=(-1 -2 0 20 32 48 64 94) elif [ $modbits -eq 2048 ]; then saltlen=(-1 -2 0 20 32 48 64 222) else saltlen=(-1 -2 0 20 32 48 64 478) fi for slen in ${saltlen[@]}; do for hash in sha1 sha224 sha256 sha384 sha512; do for mgfhash in sha1 sha224 sha256 sha384 sha512; do certfile="cert.der" echo slen $slen openssl req \ -x509 \ -${hash} \ -newkey rsa:$modbits \ -keyout key.pem \ -days 365 \ -subj '/CN=test' \ -nodes \ -sigopt rsa_padding_mode:pss \ -sigopt rsa_mgf1_md:$mgfhash \ -sigopt rsa_pss_saltlen:${slen} \ -outform der \ -out ${certfile} 2>/dev/null exp=0 id=$(keyctl padd asymmetric testkey %keyring:test < "${certfile}") rc=$? if [ $rc -ne $exp ]; then case "$exp" in 0) echo "Error: Could not load rsa-pss certificate!";; esac echo "modbits $modbits sha: $hash mgfhash $mgfhash saltlen: $slen" exit 1 else case "$rc" in 0) echo "load cert: keyid: $id modbits $modbits hash: $hash mgfhash $mgfhash saltlen $slen" esac fi done done done donedone
Hongbo Li (5):
x509: add support for rsa-pss
crypto: support rsa-pss encoding
crypto: add rsa pss test vector
crypto: ecdsa ima support
ima: add support for rsa pss verificationcrypto/Makefile | 7 +- crypto/asymmetric_keys/Makefile | 7 +- crypto/asymmetric_keys/public_key.c | 5 ++ crypto/asymmetric_keys/x509_cert_parser.c | 71 ++++++++++++++++- crypto/rsa.c | 14 ++-- crypto/rsa_helper.c | 127 ++++++++++++++++++++++++++++++ crypto/testmgr.c | 7 ++ crypto/testmgr.h | 87 ++++++++++++++++++++ include/crypto/internal/rsa.h | 25 +++++- include/keys/asymmetric-type.h | 6 ++ include/linux/oid_registry.h | 2 + security/integrity/digsig_asymmetric.c | 34 ++++---- 12 files changed, 363 insertions(+), 29 deletions(-)Signature · 1 line
1.8.3.1
Re: [PATCH 0/5] crypto: add rsa pss support for x509(Internet mail)
Quoted 10 lines · Jarkko Sakkinen
Quoted 4 lines · Hongbo Li
From: Hongbo Li <[email protected]>
This series of patches adds support for x509 cert signed by RSA with PSS encoding method. RSA PSS is described in rfc8017.
Please also briefly describe it here AND also provide link to the RFC. In the way this currently is, it is too time consuming to review the patch set.
/Jarkko
Thanks, will add that in the following patches.
Quoted 93 lines
Quoted 92 lines
This series of patches adds support for x509 cert signed by RSA with PSS encoding method. RSA PSS is described in rfc8017.
Patch1 make x509 support rsa pss algo and parse hash parameter.
Patch2 add rsa pss template.
Patch3 add test vector for rsa pss.
Patch4 is the ecdsa ima patch borrowed from Stefan Berge's ecdsa
patch series, rsa-pss's ima patch is made on top of this patch.Patch5 is the rsa-pss's ima patch.
Test by the following script, it tests different saltlen, hash, mgfhash.
keyctl newring test @u
while :; do
for modbits in 1024 2048 4096; do if [ $modbits -eq 1024 ]; then saltlen=(-1 -2 0 20 32 48 64 94) elif [ $modbits -eq 2048 ]; then saltlen=(-1 -2 0 20 32 48 64 222) else saltlen=(-1 -2 0 20 32 48 64 478) fi for slen in ${saltlen[@]}; do for hash in sha1 sha224 sha256 sha384 sha512; do for mgfhash in sha1 sha224 sha256 sha384 sha512; do certfile="cert.der" echo slen $slen openssl req \ -x509 \ -${hash} \ -newkey rsa:$modbits \ -keyout key.pem \ -days 365 \ -subj '/CN=test' \ -nodes \ -sigopt rsa_padding_mode:pss \ -sigopt rsa_mgf1_md:$mgfhash \ -sigopt rsa_pss_saltlen:${slen} \ -outform der \ -out ${certfile} 2>/dev/null exp=0 id=$(keyctl padd asymmetric testkey %keyring:test < "${certfile}") rc=$? if [ $rc -ne $exp ]; then case "$exp" in 0) echo "Error: Could not load rsa-pss certificate!";; esac echo "modbits $modbits sha: $hash mgfhash $mgfhash saltlen: $slen" exit 1 else case "$rc" in 0) echo "load cert: keyid: $id modbits $modbits hash: $hash mgfhash $mgfhash saltlen $slen" esac fi done done done donedone
Hongbo Li (5):
x509: add support for rsa-pss
crypto: support rsa-pss encoding
crypto: add rsa pss test vector
crypto: ecdsa ima support
ima: add support for rsa pss verificationcrypto/Makefile | 7 +- crypto/asymmetric_keys/Makefile | 7 +- crypto/asymmetric_keys/public_key.c | 5 ++ crypto/asymmetric_keys/x509_cert_parser.c | 71 ++++++++++++++++- crypto/rsa.c | 14 ++-- crypto/rsa_helper.c | 127 ++++++++++++++++++++++++++++++ crypto/testmgr.c | 7 ++ crypto/testmgr.h | 87 ++++++++++++++++++++ include/crypto/internal/rsa.h | 25 +++++- include/keys/asymmetric-type.h | 6 ++ include/linux/oid_registry.h | 2 + security/integrity/digsig_asymmetric.c | 34 ++++---- 12 files changed, 363 insertions(+), 29 deletions(-)Signature · 1 line
1.8.3.1