forked from RustCrypto/formats
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcms_ber.rs
More file actions
37 lines (36 loc) · 2.08 KB
/
cms_ber.rs
File metadata and controls
37 lines (36 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#[cfg(test)]
mod tests {
use cms::content_info::ContentInfo;
use der::Decode;
use hex_literal::hex;
#[test]
fn convert_indefinite_ber_ejbca_cms() {
// This represents the cms structure sent by EJBCA for SCEP requests.
#[rustfmt::skip]
const EXAMPLE_BER: &[u8] = &hex![
"30 80" // ContentInfo SEQUENCE (2 elem) (indefinite length)
"06 09 2a 86 48 86 f7 0d 01 07 02" // contentType ContentType OBJECT IDENTIFIER
"a0 80" // content [0] ANY (1 elem) (indefinite length)
"30 80" // SignedData SEQUENCE (5 elem) (indefinite length)
"02 01 01" // version CMSVersion INTEGER 1
"31 00" // digestAlgorithms DigestAlgorithmIdentifiers SET (0 elem)
"30 0b" // encapContentInfo EncapsulatedContentInfo SEQUENCE (1 elem)
"06 09 2a 86 48 86 f7 0d 01 07 01" // eContentType ContentType OBJECT IDENTIFIER
"a0 80" // CertificateSet ANY (2 elem) (indefinite length)
"30 06" // CertificateChoices SEQUENCE (3 elem)
"30 00"
"30 00"
"30 00"
"30 06" // CertificateChoices SEQUENCE (3 elem)
"30 00"
"30 00"
"30 00"
"00 00"
"31 00" // signerInfos SignerInfos SET (0 elem)
"00 00"
"00 00"
"00 00"
];
assert!(ContentInfo::from_ber(EXAMPLE_BER).is_ok());
}
}