Skip to contentSkip to conversation

pkcs7: support EC-RDSA/streebog in SignerInfo

PATCH In review Elvira Khabirova 4 participants 5 messages May 11, 2021 – Sep 21, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pkcs7: support EC-RDSA/streebog in SignerInfo

Allow using EC-RDSA/streebog in pkcs7 certificates in a similar way to how it's done in the x509 parser.

This is needed e.g. for loading kernel modules signed with EC-RDSA.

---
 crypto/asymmetric_keys/pkcs7_parser.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
crypto/asymmetric_keys/pkcs7_parser.c +11 -0
index 967329e0a07b..39c260a04167 100644
@@ -248,6 +248,12 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen,
 	case OID_sha224:
 		ctx->sinfo->sig->hash_algo = "sha224";
 		break;
+	case OID_gost2012Digest256:
+		ctx->sinfo->sig->hash_algo = "streebog256";
+		break;
+	case OID_gost2012Digest512:
+		ctx->sinfo->sig->hash_algo = "streebog512";
+		break;
 	default:
 		printk("Unsupported digest algo: %u\n", ctx->last_oid);
 		return -ENOPKG;
@@ -269,6 +275,11 @@ int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen,
 		ctx->sinfo->sig->pkey_algo = "rsa";
 		ctx->sinfo->sig->encoding = "pkcs1";
 		break;
+	case OID_gost2012PKey256:
+	case OID_gost2012PKey512:
+		ctx->sinfo->sig->pkey_algo = "ecrdsa";
+		ctx->sinfo->sig->encoding = "raw";
+		break;
 	default:
 		printk("Unsupported pkey algo: %u\n", ctx->last_oid);
 		return -ENOPKG;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Elvira Khabirova

Allow using EC-RDSA/streebog in pkcs7 certificates in a similar way to how it's done in the x509 parser.

This is needed e.g. for loading kernel modules signed with EC-RDSA.

Thanks,

Quoted 35 lines
---
 crypto/asymmetric_keys/pkcs7_parser.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
crypto/asymmetric_keys/pkcs7_parser.c +11 -0
index 967329e0a07b..39c260a04167 100644
@@ -248,6 +248,12 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen,
 	case OID_sha224:
 		ctx->sinfo->sig->hash_algo = "sha224";
 		break;
+	case OID_gost2012Digest256:
+		ctx->sinfo->sig->hash_algo = "streebog256";
+		break;
+	case OID_gost2012Digest512:
+		ctx->sinfo->sig->hash_algo = "streebog512";
+		break;
 	default:
 		printk("Unsupported digest algo: %u\n", ctx->last_oid);
 		return -ENOPKG;
@@ -269,6 +275,11 @@ int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen,
 		ctx->sinfo->sig->pkey_algo = "rsa";
 		ctx->sinfo->sig->encoding = "pkcs1";
 		break;
+	case OID_gost2012PKey256:
+	case OID_gost2012PKey512:
+		ctx->sinfo->sig->pkey_algo = "ecrdsa";
+		ctx->sinfo->sig->encoding = "raw";
+		break;
 	default:
 		printk("Unsupported pkey algo: %u\n", ctx->last_oid);
 		return -ENOPKG;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Elvira Khabirova

Hi Elvira,

Quoted 6 lines · Elvira Khabirova

Allow using EC-RDSA/streebog in pkcs7 certificates in a similar way to how it's done in the x509 parser.

This is needed e.g. for loading kernel modules signed with EC-RDSA.

I sent a similar patch to support the SM2/3 algorithm combination, which happened to conflict with your patch.

https://lkml.org/lkml/2021/6/24/248

If possible and you agree, I will put these two patches in a series and then resend.

Cheers,
Tianjia

Quoted 34 lines
---
  crypto/asymmetric_keys/pkcs7_parser.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
crypto/asymmetric_keys/pkcs7_parser.c +11 -0
index 967329e0a07b..39c260a04167 100644
@@ -248,6 +248,12 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen,
  	case OID_sha224:
  		ctx->sinfo->sig->hash_algo = "sha224";
  		break;
