|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Go to the source code of this file.
Functions | |
| void | kdf_do_clear (kdf_do_t *out) |
| OpenPGP KDF Data Object (tag F9) byte codec (see kdf.h). | |
| static bool | valid_hash (uint8_t h) |
| Accepts the hash identifiers the codec understands. | |
| 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. | |
| 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 (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. | |
| 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 expect when KDF is opt-in and not yet enabled. Useful as the default GET DATA response for tag F9. | |
|
static |
Emits a single 1-byte-length inner TLV; returns false on overflow.
Definition at line 18 of file kdf.cpp.
Referenced by kdf_do_build().
| 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.
Only fields whose has_* flag is true are emitted. Algorithm and hash bytes are always present (they describe whether the DO is active at all).
Definition at line 93 of file kdf.cpp.
References kdf_do_t::algo, emit_tlv(), kdf_do_t::has_pw1_initial, kdf_do_t::has_pw1_salt, kdf_do_t::has_pw3_initial, kdf_do_t::has_pw3_salt, kdf_do_t::has_rc_salt, kdf_do_t::hash, kdf_do_t::iter_count, KDF_ALGO_PBKDF2, KDF_ERR_BUF_TOO_SMALL, KDF_ERR_NULL, KDF_OK, KDF_SALT_LEN, kdf_do_t::pw1_initial, kdf_do_t::pw1_initial_len, kdf_do_t::pw1_salt, kdf_do_t::pw3_initial, kdf_do_t::pw3_initial_len, kdf_do_t::pw3_salt, and kdf_do_t::rc_salt.
| 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 expect when KDF is opt-in and not yet enabled. Useful as the default GET DATA response for tag F9.
| out | Output buffer (≥ 3 bytes). |
| out_cap | Buffer capacity. |
| out_len | Receives the number of bytes written. |
Definition at line 126 of file kdf.cpp.
References KDF_ALGO_NONE, KDF_ERR_BUF_TOO_SMALL, KDF_ERR_NULL, and KDF_OK.
Referenced by cmd_get_data().
| void kdf_do_clear | ( | kdf_do_t * | out | ) |
OpenPGP KDF Data Object (tag F9) byte codec (see kdf.h).
Zeroes out the structure.
Definition at line 8 of file kdf.cpp.
Referenced by kdf_do_parse().
| 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.
Recognises the inner TLVs above; unknown inner tags cause KDF_ERR_BAD_TAG so we never silently accept malformed input from the host. A short DO with KDF_ALGO_NONE in the algorithm byte and no further tags is accepted as "KDF disabled".
Definition at line 28 of file kdf.cpp.
References kdf_do_t::algo, kdf_do_t::has_pw1_initial, kdf_do_t::has_pw1_salt, kdf_do_t::has_pw3_initial, kdf_do_t::has_pw3_salt, kdf_do_t::has_rc_salt, kdf_do_t::hash, kdf_do_t::iter_count, KDF_ALGO_NONE, KDF_ALGO_PBKDF2, kdf_do_clear(), KDF_ERR_BAD_ALGO, KDF_ERR_BAD_HASH, KDF_ERR_BAD_HASH_LEN, KDF_ERR_BAD_LENGTH, KDF_ERR_BAD_TAG, KDF_ERR_NULL, KDF_OK, KDF_SALT_LEN, kdf_do_t::pw1_initial, kdf_do_t::pw1_initial_len, kdf_do_t::pw1_salt, kdf_do_t::pw3_initial, kdf_do_t::pw3_initial_len, kdf_do_t::pw3_salt, kdf_do_t::rc_salt, and valid_hash().
Referenced by apply_kdf_do().
|
static |
Accepts the hash identifiers the codec understands.
Definition at line 13 of file kdf.cpp.
References KDF_HASH_NONE, KDF_HASH_SHA256, and KDF_HASH_SHA512.
Referenced by kdf_do_parse().