Esempio n. 1
0
    signature  private_key::sign( const sha256& digest )const
    {
       if( !my ) FC_THROW_EXCEPTION( assert_exception, "!null" );
       signature sig;
       sig.resize( RSA_size(my->rsa) );

       uint32_t slen = 0;
       if( 1 != RSA_sign( NID_sha256, (uint8_t*)digest.data(),
                          32, (unsigned char*)sig.data(), &slen, my->rsa ) )
       {
          FC_THROW_EXCEPTION( exception, "rsa sign failed with ${message}", ("message",fc::string(ERR_error_string( ERR_get_error(),NULL))) );
       }
       return sig;
    }
Esempio n. 2
0
 sha256 operator << ( const sha256& h1, uint32_t i ) {
   sha256 result;
   fc::detail::shift_l( h1.data(), result.data(), result.data_size(), i );
   return result;
 }
Esempio n. 3
0
 sha256 sha256::hash( const sha256& s )
 {
     return hash( s.data(), sizeof( s._hash ) );
 }
Esempio n. 4
0
      sha256 h;
      SHA256_Final((uint8_t*)h.data(), &my->ctx );
      return h;
    }
    void sha256::encoder::reset() {
      SHA256_Init( &my->ctx);  
    }

    sha256 operator << ( const sha256& h1, uint32_t i ) {
      sha256 result;
      fc::detail::shift_l( h1.data(), result.data(), result.data_size(), i );
      return result;
    }
    sha256 operator >> ( const sha256& h1, uint32_t i ) {
      sha256 result;
      fc::detail::shift_r( h1.data(), result.data(), result.data_size(), i );
      return result;
    }
    sha256 operator ^ ( const sha256& h1, const sha256& h2 ) {
      sha256 result;
      result._hash[0] = h1._hash[0] ^ h2._hash[0];
      result._hash[1] = h1._hash[1] ^ h2._hash[1];
      result._hash[2] = h1._hash[2] ^ h2._hash[2];
      result._hash[3] = h1._hash[3] ^ h2._hash[3];
      return result;
    }
    bool operator >= ( const sha256& h1, const sha256& h2 ) {
      return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) >= 0;
    }
    bool operator > ( const sha256& h1, const sha256& h2 ) {
      return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) > 0;