Skip to content

Commit

Permalink
Merge pull request #234 from keepkey/version-6.5.1
Browse files Browse the repository at this point in the history
firmware version 6.5.1
  • Loading branch information
con5cience authored Oct 2, 2020
2 parents a39d9bf + 21bf418 commit a988325
Show file tree
Hide file tree
Showing 203 changed files with 28,159 additions and 25,550 deletions.
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
BasedOnStyle: Google
# Google style has a default of 80 lines, but clang-format 7 disregards it in
# a weird case in modtrezorio-fatfs.h. Setting it explicitly helps.
ColumnLimit: 80
# This setting differs between clang-format 7 and 9.
# Let's set it explicitly to v7 value
IncludeBlocks: Preserve
SortIncludes: false
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[submodule "deps/device-protocol"]
path = deps/device-protocol
url = https://github.com/keepkey/device-protocol.git
branch = master
[submodule "deps/trezor-firmware"]
path = deps/crypto/trezor-firmware
url = https://github.com/keepkey/trezor-firmware.git
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.7.2)

project(KeepKeyFirmware

VERSION 6.4.0
VERSION 6.5.1

LANGUAGES C CXX ASM)

set(BOOTLOADER_MAJOR_VERSION 2)
set(BOOTLOADER_MINOR_VERSION 0)
set(BOOTLOADER_MINOR_VERSION 1)
set(BOOTLOADER_PATCH_VERSION 0)

option(KK_EMULATOR "Build the emulator" OFF)
Expand Down
2 changes: 1 addition & 1 deletion deps/device-protocol
59 changes: 58 additions & 1 deletion docs/Storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ it easier to extend for new features later on.
| language | char[16] | 16 | 16 |
| label | char[48] | 48 | 32 |
| wrapped_storage_key | char[64] | 64 | 80 |
| storage_key_fingerprint | char[64] | 8 | 144 |
| storage_key_fingerprint | char[64] | 32 | 144 |
| u2froot | StorageHDNode | 129 | 176 |
| u2f_counter | u32 | 4 | 305 |
| sec_fingerprint | char[32] | 32 | 309 |
Expand All @@ -125,3 +125,60 @@ it easier to extend for new features later on.
| root_seed_cache | char[64] | 64 | 371 |
| root_ecdsa_curve_type | char[10] | 10 | 435 |
| reserved | char[63] | 63 | 445 |


STORAGE_VERSION 16 layout
-------------------------

#### Public(ish) Storage

| Field | Type | Size (bytes) | Offset (bytes) |
| ------------------------- | -------------- | ------------ | -------------- |
| version | u32 | 4 | 0 |
| flags | u32 | 4 | 4 |
| has_pin | bit 0 | | |
| has_language | bit 1 | | |
| has_label | bit 2 | | |
| has_auto_lock_delay_ms | bit 3 | | |
| imported | bit 4 | | |
| passphrase_protection | bit 5 | | |
| ShapeShift policy | bit 6 | | |
| formerly: Pin Caching | bit 7 | | |
| has_node | bit 8 | | |
| has_mnemonic | bit 9 | | |
| has_u2froot | bit 10 | | |
| Experinemtal policy | bit 11 | | |
| AdvancedMode policy | bit 12 | | |
| no backup (seedless) | bit 13 | | |
| has_sec_fingerprint | bit 14 | | |
| sca_hardened | bit 15 | | |
| has_wipe_code | bit 16 | | |
| v15_16_trans | bit 17 | | |
| reserved | bits 18 - 31 | | |
| pin_failed_attempts | u32 | 4 | 8 |
| auto_lock_delay_ms | u32 | 4 | 12 |
| language | char[16] | 16 | 16 |
| label | char[48] | 48 | 32 |
| wrapped_storage_key | char[64] | 64 | 80 |
| storage_key_fingerprint | char[64] | 32 | 144 |
| wrapped_wipe_code_key | char[64] | 64 | 176 |
| wipe_code_key_fingerprint | char[64] | 32 | 240 |
| u2froot | StorageHDNode | 129 | 272 |
| u2f_counter | u32 | 4 | 401 |
| sec_fingerprint | char[32] | 32 | 405 |
| random_salt | char[32] | 32 | 437 |
| reserved | char[1028] | 1028 | 469 |
| encrypted_secrets_version | u32 | 4 | 1497 |
| encrypted_secrets | char[512] | 512 | 1501 |


#### Secret Storage

