9 if (out) memset(out, 0,
sizeof(*out));
18static bool emit_tlv(uint8_t* out,
size_t cap,
size_t* pos, uint8_t tag,
19 const uint8_t* v, uint8_t l) {
20 if (*pos + 2u + l > cap)
return false;
23 memcpy(out + *pos, v, l);
35 const uint8_t tag = bytes[pos++];
36 const uint8_t l = bytes[pos++];
38 const uint8_t* v = bytes + pos;
54 out->
iter_count = (
static_cast<uint32_t
>(v[0]) << 24) |
55 (
static_cast<uint32_t
>(v[1]) << 16) |
56 (
static_cast<uint32_t
>(v[2]) << 8) |
57 static_cast<uint32_t
>(v[3]);
96 const uint8_t algo =
static_cast<uint8_t
>(kdf->
algo);
97 const uint8_t hash =
static_cast<uint8_t
>(kdf->
hash);
102 const uint8_t it[4] = {
103 static_cast<uint8_t
>((kdf->
iter_count >> 24) & 0xFF),
104 static_cast<uint8_t
>((kdf->
iter_count >> 16) & 0xFF),
105 static_cast<uint8_t
>((kdf->
iter_count >> 8) & 0xFF),
static bool valid_hash(uint8_t h)
Accepts the hash identifiers the codec understands.
kdf_status_t kdf_do_parse(const uint8_t *bytes, size_t len, kdf_do_t *out)
Parse a KDF-DO byte sequence into structured form.
kdf_status_t kdf_do_build_disabled(uint8_t *out, size_t out_cap, size_t *out_len)
Convenience helper: produce the "KDF disabled" KDF-DO body — three bytes (81 01 00) — that hosts expe...
kdf_status_t kdf_do_build(const kdf_do_t *kdf, uint8_t *out, size_t out_cap, size_t *out_len)
Serialise a kdf_do_t into the wire byte sequence.
void kdf_do_clear(kdf_do_t *out)
OpenPGP KDF Data Object (tag F9) byte codec (see kdf.h).
static bool emit_tlv(uint8_t *out, size_t cap, size_t *pos, uint8_t tag, const uint8_t *v, uint8_t l)
Emits a single 1-byte-length inner TLV; returns false on overflow.
#define KDF_SALT_LEN
OpenPGP KDF Data Object (tag F9) byte codec.
kdf_hash_t
Hash algorithms accepted inside KDF-DO (inner tag 0x82).
kdf_algo_t
KDF algorithm identifiers (DO 0xF9 inner tag 0x81).
kdf_status_t
KDF-DO codec error codes.