Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test_asan_ubsan_gcc:
- CONFIGURE_ARGS: [ --enable-elements=no, --enable-elements=no --enable-minimal=yes, "", --enable-minimal=yes ]
script:
- ./tools/cleanup.sh && ./tools/autogen.sh
- CC=gcc CFLAGS="-O2 -fsanitize=address -fsanitize=bounds -fsanitize=undefined -fsanitize=alignment -fsanitize-address-use-after-scope -fno-sanitize-recover=all" ./configure --enable-export-all --enable-swig-python --enable-swig-java $CONFIGURE_ARGS --enable-shared --disable-static --disable-clear-tests --disable-asm
- CC=gcc CFLAGS="-O2 -fsanitize=address -fsanitize=bounds -fsanitize=undefined -fsanitize=alignment -fsanitize-address-use-after-scope -fno-sanitize-recover=all" ./configure --enable-export-all --enable-swig-python --enable-swig-java $CONFIGURE_ARGS --enable-shared --disable-static --disable-asm
- sed -i 's/^PYTHON = /PYTHON = LD_PRELOAD=\/usr\/lib\/gcc\/x86_64-linux-gnu\/14\/libasan.so /g' src/Makefile
- sed -i 's/^JAVA = /JAVA = LD_PRELOAD=\/usr\/lib\/gcc\/x86_64-linux-gnu\/14\/libasan.so /g' src/Makefile
- make -j $(($(grep ^processor /proc/cpuinfo | wc -l) / 2))
Expand All @@ -50,7 +50,7 @@ test_scan_build_clang:
- CONFIGURE_ARGS: [ --enable-elements=no, --enable-elements=no --enable-minimal=yes, "", --enable-minimal=yes ]
script:
- ./tools/cleanup.sh && ./tools/autogen.sh
- CC=clang scan-build-19 ./configure --enable-export-all --enable-swig-python --enable-swig-java --disable-clear-tests --disable-asm $CONFIGURE_ARGS
- CC=clang scan-build-19 ./configure --enable-export-all --enable-swig-python --enable-swig-java --disable-asm $CONFIGURE_ARGS
- scan-build-19 --keep-cc --exclude src/secp256k1/ --status-bugs --keep-empty -o scan-build-output make -j $(($(grep ^processor /proc/cpuinfo | wc -l) / 2))
artifacts:
expire_in: 3 days
Expand Down Expand Up @@ -93,7 +93,7 @@ test_amalgamation:
BUILD_ARGS: [ "", -DBUILD_MINIMAL, -DBUILD_ELEMENTS, -DBUILD_ELEMENTS -DBUILD_MINIMAL ]
script:
- touch config.h
- $CC $BUILD_ARGS -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c
- $CC $BUILD_ARGS -Wall -W -Wextra -Werror -Wno-unknown-attributes -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c

test_mingw_static_build:
extends: .test_template
Expand All @@ -107,7 +107,7 @@ test_no_elements_abi:
artifacts:
script:
- ./tools/cleanup.sh && ./tools/autogen.sh
- CFLAGS='-Wall -W -Wextra -Werror' ./configure --disable-swig-python --disable-swig-java --disable-clear-tests --enable-elements=no --enable-elements-abi=no
- CFLAGS='-Wall -W -Wextra -Werror' ./configure --disable-swig-python --disable-swig-java --enable-elements=no --enable-elements-abi=no
- make -j $(($(grep ^processor /proc/cpuinfo | wc -l) / 2))

build_wally_release_files:
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changes

## Version 1.5.5

### Fixed
- De-optimize some memcpy calls on x86 to prevent leaks via extended registers.

## Version 1.5.4

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ installed.
For non-development use, you can install wally from PyPI with `pip` as follows:

```
pip install wallycore==1.5.4
pip install wallycore==1.5.5
```

For development, you can build and install wally using:
Expand Down
2 changes: 1 addition & 1 deletion _CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.18)

project(
libwallycore
VERSION 1.5.4
VERSION 1.5.5
DESCRIPTION "A collection of useful primitives for cryptocurrency wallets"
LANGUAGES C
)
Expand Down
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AC_PREREQ([2.60])
AC_INIT([libwallycore],[1.5.4])
AC_INIT([libwallycore],[1.5.5])
AC_CONFIG_AUX_DIR([tools/build-aux])
AC_CONFIG_MACRO_DIR([tools/build-aux/m4])
AC_CONFIG_SRCDIR([src/mnemonic.h])
Expand Down Expand Up @@ -236,6 +236,8 @@ AM_CONDITIONAL([EXPORT_ALL], [test "x$export_all" = "xyes"])

if test "x$export_all" != "xyes"; then
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [AM_CFLAGS="$AM_CFLAGS -fvisibility=hidden"])
else
AX_CHECK_COMPILE_FLAG([-DWALLY_EXPORT_ALL=1], [AM_CFLAGS="$AM_CFLAGS -DWALLY_EXPORT_ALL=1"])
fi