| Field | Type | Size (bytes) | Offset (bytes) |
| ------------------------- | -------------- | ------------ | -------------- |
| node | StorageHDNode | 129 | 0 |
| mnemonic | char[241] | 241 | 129 |
| root_seed_cache_status | u8 | 1 | 370 |
| root_seed_cache | char[64] | 64 | 371 |
| root_ecdsa_curve_type | char[10] | 10 | 435 |
| reserved | char[63] | 63 | 445 |
21 changes: 10 additions & 11 deletions fuzzer/firmware/eos_formatAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ extern "C" {
#include <stddef.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size != 16)
return 0;
if (size != 16) return 0;

EosAsset asset;
asset.has_amount = true;
asset.amount = *(const uint64_t*)&data[0];
asset.has_symbol = true;
asset.symbol = *(const uint64_t*)&data[8];
EosAsset asset;
asset.has_amount = true;
asset.amount = *(const uint64_t *)&data[0];
asset.has_symbol = true;
asset.symbol = *(const uint64_t *)&data[8];

char str[EOS_ASSET_STR_SIZE];
eos_formatAsset(&asset, str);
asm volatile("" : : "g"(str) : "memory");
char str[EOS_ASSET_STR_SIZE];
eos_formatAsset(&asset, str);
asm volatile("" : : "g"(str) : "memory");

return 0;
return 0;
}
11 changes: 5 additions & 6 deletions fuzzer/firmware/eos_formatName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ extern "C" {
#include <stddef.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size != 4)
return 0;
if (size != 4) return 0;

char str[EOS_NAME_STR_SIZE];
eos_formatName(*(const uint32_t*)data, str);
asm volatile("" : : "g"(str) : "memory");
char str[EOS_NAME_STR_SIZE];
eos_formatName(*(const uint32_t *)data, str);
asm volatile("" : : "g"(str) : "memory");

return 0;
return 0;
}
38 changes: 17 additions & 21 deletions fuzzer/firmware/ripple_decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,27 @@ extern "C" {
}

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size != 33)
return 0;
if (size != 33) return 0;

uint8_t buff[64];
memset(buff, 0, sizeof(buff));
uint8_t buff[64];
memset(buff, 0, sizeof(buff));

Hasher hasher;
hasher_Init(&hasher, HASHER_SHA2_RIPEMD);
hasher_Update(&hasher, data, 33);
hasher_Final(&hasher, buff + 1);
Hasher hasher;
hasher_Init(&hasher, HASHER_SHA2_RIPEMD);
hasher_Update(&hasher, data, 33);
hasher_Final(&hasher, buff + 1);

char address[56];
if (!ripple_encode_check(buff, 21, HASHER_SHA2D,
address, MAX_ADDR_SIZE))
return 1;
char address[56];
if (!ripple_encode_check(buff, 21, HASHER_SHA2D, address, MAX_ADDR_SIZE))
return 1;

uint8_t addr_raw[MAX_ADDR_RAW_SIZE];
memset(addr_raw, 0, sizeof(addr_raw));
uint32_t addr_raw_len = ripple_decode_check(address, HASHER_SHA2D,
addr_raw, MAX_ADDR_RAW_SIZE);
if (addr_raw_len != 21)
return 2;
uint8_t addr_raw[MAX_ADDR_RAW_SIZE];
memset(addr_raw, 0, sizeof(addr_raw));
uint32_t addr_raw_len =
ripple_decode_check(address, HASHER_SHA2D, addr_raw, MAX_ADDR_RAW_SIZE);
if (addr_raw_len != 21) return 2;

if (memcmp(buff, addr_raw, 21) != 0)
return 3;
if (memcmp(buff, addr_raw, 21) != 0) return 3;

return 0;
return 0;
}
14 changes: 5 additions & 9 deletions include/keepkey/board/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@
#ifndef CANVAS_H
#define CANVAS_H


#include <stdint.h>
#include <stdbool.h>


