1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

downgrade nanopb to LTS version 0.2.9.1

This commit is contained in:
Pavol Rusnak 2014-12-27 14:32:25 +01:00
parent b06780e0a7
commit b5eecb30be
16 changed files with 562 additions and 554 deletions

View File

@ -38,7 +38,7 @@ OBJS += ../trezor-crypto/aes_modes.o
OBJS += ../trezor-qrenc/qr_encode.o
OBJS += protob/pb_common.o
# OBJS += protob/pb_common.o
OBJS += protob/pb_decode.o
OBJS += protob/pb_encode.o
OBJS += protob/messages.pb.o

View File

@ -83,7 +83,7 @@ uint32_t deser_length(const uint8_t *in, uint32_t *out)
return 1 + 8;
}
int cryptoMessageSign(const uint8_t *message, pb_size_t message_len, const uint8_t *privkey, uint8_t *signature)
int cryptoMessageSign(const uint8_t *message, size_t message_len, const uint8_t *privkey, uint8_t *signature)
{
SHA256_CTX ctx;
sha256_Init(&ctx);
@ -101,7 +101,7 @@ int cryptoMessageSign(const uint8_t *message, pb_size_t message_len, const uint8
return 0;
}
int cryptoMessageVerify(const uint8_t *message, pb_size_t message_len, const uint8_t *address_raw, const uint8_t *signature)
int cryptoMessageVerify(const uint8_t *message, size_t message_len, const uint8_t *address_raw, const uint8_t *signature)
{
bignum256 r, s, e;
curve_point cp, cp2;
@ -164,7 +164,7 @@ int cryptoMessageVerify(const uint8_t *message, pb_size_t message_len, const uin
// internal from ecdsa.c
int generate_k_random(bignum256 *k);
int cryptoMessageEncrypt(curve_point *pubkey, const uint8_t *msg, pb_size_t msg_size, bool display_only, uint8_t *nonce, pb_size_t *nonce_len, uint8_t *payload, pb_size_t *payload_len, uint8_t *hmac, pb_size_t *hmac_len, const uint8_t *privkey, const uint8_t *address_raw)
int cryptoMessageEncrypt(curve_point *pubkey, const uint8_t *msg, size_t msg_size, bool display_only, uint8_t *nonce, size_t *nonce_len, uint8_t *payload, size_t *payload_len, uint8_t *hmac, size_t *hmac_len, const uint8_t *privkey, const uint8_t *address_raw)
{
if (privkey && address_raw) { // signing == true
payload[0] = display_only ? 0x81 : 0x01;
@ -216,7 +216,7 @@ int cryptoMessageEncrypt(curve_point *pubkey, const uint8_t *msg, pb_size_t msg_
return 0;
}
int cryptoMessageDecrypt(curve_point *nonce, uint8_t *payload, pb_size_t payload_len, const uint8_t *hmac, pb_size_t hmac_len, const uint8_t *privkey, uint8_t *msg, pb_size_t *msg_len, bool *display_only, bool *signing, uint8_t *address_raw)
int cryptoMessageDecrypt(curve_point *nonce, uint8_t *payload, size_t payload_len, const uint8_t *hmac, size_t hmac_len, const uint8_t *privkey, uint8_t *msg, size_t *msg_len, bool *display_only, bool *signing, uint8_t *address_raw)
{
if (hmac_len != 8) {
return 1;
@ -292,7 +292,7 @@ uint8_t *cryptoHDNodePathToPubkey(const HDNodePathType *hdnodepath)
int cryptoMultisigPubkeyIndex(const MultisigRedeemScriptType *multisig, const uint8_t *pubkey)
{
int i;
size_t i;
for (i = 0; i < multisig->pubkeys_count; i++) {
const uint8_t *node_pubkey = cryptoHDNodePathToPubkey(&(multisig->pubkeys[i]));
if (node_pubkey && memcmp(node_pubkey, pubkey, 33) == 0) {

View File

@ -32,15 +32,15 @@ uint32_t ser_length(uint32_t len, uint8_t *out);
uint32_t ser_length_hash(SHA256_CTX *ctx, uint32_t len);
int cryptoMessageSign(const uint8_t *message, pb_size_t message_len, const uint8_t *privkey, uint8_t *signature);
int cryptoMessageSign(const uint8_t *message, size_t message_len, const uint8_t *privkey, uint8_t *signature);
int cryptoMessageVerify(const uint8_t *message, pb_size_t message_len, const uint8_t *address_raw, const uint8_t *signature);
int cryptoMessageVerify(const uint8_t *message, size_t message_len, const uint8_t *address_raw, const uint8_t *signature);
// ECIES: http://memwallet.info/btcmssgs.html
int cryptoMessageEncrypt(curve_point *pubkey, const uint8_t *msg, pb_size_t msg_size, bool display_only, uint8_t *nonce, pb_size_t *nonce_len, uint8_t *payload, pb_size_t *payload_len, uint8_t *hmac, pb_size_t *hmac_len, const uint8_t *privkey, const uint8_t *address_raw);
int cryptoMessageEncrypt(curve_point *pubkey, const uint8_t *msg, size_t msg_size, bool display_only, uint8_t *nonce, size_t *nonce_len, uint8_t *payload, size_t *payload_len, uint8_t *hmac, size_t *hmac_len, const uint8_t *privkey, const uint8_t *address_raw);
int cryptoMessageDecrypt(curve_point *nonce, uint8_t *payload, pb_size_t payload_len, const uint8_t *hmac, pb_size_t hmac_len, const uint8_t *privkey, uint8_t *msg, pb_size_t *msg_len, bool *display_only, bool *signing, uint8_t *address_raw);
int cryptoMessageDecrypt(curve_point *nonce, uint8_t *payload, size_t payload_len, const uint8_t *hmac, size_t hmac_len, const uint8_t *privkey, uint8_t *msg, size_t *msg_len, bool *display_only, bool *signing, uint8_t *address_raw);
uint8_t *cryptoHDNodePathToPubkey(const HDNodePathType *hdnodepath);

View File

@ -1,12 +1,8 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.3.1 */
/* Generated by nanopb-0.2.9.1 */
#include "messages.pb.h"
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
const char GetAddress_coin_name_default[17] = "Bitcoin";
const char LoadDevice_language_default[17] = "english";
const uint32_t ResetDevice_strength_default = 128u;
@ -24,21 +20,21 @@ const pb_field_t Initialize_fields[1] = {
};
const pb_field_t Features_fields[16] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, Features, vendor, vendor, 0),
PB_FIELD( 2, UINT32 , OPTIONAL, STATIC , OTHER, Features, major_version, vendor, 0),
PB_FIELD( 3, UINT32 , OPTIONAL, STATIC , OTHER, Features, minor_version, major_version, 0),
PB_FIELD( 4, UINT32 , OPTIONAL, STATIC , OTHER, Features, patch_version, minor_version, 0),
PB_FIELD( 5, BOOL , OPTIONAL, STATIC , OTHER, Features, bootloader_mode, patch_version, 0),
PB_FIELD( 6, STRING , OPTIONAL, STATIC , OTHER, Features, device_id, bootloader_mode, 0),
PB_FIELD( 7, BOOL , OPTIONAL, STATIC , OTHER, Features, pin_protection, device_id, 0),
PB_FIELD( 8, BOOL , OPTIONAL, STATIC , OTHER, Features, passphrase_protection, pin_protection, 0),
PB_FIELD( 9, STRING , OPTIONAL, STATIC , OTHER, Features, language, passphrase_protection, 0),
PB_FIELD( 10, STRING , OPTIONAL, STATIC , OTHER, Features, label, language, 0),
PB_FIELD( 11, MESSAGE , REPEATED, STATIC , OTHER, Features, coins, label, &CoinType_fields),
PB_FIELD( 12, BOOL , OPTIONAL, STATIC , OTHER, Features, initialized, coins, 0),
PB_FIELD( 13, BYTES , OPTIONAL, STATIC , OTHER, Features, revision, initialized, 0),
PB_FIELD( 14, BYTES , OPTIONAL, STATIC , OTHER, Features, bootloader_hash, revision, 0),
PB_FIELD( 15, BOOL , OPTIONAL, STATIC , OTHER, Features, imported, bootloader_hash, 0),
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, Features, vendor, vendor, 0),
PB_FIELD2( 2, UINT32 , OPTIONAL, STATIC , OTHER, Features, major_version, vendor, 0),
PB_FIELD2( 3, UINT32 , OPTIONAL, STATIC , OTHER, Features, minor_version, major_version, 0),
PB_FIELD2( 4, UINT32 , OPTIONAL, STATIC , OTHER, Features, patch_version, minor_version, 0),
PB_FIELD2( 5, BOOL , OPTIONAL, STATIC , OTHER, Features, bootloader_mode, patch_version, 0),
PB_FIELD2( 6, STRING , OPTIONAL, STATIC , OTHER, Features, device_id, bootloader_mode, 0),
PB_FIELD2( 7, BOOL , OPTIONAL, STATIC , OTHER, Features, pin_protection, device_id, 0),
PB_FIELD2( 8, BOOL , OPTIONAL, STATIC , OTHER, Features, passphrase_protection, pin_protection, 0),
PB_FIELD2( 9, STRING , OPTIONAL, STATIC , OTHER, Features, language, passphrase_protection, 0),
PB_FIELD2( 10, STRING , OPTIONAL, STATIC , OTHER, Features, label, language, 0),
PB_FIELD2( 11, MESSAGE , REPEATED, STATIC , OTHER, Features, coins, label, &CoinType_fields),
PB_FIELD2( 12, BOOL , OPTIONAL, STATIC , OTHER, Features, initialized, coins, 0),
PB_FIELD2( 13, BYTES , OPTIONAL, STATIC , OTHER, Features, revision, initialized, 0),
PB_FIELD2( 14, BYTES , OPTIONAL, STATIC , OTHER, Features, bootloader_hash, revision, 0),
PB_FIELD2( 15, BOOL , OPTIONAL, STATIC , OTHER, Features, imported, bootloader_hash, 0),
PB_LAST_FIELD
};
@ -47,39 +43,39 @@ const pb_field_t ClearSession_fields[1] = {
};
const pb_field_t ApplySettings_fields[4] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, ApplySettings, language, language, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, ApplySettings, label, language, 0),
PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, ApplySettings, use_passphrase, label, 0),
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, ApplySettings, language, language, 0),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, ApplySettings, label, language, 0),
PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, ApplySettings, use_passphrase, label, 0),
PB_LAST_FIELD
};
const pb_field_t ChangePin_fields[2] = {
PB_FIELD( 1, BOOL , OPTIONAL, STATIC , FIRST, ChangePin, remove, remove, 0),
PB_FIELD2( 1, BOOL , OPTIONAL, STATIC , FIRST, ChangePin, remove, remove, 0),
PB_LAST_FIELD
};
const pb_field_t Ping_fields[5] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, Ping, message, message, 0),
PB_FIELD( 2, BOOL , OPTIONAL, STATIC , OTHER, Ping, button_protection, message, 0),
PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, Ping, pin_protection, button_protection, 0),
PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, Ping, passphrase_protection, pin_protection, 0),
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, Ping, message, message, 0),
PB_FIELD2( 2, BOOL , OPTIONAL, STATIC , OTHER, Ping, button_protection, message, 0),
PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, Ping, pin_protection, button_protection, 0),
PB_FIELD2( 4, BOOL , OPTIONAL, STATIC , OTHER, Ping, passphrase_protection, pin_protection, 0),
PB_LAST_FIELD
};
const pb_field_t Success_fields[2] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, Success, message, message, 0),
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, Success, message, message, 0),
PB_LAST_FIELD
};
const pb_field_t Failure_fields[3] = {
PB_FIELD( 1, ENUM , OPTIONAL, STATIC , FIRST, Failure, code, code, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, Failure, message, code, 0),
PB_FIELD2( 1, ENUM , OPTIONAL, STATIC , FIRST, Failure, code, code, 0),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, Failure, message, code, 0),
PB_LAST_FIELD
};
const pb_field_t ButtonRequest_fields[3] = {
PB_FIELD( 1, ENUM , OPTIONAL, STATIC , FIRST, ButtonRequest, code, code, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, ButtonRequest, data, code, 0),
PB_FIELD2( 1, ENUM , OPTIONAL, STATIC , FIRST, ButtonRequest, code, code, 0),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, ButtonRequest, data, code, 0),
PB_LAST_FIELD
};
@ -88,12 +84,12 @@ const pb_field_t ButtonAck_fields[1] = {
};
const pb_field_t PinMatrixRequest_fields[2] = {
PB_FIELD( 1, ENUM , OPTIONAL, STATIC , FIRST, PinMatrixRequest, type, type, 0),
PB_FIELD2( 1, ENUM , OPTIONAL, STATIC , FIRST, PinMatrixRequest, type, type, 0),
PB_LAST_FIELD
};
const pb_field_t PinMatrixAck_fields[2] = {
PB_FIELD( 1, STRING , REQUIRED, STATIC , FIRST, PinMatrixAck, pin, pin, 0),
PB_FIELD2( 1, STRING , REQUIRED, STATIC , FIRST, PinMatrixAck, pin, pin, 0),
PB_LAST_FIELD
};
@ -106,41 +102,41 @@ const pb_field_t PassphraseRequest_fields[1] = {
};
const pb_field_t PassphraseAck_fields[2] = {
PB_FIELD( 1, STRING , REQUIRED, STATIC , FIRST, PassphraseAck, passphrase, passphrase, 0),
PB_FIELD2( 1, STRING , REQUIRED, STATIC , FIRST, PassphraseAck, passphrase, passphrase, 0),
PB_LAST_FIELD
};
const pb_field_t GetEntropy_fields[2] = {
PB_FIELD( 1, UINT32 , REQUIRED, STATIC , FIRST, GetEntropy, size, size, 0),
PB_FIELD2( 1, UINT32 , REQUIRED, STATIC , FIRST, GetEntropy, size, size, 0),
PB_LAST_FIELD
};
const pb_field_t Entropy_fields[2] = {
PB_FIELD( 1, BYTES , REQUIRED, STATIC , FIRST, Entropy, entropy, entropy, 0),
PB_FIELD2( 1, BYTES , REQUIRED, STATIC , FIRST, Entropy, entropy, entropy, 0),
PB_LAST_FIELD
};
const pb_field_t GetPublicKey_fields[2] = {
PB_FIELD( 1, UINT32 , REPEATED, STATIC , FIRST, GetPublicKey, address_n, address_n, 0),
PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, GetPublicKey, address_n, address_n, 0),
PB_LAST_FIELD
};
const pb_field_t PublicKey_fields[3] = {
PB_FIELD( 1, MESSAGE , REQUIRED, STATIC , FIRST, PublicKey, node, node, &HDNodeType_fields),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, PublicKey, xpub, node, 0),
PB_FIELD2( 1, MESSAGE , REQUIRED, STATIC , FIRST, PublicKey, node, node, &HDNodeType_fields),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, PublicKey, xpub, node, 0),
PB_LAST_FIELD
};
const pb_field_t GetAddress_fields[5] = {
PB_FIELD( 1, UINT32 , REPEATED, STATIC , FIRST, GetAddress, address_n, address_n, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, GetAddress, coin_name, address_n, &GetAddress_coin_name_default),
PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, GetAddress, show_display, coin_name, 0),
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, GetAddress, multisig, show_display, &MultisigRedeemScriptType_fields),
PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, GetAddress, address_n, address_n, 0),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, GetAddress, coin_name, address_n, &GetAddress_coin_name_default),
PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, GetAddress, show_display, coin_name, 0),
PB_FIELD2( 4, MESSAGE , OPTIONAL, STATIC , OTHER, GetAddress, multisig, show_display, &MultisigRedeemScriptType_fields),
PB_LAST_FIELD
};
const pb_field_t Address_fields[2] = {
PB_FIELD( 1, STRING , REQUIRED, STATIC , FIRST, Address, address, address, 0),
PB_FIELD2( 1, STRING , REQUIRED, STATIC , FIRST, Address, address, address, 0),
PB_LAST_FIELD
};
@ -149,23 +145,23 @@ const pb_field_t WipeDevice_fields[1] = {
};
const pb_field_t LoadDevice_fields[8] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, LoadDevice, mnemonic, mnemonic, 0),
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, LoadDevice, node, mnemonic, &HDNodeType_fields),
PB_FIELD( 3, STRING , OPTIONAL, STATIC , OTHER, LoadDevice, pin, node, 0),
PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, LoadDevice, passphrase_protection, pin, 0),
PB_FIELD( 5, STRING , OPTIONAL, STATIC , OTHER, LoadDevice, language, passphrase_protection, &LoadDevice_language_default),
PB_FIELD( 6, STRING , OPTIONAL, STATIC , OTHER, LoadDevice, label, language, 0),
PB_FIELD( 7, BOOL , OPTIONAL, STATIC , OTHER, LoadDevice, skip_checksum, label, 0),
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, LoadDevice, mnemonic, mnemonic, 0),
PB_FIELD2( 2, MESSAGE , OPTIONAL, STATIC , OTHER, LoadDevice, node, mnemonic, &HDNodeType_fields),
PB_FIELD2( 3, STRING , OPTIONAL, STATIC , OTHER, LoadDevice, pin, node, 0),
PB_FIELD2( 4, BOOL , OPTIONAL, STATIC , OTHER, LoadDevice, passphrase_protection, pin, 0),
PB_FIELD2( 5, STRING , OPTIONAL, STATIC , OTHER, LoadDevice, language, passphrase_protection, &LoadDevice_language_default),
PB_FIELD2( 6, STRING , OPTIONAL, STATIC , OTHER, LoadDevice, label, language, 0),
PB_FIELD2( 7, BOOL , OPTIONAL, STATIC , OTHER, LoadDevice, skip_checksum, label, 0),
PB_LAST_FIELD
};
const pb_field_t ResetDevice_fields[7] = {
PB_FIELD( 1, BOOL , OPTIONAL, STATIC , FIRST, ResetDevice, display_random, display_random, 0),
PB_FIELD( 2, UINT32 , OPTIONAL, STATIC , OTHER, ResetDevice, strength, display_random, &ResetDevice_strength_default),
PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, ResetDevice, passphrase_protection, strength, 0),
PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, ResetDevice, pin_protection, passphrase_protection, 0),
PB_FIELD( 5, STRING , OPTIONAL, STATIC , OTHER, ResetDevice, language, pin_protection, &ResetDevice_language_default),
PB_FIELD( 6, STRING , OPTIONAL, STATIC , OTHER, ResetDevice, label, language, 0),
PB_FIELD2( 1, BOOL , OPTIONAL, STATIC , FIRST, ResetDevice, display_random, display_random, 0),
PB_FIELD2( 2, UINT32 , OPTIONAL, STATIC , OTHER, ResetDevice, strength, display_random, &ResetDevice_strength_default),
PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, ResetDevice, passphrase_protection, strength, 0),
PB_FIELD2( 4, BOOL , OPTIONAL, STATIC , OTHER, ResetDevice, pin_protection, passphrase_protection, 0),
PB_FIELD2( 5, STRING , OPTIONAL, STATIC , OTHER, ResetDevice, language, pin_protection, &ResetDevice_language_default),
PB_FIELD2( 6, STRING , OPTIONAL, STATIC , OTHER, ResetDevice, label, language, 0),
PB_LAST_FIELD
};
@ -174,17 +170,17 @@ const pb_field_t EntropyRequest_fields[1] = {
};
const pb_field_t EntropyAck_fields[2] = {
PB_FIELD( 1, BYTES , OPTIONAL, STATIC , FIRST, EntropyAck, entropy, entropy, 0),
PB_FIELD2( 1, BYTES , OPTIONAL, STATIC , FIRST, EntropyAck, entropy, entropy, 0),
PB_LAST_FIELD
};
const pb_field_t RecoveryDevice_fields[7] = {
PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, RecoveryDevice, word_count, word_count, 0),
PB_FIELD( 2, BOOL , OPTIONAL, STATIC , OTHER, RecoveryDevice, passphrase_protection, word_count, 0),
PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, RecoveryDevice, pin_protection, passphrase_protection, 0),
PB_FIELD( 4, STRING , OPTIONAL, STATIC , OTHER, RecoveryDevice, language, pin_protection, &RecoveryDevice_language_default),
PB_FIELD( 5, STRING , OPTIONAL, STATIC , OTHER, RecoveryDevice, label, language, 0),
PB_FIELD( 6, BOOL , OPTIONAL, STATIC , OTHER, RecoveryDevice, enforce_wordlist, label, 0),
PB_FIELD2( 1, UINT32 , OPTIONAL, STATIC , FIRST, RecoveryDevice, word_count, word_count, 0),
PB_FIELD2( 2, BOOL , OPTIONAL, STATIC , OTHER, RecoveryDevice, passphrase_protection, word_count, 0),
PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, RecoveryDevice, pin_protection, passphrase_protection, 0),
PB_FIELD2( 4, STRING , OPTIONAL, STATIC , OTHER, RecoveryDevice, language, pin_protection, &RecoveryDevice_language_default),
PB_FIELD2( 5, STRING , OPTIONAL, STATIC , OTHER, RecoveryDevice, label, language, 0),
PB_FIELD2( 6, BOOL , OPTIONAL, STATIC , OTHER, RecoveryDevice, enforce_wordlist, label, 0),
PB_LAST_FIELD
};
@ -193,111 +189,111 @@ const pb_field_t WordRequest_fields[1] = {
};
const pb_field_t WordAck_fields[2] = {
PB_FIELD( 1, STRING , REQUIRED, STATIC , FIRST, WordAck, word, word, 0),
PB_FIELD2( 1, STRING , REQUIRED, STATIC , FIRST, WordAck, word, word, 0),
PB_LAST_FIELD
};
const pb_field_t SignMessage_fields[4] = {
PB_FIELD( 1, UINT32 , REPEATED, STATIC , FIRST, SignMessage, address_n, address_n, 0),
PB_FIELD( 2, BYTES , REQUIRED, STATIC , OTHER, SignMessage, message, address_n, 0),
PB_FIELD( 3, STRING , OPTIONAL, STATIC , OTHER, SignMessage, coin_name, message, &SignMessage_coin_name_default),
PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, SignMessage, address_n, address_n, 0),
PB_FIELD2( 2, BYTES , REQUIRED, STATIC , OTHER, SignMessage, message, address_n, 0),
PB_FIELD2( 3, STRING , OPTIONAL, STATIC , OTHER, SignMessage, coin_name, message, &SignMessage_coin_name_default),
PB_LAST_FIELD
};
const pb_field_t VerifyMessage_fields[4] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, VerifyMessage, address, address, 0),
PB_FIELD( 2, BYTES , OPTIONAL, STATIC , OTHER, VerifyMessage, signature, address, 0),
PB_FIELD( 3, BYTES , OPTIONAL, STATIC , OTHER, VerifyMessage, message, signature, 0),
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, VerifyMessage, address, address, 0),
PB_FIELD2( 2, BYTES , OPTIONAL, STATIC , OTHER, VerifyMessage, signature, address, 0),
PB_FIELD2( 3, BYTES , OPTIONAL, STATIC , OTHER, VerifyMessage, message, signature, 0),
PB_LAST_FIELD
};
const pb_field_t MessageSignature_fields[3] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, MessageSignature, address, address, 0),
PB_FIELD( 2, BYTES , OPTIONAL, STATIC , OTHER, MessageSignature, signature, address, 0),
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, MessageSignature, address, address, 0),
PB_FIELD2( 2, BYTES , OPTIONAL, STATIC , OTHER, MessageSignature, signature, address, 0),
PB_LAST_FIELD
};
const pb_field_t EncryptMessage_fields[6] = {
PB_FIELD( 1, BYTES , OPTIONAL, STATIC , FIRST, EncryptMessage, pubkey, pubkey, 0),
PB_FIELD( 2, BYTES , OPTIONAL, STATIC , OTHER, EncryptMessage, message, pubkey, 0),
PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, EncryptMessage, display_only, message, 0),
PB_FIELD( 4, UINT32 , REPEATED, STATIC , OTHER, EncryptMessage, address_n, display_only, 0),
PB_FIELD( 5, STRING , OPTIONAL, STATIC , OTHER, EncryptMessage, coin_name, address_n, &EncryptMessage_coin_name_default),
PB_FIELD2( 1, BYTES , OPTIONAL, STATIC , FIRST, EncryptMessage, pubkey, pubkey, 0),
PB_FIELD2( 2, BYTES , OPTIONAL, STATIC , OTHER, EncryptMessage, message, pubkey, 0),
PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, EncryptMessage, display_only, message, 0),
PB_FIELD2( 4, UINT32 , REPEATED, STATIC , OTHER, EncryptMessage, address_n, display_only, 0),
PB_FIELD2( 5, STRING , OPTIONAL, STATIC , OTHER, EncryptMessage, coin_name, address_n, &EncryptMessage_coin_name_default),
PB_LAST_FIELD
};
const pb_field_t EncryptedMessage_fields[4] = {
PB_FIELD( 1, BYTES , OPTIONAL, STATIC , FIRST, EncryptedMessage, nonce, nonce, 0),
PB_FIELD( 2, BYTES , OPTIONAL, STATIC , OTHER, EncryptedMessage, message, nonce, 0),
PB_FIELD( 3, BYTES , OPTIONAL, STATIC , OTHER, EncryptedMessage, hmac, message, 0),
PB_FIELD2( 1, BYTES , OPTIONAL, STATIC , FIRST, EncryptedMessage, nonce, nonce, 0),
PB_FIELD2( 2, BYTES , OPTIONAL, STATIC , OTHER, EncryptedMessage, message, nonce, 0),
PB_FIELD2( 3, BYTES , OPTIONAL, STATIC , OTHER, EncryptedMessage, hmac, message, 0),
PB_LAST_FIELD
};
const pb_field_t DecryptMessage_fields[5] = {
PB_FIELD( 1, UINT32 , REPEATED, STATIC , FIRST, DecryptMessage, address_n, address_n, 0),
PB_FIELD( 2, BYTES , OPTIONAL, STATIC , OTHER, DecryptMessage, nonce, address_n, 0),
PB_FIELD( 3, BYTES , OPTIONAL, STATIC , OTHER, DecryptMessage, message, nonce, 0),
PB_FIELD( 4, BYTES , OPTIONAL, STATIC , OTHER, DecryptMessage, hmac, message, 0),
PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, DecryptMessage, address_n, address_n, 0),
PB_FIELD2( 2, BYTES , OPTIONAL, STATIC , OTHER, DecryptMessage, nonce, address_n, 0),
PB_FIELD2( 3, BYTES , OPTIONAL, STATIC , OTHER, DecryptMessage, message, nonce, 0),
PB_FIELD2( 4, BYTES , OPTIONAL, STATIC , OTHER, DecryptMessage, hmac, message, 0),
PB_LAST_FIELD
};
const pb_field_t DecryptedMessage_fields[3] = {
PB_FIELD( 1, BYTES , OPTIONAL, STATIC , FIRST, DecryptedMessage, message, message, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, DecryptedMessage, address, message, 0),
PB_FIELD2( 1, BYTES , OPTIONAL, STATIC , FIRST, DecryptedMessage, message, message, 0),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, DecryptedMessage, address, message, 0),
PB_LAST_FIELD
};
const pb_field_t CipherKeyValue_fields[7] = {
PB_FIELD( 1, UINT32 , REPEATED, STATIC , FIRST, CipherKeyValue, address_n, address_n, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, CipherKeyValue, key, address_n, 0),
PB_FIELD( 3, BYTES , OPTIONAL, STATIC , OTHER, CipherKeyValue, value, key, 0),
PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, CipherKeyValue, encrypt, value, 0),
PB_FIELD( 5, BOOL , OPTIONAL, STATIC , OTHER, CipherKeyValue, ask_on_encrypt, encrypt, 0),
PB_FIELD( 6, BOOL , OPTIONAL, STATIC , OTHER, CipherKeyValue, ask_on_decrypt, ask_on_encrypt, 0),
PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, CipherKeyValue, address_n, address_n, 0),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, CipherKeyValue, key, address_n, 0),
PB_FIELD2( 3, BYTES , OPTIONAL, STATIC , OTHER, CipherKeyValue, value, key, 0),
PB_FIELD2( 4, BOOL , OPTIONAL, STATIC , OTHER, CipherKeyValue, encrypt, value, 0),
PB_FIELD2( 5, BOOL , OPTIONAL, STATIC , OTHER, CipherKeyValue, ask_on_encrypt, encrypt, 0),
PB_FIELD2( 6, BOOL , OPTIONAL, STATIC , OTHER, CipherKeyValue, ask_on_decrypt, ask_on_encrypt, 0),
PB_LAST_FIELD
};
const pb_field_t CipheredKeyValue_fields[2] = {
PB_FIELD( 1, BYTES , OPTIONAL, STATIC , FIRST, CipheredKeyValue, value, value, 0),
PB_FIELD2( 1, BYTES , OPTIONAL, STATIC , FIRST, CipheredKeyValue, value, value, 0),
PB_LAST_FIELD
};
const pb_field_t EstimateTxSize_fields[4] = {
PB_FIELD( 1, UINT32 , REQUIRED, STATIC , FIRST, EstimateTxSize, outputs_count, outputs_count, 0),
PB_FIELD( 2, UINT32 , REQUIRED, STATIC , OTHER, EstimateTxSize, inputs_count, outputs_count, 0),
PB_FIELD( 3, STRING , OPTIONAL, STATIC , OTHER, EstimateTxSize, coin_name, inputs_count, &EstimateTxSize_coin_name_default),
PB_FIELD2( 1, UINT32 , REQUIRED, STATIC , FIRST, EstimateTxSize, outputs_count, outputs_count, 0),
PB_FIELD2( 2, UINT32 , REQUIRED, STATIC , OTHER, EstimateTxSize, inputs_count, outputs_count, 0),
PB_FIELD2( 3, STRING , OPTIONAL, STATIC , OTHER, EstimateTxSize, coin_name, inputs_count, &EstimateTxSize_coin_name_default),
PB_LAST_FIELD
};
const pb_field_t TxSize_fields[2] = {
PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, TxSize, tx_size, tx_size, 0),
PB_FIELD2( 1, UINT32 , OPTIONAL, STATIC , FIRST, TxSize, tx_size, tx_size, 0),
PB_LAST_FIELD
};
const pb_field_t SignTx_fields[4] = {
PB_FIELD( 1, UINT32 , REQUIRED, STATIC , FIRST, SignTx, outputs_count, outputs_count, 0),
PB_FIELD( 2, UINT32 , REQUIRED, STATIC , OTHER, SignTx, inputs_count, outputs_count, 0),
PB_FIELD( 3, STRING , OPTIONAL, STATIC , OTHER, SignTx, coin_name, inputs_count, &SignTx_coin_name_default),
PB_FIELD2( 1, UINT32 , REQUIRED, STATIC , FIRST, SignTx, outputs_count, outputs_count, 0),
PB_FIELD2( 2, UINT32 , REQUIRED, STATIC , OTHER, SignTx, inputs_count, outputs_count, 0),
PB_FIELD2( 3, STRING , OPTIONAL, STATIC , OTHER, SignTx, coin_name, inputs_count, &SignTx_coin_name_default),
PB_LAST_FIELD
};
const pb_field_t SimpleSignTx_fields[5] = {
PB_FIELD( 1, MESSAGE , REPEATED, STATIC , FIRST, SimpleSignTx, inputs, inputs, &TxInputType_fields),
PB_FIELD( 2, MESSAGE , REPEATED, STATIC , OTHER, SimpleSignTx, outputs, inputs, &TxOutputType_fields),
PB_FIELD( 3, MESSAGE , REPEATED, STATIC , OTHER, SimpleSignTx, transactions, outputs, &TransactionType_fields),
PB_FIELD( 4, STRING , OPTIONAL, STATIC , OTHER, SimpleSignTx, coin_name, transactions, &SimpleSignTx_coin_name_default),
PB_FIELD2( 1, MESSAGE , REPEATED, STATIC , FIRST, SimpleSignTx, inputs, inputs, &TxInputType_fields),
PB_FIELD2( 2, MESSAGE , REPEATED, STATIC , OTHER, SimpleSignTx, outputs, inputs, &TxOutputType_fields),
PB_FIELD2( 3, MESSAGE , REPEATED, STATIC , OTHER, SimpleSignTx, transactions, outputs, &TransactionType_fields),
PB_FIELD2( 4, STRING , OPTIONAL, STATIC , OTHER, SimpleSignTx, coin_name, transactions, &SimpleSignTx_coin_name_default),
PB_LAST_FIELD
};
const pb_field_t TxRequest_fields[4] = {
PB_FIELD( 1, ENUM , OPTIONAL, STATIC , FIRST, TxRequest, request_type, request_type, 0),
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, TxRequest, details, request_type, &TxRequestDetailsType_fields),
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, TxRequest, serialized, details, &TxRequestSerializedType_fields),
PB_FIELD2( 1, ENUM , OPTIONAL, STATIC , FIRST, TxRequest, request_type, request_type, 0),
PB_FIELD2( 2, MESSAGE , OPTIONAL, STATIC , OTHER, TxRequest, details, request_type, &TxRequestDetailsType_fields),
PB_FIELD2( 3, MESSAGE , OPTIONAL, STATIC , OTHER, TxRequest, serialized, details, &TxRequestSerializedType_fields),
PB_LAST_FIELD
};
const pb_field_t TxAck_fields[2] = {
PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, TxAck, tx, tx, &TransactionType_fields),
PB_FIELD2( 1, MESSAGE , OPTIONAL, STATIC , FIRST, TxAck, tx, tx, &TransactionType_fields),
PB_LAST_FIELD
};
@ -306,12 +302,12 @@ const pb_field_t FirmwareErase_fields[1] = {
};
const pb_field_t FirmwareUpload_fields[2] = {
PB_FIELD( 1, BYTES , REQUIRED, STATIC , FIRST, FirmwareUpload, payload, payload, 0),
PB_FIELD2( 1, BYTES , REQUIRED, STATIC , FIRST, FirmwareUpload, payload, payload, 0),
PB_LAST_FIELD
};
const pb_field_t DebugLinkDecision_fields[2] = {
PB_FIELD( 1, BOOL , REQUIRED, STATIC , FIRST, DebugLinkDecision, yes_no, yes_no, 0),
PB_FIELD2( 1, BOOL , REQUIRED, STATIC , FIRST, DebugLinkDecision, yes_no, yes_no, 0),
PB_LAST_FIELD
};
@ -320,16 +316,16 @@ const pb_field_t DebugLinkGetState_fields[1] = {
};
const pb_field_t DebugLinkState_fields[11] = {
PB_FIELD( 1, BYTES , OPTIONAL, STATIC , FIRST, DebugLinkState, layout, layout, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, pin, layout, 0),
PB_FIELD( 3, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, matrix, pin, 0),
PB_FIELD( 4, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, mnemonic, matrix, 0),
PB_FIELD( 5, MESSAGE , OPTIONAL, STATIC , OTHER, DebugLinkState, node, mnemonic, &HDNodeType_fields),
PB_FIELD( 6, BOOL , OPTIONAL, STATIC , OTHER, DebugLinkState, passphrase_protection, node, 0),
PB_FIELD( 7, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, reset_word, passphrase_protection, 0),
PB_FIELD( 8, BYTES , OPTIONAL, STATIC , OTHER, DebugLinkState, reset_entropy, reset_word, 0),
PB_FIELD( 9, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, recovery_fake_word, reset_entropy, 0),
PB_FIELD( 10, UINT32 , OPTIONAL, STATIC , OTHER, DebugLinkState, recovery_word_pos, recovery_fake_word, 0),
PB_FIELD2( 1, BYTES , OPTIONAL, STATIC , FIRST, DebugLinkState, layout, layout, 0),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, pin, layout, 0),
PB_FIELD2( 3, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, matrix, pin, 0),
PB_FIELD2( 4, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, mnemonic, matrix, 0),
PB_FIELD2( 5, MESSAGE , OPTIONAL, STATIC , OTHER, DebugLinkState, node, mnemonic, &HDNodeType_fields),
PB_FIELD2( 6, BOOL , OPTIONAL, STATIC , OTHER, DebugLinkState, passphrase_protection, node, 0),
PB_FIELD2( 7, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, reset_word, passphrase_protection, 0),
PB_FIELD2( 8, BYTES , OPTIONAL, STATIC , OTHER, DebugLinkState, reset_entropy, reset_word, 0),
PB_FIELD2( 9, STRING , OPTIONAL, STATIC , OTHER, DebugLinkState, recovery_fake_word, reset_entropy, 0),
PB_FIELD2( 10, UINT32 , OPTIONAL, STATIC , OTHER, DebugLinkState, recovery_word_pos, recovery_fake_word, 0),
PB_LAST_FIELD
};
@ -338,9 +334,9 @@ const pb_field_t DebugLinkStop_fields[1] = {
};
const pb_field_t DebugLinkLog_fields[4] = {
PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, DebugLinkLog, level, level, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, DebugLinkLog, bucket, level, 0),
PB_FIELD( 3, STRING , OPTIONAL, STATIC , OTHER, DebugLinkLog, text, bucket, 0),
PB_FIELD2( 1, UINT32 , OPTIONAL, STATIC , FIRST, DebugLinkLog, level, level, 0),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, DebugLinkLog, bucket, level, 0),
PB_FIELD2( 3, STRING , OPTIONAL, STATIC , OTHER, DebugLinkLog, text, bucket, 0),
PB_LAST_FIELD
};
@ -354,7 +350,7 @@ const pb_field_t DebugLinkLog_fields[4] = {
* numbers or field sizes that are larger than what can fit in 8 or 16 bit
* field descriptors.
*/
PB_STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(GetAddress, multisig) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(SimpleSignTx, inputs[0]) < 65536 && pb_membersize(SimpleSignTx, outputs[0]) < 65536 && pb_membersize(SimpleSignTx, transactions[0]) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(DebugLinkState, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_Features_ClearSession_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_Address_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_EncryptMessage_EncryptedMessage_DecryptMessage_DecryptedMessage_CipherKeyValue_CipheredKeyValue_EstimateTxSize_TxSize_SignTx_SimpleSignTx_TxRequest_TxAck_FirmwareErase_FirmwareUpload_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog)
STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(GetAddress, multisig) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(SimpleSignTx, inputs[0]) < 65536 && pb_membersize(SimpleSignTx, outputs[0]) < 65536 && pb_membersize(SimpleSignTx, transactions[0]) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(DebugLinkState, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_Features_ClearSession_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_Address_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_EncryptMessage_EncryptedMessage_DecryptMessage_DecryptedMessage_CipherKeyValue_CipheredKeyValue_EstimateTxSize_TxSize_SignTx_SimpleSignTx_TxRequest_TxAck_FirmwareErase_FirmwareUpload_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog)
#endif
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)

