mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
JNI: Only call ecdsa_verify if its inputs parsed correctly
Return 0 otherwise instead of calling it with bad parameters.
This commit is contained in:
parent
7b549b1abc
commit
a40c701c83
@ -48,7 +48,6 @@ SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1ve
|
|||||||
{
|
{
|
||||||
secp256k1_context *ctx = (secp256k1_context*)ctx_l;
|
secp256k1_context *ctx = (secp256k1_context*)ctx_l;
|
||||||
|
|
||||||
int result;
|
|
||||||
unsigned char* data = (unsigned char*) (*env)->GetDirectBufferAddress(env, byteBufferObject);
|
unsigned char* data = (unsigned char*) (*env)->GetDirectBufferAddress(env, byteBufferObject);
|
||||||
const unsigned char* sigdata = { (unsigned char*) (data + 32) };
|
const unsigned char* sigdata = { (unsigned char*) (data + 32) };
|
||||||
const unsigned char* pubdata = { (unsigned char*) (data + siglen + 32) };
|
const unsigned char* pubdata = { (unsigned char*) (data + siglen + 32) };
|
||||||
@ -60,13 +59,15 @@ SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1ve
|
|||||||
|
|
||||||
if( ret ) {
|
if( ret ) {
|
||||||
ret = secp256k1_ec_pubkey_parse(ctx, &pubkey, pubdata, publen);
|
ret = secp256k1_ec_pubkey_parse(ctx, &pubkey, pubdata, publen);
|
||||||
|
|
||||||
|
if( ret ) {
|
||||||
|
ret = secp256k1_ecdsa_verify(ctx, &sig, data, &pubkey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)classObject;
|
(void)classObject;
|
||||||
|
|
||||||
result = secp256k1_ecdsa_verify(ctx, &sig, data, &pubkey);
|
return ret;
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1sign
|
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1sign
|
||||||
|
Loading…
Reference in New Issue
Block a user