Skip to content

Commit 07f081f

Browse files
dhowellsJames Morris
authored andcommitted
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. Reported-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu> Signed-off-by: David Howells <dhowells@redhat.com> Tested-By: Valdis Kletnieks <valdis.kletnieks@vt.edu> Signed-off-by: James Morris <james.l.morris@oracle.com>
1 parent 3f1d44a commit 07f081f

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎crypto/asymmetric_keys/mscode_parser.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ int mscode_note_digest_algo(void *context, size_t hdrlen,
9797
case OID_sha256:
9898
ctx->digest_algo = HASH_ALGO_SHA256;
9999
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;
100109

101110
case OID__NR:
102111
sprint_oid(value, vlen, buffer, sizeof(buffer));

‎crypto/asymmetric_keys/pkcs7_parser.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen,
229229
case OID_sha256:
230230
ctx->sinfo->sig.pkey_hash_algo = HASH_ALGO_SHA256;
231231
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;
232240
default:
233241
printk("Unsupported digest algo: %u\n", ctx->last_oid);
234242
return -ENOPKG;

‎include/linux/oid_registry.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ enum OID {
6363
OID_certAuthInfoAccess, /* 1.3.6.1.5.5.7.1.1 */
6464
OID_sha1, /* 1.3.14.3.2.26 */
6565
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 */
6669

6770
/* Distinguished Name attribute IDs [RFC 2256] */
6871
OID_commonName, /* 2.5.4.3 */

0 commit comments

Comments
 (0)