Merge commits '9a8d65f0 75d7b7f5 665ba77e 3f57b9f7 eacad90f 01b819a8 31ed5386 2a39ac16 0eb30004 cbe41ac1 cc3b8a4f ' into temp-merge-1187
This commit is contained in:
@@ -72,9 +72,10 @@ static void secp256k1_ecdsa_s2c_opening_save(secp256k1_ecdsa_s2c_opening* openin
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ARG_CHECK_NO_RETURN(cond) do { \
|
||||
#define ARG_CHECK_VOID(cond) do { \
|
||||
if (EXPECT(!(cond), 0)) { \
|
||||
secp256k1_callback_call(&ctx->illegal_callback, #cond); \
|
||||
return; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
@@ -96,6 +97,15 @@ static const secp256k1_context secp256k1_context_static_ = {
|
||||
const secp256k1_context *secp256k1_context_static = &secp256k1_context_static_;
|
||||
const secp256k1_context *secp256k1_context_no_precomp = &secp256k1_context_static_;
|
||||
|
||||
/* Helper function that determines if a context is proper, i.e., is not the static context or a copy thereof.
|
||||
*
|
||||
* This is intended for "context" functions such as secp256k1_context_clone. Function which need specific
|
||||
* features of a context should still check for these features directly. For example, a function that needs
|
||||
* ecmult_gen should directly check for the existence of the ecmult_gen context. */
|
||||
static int secp256k1_context_is_proper(const secp256k1_context* ctx) {
|
||||
return secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx);
|
||||
}
|
||||
|
||||
void secp256k1_selftest(void) {
|
||||
if (!secp256k1_selftest_passes()) {
|
||||
secp256k1_callback_call(&default_error_callback, "self test failed");
|
||||
@@ -178,7 +188,7 @@ secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
|
||||
}
|
||||
|
||||
void secp256k1_context_preallocated_destroy(secp256k1_context* ctx) {
|
||||
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_static);
|
||||
ARG_CHECK_VOID(ctx != secp256k1_context_static);
|
||||
if (ctx != NULL) {
|
||||
secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx);
|
||||
}
|
||||
@@ -192,7 +202,10 @@ void secp256k1_context_destroy(secp256k1_context* ctx) {
|
||||
}
|
||||
|
||||
void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
|
||||
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_static);
|
||||
/* We compare pointers instead of checking secp256k1_context_is_proper() here
|
||||
because setting callbacks is allowed on *copies* of the static context:
|
||||
it's harmless and makes testing easier. */
|
||||
ARG_CHECK_VOID(ctx != secp256k1_context_static);
|
||||
if (fun == NULL) {
|
||||
fun = secp256k1_default_illegal_callback_fn;
|
||||
}
|
||||
@@ -201,7 +214,10 @@ void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(
|
||||
}
|
||||
|
||||
void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
|
||||
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_static);
|
||||
/* We compare pointers instead of checking secp256k1_context_is_proper() here
|
||||
because setting callbacks is allowed on *copies* of the static context:
|
||||
it's harmless and makes testing easier. */
|
||||
ARG_CHECK_VOID(ctx != secp256k1_context_static);
|
||||
if (fun == NULL) {
|
||||
fun = secp256k1_default_error_callback_fn;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user