Skip to content

Commit f06fdc0

Browse files
committed
Only have declassify flag in context when checkmem available
1 parent 376a06e commit f06fdc0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/secp256k1.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,18 @@ struct secp256k1_context_struct {
6060
secp256k1_ecmult_gen_context ecmult_gen_ctx;
6161
secp256k1_callback illegal_callback;
6262
secp256k1_callback error_callback;
63+
#if SECP256K1_CHECKMEM_ENABLED
6364
int declassify;
65+
#endif
6466
};
6567

6668
static const secp256k1_context secp256k1_context_static_ = {
6769
{ 0 },
6870
{ secp256k1_default_illegal_callback_fn, 0 },
69-
{ secp256k1_default_error_callback_fn, 0 },
70-
0
71+
{ secp256k1_default_error_callback_fn, 0 }
72+
#if SECP256K1_CHECKMEM_ENABLED
73+
, 0
74+
#endif
7175
};
7276
const secp256k1_context *secp256k1_context_static = &secp256k1_context_static_;
7377
const secp256k1_context *secp256k1_context_no_precomp = &secp256k1_context_static_;
@@ -116,7 +120,9 @@ secp256k1_context* secp256k1_context_preallocated_create(void* prealloc, unsigne
116120
/* Flags have been checked by secp256k1_context_preallocated_size. */
117121
VERIFY_CHECK((flags & SECP256K1_FLAGS_TYPE_MASK) == SECP256K1_FLAGS_TYPE_CONTEXT);
118122
secp256k1_ecmult_gen_context_build(&ret->ecmult_gen_ctx);
123+
#if SECP256K1_CHECKMEM_ENABLED
119124
ret->declassify = !!(flags & SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY);
125+
#endif
120126

121127
return ret;
122128
}
@@ -199,7 +205,13 @@ void secp256k1_scratch_space_destroy(const secp256k1_context *ctx, secp256k1_scr
199205
* of the software.
200206
*/
201207
static SECP256K1_INLINE void secp256k1_declassify(const secp256k1_context* ctx, const void *p, size_t len) {
208+
#if SECP256K1_CHECKMEM_ENABLED
202209
if (EXPECT(ctx->declassify, 0)) SECP256K1_CHECKMEM_DEFINE(p, len);
210+
#else
211+
(void)ctx;
212+
(void)p;
213+
(void)len;
214+
#endif
203215
}
204216

205217
static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) {

0 commit comments

Comments
 (0)