Skip to content

Commit 3e2291a

Browse files
remove a ton of trusted annotations, label the others (#22)
1 parent b03aca1 commit 3e2291a

6 files changed

Lines changed: 57 additions & 64 deletions

File tree

capsules/system/src/process_checker/basic.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ pub struct AppCheckerSha256 {
9999
}
100100

101101
impl AppCheckerSha256 {
102-
#[flux_rs::trusted]
103102
pub fn new(
104103
hash: &'static dyn Sha256Verifier<'static>,
105104
buffer: &'static mut [u8; 32],
@@ -118,7 +117,7 @@ impl AppCredentialsPolicy<'static> for AppCheckerSha256 {
118117
fn require_credentials(&self) -> bool {
119118
true
120119
}
121-
#[flux_rs::trusted]
120+
122121
fn check_credentials(
123122
&self,
124123
credentials: TbfFooterV2Credentials,
@@ -139,15 +138,15 @@ impl AppCredentialsPolicy<'static> for AppCheckerSha256 {
139138
_ => Err((ErrorCode::NOSUPPORT, credentials, binary)),
140139
}
141140
}
142-
#[flux_rs::trusted]
141+
143142
fn set_client(&self, client: &'static dyn AppCredentialsPolicyClient<'static>) {
144143
self.client.replace(client);
145144
}
146145
}
147146

148147
impl ClientData<32_usize> for AppCheckerSha256 {
149148
fn add_mut_data_done(&self, _result: Result<(), ErrorCode>, _data: SubSliceMut<'static, u8>) {}
150-
#[flux_rs::trusted]
149+
151150
fn add_data_done(&self, result: Result<(), ErrorCode>, data: SubSlice<'static, u8>) {
152151
match result {
153152
Err(e) => panic!("Internal error during application binary checking. SHA256 engine threw error in adding data: {:?}", e),
@@ -161,7 +160,6 @@ impl ClientData<32_usize> for AppCheckerSha256 {
161160
}
162161

163162
impl ClientVerify<32_usize> for AppCheckerSha256 {
164-
#[flux_rs::trusted]
165163
fn verification_done(
166164
&self,
167165
result: Result<bool, ErrorCode>,
@@ -218,7 +216,6 @@ pub struct AppIdAssignerNames<'a, F: Fn(&'static str) -> u32> {
218216
hasher: &'a F,
219217
}
220218

221-
#[flux_rs::trusted]
222219
impl<'a, F: Fn(&'static str) -> u32> AppIdAssignerNames<'a, F> {
223220
pub fn new(hasher: &'a F) -> Self {
224221
Self { hasher }
@@ -248,7 +245,6 @@ impl<'a, F: Fn(&'static str) -> u32> AppUniqueness for AppIdAssignerNames<'a, F>
248245
}
249246

250247
impl<'a, F: Fn(&'static str) -> u32> Compress for AppIdAssignerNames<'a, F> {
251-
#[flux_rs::trusted]
252248
fn to_short_id(&self, process: &ProcessBinary) -> ShortId {
253249
let name = process.header.get_package_name().unwrap_or("");
254250
let sum = (self.hasher)(name);
@@ -271,7 +267,6 @@ pub struct AppCheckerRsaSimulated<'a> {
271267
binary: OptionalCell<&'a [u8]>,
272268
}
273269

274-
#[flux_rs::trusted]
275270
impl<'a> AppCheckerRsaSimulated<'a> {
276271
pub fn new() -> AppCheckerRsaSimulated<'a> {
277272
Self {
@@ -284,7 +279,6 @@ impl<'a> AppCheckerRsaSimulated<'a> {
284279
}
285280

286281
impl<'a> DeferredCallClient for AppCheckerRsaSimulated<'a> {
287-
#[flux_rs::trusted]
288282
fn handle_deferred_call(&self) {
289283
// This checker does not actually verify the RSA signature; it
290284
// assumes the signature is valid and so accepts any RSA
@@ -330,7 +324,7 @@ impl<'a> AppCredentialsPolicy<'a> for AppCheckerRsaSimulated<'a> {
330324
Err((ErrorCode::BUSY, credentials, binary))
331325
}
332326
}
333-
#[flux_rs::trusted]
327+
334328
fn set_client(&self, client: &'a dyn AppCredentialsPolicyClient<'a>) {
335329
self.client.replace(client);
336330
}

capsules/system/src/process_checker/signature.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ impl<
4747
const SL: usize,
4848
> AppCheckerSignature<'a, S, H, HL, SL>
4949
{
50-
#[flux_rs::trusted]
5150
pub fn new(
5251
hasher: &'a H,
5352
verifier: &'a S,
@@ -77,7 +76,7 @@ impl<
7776
> hil::digest::ClientData<HL> for AppCheckerSignature<'a, S, H, HL, SL>
7877
{
7978
fn add_mut_data_done(&self, _result: Result<(), ErrorCode>, _data: SubSliceMut<'static, u8>) {}
80-
#[flux_rs::trusted]
79+
8180
fn add_data_done(&self, result: Result<(), ErrorCode>, data: SubSlice<'static, u8>) {
8281
self.binary.set(data.take());
8382

@@ -104,7 +103,7 @@ impl<
104103
}
105104
}
106105
}
107-
#[flux_rs::trusted]
106+
108107
impl<
109108
'a,
110109
S: hil::public_key_crypto::signature::SignatureVerify<'static, HL, SL>,
@@ -161,7 +160,7 @@ impl<
161160
// Needed to make the sha256 client work.
162161
}
163162
}
164-
#[flux_rs::trusted]
163+
165164
impl<
166165
'a,
167166
S: hil::public_key_crypto::signature::SignatureVerify<'static, HL, SL>,
@@ -193,7 +192,7 @@ impl<
193192
});
194193
}
195194
}
196-
#[flux_rs::trusted]
195+
197196
impl<
198197
'a,
199198
S: hil::public_key_crypto::signature::SignatureVerify<'static, HL, SL>,

flux_support/src/flux_arr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,43 @@ pub struct RArray<T: Copy + Display> {
1111
}
1212

1313
impl<T: Copy + Display> RArray<T> {
14-
#[flux_rs::trusted]
14+
#[flux_rs::trusted(reason = "flux wrappers")]
1515
#[flux_rs::sig(fn (arr: [T; 8]) -> Self)]
1616
pub const fn new(arr: [T; 8]) -> Self {
1717
Self { arr }
1818
}
1919

20-
#[flux_rs::trusted]
20+
#[flux_rs::trusted(reason = "flux wrappers")]
2121
#[flux_rs::sig(fn (&Self[@arr], { usize[@idx] | idx < 8 }) -> T[map_select(arr, idx)])]
2222
pub fn get(&self, idx: usize) -> T {
2323
self.arr[idx]
2424
}
2525

26-
#[flux_rs::trusted]
26+
#[flux_rs::trusted(reason = "flux wrappers")]
2727
#[flux_rs::sig(fn (self: &strg Self[@arr], { usize[@idx] | idx < 8 }, item: T) ensures self: Self[map_store(arr, idx, item)])]
2828
pub fn set(&mut self, idx: usize, item: T) {
2929
self.arr[idx] = item;
3030
}
3131

32-
#[flux_rs::trusted]
32+
#[flux_rs::trusted(reason = "flux wrappers")]
3333
#[flux_rs::sig(fn (&Self) -> usize[8])]
3434
pub fn len(&self) -> usize {
3535
self.arr.len()
3636
}
3737

38-
#[flux_rs::trusted]
38+
#[flux_rs::trusted(reason = "flux wrappers")]
3939
pub fn iter_mut(&mut self) -> IterMut<T> {
4040
self.arr.iter_mut()
4141
}
4242

43-
#[flux_rs::trusted]
43+
#[flux_rs::trusted(reason = "flux wrappers")]
4444
pub fn iter(&self) -> Iter<T> {
4545
self.arr.iter()
4646
}
4747
}
4848

4949
impl<T: Display + Copy> Display for RArray<T> {
50-
#[flux_rs::trusted]
50+
#[flux_rs::trusted(reason = "flux wrappers")]
5151
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
5252
for item in self.arr.iter() {
5353
f.write_fmt(format_args!("{}", item))?;

0 commit comments

Comments
 (0)