From 0447a3dbf2963eb3232874a0b8cc9e6d805e6761 Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Wed, 20 Nov 2024 18:03:57 -0500 Subject: [PATCH] Remove mirai_annotations dependency --- aws-lc-rs/Cargo.toml | 1 - aws-lc-rs/src/bn.rs | 5 +---- aws-lc-rs/src/ptr.rs | 6 ++---- aws-lc-rs/src/rsa/encryption/oaep.rs | 3 +-- aws-lc-rs/src/rsa/key.rs | 3 +-- aws-lc-rs/src/test.rs | 13 +++++-------- 6 files changed, 10 insertions(+), 21 deletions(-) diff --git a/aws-lc-rs/Cargo.toml b/aws-lc-rs/Cargo.toml index 5ea2e0e1095..66dfd2fb1b5 100644 --- a/aws-lc-rs/Cargo.toml +++ b/aws-lc-rs/Cargo.toml @@ -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] diff --git a/aws-lc-rs/src/bn.rs b/aws-lc-rs/src/bn.rs index 7deef7bda4a..cb1109457fd 100644 --- a/aws-lc-rs/src/bn.rs +++ b/aws-lc-rs/src/bn.rs @@ -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 { type Error = (); @@ -56,9 +55,7 @@ impl ConstPointer { 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 } diff --git a/aws-lc-rs/src/ptr.rs b/aws-lc-rs/src/ptr.rs index d6063e5edb6..f0b146adb3f 100644 --- a/aws-lc-rs/src/ptr.rs +++ b/aws-lc-rs/src/ptr.rs @@ -10,8 +10,6 @@ use aws_lc::{ RSA, }; -use mirai_annotations::verify_unreachable; - pub(crate) type LcPtr = ManagedPointer<*mut T>; pub(crate) type DetachableLcPtr = DetachablePointer<*mut T>; @@ -100,7 +98,7 @@ impl Deref for DetachablePointer

{ Some(pointer) => pointer, None => { // Safety: pointer is only None when DetachableLcPtr is detached or dropped - verify_unreachable!() + unreachable!() } } } @@ -131,7 +129,7 @@ impl From> for ManagedPointer

{ Some(pointer) => ManagedPointer { pointer }, None => { // Safety: pointer is only None when DetachableLcPtr is detached or dropped - verify_unreachable!() + unreachable!() } } } diff --git a/aws-lc-rs/src/rsa/encryption/oaep.rs b/aws-lc-rs/src/rsa/encryption/oaep.rs index 45d4e723a71..4f8184cbfb7 100644 --- a/aws-lc-rs/src/rsa/encryption/oaep.rs +++ b/aws-lc-rs/src/rsa/encryption/oaep.rs @@ -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 { @@ -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. diff --git a/aws-lc-rs/src/rsa/key.rs b/aws-lc-rs/src/rsa/key.rs index be8d8b14bb4..0372d8343a6 100644 --- a/aws-lc-rs/src/rsa/key.rs +++ b/aws-lc-rs/src/rsa/key.rs @@ -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; @@ -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!(), } } } diff --git a/aws-lc-rs/src/test.rs b/aws-lc-rs/src/test.rs index 735eb33a511..995a674cd3f 100644 --- a/aws-lc-rs/src/test.rs +++ b/aws-lc-rs/src/test.rs @@ -112,7 +112,6 @@ extern crate alloc; -use mirai_annotations::unrecoverable; use std::error::Error; use crate::{digest, error}; @@ -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), } } @@ -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); } @@ -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); } } };