Skip to content

Commit 1c9d4bc

Browse files
Switch to edition 2024
The source code changes are all just formatting, due to the switch to the 2024 style.
1 parent c562a37 commit 1c9d4bc

File tree

7 files changed

+72
-48
lines changed

7 files changed

+72
-48
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ members = ["authenticode", "authenticode-tool", "xtask"]
1111
resolver = "2"
1212

1313
[workspace.package]
14-
edition = "2021"
14+
edition = "2024"
1515
license = "MIT OR Apache-2.0"
1616
repository = "https://github.com/google/authenticode-rs"
1717
rust-version = "1.85"

authenticode-tool/src/main.rs

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#![forbid(unsafe_code)]
1010

11-
use anyhow::{anyhow, bail, Result};
11+
use anyhow::{Result, anyhow, bail};
1212
use authenticode::{
1313
AttributeCertificateIterator, AuthenticodeSignature, PeTrait,
1414
};
@@ -162,10 +162,12 @@ mod tests {
162162
#[test]
163163
fn test_action_info() {
164164
// Error: bad path.
165-
assert!(run_action(&Action::Info {
166-
pe_path: "../authenticode/tests/testdata/bad.efi".into(),
167-
})
168-
.is_err());
165+
assert!(
166+
run_action(&Action::Info {
167+
pe_path: "../authenticode/tests/testdata/bad.efi".into(),
168+
})
169+
.is_err()
170+
);
169171

170172
// Success, no signatures.
171173
run_action(&Action::Info {
@@ -189,36 +191,46 @@ mod tests {
189191
#[test]
190192
fn test_action_get_cert() {
191193
// Error: bad path.
192-
assert!(run_action(&Action::GetCert(GetCertAction {
193-
pe_path: "../authenticode/tests/testdata/bad.efi".into(),
194-
sig_index: 0,
195-
cert_index: 0,
196-
}))
197-
.is_err());
194+
assert!(
195+
run_action(&Action::GetCert(GetCertAction {
196+
pe_path: "../authenticode/tests/testdata/bad.efi".into(),
197+
sig_index: 0,
198+
cert_index: 0,
199+
}))
200+
.is_err()
201+
);
198202

199203
// Error: no signatures.
200-
assert!(run_action(&Action::GetCert(GetCertAction {
201-
pe_path: "../authenticode/tests/testdata/tiny64.efi".into(),
202-
sig_index: 0,
203-
cert_index: 0,
204-
}))
205-
.is_err());
204+
assert!(
205+
run_action(&Action::GetCert(GetCertAction {
206+
pe_path: "../authenticode/tests/testdata/tiny64.efi".into(),
207+
sig_index: 0,
208+
cert_index: 0,
209+
}))
210+
.is_err()
211+
);
206212

207213
// Error: invalid signature index.
208-
assert!(run_action(&Action::GetCert(GetCertAction {
209-
pe_path: "../authenticode/tests/testdata/tiny64.signed.efi".into(),
210-
sig_index: 1,
211-
cert_index: 0,
212-
}))
213-
.is_err());
214+
assert!(
215+
run_action(&Action::GetCert(GetCertAction {
216+
pe_path: "../authenticode/tests/testdata/tiny64.signed.efi"
217+
.into(),
218+
sig_index: 1,
219+
cert_index: 0,
220+
}))
221+
.is_err()
222+
);
214223

215224
// Error: invalid certificate index.
216-
assert!(run_action(&Action::GetCert(GetCertAction {
217-
pe_path: "../authenticode/tests/testdata/tiny64.signed.efi".into(),
218-
sig_index: 0,
219-
cert_index: 1,
220-
}))
221-
.is_err());
225+
assert!(
226+
run_action(&Action::GetCert(GetCertAction {
227+
pe_path: "../authenticode/tests/testdata/tiny64.signed.efi"
228+
.into(),
229+
sig_index: 0,
230+
cert_index: 1,
231+
}))
232+
.is_err()
233+
);
222234

223235
// Success, 32-bit.
224236
run_action(&Action::GetCert(GetCertAction {

authenticode/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ pub use authenticode_digest::authenticode_digest;
4848
pub use pe::{PeOffsetError, PeOffsets, PeTrait};
4949
pub use signature::{
5050
AuthenticodeSignature, AuthenticodeSignatureParseError, DigestInfo,
51-
SpcAttributeTypeAndOptionalValue, SpcIndirectDataContent,
52-
SPC_INDIRECT_DATA_OBJID,
51+
SPC_INDIRECT_DATA_OBJID, SpcAttributeTypeAndOptionalValue,
52+
SpcIndirectDataContent,
5353
};
5454
pub use win_cert::{
5555
AttributeCertificate, AttributeCertificateAuthenticodeError,

authenticode/src/pe_object.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use crate::pe::{PeOffsetError, PeOffsets, PeTrait};
1010
use crate::usize_from_u32;
1111
use core::mem;
1212
use core::ops::Range;
13-
use object::pe::{ImageDataDirectory, IMAGE_DIRECTORY_ENTRY_SECURITY};
13+
use object::pe::{IMAGE_DIRECTORY_ENTRY_SECURITY, ImageDataDirectory};
1414
use object::read::pe::ImageOptionalHeader;
1515
use object::read::pe::{ImageNtHeaders, PeFile};
16-
use object::{pod, LittleEndian, SectionIndex};
16+
use object::{LittleEndian, SectionIndex, pod};
1717

1818
impl<'data, I> PeTrait for PeFile<'data, I>
1919
where

authenticode/src/signature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use cms::content_info::CmsVersion;
1010
use cms::content_info::ContentInfo;
1111
use cms::signed_data::{SignedData, SignerInfo};
1212
use core::fmt::{self, Display, Formatter};
13-
use der::asn1::{ObjectIdentifier, OctetString};
1413
use der::Decode;
14+
use der::asn1::{ObjectIdentifier, OctetString};
1515
use der::{Sequence, SliceReader};
1616
use x509_cert::Certificate;
1717

authenticode/src/win_cert.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9-
use crate::usize_from_u32;
109
use crate::PeTrait;
10+
use crate::usize_from_u32;
1111
use crate::{AuthenticodeSignature, AuthenticodeSignatureParseError};
1212
use core::fmt::{self, Display, Formatter};
1313

@@ -59,10 +59,16 @@ impl Display for AttributeCertificateError {
5959
write!(f, "certificate table range is out of bounds")
6060
}
6161
Self::InvalidSize => {
62-
write!(f, "certificate table size does not match the sum of the certificate entry's aligned sizes")
62+
write!(
63+
f,
64+
"certificate table size does not match the sum of the certificate entry's aligned sizes"
65+
)
6366
}
6467
Self::InvalidCertificateSize { size } => {
65-
write!(f, "certificate table contains an entry with an invalid size: {size}")
68+
write!(
69+
f,
70+
"certificate table contains an entry with an invalid size: {size}"
71+
)
6672
}
6773
}
6874
}

authenticode/tests/test_authenticode.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use core::slice;
1919
use digest::{Digest, Update};
2020
use object::endian::LittleEndian as LE;
2121
use object::pe::{
22-
ImageDataDirectory, ImageFileHeader, ImageOptionalHeader64,
23-
IMAGE_DIRECTORY_ENTRY_SECURITY,
22+
IMAGE_DIRECTORY_ENTRY_SECURITY, ImageDataDirectory, ImageFileHeader,
23+
ImageOptionalHeader64,
2424
};
2525
use object::read::pe::{PeFile32, PeFile64};
2626
use sha1::Sha1;
@@ -127,20 +127,26 @@ fn check_exe(pe: &dyn PeTrait, expected: Expected) {
127127
fn test_authenticode32() {
128128
let pe = include_bytes!("testdata/tiny32.signed.efi");
129129
let pe64 = PeFile32::parse(pe.as_slice()).unwrap();
130-
check_exe(&pe64, Expected {
131-
sha1: "49f239f1cd5083912880e03982bb54528f2c358d",
132-
sha256: "4f5b3633fc51d9447beb5c546e9ae6e58d6eb42d1e96d623dc168d97013c08a8",
133-
});
130+
check_exe(
131+
&pe64,
132+
Expected {
133+
sha1: "49f239f1cd5083912880e03982bb54528f2c358d",
134+
sha256: "4f5b3633fc51d9447beb5c546e9ae6e58d6eb42d1e96d623dc168d97013c08a8",
135+
},
136+
);
134137
}
135138

136139
#[test]
137140
fn test_authenticode64() {
138141
let pe = include_bytes!("testdata/tiny64.signed.efi");
139142
let pe64 = PeFile64::parse(pe.as_slice()).unwrap();
140-
check_exe(&pe64, Expected {
141-
sha1: "e9bdfb63bdf687b8d3bf144033fcb09d7a393563",
142-
sha256: "a82d7e4f091c44ec75d97746b3461c8ea9151e2313f8e9a4330432ee5f25b2ae",
143-
});
143+
check_exe(
144+
&pe64,
145+
Expected {
146+
sha1: "e9bdfb63bdf687b8d3bf144033fcb09d7a393563",
147+
sha256: "a82d7e4f091c44ec75d97746b3461c8ea9151e2313f8e9a4330432ee5f25b2ae",
148+
},
149+
);
144150
}
145151

146152
fn modify_image_security_data_dir<F>(f: F) -> Vec<u8>

0 commit comments

Comments
 (0)