openagent-crypto-wasm · ct
Declared module signatures, types, configuration, and source documentation.
Source: openagent-sdk/crates/openagent-crypto-wasm/src/ct.rs. SHA-256: f322224a71a82f8f9092f36c0e26fd7a73322f9083bec9f3aece14b0ba508d51.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
ct::ct_eq
Returns true iff a and b have the same length and identical contents.
Comparison is constant time with respect to slice length: the entire
a slice is consumed before returning. Use this for comparing secrets,
MAC tags, and any byte sequence whose contents must not leak via timing.
Examples
use openagent_crypto_wasm::ct::ct_eq;
assert!(ct_eq(b"abc", b"abc"));
assert!(!ct_eq(b"abc", b"abd"));
assert!(!ct_eq(b"abc", b"abcd"));pub fn ct_eq(a: &[u8], b: &[u8]) -> bool;Source line: 28.
ct::fill_random
Fills out with cryptographically secure random bytes.
On native targets this calls getrandom::getrandom which delegates to the
OS CSPRNG (/dev/urandom, getrandom(2), BCryptGenRandom, etc.). On
WebAssembly with the wasm feature enabled, the same call routes through
the JS host's crypto.getRandomValues.
Errors
[CryptoError::RngFailed] if the underlying CSPRNG returns an error
(extremely rare; usually only on misconfigured WASI environments).
pub fn fill_random(out: &mut [u8]) -> Result<(), CryptoError>;Source line: 46.
ct::random_bytes
Returns n cryptographically secure random bytes.
pub fn random_bytes(n: usize) -> Result<Vec<u8>, CryptoError>;Source line: 53.