# Assume we have no unaligned access if cross-compiling
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def extract_docs(infile, outfile):
# built documents.
#
# The short X.Y version.
version = u'1.5.4'
version = u'1.5.5'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
4 changes: 2 additions & 2 deletions include/wally_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ extern "C" {
/** Library version */
#define WALLY_MAJOR_VER 1
#define WALLY_MINOR_VER 5
#define WALLY_PATCH_VER 4
#define WALLY_BUILD_VER 0x10504
#define WALLY_PATCH_VER 5
#define WALLY_BUILD_VER 0x10505

/**
* Initialize wally.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _call(args, cwd=ABS_PATH):

kwargs = {
'name': 'wallycore',
'version': '1.5.4',
'version': '1.5.5',
'description': 'libwally Bitcoin library',
'long_description': 'Python bindings for the libwally Bitcoin library',
'url': 'https://github.com/ElementsProject/libwally-core',
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ if USE_PTHREAD
TESTS += test_clear
noinst_PROGRAMS += test_clear
test_clear_SOURCES = ctest/test_clear.c
test_clear_CFLAGS = -I$(top_srcdir)/include $(PTHREAD_CFLAGS) $(AM_CFLAGS) $(NOOPT_CFLAGS) $(NOBUILTIN_CFLAGS)
test_clear_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir) -I$(top_srcdir)/src/secp256k1/include $(PTHREAD_CFLAGS) $(AM_CFLAGS) $(NOOPT_CFLAGS) $(NOBUILTIN_CFLAGS)
test_clear_LIBS = $(PTHREAD_LIBS)
test_clear_LDADD = $(lib_LTLIBRARIES) @CTEST_EXTRA_STATIC@
if PYTHON_MANYLINUX
Expand Down
2 changes: 1 addition & 1 deletion src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ int wally_aes_cbc_with_ecdh_key(

if (is_encrypt) {
/* Copy the IV to the start of the encrypted output */
memcpy(bytes_out, iv, iv_len);
wally_memcpy(bytes_out, iv, iv_len);
} else {
/* The IV is the first AES_BLOCK_LEN bytes of the payload */
iv = bytes;
Expand Down
24 changes: 12 additions & 12 deletions src/bip32.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ int bip32_key_from_private_key(uint32_t version,
key_out->version = version;
/* Copy the private key and set its prefix */
key_out->priv_key[0] = BIP32_FLAG_KEY_PRIVATE;
memcpy(key_out->priv_key + 1, priv_key, priv_key_len);
wally_memcpy(key_out->priv_key + 1, priv_key, priv_key_len);
/* Compute the public key */
if (key_compute_pub_key(key_out) != WALLY_OK)
return wipe_key_fail(key_out);
Expand Down Expand Up @@ -400,7 +400,7 @@ int bip32_key_from_seed_custom(const unsigned char *bytes, size_t bytes_len,
ret = bip32_key_from_private_key(version, sha.u.u8, EC_PRIVATE_KEY_LEN, key_out);
if (ret == WALLY_OK) {
/* Copy the chain code and set other members */
memcpy(key_out->chain_code, sha.u.u8 + sizeof(sha) / 2, sizeof(sha) / 2);
wally_memcpy(key_out->chain_code, sha.u.u8 + sizeof(sha) / 2, sizeof(sha) / 2);
key_out->depth = 0; /* Master key, depth 0 */
key_out->child_num = 0;
if (!(flags & BIP32_FLAG_SKIP_HASH))
Expand Down Expand Up @@ -453,7 +453,7 @@ int bip32_key_from_seed_alloc(const unsigned char *bytes, size_t bytes_len,
static unsigned char *copy_out(unsigned char *dest,
const void *src, size_t len)
{
memcpy(dest, src, len);
wally_memcpy(dest, src, len);
return dest + len;
}

Expand Down Expand Up @@ -536,7 +536,7 @@ int bip32_key_serialize(const struct ext_key *hdkey, uint32_t flags,
static const unsigned char *copy_in(void *dest,
const unsigned char *src, size_t len)
{
memcpy(dest, src, len);
wally_memcpy(dest, src, len);
return src + len;
}

Expand Down Expand Up @@ -674,13 +674,13 @@ int bip32_key_from_parent(const struct ext_key *hdkey, uint32_t child_num,
/* NB: We use the key_outs' priv_key+child_num to hold 'Data' here */
if (hardened) {
/* Hardened: Data = 0x00 || ser256(kpar) || ser32(i)) */
memcpy(key_out->priv_key, hdkey->priv_key, sizeof(hdkey->priv_key));
wally_memcpy(key_out->priv_key, hdkey->priv_key, sizeof(hdkey->priv_key));
} else {
/* Non Hardened Private: Data = serP(point(kpar)) || ser32(i)
* Non Hardened Public : Data = serP(kpar) || ser32(i)
* point(kpar) when par is private is the public key.
*/
memcpy(key_out->priv_key, hdkey->pub_key, sizeof(hdkey->pub_key));
wally_memcpy(key_out->priv_key, hdkey->pub_key, sizeof(hdkey->pub_key));
}

/* This is the '|| ser32(i)' part of the above */
Expand All @@ -694,15 +694,15 @@ int bip32_key_from_parent(const struct ext_key *hdkey, uint32_t child_num,
/* Split I into two 32-byte sequences, IL and IR
* The returned chain code ci is IR (i.e. the 2nd half of our hmac sha512)
*/
memcpy(key_out->chain_code, sha.u.u8 + sizeof(sha) / 2,
wally_memcpy(key_out->chain_code, sha.u.u8 + sizeof(sha) / 2,
sizeof(key_out->chain_code));

if (we_are_private) {
/* The returned child key ki is parse256(IL) + kpar (mod n)
* In case parse256(IL) ≥ n or ki = 0, the resulting key is invalid
* (NOTE: seckey_tweak_add checks both conditions)
*/
memcpy(key_out->priv_key, hdkey->priv_key, sizeof(hdkey->priv_key));
wally_memcpy(key_out->priv_key, hdkey->priv_key, sizeof(hdkey->priv_key));
if (!seckey_tweak_add(key_out->priv_key + 1, sha.u.u8) ||
key_compute_pub_key(key_out) != WALLY_OK)
goto fail;
Expand Down Expand Up @@ -822,7 +822,7 @@ int bip32_key_from_parent_path(const struct ext_key *hdkey,
}

if (ret == WALLY_OK)
memcpy(key_out, hdkey, sizeof(*key_out));
wally_memcpy(key_out, hdkey, sizeof(*key_out));

wally_clear(tmp, sizeof(tmp));
return ret;
Expand Down Expand Up @@ -1010,9 +1010,9 @@ int bip32_key_init(uint32_t version, uint32_t depth, uint32_t child_num,
key_out->depth = depth;
key_out->child_num = child_num;

memcpy(key_out->chain_code, chain_code, key_size(chain_code));
wally_memcpy(key_out->chain_code, chain_code, key_size(chain_code));
if (priv_key && version != BIP32_VER_MAIN_PUBLIC && version != BIP32_VER_TEST_PUBLIC)
memcpy(key_out->priv_key + 1, priv_key, key_size(priv_key) - 1);
wally_memcpy(key_out->priv_key + 1, priv_key, key_size(priv_key) - 1);
else
key_out->priv_key[0] = BIP32_FLAG_KEY_PUBLIC;
if (pub_key)
Expand Down Expand Up @@ -1135,7 +1135,7 @@ static int getb_impl(const struct ext_key *hdkey,
{
if (!hdkey || !bytes_out || len != src_len)
return WALLY_EINVAL;
memcpy(bytes_out, src, len);
wally_memcpy(bytes_out, src, len);
return WALLY_OK;
}

Expand Down
8 changes: 4 additions & 4 deletions src/bip39.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int bip39_mnemonic_from_bytes(const struct words *w,
if (w->bits != 11u || !(mask = len_to_mask(bytes_len)))
return WALLY_EINVAL;

memcpy(tmp_bytes, bytes, bytes_len);
wally_memcpy(tmp_bytes, bytes, bytes_len);
checksum = bip39_checksum(bytes, bytes_len, mask);
tmp_bytes[bytes_len] = checksum & 0xff;
if (mask > 0xff)
Expand Down Expand Up @@ -190,7 +190,7 @@ int bip39_mnemonic_to_bytes(const struct words *w, const char *mnemonic,
ret = WALLY_EINVAL; /* Bad checksum */
}
else
memcpy(bytes_out, tmp_bytes, tmp_len);
wally_memcpy(bytes_out, tmp_bytes, tmp_len);
}
}
}
Expand Down Expand Up @@ -232,9 +232,9 @@ int bip39_mnemonic_to_seed(const char *mnemonic, const char *passphrase,
if (!salt)
return WALLY_ENOMEM;

memcpy(salt, prefix, prefix_len);
wally_memcpy(salt, prefix, prefix_len);
if (passphrase_len)
memcpy(salt + prefix_len, passphrase, passphrase_len);
wally_memcpy(salt + prefix_len, passphrase, passphrase_len);

ret = wally_pbkdf2_hmac_sha512((unsigned char *)mnemonic, strlen(mnemonic),
salt, salt_len, 0,
Expand Down
4 changes: 4 additions & 0 deletions src/ccan_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@
#define CCAN_CRYPTO_SHA512_USE_MBEDTLS 1
#endif

#if !defined(WALLY_EXPORT_ALL) && !defined(_WIN32)
void __attribute__ ((visibility ("hidden"))) wally_clear(void *p, size_t len);
#else
void wally_clear(void *p, size_t len);
#endif

#define CCAN_CLEAR_MEMORY(p, len) wally_clear(p, len)

Expand Down
2 changes: 1 addition & 1 deletion src/ctest/_CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_test(test_bech32 test_bech32)

if(NOT WIN32)
add_executable(test_clear test_clear.c)
target_include_directories(test_clear PRIVATE ${CMAKE_BINARY_DIR})
target_include_directories(test_clear PRIVATE ${CMAKE_BINARY_DIR} $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src> $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/secp256k1/include>)
target_link_libraries(test_clear PRIVATE wallycore pthread)
add_test(test_clear test_clear)
endif()
Expand Down
Loading
Loading