|
|
|
@ -20,8 +20,6 @@
|
|
|
|
|
void fsm_msgCipherKeyValue(const CipherKeyValue *msg) {
|
|
|
|
|
CHECK_INITIALIZED
|
|
|
|
|
|
|
|
|
|
CHECK_PARAM(msg->has_key, _("No key provided"));
|
|
|
|
|
CHECK_PARAM(msg->has_value, _("No value provided"));
|
|
|
|
|
CHECK_PARAM(msg->value.size % 16 == 0,
|
|
|
|
|
_("Value length must be a multiple of 16"));
|
|
|
|
|
|
|
|
|
@ -67,7 +65,6 @@ void fsm_msgCipherKeyValue(const CipherKeyValue *msg) {
|
|
|
|
|
aes_cbc_decrypt(msg->value.bytes, resp->value.bytes, msg->value.size,
|
|
|
|
|
data + 32, &ctx);
|
|
|
|
|
}
|
|
|
|
|
resp->has_value = true;
|
|
|
|
|
resp->value.size = msg->value.size;
|
|
|
|
|
msg_write(MessageType_MessageType_CipheredKeyValue, resp);
|
|
|
|
|
layoutHome();
|
|
|
|
@ -89,8 +86,7 @@ void fsm_msgSignIdentity(const SignIdentity *msg) {
|
|
|
|
|
CHECK_PIN
|
|
|
|
|
|
|
|
|
|
uint8_t hash[32];
|
|
|
|
|
if (!msg->has_identity ||
|
|
|
|
|
cryptoIdentityFingerprint(&(msg->identity), hash) == 0) {
|
|
|
|
|
if (cryptoIdentityFingerprint(&(msg->identity), hash) == 0) {
|
|
|
|
|
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid identity"));
|
|
|
|
|
layoutHome();
|
|
|
|
|
return;
|
|
|
|
@ -152,14 +148,12 @@ void fsm_msgSignIdentity(const SignIdentity *msg) {
|
|
|
|
|
node, 0x00, resp->address,
|
|
|
|
|
sizeof(resp->address)); // hardcoded Bitcoin address type
|
|
|
|
|
}
|
|
|
|
|
resp->has_public_key = true;
|
|
|
|
|
resp->public_key.size = 33;
|
|
|
|
|
memcpy(resp->public_key.bytes, node->public_key, 33);
|
|
|
|
|
if (node->public_key[0] == 1) {
|
|
|
|
|
/* ed25519 public key */
|
|
|
|
|
resp->public_key.bytes[0] = 0;
|
|
|
|
|
}
|
|
|
|
|
resp->has_signature = true;
|
|
|
|
|
resp->signature.size = 65;
|
|
|
|
|
msg_write(MessageType_MessageType_SignedIdentity, resp);
|
|
|
|
|
} else {
|
|
|
|
@ -184,8 +178,7 @@ void fsm_msgGetECDHSessionKey(const GetECDHSessionKey *msg) {
|
|
|
|
|
CHECK_PIN
|
|
|
|
|
|
|
|
|
|
uint8_t hash[32];
|
|
|
|
|
if (!msg->has_identity ||
|
|
|
|
|
cryptoIdentityFingerprint(&(msg->identity), hash) == 0) {
|
|
|
|
|
if (cryptoIdentityFingerprint(&(msg->identity), hash) == 0) {
|
|
|
|
|
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid identity"));
|
|
|
|
|
layoutHome();
|
|
|
|
|
return;
|
|
|
|
@ -213,7 +206,6 @@ void fsm_msgGetECDHSessionKey(const GetECDHSessionKey *msg) {
|
|
|
|
|
int result_size = 0;
|
|
|
|
|
if (hdnode_get_shared_key(node, msg->peer_public_key.bytes,
|
|
|
|
|
resp->session_key.bytes, &result_size) == 0) {
|
|
|
|
|
resp->has_session_key = true;
|
|
|
|
|
resp->session_key.size = result_size;
|
|
|
|
|
msg_write(MessageType_MessageType_ECDHSessionKey, resp);
|
|
|
|
|
} else {
|
|
|
|
@ -293,7 +285,6 @@ void fsm_msgCosiSign(const CosiSign *msg) {
|
|
|
|
|
init_rfc6979(node->private_key, nonce, &rng);
|
|
|
|
|
generate_rfc6979(nonce, &rng);
|
|
|
|
|
|
|
|
|
|
resp->has_signature = true;
|
|
|
|
|
resp->signature.size = 32;
|
|
|
|
|
|
|
|
|
|
ed25519_cosi_sign(msg->data.bytes, msg->data.size, node->private_key, nonce,
|
|
|
|
|