1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-04-27 20:49:02 +00:00

remove scons dependency, build shared library with Makefile

This commit is contained in:
Pavol Rusnak 2015-08-05 16:16:24 +02:00
parent cbbc0bdc71
commit 418e86c293
3 changed files with 13 additions and 24 deletions

2
.gitignore vendored
View File

@ -8,8 +8,6 @@ build/
dist/ dist/
MANIFEST MANIFEST
TrezorCrypto.c TrezorCrypto.c
SConstruct
.sconsign.dblite
*.os *.os
*.so *.so
*.pyc *.pyc

View File

@ -30,15 +30,17 @@ ifdef SMALL
CFLAGS += -DUSE_PRECOMPUTED_IV=0 -DUSE_PRECOMPUTED_CP=0 CFLAGS += -DUSE_PRECOMPUTED_IV=0 -DUSE_PRECOMPUTED_CP=0
endif endif
OBJS = bignum.o ecdsa.o secp256k1.o nist256p1.o rand.o hmac.o bip32.o bip39.o pbkdf2.o base58.o SRCS = bignum.c ecdsa.c secp256k1.c nist256p1.c rand.c hmac.c bip32.c bip39.c pbkdf2.c base58.c
OBJS += ripemd160.o SRCS += ripemd160.c
OBJS += sha2.o SRCS += sha2.c
OBJS += aescrypt.o aeskey.o aestab.o aes_modes.o SRCS += aescrypt.c aeskey.c aestab.c aes_modes.c
OBJS = $(SRCS:.c=.o)
TESTLIBS = -lcheck -lrt -lpthread -lm TESTLIBS = -lcheck -lrt -lpthread -lm
TESTSSLLIBS = -lcrypto TESTSSLLIBS = -lcrypto
all: tests test-openssl all: tests test-openssl libtrezor-crypto.so
%.o: %.c %.h options.h %.o: %.c %.h options.h
$(CC) $(CFLAGS) -o $@ -c $< $(CC) $(CFLAGS) -o $@ -c $<
@ -49,5 +51,8 @@ tests: tests.o $(OBJS)
test-openssl: test-openssl.o $(OBJS) test-openssl: test-openssl.o $(OBJS)
$(CC) test-openssl.o $(OBJS) $(TESTSSLLIBS) -o test-openssl $(CC) test-openssl.o $(OBJS) $(TESTSSLLIBS) -o test-openssl
libtrezor-crypto.so: $(SRCS)
$(CC) $(CFLAGS) -fPIC -shared $(SRCS) -o libtrezor-crypto.so
clean: clean:
rm -f *.o tests test-openssl rm -f *.o tests test-openssl libtrezor-crypto.so

View File

@ -3,10 +3,9 @@ import ctypes as c
import random import random
import ecdsa import ecdsa
import hashlib import hashlib
import subprocess
import binascii import binascii
import pytest
import os import os
import pytest
def bytes2num(s): def bytes2num(s):
res = 0 res = 0
@ -22,20 +21,7 @@ curves = {
random_iters = int(os.environ.get('ITERS', 1)) random_iters = int(os.environ.get('ITERS', 1))
scons_file = ''' lib = c.cdll.LoadLibrary('./libtrezor-crypto.so')
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.get_curve_by_name.restype = c.c_void_p lib.get_curve_by_name.restype = c.c_void_p