Skip to content

Commit c6d7bdf

Browse files
authored
common: add more RSA-PSS algorithm id definitions (#9412)
Breakout from #9405. Signed-off-by: William Woodruff <[email protected]>
1 parent 19b40c2 commit c6d7bdf

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/rust/cryptography-x509/src/common.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,22 @@ pub const PSS_SHA1_HASH_ALG: AlgorithmIdentifier<'_> = AlgorithmIdentifier {
234234
params: AlgorithmParameters::Sha1(Some(())),
235235
};
236236

237+
// RSA-PSS ASN.1 hash algorithm definitions specified under the CA/B Forum BRs.
238+
pub const PSS_SHA256_HASH_ALG: AlgorithmIdentifier<'_> = AlgorithmIdentifier {
239+
oid: asn1::DefinedByMarker::marker(),
240+
params: AlgorithmParameters::Sha256(Some(())),
241+
};
242+
243+
pub const PSS_SHA384_HASH_ALG: AlgorithmIdentifier<'_> = AlgorithmIdentifier {
244+
oid: asn1::DefinedByMarker::marker(),
245+
params: AlgorithmParameters::Sha384(Some(())),
246+
};
247+
248+
pub const PSS_SHA512_HASH_ALG: AlgorithmIdentifier<'_> = AlgorithmIdentifier {
249+
oid: asn1::DefinedByMarker::marker(),
250+
params: AlgorithmParameters::Sha512(Some(())),
251+
};
252+
237253
// This is defined as an AlgorithmIdentifier in RFC 4055,
238254
// but the mask generation algorithm **must** contain an AlgorithmIdentifier
239255
// in its params, so we define it this way.
@@ -249,6 +265,22 @@ pub const PSS_SHA1_MASK_GEN_ALG: MaskGenAlgorithm<'_> = MaskGenAlgorithm {
249265
params: PSS_SHA1_HASH_ALG,
250266
};
251267

268+
// RSA-PSS ASN.1 mask gen algorithms defined under the CA/B Forum BRs.
269+
pub const PSS_SHA256_MASK_GEN_ALG: MaskGenAlgorithm<'_> = MaskGenAlgorithm {
270+
oid: oid::MGF1_OID,
271+
params: PSS_SHA256_HASH_ALG,
272+
};
273+
274+
pub const PSS_SHA384_MASK_GEN_ALG: MaskGenAlgorithm<'_> = MaskGenAlgorithm {
275+
oid: oid::MGF1_OID,
276+
params: PSS_SHA384_HASH_ALG,
277+
};
278+
279+
pub const PSS_SHA512_MASK_GEN_ALG: MaskGenAlgorithm<'_> = MaskGenAlgorithm {
280+
oid: oid::MGF1_OID,
281+
params: PSS_SHA512_HASH_ALG,
282+
};
283+
252284
// From RFC 4055 section 3.1:
253285
// RSASSA-PSS-params ::= SEQUENCE {
254286
// hashAlgorithm [0] HashAlgorithm DEFAULT

0 commit comments

Comments
 (0)