Commit graph

58 commits

Author SHA1 Message Date
DrahtBot
eb7daf4d60 Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
Wladimir J. van der Laan
3a3eabef40
Merge #13386: SHA256 implementations based on Intel SHA Extensions
66b2cf1ccf Use immintrin.h everywhere for intrinsics (Pieter Wuille)
4c935e2eee Add SHA256 implementation using using Intel SHA intrinsics (Pieter Wuille)
268400d318 [Refactor] CPU feature detection logic for SHA256 (Pieter Wuille)

Pull request description:

  Based on #13191.

  This adds SHA256 implementations that use Intel's SHA Extension instructions (using intrinsics). This needs GCC 4.9 or Clang 3.4.

  In addition to #13191, two extra implementations are provided:
  * (a) A variable-length SHA256 implementation using SHA extensions.
  * (b) A 2-way 64-byte input double-SHA256 implementation using SHA extensions.

  Benchmarks for 9001-element Merkle tree root computation on an AMD Ryzen 1800X system:
  * Using generic C++ code (pre-#10821): 6.1ms
  * Using SSE4 (master, #10821): 4.6ms
  * Using 4-way SSE4 specialized for 64-byte inputs (#13191): 2.8ms
  * Using 8-way AVX2 specialized for 64-byte inputs (#13191): 2.1ms
  * Using 2-way SHA-NI specialized for 64-byte inputs (this PR): 0.56ms

  Benchmarks for 32-byte SHA256 on the same system:
  * Using SSE4 (master, #10821): 190ns
  * Using SHA-NI (this PR): 53ns

  Benchmarks for 1000000-byte SHA256 on the same system:
  * Using SSE4 (master, #10821): 2.5ms
  * Using SHA-NI (this PR): 0.51ms

Tree-SHA512: 2b319e33b22579f815d91f9daf7994a5e1e799c4f73c13e15070dd54ba71f3f6438ccf77ae9cbd1ce76f972d9cbeb5f0edfea3d86f101bbc1055db70e42743b7
2018-07-09 21:17:18 +02:00
Chun Kuan Lee
63c16ed507 Use __cpuid_count for gnu C to avoid gitian build fail. 2018-07-07 16:01:43 +00:00
Pieter Wuille
66b2cf1ccf Use immintrin.h everywhere for intrinsics 2018-06-26 10:11:08 -07:00
Pieter Wuille
4c935e2eee Add SHA256 implementation using using Intel SHA intrinsics 2018-06-26 10:11:08 -07:00
Pieter Wuille
268400d318 [Refactor] CPU feature detection logic for SHA256 2018-06-24 10:51:07 -07:00
Wladimir J. van der Laan
5eca4e86d4
Merge #13471: For AVX2 code, also check for AVX, XSAVE, and OS support
32d153fa36 For AVX2 code, also check for AVX, XSAVE, and OS support (Pieter Wuille)

Pull request description:

  Fixes #12903.

Tree-SHA512: 01e71efb5d3a43c49a145a5b1dc4fe7d0a491e1e78479e7df830a2aaac57c3dcfc316e28984c695206c76f93b68e4350fc037ca36756ca579b7070e39c835da2
2018-06-24 15:31:33 +02:00
Pieter Wuille
32d153fa36 For AVX2 code, also check for AVX, XSAVE, and OS support 2018-06-18 14:55:54 -07:00
Pieter Wuille
1e1eb6367f Improve coverage of SHA256 SelfTest code 2018-06-12 12:10:13 -07:00
Wladimir J. van der Laan
a607d23ae8
Merge #13393: Enable double-SHA256-for-64-byte code on 32-bit x86
57ba401abc Enable double-SHA256-for-64-byte code on 32-bit x86 (Pieter Wuille)

Pull request description:

  The SSE4 and AVX2 double-SHA256-for-64-byte input code from #13191 compiles fine on 32-bit x86 systems, but the autodetection logic in sha256.cpp doesn't enable it. Fix this.

  Note that these instruction sets are only available on CPUs that support 64-bit mode as well, so it is only beneficial in the (perhaps unlikely) scenario where a 64-bit CPU is running a 32-bit Bitcoin Core binary.

Tree-SHA512: 39d5963c1ba8c33932549d5fe98bd184932689a40aeba95043eca31dd6824f566197c546b60905555eccaf407408a5f0f200247bb0907450d309b0a70b245102
2018-06-12 18:52:26 +02:00
practicalswift
906bee8e5f Use bracket syntax includes ("#include <foo.h>") 2018-06-06 11:09:05 +02:00
Pieter Wuille
57ba401abc Enable double-SHA256-for-64-byte code on 32-bit x86 2018-06-04 11:30:34 -07:00
Pieter Wuille
4437d6e1f3 8-way AVX2 implementation for double SHA256 on 64-byte inputs 2018-05-29 14:18:05 -07:00
Pieter Wuille
230294bf5f 4-way SSE4.1 implementation for double SHA256 on 64-byte inputs 2018-05-29 14:18:05 -07:00
Pieter Wuille
d0c9632883 Specialized double sha256 for 64 byte inputs 2018-05-29 14:05:00 -07:00
Pieter Wuille
57f34630fb Refactor SHA256 code 2018-05-08 07:44:21 -07:00
532479301
18307849b4 Consensus: Fix bug when compiler do not support __builtin_clz*
#ifdef is not correct since defination is defined to 0 or 1. Should change to #if
2018-03-01 17:20:27 +08:00
Akira Takizawa
595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
MeshCollider
1a445343f6 scripted-diff: Replace #include "" with #include <> (ryanofsky)
-BEGIN VERIFY SCRIPT-
for f in \
  src/*.cpp \
  src/*.h \
  src/bench/*.cpp \
  src/bench/*.h \
  src/compat/*.cpp \
  src/compat/*.h \
  src/consensus/*.cpp \
  src/consensus/*.h \
  src/crypto/*.cpp \
  src/crypto/*.h \
  src/crypto/ctaes/*.h \
  src/policy/*.cpp \
  src/policy/*.h \
  src/primitives/*.cpp \
  src/primitives/*.h \
  src/qt/*.cpp \
  src/qt/*.h \
  src/qt/test/*.cpp \
  src/qt/test/*.h \
  src/rpc/*.cpp \
  src/rpc/*.h \
  src/script/*.cpp \
  src/script/*.h \
  src/support/*.cpp \
  src/support/*.h \
  src/support/allocators/*.h \
  src/test/*.cpp \
  src/test/*.h \
  src/wallet/*.cpp \
  src/wallet/*.h \
  src/wallet/test/*.cpp \
  src/wallet/test/*.h \
  src/zmq/*.cpp \
  src/zmq/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-
2017-11-16 08:23:01 +13:00
Wladimir J. van der Laan
3aa60b7ff9
Merge #11143: Fix include path for bitcoin-config.h
5abb93f0e Fix include path for bitcoin-config.h in crypto/common.h (danra)

Pull request description:

  All the other files in the repo which include bitcoin-config.h do so with the appropriate subfolder prefixed: config/bitcoin-config.h
  The header should be included with the appropriate subfolder here as well.

Tree-SHA512: abda23a9cf251553f90afe0ee1866de46ed579471f4139737239a4f9334ca817d985deac6336740898718775d1264c0b80cb348668b10a9cae970895f2de37b8
2017-09-05 23:15:55 +02:00
Wladimir J. van der Laan
df8c72237a
Merge #11176: build: Rename --enable-experimental-asm to --enable-asm and enable by default
538cc0ca8 build: Mention use of asm in summary (Wladimir J. van der Laan)
ce5381e7f build: Rename --enable-experimental-asm to --enable-asm and enable by default (Wladimir J. van der Laan)

Pull request description:

  Now that 0.15 is branched off, enable assembler SHA256 optimizations by default, but still allow disabling them, for example if something goes wrong with auto-detection on a platform.

  Also add mention of the use of asm in the configure summary.

Tree-SHA512: cd20c497f65edd6b1e8b2cc3dfe82be11fcf4777543c830ccdec6c10f25eab4576b0f2953f3957736d7e04deaa4efca777aa84b12bb1cecb40c258e86c120ec8
2017-09-05 22:14:16 +02:00
Utsav Gupta
dc334fe749 Update hmac_sha256.h
Fixed a typo
2017-09-02 09:59:48 +05:30
danra
5abb93f0ee Fix include path for bitcoin-config.h in crypto/common.h
All the other files in the repo which include bitcoin-config.h do so with the appropriate subfolder prefixed: config/bitcoin-config.h
The header should be included with the appropriate subfolder here as well.

This canonicalization also allows getting rid of a bit of extra configuration in Makefile.am.
2017-08-31 21:30:41 +03:00
Wladimir J. van der Laan
ce5381e7fe build: Rename --enable-experimental-asm to --enable-asm and enable by default
Now that 0.15 is branched off, enable assembler SHA256 optimizations by default.
2017-08-28 11:06:11 +02:00
practicalswift
64fb0ac016 Declare single-argument (non-converting) constructors "explicit"
In order to avoid unintended implicit conversions.
2017-08-16 16:33:25 +02:00
practicalswift
90d4d89230 scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
-BEGIN VERIFY SCRIPT-
sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
-END VERIFY SCRIPT-
2017-08-07 07:36:37 +02:00
Pieter Wuille
6b8d872e5e Protect SSE4 code behind a compile-time flag 2017-07-20 09:03:53 -07:00
Pieter Wuille
fa9be909c9 Add selftest for SHA256 transform 2017-07-20 09:03:53 -07:00
Pieter Wuille
c1ccb15b0e Add SSE4 based SHA256 2017-07-20 09:03:53 -07:00
Pieter Wuille
2991c91d88 Add SHA256 dispatcher 2017-07-20 09:03:53 -07:00
Pieter Wuille
4d50f38fe0 Support multi-block SHA256 transforms
Extracted from a patch by Wladimir van der Laan.
2017-07-20 09:03:53 -07:00
practicalswift
90593ed92c Limit variable scope 2017-06-05 00:52:36 +02:00
Pieter Wuille
4fd2d2fc97 Add a FastRandomContext::randrange and use it 2017-03-29 11:26:08 -07:00
Pieter Wuille
e04326fe66 Add ChaCha20 2017-03-29 00:40:17 -07:00
Pieter Wuille
843c560003 Avoid unaligned access in crypto i/o 2017-01-12 11:52:45 -08:00
isle2983
27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Pieter Wuille
760765d5a9 Update ctaes 2016-12-08 17:09:07 -08:00
fsb4000
15fa95d7e5 Fix some typos 2016-11-28 16:16:37 +07:00
Cory Fields
27a212dcb4 crypto: add AES 128/256 CBC classes
The output should always match openssl's, even for failed operations. Even for
a decrypt with broken padding, the output is always deterministic (and attemtps
to be constant-time).
2016-05-13 10:23:03 +02:00
Pieter Wuille
6bec172eb9 Add ctaes-based constant time AES implementation 2016-05-13 10:22:54 +02:00
Pieter Wuille
cd2be4419e
Merge commit 'a545127fbccef4ee674d18d43732ce00ba97f782' as 'src/crypto/ctaes' 2016-05-11 19:37:02 +02:00
Wladimir J. van der Laan
9ad1a51857 crypto: bytes counts are 64 bit
Byte counts for SHA256, SHA512, SHA1 and RIPEMD160 must be 64 bits.
`size_t` has a different size per platform, causing divergent results
when hashing more than 4GB of data.
2016-04-15 16:44:23 +02:00
Wladimir J. van der Laan
4414f5ffe1 build: Endian compatibility
- Detect endian instead of stopping configure on big-endian
- Add `byteswap.h` and `endian.h` header for compatibility with
  Windows and other operating systems that don't come with them
- Update `crypto/common.h` functions to use compat
  endian header
2015-03-06 15:54:53 +01:00
Pieter Wuille
1a9576de9d Use libsecp256k1's RFC6979 implementation 2015-01-06 00:28:44 +01:00
sandakersmann
f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Pieter Wuille
9d8604f36a Header define style cleanups 2014-11-20 17:22:06 +01:00
Pieter Wuille
3060e36098 Add the RFC6979 PRNG 2014-11-20 17:22:06 +01:00
Pieter Wuille
a8f5087e53 Add HMAC-SHA256 2014-11-20 17:22:06 +01:00
Pieter Wuille
36fa4a78ac Split up crypto/sha2 2014-11-20 17:22:02 +01:00
Pavel Janík
84738627ce Fix all header defines 2014-11-03 16:16:40 +01:00