unify ur types
This commit is contained in:
parent
e808bf5222
commit
df5fd43c6b
|
@ -8,8 +8,7 @@
|
|||
#include "storage/keys.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ur/ur.h"
|
||||
#include "ur/auth_types.h"
|
||||
#include "ur/auth_encode.h"
|
||||
#include "ur/ur_encode.h"
|
||||
|
||||
#define AUTH_CHALLENGE_LEN 32
|
||||
#define AUTH_SIG_LEN 64
|
||||
|
@ -24,11 +23,11 @@ void device_auth_run() {
|
|||
|
||||
if ((auth.dev_auth_step.dev_auth_step_type_choice != dev_auth_step_type_dev_auth_init_m_c) ||
|
||||
!auth.dev_auth_challenge_present ||
|
||||
auth.dev_auth_device_id_present ||
|
||||
auth.dev_auth_dev_id_present ||
|
||||
auth.dev_auth_first_auth_present ||
|
||||
auth.dev_auth_auth_time_present ||
|
||||
auth.dev_auth_auth_count_present ||
|
||||
auth.dev_auth_signature_present) {
|
||||
auth.dev_auth_auth_sig_present) {
|
||||
ui_info(LSTR(DEV_AUTH_INVALID_CHALLENGE), 1);
|
||||
return;
|
||||
}
|
||||
|
@ -53,14 +52,14 @@ void device_auth_run() {
|
|||
// Response
|
||||
random_buffer((uint8_t*) auth.dev_auth_challenge.dev_auth_challenge.value, AUTH_CHALLENGE_LEN);
|
||||
|
||||
auth.dev_auth_device_id_present = 1;
|
||||
auth.dev_auth_device_id.dev_auth_device_id.value = uid;
|
||||
auth.dev_auth_device_id.dev_auth_device_id.len = HAL_DEVICE_UID_LEN;
|
||||
auth.dev_auth_dev_id_present = 1;
|
||||
auth.dev_auth_dev_id.dev_auth_dev_id.value = uid;
|
||||
auth.dev_auth_dev_id.dev_auth_dev_id.len = HAL_DEVICE_UID_LEN;
|
||||
|
||||
auth.dev_auth_step.dev_auth_step_type_choice = dev_auth_step_type_dev_auth_device_m_c;
|
||||
auth.dev_auth_signature_present = 1;
|
||||
auth.dev_auth_signature.dev_auth_signature.value = g_core.data.sig.plain_sig;
|
||||
auth.dev_auth_signature.dev_auth_signature.len = AUTH_SIG_LEN;
|
||||
auth.dev_auth_auth_sig_present = 1;
|
||||
auth.dev_auth_auth_sig.dev_auth_auth_sig.value = g_core.data.sig.plain_sig;
|
||||
auth.dev_auth_auth_sig.dev_auth_auth_sig.len = AUTH_SIG_LEN;
|
||||
|
||||
cbor_encode_dev_auth(g_core.data.sig.cbor_sig, CBOR_SIG_MAX_LEN, &auth, &g_core.data.sig.cbor_len);
|
||||
|
||||
|
@ -77,11 +76,11 @@ void device_auth_run() {
|
|||
|
||||
if ((auth.dev_auth_step.dev_auth_step_type_choice != dev_auth_step_type_dev_auth_server_m_c) ||
|
||||
auth.dev_auth_challenge_present ||
|
||||
auth.dev_auth_device_id_present ||
|
||||
auth.dev_auth_dev_id_present ||
|
||||
!auth.dev_auth_first_auth_present ||
|
||||
!auth.dev_auth_auth_time_present ||
|
||||
!auth.dev_auth_auth_count_present ||
|
||||
!auth.dev_auth_signature_present
|
||||
!auth.dev_auth_auth_sig_present
|
||||
) {
|
||||
ui_info(LSTR(DEV_AUTH_INVALID_CHALLENGE), 1);
|
||||
return;
|
||||
|
@ -94,7 +93,7 @@ void device_auth_run() {
|
|||
|
||||
const uint8_t* key;
|
||||
key_read_public(DEV_AUTH_SERVER_KEY, &key);
|
||||
if (!ecdsa_verify(&secp256k1, key, auth.dev_auth_signature.dev_auth_signature.value, digest)) {
|
||||
if (!ecdsa_verify(&secp256k1, key, auth.dev_auth_auth_sig.dev_auth_auth_sig.value, digest)) {
|
||||
ui_device_auth(auth.dev_auth_first_auth.dev_auth_first_auth, auth.dev_auth_auth_time.dev_auth_auth_time, auth.dev_auth_auth_count.dev_auth_auth_count);
|
||||
} else {
|
||||
ui_info(LSTR(DEV_AUTH_INVALID_AUTH), 1);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "storage/keys.h"
|
||||
#include "ui/ui_internal.h"
|
||||
#include "util/tlv.h"
|
||||
#include "ur/eip4527_encode.h"
|
||||
#include "ur/ur_encode.h"
|
||||
|
||||
#define BTC_SEGWIT_VER 0
|
||||
|
||||
|
@ -325,7 +325,7 @@ void core_display_public_eip4527() {
|
|||
|
||||
// this macro can only be used in core_display_public_multicoin()
|
||||
#define CORE_MULTICOIN_EXPORT(__NUM__, __PATH__, __PATH_LEN__, __SOURCE___) \
|
||||
if (encode_hd_key(&accounts.crypto_multi_accounts_keys_hd_key_m[__NUM__], &g_mem_heap[keys_off], &g_mem_heap[keys_off + PUBKEY_LEN], __PATH__, __PATH_LEN__, __SOURCE___) != ERR_OK) { \
|
||||
if (encode_hd_key(&accounts.crypto_multi_accounts_keys_tagged_hd_key_m[__NUM__], &g_mem_heap[keys_off], &g_mem_heap[keys_off + PUBKEY_LEN], __PATH__, __PATH_LEN__, __SOURCE___) != ERR_OK) { \
|
||||
ui_card_transport_error(); \
|
||||
return; \
|
||||
} \
|
||||
|
@ -357,7 +357,7 @@ void core_display_public_multicoin() {
|
|||
CORE_MULTICOIN_EXPORT(2, BTC_NATIVE_SEGWIT_PATH, BTC_NATIVE_SEGWIT_PATH_LEN, false);
|
||||
CORE_MULTICOIN_EXPORT(3, ETH_DEFAULT_BIP44, ETH_DEFAULT_BIP44_LEN, true);
|
||||
|
||||
accounts.crypto_multi_accounts_keys_hd_key_m_count = 4;
|
||||
accounts.crypto_multi_accounts_keys_tagged_hd_key_m_count = 4;
|
||||
accounts.crypto_multi_accounts_master_fingerprint = g_core.master_fingerprint;
|
||||
|
||||
cbor_encode_crypto_multi_accounts(&g_mem_heap[keys_off], MEM_HEAP_SIZE, &accounts, &g_core.data.key.cbor_len);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "keycard/keycard.h"
|
||||
#include "iso7816/smartcard.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ur/eip4527_types.h"
|
||||
#include "ur/ur_types.h"
|
||||
|
||||
#define BIP44_MAX_PATH_LEN 40
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "crypto/util.h"
|
||||
#include "keycard/keycard_cmdset.h"
|
||||
#include "mem.h"
|
||||
#include "ur/eip4527_encode.h"
|
||||
#include "ur/ur_encode.h"
|
||||
|
||||
#define ETH_MSG_MAGIC_LEN 26
|
||||
#define ETH_EIP712_MAGIC_LEN 2
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
#include "ui/theme.h"
|
||||
#include "ui/ui_internal.h"
|
||||
#include "ur/ur.h"
|
||||
#include "ur/eip4527_decode.h"
|
||||
#include "ur/auth_decode.h"
|
||||
#include "ur/btc_decode.h"
|
||||
#include "ur/ur_decode.h"
|
||||
|
||||
#define QR_INDICATOR_WIDTH ((SCREEN_WIDTH - CAM_OUT_WIDTH) / 2)
|
||||
#define QR_INDICATOR_HEIGHT 40
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "ethereum/ethUstream.h"
|
||||
#include "ethereum/eip712.h"
|
||||
#include "menu.h"
|
||||
#include "ur/eip4527_types.h"
|
||||
#include "ur/ur_types.h"
|
||||
#include "ur/ur.h"
|
||||
|
||||
#define PIN_NEW_CODE -1
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "core/core.h"
|
||||
#include "ethereum/ethUstream.h"
|
||||
#include "qrcode/qrcode.h"
|
||||
#include "ur/eip4527_types.h"
|
||||
#include "ur/ur_types.h"
|
||||
#include "ur/ur.h"
|
||||
|
||||
#define UI_NOTIFICATION_IDX 2
|
||||
|
|
|
@ -1,219 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "zcbor_decode.h"
|
||||
#include "auth_decode.h"
|
||||
#include "zcbor_print.h"
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
static bool decode_dev_auth_step_type(zcbor_state_t *state, struct dev_auth_step_type_r *result);
|
||||
static bool decode_uuid(zcbor_state_t *state, struct zcbor_string *result);
|
||||
static bool decode_repeated_dev_auth_device_id(zcbor_state_t *state, struct dev_auth_device_id *result);
|
||||
static bool decode_repeated_dev_auth_first_auth(zcbor_state_t *state, struct dev_auth_first_auth *result);
|
||||
static bool decode_repeated_dev_auth_auth_time(zcbor_state_t *state, struct dev_auth_auth_time *result);
|
||||
static bool decode_repeated_dev_auth_auth_count(zcbor_state_t *state, struct dev_auth_auth_count *result);
|
||||
static bool decode_repeated_dev_auth_challenge(zcbor_state_t *state, struct dev_auth_challenge *result);
|
||||
static bool decode_repeated_dev_auth_signature(zcbor_state_t *state, struct dev_auth_signature *result);
|
||||
static bool decode_dev_auth(zcbor_state_t *state, struct dev_auth *result);
|
||||
|
||||
|
||||
static bool decode_dev_auth_step_type(
|
||||
zcbor_state_t *state, struct dev_auth_step_type_r *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((((zcbor_uint_decode(state, &(*result).dev_auth_step_type_choice, sizeof((*result).dev_auth_step_type_choice)))) && ((((((*result).dev_auth_step_type_choice == dev_auth_step_type_dev_auth_init_m_c) && ((1)))
|
||||
|| (((*result).dev_auth_step_type_choice == dev_auth_step_type_dev_auth_device_m_c) && ((1)))
|
||||
|| (((*result).dev_auth_step_type_choice == dev_auth_step_type_dev_auth_server_m_c) && ((1)))) || (zcbor_error(state, ZCBOR_ERR_WRONG_VALUE), false))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_uuid(
|
||||
zcbor_state_t *state, struct zcbor_string *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((zcbor_tag_expect(state, 37)
|
||||
&& (zcbor_bstr_decode(state, (&(*result))))
|
||||
&& ((((*result).len >= 16)
|
||||
&& ((*result).len <= 16)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_device_id(
|
||||
zcbor_state_t *state, struct dev_auth_device_id *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (2))))
|
||||
&& (decode_uuid(state, (&(*result).dev_auth_device_id)))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_first_auth(
|
||||
zcbor_state_t *state, struct dev_auth_first_auth *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (3))))
|
||||
&& (zcbor_uint32_decode(state, (&(*result).dev_auth_first_auth)))
|
||||
&& ((((((*result).dev_auth_first_auth <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_auth_time(
|
||||
zcbor_state_t *state, struct dev_auth_auth_time *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (4))))
|
||||
&& (zcbor_uint32_decode(state, (&(*result).dev_auth_auth_time)))
|
||||
&& ((((((*result).dev_auth_auth_time <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_auth_count(
|
||||
zcbor_state_t *state, struct dev_auth_auth_count *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (5))))
|
||||
&& (zcbor_uint32_decode(state, (&(*result).dev_auth_auth_count)))
|
||||
&& ((((((*result).dev_auth_auth_count <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_challenge(
|
||||
zcbor_state_t *state, struct dev_auth_challenge *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (6))))
|
||||
&& (zcbor_bstr_decode(state, (&(*result).dev_auth_challenge)))
|
||||
&& ((((*result).dev_auth_challenge.len >= 32)
|
||||
&& ((*result).dev_auth_challenge.len <= 32)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_signature(
|
||||
zcbor_state_t *state, struct dev_auth_signature *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (7))))
|
||||
&& (zcbor_bstr_decode(state, (&(*result).dev_auth_signature)))
|
||||
&& ((((*result).dev_auth_signature.len >= 64)
|
||||
&& ((*result).dev_auth_signature.len <= 64)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_dev_auth(
|
||||
zcbor_state_t *state, struct dev_auth *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_map_start_decode(state) && (((((zcbor_uint32_expect(state, (1))))
|
||||
&& (decode_dev_auth_step_type(state, (&(*result).dev_auth_step))))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_device_id_present), (zcbor_decoder_t *)decode_repeated_dev_auth_device_id, state, (&(*result).dev_auth_device_id))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_first_auth_present), (zcbor_decoder_t *)decode_repeated_dev_auth_first_auth, state, (&(*result).dev_auth_first_auth))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_auth_time_present), (zcbor_decoder_t *)decode_repeated_dev_auth_auth_time, state, (&(*result).dev_auth_auth_time))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_auth_count_present), (zcbor_decoder_t *)decode_repeated_dev_auth_auth_count, state, (&(*result).dev_auth_auth_count))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_challenge_present), (zcbor_decoder_t *)decode_repeated_dev_auth_challenge, state, (&(*result).dev_auth_challenge))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_signature_present), (zcbor_decoder_t *)decode_repeated_dev_auth_signature, state, (&(*result).dev_auth_signature))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_map_end_decode(state))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cbor_decode_dev_auth(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct dev_auth *result,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[4];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
|
||||
(zcbor_decoder_t *)decode_dev_auth, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef AUTH_DECODE_H__
|
||||
#define AUTH_DECODE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "auth_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
|
||||
int cbor_decode_dev_auth(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct dev_auth *result,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AUTH_DECODE_H__ */
|
|
@ -1,220 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "zcbor_encode.h"
|
||||
#include "auth_encode.h"
|
||||
#include "zcbor_print.h"
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
static bool encode_dev_auth_step_type(zcbor_state_t *state, const struct dev_auth_step_type_r *input);
|
||||
static bool encode_uuid(zcbor_state_t *state, const struct zcbor_string *input);
|
||||
static bool encode_repeated_dev_auth_device_id(zcbor_state_t *state, const struct dev_auth_device_id *input);
|
||||
static bool encode_repeated_dev_auth_first_auth(zcbor_state_t *state, const struct dev_auth_first_auth *input);
|
||||
static bool encode_repeated_dev_auth_auth_time(zcbor_state_t *state, const struct dev_auth_auth_time *input);
|
||||
static bool encode_repeated_dev_auth_auth_count(zcbor_state_t *state, const struct dev_auth_auth_count *input);
|
||||
static bool encode_repeated_dev_auth_challenge(zcbor_state_t *state, const struct dev_auth_challenge *input);
|
||||
static bool encode_repeated_dev_auth_signature(zcbor_state_t *state, const struct dev_auth_signature *input);
|
||||
static bool encode_dev_auth(zcbor_state_t *state, const struct dev_auth *input);
|
||||
|
||||
|
||||
static bool encode_dev_auth_step_type(
|
||||
zcbor_state_t *state, const struct dev_auth_step_type_r *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((((*input).dev_auth_step_type_choice == dev_auth_step_type_dev_auth_init_m_c) ? ((zcbor_uint32_put(state, (1))))
|
||||
: (((*input).dev_auth_step_type_choice == dev_auth_step_type_dev_auth_device_m_c) ? ((zcbor_uint32_put(state, (2))))
|
||||
: (((*input).dev_auth_step_type_choice == dev_auth_step_type_dev_auth_server_m_c) ? ((zcbor_uint32_put(state, (3))))
|
||||
: false)))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool encode_uuid(
|
||||
zcbor_state_t *state, const struct zcbor_string *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((zcbor_tag_put(state, 37)
|
||||
&& ((((*input).len >= 16)
|
||||
&& ((*input).len <= 16)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))
|
||||
&& (zcbor_bstr_encode(state, (&(*input))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool encode_repeated_dev_auth_device_id(
|
||||
zcbor_state_t *state, const struct dev_auth_device_id *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_put(state, (2))))
|
||||
&& (encode_uuid(state, (&(*input).dev_auth_device_id)))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool encode_repeated_dev_auth_first_auth(
|
||||
zcbor_state_t *state, const struct dev_auth_first_auth *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_put(state, (3))))
|
||||
&& ((((((*input).dev_auth_first_auth <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))
|
||||
&& (zcbor_uint32_encode(state, (&(*input).dev_auth_first_auth)))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool encode_repeated_dev_auth_auth_time(
|
||||
zcbor_state_t *state, const struct dev_auth_auth_time *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_put(state, (4))))
|
||||
&& ((((((*input).dev_auth_auth_time <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))
|
||||
&& (zcbor_uint32_encode(state, (&(*input).dev_auth_auth_time)))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool encode_repeated_dev_auth_auth_count(
|
||||
zcbor_state_t *state, const struct dev_auth_auth_count *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_put(state, (5))))
|
||||
&& ((((((*input).dev_auth_auth_count <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))
|
||||
&& (zcbor_uint32_encode(state, (&(*input).dev_auth_auth_count)))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool encode_repeated_dev_auth_challenge(
|
||||
zcbor_state_t *state, const struct dev_auth_challenge *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_put(state, (6))))
|
||||
&& ((((*input).dev_auth_challenge.len >= 32)
|
||||
&& ((*input).dev_auth_challenge.len <= 32)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))
|
||||
&& (zcbor_bstr_encode(state, (&(*input).dev_auth_challenge)))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool encode_repeated_dev_auth_signature(
|
||||
zcbor_state_t *state, const struct dev_auth_signature *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_put(state, (7))))
|
||||
&& ((((*input).dev_auth_signature.len >= 64)
|
||||
&& ((*input).dev_auth_signature.len <= 64)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))
|
||||
&& (zcbor_bstr_encode(state, (&(*input).dev_auth_signature)))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool encode_dev_auth(
|
||||
zcbor_state_t *state, const struct dev_auth *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_map_start_encode(state, 7) && (((((zcbor_uint32_put(state, (1))))
|
||||
&& (encode_dev_auth_step_type(state, (&(*input).dev_auth_step))))
|
||||
&& (!(*input).dev_auth_device_id_present || encode_repeated_dev_auth_device_id(state, (&(*input).dev_auth_device_id)))
|
||||
&& (!(*input).dev_auth_first_auth_present || encode_repeated_dev_auth_first_auth(state, (&(*input).dev_auth_first_auth)))
|
||||
&& (!(*input).dev_auth_auth_time_present || encode_repeated_dev_auth_auth_time(state, (&(*input).dev_auth_auth_time)))
|
||||
&& (!(*input).dev_auth_auth_count_present || encode_repeated_dev_auth_auth_count(state, (&(*input).dev_auth_auth_count)))
|
||||
&& (!(*input).dev_auth_challenge_present || encode_repeated_dev_auth_challenge(state, (&(*input).dev_auth_challenge)))
|
||||
&& (!(*input).dev_auth_signature_present || encode_repeated_dev_auth_signature(state, (&(*input).dev_auth_signature)))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_map_end_encode(state, 7))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cbor_encode_dev_auth(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct dev_auth *input,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[4];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
|
||||
(zcbor_decoder_t *)encode_dev_auth, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef AUTH_ENCODE_H__
|
||||
#define AUTH_ENCODE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "auth_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
|
||||
int cbor_encode_dev_auth(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct dev_auth *input,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AUTH_ENCODE_H__ */
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef AUTH_TYPES_H__
|
||||
#define AUTH_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <zcbor_common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Which value for --default-max-qty this file was created with.
|
||||
*
|
||||
* The define is used in the other generated file to do a build-time
|
||||
* compatibility check.
|
||||
*
|
||||
* See `zcbor --help` for more information about --default-max-qty
|
||||
*/
|
||||
#define DEFAULT_MAX_QTY 3
|
||||
|
||||
struct dev_auth_step_type_r {
|
||||
enum {
|
||||
dev_auth_step_type_dev_auth_init_m_c = 1,
|
||||
dev_auth_step_type_dev_auth_device_m_c = 2,
|
||||
dev_auth_step_type_dev_auth_server_m_c = 3,
|
||||
} dev_auth_step_type_choice;
|
||||
};
|
||||
|
||||
struct dev_auth_device_id {
|
||||
struct zcbor_string dev_auth_device_id;
|
||||
};
|
||||
|
||||
struct dev_auth_first_auth {
|
||||
uint32_t dev_auth_first_auth;
|
||||
};
|
||||
|
||||
struct dev_auth_auth_time {
|
||||
uint32_t dev_auth_auth_time;
|
||||
};
|
||||
|
||||
struct dev_auth_auth_count {
|
||||
uint32_t dev_auth_auth_count;
|
||||
};
|
||||
|
||||
struct dev_auth_challenge {
|
||||
struct zcbor_string dev_auth_challenge;
|
||||
};
|
||||
|
||||
struct dev_auth_signature {
|
||||
struct zcbor_string dev_auth_signature;
|
||||
};
|
||||
|
||||
struct dev_auth {
|
||||
struct dev_auth_step_type_r dev_auth_step;
|
||||
struct dev_auth_device_id dev_auth_device_id;
|
||||
bool dev_auth_device_id_present;
|
||||
struct dev_auth_first_auth dev_auth_first_auth;
|
||||
bool dev_auth_first_auth_present;
|
||||
struct dev_auth_auth_time dev_auth_auth_time;
|
||||
bool dev_auth_auth_time_present;
|
||||
struct dev_auth_auth_count dev_auth_auth_count;
|
||||
bool dev_auth_auth_count_present;
|
||||
struct dev_auth_challenge dev_auth_challenge;
|
||||
bool dev_auth_challenge_present;
|
||||
struct dev_auth_signature dev_auth_signature;
|
||||
bool dev_auth_signature_present;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AUTH_TYPES_H__ */
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "zcbor_decode.h"
|
||||
#include "btc_decode.h"
|
||||
#include "zcbor_print.h"
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
static bool decode_psbt(zcbor_state_t *state, struct zcbor_string *result);
|
||||
|
||||
|
||||
static bool decode_psbt(
|
||||
zcbor_state_t *state, struct zcbor_string *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_bstr_decode(state, (&(*result))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cbor_decode_psbt(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct zcbor_string *result,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[2];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
|
||||
(zcbor_decoder_t *)decode_psbt, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef BTC_DECODE_H__
|
||||
#define BTC_DECODE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "btc_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
|
||||
int cbor_decode_psbt(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct zcbor_string *result,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BTC_DECODE_H__ */
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "zcbor_encode.h"
|
||||
#include "btc_encode.h"
|
||||
#include "zcbor_print.h"
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
static bool encode_psbt(zcbor_state_t *state, const struct zcbor_string *input);
|
||||
|
||||
|
||||
static bool encode_psbt(
|
||||
zcbor_state_t *state, const struct zcbor_string *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_bstr_encode(state, (&(*input))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cbor_encode_psbt(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct zcbor_string *input,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[2];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
|
||||
(zcbor_decoder_t *)encode_psbt, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef BTC_ENCODE_H__
|
||||
#define BTC_ENCODE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "btc_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
|
||||
int cbor_encode_psbt(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct zcbor_string *input,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BTC_ENCODE_H__ */
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef BTC_TYPES_H__
|
||||
#define BTC_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Which value for --default-max-qty this file was created with.
|
||||
*
|
||||
* The define is used in the other generated file to do a build-time
|
||||
* compatibility check.
|
||||
*
|
||||
* See `zcbor --help` for more information about --default-max-qty
|
||||
*/
|
||||
#define DEFAULT_MAX_QTY 3
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BTC_TYPES_H__ */
|
36
app/ur/ur.c
36
app/ur/ur.c
|
@ -2,30 +2,30 @@
|
|||
#include "ur.h"
|
||||
#include "bytewords.h"
|
||||
#include "sampler.h"
|
||||
#include "ur_part_decode.h"
|
||||
#include "ur_decode.h"
|
||||
|
||||
#define MIN_ENCODED_LEN 22
|
||||
#define MAX_CBOR_HEADER_LEN 32
|
||||
|
||||
#define UR_TYPE(t) (ur_type_t)(((t * 4558338) >> 28) & 0xf)
|
||||
#define UR_TYPE(t) (ur_type_t)(((t * 4597373) >> 28) & 0xf)
|
||||
|
||||
const char *const ur_type_string[] = {
|
||||
"ETH-SIGNATURE",
|
||||
"CRYPTO-OUTPUT",
|
||||
"CRYPTO-KEYPATH",
|
||||
"ETH-SIGN-REQUEST",
|
||||
NULL,
|
||||
NULL,
|
||||
"BYTES",
|
||||
NULL,
|
||||
"FS-DATA",
|
||||
"DEV-AUTH",
|
||||
"CRYPTO-MULTI-ACCOUNTS",
|
||||
"FW-UPDATE",
|
||||
NULL,
|
||||
NULL,
|
||||
"CRYPTO-PSBT",
|
||||
"CRYPTO-HDKEY",
|
||||
"ETH-SIGNATURE",
|
||||
"CRYPTO-OUTPUT",
|
||||
"CRYPTO-ACCOUNT",
|
||||
NULL,
|
||||
"ETH-SIGN-REQUEST",
|
||||
NULL,
|
||||
"BYTES",
|
||||
NULL,
|
||||
"FS-DATA",
|
||||
"DEV-AUTH",
|
||||
"CRYPTO-MULTI-ACCOUNTS",
|
||||
"FW-UPDATE",
|
||||
NULL,
|
||||
NULL,
|
||||
"CRYPTO-PSBT",
|
||||
"CRYPTO-HDKEY",
|
||||
};
|
||||
|
||||
static app_err_t ur_process_simple(ur_t* ur, uint8_t* parts, uint8_t* part_data, size_t part_len, uint32_t desc_idx, struct ur_part* part) {
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
typedef enum {
|
||||
ETH_SIGNATURE = 0,
|
||||
CRYPTO_OUTPUT = 1,
|
||||
CRYPTO_KEYPATH = 2,
|
||||
ETH_SIGN_REQUEST = 3,
|
||||
CRYPTO_ACCOUNT = 2,
|
||||
ETH_SIGN_REQUEST = 4,
|
||||
BYTES = 6,
|
||||
FS_DATA = 8,
|
||||
DEV_AUTH = 9,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "zcbor_decode.h"
|
||||
#include "eip4527_decode.h"
|
||||
#include "ur_decode.h"
|
||||
#include "zcbor_print.h"
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
|
@ -19,6 +19,13 @@
|
|||
static bool decode_uuid(zcbor_state_t *state, struct zcbor_string *result);
|
||||
static bool decode_repeated_eth_signature_request_id(zcbor_state_t *state, struct eth_signature_request_id *result);
|
||||
static bool decode_repeated_eth_signature_signature_origin(zcbor_state_t *state, struct eth_signature_signature_origin *result);
|
||||
static bool decode_dev_auth_step_type(zcbor_state_t *state, struct dev_auth_step_type_r *result);
|
||||
static bool decode_repeated_dev_auth_dev_id(zcbor_state_t *state, struct dev_auth_dev_id *result);
|
||||
static bool decode_repeated_dev_auth_first_auth(zcbor_state_t *state, struct dev_auth_first_auth *result);
|
||||
static bool decode_repeated_dev_auth_auth_time(zcbor_state_t *state, struct dev_auth_auth_time *result);
|
||||
static bool decode_repeated_dev_auth_auth_count(zcbor_state_t *state, struct dev_auth_auth_count *result);
|
||||
static bool decode_repeated_dev_auth_challenge(zcbor_state_t *state, struct dev_auth_challenge *result);
|
||||
static bool decode_repeated_dev_auth_auth_sig(zcbor_state_t *state, struct dev_auth_auth_sig *result);
|
||||
static bool decode_repeated_eth_sign_request_request_id(zcbor_state_t *state, struct eth_sign_request_request_id *result);
|
||||
static bool decode_sign_data_type(zcbor_state_t *state, struct sign_data_type_r *result);
|
||||
static bool decode_repeated_eth_sign_request_chain_id(zcbor_state_t *state, struct eth_sign_request_chain_id *result);
|
||||
|
@ -31,9 +38,20 @@ static bool decode_repeated_eth_sign_request_request_origin(zcbor_state_t *state
|
|||
static bool decode_coininfo(zcbor_state_t *state, struct coininfo *result);
|
||||
static bool decode_repeated_hd_key_use_info(zcbor_state_t *state, struct hd_key_use_info *result);
|
||||
static bool decode_repeated_hd_key_source(zcbor_state_t *state, struct hd_key_source *result);
|
||||
static bool decode_tagged_hd_key(zcbor_state_t *state, struct hd_key *result);
|
||||
static bool decode_repeated_crypto_multi_accounts_device(zcbor_state_t *state, struct crypto_multi_accounts_device *result);
|
||||
static bool decode_repeated_crypto_multi_accounts_device_id(zcbor_state_t *state, struct crypto_multi_accounts_device_id *result);
|
||||
static bool decode_repeated_crypto_multi_accounts_version(zcbor_state_t *state, struct crypto_multi_accounts_version *result);
|
||||
static bool decode_key_exp(zcbor_state_t *state, struct hd_key *result);
|
||||
static bool decode_witness_public_key_hash(zcbor_state_t *state, struct hd_key *result);
|
||||
static bool decode_script_hash(zcbor_state_t *state, struct hd_key *result);
|
||||
static bool decode_public_key_hash(zcbor_state_t *state, struct hd_key *result);
|
||||
static bool decode_taproot(zcbor_state_t *state, struct hd_key *result);
|
||||
static bool decode_crypto_output(zcbor_state_t *state, struct crypto_output_r *result);
|
||||
static bool decode_psbt(zcbor_state_t *state, struct zcbor_string *result);
|
||||
static bool decode_dev_auth(zcbor_state_t *state, struct dev_auth *result);
|
||||
static bool decode_ur_part(zcbor_state_t *state, struct ur_part *result);
|
||||
static bool decode_crypto_account(zcbor_state_t *state, struct crypto_account *result);
|
||||
static bool decode_crypto_multi_accounts(zcbor_state_t *state, struct crypto_multi_accounts *result);
|
||||
static bool decode_hd_key(zcbor_state_t *state, struct hd_key *result);
|
||||
static bool decode_eth_signature(zcbor_state_t *state, struct eth_signature *result);
|
||||
|
@ -94,6 +112,140 @@ static bool decode_repeated_eth_signature_signature_origin(
|
|||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_dev_auth_step_type(
|
||||
zcbor_state_t *state, struct dev_auth_step_type_r *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((((zcbor_uint_decode(state, &(*result).dev_auth_step_type_choice, sizeof((*result).dev_auth_step_type_choice)))) && ((((((*result).dev_auth_step_type_choice == dev_auth_step_type_dev_auth_init_m_c) && ((1)))
|
||||
|| (((*result).dev_auth_step_type_choice == dev_auth_step_type_dev_auth_device_m_c) && ((1)))
|
||||
|| (((*result).dev_auth_step_type_choice == dev_auth_step_type_dev_auth_server_m_c) && ((1)))) || (zcbor_error(state, ZCBOR_ERR_WRONG_VALUE), false))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_dev_id(
|
||||
zcbor_state_t *state, struct dev_auth_dev_id *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (2))))
|
||||
&& (decode_uuid(state, (&(*result).dev_auth_dev_id)))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_first_auth(
|
||||
zcbor_state_t *state, struct dev_auth_first_auth *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (3))))
|
||||
&& (zcbor_uint32_decode(state, (&(*result).dev_auth_first_auth)))
|
||||
&& ((((((*result).dev_auth_first_auth <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_auth_time(
|
||||
zcbor_state_t *state, struct dev_auth_auth_time *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (4))))
|
||||
&& (zcbor_uint32_decode(state, (&(*result).dev_auth_auth_time)))
|
||||
&& ((((((*result).dev_auth_auth_time <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_auth_count(
|
||||
zcbor_state_t *state, struct dev_auth_auth_count *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (5))))
|
||||
&& (zcbor_uint32_decode(state, (&(*result).dev_auth_auth_count)))
|
||||
&& ((((((*result).dev_auth_auth_count <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_challenge(
|
||||
zcbor_state_t *state, struct dev_auth_challenge *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (6))))
|
||||
&& (zcbor_bstr_decode(state, (&(*result).dev_auth_challenge)))
|
||||
&& ((((*result).dev_auth_challenge.len >= 32)
|
||||
&& ((*result).dev_auth_challenge.len <= 32)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_dev_auth_auth_sig(
|
||||
zcbor_state_t *state, struct dev_auth_auth_sig *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((((zcbor_uint32_expect(state, (7))))
|
||||
&& (zcbor_bstr_decode(state, (&(*result).dev_auth_auth_sig)))
|
||||
&& ((((*result).dev_auth_auth_sig.len >= 64)
|
||||
&& ((*result).dev_auth_auth_sig.len <= 64)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_eth_sign_request_request_id(
|
||||
zcbor_state_t *state, struct eth_sign_request_request_id *result)
|
||||
{
|
||||
|
@ -323,6 +475,24 @@ static bool decode_repeated_hd_key_source(
|
|||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_tagged_hd_key(
|
||||
zcbor_state_t *state, struct hd_key *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((zcbor_tag_expect(state, 303)
|
||||
&& (decode_hd_key(state, (&(*result))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_repeated_crypto_multi_accounts_device(
|
||||
zcbor_state_t *state, struct crypto_multi_accounts_device *result)
|
||||
{
|
||||
|
@ -377,6 +547,202 @@ static bool decode_repeated_crypto_multi_accounts_version(
|
|||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_key_exp(
|
||||
zcbor_state_t *state, struct hd_key *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((zcbor_tag_expect(state, 303)
|
||||
&& (decode_hd_key(state, (&(*result))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_witness_public_key_hash(
|
||||
zcbor_state_t *state, struct hd_key *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((zcbor_tag_expect(state, 404)
|
||||
&& (decode_key_exp(state, (&(*result))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_script_hash(
|
||||
zcbor_state_t *state, struct hd_key *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((zcbor_tag_expect(state, 400)
|
||||
&& (decode_witness_public_key_hash(state, (&(*result))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_public_key_hash(
|
||||
zcbor_state_t *state, struct hd_key *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((zcbor_tag_expect(state, 403)
|
||||
&& (decode_key_exp(state, (&(*result))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_taproot(
|
||||
zcbor_state_t *state, struct hd_key *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = ((zcbor_tag_expect(state, 409)
|
||||
&& (decode_key_exp(state, (&(*result))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_crypto_output(
|
||||
zcbor_state_t *state, struct crypto_output_r *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
bool int_res;
|
||||
|
||||
bool tmp_result = (((zcbor_union_start_code(state) && (int_res = ((((decode_script_hash(state, (&(*result).crypto_output_script_hash_m)))) && (((*result).crypto_output_choice = crypto_output_script_hash_m_c), true))
|
||||
|| (zcbor_union_elem_code(state) && (((decode_public_key_hash(state, (&(*result).crypto_output_public_key_hash_m)))) && (((*result).crypto_output_choice = crypto_output_public_key_hash_m_c), true)))
|
||||
|| (zcbor_union_elem_code(state) && (((decode_witness_public_key_hash(state, (&(*result).crypto_output_witness_public_key_hash_m)))) && (((*result).crypto_output_choice = crypto_output_witness_public_key_hash_m_c), true)))
|
||||
|| (zcbor_union_elem_code(state) && (((decode_taproot(state, (&(*result).crypto_output_taproot_m)))) && (((*result).crypto_output_choice = crypto_output_taproot_m_c), true)))), zcbor_union_end_code(state), int_res))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_psbt(
|
||||
zcbor_state_t *state, struct zcbor_string *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_bstr_decode(state, (&(*result))))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_dev_auth(
|
||||
zcbor_state_t *state, struct dev_auth *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_map_start_decode(state) && (((((zcbor_uint32_expect(state, (1))))
|
||||
&& (decode_dev_auth_step_type(state, (&(*result).dev_auth_step))))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_dev_id_present), (zcbor_decoder_t *)decode_repeated_dev_auth_dev_id, state, (&(*result).dev_auth_dev_id))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_first_auth_present), (zcbor_decoder_t *)decode_repeated_dev_auth_first_auth, state, (&(*result).dev_auth_first_auth))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_auth_time_present), (zcbor_decoder_t *)decode_repeated_dev_auth_auth_time, state, (&(*result).dev_auth_auth_time))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_auth_count_present), (zcbor_decoder_t *)decode_repeated_dev_auth_auth_count, state, (&(*result).dev_auth_auth_count))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_challenge_present), (zcbor_decoder_t *)decode_repeated_dev_auth_challenge, state, (&(*result).dev_auth_challenge))
|
||||
&& zcbor_present_decode(&((*result).dev_auth_auth_sig_present), (zcbor_decoder_t *)decode_repeated_dev_auth_auth_sig, state, (&(*result).dev_auth_auth_sig))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_map_end_decode(state))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_ur_part(
|
||||
zcbor_state_t *state, struct ur_part *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_list_start_decode(state) && ((((zcbor_uint32_decode(state, (&(*result).ur_part_seqNum)))
|
||||
&& ((((((*result).ur_part_seqNum <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)))
|
||||
&& ((zcbor_uint32_decode(state, (&(*result).ur_part_seqLen))))
|
||||
&& ((zcbor_uint32_decode(state, (&(*result).ur_part_messageLen))))
|
||||
&& ((zcbor_uint32_decode(state, (&(*result).ur_part_checksum)))
|
||||
&& ((((((*result).ur_part_checksum <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)))
|
||||
&& ((zcbor_bstr_decode(state, (&(*result).ur_part_data))))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_crypto_account(
|
||||
zcbor_state_t *state, struct crypto_account *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_map_start_decode(state) && (((((zcbor_uint32_expect(state, (1))))
|
||||
&& (zcbor_uint32_decode(state, (&(*result).crypto_account_master_fingerprint)))
|
||||
&& ((((((*result).crypto_account_master_fingerprint <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)))
|
||||
&& (((zcbor_uint32_expect(state, (2))))
|
||||
&& (zcbor_list_start_decode(state) && ((zcbor_multi_decode(0, 10, &(*result).crypto_account_output_descriptors_crypto_output_m_count, (zcbor_decoder_t *)decode_crypto_output, state, (&(*result).crypto_account_output_descriptors_crypto_output_m), sizeof(struct crypto_output_r))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_map_end_decode(state))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
static bool decode_crypto_multi_accounts(
|
||||
zcbor_state_t *state, struct crypto_multi_accounts *result)
|
||||
{
|
||||
|
@ -386,7 +752,7 @@ static bool decode_crypto_multi_accounts(
|
|||
&& (zcbor_uint32_decode(state, (&(*result).crypto_multi_accounts_master_fingerprint)))
|
||||
&& ((((((*result).crypto_multi_accounts_master_fingerprint <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)))
|
||||
&& (((zcbor_uint32_expect(state, (2))))
|
||||
&& (zcbor_list_start_decode(state) && ((zcbor_multi_decode(0, 10, &(*result).crypto_multi_accounts_keys_hd_key_m_count, (zcbor_decoder_t *)decode_hd_key, state, (&(*result).crypto_multi_accounts_keys_hd_key_m), sizeof(struct hd_key))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))
|
||||
&& (zcbor_list_start_decode(state) && ((zcbor_multi_decode(0, 10, &(*result).crypto_multi_accounts_keys_tagged_hd_key_m_count, (zcbor_decoder_t *)decode_tagged_hd_key, state, (&(*result).crypto_multi_accounts_keys_tagged_hd_key_m), sizeof(struct hd_key))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))
|
||||
&& zcbor_present_decode(&((*result).crypto_multi_accounts_device_present), (zcbor_decoder_t *)decode_repeated_crypto_multi_accounts_device, state, (&(*result).crypto_multi_accounts_device))
|
||||
&& zcbor_present_decode(&((*result).crypto_multi_accounts_device_id_present), (zcbor_decoder_t *)decode_repeated_crypto_multi_accounts_device_id, state, (&(*result).crypto_multi_accounts_device_id))
|
||||
&& zcbor_present_decode(&((*result).crypto_multi_accounts_version_present), (zcbor_decoder_t *)decode_repeated_crypto_multi_accounts_version, state, (&(*result).crypto_multi_accounts_version))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_map_end_decode(state))));
|
||||
|
@ -531,4 +897,52 @@ int cbor_decode_crypto_multi_accounts(
|
|||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
|
||||
(zcbor_decoder_t *)decode_crypto_multi_accounts, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
||||
|
||||
|
||||
int cbor_decode_crypto_account(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct crypto_account *result,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[8];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
|
||||
(zcbor_decoder_t *)decode_crypto_account, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
||||
|
||||
|
||||
int cbor_decode_ur_part(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct ur_part *result,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[3];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
|
||||
(zcbor_decoder_t *)decode_ur_part, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
||||
|
||||
|
||||
int cbor_decode_dev_auth(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct dev_auth *result,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[4];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
|
||||
(zcbor_decoder_t *)decode_dev_auth, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
||||
|
||||
|
||||
int cbor_decode_psbt(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct zcbor_string *result,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[2];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
|
||||
(zcbor_decoder_t *)decode_psbt, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
|
@ -4,14 +4,14 @@
|
|||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef EIP4527_DECODE_H__
|
||||
#define EIP4527_DECODE_H__
|
||||
#ifndef UR_DECODE_H__
|
||||
#define UR_DECODE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "eip4527_types.h"
|
||||
#include "ur_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -43,6 +43,30 @@ int cbor_decode_hd_key(
|
|||
int cbor_decode_crypto_multi_accounts(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct crypto_multi_accounts *result,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
int cbor_decode_crypto_account(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct crypto_account *result,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
int cbor_decode_ur_part(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct ur_part *result,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
int cbor_decode_dev_auth(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct dev_auth *result,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
int cbor_decode_psbt(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct zcbor_string *result,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
|
@ -50,4 +74,4 @@ int cbor_decode_crypto_multi_accounts(
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* EIP4527_DECODE_H__ */
|
||||
#endif /* UR_DECODE_H__ */
|
File diff suppressed because it is too large
Load Diff
|
@ -4,14 +4,14 @@
|
|||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef EIP4527_ENCODE_H__
|
||||
#define EIP4527_ENCODE_H__
|
||||
#ifndef UR_ENCODE_H__
|
||||
#define UR_ENCODE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "eip4527_types.h"
|
||||
#include "ur_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -43,6 +43,30 @@ int cbor_encode_hd_key(
|
|||
int cbor_encode_crypto_multi_accounts(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct crypto_multi_accounts *input,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
int cbor_encode_crypto_account(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct crypto_account *input,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
int cbor_encode_ur_part(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct ur_part *input,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
int cbor_encode_dev_auth(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct dev_auth *input,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
int cbor_encode_psbt(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct zcbor_string *input,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
|
@ -50,4 +74,4 @@ int cbor_encode_crypto_multi_accounts(
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* EIP4527_ENCODE_H__ */
|
||||
#endif /* UR_ENCODE_H__ */
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "zcbor_decode.h"
|
||||
#include "ur_part_decode.h"
|
||||
#include "zcbor_print.h"
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
static bool decode_ur_part(zcbor_state_t *state, struct ur_part *result);
|
||||
|
||||
|
||||
static bool decode_ur_part(
|
||||
zcbor_state_t *state, struct ur_part *result)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_list_start_decode(state) && ((((zcbor_uint32_decode(state, (&(*result).ur_part_seqNum)))
|
||||
&& ((((((*result).ur_part_seqNum <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)))
|
||||
&& ((zcbor_uint32_decode(state, (&(*result).ur_part_seqLen))))
|
||||
&& ((zcbor_uint32_decode(state, (&(*result).ur_part_messageLen))))
|
||||
&& ((zcbor_uint32_decode(state, (&(*result).ur_part_checksum)))
|
||||
&& ((((((*result).ur_part_checksum <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)))
|
||||
&& ((zcbor_bstr_decode(state, (&(*result).ur_part_data))))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cbor_decode_ur_part(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct ur_part *result,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[3];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
|
||||
(zcbor_decoder_t *)decode_ur_part, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef UR_PART_DECODE_H__
|
||||
#define UR_PART_DECODE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "ur_part_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
|
||||
int cbor_decode_ur_part(
|
||||
const uint8_t *payload, size_t payload_len,
|
||||
struct ur_part *result,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UR_PART_DECODE_H__ */
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "zcbor_encode.h"
|
||||
#include "ur_part_encode.h"
|
||||
#include "zcbor_print.h"
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
static bool encode_ur_part(zcbor_state_t *state, const struct ur_part *input);
|
||||
|
||||
|
||||
static bool encode_ur_part(
|
||||
zcbor_state_t *state, const struct ur_part *input)
|
||||
{
|
||||
zcbor_log("%s\r\n", __func__);
|
||||
|
||||
bool tmp_result = (((zcbor_list_start_encode(state, 5) && (((((((((*input).ur_part_seqNum <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))
|
||||
&& (zcbor_uint32_encode(state, (&(*input).ur_part_seqNum))))
|
||||
&& ((zcbor_uint32_encode(state, (&(*input).ur_part_seqLen))))
|
||||
&& ((zcbor_uint32_encode(state, (&(*input).ur_part_messageLen))))
|
||||
&& (((((((*input).ur_part_checksum <= UINT32_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))
|
||||
&& (zcbor_uint32_encode(state, (&(*input).ur_part_checksum))))
|
||||
&& ((zcbor_bstr_encode(state, (&(*input).ur_part_data))))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 5))));
|
||||
|
||||
if (!tmp_result) {
|
||||
zcbor_trace_file(state);
|
||||
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
|
||||
} else {
|
||||
zcbor_log("%s success\r\n", __func__);
|
||||
}
|
||||
|
||||
return tmp_result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cbor_encode_ur_part(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct ur_part *input,
|
||||
size_t *payload_len_out)
|
||||
{
|
||||
zcbor_state_t states[3];
|
||||
|
||||
return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
|
||||
(zcbor_decoder_t *)encode_ur_part, sizeof(states) / sizeof(zcbor_state_t), 1);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef UR_PART_ENCODE_H__
|
||||
#define UR_PART_ENCODE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "ur_part_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if DEFAULT_MAX_QTY != 3
|
||||
#error "The type file was generated with a different default_max_qty than this file"
|
||||
#endif
|
||||
|
||||
|
||||
int cbor_encode_ur_part(
|
||||
uint8_t *payload, size_t payload_len,
|
||||
const struct ur_part *input,
|
||||
size_t *payload_len_out);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UR_PART_ENCODE_H__ */
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Generated using zcbor version 0.8.1
|
||||
* https://github.com/NordicSemiconductor/zcbor
|
||||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef UR_PART_TYPES_H__
|
||||
#define UR_PART_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <zcbor_common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Which value for --default-max-qty this file was created with.
|
||||
*
|
||||
* The define is used in the other generated file to do a build-time
|
||||
* compatibility check.
|
||||
*
|
||||
* See `zcbor --help` for more information about --default-max-qty
|
||||
*/
|
||||
#define DEFAULT_MAX_QTY 3
|
||||
|
||||
struct ur_part {
|
||||
uint32_t ur_part_seqNum;
|
||||
uint32_t ur_part_seqLen;
|
||||
uint32_t ur_part_messageLen;
|
||||
uint32_t ur_part_checksum;
|
||||
struct zcbor_string ur_part_data;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UR_PART_TYPES_H__ */
|
|
@ -4,8 +4,8 @@
|
|||
* Generated with a --default-max-qty of 3
|
||||
*/
|
||||
|
||||
#ifndef EIP4527_TYPES_H__
|
||||
#define EIP4527_TYPES_H__
|
||||
#ifndef UR_TYPES_H__
|
||||
#define UR_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -41,6 +41,62 @@ struct eth_signature {
|
|||
bool eth_signature_signature_origin_present;
|
||||
};
|
||||
|
||||
struct ur_part {
|
||||
uint32_t ur_part_seqNum;
|
||||
uint32_t ur_part_seqLen;
|
||||
uint32_t ur_part_messageLen;
|
||||
uint32_t ur_part_checksum;
|
||||
struct zcbor_string ur_part_data;
|
||||
};
|
||||
|
||||
struct dev_auth_step_type_r {
|
||||
enum {
|
||||
dev_auth_step_type_dev_auth_init_m_c = 1,
|
||||
dev_auth_step_type_dev_auth_device_m_c = 2,
|
||||
dev_auth_step_type_dev_auth_server_m_c = 3,
|
||||
} dev_auth_step_type_choice;
|
||||
};
|
||||
|
||||
struct dev_auth_dev_id {
|
||||
struct zcbor_string dev_auth_dev_id;
|
||||
};
|
||||
|
||||
struct dev_auth_first_auth {
|
||||
uint32_t dev_auth_first_auth;
|
||||
};
|
||||
|
||||
struct dev_auth_auth_time {
|
||||
uint32_t dev_auth_auth_time;
|
||||
};
|
||||
|
||||
struct dev_auth_auth_count {
|
||||
uint32_t dev_auth_auth_count;
|
||||
};
|
||||
|
||||
struct dev_auth_challenge {
|
||||
struct zcbor_string dev_auth_challenge;
|
||||
};
|
||||
|
||||
struct dev_auth_auth_sig {
|
||||
struct zcbor_string dev_auth_auth_sig;
|
||||
};
|
||||
|
||||
struct dev_auth {
|
||||
struct dev_auth_step_type_r dev_auth_step;
|
||||
struct dev_auth_dev_id dev_auth_dev_id;
|
||||
bool dev_auth_dev_id_present;
|
||||
struct dev_auth_first_auth dev_auth_first_auth;
|
||||
bool dev_auth_first_auth_present;
|
||||
struct dev_auth_auth_time dev_auth_auth_time;
|
||||
bool dev_auth_auth_time_present;
|
||||
struct dev_auth_auth_count dev_auth_auth_count;
|
||||
bool dev_auth_auth_count_present;
|
||||
struct dev_auth_challenge dev_auth_challenge;
|
||||
bool dev_auth_challenge_present;
|
||||
struct dev_auth_auth_sig dev_auth_auth_sig;
|
||||
bool dev_auth_auth_sig_present;
|
||||
};
|
||||
|
||||
struct eth_sign_request_request_id {
|
||||
struct zcbor_string eth_sign_request_request_id;
|
||||
};
|
||||
|
@ -142,18 +198,39 @@ struct crypto_multi_accounts_version {
|
|||
|
||||
struct crypto_multi_accounts {
|
||||
uint32_t crypto_multi_accounts_master_fingerprint;
|
||||
struct hd_key crypto_multi_accounts_keys_hd_key_m[10];
|
||||
size_t crypto_multi_accounts_keys_hd_key_m_count;
|
||||
struct hd_key crypto_multi_accounts_keys_tagged_hd_key_m[10];
|
||||
size_t crypto_multi_accounts_keys_tagged_hd_key_m_count;
|
||||
struct crypto_multi_accounts_device crypto_multi_accounts_device;
|
||||
bool crypto_multi_accounts_device_present;
|
||||
struct crypto_multi_accounts_device_id crypto_multi_accounts_device_id;
|
||||
bool crypto_multi_accounts_device_id_present;
|
||||
struct crypto_multi_accounts_version crypto_multi_accounts_version;
|
||||
bool crypto_multi_accounts_version_present;
|
||||
};
|
||||
|
||||
struct crypto_output_r {
|
||||
union {
|
||||
struct hd_key crypto_output_script_hash_m;
|
||||
struct hd_key crypto_output_public_key_hash_m;
|
||||
struct hd_key crypto_output_witness_public_key_hash_m;
|
||||
struct hd_key crypto_output_taproot_m;
|
||||
};
|
||||
enum {
|
||||
crypto_output_script_hash_m_c,
|
||||
crypto_output_public_key_hash_m_c,
|
||||
crypto_output_witness_public_key_hash_m_c,
|
||||
crypto_output_taproot_m_c,
|
||||
} crypto_output_choice;
|
||||
};
|
||||
|
||||
struct crypto_account {
|
||||
uint32_t crypto_account_master_fingerprint;
|
||||
struct crypto_output_r crypto_account_output_descriptors_crypto_output_m[10];
|
||||
size_t crypto_account_output_descriptors_crypto_output_m_count;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EIP4527_TYPES_H__ */
|
||||
#endif /* UR_TYPES_H__ */
|
|
@ -1,27 +0,0 @@
|
|||
dev-auth-init = 1
|
||||
dev-auth-device = 2
|
||||
dev-auth-server = 3
|
||||
|
||||
dev-auth-step-type = dev-auth-init / dev-auth-device / dev-auth-server
|
||||
|
||||
dev-auth = {
|
||||
dev-auth-step: dev-auth-step-type,
|
||||
? device-id: uuid,
|
||||
? first-auth: timestamp,
|
||||
? auth-time: timestamp,
|
||||
? auth-count: uint32,
|
||||
? challenge: bstr .size 32,
|
||||
? signature: bstr .size 64,
|
||||
}
|
||||
|
||||
dev-auth-step = 1
|
||||
device-id = 2
|
||||
first-auth = 3
|
||||
auth-time = 4
|
||||
auth-count = 5
|
||||
challenge = 6
|
||||
signature = 7
|
||||
|
||||
uuid = #6.37(bstr .size 16)
|
||||
timestamp = uint .size 4
|
||||
uint32 = uint .size 4
|
|
@ -1 +0,0 @@
|
|||
psbt = bstr
|
|
@ -1,114 +0,0 @@
|
|||
; Crypto Keypath
|
||||
crypto-keypath = {
|
||||
components: [0*10 path-component],
|
||||
? source-fingerprint: uint32 .gt 0,
|
||||
? depth: uint8
|
||||
}
|
||||
|
||||
path-component = (
|
||||
child-index,
|
||||
is-hardened
|
||||
)
|
||||
|
||||
uint8 = uint .size 1
|
||||
uint32 = uint .size 4
|
||||
uint31 = uint32 .lt 2147483648
|
||||
child-index = uint31
|
||||
is-hardened = bool
|
||||
components = 1
|
||||
source-fingerprint = 2
|
||||
depth = 3
|
||||
|
||||
; Coin info
|
||||
coininfo = {
|
||||
coin-type: uint31,
|
||||
network: int
|
||||
}
|
||||
|
||||
coin-type = 1
|
||||
network = 2
|
||||
|
||||
; Crypto HDKey
|
||||
hd-key = {
|
||||
;? is-master: bool,
|
||||
is-private: bool,
|
||||
key-data: key-data-bytes,
|
||||
chain-code: chain-code-bytes,
|
||||
? use-info: #6.305(coininfo),
|
||||
origin: #6.304(crypto-keypath),
|
||||
;? children: #6.304(crypto-keypath),
|
||||
parent-fingerprint: uint32 .gt 0,
|
||||
name: text,
|
||||
? source: text
|
||||
}
|
||||
|
||||
is-master = 1
|
||||
is-private = 2
|
||||
key-data = 3
|
||||
chain-code = 4
|
||||
use-info = 5
|
||||
origin = 6
|
||||
children = 7
|
||||
parent-fingerprint = 8
|
||||
name = 9
|
||||
source = 10
|
||||
|
||||
key-data-bytes = bstr .size 33
|
||||
chain-code-bytes = bstr .size 32
|
||||
|
||||
; Crypto Multi Accounts
|
||||
crypto-multi-accounts = {
|
||||
master-fingerprint: uint32,
|
||||
keys: [0*10 #6.303(hd-key)],
|
||||
? device: text,
|
||||
? device-id: text,
|
||||
? version: text
|
||||
}
|
||||
|
||||
master-fingerprint = 1
|
||||
keys = 2
|
||||
device = 3
|
||||
device-id = 4
|
||||
version = 5
|
||||
|
||||
; Sign data type
|
||||
sign-data-type = eth-transaction-data / eth-typed-data / eth-raw-bytes / eth-typed-transaction
|
||||
|
||||
eth-transaction-data = 1
|
||||
eth-typed-data = 2
|
||||
eth-raw-bytes = 3
|
||||
eth-typed-transaction = 4
|
||||
|
||||
; Eth Sign request
|
||||
eth-sign-request = {
|
||||
? request-id: uuid,
|
||||
sign-data: sign-data-bytes,
|
||||
data-type: sign-data-type,
|
||||
? chain-id: int,
|
||||
derivation-path: #6.304(crypto-keypath),
|
||||
? address: eth-address-bytes,
|
||||
? request-origin: text
|
||||
}
|
||||
|
||||
request-id = 1
|
||||
sign-data = 2
|
||||
data-type = 3
|
||||
chain-id = 4
|
||||
derivation-path = 5
|
||||
address = 6
|
||||
request-origin = 7
|
||||
eth-address-bytes = bstr .size 20
|
||||
sign-data-bytes = bstr
|
||||
uuid = #6.37(bstr)
|
||||
|
||||
; Eth Signature
|
||||
eth-signature = {
|
||||
? request-id: uuid,
|
||||
signature: eth-signature-bytes,
|
||||
? signature-origin: text,
|
||||
}
|
||||
|
||||
signature = 2
|
||||
signature-origin = 3
|
||||
|
||||
eth-signature-bytes = bstr
|
174
cddl/ur.cddl
174
cddl/ur.cddl
|
@ -1,3 +1,4 @@
|
|||
; UR Part
|
||||
ur-part = [
|
||||
seqNum: uint32,
|
||||
seqLen: uint,
|
||||
|
@ -6,4 +7,175 @@ ur-part = [
|
|||
data: bstr
|
||||
]
|
||||
|
||||
uint32 = uint .size 4
|
||||
; Crypto Keypath
|
||||
crypto-keypath = {
|
||||
components: [0*10 path-component],
|
||||
? source-fingerprint: uint32 .gt 0,
|
||||
? depth: uint8
|
||||
}
|
||||
|
||||
path-component = (
|
||||
child-index,
|
||||
is-hardened
|
||||
)
|
||||
|
||||
uint8 = uint .size 1
|
||||
uint32 = uint .size 4
|
||||
uint31 = uint32 .lt 2147483648
|
||||
child-index = uint31
|
||||
is-hardened = bool
|
||||
components = 1
|
||||
source-fingerprint = 2
|
||||
depth = 3
|
||||
|
||||
; Coin info
|
||||
coininfo = {
|
||||
coin-type: uint31,
|
||||
network: int
|
||||
}
|
||||
|
||||
coin-type = 1
|
||||
network = 2
|
||||
|
||||
; Crypto HDKey
|
||||
hd-key = {
|
||||
;? is-master: bool,
|
||||
is-private: bool,
|
||||
key-data: key-data-bytes,
|
||||
chain-code: chain-code-bytes,
|
||||
? use-info: #6.305(coininfo),
|
||||
origin: #6.304(crypto-keypath),
|
||||
;? children: #6.304(crypto-keypath),
|
||||
parent-fingerprint: uint32 .gt 0,
|
||||
name: text,
|
||||
? source: text
|
||||
}
|
||||
|
||||
is-master = 1
|
||||
is-private = 2
|
||||
key-data = 3
|
||||
chain-code = 4
|
||||
use-info = 5
|
||||
origin = 6
|
||||
children = 7
|
||||
parent-fingerprint = 8
|
||||
name = 9
|
||||
source = 10
|
||||
|
||||
key-data-bytes = bstr .size 33
|
||||
chain-code-bytes = bstr .size 32
|
||||
|
||||
; Crypto Multi Accounts
|
||||
tagged-hd-key = #6.303(hd-key)
|
||||
crypto-multi-accounts = {
|
||||
master-fingerprint: uint32,
|
||||
keys: [0*10 tagged-hd-key],
|
||||
? device: text,
|
||||
? device-id: text,
|
||||
? version: text
|
||||
}
|
||||
|
||||
master-fingerprint = 1
|
||||
keys = 2
|
||||
device = 3
|
||||
device-id = 4
|
||||
version = 5
|
||||
|
||||
; Sign data type
|
||||
sign-data-type = eth-transaction-data / eth-typed-data / eth-raw-bytes / eth-typed-transaction
|
||||
|
||||
eth-transaction-data = 1
|
||||
eth-typed-data = 2
|
||||
eth-raw-bytes = 3
|
||||
eth-typed-transaction = 4
|
||||
|
||||
; Eth Sign request
|
||||
eth-sign-request = {
|
||||
? request-id: uuid,
|
||||
sign-data: sign-data-bytes,
|
||||
data-type: sign-data-type,
|
||||
? chain-id: int,
|
||||
derivation-path: #6.304(crypto-keypath),
|
||||
? address: eth-address-bytes,
|
||||
? request-origin: text
|
||||
}
|
||||
|
||||
request-id = 1
|
||||
sign-data = 2
|
||||
data-type = 3
|
||||
chain-id = 4
|
||||
derivation-path = 5
|
||||
address = 6
|
||||
request-origin = 7
|
||||
eth-address-bytes = bstr .size 20
|
||||
sign-data-bytes = bstr
|
||||
uuid = #6.37(bstr)
|
||||
|
||||
; Eth Signature
|
||||
eth-signature = {
|
||||
? request-id: uuid,
|
||||
signature: eth-signature-bytes,
|
||||
? signature-origin: text,
|
||||
}
|
||||
|
||||
signature = 2
|
||||
signature-origin = 3
|
||||
|
||||
eth-signature-bytes = bstr
|
||||
|
||||
; Crypto Output
|
||||
key-exp = #6.303(hd-key)
|
||||
|
||||
crypto-output = (
|
||||
script-hash / ; sh
|
||||
public-key-hash / ; pkh
|
||||
witness-public-key-hash / ; wpkh
|
||||
taproot ; tr
|
||||
)
|
||||
|
||||
script-hash = #6.400(witness-public-key-hash)
|
||||
public-key-hash = #6.403(key-exp)
|
||||
witness-public-key-hash = #6.404(key-exp)
|
||||
taproot = #6.409(key-exp)
|
||||
|
||||
threshold = 1
|
||||
|
||||
script-bytes = bytes
|
||||
|
||||
crypto-account = {
|
||||
master-fingerprint: uint32,
|
||||
output-descriptors: [0*10 #6.308(crypto-output)]
|
||||
}
|
||||
|
||||
output-descriptors = 2
|
||||
|
||||
; PSBT
|
||||
psbt = bstr
|
||||
|
||||
; Dev auth
|
||||
|
||||
dev-auth-init = 1
|
||||
dev-auth-device = 2
|
||||
dev-auth-server = 3
|
||||
|
||||
dev-auth-step-type = dev-auth-init / dev-auth-device / dev-auth-server
|
||||
|
||||
dev-auth = {
|
||||
dev-auth-step: dev-auth-step-type,
|
||||
? dev-id: uuid,
|
||||
? first-auth: timestamp,
|
||||
? auth-time: timestamp,
|
||||
? auth-count: uint32,
|
||||
? challenge: bstr .size 32,
|
||||
? auth-sig: bstr .size 64,
|
||||
}
|
||||
|
||||
dev-auth-step = 1
|
||||
dev-id = 2
|
||||
first-auth = 3
|
||||
auth-time = 4
|
||||
auth-count = 5
|
||||
challenge = 6
|
||||
auth-sig = 7
|
||||
|
||||
timestamp = uint .size 4
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
words = ['BYTES', 'CRYPTO-HDKEY', 'CRYPTO-KEYPATH', 'CRYPTO-MULTI-ACCOUNTS', 'CRYPTO-OUTPUT', 'CRYPTO-PSBT', 'DEV-AUTH', 'ETH-SIGN-REQUEST', 'ETH-SIGNATURE', 'FS-DATA', 'FW-UPDATE']
|
||||
words = ['BYTES', 'CRYPTO-ACCOUNT', 'CRYPTO-HDKEY', 'CRYPTO-MULTI-ACCOUNTS', 'CRYPTO-OUTPUT', 'CRYPTO-PSBT', 'DEV-AUTH', 'ETH-SIGN-REQUEST', 'ETH-SIGNATURE', 'FS-DATA', 'FW-UPDATE']
|
||||
|
||||
def hf(w, m):
|
||||
sum = 0
|
||||
|
@ -22,5 +22,20 @@ while repeat:
|
|||
else:
|
||||
lut[h] = w
|
||||
|
||||
print(lut)
|
||||
print(mult)
|
||||
|
||||
print("const char *const ur_type_string[] = {")
|
||||
for i in range(16):
|
||||
if i in lut:
|
||||
print(f" \"{lut[i]}\",")
|
||||
else:
|
||||
print(" NULL,")
|
||||
print("};\n")
|
||||
|
||||
print("typedef enum {")
|
||||
for i in range(16):
|
||||
if i in lut:
|
||||
print(f" {lut[i].replace("-", "_")} = {i},")
|
||||
print(f" UR_ANY_TX = 255")
|
||||
print("} ur_type_t;\n")
|
||||
|
||||
print(f"Multiplier: {mult}")
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
zcbor code -c cddl/eip4527.cddl -d -e -t eth-sign-request eth-signature hd-key crypto-multi-accounts --output-c app/ur/eip4527.c --output-h app/ur/eip4527.h
|
||||
zcbor code -c cddl/ur.cddl -d -e -t ur-part --output-c app/ur/ur_part.c --output-h app/ur/ur_part.h
|
||||
zcbor code -c cddl/auth.cddl -d -e -t dev-auth --output-c app/ur/auth.c --output-h app/ur/auth.h
|
||||
zcbor code -c cddl/btc.cddl -d -e -t psbt --output-c app/ur/btc.c --output-h app/ur/btc.h
|
||||
zcbor code -c cddl/ur.cddl -d -e -t eth-sign-request eth-signature hd-key crypto-multi-accounts crypto-account ur-part dev-auth psbt --output-c app/ur/ur.c --output-h app/ur/ur.h
|
Loading…
Reference in New Issue