Skip to content

Commit cb7fd23

Browse files
committed
DONTMERGE: attempt to get debug_scan_qr working
It turns out whatever miniz is producing, its not compatible with compress/uncompress from zlib with the flags we are using. It seems we don't include any header bytes in the compressed data and so we'd probably need to prepend a fake header to get this to work. This commit doesn't enable the debug_scan_qr tests so shouldn't fail the build.
1 parent c9713f1 commit cb7fd23

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

libjade/include/miniz.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#ifndef _SW_JADE_MINIZ_H_
2+
#define _SW_JADE_MINIZ_H_ 1
3+
#include <zlib.h>
4+
5+
#define TDEFL_DEFAULT_MAX_PROBES 0
6+
#define TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF 0
7+
#define TDEFL_FINISH 0
8+
9+
typedef struct tdefl_compressor
10+
{
11+
int unused;
12+
} tdefl_compressor;
13+
14+
typedef struct tdefl_compressor tinfl_decompressor;
15+
16+
typedef int tdefl_status;
17+
typedef int tinfl_status;
18+
19+
#define TDEFL_STATUS_OKAY Z_OK
20+
#define TDEFL_STATUS_DONE Z_OK
21+
#define TINFL_STATUS_DONE Z_OK
22+
23+
static inline tdefl_status tdefl_init(void* ctx, void* unused, void* unused2, int flags)
24+
{
25+
return TDEFL_STATUS_OKAY;
26+
}
27+
28+
static inline tdefl_status tdefl_compress(tdefl_compressor* ctx, const uint8_t* data, size_t *data_len, uint8_t* output, size_t *output_len, int flags)
29+
{
30+
// Defer to zlib
31+
return compress2(output, output_len, data, *data_len, Z_BEST_COMPRESSION);
32+
}
33+
34+
static inline tinfl_status tinfl_init(tinfl_decompressor* ctx)
35+
{
36+
return TDEFL_STATUS_OKAY;
37+
}
38+
39+
static inline tinfl_status tinfl_decompress(tinfl_decompressor* ctx, const uint8_t* data, size_t *data_len, uint8_t* output, uint8_t* output_nex, size_t *output_len, int flags)
40+
{
41+
return uncompress2(output, output_len, data, data_len);
42+
}
43+
44+
#endif // _SW_JADE_MINIZ_H_

libjade/libjade.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ static void unsupported_process(void* process, char* name)
151151
}
152152
#define UNSUPPORTED(n) void n##_process(void* p) { unsupported_process(p, #n); }
153153

154-
UNSUPPORTED(debug_scan_qr)
155154
UNSUPPORTED(get_bip85_bip39_entropy)
156155
UNSUPPORTED(get_bip85_rsa_entropy)
157156
int get_bip85_bip39_entropy_cbor(const CborValue* params, CborEncoder* output, const char** errmsg)

main/amalgamated.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ void __wrap_abort(void);
8686
#include "./process/dashboard.c"
8787
#include "./process/debug_clean.c"
8888
#include "./process/debug_handshake.c"
89-
#ifndef CONFIG_LIBJADE
9089
#include "./process/debug_scan_qr.c"
91-
#endif // CONFIG_LIBJADE
9290
#include "./process/debug_set_mnemonic.c"
9391
#ifndef CONFIG_LIBJADE
9492
#include "./process/get_bip85_entropy.c"

make_libjade.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ ${SW_JADE_CC} -c ${SW_JADE_CFLAGS} \
7171
# libjade.so
7272
${SW_JADE_CXX} -shared -pthread -Wl,--no-undefined \
7373
-fPIC -DPIC -fvisibility=hidden \
74-
libjade/libjade.o libjade/bc_ur.o ${SW_JADE_LDFLAGS} -lm -o libjade.so
74+
libjade/libjade.o libjade/bc_ur.o ${SW_JADE_LDFLAGS} -lm -lz -o libjade.so
7575

7676
rm -f libjade/libjade.o libjade/bc_ur.o

0 commit comments

Comments
 (0)