typedef struct
{
uint8_t* buffer;
uint16_t height;
uint16_t width;
bool dirty;
typedef struct {
uint8_t* buffer;
uint16_t height;
uint16_t width;
bool dirty;
} Canvas;

#endif

24 changes: 12 additions & 12 deletions include/keepkey/board/check_bootloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ extern char bl_hash_v1_0_4_unpatched[32];

extern char bl_hash_v1_1_0[32];
extern char bl_hash_v2_0_0[32];

extern char bl_hash_v2_1_0[32];

typedef enum _BootloaderKind {
BLK_UNKNOWN,
BLK_v1_0_0,
BLK_v1_0_1,
BLK_v1_0_2,
BLK_v1_0_3,
BLK_v1_0_3_sig,
BLK_v1_0_3_elf,
BLK_v1_0_4,
BLK_v1_1_0,
BLK_v2_0_0
BLK_UNKNOWN,
BLK_v1_0_0,
BLK_v1_0_1,
BLK_v1_0_2,
BLK_v1_0_3,
BLK_v1_0_3_sig,
BLK_v1_0_3_elf,
BLK_v1_0_4,
BLK_v1_1_0,
BLK_v2_0_0,
BLK_v2_1_0
} BootloaderKind;

BootloaderKind get_bootloaderKind(void);

#endif

82 changes: 41 additions & 41 deletions include/keepkey/board/confirm_sm.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,31 @@
/* The number of milliseconds to wait for a confirmation */
#define CONFIRM_TIMEOUT_MS 1200

typedef enum
{
HOME,
CONFIRM_WAIT,
CONFIRMED,
FINISHED
} DisplayState;

typedef enum
{
LAYOUT_REQUEST,
LAYOUT_REQUEST_NO_ANIMATION,
LAYOUT_CONFIRM_ANIMATION,
LAYOUT_CONFIRMED,
LAYOUT_FINISHED,
LAYOUT_NUM_LAYOUTS,
LAYOUT_INVALID
typedef enum { HOME, CONFIRM_WAIT, CONFIRMED, FINISHED } DisplayState;

typedef enum {
LAYOUT_REQUEST,
LAYOUT_REQUEST_NO_ANIMATION,
LAYOUT_CONFIRM_ANIMATION,
LAYOUT_CONFIRMED,
LAYOUT_FINISHED,
LAYOUT_NUM_LAYOUTS,
LAYOUT_INVALID
} ActiveLayout;

/* Define the given layout dialog texts for each screen */
typedef struct
{
const char *request_title;
const char *request_body;
typedef struct {
const char *request_title;
const char *request_body;
} ScreenLine;

typedef ScreenLine ScreenLines;
typedef ScreenLines DialogLines[LAYOUT_NUM_LAYOUTS];

typedef struct
{
DialogLines lines;
DisplayState display_state;
ActiveLayout active_layout;
typedef struct {
DialogLines lines;
DisplayState display_state;
ActiveLayout active_layout;
} StateInfo;

typedef void (*layout_notification_t)(const char *str1, const char *str2,
Expand All @@ -72,7 +63,11 @@ typedef void (*layout_notification_t)(const char *str1, const char *str2,
/// \param request_title Title of confirm message.
/// \param request_body Body of confirm message.
/// \returns true iff the device confirmed.
bool confirm(ButtonRequestType type, const char *request_title, const char *request_body,
bool confirm(ButtonRequestType type, const char *request_title,
const char *request_body, ...)
__attribute__((format(printf, 3, 4)));

bool confirm_constant_power(ButtonRequestType type, const char *request_title, const char *request_body,
...) __attribute__((format(printf, 3, 4)));

/// User confirmation.
Expand All @@ -81,8 +76,9 @@ bool confirm(ButtonRequestType type, const char *request_title, const char *requ
/// \param request_body Body of confirm message.
/// \returns true iff the device confirmed.
bool confirm_with_custom_button_request(ButtonRequest *button_request,
const char *request_title, const char *request_body,
...) __attribute__((format(printf, 3, 4)));
const char *request_title,
const char *request_body, ...)
__attribute__((format(printf, 3, 4)));

/// User confirmation, custom layout.
/// \param layout_notification_func Layout callback.
Expand All @@ -92,28 +88,32 @@ bool confirm_with_custom_button_request(ButtonRequest *button_request,
/// \returns true iff the device confirmed.
bool confirm_with_custom_layout(layout_notification_t layout_notification_func,
ButtonRequestType type,
const char *request_title, const char *request_body,
...) __attribute__((format(printf, 4, 5)));
const char *request_title,
const char *request_body, ...)
__attribute__((format(printf, 4, 5)));

/// User confirmation.
///
/// Does not message the host for ButtonAcks.
/// \param request_title Title of confirm message.
/// \param request_body Body of confirm message.
/// \returns true iff the device confirmed.
bool confirm_without_button_request(const char *request_title, const char *request_body,
...) __attribute__((format(printf, 2, 3)));
bool confirm_without_button_request(const char *request_title,
const char *request_body, ...)
__attribute__((format(printf, 2, 3)));

/// Like confirm, but always \returns true.
/// \param request_title Title of confirm message.
/// \param request_body Body of confirm message.
bool review(ButtonRequestType type, const char *request_title, const char *request_body,
...) __attribute__((format(printf, 3, 4)));

/// Like confirm, but always \returns true. Does not message the host for ButtonAcks.
/// \param request_title Title of confirm message.
/// \param request_body Body of confirm message.
bool review_without_button_request(const char *request_title, const char *request_body,
...) __attribute__((format(printf, 2, 3)));
bool review(ButtonRequestType type, const char *request_title,
const char *request_body, ...)
__attribute__((format(printf, 3, 4)));

/// Like confirm, but always \returns true. Does not message the host for
/// ButtonAcks. \param request_title Title of confirm message. \param
/// request_body Body of confirm message.
bool review_without_button_request(const char *request_title,
const char *request_body, ...)
__attribute__((format(printf, 2, 3)));

#endif
Loading

1 comment on commit a988325

@greatwolf
Copy link
Contributor

@greatwolf greatwolf commented on a988325 Oct 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a v6.5.1 tag in the Releases section. But where is the corresponding firmware binary for it? It looks like the bootloader also got bumped up to v2.1.0, Is that required over v2.0.0 for this to work? Again where is the bootloader binary for v2.1.0?

Please sign in to comment.