#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(not(any(feature = "whitebox", feature = "whitebox_lite")))]
compile_error!(
"Aegis VM: 'whitebox' or 'whitebox_lite' feature is required for encrypted bytecode execution! \
Add `features = [\"whitebox\"]` to your aegis_vm dependency in Cargo.toml."
);
#[cfg(not(feature = "std"))]
extern crate alloc;
pub use aegis_vm_macro::vm_protect;
pub use aegis_vm_macro::obfuscate_strings;
pub use aegis_vm_macro::aegis_str;
pub mod error;
pub mod opcodes;
pub mod state;
pub mod handlers;
pub mod engine;
pub mod bytecode;
pub mod crypto;
pub mod native;
pub mod integrity;
pub mod smc;
pub mod string_obfuscation;
#[cfg(any(feature = "whitebox", feature = "whitebox_lite"))]
pub mod whitebox;
#[cfg(feature = "async_vm")]
pub mod async_vm;
pub use spin::Once as SpinOnce;
#[cfg(feature = "std")]
pub use std::vec::Vec as StdVec;
#[cfg(not(feature = "std"))]
pub use alloc::vec::Vec as StdVec;
pub use error::{VmError, VmResult};
pub use state::VmState;
pub use engine::{execute, execute_with_state, execute_with_natives, execute_with_native_table, run, run_with_natives, run_with_native_table};
pub use bytecode::{BytecodeHeader, BytecodePackage, ProtectionLevel, BuildInfo};
pub use crypto::CryptoContext;
pub use native::{NativeRegistry, NativeRegistryBuilder, NativeFunction, standard_ids};
pub use integrity::{IntegrityTable, IntegrityError, compute_hash, verify_hash};
pub use smc::{SmcConfig, execute_smc, execute_smc_with_natives, encrypt_bytecode, decrypt_bytecode};
pub mod build_config {
include!(concat!(env!("OUT_DIR"), "/build_config.rs"));
}
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn fnv1a_hash(data: &[u8]) -> u64 {
let mut hash = build_config::FNV_BASIS_64;
for &byte in data {
hash ^= byte as u64;
hash = hash.wrapping_mul(build_config::FNV_PRIME_64);
}
hash
}
pub fn fnv1a_hash32(data: &[u8]) -> u32 {
let mut hash = build_config::FNV_BASIS_32;
for &byte in data {
hash ^= byte as u32;
hash = hash.wrapping_mul(build_config::FNV_PRIME_32);
}
hash
}