View File

@ -1,15 +1,11 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.1 */
/* Generated by nanopb-0.2.9.1 */
#ifndef PB_MESSAGES_PB_H_INCLUDED
#define PB_MESSAGES_PB_H_INCLUDED
#ifndef _PB_MESSAGES_PB_H_
#define _PB_MESSAGES_PB_H_
#include "pb.h"
#include "types.pb.h"
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -139,10 +135,13 @@ typedef struct _ChangePin {
bool remove;
} ChangePin;
typedef PB_BYTES_ARRAY_T(1024) CipherKeyValue_value_t;
typedef struct {
size_t size;
uint8_t bytes[1024];
} CipherKeyValue_value_t;
typedef struct _CipherKeyValue {
pb_size_t address_n_count;
size_t address_n_count;
uint32_t address_n[8];
bool has_key;
char key[256];
@ -156,7 +155,10 @@ typedef struct _CipherKeyValue {
bool ask_on_decrypt;
} CipherKeyValue;
typedef PB_BYTES_ARRAY_T(1024) CipheredKeyValue_value_t;
typedef struct {
size_t size;
uint8_t bytes[1024];
} CipheredKeyValue_value_t;
typedef struct _CipheredKeyValue {
bool has_value;
@ -176,9 +178,15 @@ typedef struct _DebugLinkLog {
char text[256];
} DebugLinkLog;
typedef PB_BYTES_ARRAY_T(1024) DebugLinkState_layout_t;
typedef struct {
size_t size;
uint8_t bytes[1024];
} DebugLinkState_layout_t;
typedef PB_BYTES_ARRAY_T(128) DebugLinkState_reset_entropy_t;
typedef struct {
size_t size;
uint8_t bytes[128];
} DebugLinkState_reset_entropy_t;
typedef struct _DebugLinkState {
bool has_layout;
@ -203,14 +211,23 @@ typedef struct _DebugLinkState {
uint32_t recovery_word_pos;
} DebugLinkState;
typedef PB_BYTES_ARRAY_T(33) DecryptMessage_nonce_t;
typedef struct {
size_t size;
uint8_t bytes[33];
} DecryptMessage_nonce_t;
typedef PB_BYTES_ARRAY_T(1120) DecryptMessage_message_t;
typedef struct {
size_t size;
uint8_t bytes[1120];
} DecryptMessage_message_t;
typedef PB_BYTES_ARRAY_T(8) DecryptMessage_hmac_t;
typedef struct {
size_t size;
uint8_t bytes[8];
} DecryptMessage_hmac_t;
typedef struct _DecryptMessage {
pb_size_t address_n_count;
size_t address_n_count;
uint32_t address_n[8];
bool has_nonce;
DecryptMessage_nonce_t nonce;
@ -220,7 +237,10 @@ typedef struct _DecryptMessage {
DecryptMessage_hmac_t hmac;
} DecryptMessage;
typedef PB_BYTES_ARRAY_T(1024) DecryptedMessage_message_t;
typedef struct {
size_t size;
uint8_t bytes[1024];
} DecryptedMessage_message_t;
typedef struct _DecryptedMessage {
bool has_message;
@ -229,9 +249,15 @@ typedef struct _DecryptedMessage {
char address[36];
} DecryptedMessage;
typedef PB_BYTES_ARRAY_T(33) EncryptMessage_pubkey_t;
typedef struct {
size_t size;
uint8_t bytes[33];
} EncryptMessage_pubkey_t;
typedef PB_BYTES_ARRAY_T(1024) EncryptMessage_message_t;
typedef struct {
size_t size;
uint8_t bytes[1024];
} EncryptMessage_message_t;
typedef struct _EncryptMessage {
bool has_pubkey;
@ -240,17 +266,26 @@ typedef struct _EncryptMessage {
EncryptMessage_message_t message;
bool has_display_only;
bool display_only;
pb_size_t address_n_count;
size_t address_n_count;
uint32_t address_n[8];
bool has_coin_name;
char coin_name[17];
} EncryptMessage;
typedef PB_BYTES_ARRAY_T(33) EncryptedMessage_nonce_t;
typedef struct {
size_t size;
uint8_t bytes[33];
} EncryptedMessage_nonce_t;
typedef PB_BYTES_ARRAY_T(1120) EncryptedMessage_message_t;
typedef struct {
size_t size;
uint8_t bytes[1120];
} EncryptedMessage_message_t;
typedef PB_BYTES_ARRAY_T(8) EncryptedMessage_hmac_t;
typedef struct {
size_t size;
uint8_t bytes[8];
} EncryptedMessage_hmac_t;
typedef struct _EncryptedMessage {
bool has_nonce;
@ -261,13 +296,19 @@ typedef struct _EncryptedMessage {
EncryptedMessage_hmac_t hmac;
} EncryptedMessage;
typedef PB_BYTES_ARRAY_T(1024) Entropy_entropy_t;
typedef struct {
size_t size;
uint8_t bytes[1024];
} Entropy_entropy_t;
typedef struct _Entropy {
Entropy_entropy_t entropy;
} Entropy;
typedef PB_BYTES_ARRAY_T(128) EntropyAck_entropy_t;
typedef struct {
size_t size;
uint8_t bytes[128];
} EntropyAck_entropy_t;
typedef struct _EntropyAck {
bool has_entropy;
@ -288,9 +329,15 @@ typedef struct _Failure {
char message[256];
} Failure;
typedef PB_BYTES_ARRAY_T(20) Features_revision_t;
typedef struct {
size_t size;
uint8_t bytes[20];
} Features_revision_t;
typedef PB_BYTES_ARRAY_T(32) Features_bootloader_hash_t;
typedef struct {
size_t size;
uint8_t bytes[32];
} Features_bootloader_hash_t;
typedef struct _Features {
bool has_vendor;
@ -313,7 +360,7 @@ typedef struct _Features {
char language[17];
bool has_label;
char label[33];
pb_size_t coins_count;
size_t coins_count;
CoinType coins[5];
bool has_initialized;
bool initialized;
@ -325,14 +372,17 @@ typedef struct _Features {
bool imported;
} Features;
typedef PB_BYTES_ARRAY_T(0) FirmwareUpload_payload_t;
typedef struct {
size_t size;
uint8_t bytes[0];
} FirmwareUpload_payload_t;
typedef struct _FirmwareUpload {
FirmwareUpload_payload_t payload;
} FirmwareUpload;
typedef struct _GetAddress {
pb_size_t address_n_count;
size_t address_n_count;
uint32_t address_n[8];
bool has_coin_name;
char coin_name[17];
@ -347,7 +397,7 @@ typedef struct _GetEntropy {
} GetEntropy;
typedef struct _GetPublicKey {
pb_size_t address_n_count;
size_t address_n_count;
uint32_t address_n[8];
} GetPublicKey;
@ -368,7 +418,10 @@ typedef struct _LoadDevice {
bool skip_checksum;
} LoadDevice;
typedef PB_BYTES_ARRAY_T(65) MessageSignature_signature_t;
typedef struct {
size_t size;
uint8_t bytes[65];
} MessageSignature_signature_t;
typedef struct _MessageSignature {
bool has_address;
@ -437,10 +490,13 @@ typedef struct _ResetDevice {
char label[33];
} ResetDevice;
typedef PB_BYTES_ARRAY_T(1024) SignMessage_message_t;
typedef struct {
size_t size;
uint8_t bytes[1024];
} SignMessage_message_t;
typedef struct _SignMessage {
pb_size_t address_n_count;
size_t address_n_count;
uint32_t address_n[8];
SignMessage_message_t message;
bool has_coin_name;
@ -455,11 +511,11 @@ typedef struct _SignTx {
} SignTx;
typedef struct _SimpleSignTx {
pb_size_t inputs_count;
size_t inputs_count;
TxInputType inputs[0];
pb_size_t outputs_count;
size_t outputs_count;
TxOutputType outputs[0];
pb_size_t transactions_count;
size_t transactions_count;
TransactionType transactions[0];
bool has_coin_name;
char coin_name[17];
@ -489,9 +545,15 @@ typedef struct _TxSize {
uint32_t tx_size;
} TxSize;
typedef PB_BYTES_ARRAY_T(65) VerifyMessage_signature_t;
typedef struct {
size_t size;
uint8_t bytes[65];
} VerifyMessage_signature_t;
typedef PB_BYTES_ARRAY_T(1024) VerifyMessage_message_t;
typedef struct {
size_t size;
uint8_t bytes[1024];
} VerifyMessage_message_t;
typedef struct _VerifyMessage {
bool has_address;

View File

@ -2,8 +2,8 @@
* stuff. For the high-level interface, see pb_encode.h and pb_decode.h.
*/
#ifndef PB_H_INCLUDED
#define PB_H_INCLUDED
#ifndef _PB_H_
#define _PB_H_
/*****************************************************************
* Nanopb compilation time options. You can change these here by *
@ -46,7 +46,7 @@
/* Version of the nanopb library. Just in case you want to check it in
* your own program. */
#define NANOPB_VERSION nanopb-0.3.1
#define NANOPB_VERSION nanopb-0.2.9.1
/* Include all the system headers needed by nanopb. You will need the
* definitions of the following:
@ -98,27 +98,23 @@
#endif
/* Handly macro for suppressing unreferenced-parameter compiler warnings. */
#ifndef PB_UNUSED
#define PB_UNUSED(x) (void)(x)
#ifndef UNUSED
#define UNUSED(x) (void)(x)
#endif
/* Compile-time assertion, used for checking compatible compilation options.
* If this does not work properly on your compiler, use
* #define PB_NO_STATIC_ASSERT to disable it.
* If this does not work properly on your compiler, use #define STATIC_ASSERT
* to disable it.
*
* But before doing that, check carefully the error message / place where it
* comes from to see if the error has a real cause. Unfortunately the error
* message is not always very clear to read, but you can see the reason better
* in the place where the PB_STATIC_ASSERT macro was called.
* in the place where the STATIC_ASSERT macro was called.
*/
#ifndef PB_NO_STATIC_ASSERT
#ifndef PB_STATIC_ASSERT
#define PB_STATIC_ASSERT(COND,MSG) typedef char PB_STATIC_ASSERT_MSG(MSG, __LINE__, __COUNTER__)[(COND)?1:-1];
#define PB_STATIC_ASSERT_MSG(MSG, LINE, COUNTER) PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER)
#define PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER) pb_static_assertion_##MSG##LINE##COUNTER
#endif
#else
#define PB_STATIC_ASSERT(COND,MSG)
#ifndef STATIC_ASSERT
#define STATIC_ASSERT(COND,MSG) typedef char STATIC_ASSERT_MSG(MSG, __LINE__, __COUNTER__)[(COND)?1:-1];
#define STATIC_ASSERT_MSG(MSG, LINE, COUNTER) STATIC_ASSERT_MSG_(MSG, LINE, COUNTER)
#define STATIC_ASSERT_MSG_(MSG, LINE, COUNTER) static_assertion_##MSG##LINE##COUNTER
#endif
/* Number of required fields to keep track of. */
@ -191,15 +187,12 @@ typedef uint8_t pb_type_t;
* and array counts.
*/
#if defined(PB_FIELD_32BIT)
#define PB_SIZE_MAX ((uint32_t)-1)
typedef uint32_t pb_size_t;
typedef int32_t pb_ssize_t;
#elif defined(PB_FIELD_16BIT)
#define PB_SIZE_MAX ((uint16_t)-1)
typedef uint16_t pb_size_t;
typedef int16_t pb_ssize_t;
#else
#define PB_SIZE_MAX ((uint8_t)-1)
typedef uint8_t pb_size_t;
typedef int8_t pb_ssize_t;
#endif
@ -213,8 +206,8 @@ typedef uint8_t pb_type_t;
* PB_FIELD_32BIT.
*/
PB_PACKED_STRUCT_START
typedef struct pb_field_s pb_field_t;
struct pb_field_s {
typedef struct _pb_field_t pb_field_t;
struct _pb_field_t {
pb_size_t tag;
pb_type_t type;
pb_size_t data_offset; /* Offset of field data, relative to previous field. */
@ -235,27 +228,27 @@ PB_PACKED_STRUCT_END
* If you get errors here, it probably means that your stdint.h is not
* correct for your platform.
*/
PB_STATIC_ASSERT(sizeof(int8_t) == 1, INT8_T_WRONG_SIZE)
PB_STATIC_ASSERT(sizeof(uint8_t) == 1, UINT8_T_WRONG_SIZE)
PB_STATIC_ASSERT(sizeof(int16_t) == 2, INT16_T_WRONG_SIZE)
PB_STATIC_ASSERT(sizeof(uint16_t) == 2, UINT16_T_WRONG_SIZE)
PB_STATIC_ASSERT(sizeof(int32_t) == 4, INT32_T_WRONG_SIZE)
PB_STATIC_ASSERT(sizeof(uint32_t) == 4, UINT32_T_WRONG_SIZE)
PB_STATIC_ASSERT(sizeof(int64_t) == 8, INT64_T_WRONG_SIZE)
PB_STATIC_ASSERT(sizeof(uint64_t) == 8, UINT64_T_WRONG_SIZE)
STATIC_ASSERT(sizeof(int8_t) == 1, INT8_T_WRONG_SIZE)
STATIC_ASSERT(sizeof(uint8_t) == 1, UINT8_T_WRONG_SIZE)
STATIC_ASSERT(sizeof(int16_t) == 2, INT16_T_WRONG_SIZE)
STATIC_ASSERT(sizeof(uint16_t) == 2, UINT16_T_WRONG_SIZE)
STATIC_ASSERT(sizeof(int32_t) == 4, INT32_T_WRONG_SIZE)
STATIC_ASSERT(sizeof(uint32_t) == 4, UINT32_T_WRONG_SIZE)
STATIC_ASSERT(sizeof(int64_t) == 8, INT64_T_WRONG_SIZE)
STATIC_ASSERT(sizeof(uint64_t) == 8, UINT64_T_WRONG_SIZE)
/* This structure is used for 'bytes' arrays.
* It has the number of bytes in the beginning, and after that an array.
* Note that actual structs used will have a different length of bytes array.
*/
#define PB_BYTES_ARRAY_T(n) struct { pb_size_t size; uint8_t bytes[n]; }
#define PB_BYTES_ARRAY_T(n) struct { size_t size; uint8_t bytes[n]; }
#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
struct pb_bytes_array_s {
pb_size_t size;
struct _pb_bytes_array_t {
size_t size;
uint8_t bytes[1];
};
typedef struct pb_bytes_array_s pb_bytes_array_t;
typedef struct _pb_bytes_array_t pb_bytes_array_t;
/* This structure is used for giving the callback function.
* It is stored in the message structure and filled in by the method that
@ -275,10 +268,10 @@ typedef struct pb_bytes_array_s pb_bytes_array_t;
*
* The callback can be null if you want to skip a field.
*/
typedef struct pb_istream_s pb_istream_t;
typedef struct pb_ostream_s pb_ostream_t;
typedef struct pb_callback_s pb_callback_t;
struct pb_callback_s {
typedef struct _pb_istream_t pb_istream_t;
typedef struct _pb_ostream_t pb_ostream_t;
typedef struct _pb_callback_t pb_callback_t;
struct _pb_callback_t {
#ifdef PB_OLD_CALLBACK_STYLE
/* Deprecated since nanopb-0.2.1 */
union {
@ -311,9 +304,9 @@ typedef enum {
* if you want to catch all unknown fields, you can also create a custom
* pb_extension_type_t with your own callback.
*/
typedef struct pb_extension_type_s pb_extension_type_t;
typedef struct pb_extension_s pb_extension_t;
struct pb_extension_type_s {
typedef struct _pb_extension_type_t pb_extension_type_t;
typedef struct _pb_extension_t pb_extension_t;
struct _pb_extension_type_t {
/* Called for each unknown field in the message.
* If you handle the field, read off all of its data and return true.
* If you do not handle the field, do not read anything and return true.
@ -335,7 +328,7 @@ struct pb_extension_type_s {
const void *arg;
};
struct pb_extension_s {
struct _pb_extension_t {
/* Type describing the extension field. Usually you'll initialize
* this to a pointer to the automatically generated structure. */
const pb_extension_type_t *type;
@ -365,9 +358,6 @@ struct pb_extension_s {
# endif
#endif
/* This is used to inform about need to regenerate .pb.h/.pb.c files. */
#define PB_PROTO_HEADER_VERSION 30
/* These macros are used to declare pb_field_t's in the constant array. */
/* Size of a structure member, in bytes. */
#define pb_membersize(st, m) (sizeof ((st*)0)->m)
@ -479,15 +469,26 @@ struct pb_extension_s {
* SINT32, SINT64, STRING, UINT32, UINT64 or EXTENSION
* - Field rules: REQUIRED, OPTIONAL or REPEATED
* - Allocation: STATIC or CALLBACK
* - Placement: FIRST or OTHER, depending on if this is the first field in structure.
* - Message name
* - Field name
* - Previous field name (or field name again for first field)
* - Pointer to default value or submsg fields.
*/
#define PB_FIELD(tag, type, rules, allocation, placement, message, field, prevfield, ptr) \
PB_ ## rules ## _ ## allocation(tag, message, field, \
#define PB_FIELD(tag, type, rules, allocation, message, field, prevfield, ptr) \
PB_ ## rules ## _ ## allocation(tag, message, field, \
PB_DATAOFFSET_CHOOSE(message, field, prevfield), \
PB_LTYPE_MAP_ ## type, ptr)
/* This is a new version of the macro used by nanopb generator from
* version 0.2.3 onwards. It avoids the use of a ternary expression in
* the initialization, which confused some compilers.
*
* - Placement: FIRST or OTHER, depending on if this is the first field in structure.
*
*/
#define PB_FIELD2(tag, type, rules, allocation, placement, message, field, prevfield, ptr) \
PB_ ## rules ## _ ## allocation(tag, message, field, \
PB_DATAOFFSET_ ## placement(message, field, prevfield), \
PB_LTYPE_MAP_ ## type, ptr)
@ -501,7 +502,7 @@ struct pb_extension_s {
#ifdef PB_NO_ERRMSG
#define PB_RETURN_ERROR(stream,msg) \
do {\
PB_UNUSED(stream); \
UNUSED(stream); \
return false; \
} while(0)
#define PB_GET_ERROR(stream) "(errmsg disabled)"

View File

@ -1,90 +0,0 @@
/* pb_common.c: Common support functions for pb_encode.c and pb_decode.c.
*
* 2014 Petteri Aimonen <jpa@kapsi.fi>
*/
#include "pb_common.h"
bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct)
{
iter->start = fields;
iter->pos = fields;
iter->required_field_index = 0;
iter->dest_struct = dest_struct;
iter->pData = (char*)dest_struct + iter->pos->data_offset;
iter->pSize = (char*)iter->pData + iter->pos->size_offset;
return (iter->pos->tag != 0);
}
bool pb_field_iter_next(pb_field_iter_t *iter)
{
const pb_field_t *prev_field = iter->pos;
if (prev_field->tag == 0)
{
/* Handle empty message types, where the first field is already the terminator.
* In other cases, the iter->pos never points to the terminator. */
return false;
}
iter->pos++;
if (iter->pos->tag == 0)
{
/* Wrapped back to beginning, reinitialize */
(void)pb_field_iter_begin(iter, iter->start, iter->dest_struct);
return false;
}
else
{
/* Increment the pointers based on previous field size */
size_t prev_size = prev_field->data_size;
if (PB_ATYPE(prev_field->type) == PB_ATYPE_STATIC &&
PB_HTYPE(prev_field->type) == PB_HTYPE_REPEATED)
{
/* In static arrays, the data_size tells the size of a single entry and
* array_size is the number of entries */
prev_size *= prev_field->array_size;
}
else if (PB_ATYPE(prev_field->type) == PB_ATYPE_POINTER)
{
/* Pointer fields always have a constant size in the main structure.
* The data_size only applies to the dynamically allocated area. */
prev_size = sizeof(void*);
}
if (PB_HTYPE(prev_field->type) == PB_HTYPE_REQUIRED)
{
/* Count the required fields, in order to check their presence in the
* decoder. */
iter->required_field_index++;
}
iter->pData = (char*)iter->pData + prev_size + iter->pos->data_offset;
iter->pSize = (char*)iter->pData + iter->pos->size_offset;
return true;
}
}
bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag)
{
const pb_field_t *start = iter->pos;
do {
if (iter->pos->tag == tag &&
PB_LTYPE(iter->pos->type) != PB_LTYPE_EXTENSION)
{
/* Found the wanted field */
return true;
}
(void)pb_field_iter_next(iter);
} while (iter->pos != start);
/* Searched all the way back to start, and found nothing. */
return false;
}

View File

@ -1,42 +0,0 @@
/* pb_common.h: Common support functions for pb_encode.c and pb_decode.c.
* These functions are rarely needed by applications directly.
*/
#ifndef PB_COMMON_H_INCLUDED
#define PB_COMMON_H_INCLUDED
#include "pb.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Iterator for pb_field_t list */
struct pb_field_iter_s {
const pb_field_t *start; /* Start of the pb_field_t array */
const pb_field_t *pos; /* Current position of the iterator */
unsigned required_field_index; /* Zero-based index that counts only the required fields */
void *dest_struct; /* Pointer to start of the structure */
void *pData; /* Pointer to current field value */
void *pSize; /* Pointer to count/has field */
};
typedef struct pb_field_iter_s pb_field_iter_t;
/* Initialize the field iterator structure to beginning.
* Returns false if the message type is empty. */
bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct);
/* Advance the iterator to the next field.
* Returns false when the iterator wraps back to the first field. */
bool pb_field_iter_next(pb_field_iter_t *iter);
/* Advance the iterator until it points at a field with the given tag.
* Returns false if no such field exists. */
bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View File

@ -15,23 +15,36 @@
#include "pb.h"
#include "pb_decode.h"
#include "pb_common.h"
/**************************************
* Declarations internal to this file *
**************************************/
/* Iterator for pb_field_t list */
typedef struct {
const pb_field_t *start; /* Start of the pb_field_t array */
const pb_field_t *pos; /* Current position of the iterator */
unsigned field_index; /* Zero-based index of the field. */
unsigned required_field_index; /* Zero-based index that counts only the required fields */
void *dest_struct; /* Pointer to the destination structure to decode to */
void *pData; /* Pointer where to store current field value */
void *pSize; /* Pointer where to store the size of current array field */
} pb_field_iterator_t;
typedef bool (*pb_decoder_t)(pb_istream_t *stream, const pb_field_t *field, void *dest) checkreturn;
static bool checkreturn buf_read(pb_istream_t *stream, uint8_t *buf, size_t count);
static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest);
static bool checkreturn read_raw_value(pb_istream_t *stream, pb_wire_type_t wire_type, uint8_t *buf, size_t *size);
static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter);
static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter);
static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter);
static void pb_field_init(pb_field_iterator_t *iter, const pb_field_t *fields, void *dest_struct);
static bool pb_field_next(pb_field_iterator_t *iter);
static bool checkreturn pb_field_find(pb_field_iterator_t *iter, uint32_t tag);
static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
static bool checkreturn default_extension_decoder(pb_istream_t *stream, pb_extension_t *extension, uint32_t tag, pb_wire_type_t wire_type);
static bool checkreturn decode_extension(pb_istream_t *stream, uint32_t tag, pb_wire_type_t wire_type, pb_field_iter_t *iter);
static bool checkreturn find_extension_field(pb_field_iter_t *iter);
static bool checkreturn decode_extension(pb_istream_t *stream, uint32_t tag, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
static bool checkreturn find_extension_field(pb_field_iterator_t *iter);
static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_struct);
static bool checkreturn pb_dec_varint(pb_istream_t *stream, const pb_field_t *field, void *dest);
static bool checkreturn pb_dec_uvarint(pb_istream_t *stream, const pb_field_t *field, void *dest);
@ -46,7 +59,7 @@ static bool checkreturn pb_skip_string(pb_istream_t *stream);
#ifdef PB_ENABLE_MALLOC
static bool checkreturn allocate_field(pb_istream_t *stream, void *pData, size_t data_size, size_t array_size);
static void pb_release_single_field(const pb_field_iter_t *iter);
static void pb_release_single_field(const pb_field_iterator_t *iter);
#endif
/* --- Function pointers to field decoders ---
@ -330,11 +343,75 @@ void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream)
#endif
}
static void pb_field_init(pb_field_iterator_t *iter, const pb_field_t *fields, void *dest_struct)
{
iter->start = iter->pos = fields;
iter->field_index = 0;
iter->required_field_index = 0;
iter->pData = (char*)dest_struct + iter->pos->data_offset;
iter->pSize = (char*)iter->pData + iter->pos->size_offset;
iter->dest_struct = dest_struct;
}
static bool pb_field_next(pb_field_iterator_t *iter)
{
bool notwrapped = true;
size_t prev_size = iter->pos->data_size;
if (PB_ATYPE(iter->pos->type) == PB_ATYPE_STATIC &&
PB_HTYPE(iter->pos->type) == PB_HTYPE_REPEATED)
{
prev_size *= iter->pos->array_size;
}
else if (PB_ATYPE(iter->pos->type) == PB_ATYPE_POINTER)
{
prev_size = sizeof(void*);
}
if (iter->pos->tag == 0)
return false; /* Only happens with empty message types */
if (PB_HTYPE(iter->pos->type) == PB_HTYPE_REQUIRED)
iter->required_field_index++;
iter->pos++;
iter->field_index++;
if (iter->pos->tag == 0)
{
iter->pos = iter->start;
iter->field_index = 0;
iter->required_field_index = 0;
iter->pData = iter->dest_struct;
prev_size = 0;
notwrapped = false;
}
iter->pData = (char*)iter->pData + prev_size + iter->pos->data_offset;
iter->pSize = (char*)iter->pData + iter->pos->size_offset;
return notwrapped;
}
static bool checkreturn pb_field_find(pb_field_iterator_t *iter, uint32_t tag)
{
unsigned start = iter->field_index;
do {
if (iter->pos->tag == tag &&
PB_LTYPE(iter->pos->type) != PB_LTYPE_EXTENSION)
{
return true;
}
(void)pb_field_next(iter);
} while (iter->field_index != start);
return false;
}
/*************************
* Decode a single field *
*************************/
static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter)
static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter)
{
pb_type_t type;
pb_decoder_t func;
@ -357,7 +434,7 @@ static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t
{
/* Packed array */
bool status = true;
pb_size_t *size = (pb_size_t*)iter->pSize;
size_t *size = (size_t*)iter->pSize;
pb_istream_t substream;
if (!pb_make_string_substream(stream, &substream))
return false;
@ -382,7 +459,7 @@ static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t
else
{
/* Repeated field */
pb_size_t *size = (pb_size_t*)iter->pSize;
size_t *size = (size_t*)iter->pSize;
void *pItem = (uint8_t*)iter->pData + iter->pos->data_size * (*size);
if (*size >= iter->pos->array_size)
PB_RETURN_ERROR(stream, "array overflow");
@ -437,7 +514,7 @@ static bool checkreturn allocate_field(pb_istream_t *stream, void *pData, size_t
}
/* Clear a newly allocated item in case it contains a pointer, or is a submessage. */
static void initialize_pointer_field(void *pItem, pb_field_iter_t *iter)
static void initialize_pointer_field(void *pItem, pb_field_iterator_t *iter)
{
if (PB_LTYPE(iter->pos->type) == PB_LTYPE_STRING ||
PB_LTYPE(iter->pos->type) == PB_LTYPE_BYTES)
@ -451,11 +528,11 @@ static void initialize_pointer_field(void *pItem, pb_field_iter_t *iter)
}
#endif
static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter)
static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter)
{
#ifndef PB_ENABLE_MALLOC
PB_UNUSED(wire_type);
PB_UNUSED(iter);
UNUSED(wire_type);
UNUSED(iter);
PB_RETURN_ERROR(stream, "no malloc support");
#else
pb_type_t type;
@ -495,7 +572,7 @@ static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_
{
/* Packed array, multiple items come in at once. */
bool status = true;
pb_size_t *size = (pb_size_t*)iter->pSize;
size_t *size = (size_t*)iter->pSize;
size_t allocated_size = *size;
void *pItem;
pb_istream_t substream;
@ -505,7 +582,7 @@ static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_
while (substream.bytes_left)
{
if ((size_t)*size + 1 > allocated_size)
if (*size + 1 > allocated_size)
{
/* Allocate more storage. This tries to guess the
* number of remaining entries. Round the division
@ -527,16 +604,6 @@ static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_
status = false;
break;
}
if (*size == PB_SIZE_MAX)
{
#ifndef PB_NO_ERRMSG
stream->errmsg = "too many array entries";
#endif
status = false;
break;
}
(*size)++;
}
pb_close_string_substream(stream, &substream);
@ -546,12 +613,9 @@ static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_
else
{
/* Normal repeated field, i.e. only one item at a time. */
pb_size_t *size = (pb_size_t*)iter->pSize;
size_t *size = (size_t*)iter->pSize;
void *pItem;
if (*size == PB_SIZE_MAX)
PB_RETURN_ERROR(stream, "too many array entries");
(*size)++;
if (!allocate_field(stream, iter->pData, iter->pos->data_size, *size))
return false;
@ -567,7 +631,7 @@ static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_
#endif
}
static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter)
static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter)
{
pb_callback_t *pCallback = (pb_callback_t*)iter->pData;
@ -614,7 +678,7 @@ static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type
}
}
static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter)
static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter)
{
switch (PB_ATYPE(iter->pos->type))
{
@ -638,15 +702,16 @@ static bool checkreturn default_extension_decoder(pb_istream_t *stream,
pb_extension_t *extension, uint32_t tag, pb_wire_type_t wire_type)
{
const pb_field_t *field = (const pb_field_t*)extension->type->arg;
pb_field_iter_t iter;
pb_field_iterator_t iter;
if (field->tag != tag)
return true;
/* Fake a field iterator for the extension field.
* It is not actually safe to advance this iterator, but decode_field
* will not even try to. */
(void)pb_field_iter_begin(&iter, field, extension->dest);
iter.start = field;
iter.pos = field;
iter.field_index = 0;
iter.required_field_index = 0;
iter.dest_struct = extension->dest;
iter.pData = extension->dest;
iter.pSize = &extension->found;
@ -656,7 +721,7 @@ static bool checkreturn default_extension_decoder(pb_istream_t *stream,
/* Try to decode an unknown field as an extension field. Tries each extension
* decoder in turn, until one of them handles the field or loop ends. */
static bool checkreturn decode_extension(pb_istream_t *stream,
uint32_t tag, pb_wire_type_t wire_type, pb_field_iter_t *iter)
uint32_t tag, pb_wire_type_t wire_type, pb_field_iterator_t *iter)
{
pb_extension_t *extension = *(pb_extension_t* const *)iter->pData;
size_t pos = stream->bytes_left;
@ -681,15 +746,15 @@ static bool checkreturn decode_extension(pb_istream_t *stream,
/* Step through the iterator until an extension field is found or until all
* entries have been checked. There can be only one extension field per
* message. Returns false if no extension field is found. */
static bool checkreturn find_extension_field(pb_field_iter_t *iter)
static bool checkreturn find_extension_field(pb_field_iterator_t *iter)
{
const pb_field_t *start = iter->pos;
unsigned start = iter->field_index;
do {
if (PB_LTYPE(iter->pos->type) == PB_LTYPE_EXTENSION)
return true;
(void)pb_field_iter_next(iter);
} while (iter->pos != start);
(void)pb_field_next(iter);
} while (iter->field_index != start);
return false;
}
@ -697,15 +762,17 @@ static bool checkreturn find_extension_field(pb_field_iter_t *iter)
/* Initialize message fields to default values, recursively */
static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_struct)
{
pb_field_iter_t iter;
if (!pb_field_iter_begin(&iter, fields, dest_struct))
return; /* Empty message type */
pb_field_iterator_t iter;
pb_field_init(&iter, fields, dest_struct);
do
{
pb_type_t type;
type = iter.pos->type;
/* Avoid crash on empty message types (zero fields) */
if (iter.pos->tag == 0)
continue;
if (PB_ATYPE(type) == PB_ATYPE_STATIC)
{
@ -718,7 +785,7 @@ static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_str
else if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
{
/* Set array count to 0, no need to initialize contents. */
*(pb_size_t*)iter.pSize = 0;
*(size_t*)iter.pSize = 0;
continue;
}
@ -746,14 +813,14 @@ static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_str
/* Initialize array count to 0. */
if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
{
*(pb_size_t*)iter.pSize = 0;
*(size_t*)iter.pSize = 0;
}
}
else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
{
/* Don't overwrite callback */
}
} while (pb_field_iter_next(&iter));
} while (pb_field_next(&iter));
}
/*********************
@ -764,11 +831,9 @@ bool checkreturn pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[
{
uint8_t fields_seen[(PB_MAX_REQUIRED_FIELDS + 7) / 8] = {0, 0, 0, 0, 0, 0, 0, 0};
uint32_t extension_range_start = 0;
pb_field_iter_t iter;
pb_field_iterator_t iter;
/* Return value ignored, as empty message types will be correctly handled by
* pb_field_iter_find() anyway. */
(void)pb_field_iter_begin(&iter, fields, dest_struct);
pb_field_init(&iter, fields, dest_struct);
while (stream->bytes_left)
{
@ -784,7 +849,7 @@ bool checkreturn pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[
return false;
}
if (!pb_field_iter_find(&iter, tag))
if (!pb_field_find(&iter, tag))
{
/* No match found, check if it matches an extension. */
if (tag >= extension_range_start)
@ -837,7 +902,7 @@ bool checkreturn pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[
do {
req_field_count = iter.required_field_index;
last_type = iter.pos->type;
} while (pb_field_iter_next(&iter));
} while (pb_field_next(&iter));
/* Fixup if last field was also required. */
if (PB_HTYPE(last_type) == PB_HTYPE_REQUIRED && iter.pos->tag != 0)
@ -886,7 +951,7 @@ bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *
}
#ifdef PB_ENABLE_MALLOC
static void pb_release_single_field(const pb_field_iter_t *iter)
static void pb_release_single_field(const pb_field_iterator_t *iter)
{
pb_type_t type;
type = iter->pos->type;
@ -937,15 +1002,16 @@ static void pb_release_single_field(const pb_field_iter_t *iter)
void pb_release(const pb_field_t fields[], void *dest_struct)
{
pb_field_iter_t iter;
if (!pb_field_iter_begin(&iter, fields, dest_struct))
pb_field_iterator_t iter;
pb_field_init(&iter, fields, dest_struct);
if (iter.pos->tag == 0)
return; /* Empty message type */
do
{
pb_release_single_field(&iter);
} while (pb_field_iter_next(&iter));
} while (pb_field_next(&iter));
}
#endif
@ -1059,13 +1125,13 @@ static bool checkreturn pb_dec_svarint(pb_istream_t *stream, const pb_field_t *f
static bool checkreturn pb_dec_fixed32(pb_istream_t *stream, const pb_field_t *field, void *dest)
{
PB_UNUSED(field);
UNUSED(field);
return pb_decode_fixed32(stream, dest);
}
static bool checkreturn pb_dec_fixed64(pb_istream_t *stream, const pb_field_t *field, void *dest)
{
PB_UNUSED(field);
UNUSED(field);
return pb_decode_fixed64(stream, dest);
}
@ -1078,9 +1144,6 @@ static bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *fie
if (!pb_decode_varint32(stream, &size))
return false;
if (size > PB_SIZE_MAX)
PB_RETURN_ERROR(stream, "bytes overflow");
alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
if (size > alloc_size)
PB_RETURN_ERROR(stream, "size too large");
@ -1101,8 +1164,9 @@ static bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *fie
PB_RETURN_ERROR(stream, "bytes overflow");
bdest = (pb_bytes_array_t*)dest;
}
bdest->size = size;
bdest->size = (pb_size_t)size;
return pb_read(stream, bdest->bytes, size);
}

View File

@ -3,8 +3,8 @@
* field descriptions created by nanopb_generator.py.
*/
#ifndef PB_DECODE_H_INCLUDED
#define PB_DECODE_H_INCLUDED
#ifndef _PB_DECODE_H_
#define _PB_DECODE_H_
#include "pb.h"
@ -25,7 +25,7 @@ extern "C" {
* is different than from the main stream. Don't use bytes_left to compute
* any pointers.
*/
struct pb_istream_s
struct _pb_istream_t
{
#ifdef PB_BUFFER_ONLY
/* Callback pointer is not used in buffer-only configuration.

View File

@ -5,7 +5,6 @@
#include "pb.h"
#include "pb_encode.h"
#include "pb_common.h"
/* Use the GCC warn_unused_result attribute to check that all return values
* are propagated correctly. On other compilers and gcc before 3.4.0 just
@ -246,7 +245,7 @@ static bool checkreturn encode_basic_field(pb_ostream_t *stream,
break;
case PB_HTYPE_REPEATED:
if (!encode_array(stream, field, pData, *(const pb_size_t*)pSize, func))
if (!encode_array(stream, field, pData, *(const size_t*)pSize, func))
return false;
break;
@ -311,7 +310,7 @@ static bool checkreturn encode_extension_field(pb_ostream_t *stream,
const pb_field_t *field, const void *pData)
{
const pb_extension_t *extension = *(const pb_extension_t* const *)pData;
PB_UNUSED(field);
UNUSED(field);
while (extension)
{
@ -334,38 +333,42 @@ static bool checkreturn encode_extension_field(pb_ostream_t *stream,
* Encode all fields *
*********************/
static void *remove_const(const void *p)
{
/* Note: this casts away const, in order to use the common field iterator
* logic for both encoding and decoding. */
union {
void *p1;
const void *p2;
} t;
t.p2 = p;
return t.p1;
}
bool checkreturn pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct)
{
pb_field_iter_t iter;
if (!pb_field_iter_begin(&iter, fields, remove_const(src_struct)))
return true; /* Empty message type */
const pb_field_t *field = fields;
const void *pData = src_struct;
size_t prev_size = 0;
do {
if (PB_LTYPE(iter.pos->type) == PB_LTYPE_EXTENSION)
while (field->tag != 0)
{
pData = (const char*)pData + prev_size + field->data_offset;
if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
prev_size = sizeof(const void*);
else
prev_size = field->data_size;
/* Special case for static arrays */
if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
{
prev_size *= field->array_size;
}
if (PB_LTYPE(field->type) == PB_LTYPE_EXTENSION)
{
/* Special case for the extension field placeholder */
if (!encode_extension_field(stream, iter.pos, iter.pData))
if (!encode_extension_field(stream, field, pData))
return false;
}
else
{
/* Regular field */
if (!encode_field(stream, iter.pos, iter.pData))
if (!encode_field(stream, field, pData))
return false;
}
} while (pb_field_iter_next(&iter));
field++;
}
return true;
}
@ -599,13 +602,13 @@ static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *f
static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
PB_UNUSED(field);
UNUSED(field);
return pb_encode_fixed64(stream, src);
}
static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
PB_UNUSED(field);
UNUSED(field);
return pb_encode_fixed32(stream, src);
}
@ -630,6 +633,7 @@ static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *fie
static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
/* strnlen() is not always available, so just use a loop */
size_t size = 0;
size_t max_size = field->data_size;
const char *p = (const char*)src;
@ -643,7 +647,6 @@ static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *fi
}
else
{
/* strnlen() is not always available, so just use a loop */
while (size < max_size && *p != '\0')
{
size++;

View File

@ -3,8 +3,8 @@
* field descriptions created by nanopb_generator.py.
*/
#ifndef PB_ENCODE_H_INCLUDED
#define PB_ENCODE_H_INCLUDED
#ifndef _PB_ENCODE_H_
#define _PB_ENCODE_H_
#include "pb.h"
@ -24,7 +24,7 @@ extern "C" {
* 4) Substreams will modify max_size and bytes_written. Don't use them
* to calculate any pointers.
*/
struct pb_ostream_s
struct _pb_ostream_t
{
#ifdef PB_BUFFER_ONLY
/* Callback pointer is not used in buffer-only configuration.

View File

@ -1,24 +1,20 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.3.1 */
/* Generated by nanopb-0.2.9.1 */
#include "storage.pb.h"
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
const pb_field_t Storage_fields[10] = {
PB_FIELD( 1, UINT32 , REQUIRED, STATIC , FIRST, Storage, version, version, 0),
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, Storage, node, version, &HDNodeType_fields),
PB_FIELD( 3, STRING , OPTIONAL, STATIC , OTHER, Storage, mnemonic, node, 0),
PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, Storage, passphrase_protection, mnemonic, 0),
PB_FIELD( 5, UINT32 , OPTIONAL, STATIC , OTHER, Storage, pin_failed_attempts, passphrase_protection, 0),
PB_FIELD( 6, STRING , OPTIONAL, STATIC , OTHER, Storage, pin, pin_failed_attempts, 0),
PB_FIELD( 7, STRING , OPTIONAL, STATIC , OTHER, Storage, language, pin, 0),
PB_FIELD( 8, STRING , OPTIONAL, STATIC , OTHER, Storage, label, language, 0),
PB_FIELD( 9, BOOL , OPTIONAL, STATIC , OTHER, Storage, imported, label, 0),
PB_FIELD2( 1, UINT32 , REQUIRED, STATIC , FIRST, Storage, version, version, 0),
PB_FIELD2( 2, MESSAGE , OPTIONAL, STATIC , OTHER, Storage, node, version, &HDNodeType_fields),
PB_FIELD2( 3, STRING , OPTIONAL, STATIC , OTHER, Storage, mnemonic, node, 0),
PB_FIELD2( 4, BOOL , OPTIONAL, STATIC , OTHER, Storage, passphrase_protection, mnemonic, 0),
PB_FIELD2( 5, UINT32 , OPTIONAL, STATIC , OTHER, Storage, pin_failed_attempts, passphrase_protection, 0),
PB_FIELD2( 6, STRING , OPTIONAL, STATIC , OTHER, Storage, pin, pin_failed_attempts, 0),
PB_FIELD2( 7, STRING , OPTIONAL, STATIC , OTHER, Storage, language, pin, 0),
PB_FIELD2( 8, STRING , OPTIONAL, STATIC , OTHER, Storage, label, language, 0),
PB_FIELD2( 9, BOOL , OPTIONAL, STATIC , OTHER, Storage, imported, label, 0),
PB_LAST_FIELD
};
@ -32,7 +28,7 @@ const pb_field_t Storage_fields[10] = {
* numbers or field sizes that are larger than what can fit in 8 or 16 bit
* field descriptors.
*/
PB_STATIC_ASSERT((pb_membersize(Storage, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Storage)
STATIC_ASSERT((pb_membersize(Storage, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Storage)
#endif
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
@ -43,7 +39,7 @@ PB_STATIC_ASSERT((pb_membersize(Storage, node) < 65536), YOU_MUST_DEFINE_PB_FIEL
* numbers or field sizes that are larger than what can fit in the default
* 8 bit descriptors.
*/
PB_STATIC_ASSERT((pb_membersize(Storage, node) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_Storage)
STATIC_ASSERT((pb_membersize(Storage, node) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_Storage)
#endif

View File

@ -1,15 +1,11 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.1 */
/* Generated by nanopb-0.2.9.1 */
#ifndef PB_STORAGE_PB_H_INCLUDED
#define PB_STORAGE_PB_H_INCLUDED
#ifndef _PB_STORAGE_PB_H_
#define _PB_STORAGE_PB_H_
#include "pb.h"
#include "types.pb.h"
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -1,12 +1,8 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.3.1 */
/* Generated by nanopb-0.2.9.1 */
#include "types.pb.h"
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
const uint32_t CoinType_address_type_default = 0u;
const uint32_t CoinType_address_type_p2sh_default = 5u;
const uint32_t TxInputType_sequence_default = 4294967295u;
@ -14,84 +10,84 @@ const InputScriptType TxInputType_script_type_default = InputScriptType_SPENDADD
const pb_field_t HDNodeType_fields[7] = {
PB_FIELD( 1, UINT32 , REQUIRED, STATIC , FIRST, HDNodeType, depth, depth, 0),
PB_FIELD( 2, UINT32 , REQUIRED, STATIC , OTHER, HDNodeType, fingerprint, depth, 0),
PB_FIELD( 3, UINT32 , REQUIRED, STATIC , OTHER, HDNodeType, child_num, fingerprint, 0),
PB_FIELD( 4, BYTES , REQUIRED, STATIC , OTHER, HDNodeType, chain_code, child_num, 0),
PB_FIELD( 5, BYTES , OPTIONAL, STATIC , OTHER, HDNodeType, private_key, chain_code, 0),
PB_FIELD( 6, BYTES , OPTIONAL, STATIC , OTHER, HDNodeType, public_key, private_key, 0),
PB_FIELD2( 1, UINT32 , REQUIRED, STATIC , FIRST, HDNodeType, depth, depth, 0),
PB_FIELD2( 2, UINT32 , REQUIRED, STATIC , OTHER, HDNodeType, fingerprint, depth, 0),
PB_FIELD2( 3, UINT32 , REQUIRED, STATIC , OTHER, HDNodeType, child_num, fingerprint, 0),
PB_FIELD2( 4, BYTES , REQUIRED, STATIC , OTHER, HDNodeType, chain_code, child_num, 0),
PB_FIELD2( 5, BYTES , OPTIONAL, STATIC , OTHER, HDNodeType, private_key, chain_code, 0),
PB_FIELD2( 6, BYTES , OPTIONAL, STATIC , OTHER, HDNodeType, public_key, private_key, 0),
PB_LAST_FIELD
};
const pb_field_t HDNodePathType_fields[3] = {
PB_FIELD( 1, MESSAGE , REQUIRED, STATIC , FIRST, HDNodePathType, node, node, &HDNodeType_fields),
PB_FIELD( 2, UINT32 , REPEATED, STATIC , OTHER, HDNodePathType, address_n, node, 0),
PB_FIELD2( 1, MESSAGE , REQUIRED, STATIC , FIRST, HDNodePathType, node, node, &HDNodeType_fields),
PB_FIELD2( 2, UINT32 , REPEATED, STATIC , OTHER, HDNodePathType, address_n, node, 0),
PB_LAST_FIELD
};
const pb_field_t CoinType_fields[6] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, CoinType, coin_name, coin_name, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, CoinType, coin_shortcut, coin_name, 0),
PB_FIELD( 3, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, address_type, coin_shortcut, &CoinType_address_type_default),
PB_FIELD( 4, UINT64 , OPTIONAL, STATIC , OTHER, CoinType, maxfee_kb, address_type, 0),
PB_FIELD( 5, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, address_type_p2sh, maxfee_kb, &CoinType_address_type_p2sh_default),
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, CoinType, coin_name, coin_name, 0),
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, CoinType, coin_shortcut, coin_name, 0),
PB_FIELD2( 3, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, address_type, coin_shortcut, &CoinType_address_type_default),
PB_FIELD2( 4, UINT64 , OPTIONAL, STATIC , OTHER, CoinType, maxfee_kb, address_type, 0),
PB_FIELD2( 5, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, address_type_p2sh, maxfee_kb, &CoinType_address_type_p2sh_default),
PB_LAST_FIELD
};
const pb_field_t MultisigRedeemScriptType_fields[4] = {
PB_FIELD( 1, MESSAGE , REPEATED, STATIC , FIRST, MultisigRedeemScriptType, pubkeys, pubkeys, &HDNodePathType_fields),
PB_FIELD( 2, BYTES , REPEATED, STATIC , OTHER, MultisigRedeemScriptType, signatures, pubkeys, 0),
PB_FIELD( 3, UINT32 , OPTIONAL, STATIC , OTHER, MultisigRedeemScriptType, m, signatures, 0),
PB_FIELD2( 1, MESSAGE , REPEATED, STATIC , FIRST, MultisigRedeemScriptType, pubkeys, pubkeys, &HDNodePathType_fields),
PB_FIELD2( 2, BYTES , REPEATED, STATIC , OTHER, MultisigRedeemScriptType, signatures, pubkeys, 0),
PB_FIELD2( 3, UINT32 , OPTIONAL, STATIC , OTHER, MultisigRedeemScriptType, m, signatures, 0),
PB_LAST_FIELD
};
const pb_field_t TxInputType_fields[8] = {
PB_FIELD( 1, UINT32 , REPEATED, STATIC , FIRST, TxInputType, address_n, address_n, 0),
PB_FIELD( 2, BYTES , REQUIRED, STATIC , OTHER, TxInputType, prev_hash, address_n, 0),
PB_FIELD( 3, UINT32 , REQUIRED, STATIC , OTHER, TxInputType, prev_index, prev_hash, 0),
PB_FIELD( 4, BYTES , OPTIONAL, STATIC , OTHER, TxInputType, script_sig, prev_index, 0),
PB_FIELD( 5, UINT32 , OPTIONAL, STATIC , OTHER, TxInputType, sequence, script_sig, &TxInputType_sequence_default),
PB_FIELD( 6, ENUM , OPTIONAL, STATIC , OTHER, TxInputType, script_type, sequence, &TxInputType_script_type_default),
PB_FIELD( 7, MESSAGE , OPTIONAL, STATIC , OTHER, TxInputType, multisig, script_type, &MultisigRedeemScriptType_fields),
PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, TxInputType, address_n, address_n, 0),
PB_FIELD2( 2, BYTES , REQUIRED, STATIC , OTHER, TxInputType, prev_hash, address_n, 0),
PB_FIELD2( 3, UINT32 , REQUIRED, STATIC , OTHER, TxInputType, prev_index, prev_hash, 0),
PB_FIELD2( 4, BYTES , OPTIONAL, STATIC , OTHER, TxInputType, script_sig, prev_index, 0),
PB_FIELD2( 5, UINT32 , OPTIONAL, STATIC , OTHER, TxInputType, sequence, script_sig, &TxInputType_sequence_default),
PB_FIELD2( 6, ENUM , OPTIONAL, STATIC , OTHER, TxInputType, script_type, sequence, &TxInputType_script_type_default),
PB_FIELD2( 7, MESSAGE , OPTIONAL, STATIC , OTHER, TxInputType, multisig, script_type, &MultisigRedeemScriptType_fields),
PB_LAST_FIELD
};
const pb_field_t TxOutputType_fields[6] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, TxOutputType, address, address, 0),
PB_FIELD( 2, UINT32 , REPEATED, STATIC , OTHER, TxOutputType, address_n, address, 0),
PB_FIELD( 3, UINT64 , REQUIRED, STATIC , OTHER, TxOutputType, amount, address_n, 0),
PB_FIELD( 4, ENUM , REQUIRED, STATIC , OTHER, TxOutputType, script_type, amount, 0),
PB_FIELD( 5, MESSAGE , OPTIONAL, STATIC , OTHER, TxOutputType, multisig, script_type, &MultisigRedeemScriptType_fields),
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, TxOutputType, address, address, 0),
PB_FIELD2( 2, UINT32 , REPEATED, STATIC , OTHER, TxOutputType, address_n, address, 0),
PB_FIELD2( 3, UINT64 , REQUIRED, STATIC , OTHER, TxOutputType, amount, address_n, 0),
PB_FIELD2( 4, ENUM , REQUIRED, STATIC , OTHER, TxOutputType, script_type, amount, 0),
PB_FIELD2( 5, MESSAGE , OPTIONAL, STATIC , OTHER, TxOutputType, multisig, script_type, &MultisigRedeemScriptType_fields),
PB_LAST_FIELD
};
const pb_field_t TxOutputBinType_fields[3] = {
PB_FIELD( 1, UINT64 , REQUIRED, STATIC , FIRST, TxOutputBinType, amount, amount, 0),
PB_FIELD( 2, BYTES , REQUIRED, STATIC , OTHER, TxOutputBinType, script_pubkey, amount, 0),
PB_FIELD2( 1, UINT64 , REQUIRED, STATIC , FIRST, TxOutputBinType, amount, amount, 0),
PB_FIELD2( 2, BYTES , REQUIRED, STATIC , OTHER, TxOutputBinType, script_pubkey, amount, 0),
PB_LAST_FIELD
};
const pb_field_t TransactionType_fields[8] = {
PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, TransactionType, version, version, 0),
PB_FIELD( 2, MESSAGE , REPEATED, STATIC , OTHER, TransactionType, inputs, version, &TxInputType_fields),
PB_FIELD( 3, MESSAGE , REPEATED, STATIC , OTHER, TransactionType, bin_outputs, inputs, &TxOutputBinType_fields),
PB_FIELD( 4, UINT32 , OPTIONAL, STATIC , OTHER, TransactionType, lock_time, bin_outputs, 0),
PB_FIELD( 5, MESSAGE , REPEATED, STATIC , OTHER, TransactionType, outputs, lock_time, &TxOutputType_fields),
PB_FIELD( 6, UINT32 , OPTIONAL, STATIC , OTHER, TransactionType, inputs_cnt, outputs, 0),
PB_FIELD( 7, UINT32 , OPTIONAL, STATIC , OTHER, TransactionType, outputs_cnt, inputs_cnt, 0),
PB_FIELD2( 1, UINT32 , OPTIONAL, STATIC , FIRST, TransactionType, version, version, 0),
PB_FIELD2( 2, MESSAGE , REPEATED, STATIC , OTHER, TransactionType, inputs, version, &TxInputType_fields),
PB_FIELD2( 3, MESSAGE , REPEATED, STATIC , OTHER, TransactionType, bin_outputs, inputs, &TxOutputBinType_fields),
PB_FIELD2( 4, UINT32 , OPTIONAL, STATIC , OTHER, TransactionType, lock_time, bin_outputs, 0),
PB_FIELD2( 5, MESSAGE , REPEATED, STATIC , OTHER, TransactionType, outputs, lock_time, &TxOutputType_fields),
PB_FIELD2( 6, UINT32 , OPTIONAL, STATIC , OTHER, TransactionType, inputs_cnt, outputs, 0),
PB_FIELD2( 7, UINT32 , OPTIONAL, STATIC , OTHER, TransactionType, outputs_cnt, inputs_cnt, 0),
PB_LAST_FIELD
};
const pb_field_t TxRequestDetailsType_fields[3] = {
PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, TxRequestDetailsType, request_index, request_index, 0),
PB_FIELD( 2, BYTES , OPTIONAL, STATIC , OTHER, TxRequestDetailsType, tx_hash, request_index, 0),
PB_FIELD2( 1, UINT32 , OPTIONAL, STATIC , FIRST, TxRequestDetailsType, request_index, request_index, 0),
PB_FIELD2( 2, BYTES , OPTIONAL, STATIC , OTHER, TxRequestDetailsType, tx_hash, request_index, 0),
PB_LAST_FIELD
};
const pb_field_t TxRequestSerializedType_fields[4] = {
PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, TxRequestSerializedType, signature_index, signature_index, 0),
PB_FIELD( 2, BYTES , OPTIONAL, STATIC , OTHER, TxRequestSerializedType, signature, signature_index, 0),
PB_FIELD( 3, BYTES , OPTIONAL, STATIC , OTHER, TxRequestSerializedType, serialized_tx, signature, 0),
PB_FIELD2( 1, UINT32 , OPTIONAL, STATIC , FIRST, TxRequestSerializedType, signature_index, signature_index, 0),
PB_FIELD2( 2, BYTES , OPTIONAL, STATIC , OTHER, TxRequestSerializedType, signature, signature_index, 0),
PB_FIELD2( 3, BYTES , OPTIONAL, STATIC , OTHER, TxRequestSerializedType, serialized_tx, signature, 0),
PB_LAST_FIELD
};
@ -100,7 +96,7 @@ typedef struct {
} wire_in_struct;
static const pb_field_t wire_in_field =
PB_FIELD(50002, BOOL , OPTEXT, STATIC , FIRST, wire_in_struct, wire_in, wire_in, 0);
PB_FIELD2(50002, BOOL , OPTEXT, STATIC , FIRST, wire_in_struct, wire_in, wire_in, 0);
const pb_extension_type_t wire_in = {
NULL,
@ -113,7 +109,7 @@ typedef struct {
} wire_out_struct;
static const pb_field_t wire_out_field =
PB_FIELD(50003, BOOL , OPTEXT, STATIC , FIRST, wire_out_struct, wire_out, wire_out, 0);
PB_FIELD2(50003, BOOL , OPTEXT, STATIC , FIRST, wire_out_struct, wire_out, wire_out, 0);
const pb_extension_type_t wire_out = {
NULL,
@ -126,7 +122,7 @@ typedef struct {
} wire_debug_in_struct;
static const pb_field_t wire_debug_in_field =
PB_FIELD(50004, BOOL , OPTEXT, STATIC , FIRST, wire_debug_in_struct, wire_debug_in, wire_debug_in, 0);
PB_FIELD2(50004, BOOL , OPTEXT, STATIC , FIRST, wire_debug_in_struct, wire_debug_in, wire_debug_in, 0);
const pb_extension_type_t wire_debug_in = {
NULL,
@ -139,7 +135,7 @@ typedef struct {
} wire_debug_out_struct;
static const pb_field_t wire_debug_out_field =
PB_FIELD(50005, BOOL , OPTEXT, STATIC , FIRST, wire_debug_out_struct, wire_debug_out, wire_debug_out, 0);
PB_FIELD2(50005, BOOL , OPTEXT, STATIC , FIRST, wire_debug_out_struct, wire_debug_out, wire_debug_out, 0);
const pb_extension_type_t wire_debug_out = {
NULL,
@ -157,7 +153,7 @@ const pb_extension_type_t wire_debug_out = {
* numbers or field sizes that are larger than what can fit in 8 or 16 bit
* field descriptors.
*/
PB_STATIC_ASSERT((pb_membersize(HDNodePathType, node) < 65536 && pb_membersize(MultisigRedeemScriptType, pubkeys[0]) < 65536 && pb_membersize(TxInputType, multisig) < 65536 && pb_membersize(TxOutputType, multisig) < 65536 && pb_membersize(TransactionType, inputs[0]) < 65536 && pb_membersize(TransactionType, bin_outputs[0]) < 65536 && pb_membersize(TransactionType, outputs[0]) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_HDNodeType_HDNodePathType_CoinType_MultisigRedeemScriptType_TxInputType_TxOutputType_TxOutputBinType_TransactionType_TxRequestDetailsType_TxRequestSerializedType)
STATIC_ASSERT((pb_membersize(HDNodePathType, node) < 65536 && pb_membersize(MultisigRedeemScriptType, pubkeys[0]) < 65536 && pb_membersize(TxInputType, multisig) < 65536 && pb_membersize(TxOutputType, multisig) < 65536 && pb_membersize(TransactionType, inputs[0]) < 65536 && pb_membersize(TransactionType, bin_outputs[0]) < 65536 && pb_membersize(TransactionType, outputs[0]) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_HDNodeType_HDNodePathType_CoinType_MultisigRedeemScriptType_TxInputType_TxOutputType_TxOutputBinType_TransactionType_TxRequestDetailsType_TxRequestSerializedType)
#endif
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)

View File

@ -1,13 +1,9 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.1 */
/* Generated by nanopb-0.2.9.1 */
#ifndef PB_TYPES_PB_H_INCLUDED
#define PB_TYPES_PB_H_INCLUDED
#ifndef _PB_TYPES_PB_H_
#define _PB_TYPES_PB_H_
#include "pb.h"
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -79,11 +75,20 @@ typedef struct _CoinType {
uint32_t address_type_p2sh;
} CoinType;
typedef PB_BYTES_ARRAY_T(32) HDNodeType_chain_code_t;
typedef struct {
size_t size;
uint8_t bytes[32];
} HDNodeType_chain_code_t;
typedef PB_BYTES_ARRAY_T(32) HDNodeType_private_key_t;
typedef struct {
size_t size;
uint8_t bytes[32];
} HDNodeType_private_key_t;
typedef PB_BYTES_ARRAY_T(33) HDNodeType_public_key_t;
typedef struct {
size_t size;
uint8_t bytes[33];
} HDNodeType_public_key_t;
typedef struct _HDNodeType {
uint32_t depth;
@ -96,14 +101,20 @@ typedef struct _HDNodeType {
HDNodeType_public_key_t public_key;
} HDNodeType;
typedef PB_BYTES_ARRAY_T(520) TxOutputBinType_script_pubkey_t;
typedef struct {
size_t size;
uint8_t bytes[520];
} TxOutputBinType_script_pubkey_t;
typedef struct _TxOutputBinType {
uint64_t amount;
TxOutputBinType_script_pubkey_t script_pubkey;
} TxOutputBinType;
typedef PB_BYTES_ARRAY_T(32) TxRequestDetailsType_tx_hash_t;
typedef struct {
size_t size;
uint8_t bytes[32];
} TxRequestDetailsType_tx_hash_t;
typedef struct _TxRequestDetailsType {
bool has_request_index;
@ -112,9 +123,15 @@ typedef struct _TxRequestDetailsType {
TxRequestDetailsType_tx_hash_t tx_hash;
} TxRequestDetailsType;
typedef PB_BYTES_ARRAY_T(73) TxRequestSerializedType_signature_t;
typedef struct {
size_t size;
uint8_t bytes[73];
} TxRequestSerializedType_signature_t;
typedef PB_BYTES_ARRAY_T(2048) TxRequestSerializedType_serialized_tx_t;
typedef struct {
size_t size;
uint8_t bytes[2048];
} TxRequestSerializedType_serialized_tx_t;
typedef struct _TxRequestSerializedType {
bool has_signature_index;
@ -127,27 +144,36 @@ typedef struct _TxRequestSerializedType {
typedef struct _HDNodePathType {
HDNodeType node;
pb_size_t address_n_count;
size_t address_n_count;
uint32_t address_n[8];
} HDNodePathType;
typedef PB_BYTES_ARRAY_T(73) MultisigRedeemScriptType_signatures_t;
typedef struct {
size_t size;
uint8_t bytes[73];
} MultisigRedeemScriptType_signatures_t;
typedef struct _MultisigRedeemScriptType {
pb_size_t pubkeys_count;
size_t pubkeys_count;
HDNodePathType pubkeys[15];
pb_size_t signatures_count;
size_t signatures_count;
MultisigRedeemScriptType_signatures_t signatures[15];
bool has_m;
uint32_t m;
} MultisigRedeemScriptType;
typedef PB_BYTES_ARRAY_T(32) TxInputType_prev_hash_t;
typedef struct {
size_t size;
uint8_t bytes[32];
} TxInputType_prev_hash_t;
typedef PB_BYTES_ARRAY_T(1650) TxInputType_script_sig_t;
typedef struct {
size_t size;
uint8_t bytes[1650];
} TxInputType_script_sig_t;
typedef struct _TxInputType {
pb_size_t address_n_count;
size_t address_n_count;
uint32_t address_n[8];
TxInputType_prev_hash_t prev_hash;
uint32_t prev_index;
@ -164,7 +190,7 @@ typedef struct _TxInputType {
typedef struct _TxOutputType {
bool has_address;
char address[36];
pb_size_t address_n_count;
size_t address_n_count;
uint32_t address_n[8];
uint64_t amount;
OutputScriptType script_type;
@ -175,13 +201,13 @@ typedef struct _TxOutputType {
typedef struct _TransactionType {
bool has_version;
uint32_t version;
pb_size_t inputs_count;
size_t inputs_count;
TxInputType inputs[1];
pb_size_t bin_outputs_count;
size_t bin_outputs_count;
TxOutputBinType bin_outputs[1];
bool has_lock_time;
uint32_t lock_time;
pb_size_t outputs_count;
size_t outputs_count;
TxOutputType outputs[1];
bool has_inputs_cnt;
uint32_t inputs_cnt;