Removed gotos, which are hard to trace and maintain.

This commit is contained in:
Iang authored and Pieter Wuille committed 2015-02-12 18:18:31 -08:00
1 parent 035406d6db
commit 11690d3bb9
1 file changed
+5 -10
+5 -10
View File
@@ -37,7 +37,6 @@ int secp256k1_ecdsa_verify(const unsigned char *msg32, const unsigned char *sig,
secp256k1_ge_t q; secp256k1_ge_t q;
secp256k1_ecdsa_sig_t s; secp256k1_ecdsa_sig_t s;
secp256k1_scalar_t m; secp256k1_scalar_t m;
int ret = -3;
DEBUG_CHECK(secp256k1_ecmult_consts != NULL); DEBUG_CHECK(secp256k1_ecmult_consts != NULL);
DEBUG_CHECK(msg32 != NULL); DEBUG_CHECK(msg32 != NULL);
DEBUG_CHECK(sig != NULL); DEBUG_CHECK(sig != NULL);
@@ -46,20 +45,16 @@ int secp256k1_ecdsa_verify(const unsigned char *msg32, const unsigned char *sig,
secp256k1_scalar_set_b32(&m, msg32, NULL); secp256k1_scalar_set_b32(&m, msg32, NULL);
if (!secp256k1_eckey_pubkey_parse(&q, pubkey, pubkeylen)) { if (!secp256k1_eckey_pubkey_parse(&q, pubkey, pubkeylen)) {
ret = -1; return -1;
goto end;
} }
if (!secp256k1_ecdsa_sig_parse(&s, sig, siglen)) { if (!secp256k1_ecdsa_sig_parse(&s, sig, siglen)) {
ret = -2; return -2;
goto end;
} }
if (!secp256k1_ecdsa_sig_verify(&s, &q, &m)) { if (!secp256k1_ecdsa_sig_verify(&s, &q, &m)) {
ret = 0; return 0;
goto end;
} }
ret = 1; /* success is 1, all other values are fail */
end: return 1;
return ret;
} }
static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, unsigned int counter, const void *data) { static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, unsigned int counter, const void *data) {