Skip to content

Commit

Permalink
Remove mirai_annotations dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Nov 20, 2024
1 parent a9d5765 commit 0447a3d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 21 deletions.
1 change: 0 additions & 1 deletion aws-lc-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ untrusted = { version = "0.7.1", optional = true }
aws-lc-sys = { version = "0.23.0", path = "../aws-lc-sys", optional = true }
aws-lc-fips-sys = { version = "0.12.0", path = "../aws-lc-fips-sys", optional = true }
zeroize = "1.7"
mirai-annotations = "1.12.0"
paste = "1.0.11"

[dev-dependencies]
Expand Down
5 changes: 1 addition & 4 deletions aws-lc-rs/src/bn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use crate::ptr::{ConstPointer, DetachableLcPtr, LcPtr};
use aws_lc::{BN_bin2bn, BN_bn2bin, BN_new, BN_num_bits, BN_num_bytes, BN_set_u64, BIGNUM};
use core::ptr::null_mut;
use mirai_annotations::unrecoverable;

impl TryFrom<&[u8]> for LcPtr<BIGNUM> {
type Error = ();
Expand Down Expand Up @@ -56,9 +55,7 @@ impl ConstPointer<BIGNUM> {
let bn_bytes = BN_num_bytes(**self);
let mut byte_vec = Vec::with_capacity(bn_bytes as usize);
let out_bytes = BN_bn2bin(**self, byte_vec.as_mut_ptr());
if out_bytes != (bn_bytes as usize) {
unrecoverable!("More bytes written than allocated.");
}
debug_assert_ne!(out_bytes, bn_bytes as usize);
byte_vec.set_len(out_bytes);
byte_vec
}
Expand Down
6 changes: 2 additions & 4 deletions aws-lc-rs/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use aws_lc::{
RSA,
};

use mirai_annotations::verify_unreachable;

pub(crate) type LcPtr<T> = ManagedPointer<*mut T>;
pub(crate) type DetachableLcPtr<T> = DetachablePointer<*mut T>;

Expand Down Expand Up @@ -100,7 +98,7 @@ impl<P: Pointer> Deref for DetachablePointer<P> {
Some(pointer) => pointer,
None => {
// Safety: pointer is only None when DetachableLcPtr is detached or dropped
verify_unreachable!()
unreachable!()
}
}
}
Expand Down Expand Up @@ -131,7 +129,7 @@ impl<P: Pointer> From<DetachablePointer<P>> for ManagedPointer<P> {
Some(pointer) => ManagedPointer { pointer },
None => {
// Safety: pointer is only None when DetachableLcPtr is detached or dropped
verify_unreachable!()
unreachable!()
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions aws-lc-rs/src/rsa/encryption/oaep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use aws_lc::{
EVP_PKEY_CTX, RSA_PKCS1_OAEP_PADDING,
};
use core::{fmt::Debug, mem::size_of_val, ptr::null_mut};
use mirai_annotations::verify_unreachable;

/// RSA-OAEP with SHA1 Hash and SHA1 MGF1
pub const OAEP_SHA1_MGF1SHA1: OaepAlgorithm = OaepAlgorithm {
Expand Down Expand Up @@ -163,7 +162,7 @@ impl OaepPublicEncryptingKey {
EncryptionAlgorithmId::OaepSha256Mgf1sha256 => 32,
EncryptionAlgorithmId::OaepSha384Mgf1sha384 => 48,
EncryptionAlgorithmId::OaepSha512Mgf1sha512 => 64,
_ => verify_unreachable!(),
_ => unreachable!(),
};

// The RSA-OAEP algorithms we support use the hashing algorithm for the hash and mgf1 functions.
Expand Down
3 changes: 1 addition & 2 deletions aws-lc-rs/src/rsa/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use core::{
// use core::ffi::c_int;
use std::os::raw::c_int;

use mirai_annotations::verify_unreachable;
#[cfg(feature = "ring-io")]
use untrusted::Input;
use zeroize::Zeroize;
Expand Down Expand Up @@ -263,7 +262,7 @@ impl KeyPair {
// https://github.com/awslabs/aws-lc/blob/main/include/openssl/rsa.h#L99
unsafe { RSA_size(*rsa.as_const()) as usize }
}
Err(_) => verify_unreachable!(),
Err(_) => unreachable!(),
}
}
}
Expand Down
13 changes: 5 additions & 8 deletions aws-lc-rs/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@

extern crate alloc;

use mirai_annotations::unrecoverable;
use std::error::Error;

use crate::{digest, error};
Expand Down Expand Up @@ -183,7 +182,7 @@ impl TestCase {
"SHA3_256" => Some(&digest::SHA3_256),
"SHA3_384" => Some(&digest::SHA3_384),
"SHA3_512" => Some(&digest::SHA3_512),
_ => unrecoverable!("Unsupported digest algorithm: {}", name),
_ => unreachable!("Unsupported digest algorithm: {}", name),
}
}

Expand Down Expand Up @@ -213,20 +212,18 @@ impl TestCase {
Some(b't') => b'\t',
Some(b'n') => b'\n',
_ => {
unrecoverable!("Invalid hex escape sequence in string.");
panic!("Invalid hex escape sequence in string.");
}
}
}
Some(b'"') => {
if s.next().is_some() {
unrecoverable!(
"characters after the closing quote of a quoted string."
);
panic!("characters after the closing quote of a quoted string.");
}
break;
}
Some(b) => *b,
None => unrecoverable!("Missing terminating '\"' in string literal."),
None => panic!("Missing terminating '\"' in string literal."),
};
bytes.push(b);
}
Expand All @@ -236,7 +233,7 @@ impl TestCase {
match from_hex(&s) {
Ok(s) => s,
Err(err_str) => {
unrecoverable!("{} in {}", err_str, s);
panic!("{} in {}", err_str, s);
}
}
};
Expand Down

0 comments on commit 0447a3d

Please sign in to comment.