FC Updates from BitShares and myself #21

Closed
nathanielhourt wants to merge 687 commits from dapp-support into latest-fc
3 changed files with 7 additions and 11 deletions
Showing only changes of commit 9505342dbf - Show all commits

View file

@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#pragma once
#include <openssl/sha.h>
#include <boost/endian/buffers.hpp>
#include <fc/fwd.hpp>
#include <fc/io/raw_fwd.hpp>
@ -39,7 +40,7 @@ class hash160
explicit operator string()const;
char* data() const;
size_t data_size() const { return 160/8; }
static constexpr size_t data_size() { return 160/8; }
static hash160 hash( const char* d, uint32_t dlen );
static hash160 hash( const string& );
@ -66,7 +67,7 @@ class hash160
private:
class impl;
fc::fwd<impl,96> my;
std::vector<uint8_t> bytes;
SHA256_CTX sha_ctx;;
};
template<typename T>

View file

@ -24,7 +24,6 @@
#include <fc/crypto/hex.hpp>
#include <fc/fwd_impl.hpp>
#include <openssl/sha.h>
#include <openssl/ripemd.h>
#include <string.h>
#include <fc/crypto/hash160.hpp>
@ -55,7 +54,7 @@ class hash160::encoder::impl {
};
hash160::encoder::~encoder() {}
hash160::encoder::encoder() {}
hash160::encoder::encoder() { SHA256_Init(&sha_ctx); }
hash160 hash160::hash( const char* d, uint32_t dlen ) {
encoder e;
@ -69,15 +68,11 @@ hash160 hash160::hash( const string& s ) {
void hash160::encoder::write( const char* d, uint32_t dlen )
{
for(uint32_t i = 0; i < dlen; ++i)
bytes.push_back(d[i]);
SHA256_Update( &sha_ctx, d, dlen);
}
hash160 hash160::encoder::result() {
// perform the first hashing function
SHA256_CTX sha_ctx;
SHA256_Init(&sha_ctx);
SHA256_Update( &sha_ctx, bytes.data(), bytes.size());
// finalize the first hash
unsigned char sha_hash[SHA256_DIGEST_LENGTH];
SHA256_Final( sha_hash, &sha_ctx );
// perform the second hashing function

View file

@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(static_variant_depth_test)
for( const auto& line : lines )
if( line.find("_svdt_visitor") != std::string::npos ) count++;
BOOST_CHECK_LT( 2, count ); // test.visit(), static_variant::visit, function object, visitor
BOOST_CHECK_GT( 8, count ); // some is implementation-dependent
BOOST_CHECK_GT( 10, count ); // some is implementation-dependent
}
#endif