Skip to content

Commit

Permalink
Merge pull request #323 from keepkey/symbol-display
Browse files Browse the repository at this point in the history
Symbol display
  • Loading branch information
markrypt0 authored Sep 13, 2022
2 parents dc4dc98 + 4a31140 commit d3047c4
Show file tree
Hide file tree
Showing 23 changed files with 1,978 additions and 55 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.7.2)

project(KeepKeyFirmware

VERSION 7.4.0
VERSION 7.5.0

LANGUAGES C CXX ASM)

set(BOOTLOADER_MAJOR_VERSION 2)
set(BOOTLOADER_MINOR_VERSION 1)
set(BOOTLOADER_PATCH_VERSION 4)
set(BOOTLOADER_PATCH_VERSION 5)

option(KK_EMULATOR "Build the emulator" OFF)
option(KK_DEBUG_LINK "Build with debug-link enabled" OFF)
Expand Down
2 changes: 1 addition & 1 deletion deps/device-protocol
7 changes: 7 additions & 0 deletions include/keepkey/board/confirm_sm.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* This file is part of the KeepKey project.
*
* Copyright (c) 2022 markrypto
* Copyright (C) 2018 KeepKey LLC
*
* This library is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -75,6 +76,8 @@ typedef struct {
ActiveLayout active_layout;
} StateInfo;

#define isprint(c) ((c) >= 0x20 && (c) < 0x7f)

typedef void (*layout_notification_t)(const char *str1, const char *str2,
NotificationType type);

Expand Down Expand Up @@ -136,4 +139,8 @@ bool review_without_button_request(const char *request_title,
const char *request_body, ...)
__attribute__((format(printf, 2, 3)));

bool review_with_icon(ButtonRequestType type, IconType iconNum, const char *request_title,
const char *request_body, ...)
__attribute__((format(printf, 4, 5)));

#endif
10 changes: 10 additions & 0 deletions include/keepkey/board/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
/* Margin */
#define TOP_MARGIN 7
#define LEFT_MARGIN 4
#define LEFT_MARGIN_WITH_ICON 40

/* Title */
#define TITLE_COLOR 0xFF
#define TITLE_WIDTH 206
#define TITLE_WIDTH_WITH_ICON TITLE_WIDTH-LEFT_MARGIN_WITH_ICON
#define TITLE_ROWS 1
#define TITLE_FONT_LINE_PADDING 0
#define TITLE_CHAR_MAX 128
Expand All @@ -51,6 +53,7 @@
#define BODY_TOP_MARGIN 7
#define BODY_COLOR 0xFF
#define BODY_WIDTH 225
#define BODY_WIDTH_WITH_ICON BODY_WIDTH-LEFT_MARGIN_WITH_ICON
#define BODY_ROWS 3
#define BODY_FONT_LINE_PADDING 4
#define BODY_CHAR_MAX 352
Expand All @@ -73,6 +76,11 @@ typedef enum {
NOTIFICATION_LOGO,
} NotificationType;

typedef enum {
NO_ICON=0,
ETHEREUM_ICON,
} IconType;

typedef void (*AnimateCallback)(void *data, uint32_t duration,
uint32_t elapsed);
typedef struct Animation Animation;
Expand All @@ -92,6 +100,7 @@ typedef struct {

} AnimationQueue;

void layout_has_icon(bool tf);
void layout_init(Canvas *canvas);
Canvas *layout_get_canvas(void);
void call_leaving_handler(void);
Expand All @@ -100,6 +109,7 @@ void layout_standard_notification(const char *str1, const char *str2,
NotificationType type);
void layout_constant_power_notification(const char *str1, const char *str2, NotificationType type);
void layout_notification_icon(NotificationType type, DrawableParams *sp);
void layout_add_icon(IconType type);
void layout_warning(const char *prompt);
void layout_warning_static(const char *str);
void layout_simple_message(const char *str);
Expand Down
1 change: 1 addition & 0 deletions include/keepkey/board/resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <stdint.h>
#include <stdbool.h>

const AnimationFrame *get_ethereum_icon_frame(void);
const AnimationFrame *get_confirm_icon_frame(void);
const AnimationFrame *get_confirmed_frame(void);
const AnimationFrame *get_unplug_frame(void);
Expand Down
111 changes: 111 additions & 0 deletions include/keepkey/firmware/eip712.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

