1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-26 00:08:10 +00:00

vendor: replace vendor/trezor-qrenc with vendor/QR-Code-generator

This commit is contained in:
Pavol Rusnak 2019-02-16 17:21:35 +01:00
parent 92382d3f2c
commit 79e9ae28b7
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
6 changed files with 26 additions and 15 deletions

6
.gitmodules vendored
View File

@ -4,9 +4,6 @@
[submodule "trezor-common"]
path = vendor/trezor-common
url = https://github.com/trezor/trezor-common.git
[submodule "trezor-qrenc"]
path = vendor/trezor-qrenc
url = https://github.com/trezor/trezor-qrenc.git
[submodule "libopencm3"]
path = vendor/libopencm3
url = https://github.com/libopencm3/libopencm3.git
@ -16,3 +13,6 @@
[submodule "vendor/trezor-storage"]
path = vendor/trezor-storage
url = https://github.com/trezor/trezor-storage.git
[submodule "vendor/QR-Code-generator"]
path = vendor/QR-Code-generator
url = https://github.com/nayuki/QR-Code-generator.git

View File

@ -72,7 +72,7 @@ CFLAGS += $(OPTFLAGS) \
-I$(TOP_DIR) \
-I$(TOP_DIR)gen \
-I$(TOP_DIR)vendor/trezor-crypto \
-I$(TOP_DIR)vendor/trezor-qrenc \
-I$(TOP_DIR)vendor/QR-Code-generator/c \
-I$(TOP_DIR)vendor/trezor-storage
LDFLAGS += -L$(TOP_DIR) \

View File

@ -82,7 +82,7 @@ OBJS += ../vendor/trezor-crypto/chacha20poly1305/rfc7539.o
OBJS += ../vendor/trezor-crypto/nem.o
OBJS += ../vendor/trezor-qrenc/qr_encode.o
OBJS += ../vendor/QR-Code-generator/c/qrcodegen.o
OBJS += ../vendor/trezor-storage/storage.o
OBJS += ../vendor/trezor-storage/norcow.o
@ -117,7 +117,6 @@ DEBUG_LOG ?= 0
CFLAGS += -Wno-sequence-point
CFLAGS += -I../vendor/nanopb -Iprotob -DPB_FIELD_16BIT=1
CFLAGS += -DQR_MAX_VERSION=0
CFLAGS += -DDEBUG_LINK=$(DEBUG_LINK)
CFLAGS += -DDEBUG_LOG=$(DEBUG_LOG)
CFLAGS += -DSCM_REVISION='"$(shell git rev-parse HEAD | sed 's:\(..\):\\x\1:g')"'

View File

@ -27,7 +27,7 @@
#include "bitmaps.h"
#include "string.h"
#include "util.h"
#include "qr_encode.h"
#include "qrcodegen.h"
#include "timer.h"
#include "bignum.h"
#include "secp256k1.h"
@ -553,6 +553,8 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last)
oledRefresh();
}
#define QR_MAX_VERSION 9
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase, const uint32_t *address_n, size_t address_n_count, bool address_is_account)
{
if (layoutLast != layoutAddress) {
@ -564,7 +566,6 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
uint32_t addrlen = strlen(address);
if (qrcode) {
static unsigned char bitdata[QR_MAX_BITDATA];
char address_upcase[addrlen + 1];
if (ignorecase) {
for (uint32_t i = 0; i < addrlen + 1; i++) {
@ -572,16 +573,28 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
address[i] + 'A' - 'a' : address[i];
}
}
int side = qr_encode(addrlen <= (ignorecase ? 60 : 40) ? QR_LEVEL_M : QR_LEVEL_L, 0,
ignorecase ? address_upcase : address, 0, bitdata);
uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)];
uint8_t tempdata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)];
int side = 0;
if (qrcodegen_encodeText(
ignorecase ? address_upcase : address,
tempdata,
codedata,
qrcodegen_Ecc_LOW,
qrcodegen_VERSION_MIN,
QR_MAX_VERSION,
qrcodegen_Mask_AUTO,
true)) {
side = qrcodegen_getSize(codedata);
}
oledInvert(0, 0, 63, 63);
if (side > 0 && side <= 29) {
int offset = 32 - side;
for (int i = 0; i < side; i++) {
for (int j = 0; j< side; j++) {
int a = j * side + i;
if (bitdata[a / 8] & (1 << (7 - a % 8))) {
if (qrcodegen_getModule(codedata, i, j)) {
oledBox(offset + i * 2, offset + j * 2,
offset + 1 + i * 2, offset + 1 + j * 2, false);
}
@ -591,8 +604,7 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
int offset = 32 - (side / 2);
for (int i = 0; i < side; i++) {
for (int j = 0; j< side; j++) {
int a = j * side + i;
if (bitdata[a / 8] & (1 << (7 - a % 8))) {
if (qrcodegen_getModule(codedata, i, j)) {
oledClearPixel(offset + i, offset + j);
}
}

1
vendor/QR-Code-generator vendored Submodule

@ -0,0 +1 @@
Subproject commit 40d24f38aa0a8180b271b6c88be8633f842ed9d4

1
vendor/trezor-qrenc vendored

@ -1 +0,0 @@
Subproject commit 4da44cacb7bd69aa297bafe4a41c498a050225a4