-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest_errors.rs
More file actions
109 lines (101 loc) · 3.15 KB
/
test_errors.rs
File metadata and controls
109 lines (101 loc) · 3.15 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Ignore warnings from not using the return value of `format!`.
#![expect(unused_must_use)]
use authenticode::{
AttributeCertificateAuthenticodeError, AttributeCertificateError,
AuthenticodeSignatureParseError, PeOffsetError,
};
use cms::content_info::CmsVersion;
use der::asn1::ObjectIdentifier;
// Don't check the actual messages, just validate that formatting without
// panic or error.
#[test]
fn test_attribute_certificate_authenticode_error() {
format!(
"{}",
AttributeCertificateAuthenticodeError::InvalidCertificateRevision(0)
);
format!(
"{}",
AttributeCertificateAuthenticodeError::InvalidCertificateType(0)
);
format!(
"{}",
AttributeCertificateAuthenticodeError::InvalidSignature(
AuthenticodeSignatureParseError::Empty
)
);
}
#[test]
fn test_attribute_certificate_error() {
format!("{}", AttributeCertificateError::InvalidSize);
format!("{}", AttributeCertificateError::OutOfBounds);
format!(
"{}",
AttributeCertificateError::InvalidCertificateSize { size: 123 }
);
}
#[test]
fn test_authenticode_signature_parse_error() {
let cms_ver = CmsVersion::V1;
let der_err = der::Error::new(der::ErrorKind::Failed, der::Length::ZERO);
let oid = ObjectIdentifier::new_unwrap("1.2.3");
format!("{}", AuthenticodeSignatureParseError::Empty);
format!(
"{}",
AuthenticodeSignatureParseError::InvalidContentInfo(der_err)
);
format!(
"{}",
AuthenticodeSignatureParseError::InvalidContentType(oid)
);
format!(
"{}",
AuthenticodeSignatureParseError::InvalidSignedData(der_err)
);
format!(
"{}",
AuthenticodeSignatureParseError::InvalidSignedDataVersion(cms_ver)
);
format!(
"{}",
AuthenticodeSignatureParseError::InvalidNumDigestAlgorithms(0)
);
format!(
"{}",
AuthenticodeSignatureParseError::InvalidEncapsulatedContentType(oid)
);
format!(
"{}",
AuthenticodeSignatureParseError::EmptyEncapsulatedContent
);
format!(
"{}",
AuthenticodeSignatureParseError::InvalidSpcIndirectDataContent(der_err)
);
format!(
"{}",
AuthenticodeSignatureParseError::InvalidNumSignerInfo(0)
);
format!(
"{}",
AuthenticodeSignatureParseError::InvalidSignerInfoVersion(cms_ver)
);
format!("{}", AuthenticodeSignatureParseError::AlgorithmMismatch);
format!(
"{}",
AuthenticodeSignatureParseError::EmptyAuthenticatedAttributes
);
format!("{}", AuthenticodeSignatureParseError::MissingContentTypeAuthenticatedAttribute);
format!("{}", AuthenticodeSignatureParseError::MissingMessageDigestAuthenticatedAttribute);
}
#[test]
fn test_pe_offset_error() {
format!("{}", PeOffsetError);
}