Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/up/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebseb7 committed Mar 4, 2019
2 parents 8226c47 + 0d11a6e commit c752d2b
Show file tree
Hide file tree
Showing 17 changed files with 651 additions and 258 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ ICONNAME = images/icon_monero.gif
endif

APPVERSION_M=1
APPVERSION_N=0
APPVERSION_P=1
APPVERSION_N=1
APPVERSION_P=3

APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
SPECVERSION="0.x.0"
SPECVERSION="0.9.0"

DEFINES += $(MONERO_CONFIG) MONERO_VERSION=$(APPVERSION) MONERO_NAME=$(APPNAME) SPEC_VERSION=$(SPECVERSION)

Expand Down Expand Up @@ -65,7 +65,7 @@ DEFINES += UNUSED\(x\)=\(void\)x
DEFINES += APPVERSION=\"$(APPVERSION)\"
DEFINES += CUSTOM_IO_APDU_BUFFER_SIZE=\(255+5+64\)

DEFINES += HAVE_USB_CLASS_CCID
#DEFINES += HAVE_USB_CLASS_CCID


#DEFINES += IOCRYPT
Expand Down Expand Up @@ -94,6 +94,8 @@ CFLAGS += -O3 -Os
AS := $(GCCPATH)arm-none-eabi-gcc

LD := $(GCCPATH)arm-none-eabi-gcc
SCRIPT_LD:=script.ld

#LDFLAGS += -O0 -gdwarf-2 -gstrict-dwarf
LDFLAGS += -O3 -Os
LDLIBS += -lm -lgcc -lc
Expand Down
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,43 @@
Monero wallet application for Ledger Blue and Nano S


# Revision
# Revision

## v1.1.3

- Remove rolling address display
- Allow STEALTH instruction outside TX
- Doc fix

## v1.1.2

Fix stack overflow for 1.5.5 SDK

## v1.1.1

Allow transaction parsing when screen is locked

## v1.1.0

Initial Release

Targeted Client: Monero 0.13.0.0+

- Security fix: Screen lock management
- Optimisation: New protocol V2 for future
- Fix bug in large amount display that was truncated
- Remove confirmation for zero amount (fake sweep change)
- Better handling for change address to not display them
- Dual id (PIN based) management
- Add onscreen seed words display


## v1.0.0

Initial Release

Targeted Client: Monero 0.13.0.0+


## v 0.12.4 / Beta 5

Expand All @@ -30,7 +66,7 @@ Targeted Client: Monero 0.12.1
## v 0.12.1 / Beta 2

Targeted Client: Monero 0.12.1

- Add second PIN support
- Remove key storage in NVRAM, always recompute secret key at boot
- Export secret viewkey, with agreement of user, to speed up tx scan
Expand All @@ -41,4 +77,4 @@ Targeted Client: Monero 0.12.1

Targeted Client: Monero 0.12.0

- Initial Beta.
- Initial Beta.
27 changes: 3 additions & 24 deletions doc/user/bolos-app-monero.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,17 @@ System Configuration
Linux
~~~~~

The following packages must be installed: pcsc-tools pcscd libpcsclite1:amd64 .

You have to have to add the NanoS to /etc/libccid_Info.plist

In <key>ifdVendorID</key> add the entry <string>0x2C97</string>
In <key>ifdProductID</key> add the entry <string>0x0001</string>
In <key>ifdFriendlyName</key> add the entry <string>Ledger Token</string>

These 3 entries must be added at the end of each list.
TO BE REWRITE FOR HID

MAC
~~~

The SmartCard service must be installed. See https://smartcardservices.github.io/

