Skip to content

Commit

Permalink
ci: added encrypt test targets
Browse files Browse the repository at this point in the history
cmake: added encrypt test and random test_passwd options (default off)
configure: added encrypt test and random test_passwd options (default off)
docs: added note about random test_passwd option (--enable-test-passwd)
seal: added check for getpass and random test_passwd
test: added check for encrypt test to test_tpm
gitignore: added encrypted store
  • Loading branch information
edtubbs committed Dec 3, 2023
1 parent 93d8f3b commit 623c5bd
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 16 deletions.
89 changes: 86 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@ jobs:
matrix:
name:
- armhf-linux
- armhf-linux-test-encrypt
- aarch64-linux
- aarch64-linux-test-encrypt
- x86_64-linux-dbg
- x86_64-linux-openenclave
- x86_64-macos
- x86_64-macos-test-encrypt
# - arm64-macos
- x86_64-win
- x86_64-win-test-encrypt
- i686-win
- i686-win-test-encrypt
- i686-linux
- i686-linux-test-encrypt
include:
- name: armhf-linux
host: arm-linux-gnueabihf
Expand All @@ -42,6 +48,14 @@ jobs:
config-opts: "--enable-static --disable-shared"
run-tests: true
goal: install
- name: armhf-linux-test-encrypt
host: arm-linux-gnueabihf
os: ubuntu-20.04
packages: g++-arm-linux-gnueabihf qemu-user-static qemu-user
dep-opts: "CROSS_COMPILE='yes' SPEED=slow V=1"
config-opts: "--enable-static --disable-shared --enable-test-encrypt --enable-test-passwd"
run-tests: true
goal: install
- name: aarch64-linux
host: aarch64-linux-gnu
os: ubuntu-20.04
Expand All @@ -50,6 +64,14 @@ jobs:
config-opts: "LIBS='-levent_pthreads' --enable-static --disable-shared"
run-tests: true
goal: install
- name: aarch64-linux-test-encrypt
host: aarch64-linux-gnu
os: ubuntu-20.04
packages: g++-aarch64-linux-gnu qemu-user-static qemu-user
dep-opts: "CROSS_COMPILE='yes' SPEED=slow V=1"
config-opts: "LIBS='-levent_pthreads' --enable-static --disable-shared --enable-test-encrypt --enable-test-passwd"
run-tests: true
goal: install
- name: x86_64-linux-dbg
host: x86_64-pc-linux-gnu
os: ubuntu-20.04
Expand All @@ -64,7 +86,7 @@ jobs:
run-tests: true
packages: python3-dev python3-dbg python
dep-opts: "DEBUG=1 SPEED=slow V=1"
config-opts: "--enable-debug --enable-openenclave CFLAGS=-U_FORTIFY_SOURCE"
config-opts: "--enable-debug --enable-test-encrypt --enable-test-passwd --enable-openenclave CFLAGS=-U_FORTIFY_SOURCE"
goal: install
- name: x86_64-macos
host: x86_64-apple-darwin15
Expand All @@ -77,6 +99,17 @@ jobs:
sdk: 12.2
sdk-build: 12B45b
sdk-shasum: "df75d30ecafc429e905134333aeae56ac65fac67cb4182622398fd717df77619"
- name: x86_64-macos-test-encrypt
host: x86_64-apple-darwin15
os: macos-latest
run-tests: true
dep-opts: "SPEED=slow V=1"
config-opts: "--enable-static --disable-shared --enable-test-encrypt --enable-test-passwd"
packages: cmake zlib xorriso
goal: install
sdk: 12.2
sdk-build: 12B45b
sdk-shasum: "df75d30ecafc429e905134333aeae56ac65fac67cb4182622398fd717df77619"
# - name: arm64-macos
# host: arm64-apple-darwin
# os: macos-latest
Expand All @@ -102,6 +135,20 @@ jobs:
config-opts: ""
run-tests: true
goal: install
- name: x86_64-win-test-encrypt
host: x86_64-w64-mingw32
arch: i386
os: ubuntu-20.04
packages: python3 nsis g++-mingw-w64-x86-64 wine64 wine-stable bc wine-binfmt
postinstall: |
sudo dpkg -s mono-runtime && sudo apt-get remove mono-runtime || echo "Very nothing to uninstall."
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
sudo update-binfmts --import /usr/share/binfmts/wine
dep-opts: "CROSS_COMPILE='yes' SPEED=slow V=1"
config-opts: "--enable-test-encrypt --enable-test-passwd"
run-tests: true
goal: install
- name: i686-win
host: i686-w64-mingw32
arch: i386
Expand All @@ -124,6 +171,28 @@ jobs:
config-opts: ""
run-tests: true
goal: install
- name: i686-win-test-encrypt
host: i686-w64-mingw32
arch: i386
os: ubuntu-20.04
packages: python3-pip python3-setuptools nsis g++ g++-mingw-w64-i686 mingw-w64-i686-dev wine-stable winehq-stable bc wine-binfmt binfmt-support
preinstall: |
OS_FLAVOR=$(cat /etc/*ease | grep UBUNTU_CODENAME | cut -d "=" -f 2)
if [ ! -d "/etc/apt/keyrings" ]; then sudo mkdir -pm755 /etc/apt/keyrings; fi
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/$OS_FLAVOR/winehq-$OS_FLAVOR.sources
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libgd3/focal libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal
sudo apt-get purge -yqq libmono* moby* mono* php* libgdiplus libpcre2-posix3 libzip4
postinstall: |
sudo update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix
sudo update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix
sudo update-binfmts --import /usr/share/binfmts/wine
dep-opts: "CROSS_COMPILE='yes' SPEED=slow V=1"
config-opts: "--enable-test-encrypt --enable-test-passwd"
run-tests: true
goal: install
- name: i686-linux
host: i686-pc-linux-gnu
os: ubuntu-20.04
Expand All @@ -132,6 +201,14 @@ jobs:
dep-opts: "SPEED=slow V=1"
config-opts: "--enable-static --disable-shared"
goal: install
- name: i686-linux-test-encrypt
host: i686-pc-linux-gnu
os: ubuntu-20.04
packages: g++-multilib bc
run-tests: true
dep-opts: "SPEED=slow V=1"
config-opts: "--enable-static --disable-shared --enable-test-encrypt --enable-test-passwd"
goal: install

runs-on: ${{ matrix.os }}

Expand All @@ -147,7 +224,7 @@ jobs:

- name: install packages
run: |
if ([ "${{ matrix.name }}" == "x86_64-macos" ] || [ "${{ matrix.name }}" == "arm64-macos" ]); then
if ([ "${{ matrix.name }}" == "x86_64-macos" ] || [ "${{ matrix.name }}" == "arm64-macos" ] || [ "${{ matrix.name }}" == "x86_64-macos-test-encrypt" ]); then
brew update
brew install automake coreutils ${{ matrix.packages }}
echo PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" >> ~/.bashrc
Expand Down Expand Up @@ -216,7 +293,7 @@ jobs:
build_dir=./build/libdogecoin-${{ github.sha }}-${{ matrix.name }}
make -j"$(getconf _NPROCESSORS_ONLN)" SPEED=slow V=1
mkdir -p $build_dir/bin $build_dir/docs $build_dir/examples $build_dir/include $build_dir/lib
if ([ "${{ matrix.name }}" == "x86_64-win" ] || [ "${{ matrix.name }}" == "i686-win" ]); then
if ([ "${{ matrix.name }}" == "x86_64-win" ] || [ "${{ matrix.name }}" == "i686-win" ] || [ "${{ matrix.name }}" == "x86_64-win-test-encrypt" ] || [ "${{ matrix.name }}" == "i686-win-test-encrypt" ]); then
cp spvnode.exe such.exe sendtx.exe $build_dir/bin/
else
cp spvnode such sendtx $build_dir/bin/
Expand All @@ -239,9 +316,15 @@ jobs:
"armhf-linux")
qemu-arm -E LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib/ /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 ./tests
;;
"armhf-linux-test-encrypt")
qemu-arm -E LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib/ /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 ./tests
;;
"aarch64-linux")
qemu-aarch64 -E LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib/ /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 ./tests
;;
"aarch64-linux-test-encrypt")
qemu-aarch64 -E LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib/ /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 ./tests
;;
"x86_64-linux-dbg")
make check -j"$(getconf _NPROCESSORS_ONLN)" V=1
python3 tooltests.py
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,7 @@ include/include.am
# QR
qrtest.png
qrtest.jpg

# Store
store/*
.store/*
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ SET(WITH_WALLET TRUE CACHE BOOL "enable wallet")
SET(USE_SSE2 FALSE CACHE BOOL "enable scrypt sse2")
SET(USE_TPM2 TRUE CACHE BOOL "enable tpm2")
SET(USE_OPENENCLAVE FALSE CACHE BOOL "enable openenclave")
SET(TEST_PASSWD TRUE CACHE BOOL "enable test password")
SET(TEST_ENCRYPT TRUE CACHE BOOL "enable test encrypt")
SET(TEST_PASSWD FALSE CACHE BOOL "enable test password")
string(RANDOM LENGTH 12 ALPHABET abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 PASSWD_STR)
SET(RANDOM_DEVICE "/dev/urandom" CACHE STRING "set the device to read random data from")

# Set a default build type if none was specified
Expand Down Expand Up @@ -111,8 +113,12 @@ ENDIF()
IF(USE_OPENENCLAVE)
ADD_DEFINITIONS(-DUSE_OPENENCLAVE=1)
ENDIF()
IF(TEST_ENCRYPT)
ADD_DEFINITIONS(-DTEST_ENCRYPT=1)
ENDIF()
IF(TEST_PASSWD)
ADD_DEFINITIONS(-DTEST_PASSWD=1)
ADD_DEFINITIONS(-DPASSWD_STR="${PASSWD_STR}")
ENDIF()

MESSAGE(STATUS "")
Expand All @@ -126,7 +132,11 @@ MESSAGE(STATUS " WITH_WALLET = ${WITH_WALLET}")
MESSAGE(STATUS "")
MESSAGE(STATUS " USE_SSE2 = ${USE_SSE2}")
MESSAGE(STATUS " USE_TPM2 = ${USE_TPM2}")
MESSAGE(STATUS " TEST_ENCRYPT = ${TEST_ENCRYPT}")
MESSAGE(STATUS " TEST_PASSWD = ${TEST_PASSWD}")
IF(TEST_PASSWD)
MESSAGE(STATUS " ${PASSWD_STR}")
ENDIF()
MESSAGE(STATUS "")
MESSAGE(STATUS " openenclave = ${USE_OPENENCLAVE}")
MESSAGE(STATUS "")
Expand Down
20 changes: 18 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,17 @@ AC_ARG_ENABLE(tests,
[use_tests=$enableval],
[use_tests=yes])

AC_ARG_ENABLE([test-encrypt],
[AS_HELP_STRING([--enable-test-encrypt],
[disable test encrypt/decrypt (default is no)])],
[test_encrypt=$enableval],
[test_encrypt=no])

AC_ARG_ENABLE([test-passwd],
[AS_HELP_STRING([--enable-test-passwd],
[enable test password for encrypt/decrypt (default is yes)])],
[enable test password for encrypt/decrypt (default is no)])],
[test_passwd=$enableval],
[test_passwd=yes])
[test_passwd=no])

AC_MSG_CHECKING([for __builtin_expect])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void myfunc() {__builtin_expect(0,0);}]])],
Expand Down Expand Up @@ -188,8 +194,14 @@ if test "x$enable_debug" = xyes; then
AC_DEFINE_UNQUOTED([ENABLE_DEBUG],[1],[Define to 1 to enable debug output])
fi

if test "x$test_encrypt" = xyes; then
AC_DEFINE_UNQUOTED([TEST_ENCRYPT],[1],[Define to 1 to enable test encrypt/decrypt])
fi

if test "x$test_passwd" = xyes; then
AC_DEFINE_UNQUOTED([TEST_PASSWD],[1],[Define to 1 to enable test password])
PASSWD_STR=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12`
AC_SUBST(PASSWD_STR)
fi

if test "x$with_net" = xyes; then
Expand Down Expand Up @@ -248,7 +260,11 @@ echo " with wallet = $with_wallet"
echo " with unistring = $with_unistring"
echo
echo " SSE2 Scrypt = $use_scrypt_sse2"
echo " test encrypt = $test_encrypt"
echo " test password = $test_passwd"
if test "x$test_passwd" = xyes; then
echo " = $PASSWD_STR"
fi
echo
echo " openenclave = $use_openenclave"
echo
Expand Down
7 changes: 7 additions & 0 deletions doc/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ At this step there are plenty of flags that can be specified, the two most perti
./configure CFLAGS='-Ipath/to/additional/include/files'
```

Another useful flag is `--enable-test-passwd`, which will generate a random password for the wallet encryption key. This is useful for testing purposes, but should never be used in production. This flag is disabled by default, but can be enabled with the following command:
```c
./configure --enable-test-passwd
```

### `--enable-test-passwd` is for **testing purposes only** and should never be used in production.

For a complete list of all different configuration options, you can run the command `./configure --help`.

Finally, once you have configured the library to your liking, it is ready to be built. This can be done with the simple `make` command:
Expand Down
Loading

0 comments on commit 623c5bd

Please sign in to comment.