mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
remove scons dependency, build shared library with Makefile
This commit is contained in:
parent
cbbc0bdc71
commit
418e86c293
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,8 +8,6 @@ build/
|
||||
dist/
|
||||
MANIFEST
|
||||
TrezorCrypto.c
|
||||
SConstruct
|
||||
.sconsign.dblite
|
||||
*.os
|
||||
*.so
|
||||
*.pyc
|
||||
|
17
Makefile
17
Makefile
@ -30,15 +30,17 @@ ifdef SMALL
|
||||
CFLAGS += -DUSE_PRECOMPUTED_IV=0 -DUSE_PRECOMPUTED_CP=0
|
||||
endif
|
||||
|
||||
OBJS = bignum.o ecdsa.o secp256k1.o nist256p1.o rand.o hmac.o bip32.o bip39.o pbkdf2.o base58.o
|
||||
OBJS += ripemd160.o
|
||||
OBJS += sha2.o
|
||||
OBJS += aescrypt.o aeskey.o aestab.o aes_modes.o
|
||||
SRCS = bignum.c ecdsa.c secp256k1.c nist256p1.c rand.c hmac.c bip32.c bip39.c pbkdf2.c base58.c
|
||||
SRCS += ripemd160.c
|
||||
SRCS += sha2.c
|
||||
SRCS += aescrypt.c aeskey.c aestab.c aes_modes.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
TESTLIBS = -lcheck -lrt -lpthread -lm
|
||||
TESTSSLLIBS = -lcrypto
|
||||
|
||||
all: tests test-openssl
|
||||
all: tests test-openssl libtrezor-crypto.so
|
||||
|
||||
%.o: %.c %.h options.h
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
@ -49,5 +51,8 @@ tests: tests.o $(OBJS)
|
||||
test-openssl: test-openssl.o $(OBJS)
|
||||
$(CC) test-openssl.o $(OBJS) $(TESTSSLLIBS) -o test-openssl
|
||||
|
||||
libtrezor-crypto.so: $(SRCS)
|
||||
$(CC) $(CFLAGS) -fPIC -shared $(SRCS) -o libtrezor-crypto.so
|
||||
|
||||
clean:
|
||||
rm -f *.o tests test-openssl
|
||||
rm -f *.o tests test-openssl libtrezor-crypto.so
|
||||
|
@ -3,10 +3,9 @@ import ctypes as c
|
||||
import random
|
||||
import ecdsa
|
||||
import hashlib
|
||||
import subprocess
|
||||
import binascii
|
||||
import pytest
|
||||
import os
|
||||
import pytest
|
||||
|
||||
def bytes2num(s):
|
||||
res = 0
|
||||
@ -22,20 +21,7 @@ curves = {
|
||||
|
||||
random_iters = int(os.environ.get('ITERS', 1))
|
||||
|
||||
scons_file = '''
|
||||
srcs = 'ecdsa bignum secp256k1 nist256p1 sha2 rand hmac ripemd160 base58'
|
||||
srcs = [(s + '.c') for s in srcs.split()]
|
||||
flags = ('-O3 -g -W -Wall -Wextra -Wimplicit-function-declaration '
|
||||
'-Wredundant-decls -Wstrict-prototypes -Wundef -Wshadow '
|
||||
'-Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar '
|
||||
'-Wformat-nonliteral -Winit-self -Wuninitialized -Wformat-security '
|
||||
'-Werror -Wno-sequence-point ')
|
||||
SharedLibrary('ecdsa', srcs, CCFLAGS=flags)
|
||||
'''
|
||||
open('SConstruct', 'w').write(scons_file)
|
||||
|
||||
subprocess.check_call('scons -s', shell=True)
|
||||
lib = c.cdll.LoadLibrary('./libecdsa.so')
|
||||
lib = c.cdll.LoadLibrary('./libtrezor-crypto.so')
|
||||
|
||||
lib.get_curve_by_name.restype = c.c_void_p
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user