Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
update trezor-crypto, adapt firmware to to changes
Browse files Browse the repository at this point in the history
  • Loading branch information
prusnak committed Jan 13, 2018
1 parent 7e382fb commit c4e3596
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 42 deletions.
3 changes: 1 addition & 2 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ CFLAGS += $(OPTFLAGS) \
$(FPUFLAGS) \
-DSTM32F2 \
-DCONFIDENTIAL='__attribute__((section("confidential")))' \
-DRAND_PLATFORM_INDEPENDENT=1 \
-I$(TOOLCHAIN_DIR)/include \
-I$(TOP_DIR) \
-I$(TOP_DIR)gen \
-I$(TOP_DIR)vendor/trezor-crypto \
-I$(TOP_DIR)vendor/trezor-crypto/aes \
-I$(TOP_DIR)vendor/trezor-crypto/ed25519-donna \
-I$(TOP_DIR)vendor/trezor-qrenc

LDFLAGS += -L$(TOP_DIR) \
Expand Down
1 change: 1 addition & 0 deletions firmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ OBJS += ../vendor/trezor-crypto/ecdsa.o
OBJS += ../vendor/trezor-crypto/curves.o
OBJS += ../vendor/trezor-crypto/secp256k1.o
OBJS += ../vendor/trezor-crypto/nist256p1.o
OBJS += ../vendor/trezor-crypto/rand.o

OBJS += ../vendor/trezor-crypto/ed25519-donna/curve25519-donna-32bit.o
OBJS += ../vendor/trezor-crypto/ed25519-donna/curve25519-donna-helpers.o
Expand Down
2 changes: 1 addition & 1 deletion firmware/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "sha2.h"
#include "ripemd160.h"
#include "pbkdf2.h"
#include "aes.h"
#include "aes/aes.h"
#include "hmac.h"
#include "bip32.h"
#include "layout.h"
Expand Down
2 changes: 1 addition & 1 deletion firmware/fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "usb.h"
#include "util.h"
#include "signing.h"
#include "aes.h"
#include "aes/aes.h"
#include "hmac.h"
#include "crypto.h"
#include "base58.h"
Expand Down
2 changes: 1 addition & 1 deletion firmware/nem2.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "nem2.h"

#include "aes.h"
#include "aes/aes.h"
#include "fsm.h"
#include "gettext.h"
#include "layout2.h"
Expand Down
2 changes: 1 addition & 1 deletion firmware/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "trezor.h"
#include "sha2.h"
#include "aes.h"
#include "aes/aes.h"
#include "pbkdf2.h"
#include "bip32.h"
#include "bip39.h"
Expand Down
28 changes: 0 additions & 28 deletions rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,3 @@ uint32_t random32(void)
return new;
}
#endif

uint32_t random_uniform(uint32_t n)
{
uint32_t x, max = 0xFFFFFFFF - (0xFFFFFFFF % n);
while ((x = random32()) >= max);
return x / (max / n);
}

void random_buffer(uint8_t *buf, size_t len)
{
uint32_t r = 0;
for (size_t i = 0; i < len; i++) {
if (i % 4 == 0) {
r = random32();
}
buf[i] = (r >> ((i % 4) * 8)) & 0xFF;
}
}

void random_permute(char *str, size_t len)
{
for (int i = len - 1; i >= 1; i--) {
int j = random_uniform(i + 1);
char t = str[j];
str[j] = str[i];
str[i] = t;
}
}
8 changes: 1 addition & 7 deletions rng.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
#ifndef __RNG_H__
#define __RNG_H__

#include <stdint.h>
#include <stdlib.h>

uint32_t random32(void);
uint32_t random_uniform(uint32_t n);
void random_buffer(uint8_t *buf, size_t len);
void random_permute(char *buf, size_t len);
#include "rand.h"

#endif
2 changes: 1 addition & 1 deletion vendor/trezor-crypto
Submodule trezor-crypto updated 13 files
+1 −4 Makefile
+4 −4 bip32.c
+1 −1 bip32.h
+1 −1 bip39_english.h
+220 −359 blake256.c
+3 −27 blake256.h
+1 −1 nem.c
+1 −1 nem.h
+28 −40 rand.c
+0 −1 rand.h
+3 −3 test_check.c
+11 −2 test_openssl.c
+1 −1 test_speed.c

0 comments on commit c4e3596

Please sign in to comment.