/*
* Copyright (c) 2022 markrypto ([email protected])
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/


/*
Produces hashes based on the metamask v4 rules. This is different from the EIP-712 spec
in how arrays of structs are hashed but is compatable with metamask.
See https://github.com/MetaMask/eth-sig-util/pull/107
eip712 data rules:
Parser wants to see C strings, not javascript strings:
requires all complete json message strings to be enclosed by braces, i.e., { ... }
Cannot have entire json string quoted, i.e., "{ ... }" will not work.
Remove all quote escape chars, e.g., {"types": not {\"types\":
int values must be hex. Negative sign indicates negative value, e.g., -5, -8a67
Note: Do not prefix ints or uints with 0x
All hex and byte strings must be big-endian
Byte strings and address should be prefixed by 0x
*/
#ifndef EIP712_H
#define EIP712_H

#include "keepkey/firmware/tiny-json.h"

#define USE_KECCAK 1
#define ADDRESS_SIZE 42
#define JSON_OBJ_POOL_SIZE 100
#define STRBUFSIZE 511
#define MAX_USERDEF_TYPES 10 // This is max number of user defined type allowed
#define MAX_TYPESTRING 33 // maximum size for a type string
#define MAX_ENCBYTEN_SIZE 66
#define STACK_REENTRANCY_REQ 1280 // calculate this from a re-entrant call (unsigned)&p - (unsigned)&end)
#define STACK_SIZE_GUARD (STACK_REENTRANCY_REQ + 64) // Can't recurse without this much stack available

typedef enum {
NOT_ENCODABLE = 0,
ADDRESS,
STRING,
UINT,
INT,
BYTES,
BYTES_N,
BOOL,
UDEF_TYPE,
PREV_USERDEF,
TOO_MANY_UDEFS
} basicType;

typedef enum {
DOMAIN = 1,
MESSAGE
} dm;

// error list status
#define SUCCESS 1
#define NULL_MSG_HASH 2 // this is legal, not an error
#define GENERAL_ERROR 3
#define UDEF_NAME_ERROR 4
#define UDEFS_OVERFLOW 5
#define UDEF_ARRAY_NAME_ERR 6
#define ADDR_STRING_VFLOW 7
#define BYTESN_STRING_ERROR 8
#define BYTESN_SIZE_ERROR 9
#define INT_ARRAY_ERROR 10
#define BYTESN_ARRAY_ERROR 11
#define BOOL_ARRAY_ERROR 12
#define RECURSION_ERROR 13

#define JSON_PTYPENAMEERR 14
#define JSON_PTYPEVALERR 15
#define JSON_TYPESPROPERR 16
#define JSON_TYPE_SPROPERR 17
#define JSON_DPROPERR 18
#define MSG_NO_DS 19
#define JSON_MPROPERR 20
#define JSON_PTYPESOBJERR 21
#define JSON_TYPE_S_ERR 22
#define JSON_TYPE_S_NAMEERR 23
#define UNUSED_ERR_2 24 // available for re-use
#define JSON_NO_PAIRS 25
#define JSON_PAIRS_NOTEXT 26
#define JSON_NO_PAIRS_SIB 27
#define TYPE_NOT_ENCODABLE 28
#define JSON_NOPAIRVAL 29
#define JSON_NOPAIRNAME 30
#define JSON_TYPE_T_NOVAL 31
#define ADDR_STRING_NULL 32
#define JSON_TYPE_WNOVAL 33

#define LAST_ERROR JSON_TYPE_WNOVAL

int memcheck(void);
int encode(const json_t *jsonTypes, const json_t *jsonVals, const char *typeS, uint8_t *hashRet);

#endif

1 change: 1 addition & 0 deletions include/keepkey/firmware/ethereum.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ void ethereum_typed_hash_sign(const EthereumSignTypedHash *msg,
EthereumTypedDataSignature *resp);
bool ethereum_path_check(uint32_t address_n_count, const uint32_t *address_n,
bool pubkey_export, uint64_t chain);
void e712_types_values(Ethereum712TypesValues *msg, EthereumTypedDataSignature *resp, const HDNode *node);

#endif
1 change: 1 addition & 0 deletions include/keepkey/firmware/fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void fsm_msgEthereumTxAck(EthereumTxAck *msg);
void fsm_msgEthereumSignMessage(EthereumSignMessage *msg);
void fsm_msgEthereumVerifyMessage(const EthereumVerifyMessage *msg);
void fsm_msgEthereumSignTypedHash(const EthereumSignTypedHash *msg);
void fsm_msgEthereum712TypesValues(Ethereum712TypesValues *msg);

void fsm_msgNanoGetAddress(NanoGetAddress *msg);
void fsm_msgNanoSignTx(NanoSignTx *msg);
Expand Down
Loading

0 comments on commit d3047c4

Please sign in to comment.