Sign in

    justinwongcn/moonpgp/s2k does not have a README file

    S2k

    String-to-Key derivations (RFC 9580 §3.7). PGP-wire material, never a replaceable third-party concern.

    S2k::derive_key

    fn S2k::derive_key(self : S2k, passphrase : BytesView, key_len : Int) -> Bytes raise

    Derive a key of key_len bytes from passphrase under this specifier, capped at the implementation's 2 GiB Argon2 ceiling (@primitives.ARGON2_MAX_MEMORY_KIB). Use derive_key_capped when parsing untrusted specifiers and a tighter policy is wanted.

    S2k::derive_key_capped

    fn S2k::derive_key_capped(self : S2k, passphrase : BytesView, key_len : Int, max_memory_kib : Int) -> Bytes raise

    Derive a key of key_len bytes from passphrase under this specifier, enforcing max_memory_kib as an upper bound on the Argon2 memory cost. A 20-octet specifier can ask for 2^31 KiB, so callers that parse untrusted packets should pass a policy limit rather than rely on the 2 GiB implementation ceiling that derive_key uses.

    S2k::encode

    fn S2k::encode(self : S2k) -> Bytes raise

    Encode this specifier to its wire form.

    S2k::equal

    fn S2k::equal(S2k, S2k) -> Bool

    S2k::is_argon2

    fn S2k::is_argon2(self : S2k) -> Bool

    True for the Argon2 (type 4) specifier. RFC 9580 §3.7.2.1 permits it in a Secret Key packet only with S2K usage octet 253 (AEAD).

    S2k::not_equal

    fn S2k::not_equal(x : S2k, y : S2k) -> Bool

    S2k::to_repr

    ARGON2_SALT_SIZE

    let ARGON2_SALT_SIZE : Int

    Salt length in octets for Argon2 S2K (RFC 9580 §3.7.1.4).

    SALT_SIZE

    let SALT_SIZE : Int

    Salt length in octets for salted/iterated S2K.

    decode_count

    fn decode_count(count_byte : Int) -> Int

    Decode an encoded count byte into the actual octet count (RFC 9580 §3.7.1.3).

    encode_count

    fn encode_count(target : Int) -> Int

    Pick the count byte that yields the smallest count >= target (as GnuPG does). When no byte can reach the target, the largest count (255) is returned: falling back to 0 would silently select the minimum work factor instead of the maximum.

    parse

    fn parse(view : BytesView) -> (S2k, Int) raise

    Parse an S2K specifier from the front of view. Returns the specifier and the number of bytes consumed.

    Source Files