forked from Chia-Network/bls-signatures
-
Notifications
You must be signed in to change notification settings - Fork 34
fix: introduce util::Bn, util::Sec{Free,Malloc,Vector} for harmonised secret-content handling
#128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kwvg
wants to merge
15
commits into
dashpay:develop
Choose a base branch
from
kwvg:harden
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2a48670
fix: test for the uppercase prefix intended by `Util::HexToBytes()`
kwvg 6cce356
fix: stop FourBytesToInt shifting into the sign bit
kwvg c2050b7
doc: add MIT license so existing `COPYING.MIT` references land
kwvg be44876
build: introduce `.gitattributes` and normalize Autotools sources
kwvg e6293a8
build: sync definitions to CMake's C++17 requirement, refresh headers
kwvg 09302ea
fix: make public headers safe to include without additional headers
kwvg f33cf95
refactor(move-only): move the installed headers' definitions into TUs
kwvg 777be77
chore: drop unused libsodium code path
kwvg 876202d
refactor: s/bn_helpers/secure/g, move definitions to TU, header internal
kwvg 5b96a80
refactor: replace `Bn{,Array}Guard` with explicit move-only `util::Bn`
kwvg 46bf3e2
refactor: define `util::Sec{Malloc,Free}` over the defined callback
kwvg 46fc1b4
feat: introduce `util::SecVector<T>` for handling sensitive bytes
kwvg 099073d
feat: introduce `util::SecPtr<T>` for holding temporaries
kwvg 1d8bc7f
fix: clear `ChainCode` and give it value semantics
kwvg 5c92730
fix: clear `PrivateKey` before another value is copied over it
kwvg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| * text=auto eol=lf | ||
| *.mk text whitespace=-tab-in-indent,trailing-space,tabwidth=4 | ||
| Makefile* text whitespace=-tab-in-indent,trailing-space,tabwidth=4 | ||
|
|
||
| # Vendored dependencies are not subject to normalization. | ||
| depends/** -text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| The MIT License (MIT) | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,22 @@ | ||
| # Copyright (c) 2021 The PIVX developers | ||
| # Copyright (c) 2022 The Dash Core developers | ||
| # Distributed under the MIT software license, see the accompanying | ||
| # file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. | ||
| DASHBLS_RUNBENCH = runbench | ||
| runbench_SOURCES = \ | ||
| src/test-bench.cpp \ | ||
| src/test-utils.hpp | ||
| runbench_SOURCES += \ | ||
| $(RELIC_H) \ | ||
| $(DASHBLS_H) | ||
| runbench_CPPFLAGS = $(AM_CPPFLAGS) $(DASHBLS_INCLUDES) $(RELIC_INCLUDES) | ||
| runbench_CXXFLAGS = $(AM_CXXFLAGS) | ||
| runbench_LDFLAGS = -static $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) | ||
| runbench_LDADD = $(LIBDASHBLS) | ||
| noinst_PROGRAMS += $(DASHBLS_RUNBENCH) | ||
| # Copyright (c) 2021 The PIVX developers | ||
| # Copyright (c) 2022 The Dash Core developers | ||
| # Distributed under the MIT software license, see the accompanying | ||
| # file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| DASHBLS_RUNBENCH = runbench | ||
|
|
||
| runbench_SOURCES = \ | ||
| include/dashbls/test-utils.hpp \ | ||
| src/test-bench.cpp | ||
|
|
||
| runbench_SOURCES += \ | ||
| $(RELIC_H) \ | ||
| $(DASHBLS_H) | ||
|
|
||
| runbench_CPPFLAGS = $(AM_CPPFLAGS) $(DASHBLS_INCLUDES) $(RELIC_INCLUDES) | ||
| runbench_CXXFLAGS = $(AM_CXXFLAGS) | ||
| runbench_LDFLAGS = -static $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) | ||
|
|
||
| runbench_LDADD = $(LIBDASHBLS) | ||
|
|
||
| noinst_PROGRAMS += $(DASHBLS_RUNBENCH) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,73 @@ | ||
| # Copyright (c) 2021 The PIVX developers | ||
| # Copyright (c) 2022 The Dash Core developers | ||
| # Distributed under the MIT software license, see the accompanying | ||
| # file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| LIBDASHBLS = libdashbls.la | ||
|
|
||
| DASHBLS_CPPFLAGS = -DBLSALLOC_MIMALLOC=1 | ||
|
|
||
| DASHBLS_INCLUDES = \ | ||
| -I$(builddir) \ | ||
| -I$(builddir)/obj \ | ||
| -I$(top_srcdir)/include/dashbls | ||
|
|
||
| DASHBLS_H = \ | ||
| src/bls.hpp \ | ||
| src/chaincode.hpp \ | ||
| src/elements.hpp \ | ||
| src/extendedprivatekey.hpp \ | ||
| src/extendedpublickey.hpp \ | ||
| src/hdkeys.hpp \ | ||
| src/hkdf.hpp \ | ||
| src/legacy.hpp \ | ||
| src/privatekey.hpp \ | ||
| src/schemes.hpp \ | ||
| src/test-utils.hpp \ | ||
| src/threshold.hpp \ | ||
| src/util.hpp | ||
|
|
||
| libdashbls_la_SOURCES = \ | ||
| src/bls.cpp \ | ||
| src/chaincode.cpp \ | ||
| src/elements.cpp \ | ||
| src/extendedprivatekey.cpp \ | ||
| src/extendedpublickey.cpp \ | ||
| src/legacy.cpp \ | ||
| src/privatekey.cpp \ | ||
| src/schemes.cpp \ | ||
| src/threshold.cpp | ||
|
|
||
| libdashbls_la_SOURCES += \ | ||
| $(DASHBLS_H) \ | ||
| $(MIMALLOC_H) \ | ||
| $(RELIC_H) | ||
|
|
||
| libdashbls_la_LIBADD = \ | ||
| $(LIBMIMALLOC) \ | ||
| $(LIBRELIC) \ | ||
| $(GMP_LIBS) | ||
|
|
||
| libdashbls_la_CPPFLAGS = $(AM_CPPFLAGS) $(RELIC_INCLUDES) $(MIMALLOC_INCLUDES) $(DASHBLS_INCLUDES) $(DASHBLS_CPPFLAGS) | ||
| libdashbls_la_CXXFLAGS = $(AM_CXXFLAGS) | ||
| libdashbls_la_LDFLAGS = $(AM_LDFLAGS) | ||
|
|
||
| include Makefile.mimalloc.include | ||
| include Makefile.relic.include | ||
|
|
||
| if USE_TESTS | ||
| include Makefile.test.include | ||
| endif | ||
|
|
||
| if USE_BENCH | ||
| include Makefile.bench.include | ||
| endif | ||
|
|
||
| lib_LTLIBRARIES += $(LIBDASHBLS) | ||
| # Copyright (c) 2021 The PIVX developers | ||
| # Copyright (c) 2022 The Dash Core developers | ||
| # Distributed under the MIT software license, see the accompanying | ||
| # file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| LIBDASHBLS = libdashbls.la | ||
|
|
||
| DASHBLS_CPPFLAGS = -DBLSALLOC_MIMALLOC=1 | ||
|
|
||
| DASHBLS_INCLUDES = \ | ||
| -I$(builddir) \ | ||
| -I$(builddir)/obj \ | ||
| -I$(top_srcdir)/include/dashbls | ||
|
|
||
| DASHBLS_H = \ | ||
| include/dashbls/bls.hpp \ | ||
| include/dashbls/chaincode.hpp \ | ||
| include/dashbls/elements.hpp \ | ||
| include/dashbls/extendedprivatekey.hpp \ | ||
| include/dashbls/extendedpublickey.hpp \ | ||
| include/dashbls/hdkeys.hpp \ | ||
| include/dashbls/hkdf.hpp \ | ||
| include/dashbls/legacy.hpp \ | ||
| include/dashbls/privatekey.hpp \ | ||
| include/dashbls/schemes.hpp \ | ||
| include/dashbls/test-utils.hpp \ | ||
| include/dashbls/threshold.hpp \ | ||
| include/dashbls/util.hpp | ||
|
|
||
| libdashbls_la_SOURCES = \ | ||
| src/bls.cpp \ | ||
| src/chaincode.cpp \ | ||
| src/elements.cpp \ | ||
| src/extendedprivatekey.cpp \ | ||
| src/extendedpublickey.cpp \ | ||
| src/hdkeys.cpp \ | ||
| src/hkdf.cpp \ | ||
| src/legacy.cpp \ | ||
| src/privatekey.cpp \ | ||
| src/schemes.cpp \ | ||
| src/secure.cpp \ | ||
| src/secure.h \ | ||
| src/threshold.cpp \ | ||
| src/wipe.cpp \ | ||
| src/wipe.h \ | ||
| src/util.cpp | ||
|
|
||
| libdashbls_la_SOURCES += \ | ||
| $(DASHBLS_H) \ | ||
| $(MIMALLOC_H) \ | ||
| $(RELIC_H) | ||
|
|
||
| libdashbls_la_LIBADD = \ | ||
| $(LIBMIMALLOC) \ | ||
| $(LIBRELIC) \ | ||
| $(GMP_LIBS) | ||
|
|
||
| libdashbls_la_CPPFLAGS = $(AM_CPPFLAGS) $(RELIC_INCLUDES) $(MIMALLOC_INCLUDES) $(DASHBLS_INCLUDES) $(DASHBLS_CPPFLAGS) | ||
| libdashbls_la_CXXFLAGS = $(AM_CXXFLAGS) | ||
| libdashbls_la_LDFLAGS = $(AM_LDFLAGS) | ||
|
|
||
| include Makefile.mimalloc.include | ||
| include Makefile.relic.include | ||
|
|
||
| if USE_TESTS | ||
| include Makefile.test.include | ||
| endif | ||
|
|
||
| if USE_BENCH | ||
| include Makefile.bench.include | ||
| endif | ||
|
|
||
| lib_LTLIBRARIES += $(LIBDASHBLS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,46 @@ | ||
| # Copyright (c) 2022-2025 The Dash Core developers | ||
| # Distributed under the MIT software license, see the accompanying | ||
| # file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. | ||
| LIBMIMALLOC = libmimalloc-secure.la | ||
| MIMALLOC_CPPFLAGS = \ | ||
| -DMI_SECURE=4 \ | ||
| -DNDEBUG | ||
| MIMALLOC_INCLUDES = \ | ||
| -I$(top_srcdir)/depends/mimalloc/include \ | ||
| -I$(top_srcdir)/depends/mimalloc/src | ||
| MIMALLOC_H = \ | ||
| depends/mimalloc/include/mimalloc-new-delete.h \ | ||
| depends/mimalloc/include/mimalloc-override.h \ | ||
| depends/mimalloc/include/mimalloc-stats.h \ | ||
| depends/mimalloc/include/mimalloc.h \ | ||
| depends/mimalloc/src/bitmap.h | ||
| libmimalloc_secure_la_SOURCES = \ | ||
| $(MIMALLOC_H) \ | ||
| depends/mimalloc/src/alloc-aligned.c \ | ||
| depends/mimalloc/src/alloc-posix.c \ | ||
| depends/mimalloc/src/alloc.c \ | ||
| depends/mimalloc/src/arena-meta.c \ | ||
| depends/mimalloc/src/arena.c \ | ||
| depends/mimalloc/src/bitmap.c \ | ||
| depends/mimalloc/src/heap.c \ | ||
| depends/mimalloc/src/init.c \ | ||
| depends/mimalloc/src/libc.c \ | ||
| depends/mimalloc/src/options.c \ | ||
| depends/mimalloc/src/os.c \ | ||
| depends/mimalloc/src/page-map.c \ | ||
| depends/mimalloc/src/page.c \ | ||
| depends/mimalloc/src/random.c \ | ||
| depends/mimalloc/src/stats.c \ | ||
| depends/mimalloc/src/prim/prim.c | ||
| libmimalloc_secure_la_CPPFLAGS = $(AM_CPPFLAGS) $(MIMALLOC_CPPFLAGS) $(MIMALLOC_INCLUDES) | ||
| libmimalloc_secure_la_CXXFLAGS = $(AM_CXXFLAGS) | ||
| libmimalloc_secure_la_CFLAGS = $(AM_CFLAGS) | ||
| libmimalloc_secure_la_LDFLAGS = $(AM_LDFLAGS) | ||
| noinst_LTLIBRARIES += $(LIBMIMALLOC) | ||
| # Copyright (c) 2022-2025 The Dash Core developers | ||
| # Distributed under the MIT software license, see the accompanying | ||
| # file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| LIBMIMALLOC = libmimalloc-secure.la | ||
|
|
||
| MIMALLOC_CPPFLAGS = \ | ||
| -DMI_SECURE=4 \ | ||
| -DNDEBUG | ||
|
|
||
| MIMALLOC_INCLUDES = \ | ||
| -I$(top_srcdir)/depends/mimalloc/include \ | ||
| -I$(top_srcdir)/depends/mimalloc/src | ||
|
|
||
| MIMALLOC_H = \ | ||
| depends/mimalloc/include/mimalloc-new-delete.h \ | ||
| depends/mimalloc/include/mimalloc-override.h \ | ||
| depends/mimalloc/include/mimalloc-stats.h \ | ||
| depends/mimalloc/include/mimalloc.h \ | ||
| depends/mimalloc/src/bitmap.h | ||
|
|
||
| libmimalloc_secure_la_SOURCES = \ | ||
| $(MIMALLOC_H) \ | ||
| depends/mimalloc/src/alloc-aligned.c \ | ||
| depends/mimalloc/src/alloc-posix.c \ | ||
| depends/mimalloc/src/alloc.c \ | ||
| depends/mimalloc/src/arena-meta.c \ | ||
| depends/mimalloc/src/arena.c \ | ||
| depends/mimalloc/src/bitmap.c \ | ||
| depends/mimalloc/src/heap.c \ | ||
| depends/mimalloc/src/init.c \ | ||
| depends/mimalloc/src/libc.c \ | ||
| depends/mimalloc/src/options.c \ | ||
| depends/mimalloc/src/os.c \ | ||
| depends/mimalloc/src/page-map.c \ | ||
| depends/mimalloc/src/page.c \ | ||
| depends/mimalloc/src/random.c \ | ||
| depends/mimalloc/src/stats.c \ | ||
| depends/mimalloc/src/prim/prim.c | ||
|
|
||
| libmimalloc_secure_la_CPPFLAGS = $(AM_CPPFLAGS) $(MIMALLOC_CPPFLAGS) $(MIMALLOC_INCLUDES) | ||
| libmimalloc_secure_la_CXXFLAGS = $(AM_CXXFLAGS) | ||
| libmimalloc_secure_la_CFLAGS = $(AM_CFLAGS) | ||
| libmimalloc_secure_la_LDFLAGS = $(AM_LDFLAGS) | ||
|
|
||
| noinst_LTLIBRARIES += $(LIBMIMALLOC) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.