Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #75

Closed
wants to merge 11 commits into from
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ matrix:
sources:
- ubuntu-toolchain-r-test
- os: osx
env:
- PYTHON=python3

before_script:
- sh "./tiny-firmware/protob/ci-scripts/install-${TRAVIS_OS_NAME}.sh" ;
Expand Down
2 changes: 1 addition & 1 deletion tiny-firmware/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.7.0
v1.0.0
2 changes: 1 addition & 1 deletion tiny-firmware/bootloader/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.5.0
v1.0.0
2 changes: 1 addition & 1 deletion tiny-firmware/bootloader/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void bootloader_loop(void)
} else {
oledDrawString(52, 10, "Welcome!", FONT_STANDARD);
oledDrawString(52, 30, "Please visit", FONT_STANDARD);
oledDrawString(52, 50, "skycoin.net", FONT_STANDARD);
oledDrawString(52, 50, "skycoin.com", FONT_STANDARD);
}
oledRefresh();

Expand Down
10 changes: 5 additions & 5 deletions tiny-firmware/bootloader/combine/prepare.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python
from __future__ import print_function

bl = open('bl.bin').read()
fw = open('fw.bin').read()
combined = bl + fw[:256] + (32768-256)*'\x00' + fw[256:]
bl = open('bl.bin', "rb").read()
fw = open('fw.bin', "rb").read()
combined = bl + fw[:256] + (32768-256)*b'\x00' + fw[256:]

open('combined.bin', 'w').write(combined)
open('combined.bin', 'wb').write(combined)

print('bootloader : %d bytes' % len(bl))
print('firmware : %d bytes' % len(fw))
print('combined : %d bytes' % len(combined))

20 changes: 14 additions & 6 deletions tiny-firmware/firmware/bootloader_integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@
*/
#include "bootloader_integrity.h"
#include "memory.h"
#include "sha2.h"
#include "string.h"

int check_bootloader(void) {
uint8_t hash[32];
static char *bootloader_hashes[] = {
"\x35\xf7\xb6\x20\x72\xcc\x84\x6e\x63\x5a\x0b\x36\xd6\x60\x40\x50\x0e\x71\x6a\x7c\xad\x1e\x64\x50\x5f\xbd\x64\x21\xcf\x07\x75\x5e",
"\x13\xa2\x8e\xc7\x4d\x3c\xca\x6a\xe8\xc5\xf7\x26\xb1\x59\xf7\x0b\x5b\x86\x33\x1c\x51\x57\x93\xe0\x5c\x82\xde\x60\xc2\x7b\xd0\x18",
"\x57\x28\x17\x0b\x2b\x59\x9a\x46\x40\xac\x80\x05\x14\x3c\xa7\x9f\xdf\x96\x77\xdd\xc9\x85\x19\x50\x31\x13\x67\x02\x41\x9a\x45\x35"
};

bool check_bootloader(void) {
uint8_t hash[SHA256_DIGEST_LENGTH];
memory_bootloader_hash(hash);
return !memcmp(hash,
"\x63\x30\xfc\xec\x16\x72\xfa\xd3\x0b\x42\x1b\x60\xf7\x4f\x83\x9a\x39\x39\x33\x45\x65\xcb\x70\x3b\x2b\xd7\x18\x2e\xa2\xdd\xa0\x19",
32);
bool is_official = false;
for (uint32_t i = 0; i < sizeof(bootloader_hashes) / sizeof(char *); i++) {
is_official |= !memcmp(hash, bootloader_hashes[i], 32);
}
return is_official;
}

3 changes: 2 additions & 1 deletion tiny-firmware/firmware/bootloader_integrity.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

#ifndef HARDWARE_WALLET_BOOTLOADER_CHECK_H
#define HARDWARE_WALLET_BOOTLOADER_CHECK_H
#include <stdbool.h>

int check_bootloader(void);
bool check_bootloader(void);

#endif //HARDWARE_WALLET_BOOTLOADER_CHECK_H