1. First it is necessary to [disable SIP](https://developer.apple.com/library/mac/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html) That doesn't allow the editing of files in /usr/.

2. You have to add the Nano S to /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist


In <key>ifdVendorID</key> add the entry <string>0x2C97</string>
In <key>ifdProductID</key> add the entry <string>0x0001</string>
In <key>ifdFriendlyName</key> add the entry <string>Ledger Token</string>

This 3 entries must be added at the end of each list.

3. [Enable SIP](https://developer.apple.com/library/content/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html)
TO BE REWRITE FOR HID

Windows
~~~~~~~

SmartCard service should be already installed. Maybe you have to start it.
TO BE REWRITE FOR HID



Expand Down
170 changes: 170 additions & 0 deletions script.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*******************************************************************************
* Ledger Blue - Secure firmware
* (c) 2016, 2017, 2018, 2019 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/

/**
* Global chip memory layout and constants
*
*/

MEMORY
{
DISCARD (rwx) : ORIGIN = 0xd0000000, LENGTH = 1M

FLASH (rx) : ORIGIN = 0xc0d00000, LENGTH = 400K
SRAM (rwx) : ORIGIN = 0x20001800, LENGTH = 4K
}

PAGE_SIZE = 64;
STACK_SIZE = 768;
END_STACK = ORIGIN(SRAM) + LENGTH(SRAM);

SECTIONS
{
ENTRY(main)

/****************************************************************/
/* This section locates the code in FLASH */
/****************************************************************/

/** put text in Flash memory, VMA will be equal to LMA */
.text :
{
/* provide start code symbol, shall be zero */
_text = .;
_nvram = .;

PROVIDE(_setjmp = setjmp); /*thanks clang*/

/* ensure main is always @ 0xC0D00000 */
*(.boot*)

/* place the other code and rodata defined BUT nvram variables that are displaced in a r/w area */
*(.text*)
*(.rodata)
*(.rodata.[^N]*) /*.data.rel.ro* not here to detect invalid PIC usage */
*(.rodata.N[^_]*)

. = ALIGN(4);

/* all code placed */
_etext = .;

. = ALIGN(PAGE_SIZE);

_nvram_data = .;

/* NVM data (ex-filesystem) */
*(.bss.N_* .rodata.N_*)

. = ALIGN(PAGE_SIZE);
_install_parameters = .;
PROVIDE(N_install_parameters = .);
_envram = .;
_nvram_data_size = _envram - _nvram_data;

} > FLASH = 0x00

.data (NOLOAD):
{
. = ALIGN(4);

/**
* Place RAM initialized variables
*/
_data = .;

*(vtable)
*(.data*)

_edata = .;

} > DISCARD /*> SRAM AT>FLASH = 0x00 */

.bss :
{
/**
* Place RAM uninitialized variables
*/
_bss = .;
*(.bss*)
_ebss = .;


/**
* Reserve stack size
*/
. = ALIGN(4);
app_stack_canary = .;
PROVIDE(app_stack_canary = .);
. += 4;
_stack_validation = .;
. = _stack_validation + STACK_SIZE;
_stack = ABSOLUTE(END_STACK) - STACK_SIZE;
PROVIDE( _stack = ABSOLUTE(END_STACK) - STACK_SIZE);
_estack = ABSOLUTE(END_STACK);
PROVIDE( _estack = ABSOLUTE(END_STACK) );

} > SRAM = 0x00

/****************************************************************/
/* DEBUG */
/****************************************************************/

/* remove the debugging information from the standard libraries */
DEBUG (NOLOAD) :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
}

/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }

}
14 changes: 8 additions & 6 deletions src/monero_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ int monero_apdu_get_subaddress_spend_public_key(void);
int monero_apdu_get_subaddress_secret_key(void);

int monero_apdu_open_tx(void);
void monero_reset_tx(void);
int monero_apdu_open_subtx(void) ;
int monero_apdu_set_signature_mode(void) ;
int monero_apdu_stealth(void);
Expand Down Expand Up @@ -162,12 +163,13 @@ int monero_hash(unsigned int algo, cx_hash_t * hasher, unsigned char* buf, unsi
#define monero_sha256_commitment_final(out) \
monero_hash_final((cx_hash_t *)&G_monero_vstate.sha256_commitment, (out)?(out):G_monero_vstate.C)

#define monero_sha256_amount_init() \
monero_hash_init_sha256((cx_hash_t *)&G_monero_vstate.sha256_amount)
#define monero_sha256_amount_update(buf,len) \
monero_hash_update((cx_hash_t *)&G_monero_vstate.sha256_amount, (buf), (len))
#define monero_sha256_amount_final(out) \
monero_hash_final((cx_hash_t *)&G_monero_vstate.sha256_amount, (out)?(out):G_monero_vstate.KV)
#define monero_sha256_outkeys_init() \
monero_hash_init_sha256((cx_hash_t *)&G_monero_vstate.sha256_out_keys)
#define monero_sha256_outkeys_update(buf,len) \
monero_hash_update((cx_hash_t *)&G_monero_vstate.sha256_out_keys, (buf), (len))
#define monero_sha256_outkeys_final(out) \
monero_hash_final((cx_hash_t *)&G_monero_vstate.sha256_out_keys, (out)?(out):G_monero_vstate.OUTK)


/**
* LE-7-bits encoding. High bit set says one more byte to decode.
Expand Down
5 changes: 0 additions & 5 deletions src/monero_blind.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ int monero_apdu_blind() {

monero_io_discard(1);

//Update Hkv
monero_sha256_amount_update(AKout,32);
monero_sha256_amount_update(k,32);
monero_sha256_amount_update(v,32);

//blind mask
monero_hash_to_scalar(AKout, AKout);
monero_addm(k,k,AKout);
Expand Down
Loading

0 comments on commit c752d2b

Please sign in to comment.