1
0
Fork 0
forked from lthn/blockchain

made crypto_ops::validate_key_image exception safe

This commit is contained in:
sowle 2019-05-23 05:07:59 +03:00
parent f8f0e7a817
commit 007769124a

View file

@ -27,9 +27,11 @@
namespace crypto {
DISABLE_GCC_AND_CLANG_WARNING(strict-aliasing)
const unsigned char Z_[32] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char I_[32] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char L_[32] = { 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 };
const key_image Z = *reinterpret_cast<const key_image*>(&Z_);
const key_image I = *reinterpret_cast<const key_image*>(&I_);
const key_image L = *reinterpret_cast<const key_image*>(&L_);
@ -148,10 +150,7 @@ namespace crypto {
ge_p3 A = ge_p3();
ge_p2 R = ge_p2();
if (ge_frombytes_vartime(&A, reinterpret_cast<const unsigned char*>(&P)) != 0)
{
crypto_assert(false);
throw std::runtime_error(__func__);
}
return Z;
ge_scalarmult(&R, reinterpret_cast<const unsigned char*>(&a), &A);
key_image a_p = key_image();
ge_tobytes(reinterpret_cast<unsigned char*>(&a_p), &R);
@ -161,9 +160,8 @@ namespace crypto {
bool crypto_ops::validate_key_image(const key_image& ki)
{
if (!(scalarmult_key(ki, L) == I))
{
return false;
}
return true;
}