/// Cryptographic hashes, computed by the runtime over `ring` (issue #145: /// PostgreSQL's SCRAM-SHA-256 needs them), Ed25519 signatures (ADR 0067), /// and ChaCha20-Poly1305 with HKDF-SHA-256 for encryption at rest /// (ADR 0071). SHA-1 and MD5 are not offered. /// /// These are primitives over raw bytes, not a cryptography library: no key /// types, no encodings, no nonce bookkeeping. /// SHA-256 of `data` (FIPS 180-4). @extern c "tl_crypto_sha256" pub fn sha256 :: data: Bytes -> Bytes /// HMAC-SHA-256 of `message` under `key` (RFC 2104). @extern c "tl_crypto_hmac_sha256" pub fn hmac_sha256 :: key: Bytes message: Bytes -> Bytes /// PBKDF2-HMAC-SHA-256 of `password` with `salt` and `iterations` /// (at least 1), `length` bytes of output (at most 1 MiB). /// /// The iteration count is the caller's, so the derivation runs on the /// runtime's `cpu` blocking pool: a large one never stalls the scheduler. @extern c "tl_crypto_pbkdf2_sha256" (blocking cpu) pub fn pbkdf2_hmac_sha256 :: password: Bytes salt: Bytes iterations: Int length: Int -> Bytes /// Whether `signature` is the Ed25519 signature of `message` under /// `public_key` (RFC 8032). A key that is not 32 bytes or a signature /// that is not 64 is no signature: `False`. @extern c "tl_crypto_ed25519_verify" pub fn ed25519_verify :: public_key: Bytes message: Bytes signature: Bytes -> Bool /// The Ed25519 public key (32 bytes) of a 32-byte `seed`, RFC 8032's /// private key. For tests and tools: a server verifies, and its clients /// keep their seeds. Panics on a seed of another length. @extern c "tl_crypto_ed25519_public_key" pub fn ed25519_public_key :: seed: Bytes -> Bytes /// The Ed25519 signature (64 bytes) of `message` under the key pair of a /// 32-byte `seed`. For tests and tools, like `ed25519_public_key`; panics /// on a seed of another length. @extern c "tl_crypto_ed25519_sign" pub fn ed25519_sign :: seed: Bytes message: Bytes -> Bytes /// The ChaCha20-Poly1305 sealing of `plaintext` (RFC 8439): the ciphertext, /// as long as `plaintext`, then a 16-byte tag that also authenticates /// `aad`, data sent or stored in the clear alongside (an id, a version). /// /// `key` is 32 bytes and `nonce` 12; another length panics. A nonce must /// never repeat under one key: one repeat reveals the two plaintexts' /// XOR and lets the tag be forged. Random nonces (`random.bytes 12`) are /// safe for about 2^32 messages per key; derive a key per owner or per /// purpose (`hkdf_sha256`) to stay far below that. @extern c "tl_crypto_chacha20_poly1305_seal" pub fn chacha20_poly1305_seal :: key: Bytes nonce: Bytes plaintext: Bytes aad: Bytes -> Bytes /// The plaintext of `sealed` if it authenticates under `key`, `nonce` and /// `aad`, else an `Error`: a changed byte, another key, nonce or `aad`, /// and a message shorter than its tag are all the same refusal. A key /// that is not 32 bytes or a nonce that is not 12 panics, as when sealing. @extern c "tl_crypto_chacha20_poly1305_open" pub fn chacha20_poly1305_open :: key: Bytes nonce: Bytes sealed: Bytes aad: Bytes -> Result /// HKDF-SHA-256 (RFC 5869), extract then expand: `length` bytes derived /// from `secret`, with `salt` (empty means RFC 5869's zero salt) and /// `info`, which names what the bytes are for. Distinct `info`s give /// independent keys from one secret. `length` is 0 to 8160; another /// panics. @extern c "tl_crypto_hkdf_sha256" pub fn hkdf_sha256 :: secret: Bytes salt: Bytes info: Bytes length: Int -> Bytes