Updates from BitShares FC #22

Closed
nathanielhourt wants to merge 693 commits from dapp-support into latest-fc
2 changed files with 12 additions and 12 deletions
Showing only changes of commit c554c7e56d - Show all commits

View file

@ -22,11 +22,10 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#pragma once #pragma once
#include <openssl/sha.h>
#include <boost/endian/buffers.hpp> #include <boost/endian/buffers.hpp>
#include <fc/fwd.hpp> #include <fc/fwd.hpp>
#include <fc/string.hpp>
#include <fc/io/raw_fwd.hpp> #include <fc/io/raw_fwd.hpp>
#include <fc/reflect/typename.hpp>
namespace fc{ namespace fc{
@ -66,8 +65,7 @@ class hash160
private: private:
class impl; class impl;
fc::fwd<impl,96> my; fc::fwd<impl,117> my;
SHA256_CTX sha_ctx;;
}; };
template<typename T> template<typename T>

View file

@ -23,12 +23,15 @@
*/ */
#include <fc/crypto/hex.hpp> #include <fc/crypto/hex.hpp>
#include <fc/crypto/hmac.hpp>
#include <fc/fwd_impl.hpp> #include <fc/fwd_impl.hpp>
#include <openssl/sha.h>
#include <openssl/ripemd.h> #include <openssl/ripemd.h>
#include <string.h> #include <string.h>
#include <cmath>
#include <fc/crypto/hash160.hpp> #include <fc/crypto/hash160.hpp>
#include <fc/variant.hpp> #include <fc/variant.hpp>
#include <vector> #include <fc/exception/exception.hpp>
#include "_digest_common.hpp" #include "_digest_common.hpp"
namespace fc namespace fc
@ -48,13 +51,12 @@ hash160::operator string()const { return str(); }
char* hash160::data()const { return (char*)&_hash[0]; } char* hash160::data()const { return (char*)&_hash[0]; }
class hash160::encoder::impl { struct hash160::encoder::impl {
public: SHA256_CTX ctx;
impl() { }
}; };
hash160::encoder::~encoder() {} hash160::encoder::~encoder() {}
hash160::encoder::encoder() { SHA256_Init(&sha_ctx); } hash160::encoder::encoder() { SHA256_Init(&my->ctx); }
hash160 hash160::hash( const char* d, uint32_t dlen ) { hash160 hash160::hash( const char* d, uint32_t dlen ) {
encoder e; encoder e;
@ -68,13 +70,13 @@ hash160 hash160::hash( const string& s ) {
void hash160::encoder::write( const char* d, uint32_t dlen ) void hash160::encoder::write( const char* d, uint32_t dlen )
{ {
SHA256_Update( &sha_ctx, d, dlen); SHA256_Update( &my->ctx, d, dlen);
} }
hash160 hash160::encoder::result() { hash160 hash160::encoder::result() {
// finalize the first hash // finalize the first hash
unsigned char sha_hash[SHA256_DIGEST_LENGTH]; unsigned char sha_hash[SHA256_DIGEST_LENGTH];
SHA256_Final( sha_hash, &sha_ctx ); SHA256_Final( sha_hash, &my->ctx );
// perform the second hashing function // perform the second hashing function
RIPEMD160_CTX ripe_ctx; RIPEMD160_CTX ripe_ctx;
RIPEMD160_Init(&ripe_ctx); RIPEMD160_Init(&ripe_ctx);
@ -86,7 +88,7 @@ hash160 hash160::encoder::result() {
void hash160::encoder::reset() void hash160::encoder::reset()
{ {
SHA256_Init(&sha_ctx); SHA256_Init(&my->ctx);
} }
hash160 operator << ( const hash160& h1, uint32_t i ) { hash160 operator << ( const hash160& h1, uint32_t i ) {