### Example: Initialize tables and encrypt a block Source: https://docs.rs/aegis_vm/latest/aegis_vm/whitebox/fn.init_tables.html Example usage of `init_tables` and `whitebox_encrypt`. It initializes the tables at startup without any key, then encrypts a 16-byte block. ```rust use aegis_vm::whitebox; // Initialize tables at startup (no key involved!) let tables = whitebox::init_tables(); // Use for encryption let mut block = [0u8; 16]; whitebox::whitebox_encrypt(&mut block, &tables); ``` -------------------------------- ### into_ok example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Shows how to use into_ok on a Result with an infallible error type to get the Ok value without panicking. ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` -------------------------------- ### and_then examples Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search= Examples for the and_then method, showing chaining fallible operations that may return Err. ```rust assert_eq!(Ok(2).and_then(sq_then_to_string), Ok(4.to_string())); assert_eq!(Ok(1_000_000).and_then(sq_then_to_string), Err("overflowed")); assert_eq!(Err("not a number").and_then(sq_then_to_string), Err("not a number")); ``` ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### RustAegis VM crate documentation and example Source: https://docs.rs/aegis_vm/latest/src/aegis_vm/lib.rs.html?search=std%3A%3Avec Crate-level documentation for RustAegis VM, a custom VM for code virtualization and protection. Includes a Rust example showing bytecode execution: 40 + 2 = 42. ```rust //! # RustAegis VM //! //! Custom Virtual Machine for code virtualization and protection. //! //! This VM converts critical Rust code to custom bytecode that is interpreted //! at runtime, making static analysis and patching extremely difficult. //! //! ## Features //! //! - **Hybrid Architecture**: Stack + Register based for flexibility //! - **60+ Opcodes**: Complete instruction set for complex logic //! - **Anti-Analysis**: Opaque predicates, timing checks, integrity verification //! - **Cross-Platform**: Works on iOS and Android //! - **OLLVM Compatible**: Uses fastrand instead of rand crate //! //! ## Example //! //! ```rust //! use aegis_vm::{execute, build_config::opcodes::{stack, arithmetic, exec}}; //! //! // Simple bytecode: 40 + 2 = 42 //! let bytecode = [ //! stack::PUSH_IMM8, 40, //! stack::PUSH_IMM8, 2, //! arithmetic::ADD, //! exec::HALT, //! ]; //! //! let result = execute(&bytecode, &[]).unwrap(); //! assert_eq!(result, 42); //! ``` ``` -------------------------------- ### Result::is_ok_and Example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Example for the is_ok_and method, which returns true if the result is Ok and the value matches a predicate. ```rust let x: Result = Ok(2); assert_eq!(x.is_ok_and(|x| x > 1), true); let x: Result = Ok(0); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Err("hey"); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Ok("ownership".to_string()); assert_eq!(x.as_ref().is_ok_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` -------------------------------- ### Result::is_ok Example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Example for the is_ok method, which returns true if the result is Ok. ```rust let x: Result = Ok(-3); assert_eq!(x.is_ok(), true); let x: Result = Err("Some error message"); assert_eq!(x.is_ok(), false); ``` -------------------------------- ### Example output in binary Source: https://docs.rs/aegis_vm/latest/aegis_vm/attr.obfuscate_strings.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows the difference between plaintext and encrypted bytes in the binary. ```rust // Before: plaintext visible "VM bytecode decryption failed" // After: only encrypted bytes visible [0x4a, 0x7f, 0x2c, 0x91, 0x3e, ...] ``` -------------------------------- ### map() example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Demonstrates using `map` to apply a function to the `Ok` value of a `Result`, leaving `Err` untouched. The example parses each line of a string and prints the doubled value. ```rust let line = "1\n2\n3\n4\n"; for num in line.lines() { match num.parse::().map(|i| i * 2) { Ok(n) => println!("{n}"), Err(..) => {} } } ``` -------------------------------- ### unwrap_or_default example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Shows how to use unwrap_or_default to get the contained value or a default when parsing fails. ```rust let good_year_from_input = "1909"; let bad_year_from_input = "190blarg"; let good_year = good_year_from_input.parse().unwrap_or_default(); let bad_year = bad_year_from_input.parse().unwrap_or_default(); assert_eq!(1909, good_year); assert_eq!(0, bad_year); ``` -------------------------------- ### as_mut() example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Shows using `as_mut()` to get mutable references to the `Ok` or `Err` values and modify them in place. ```rust fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); let mut x: Result = Err(13); mutate(&mut x); assert_eq!(x.unwrap_err(), 0); ``` -------------------------------- ### run Source: https://docs.rs/aegis_vm/latest/aegis_vm Runs the VM with the given bytecode and arguments, returning the result. ```APIDOC ## [FUNCTION] run ### Description Runs the VM with the given bytecode and arguments, returning the result. ### Signature ```rust pub fn run(bytecode: &[u8], args: &[u8]) -> VmResult ``` ### Parameters - **bytecode** (`&[u8]`) - The bytecode to execute. - **args** (`&[u8]`) - The arguments to pass to the VM. ### Returns - **VmResult** - The result of the execution, or an error. ``` -------------------------------- ### into_err example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Shows how to use into_err on a Result with an infallible Ok type to get the Err value without panicking. ```rust fn only_bad_news() -> Result { Err("Oops, it failed".into()) } let error: String = only_bad_news().into_err(); println!("{error}"); ``` -------------------------------- ### BuildInfo::new - Create new build info Source: https://docs.rs/aegis_vm/latest/src/aegis_vm/bytecode.rs.html?search= Starts the implementation of BuildInfo with a new method to create build info. The method body is not shown in the source. ```rust impl BuildInfo { /// Create new build info ``` -------------------------------- ### run Source: https://docs.rs/aegis_vm/latest/aegis_vm?search= Runs bytecode in the VM with a default state, returning the result. ```APIDOC ## run ### Description Runs bytecode in the VM with a default state, returning the result. ### Signature `pub fn run(bytecode: &[u8], args: &[u8]) -> VmResult` ### Parameters - **bytecode** (slice of u8) - Required - The bytecode to run. - **args** (slice of u8) - Required - Arguments passed to the VM. ### Returns - **VmResult** - The result of execution, or an error. ``` -------------------------------- ### new Source: https://docs.rs/aegis_vm/latest/aegis_vm/whitebox/struct.WhiteboxCryptoContext.html?search= Creates a new WBC crypto context, generating tables and deriving keys at startup. ```APIDOC ## new ### Description Creates a new WBC crypto context. Generates tables and derives keys at startup (cold path). Uses build-time pre-computed domain hashes; no domain strings exist in the binary. ### Method new ### Signature pub fn new() -> Self ### Returns - **Self** - A new WhiteboxCryptoContext instance. ``` -------------------------------- ### iter_mut: Mutate contained value via iterator Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Shows `iter_mut` to get a mutable iterator over the contained value. The example modifies the `Ok` value to 40 and asserts the result. ```rust let mut x: Result = Ok(7); match x.iter_mut().next() { Some(v) => *v = 40, None => {}, } assert_eq!(x, Ok(40)); let mut x: Result = Err("nothing!"); assert_eq!(x.iter_mut().next(), None); ``` -------------------------------- ### as_deref_mut: Mutate Ok value through DerefMut Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Shows `as_deref_mut` to get mutable references to the `Ok` value via `DerefMut`. The example mutates the string to uppercase and asserts both `Ok` and `Err` cases. ```rust let mut s = "HELLO".to_string(); let mut x: Result = Ok("hello".to_string()); let y: Result<&mut str, &mut u32> = Ok(&mut s); assert_eq!(x.as_deref_mut().map(|x| { x.make_ascii_uppercase(); x }), y); let mut i = 42; let mut x: Result = Err(42); let y: Result<&mut str, &mut u32> = Err(&mut i); assert_eq!(x.as_deref_mut().map(|x| { x.make_ascii_uppercase(); x }), y); ``` -------------------------------- ### ok() example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Demonstrates converting a `Result` to an `Option` using `ok()`, which returns `Some(value)` for `Ok` and `None` for `Err`. ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); ``` -------------------------------- ### Result::is_err Example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Example for the is_err method, which returns true if the result is Err. ```rust let x: Result = Ok(-3); assert_eq!(x.is_err(), false); let x: Result = Err("Some error message"); assert_eq!(x.is_err(), true); ``` -------------------------------- ### Result::cloned for &T Example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Example for the cloned method on Result<&T, E>, which clones the Ok value. ```rust let val = 12; let x: Result<&i32, i32> = Ok(&val); assert_eq!(x, Ok(&12)); let cloned = x.cloned(); assert_eq!(cloned, Ok(12)); ``` -------------------------------- ### init_tables_lite() Source: https://docs.rs/aegis_vm/latest/src/aegis_vm/whitebox/mod.rs.html?search=u32+-%3E+bool Initializes lightweight whitebox tables (~40KB instead of ~500KB). Less secure but smaller footprint. Note: Lite tables still use runtime key derivation for now. ```APIDOC ## init_tables_lite() ### Description Initializes lightweight whitebox tables (~40KB instead of ~500KB). Less secure but smaller footprint. Note: Lite tables still use runtime key derivation for now. ### Method Function ### Signature ```rust pub fn init_tables_lite() -> WhiteboxTablesLite ``` ### Returns - **WhiteboxTablesLite** - The lightweight whitebox tables. ``` -------------------------------- ### Result::copied for &T Example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Example for the copied method on Result<&T, E>, which copies the Ok value. ```rust let val = 12; let x: Result<&i32, i32> = Ok(&val); assert_eq!(x, Ok(&12)); let copied = x.copied(); assert_eq!(copied, Ok(12)); ``` -------------------------------- ### Box::new_uninit_in example Source: https://docs.rs/aegis_vm/latest/aegis_vm/native/type.NativeFunction.html?search=u32+-%3E+bool Constructs a new box with uninitialized contents in the provided allocator. Shows deferred initialization with `write` and `assume_init`. Requires nightly-only `allocator_api` feature. ```rust #![feature(allocator_api)] use std::alloc::System; let mut five = Box::::new_uninit_in(System); // Deferred initialization: five.write(5); let five = unsafe { five.assume_init() }; assert_eq!(*five, 5) ``` -------------------------------- ### WhiteboxCryptoContext::new: Initialize context Source: https://docs.rs/aegis_vm/latest/src/aegis_vm/whitebox/mod.rs.html?search= This snippet is the body of `WhiteboxCryptoContext::new`, which generates tables and derives keys at startup (cold path). It uses pre-computed domain hashes so no domain strings exist in the binary. ```rust use crate::build_config::whitebox_config::{ get_bytecode_domain_hash, get_smc_domain_hash }; let tables = init_tables(); // Use pre-computed domain hashes (strings don't exist in binary!) let bytecode_hash = get_bytecode_domain_hash(); let smc_hash = get_smc_domain_hash(); let bytecode_key = derive_key_from_hash_with_tables(&bytecode_hash, &tables); ``` -------------------------------- ### init_tables Source: https://docs.rs/aegis_vm/latest/aegis_vm/whitebox/fn.init_tables.html Documentation for the init_tables function in the aegis_vm whitebox module. ```APIDOC ## Function init_tables ### Description Initializes whitebox tables from build-time embedded data. The AES key is used only during compilation and does not exist at runtime, providing true white-box security. Tables are reconstructed from an entropy pool and deltas. ### Signature ```rust pub fn init_tables() -> WhiteboxTables ``` ### Parameters None. ### Returns - **WhiteboxTables** - The initialized whitebox tables used for encryption operations. ### Example ```rust use aegis_vm::whitebox; // Initialize tables at startup (no key involved!) let tables = whitebox::init_tables(); // Use for encryption let mut block = [0u8; 16]; whitebox::whitebox_encrypt(&mut block, &tables); ``` ``` -------------------------------- ### Result::cloned for &mut T Example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Example for the cloned method on Result<&mut T, E>, which clones the Ok value. ```rust let mut val = 12; let x: Result<&mut i32, i32> = Ok(&mut val); assert_eq!(x, Ok(&mut 12)); let cloned = x.cloned(); assert_eq!(cloned, Ok(12)); ``` -------------------------------- ### expect: Recommended message style for environment variable Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Shows the recommended message style for `expect`: describe the reason you expect the `Result` to be `Ok`. The example reads an environment variable and panics with a message explaining the expected condition. ```rust let path = std::env::var("IMPORTANT_PATH") .expect("env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`"); ``` -------------------------------- ### Result::copied for &mut T Example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Example for the copied method on Result<&mut T, E>, which copies the Ok value. ```rust let mut val = 12; let x: Result<&mut i32, i32> = Ok(&mut val); assert_eq!(x, Ok(&mut 12)); let copied = x.copied(); assert_eq!(copied, Ok(12)); ``` -------------------------------- ### Result::flatten Example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Examples for the flatten method on Result, E>, which removes one level of nesting. ```rust let x: Result, u32> = Ok(Ok("hello")); assert_eq!(Ok("hello"), x.flatten()); let x: Result, u32> = Ok(Err(6)); assert_eq!(Err(6), x.flatten()); let x: Result, u32> = Err(6); assert_eq!(Err(6), x.flatten()); ``` ```rust let x: Result, u32>, u32> = Ok(Ok(Ok("hello"))); assert_eq!(Ok(Ok("hello")), x.flatten()); assert_eq!(Ok("hello"), x.flatten().flatten()); ``` -------------------------------- ### Result::transpose Example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Example for the transpose method on Result, E>, which converts a Result of an Option into an Option of a Result. ```rust #[derive(Debug, Eq, PartialEq)] struct SomeErr; let x: Result, SomeErr> = Ok(Some(5)); let y: Option> = Some(Ok(5)); assert_eq!(x.transpose(), y); ``` -------------------------------- ### Box::take and Box::write example Source: https://docs.rs/aegis_vm/latest/aegis_vm/native/type.NativeFunction.html?search=u32+-%3E+bool Shows how to take a value out of a box and then reuse the same allocation for a new value using Box::take and Box::write. ```rust // take the value out of the box let (value, uninit) = Box::take(c); assert_eq!(value, 5); // reuse the box for a second value let c = Box::write(uninit, 6); assert_eq!(*c, 6); ``` -------------------------------- ### Register and call native functions with NativeRegistry Source: https://docs.rs/aegis_vm/latest/aegis_vm/native/index.html?search= Shows how to create a NativeRegistry, register native functions with IDs 0 and 1, and call them from the VM. The first function ignores arguments and returns 42; the second doubles the first argument if present, otherwise returns 0. Calls return Result values that unwrap to the expected results. ```rust use aegis_vm::native::{NativeRegistry, NativeFunction}; let mut registry = NativeRegistry::new(); // Register a simple function registry.register(0, |_args| 42); // Register a function that uses arguments registry.register(1, |args| { if args.is_empty() { return 0; } args[0] * 2 }); // Call from VM assert_eq!(registry.call(0, &[]).unwrap(), 42); assert_eq!(registry.call(1, &[21]).unwrap(), 42); ``` -------------------------------- ### Usage example with obfuscate_strings Source: https://docs.rs/aegis_vm/latest/aegis_vm/attr.obfuscate_strings.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Example of applying the obfuscate_strings attribute to a function. All string literals in the function are encrypted at compile time. ```rust use aegis_vm_macro::obfuscate_strings; #[obfuscate_strings] fn error_handler(code: u32) -> &'static str { match code { 1 => "Invalid input", // Encrypted! 2 => "Access denied", // Encrypted! _ => "Unknown error", // Encrypted! } } ``` -------------------------------- ### run Source: https://docs.rs/aegis_vm/latest/aegis_vm/engine/index.html?search=std%3A%3Avec Main execution loop without native functions. ```APIDOC ## run ### Description Main execution loop without native functions. ### Parameters - **bytecode** (unknown) - Required - The bytecode to execute. ### Returns - **result** (unknown) - The result of the execution. ``` -------------------------------- ### map_or_else() example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Demonstrates using `map_or_else` to apply a fallback function to the `Err` value or a function to the `Ok` value. The example uses a closure that multiplies the error by 2. ```rust let k = 21; let x : Result<_, &str> = Ok("foo"); assert_eq!(x.map_or_else(|e| k * 2, |v| v.len()), 3); let x : Result<&str, _> = Err("bar"); assert_eq!(x.map_or_else(|e| k * 2, |v| v.len()), 42); ``` -------------------------------- ### and_then chaining example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Shows how to chain fallible operations that may return Err using and_then. The example assumes sq_then_to_string is a function that returns Result. ```rust assert_eq!(Ok(2).and_then(sq_then_to_string), Ok(4.to_string())); assert_eq!(Ok(1_000_000).and_then(sq_then_to_string), Err("overflowed")); assert_eq!(Err("not a number").and_then(sq_then_to_string), Err("not a number")); ``` -------------------------------- ### BuildInfo::new Source: https://docs.rs/aegis_vm/latest/aegis_vm/bytecode/struct.BuildInfo.html Creates a new BuildInfo instance with the given build ID and protection level. ```APIDOC ## BuildInfo::new ### Description Creates a new BuildInfo instance with the specified build ID and protection level. ### Method `pub fn new(build_id: u64, protection_level: ProtectionLevel) -> Self` ### Parameters - **build_id** (u64) - Required - Unique build identifier (derived from HMAC) - **protection_level** (ProtectionLevel) - Required - Protection level used ### Returns - **Self** - A new BuildInfo instance ### Example ```rust let info = BuildInfo::new(12345, ProtectionLevel::High); ``` ``` -------------------------------- ### Equivalent cleanup using drop(Box::from_non_null(non_null)) Source: https://docs.rs/aegis_vm/latest/aegis_vm/native/type.NativeFunction.html?search=u32+-%3E+bool Equivalent to the manual cleanup example, but uses Box::from_non_null inside drop to let the Box destructor handle cleanup. This is a simpler alternative to explicit deallocation. ```rust let x = Box::new(String::from("Hello")); let non_null = Box::into_non_null(x); unsafe { drop(Box::from_non_null(non_null)); } ``` -------------------------------- ### run Source: https://docs.rs/aegis_vm/latest/src/aegis_vm/lib.rs.html?search=u32+-%3E+bool Runs bytecode with a given state. ```APIDOC ## [Function] run ### Description Runs a bytecode program with a given state and returns the result. ### Signature ```rust pub fn run(bytecode: &[u8], args: &[u8], state: VmState) -> VmResult ``` ### Parameters - **bytecode** (`&[u8]`) - Required - The bytecode to execute. - **args** (`&[u8]`) - Required - Arguments passed to the VM. - **state** (`VmState`) - Required - The initial VM state. ### Returns - **VmResult** - The result of the execution, or an error. ``` -------------------------------- ### is_err_and example Source: https://docs.rs/aegis_vm/latest/aegis_vm/error/type.VmResult.html?search=std%3A%3Avec Shows how to use `is_err_and` to check if a `Result` is `Err` and its value matches a predicate. The example uses `ErrorKind` comparisons and demonstrates that `as_ref()` can be used to avoid consuming the `Result`. ```rust use std::io::{Error, ErrorKind}; let x: Result = Err(Error::new(ErrorKind::NotFound, "!")); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), true); let x: Result = Err(Error::new(ErrorKind::PermissionDenied, "!")); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); let x: Result = Ok(123); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); let x: Result = Err("ownership".to_string()); assert_eq!(x.as_ref().is_err_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` -------------------------------- ### try_call_once example Source: https://docs.rs/aegis_vm/latest/aegis_vm/type.SpinOnce.html?search= Example of using try_call_once to allow the initialization closure to fail. If the closure returns an error, the Once remains uninitialized. The method blocks if another initialization is running and panics if the Once previously panicked. ```rust use spin; static INIT: spin::Once = spin::Once::new(); fn get_cached_val() -> Result { INIT.try_call_once(expensive_fallible_computation).map(|x| *x) } fn expensive_fallible_computation() -> Result { // ... } ``` -------------------------------- ### Initialize lightweight whitebox tables Source: https://docs.rs/aegis_vm/latest/src/aegis_vm/whitebox/mod.rs.html?search=u32+-%3E+bool Creates a smaller whitebox table set (~40KB instead of ~500KB) with reduced security. The lite version only uses the tbox and tbox_last tables, extracting tbox_last from round 9. Note that lite tables still use runtime key derivation for now. ```rust /// Initialize lightweight whitebox tables (~40KB instead of ~500KB) /// Less secure but smaller footprint /// /// **NOTE**: Lite tables still use runtime key derivation for now. /// For maximum security, use full `init_tables()` instead. pub fn init_tables_lite() -> WhiteboxTablesLite { use crate::build_config::whitebox_config::reconstruct_tbox; // For lite version, we only need tbox and tbox_last let full_tbox = reconstruct_tbox(); // Extract tbox_last from round 9 let mut tbox_last = [[0u8; 256]; AES_BLOCK_SIZE]; for (pos, tbox_pos) in tbox_last.iter_mut().enumerate() { tbox_pos.copy_from_slice(&full_tbox[AES_ROUNDS - 1][pos]); } WhiteboxTablesLite { tbox: full_tbox, tbox_last, } } ``` -------------------------------- ### BytecodeHeader::new Source: https://docs.rs/aegis_vm/latest/aegis_vm/bytecode/struct.BytecodeHeader.html?search= Creates a new BytecodeHeader instance with the given build ID, timestamp, and flags. ```APIDOC ## BytecodeHeader::new ### Description Creates a new BytecodeHeader instance with the specified build ID, timestamp, and flags. ### Method new ### Signature pub fn new(build_id: u64, timestamp: u64, flags: u16) -> Self ### Parameters - **build_id** (u64) - Required - Unique build identifier - **timestamp** (u64) - Required - Build timestamp (Unix epoch seconds) - **flags** (u16) - Required - Protection flags ### Returns - **Self** - A new BytecodeHeader instance ``` -------------------------------- ### w_str_get wrapper Source: https://docs.rs/aegis_vm/latest/src/aegis_vm/handlers/dispatch.rs.html Wrapper for string get handler. ```rust super::handle_str_get(s) } ``` -------------------------------- ### BuildInfo::new Source: https://docs.rs/aegis_vm/latest/aegis_vm/bytecode/struct.BuildInfo.html?search=u32+-%3E+bool Creates a new BuildInfo instance with the given build ID and protection level. This is the primary constructor for the struct. ```APIDOC ## BuildInfo::new ### Description Creates a new BuildInfo instance with the provided build ID and protection level. ### Method `pub fn new(build_id: u64, protection_level: ProtectionLevel) -> Self` ### Parameters - **build_id** (u64) - Required - Unique build identifier (derived from HMAC) - **protection_level** (ProtectionLevel) - Required - Protection level used ### Returns - **Self** - A new BuildInfo instance with the given parameters. ### Example ```rust let info = BuildInfo::new(12345, ProtectionLevel::Standard); ``` ```