From 7b4737c87805b464cd47d01a9d814df5e41b8255 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 26 Apr 2014 19:26:34 +0200 Subject: Switch script.cpp and hash.cpp to use sha2.cpp instead of OpenSSL. --- src/script.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/script.cpp') diff --git a/src/script.cpp b/src/script.cpp index 11cdfef95..f20c0bcca 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -9,10 +9,13 @@ #include "hash.h" #include "key.h" #include "keystore.h" +#include "sha2.h" #include "sync.h" #include "uint256.h" #include "util.h" +#include + #include #include #include @@ -805,17 +808,11 @@ bool EvalScript(vector >& stack, const CScript& script, co else if (opcode == OP_SHA1) SHA1(&vch[0], vch.size(), &vchHash[0]); else if (opcode == OP_SHA256) - SHA256(&vch[0], vch.size(), &vchHash[0]); + CSHA256().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); else if (opcode == OP_HASH160) - { - uint160 hash160 = Hash160(vch); - memcpy(&vchHash[0], &hash160, sizeof(hash160)); - } + CHash160().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); else if (opcode == OP_HASH256) - { - uint256 hash = Hash(vch.begin(), vch.end()); - memcpy(&vchHash[0], &hash, sizeof(hash)); - } + CHash256().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); popstack(stack); stack.push_back(vchHash); } -- cgit v1.2.3 From 1cc344ce42d8dddd6356c89ef3ceb58418676816 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 28 Apr 2014 03:09:13 +0200 Subject: Add built-in SHA-1 implementation. --- src/script.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/script.cpp') diff --git a/src/script.cpp b/src/script.cpp index f20c0bcca..facf3044d 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -9,13 +9,12 @@ #include "hash.h" #include "key.h" #include "keystore.h" +#include "sha1.h" #include "sha2.h" #include "sync.h" #include "uint256.h" #include "util.h" -#include - #include #include #include @@ -806,7 +805,7 @@ bool EvalScript(vector >& stack, const CScript& script, co if (opcode == OP_RIPEMD160) RIPEMD160(&vch[0], vch.size(), &vchHash[0]); else if (opcode == OP_SHA1) - SHA1(&vch[0], vch.size(), &vchHash[0]); + CSHA1().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); else if (opcode == OP_SHA256) CSHA256().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); else if (opcode == OP_HASH160) -- cgit v1.2.3 From 13b5dfef64bbb77d583b2acc59e2b33f89645308 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 28 Apr 2014 12:20:15 +0200 Subject: Move crypto implementations to src/crypto/ --- src/script.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/script.cpp') diff --git a/src/script.cpp b/src/script.cpp index facf3044d..c6574a6ee 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -9,8 +9,8 @@ #include "hash.h" #include "key.h" #include "keystore.h" -#include "sha1.h" -#include "sha2.h" +#include "crypto/sha1.h" +#include "crypto/sha2.h" #include "sync.h" #include "uint256.h" #include "util.h" -- cgit v1.2.3 From a5bc9c09177420bd1c6a1f9ece9ecfbe80c453fe Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 1 May 2014 00:43:31 +0200 Subject: Add built-in RIPEMD-160 implementation --- src/script.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/script.cpp') diff --git a/src/script.cpp b/src/script.cpp index c6574a6ee..b383a00a6 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -11,6 +11,7 @@ #include "keystore.h" #include "crypto/sha1.h" #include "crypto/sha2.h" +#include "crypto/ripemd160.h" #include "sync.h" #include "uint256.h" #include "util.h" @@ -803,7 +804,7 @@ bool EvalScript(vector >& stack, const CScript& script, co valtype& vch = stacktop(-1); valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32); if (opcode == OP_RIPEMD160) - RIPEMD160(&vch[0], vch.size(), &vchHash[0]); + CRIPEMD160().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); else if (opcode == OP_SHA1) CSHA1().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); else if (opcode == OP_SHA256) -- cgit v1.2.3