byte-array-ops 0.3.5

A no_std-compatible library for security-by-default byte array operations. Includes automatic memory zeroization, constant-time utilities, multiple input formats (hex, binary, UTF-8), bitwise operations, and comprehensive type conversions with minimal dependencies.
Documentation
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.5] - 2025-12-18

### Added
- Exposed `zeroize::Zeroize` from the `zeroize` crate for clients in order to help with cleanup of any non-`ByteArray` data
- Added unsafe functions `as_mut_ptr` and `as_ptr` for raw pointer dereferencing. These functions are explicitly marked `unsafe`

## [0.3.4] - 2025-12-17

### Added
- Added `Ranges` syntax to `ByteArray`
- Added documentation examples for all new features since `v0.3.1`
- Added `deny.toml` for cargo deny checks

### Changed
- Updated CI/CD pipeline to use `cargo-audit` and `cargo-deny`


## [0.3.3] - 2025-12-17

### Added
- Added `bytes!` constructor macro which acts similar to `vec![element; count]`
- Thread-safety tests for `ByteArray` through static assertions for `Send+Sync+Unpin+Sized`

### Deprecated
- Marked `fill_zeros` for deprecation and is to be renamed to `with_zeros` in the future
- Marked `fill_with` for deprecation and is to be renamed to `with_value` in the future

## [0.3.2] - 2025-12-17

### Added
- Added secure `truncate` functionality with zeroize upon truncation

## [0.3.1] - 2025-12-16

### Fixed
- Fixed documentation remnants from previous version

## [0.3.0] - 2025-12-16

### Added
- Added Automatic memory zeroization on drop via `Drop` trait implementation
- Added Zeroization behavior notes in documentation examples

### Security
- `zeroize` is now a required dependency (security-by-default)

### Changed
- **BREAKING**: Removed all `sec_harden_*` feature flags
- **BREAKING**: Bitwise operations now always compiled (removed `ops_algebra` feature)
- Updated Cargo.toml description for security-by-default
- Restructured MILESTONES for incremental feature delivery
- Cleaned up Documentation (removed hardened/insecure mode references)

### Removed
- Removed Crate split plan references

### Fixed
- Fixed XOR encryption example security warning added

---

## [0.2.1] - 2025-12-15 - YANKED

### Added
- Added comprehensive documentation for macros (`try_bytes!`, `try_hex!`, `try_bin!`) with usage caveats
- Added unit tests for `truncate` method in insecure operations module
- Added comprehensive `Deref` tests for insecure operations (`get()`, `first()`, `last()`, slice methods)
- Added `docs/hardening.md` - comprehensive security hardening guide
- Added security hardening section to README.md

### Fixed
- Fixed minor missing checklist flag in milestones under the [Readme]./README.md
- Fixed Display format string in hardened mode (`write!(f, "ByteArray length: {}", self.len())`)
- Fixed all doc tests in `docs/hardening.md` to be compilable with proper imports and variable definitions
- Fixed all rustdoc warnings (unresolved links and unclosed HTML tags)
  - Removed links to hardened module when features not enabled (made plain text)
  - Removed links to deleted types (`UninitByteArray`, `ByteArrayOddWordPad`)
  - Fixed method references (`ByteArray::iter()`, `ByteArray::get()`) to account for mode availability
  - Escaped all `Vec<u8>` references with backticks to prevent HTML tag warnings

### Changed
- **BREAKING**: refactored module name from `byte_array` to `core`
- Removed security hardening features from main Features table in README.md (moved to separate crate documentation)
- Updated Security Hardening section in README.md with detailed explanation of crate split rationale and migration path
- **BREAKING**: refactored trust module to folder-based structure:
  - `trust::hardened_ops``trust::hardened/` (submodules: `vec`, `iter`, `display`)
  - `trust::insecure_ops``trust::insecure/` (submodules: `vec`, `display`)
- Moved `len()`, `is_empty()`, `get()` implementations from `model.rs` to `trust/hardened/vec.rs`
- Moved iterator methods (`iter()`, `iter_mut()`) from `core/iter.rs` to `trust/hardened/iter.rs`
- Iterator type definitions (`ByteArrayIter`, `ByteArrayIterMut`) remain in `core/iter.rs` for shared access
- Added `truncate()` with `unimplemented!()` to hardened mode (blocked due to reallocation/data remnance concerns)
- In insecure mode, Vec methods (`len()`, `is_empty()`, `get()`, `iter()`, etc.) now accessed exclusively through `Deref` trait
- Moved unit tests to their respective modules (hardened vs insecure submodules)
- Removed emojis from README.md (replaced with text equivalents and markdown checkboxes)
- Added macro examples (`try_hex!`, `try_bin!`) to README.md Basic Example section

---

## [0.2.0] - 2025-12-03

### Added
- Added `try_bytes!` macro helper for `ByteArray` construction (note: silently converts to UTF-8 without format prefix - see macro docs)
- Added `try_bin!` macro helper for `ByteArray` construction (always binary, no UTF-8 fallback)
- Added `try_hex!` macro helper for `ByteArray` construction (always hex, no UTF-8 fallback)
- Added `truncate` method in insecure operations

