Skip to content

Commit 20fad86

Browse files
authored
cms: Added a test for BER-CMS (#1941)
1 parent a6c5a29 commit 20fad86

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

cms/tests/cms_ber.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#[cfg(test)]
2+
mod tests {
3+
use cms::content_info::ContentInfo;
4+
use der::Decode;
5+
use hex_literal::hex;
6+
7+
#[test]
8+
fn convert_indefinite_ber_ejbca_cms() {
9+
// This represents the cms structure sent by EJBCA for SCEP requests.
10+
#[rustfmt::skip]
11+
const EXAMPLE_BER: &[u8] = &hex![
12+
"30 80" // ContentInfo SEQUENCE (2 elem) (indefinite length)
13+
"06 09 2a 86 48 86 f7 0d 01 07 02" // contentType ContentType OBJECT IDENTIFIER
14+
"a0 80" // content [0] ANY (1 elem) (indefinite length)
15+
"30 80" // SignedData SEQUENCE (5 elem) (indefinite length)
16+
"02 01 01" // version CMSVersion INTEGER 1
17+
"31 00" // digestAlgorithms DigestAlgorithmIdentifiers SET (0 elem)
18+
"30 0b" // encapContentInfo EncapsulatedContentInfo SEQUENCE (1 elem)
19+
"06 09 2a 86 48 86 f7 0d 01 07 01" // eContentType ContentType OBJECT IDENTIFIER
20+
"a0 80" // CertificateSet ANY (2 elem) (indefinite length)
21+
"30 06" // CertificateChoices SEQUENCE (3 elem)
22+
"30 00"
23+
"30 00"
24+
"30 00"
25+
"30 06" // CertificateChoices SEQUENCE (3 elem)
26+
"30 00"
27+
"30 00"
28+
"30 00"
29+
"00 00"
30+
"31 00" // signerInfos SignerInfos SET (0 elem)
31+
"00 00"
32+
"00 00"
33+
"00 00"
34+
];
35+
assert!(ContentInfo::from_ber(EXAMPLE_BER).is_ok());
36+
}
37+
}

0 commit comments

Comments
 (0)