| Crates.io | byte-array-ops |
| lib.rs | byte-array-ops |
| version | 0.4.0 |
| created_at | 2025-11-28 19:43:55.191362+00 |
| updated_at | 2026-01-07 16:44:28.014723+00 |
| description | 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. |
| homepage | https://gitlab.com/jurassicLizard/byte-array-ops |
| repository | https://gitlab.com/jurassicLizard/byte-array-ops |
| max_upload_size | |
| id | 1955933 |
| size | 120,069 |
Notice Minimal functional milestones have been reached. No further features planned due to lack of priority. Security patches will be provided when needed for all versions
A no_std-compatible Rust library for secure-by-default byte array operations.
Design Philosophy:
experimental flag (disabled by default).Security Features (Always Enabled):
zeroize) - Automatic cleanup on dropsubtle) - Timing attack resistance for equality and bitwise operationsNote on Feature Selection:
[dependencies]
byte-array-ops = "0.4"
See the API documentation for comprehensive examples including:
try_bytes!, try_hex!, try_bin!)CAVEAT: The try_bytes! macro silently converts to UTF-8 when no format prefix (0x, 0b, 0o) is provided. Use try_hex! or try_bin! for guaranteed hex/binary parsing without format detection.
use byte_array_ops::ByteArray;
use byte_array_ops::errors::ByteArrayError;
use byte_array_ops::{try_hex, try_bin};
fn main() -> Result<(),ByteArrayError> {
// From hex string (using parse)
let from_hex: ByteArray = "0xdeadbeef".parse()?;
assert_eq!(from_hex.as_bytes(), [0xde, 0xad, 0xbe, 0xef]);
// Using macros for convenience
let with_macro = try_hex!("cafe")?;
assert_eq!(with_macro.as_bytes(), [0xca, 0xfe]);
let binary = try_bin!("11110000")?;
assert_eq!(binary.as_bytes(), [0xf0]);
// From UTF-8 string (no prefix)
let from_utf8: ByteArray = "hello".parse()?;
assert_eq!(from_utf8.as_bytes(), b"hello");
// Bitwise operations
let a: ByteArray = "0xff00".parse()?;
let b: ByteArray = "0x0ff0".parse()?;
let result = a ^ b; // XOR
assert_eq!(result.as_bytes(), [0xf0, 0xf0]);
// Range indexing
let slice = &from_hex[1..3]; // bytes 1-2: [0xad, 0xbe]
let tail = &from_hex[2..]; // from index 2 to end
Ok(())
}
no_std SupportThis library is no_std compatible and requires only the alloc crate. Perfect for:
std is unavailableMaintenance Mode: This project has reached its minimal functional milestones and is now in maintenance mode. Security patches will be provided as needed. No new features are planned.
Core functionality with production-ready type conversions and bitwise operations:
API refinement and macro ergonomics:
SecureReallocationProvider trait, which will encompass more secure implementations of vector methods that may require allocationByteArray constructionSecurity-by-default architecture:
Constant-time operations:
PartialEq, Eq)XOR, AND, OR)### v0.5.0 (Planned - Possible Breaking Changes) Deprioritized due to maintenance-mode
Memory locking:
### v0.6.0 (Planned - Possible Breaking Changes) Deprioritized due to maintenance-mode
Performance optimization for high-throughput scenarios:
### v1.0.0 (Future) Deprioritized due to maintenance-mode
Stable API with long-term compatibility guarantees:
This library is designed with security-by-default:
Always Enabled:
zeroize) - Sensitive data is automatically cleared on dropsubtle) - Timing attack resistance for equality checks and bitwise operations (XOR, AND, OR)try_extend) actively detect unsafe memory operations by tracking buffer addresses. If an unexpected reallocation occurs that could leave sensitive data remnants in the old memory location, these operations fail with a security error rather than silently leaking data.Why Security-by-Default?
Most byte array operations in Rust involve cryptographic material (keys, IVs, authentication tokens, passwords). Making security opt-in creates a dangerous default where developers must remember to enable protections. Instead, we make the secure choice the easy choice.
What About Performance?
Security features add minimal overhead:
For the vast majority of use cases, this overhead is negligible compared to the security guarantees provided.
Best Practices:
Vec<u8> may be more appropriateLimitations:
Licensed under the Apache License, Version 2.0. See LICENSE for details.