+	case OID_gost2012Digest256:
+		ctx->sinfo->sig->hash_algo = "streebog256";
+		break;
+	case OID_gost2012Digest512:
+		ctx->sinfo->sig->hash_algo = "streebog512";
+		break;
  	default:
  		printk("Unsupported digest algo: %u\n", ctx->last_oid);
  		return -ENOPKG;
@@ -269,6 +275,11 @@ int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen,
  		ctx->sinfo->sig->pkey_algo = "rsa";
  		ctx->sinfo->sig->encoding = "pkcs1";
  		break;
+	case OID_gost2012PKey256:
+	case OID_gost2012PKey512:
+		ctx->sinfo->sig->pkey_algo = "ecrdsa";
+		ctx->sinfo->sig->encoding = "raw";
+		break;
  	default:
  		printk("Unsupported pkey algo: %u\n", ctx->last_oid);
  		return -ENOPKG;
#3 lore raw
In reply to Elvira Khabirova

ping.

Quoted 40 lines · Elvira Khabirova

Allow using EC-RDSA/streebog in pkcs7 certificates in a similar way to how it's done in the x509 parser.

This is needed e.g. for loading kernel modules signed with EC-RDSA.

---
  crypto/asymmetric_keys/pkcs7_parser.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
crypto/asymmetric_keys/pkcs7_parser.c +11 -0
index 967329e0a07b..39c260a04167 100644
@@ -248,6 +248,12 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen,
  	case OID_sha224:
  		ctx->sinfo->sig->hash_algo = "sha224";
  		break;
+	case OID_gost2012Digest256:
+		ctx->sinfo->sig->hash_algo = "streebog256";
+		break;
+	case OID_gost2012Digest512:
+		ctx->sinfo->sig->hash_algo = "streebog512";
+		break;
  	default:
  		printk("Unsupported digest algo: %u\n", ctx->last_oid);
  		return -ENOPKG;
@@ -269,6 +275,11 @@ int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen,
  		ctx->sinfo->sig->pkey_algo = "rsa";
  		ctx->sinfo->sig->encoding = "pkcs1";
  		break;
+	case OID_gost2012PKey256:
+	case OID_gost2012PKey512:
+		ctx->sinfo->sig->pkey_algo = "ecrdsa";
+		ctx->sinfo->sig->encoding = "raw";
+		break;
  	default:
  		printk("Unsupported pkey algo: %u\n", ctx->last_oid);
  		return -ENOPKG;
maintainer Acked-by
#4 lore raw
Quoted 35 lines · Tianjia Zhang

ping.

Quoted 32 lines · Elvira Khabirova

Allow using EC-RDSA/streebog in pkcs7 certificates in a similar way to how it's done in the x509 parser.

This is needed e.g. for loading kernel modules signed with EC-RDSA.

---
  crypto/asymmetric_keys/pkcs7_parser.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
crypto/asymmetric_keys/pkcs7_parser.c +7 -0
index 967329e0a07b..39c260a04167 100644
@@ -248,6 +248,12 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen,
  	case OID_sha224:
  		ctx->sinfo->sig->hash_algo = "sha224";
  		break;
+	case OID_gost2012Digest256:
+		ctx->sinfo->sig->hash_algo = "streebog256";
+		break;
+	case OID_gost2012Digest512:
+		ctx->sinfo->sig->hash_algo = "streebog512";
+		break;
  	default:
  		printk("Unsupported digest algo: %u\n", ctx->last_oid);
  		return -ENOPKG;
@@ -269,6 +275,11 @@ int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen,
  		ctx->sinfo->sig->pkey_algo = "rsa";
  		ctx->sinfo->sig->encoding = "pkcs1";
  		break;
+	case OID_gost2012PKey256:
Quoted 8 lines

crypto/asymmetric_keys/pkcs7_parser.c int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen, · line 285

Quoted 8 lines
crypto/asymmetric_keys/pkcs7_parser.c +4 -0
+	case OID_gost2012PKey512:
+		ctx->sinfo->sig->pkey_algo = "ecrdsa";
+		ctx->sinfo->sig->encoding = "raw";
+		break;
  	default:
  		printk("Unsupported pkey algo: %u\n", ctx->last_oid);
  		return -ENOPKG;

/Jarkko