Skip to content

stdlib/cryptoView source ↗

crypto

16 items · generated by scribe fromstdlib/crypto.fd· synced 2026-11-15

stdlib/crypto16 items

Contents

K0:

pub const K0: i64 = 0x428a2f98; pub const K1: i64 = 0x71374491; pub const K2: i64 = 0xb5c0fbcf; pub const K3: i64 = 0xe9b5dba5; pub const K4: i64 = 0x3956c25b; pub const K5: i64 = 0x59f111f1; pub const K6: i64 = 0x923f82a4; pub const K7: i64 = 0xab1c5ed5; pub const K8: i64 = 0xd807aa98; pub const K9: i64 = 0x12835b01; pub const K10: i64 = 0x243185be; pub const K11: i64 = 0x550c7dc3; pub const K12: i64 = 0x72be5d74; pub const K13: i64 = 0x80deb1fe; pub const K14: i64 = 0x9bdc06a7; pub const K15: i64 = 0xc19bf174; pub const K16: i64 = 0xe49b69c1; pub const K17: i64 = 0xefbe4786; pub const K18: i64 = 0x0fc19dc6; pub const K19: i64 = 0x240ca1cc; pub const K20: i64 = 0x2de92c6f; pub const K21: i64 = 0x4a7484aa; pub const K22: i64 = 0x5cb0a9dc; pub const K23: i64 = 0x76f988da; pub const K24: i64 = 0x983e5152; pub const K25: i64 = 0xa831c66d; pub const K26: i64 = 0xb00327c8; pub const K27: i64 = 0xbf597fc7; pub const K28: i64 = 0xc6e00bf3; pub const K29: i64 = 0xd5a79147; pub const K30: i64 = 0x06ca6351; pub const K31: i64 = 0x14292967; pub const K32: i64 = 0x27b70a85; pub const K33: i64 = 0x2e1b2138; pub const K34: i64 = 0x4d2c6dfc; pub const K35: i64 = 0x53380d13; pub const K36: i64 = 0x650a7354; pub const K37: i64 = 0x766a0abb; pub const K38: i64 = 0x81c2c92e; pub const K39: i64 = 0x92722c85; pub const K40: i64 = 0xa2bfe8a1; pub const K41: i64 = 0xa81a664b; pub const K42: i64 = 0xc24b8b70; pub const K43: i64 = 0xc76c51a3; pub const K44: i64 = 0xd192e819; pub const K45: i64 = 0xd6990624; pub const K46: i64 = 0xf40e3585; pub const K47: i64 = 0x106aa070; pub const K48: i64 = 0x19a4c116; pub const K49: i64 = 0x1e376c08; pub const K50: i64 = 0x2748774c; pub const K51: i64 = 0x34b0bcb5; pub const K52: i64 = 0x391c0cb3; pub const K53: i64 = 0x4ed8aa4a; pub const K54: i64 = 0x5b9cca4f; pub const K55: i64 = 0x682e6ff3; pub const K56: i64 = 0x748f82ee; pub const K57: i64 = 0x78a5636f; pub const K58: i64 = 0x84c87814; pub const K59: i64 = 0x8cc70208; pub const K60: i64 = 0x90befffa; pub const K61: i64 = 0xa4506ceb; pub const K62: i64 = 0xbef9a3f7; pub const K63: i64 = 0xc67178f2;

Defined at line 30


H0_INIT:

pub const H0_INIT: i64 = 0x6a09e667; pub const H1_INIT: i64 = 0xbb67ae85; pub const H2_INIT: i64 = 0x3c6ef372; pub const H3_INIT: i64 = 0xa54ff53a; pub const H4_INIT: i64 = 0x510e527f; pub const H5_INIT: i64 = 0x9b05688c; pub const H6_INIT: i64 = 0x1f83d9ab; pub const H7_INIT: i64 = 0x5be0cd19;

Defined at line 32


crypto_sha256

Compute SHA-256 hash of a string. Returns a 32-byte Vec of hash values (each byte 0-255).

pub fn crypto_sha256(input: str) -> Vec<i64> {

Parameters:

  • input: str

Returns: Vec<i64>

Defined at line 76


crypto_sha256_bytes

Compute SHA-256 of a byte vector (each element 0-255): binary-safe. Returns a 32-byte Vec.

pub fn crypto_sha256_bytes(msg: Vec<i64>) -> Vec<i64> {

Parameters:

  • msg: Vec<i64>

Returns: Vec<i64>

Defined at line 82


crypto_sha256_hex

Convert SHA-256 hash bytes to hex string.

pub fn crypto_sha256_hex(hash: Vec<i64>) -> str {

Parameters:

  • hash: Vec<i64>

Returns: str

Defined at line 404


crypto_sha256_hex_str

Compute SHA-256 and return as hex string.

pub fn crypto_sha256_hex_str(input: str) -> str {

Parameters:

  • input: str

Returns: str

Defined at line 418


NonceTracker

A nonce tracker — keeps track of used nonces to prevent reuse.

pub struct NonceTracker {

Fields:

NameType
usedVec<i64>
nexti64

Defined at line 432


crypto_nonce_tracker_new

Create a new nonce tracker.

pub fn crypto_nonce_tracker_new() -> NonceTracker {

Returns: NonceTracker

Defined at line 438


crypto_nonce_next

Generate and track a nonce. Returns the next sequential nonce.

pub fn crypto_nonce_next(tracker: & mut NonceTracker) -> i64 {

Parameters:

  • tracker: & mut NonceTracker

Returns: i64

Defined at line 445


crypto_nonce_is_used

Check if a nonce has been used.

pub fn crypto_nonce_is_used(tracker: & NonceTracker, nonce: i64) -> bool {

Parameters:

  • tracker: & NonceTracker
  • nonce: i64

Returns: bool

Defined at line 453


crypto_nonce_register

Register a specific nonce value as used. Returns false if already used.

pub fn crypto_nonce_register(tracker: & mut NonceTracker, nonce: i64) -> bool {

Parameters:

  • tracker: & mut NonceTracker
  • nonce: i64

Returns: bool

Defined at line 463


crypto_nonce_reset

Reset nonce tracking (for testing only).

pub fn crypto_nonce_reset(tracker: & mut NonceTracker) -> void {

Parameters:

  • tracker: & mut NonceTracker

Returns: void

Defined at line 475


crypto_constant_time_eq

Compare two byte arrays in constant time (prevents timing attacks). Returns true if equal, false otherwise. Always processes all bytes.

pub fn crypto_constant_time_eq(a: Vec<i64>, b: Vec<i64>) -> bool {

Parameters:

  • a: Vec<i64>
  • b: Vec<i64>

Returns: bool

Defined at line 543


CRYPTO_APPROVED_ALGORITHMS:

pub const CRYPTO_APPROVED_ALGORITHMS: str = "SHA-256, HMAC-SHA256"; pub const CRYPTO_REJECTED_ALGORITHMS: str = "MD5, SHA-1, custom";

Defined at line 575


crypto_random_u64

64 random bits.

pub fn crypto_random_u64() -> i64 {

Returns: i64

Defined at line 582


crypto_random_bytes

n random bytes, each 0..255.

pub fn crypto_random_bytes(n: i64) -> Vec<i64> {

Parameters:

  • n: i64

Returns: Vec<i64>

Defined at line 587


Generated by scribe, the Fides documentation generator