docs/generated/contracts.mdgenerated from code

Reference · 3 min read

secret-entropy

Contracts: secret-entropy.

Source: crates/lvcs/src/secrets/entropy.rs.

ruston main
1/// The rule a hit of the heuristic names in `SecretHit::rule`.2const ENTROPY_RULE: &str = "entropy";34/// Fewest code points of a candidate: a maximal run of ASCII letters,5/// digits, `+`, `/`, `_`, and `-` that holds an uppercase letter, a6/// lowercase letter, and a digit.7const ENTROPY_MIN_LEN: usize = 24;89/// Least share of adjacent pairs of the candidate's letters and digits10/// (its other code points skipped) that switch between uppercase,11/// lowercase, and digit.12const ENTROPY_MIN_SWITCHES: f64 = 0.35;1314/// Least Shannon entropy of a candidate of [`ENTROPY_MIN_LEN`] code15/// points, in bits per code point. The floor rises with the candidate's16/// length, since a longer random string reaches a higher entropy.17const ENTROPY_FLOOR_MIN: f64 = 3.9;1819/// How much the entropy floor rises per code point past20/// [`ENTROPY_MIN_LEN`].21const ENTROPY_FLOOR_STEP: f64 = 0.0375;2223/// The highest the entropy floor rises, reached at 40 code points.24const ENTROPY_FLOOR_MAX: f64 = 4.5;2526/// Fewest lowercase letters in a row that make a word, together with the27/// uppercase letter right before them (`Address` in `Ipv4AddressToString`).28const WORD_MIN_LOWER: usize = 3;2930/// Most share of a candidate's letters that may sit in words: an31/// identifier (`NewSessionTicketPayloadTls13`) or a path is mostly words,32/// and a random string seldom is.33const ENTROPY_MAX_WORD_SHARE: f64 = 0.6;3435/// Labels a digest starts with, so a candidate starting with one is not a36/// secret: `sha512-` in npm lockfiles and HTML `integrity` attributes.37const DIGEST_PREFIXES: &[&str] = &["sha1-", "sha256-", "sha384-", "sha512-"];3839/// Labels public data comes right after, so a candidate following one is40/// not a secret: `h1:` in Go's `go.sum`, a data URI's `;base64,`, and the41/// key types of SSH public keys.42const PUBLIC_LEADS: &[&str] = &[43    "h1:",44    ";base64,",45    "ssh-rsa ",46    "ssh-dss ",47    "ssh-ed25519 ",48    "ecdsa-sha2-nistp256 ",49    "ecdsa-sha2-nistp384 ",50    "ecdsa-sha2-nistp521 ",51    "sk-ssh-ed25519@openssh.com ",52    "sk-ecdsa-sha2-nistp256@openssh.com ",53    "a=ice-ufrag:",54    "a=ice-pwd:",55];5657/// Labels inside a candidate that the segment after them, up to the next58/// `/`, is public data behind: a libp2p multiaddr's `/certhash/`, the59/// multibase hash of the node's TLS certificate.60const PUBLIC_SEGMENT_LEADS: &[&str] = &["/certhash/"];6162/// Public ids of a fixed shape, each its prefix and its length in code63/// points, all base58: node ids (Ed25519 `12D3KooW…`, secp256k164/// `16Uiu2HA…`) and CIDv0 content ids (`Qm…`). Inside a candidate, a run65/// of exactly that shape that no other letter or digit touches is left66/// out.67const PUBLIC_IDS: &[(&str, usize)] = &[("12D3KooW", 52), ("16Uiu2HA", 53), ("Qm", 46)];6869/// Labels a public key's fingerprint comes right after, each with the70/// fingerprint's length in code points, so a candidate of exactly that71/// length following one is not a secret: OpenSSH prints a key's SHA-25672/// fingerprint as `SHA256:` and 43 base64 code points, in `ssh`'s host key73/// warnings and `ssh-keygen -l` (mixed-version/5: one in a failed run's74/// log had the log refused).75const PUBLIC_FINGERPRINT_LEADS: &[(&str, usize)] = &[("SHA256:", 43)];