37 uint8_t min_depth = 3;
39 if (max_depth < min_depth) {
40 max_depth = min_depth;
43 uint8_t depth = min_depth;
44 if (ctrl_len > 2 && max_depth > min_depth) {
45 depth = min_depth + (ctrl[2] % (max_depth - min_depth + 1));
48 size_t needed = 1 + (size_t) depth * 4;
49 if (buf_size < needed) {
60 account = ctrl[1] % ((uint32_t) cfg->
max_account + 1);
66 U4BE_ENCODE(p, 0, 0x80000000UL | purpose);
75 U4BE_ENCODE(p, 0, 0x80000000UL | account);
79 for (uint8_t i = 3; i < depth; i++) {
81 size_t ctrl_idx = 3 + (size_t) (i - 3);
82 if (ctrl_idx < ctrl_len) {
83 child = ctrl[ctrl_idx] % 2;
85 U4BE_ENCODE(p, 0, child);
89 return (
size_t) (p - buf);
static size_t fuzz_bip32_build(const fuzz_bip32_config_t *cfg, const uint8_t *ctrl, size_t ctrl_len, uint8_t *buf, size_t buf_size)