Skip to content

Commit 8797a33

Browse files
committed
Remove mirai_annotations dependency
1 parent 8797bb2 commit 8797a33

File tree

7 files changed

+10
-55
lines changed

7 files changed

+10
-55
lines changed

.github/workflows/analysis.yml

-34
Original file line numberDiff line numberDiff line change
@@ -205,40 +205,6 @@ jobs:
205205
exit 0
206206
}
207207
208-
mirai-analysis:
209-
if: github.repository_owner == 'aws'
210-
runs-on: ubuntu-latest
211-
steps:
212-
- uses: actions/checkout@v3
213-
with:
214-
submodules: 'recursive'
215-
lfs: true
216-
217-
- uses: dtolnay/rust-toolchain@master
218-
id: toolchain
219-
with:
220-
toolchain: ${{ env.MIRAI_TOOLCHAIN }}
221-
components: rust-src, rustc-dev, llvm-tools-preview
222-
- name: Set Rust toolchain override
223-
run: rustup override set ${{ steps.toolchain.outputs.name }}
224-
225-
# https://github.com/facebookexperimental/MIRAI/blob/main/documentation/InstallationGuide.md#installing-mirai-into-cargo
226-
- name: Install MIRAI
227-
run: |
228-
MIRAI_TMP_SRC=$(mktemp -d)
229-
git clone --depth 1 --branch ${{ env.MIRAI_TAG }} https://github.com/facebookexperimental/MIRAI.git ${MIRAI_TMP_SRC}
230-
pushd ${MIRAI_TMP_SRC}
231-
cargo install --locked --force --path ./checker --no-default-features
232-
popd
233-
rm -rf ${MIRAI_TMP_SRC}
234-
235-
- name: Run MIRAI
236-
working-directory: ./aws-lc-rs
237-
run: |
238-
cargo update
239-
cargo update -p clap --precise 4.4.18
240-
cargo mirai
241-
242208
minimal-versions:
243209
if: github.repository_owner == 'aws'
244210
name: Resolve the dependencies to the minimum SemVer version

aws-lc-rs/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ untrusted = { version = "0.7.1", optional = true }
5050
aws-lc-sys = { version = "0.23.0", path = "../aws-lc-sys", optional = true }
5151
aws-lc-fips-sys = { version = "0.12.0", path = "../aws-lc-fips-sys", optional = true }
5252
zeroize = "1.7"
53-
mirai-annotations = "1.12.0"
5453
paste = "1.0.11"
5554

5655
[dev-dependencies]

aws-lc-rs/src/bn.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use crate::ptr::{ConstPointer, DetachableLcPtr, LcPtr};
55
use aws_lc::{BN_bin2bn, BN_bn2bin, BN_new, BN_num_bits, BN_num_bytes, BN_set_u64, BIGNUM};
66
use core::ptr::null_mut;
7-
use mirai_annotations::unrecoverable;
87

98
impl TryFrom<&[u8]> for LcPtr<BIGNUM> {
109
type Error = ();
@@ -56,9 +55,7 @@ impl ConstPointer<BIGNUM> {
5655
let bn_bytes = BN_num_bytes(**self);
5756
let mut byte_vec = Vec::with_capacity(bn_bytes as usize);
5857
let out_bytes = BN_bn2bin(**self, byte_vec.as_mut_ptr());
59-
if out_bytes != (bn_bytes as usize) {
60-
unrecoverable!("More bytes written than allocated.");
61-
}
58+
debug_assert_ne!(out_bytes, bn_bytes as usize);
6259
byte_vec.set_len(out_bytes);
6360
byte_vec
6461
}

aws-lc-rs/src/ptr.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ use aws_lc::{
1010
RSA,
1111
};
1212

13-
use mirai_annotations::verify_unreachable;
14-
1513
pub(crate) type LcPtr<T> = ManagedPointer<*mut T>;
1614
pub(crate) type DetachableLcPtr<T> = DetachablePointer<*mut T>;
1715

@@ -100,7 +98,7 @@ impl<P: Pointer> Deref for DetachablePointer<P> {
10098
Some(pointer) => pointer,
10199
None => {
102100
// Safety: pointer is only None when DetachableLcPtr is detached or dropped
103-
verify_unreachable!()
101+
unreachable!()
104102
}
105103
}
106104
}
@@ -131,7 +129,7 @@ impl<P: Pointer> From<DetachablePointer<P>> for ManagedPointer<P> {
131129
Some(pointer) => ManagedPointer { pointer },
132130
None => {
133131
// Safety: pointer is only None when DetachableLcPtr is detached or dropped
134-
verify_unreachable!()
132+
unreachable!()
135133
}
136134
}
137135
}

