Skip to content

Commit ee62afb

Browse files
xnoxherbertx
authored andcommitted
crypto: rsa-pkcs1pad - Add FIPS 202 SHA-3 support
Add support in rsa-pkcs1pad for FIPS 202 SHA-3 hashes, sizes 256 and up. As 224 is too weak for any practical purposes. Signed-off-by: Dimitri John Ledkov <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 4b05765 commit ee62afb

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

crypto/rsa-pkcs1pad.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ static const u8 rsa_digest_info_sha512[] = {
6161
0x05, 0x00, 0x04, 0x40
6262
};
6363

64+
static const u8 rsa_digest_info_sha3_256[] = {
65+
0x30, 0x31, 0x30, 0x0d, 0x06, 0x09,
66+
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x08,
67+
0x05, 0x00, 0x04, 0x20
68+
};
69+
70+
static const u8 rsa_digest_info_sha3_384[] = {
71+
0x30, 0x41, 0x30, 0x0d, 0x06, 0x09,
72+
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x09,
73+
0x05, 0x00, 0x04, 0x30
74+
};
75+
76+
static const u8 rsa_digest_info_sha3_512[] = {
77+
0x30, 0x51, 0x30, 0x0d, 0x06, 0x09,
78+
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x0A,
79+
0x05, 0x00, 0x04, 0x40
80+
};
81+
6482
static const struct rsa_asn1_template {
6583
const char *name;
6684
const u8 *data;
@@ -74,8 +92,13 @@ static const struct rsa_asn1_template {
7492
_(sha384),
7593
_(sha512),
7694
_(sha224),
77-
{ NULL }
7895
#undef _
96+
#define _(X) { "sha3-" #X, rsa_digest_info_sha3_##X, sizeof(rsa_digest_info_sha3_##X) }
97+
_(256),
98+
_(384),
99+
_(512),
100+
#undef _
101+
{ NULL }
79102
};
80103

81104
static const struct rsa_asn1_template *rsa_lookup_asn1(const char *name)

crypto/testmgr.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5464,6 +5464,18 @@ static const struct alg_test_desc alg_test_descs[] = {
54645464
.alg = "pkcs1pad(rsa,sha512)",
54655465
.test = alg_test_null,
54665466
.fips_allowed = 1,
5467+
}, {
5468+
.alg = "pkcs1pad(rsa,sha3-256)",
5469+
.test = alg_test_null,
5470+
.fips_allowed = 1,
5471+
}, {
5472+
.alg = "pkcs1pad(rsa,sha3-384)",
5473+
.test = alg_test_null,
5474+
.fips_allowed = 1,
5475+
}, {
5476+
.alg = "pkcs1pad(rsa,sha3-512)",
5477+
.test = alg_test_null,
5478+
.fips_allowed = 1,
54675479
}, {
54685480
.alg = "poly1305",
54695481
.test = alg_test_hash,

0 commit comments

Comments
 (0)