### Changed
- **BREAKING** Changed `with_hex(self, hex_str)` instance method to static `from_hex(hex_str)` constructor
- **BREAKING** Changed `with_bin(self, bin_str)` instance method to static `from_bin(bin_str)` constructor

### Removed
- **BREAKING** Removed `UninitByteArray` struct - simplified API with always left-padding by default
- **BREAKING** Removed `ByteArrayOddWordPad` enum - no longer need to specify padding direction
- **BREAKING** Removed `new_uninit()` constructor - use `new()` for simple construction instead

### Fixed
- Byte handling for multibyte utf-8 like emojis

---

## [0.1.2] - 2025-12-03

### Added
- Added `AsRef<[u8]>` and `AsMut<[u8]>` implementations for `ByteArray`
- Added `PartialEq,Eq` derives for `ByteArrayError`


---

## [0.1.1] - 2025-11-25

### Added
- Added optimized build target
 
### Fixed
- Fixed docs.rs documentation not building properly

---

## [0.1.0] - 2025-11-28

### Added

- Added `ByteArray` struct as wrapper over `Vec<u8>` in `byte_array::model` module
- Added `ByteArrayOddWordPad` enum to control left/right padding for odd-length inputs
- Added `UninitByteArray` builder struct for advanced padding control
- Defined module structure: `model`, `ops`, `type_conv`, and `errors`
- Added `with_hex()` method for parsing hexadecimal strings with efficient nibble conversion
- Added `with_bin()` method for parsing binary strings with direct bit manipulation
- Implemented `FromStr` trait supporting `0x` (hex), `0b` (binary), and UTF-8 fallback (no prefix)
- Added length guard for handling short input strings (< 2 characters)
- Implemented left-padding by default for odd-length hex/binary inputs
- Implemented `From<&[u8]>` for `ByteArray` in `type_conv` module
- Implemented `From<&[u8; N]>` for `ByteArray` in `type_conv` module
- Implemented `From<Vec<u8>>` for `ByteArray` (zero-cost move) in `type_conv` module
- Implemented `From<u8>` for `ByteArray` in `type_conv` module
- Implemented `From<ByteArray>` for `Vec<u8>` (zero-cost extraction) in `type_conv` module
- Implemented `Index<usize>` trait for array-style access with `[]` operator
- Added `get()` method for bounds-checked element access returning `Option<&u8>`
- Added `as_bytes()` method to borrow internal byte slice
- Added `len()` method to get byte count
- Added `is_empty()` method to check for empty arrays
- Added `get_padding()` method to query current padding direction
- Added `with_capacity()` constructor for efficient pre-allocation
- Added `Internal` helper struct in `ops` module with `hex_char_to_nibble_unchecked()` for performance
- Implemented direct byte arithmetic for conversions (avoiding `to_digit()` overhead)
- Added unit test for hexadecimal string parsing with odd-length input
- Added `experimental` Cargo feature for untested proof-of-concept functions
- Added `PartialEq,Eq` derives for `ByteArray` in order to support equality operations
- Added unit test for single byte type conversion
- Added unit test for equality operations
- Added `init_zeros()` method to `ByteArray` and corresponding unit test
- Implemented `IndexMut` for `ByteArray` and added corresponding tests
- Added `ǹew_uninit()` constructor for `ByteArray` returning `UninitByteArray` needed when preparing the bytearray with padding and configuration options
- Added `fill_zeros()` method for `ByteArray` filling the array to capacity with zeros
- Added `fill_with(value)` method for `ByteArray` filling the array to capacity with a specified value
- Added `init_value(value, count)` constructor for `ByteArray` initializing the array with the specified value and count
- Added `try_push(value)` method for `ByteArray` allowing to push a u8 value (experimental feature)
- Added `hardened` Cargo feature flag for future security hardening (memory locking, secure wiping)
- Implemented `BitXor` trait for XOR operations (`^` operator)
- Implemented `BitXorAssign` trait for in-place XOR operations (`^=` operator)
- Implemented `BitAnd` trait for AND operations (`&` operator)
- Implemented `BitAndAssign` trait for in-place AND operations (`&=` operator)
- Implemented `BitOr` trait for OR operations (`|` operator)
- Implemented `BitOrAssign` trait for in-place OR operations (`|=` operator)
- Implemented `Not` trait for bitwise NOT operations (`!` operator)
- Implemented `From<[u8; N]>` for `ByteArray` to support array literal conversions
- Added `ByteArrayIter<'a>` and `ByteArrayIterMut<'a>` iterator structs in `byte_array::iter` module
- Implemented `Iterator` trait for both `ByteArrayIter` (yielding `&u8`) and `ByteArrayIterMut` (yielding `&mut u8`)
- Implemented `ExactSizeIterator` trait for both iterator types enabling `.len()` method and size optimizations
- Added `.iter()` and `.iter_mut()` methods to `ByteArray` for creating iterators
- Implemented `IntoIterator` for `&ByteArray` and `&mut ByteArray` enabling `for` loop syntax
- Added unit tests for `type_conv` module covering all type conversions and FromStr parsing
- Added comprehensive unit tests for `ops` module covering all bitwise operations (XOR, AND, OR, NOT) and their assignment variants
- Implemented `Debug` and `Display` traits for `ByteArray` both for the hardened and insecure features
- Added documentation, license and Readme