Updates to crypto/fc
This commit is contained in:
parent
59a121d64b
commit
639a0c795a
5 changed files with 19 additions and 17 deletions
|
|
@ -105,6 +105,7 @@ set( fc_sources
|
|||
src/crypto/hex.cpp
|
||||
src/crypto/sha1.cpp
|
||||
src/crypto/sha256.cpp
|
||||
src/crypto/sha512.cpp
|
||||
src/crypto/dh.cpp
|
||||
src/crypto/blowfish.cpp
|
||||
src/network/tcp_socket.cpp
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <fc/crypto/sha512.hpp>
|
||||
#include <fc/fwd.hpp>
|
||||
#include <fc/array.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace fc { namespace ecc {
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ namespace fc { namespace ecc {
|
|||
~public_key();
|
||||
bool verify( const fc::sha256& digest, const signature& sig );
|
||||
|
||||
std::vector<char> serialize();
|
||||
std::vector<char> serialize()const;
|
||||
public_key( const std::vector<char>& v );
|
||||
public_key( const compact_signature& c, const fc::sha256& digest );
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -106,13 +106,13 @@ namespace fc {
|
|||
if( b ) { v = T(); unpack( s, *v ); }
|
||||
}
|
||||
|
||||
// fc::vector
|
||||
template<typename Stream> inline void pack( Stream& s, const fc::vector<char>& value ) {
|
||||
// std::vector
|
||||
template<typename Stream> inline void pack( Stream& s, const std::vector<char>& value ) {
|
||||
pack( s, unsigned_int(value.size()) );
|
||||
if( value.size() )
|
||||
s.write( &value.front(), value.size() );
|
||||
}
|
||||
template<typename Stream> inline void unpack( Stream& s, fc::vector<char>& value ) {
|
||||
template<typename Stream> inline void unpack( Stream& s, std::vector<char>& value ) {
|
||||
unsigned_int size; unpack( s, size );
|
||||
value.resize(size.value);
|
||||
if( value.size() )
|
||||
|
|
@ -126,7 +126,7 @@ namespace fc {
|
|||
}
|
||||
|
||||
template<typename Stream> inline void unpack( Stream& s, fc::string& v ) {
|
||||
fc::vector<char> tmp; unpack(s,tmp);
|
||||
std::vector<char> tmp; unpack(s,tmp);
|
||||
v = fc::string(tmp.begin(),tmp.end());
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ namespace fc {
|
|||
|
||||
|
||||
template<typename Stream, typename T>
|
||||
inline void pack( Stream& s, const fc::vector<T>& value ) {
|
||||
inline void pack( Stream& s, const std::vector<T>& value ) {
|
||||
pack( s, unsigned_int(value.size()) );
|
||||
auto itr = value.begin();
|
||||
auto end = value.end();
|
||||
|
|
@ -222,7 +222,7 @@ namespace fc {
|
|||
}
|
||||
|
||||
template<typename Stream, typename T>
|
||||
inline void unpack( Stream& s, fc::vector<T>& value ) {
|
||||
inline void unpack( Stream& s, std::vector<T>& value ) {
|
||||
unsigned_int size; unpack( s, size );
|
||||
value.resize(size.value);
|
||||
auto itr = value.begin();
|
||||
|
|
@ -383,10 +383,10 @@ namespace fc {
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
inline fc::vector<char> pack( const T& v ) {
|
||||
inline std::vector<char> pack( const T& v ) {
|
||||
datastream<size_t> ps;
|
||||
raw::pack(ps,v );
|
||||
fc::vector<char> vec(ps.tellp());
|
||||
std::vector<char> vec(ps.tellp());
|
||||
|
||||
if( vec.size() ) {
|
||||
datastream<char*> ds( vec.data(), size_t(vec.size()) );
|
||||
|
|
@ -396,7 +396,7 @@ namespace fc {
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
inline T unpack( const fc::vector<char>& s ) {
|
||||
inline T unpack( const std::vector<char>& s ) {
|
||||
T tmp;
|
||||
if( s.size() ) {
|
||||
datastream<const char*> ds( s.data(), size_t(s.size()) );
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ namespace fc { namespace raw {
|
|||
template<typename Stream, typename T> inline void pack( Stream& s, const T& v );
|
||||
template<typename Stream, typename T> inline void unpack( Stream& s, T& v );
|
||||
|
||||
template<typename Stream, typename T> inline void pack( Stream& s, const fc::vector<T>& v );
|
||||
template<typename Stream, typename T> inline void unpack( Stream& s, fc::vector<T>& v );
|
||||
template<typename Stream, typename T> inline void pack( Stream& s, const std::vector<T>& v );
|
||||
template<typename Stream, typename T> inline void unpack( Stream& s, std::vector<T>& v );
|
||||
|
||||
template<typename Stream> inline void pack( Stream& s, const signed_int& v );
|
||||
template<typename Stream> inline void unpack( Stream& s, signed_int& vi );
|
||||
|
|
@ -22,8 +22,8 @@ namespace fc { namespace raw {
|
|||
template<typename Stream> inline void unpack( Stream& s, unsigned_int& vi );
|
||||
|
||||
template<typename Stream> inline void pack( Stream& s, const char* v );
|
||||
template<typename Stream> inline void pack( Stream& s, const fc::vector<char>& value );
|
||||
template<typename Stream> inline void unpack( Stream& s, fc::vector<char>& value );
|
||||
template<typename Stream> inline void pack( Stream& s, const std::vector<char>& value );
|
||||
template<typename Stream> inline void unpack( Stream& s, std::vector<char>& value );
|
||||
|
||||
template<typename Stream, typename T, size_t N> inline void pack( Stream& s, const fc::array<T,N>& v);
|
||||
template<typename Stream, typename T, size_t N> inline void unpack( Stream& s, fc::array<T,N>& v);
|
||||
|
|
@ -31,8 +31,8 @@ namespace fc { namespace raw {
|
|||
template<typename Stream> inline void pack( Stream& s, const bool& v );
|
||||
template<typename Stream> inline void unpack( Stream& s, bool& v );
|
||||
|
||||
template<typename T> inline fc::vector<char> pack( const T& v );
|
||||
template<typename T> inline T unpack( const fc::vector<char>& s );
|
||||
template<typename T> inline std::vector<char> pack( const T& v );
|
||||
template<typename T> inline T unpack( const std::vector<char>& s );
|
||||
template<typename T> inline T unpack( const char* d, uint32_t s );
|
||||
template<typename T> inline void unpack( const char* d, uint32_t s, T& v );
|
||||
} }
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ namespace fc { namespace ecc {
|
|||
return 1 == ECDSA_verify( 0, (unsigned char*)&digest, sizeof(digest), (unsigned char*)&sig, sizeof(sig), my->_key );
|
||||
}
|
||||
|
||||
std::vector<char> public_key::serialize()
|
||||
std::vector<char> public_key::serialize()const
|
||||
{
|
||||
EC_KEY_set_conv_form( my->_key, POINT_CONVERSION_COMPRESSED );
|
||||
size_t nbytes = i2o_ECPublicKey( my->_key, nullptr );
|
||||
|
|
|
|||
Loading…
Reference in a new issue