未验证 提交 81908425 编写于 作者: D Daniel Larimer 提交者: GitHub

Merge pull request #2283 from EOSIO/fix_r1_high_s_value

 Fix for logic when signing via r1 key containing high S value
......@@ -526,9 +526,11 @@ namespace fc { namespace crypto { namespace r1 {
if (sig==nullptr)
FC_THROW_EXCEPTION( exception, "Unable to sign" );
const BIGNUM *r, *sig_s;
ssl_bignum s;
ECDSA_SIG_get0(sig, &r, &sig_s);
//We can't use ssl_bignum here; _get0() does not transfer ownership to us; _set0() does transfer ownership to fc::ecdsa_sig
const BIGNUM *sig_r, *sig_s;
BIGNUM *r = BN_new(), *s = BN_new();
ECDSA_SIG_get0(sig, &sig_r, &sig_s);
BN_copy(r, sig_r);
BN_copy(s, sig_s);
//want to always use the low S value
......@@ -545,6 +547,8 @@ namespace fc { namespace crypto { namespace r1 {
int nBitsS = BN_num_bits(s);
if(nBitsR > 256 || nBitsS > 256)
FC_THROW_EXCEPTION( exception, "Unable to sign" );
ECDSA_SIG_set0(sig, r, s);
int nRecId = -1;
for (int i=0; i<4; i++)
......
add_executable( test_cypher_suites test_cypher_suites.cpp )
target_link_libraries( test_cypher_suites fc )
add_test(NAME test_cypher_suites COMMAND libraries/fc/test/crypto/test_cypher_suites WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册