History

PKCS#7: Add OIDs for sha224, sha284 and sha512 hash algos and use them

Add OIDs for sha224, sha284 and sha512 hash algos and use them to select the hashing algorithm. Without this, something like the following error might get written to dmesg: [ 31.829322] PKCS7: Unknown OID: [32] 2.16.840.1.101.3.4.2.3 [ 31.829328] PKCS7: Unknown OID: [180] 2.16.840.1.101.3.4.2.3 [ 31.829330] Unsupported digest algo: 55 Where the 55 on the third line is OID__NR indicating an unknown OID.

David Howells committed 11 years ago

Commit 07f081f1 parent 3f1d44a3 files · +20 −0Browse files

Unified · Split

3 files
  1. crypto/asymmetric_keys/mscode_parser.c +9 −0
  2. crypto/asymmetric_keys/pkcs7_parser.c +8 −0
  3. include/linux/oid_registry.h +3 −0
crypto/asymmetric_keys/mscode_parser.c+9−0
@@ -97,6 +97,15 @@ int mscode_note_digest_algo(void *context, size_t hdrlen, · 96 unmodified lines
97 case OID_sha256:97 case OID_sha256:
98 ctx->digest_algo = HASH_ALGO_SHA256;98 ctx->digest_algo = HASH_ALGO_SHA256;
99 break;99 break;
100 case OID_sha384:
101 ctx->digest_algo = HASH_ALGO_SHA384;
102 break;
103 case OID_sha512:
104 ctx->digest_algo = HASH_ALGO_SHA512;
105 break;
106 case OID_sha224:
107 ctx->digest_algo = HASH_ALGO_SHA224;
108 break;
100 109
101 case OID__NR:110 case OID__NR:
102 sprint_oid(value, vlen, buffer, sizeof(buffer));111 sprint_oid(value, vlen, buffer, sizeof(buffer));
crypto/asymmetric_keys/pkcs7_parser.c+8−0
@@ -229,6 +229,14 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen, · 228 unmodified lines
229 case OID_sha256:229 case OID_sha256:
230 ctx->sinfo->sig.pkey_hash_algo = HASH_ALGO_SHA256;230 ctx->sinfo->sig.pkey_hash_algo = HASH_ALGO_SHA256;
231 break;231 break;
232 case OID_sha384:
233 ctx->sinfo->sig.pkey_hash_algo = HASH_ALGO_SHA384;
234 break;
235 case OID_sha512:
236 ctx->sinfo->sig.pkey_hash_algo = HASH_ALGO_SHA512;
237 break;
238 case OID_sha224:
239 ctx->sinfo->sig.pkey_hash_algo = HASH_ALGO_SHA224;
232 default:240 default:
233 printk("Unsupported digest algo: %u\n", ctx->last_oid);241 printk("Unsupported digest algo: %u\n", ctx->last_oid);
234 return -ENOPKG;242 return -ENOPKG;
include/linux/oid_registry.h+3−0
@@ -63,6 +63,9 @@ enum OID { · 62 unmodified lines
63 OID_certAuthInfoAccess, /* 1.3.6.1.5.5.7.1.1 */63 OID_certAuthInfoAccess, /* 1.3.6.1.5.5.7.1.1 */
64 OID_sha1, /* 1.3.14.3.2.26 */64 OID_sha1, /* 1.3.14.3.2.26 */
65 OID_sha256, /* 2.16.840.1.101.3.4.2.1 */65 OID_sha256, /* 2.16.840.1.101.3.4.2.1 */
66 OID_sha384, /* 2.16.840.1.101.3.4.2.2 */
67 OID_sha512, /* 2.16.840.1.101.3.4.2.3 */
68 OID_sha224, /* 2.16.840.1.101.3.4.2.4 */
66 69
67 /* Distinguished Name attribute IDs [RFC 2256] */70 /* Distinguished Name attribute IDs [RFC 2256] */
68 OID_commonName, /* 2.5.4.3 */71 OID_commonName, /* 2.5.4.3 */