aws-lc-rs/src/rsa/encryption/oaep.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use aws_lc::{
1616
EVP_PKEY_CTX, RSA_PKCS1_OAEP_PADDING,
1717
};
1818
use core::{fmt::Debug, mem::size_of_val, ptr::null_mut};
19-
use mirai_annotations::verify_unreachable;
2019

2120
/// RSA-OAEP with SHA1 Hash and SHA1 MGF1
2221
pub const OAEP_SHA1_MGF1SHA1: OaepAlgorithm = OaepAlgorithm {
@@ -163,7 +162,7 @@ impl OaepPublicEncryptingKey {
163162
EncryptionAlgorithmId::OaepSha256Mgf1sha256 => 32,
164163
EncryptionAlgorithmId::OaepSha384Mgf1sha384 => 48,
165164
EncryptionAlgorithmId::OaepSha512Mgf1sha512 => 64,
166-
_ => verify_unreachable!(),
165+
_ => unreachable!(),
167166
};
168167

169168
// The RSA-OAEP algorithms we support use the hashing algorithm for the hash and mgf1 functions.

aws-lc-rs/src/rsa/key.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use core::{
4040
// use core::ffi::c_int;
4141
use std::os::raw::c_int;
4242

43-
use mirai_annotations::verify_unreachable;
4443
#[cfg(feature = "ring-io")]
4544
use untrusted::Input;
4645
use zeroize::Zeroize;
@@ -263,7 +262,7 @@ impl KeyPair {
263262
// https://github.com/awslabs/aws-lc/blob/main/include/openssl/rsa.h#L99
264263
unsafe { RSA_size(*rsa.as_const()) as usize }
265264
}
266-
Err(_) => verify_unreachable!(),
265+
Err(_) => unreachable!(),
267266
}
268267
}
269268
}

aws-lc-rs/src/test.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112

113113
extern crate alloc;
114114

115-
use mirai_annotations::unrecoverable;
116115
use std::error::Error;
117116

118117
use crate::{digest, error};
@@ -183,7 +182,7 @@ impl TestCase {
183182
"SHA3_256" => Some(&digest::SHA3_256),
184183
"SHA3_384" => Some(&digest::SHA3_384),
185184
"SHA3_512" => Some(&digest::SHA3_512),
186-
_ => unrecoverable!("Unsupported digest algorithm: {}", name),
185+
_ => unreachable!("Unsupported digest algorithm: {}", name),
187186
}
188187
}
189188

@@ -213,20 +212,18 @@ impl TestCase {
213212
Some(b't') => b'\t',
214213
Some(b'n') => b'\n',
215214
_ => {
216-
unrecoverable!("Invalid hex escape sequence in string.");
215+
panic!("Invalid hex escape sequence in string.");
217216
}
218217
}
219218
}
220219
Some(b'"') => {
221220
if s.next().is_some() {
222-
unrecoverable!(
223-
"characters after the closing quote of a quoted string."
224-
);
221+
panic!("characters after the closing quote of a quoted string.");
225222
}
226223
break;
227224
}
228225
Some(b) => *b,
229-
None => unrecoverable!("Missing terminating '\"' in string literal."),
226+
None => panic!("Missing terminating '\"' in string literal."),
230227
};
231228
bytes.push(b);
232229
}
@@ -236,7 +233,7 @@ impl TestCase {
236233
match from_hex(&s) {
237234
Ok(s) => s,
238235
Err(err_str) => {
239-
unrecoverable!("{} in {}", err_str, s);
236+
panic!("{} in {}", err_str, s);
240237
}
241238
}
242239
};

0 commit comments

Comments
 (0)