aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2018-10-09 12:47:15 -0400
committerJames Morris <james.morris@microsoft.com>2018-10-26 04:30:46 -0400
commit039884907787e55166e84e0b654a5342cc8a04ab (patch)
treefb7cdbe592729653377a85303a9ce3b162a73e2d
parent5a30771832aab228e0863e414f9182f86797429e (diff)
KEYS: Make the X.509 and PKCS7 parsers supply the sig encoding type [ver #2]
Make the X.509 and PKCS7 parsers fill in the signature encoding type field recently added to the public_key_signature struct. Signed-off-by: David Howells <dhowells@redhat.com> Tested-by: Marcel Holtmann <marcel@holtmann.org> Reviewed-by: Marcel Holtmann <marcel@holtmann.org> Reviewed-by: Denis Kenzior <denkenz@gmail.com> Tested-by: Denis Kenzior <denkenz@gmail.com> Signed-off-by: James Morris <james.morris@microsoft.com>
-rw-r--r--crypto/asymmetric_keys/pkcs7_parser.c1
-rw-r--r--crypto/asymmetric_keys/x509_cert_parser.c21
2 files changed, 10 insertions, 12 deletions
diff --git a/crypto/asymmetric_keys/pkcs7_parser.c b/crypto/asymmetric_keys/pkcs7_parser.c
index 0f134162cef4..f0d56e1a8b7e 100644
--- a/crypto/asymmetric_keys/pkcs7_parser.c
+++ b/crypto/asymmetric_keys/pkcs7_parser.c
@@ -271,6 +271,7 @@ int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen,
271 switch (ctx->last_oid) { 271 switch (ctx->last_oid) {
272 case OID_rsaEncryption: 272 case OID_rsaEncryption:
273 ctx->sinfo->sig->pkey_algo = "rsa"; 273 ctx->sinfo->sig->pkey_algo = "rsa";
274 ctx->sinfo->sig->encoding = "pkcs1";
274 break; 275 break;
275 default: 276 default:
276 printk("Unsupported pkey algo: %u\n", ctx->last_oid); 277 printk("Unsupported pkey algo: %u\n", ctx->last_oid);
diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index b6cabac4b62b..991f4d735a4e 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -199,35 +199,32 @@ int x509_note_pkey_algo(void *context, size_t hdrlen,
199 199
200 case OID_md4WithRSAEncryption: 200 case OID_md4WithRSAEncryption:
201 ctx->cert->sig->hash_algo = "md4"; 201 ctx->cert->sig->hash_algo = "md4";
202 ctx->cert->sig->pkey_algo = "rsa"; 202 goto rsa_pkcs1;
203 break;
204 203
205 case OID_sha1WithRSAEncryption: 204 case OID_sha1WithRSAEncryption:
206 ctx->cert->sig->hash_algo = "sha1"; 205 ctx->cert->sig->hash_algo = "sha1";
207 ctx->cert->sig->pkey_algo = "rsa"; 206 goto rsa_pkcs1;
208 break;
209 207
210 case OID_sha256WithRSAEncryption: 208 case OID_sha256WithRSAEncryption:
211 ctx->cert->sig->hash_algo = "sha256"; 209 ctx->cert->sig->hash_algo = "sha256";
212 ctx->cert->sig->pkey_algo = "rsa"; 210 goto rsa_pkcs1;
213 break;
214 211
215 case OID_sha384WithRSAEncryption: 212 case OID_sha384WithRSAEncryption:
216 ctx->cert->sig->hash_algo = "sha384"; 213 ctx->cert->sig->hash_algo = "sha384";
217 ctx->cert->sig->pkey_algo = "rsa"; 214 goto rsa_pkcs1;
218 break;
219 215
220 case OID_sha512WithRSAEncryption: 216 case OID_sha512WithRSAEncryption:
221 ctx->cert->sig->hash_algo = "sha512"; 217 ctx->cert->sig->hash_algo = "sha512";
222 ctx->cert->sig->pkey_algo = "rsa"; 218 goto rsa_pkcs1;
223 break;
224 219
225 case OID_sha224WithRSAEncryption: 220 case OID_sha224WithRSAEncryption:
226 ctx->cert->sig->hash_algo = "sha224"; 221 ctx->cert->sig->hash_algo = "sha224";
227 ctx->cert->sig->pkey_algo = "rsa"; 222 goto rsa_pkcs1;
228 break;
229 } 223 }
230 224
225rsa_pkcs1:
226 ctx->cert->sig->pkey_algo = "rsa";
227 ctx->cert->sig->encoding = "pkcs1";
231 ctx->algo_oid = ctx->last_oid; 228 ctx->algo_oid = ctx->last_oid;
232 return 0; 229 return 0;
233} 230}