From: Rudolf Polzer Date: Tue, 25 Oct 2011 11:30:18 +0000 (+0200) Subject: mark things that need to be made threadsafe X-Git-Tag: v0.5~21 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7fd30783216b874f085f19fff2d22ff2133b1fd6;p=xonotic%2Fd0_blind_id.git mark things that need to be made threadsafe --- diff --git a/d0_bignum-gmp.c b/d0_bignum-gmp.c index c26e9fc..d59f735 100644 --- a/d0_bignum-gmp.c +++ b/d0_bignum-gmp.c @@ -56,8 +56,8 @@ struct d0_bignum_s mpz_t z; }; -static gmp_randstate_t RANDSTATE; -static d0_bignum_t temp; +static gmp_randstate_t RANDSTATE; // FIXME make threadsafe +static d0_bignum_t temp; // FIXME make threadsafe #include #include @@ -133,7 +133,7 @@ void d0_bignum_SHUTDOWN(void) D0_BOOL d0_iobuf_write_bignum(d0_iobuf_t *buf, const d0_bignum_t *bignum) { - static unsigned char numbuf[65536]; + static unsigned char numbuf[65536]; // FIXME make threadsafe size_t count = 0; numbuf[0] = mpz_sgn(bignum->z) & 3; if((numbuf[0] & 3) != 0) // nonzero @@ -148,7 +148,7 @@ D0_BOOL d0_iobuf_write_bignum(d0_iobuf_t *buf, const d0_bignum_t *bignum) d0_bignum_t *d0_iobuf_read_bignum(d0_iobuf_t *buf, d0_bignum_t *bignum) { - static unsigned char numbuf[65536]; + static unsigned char numbuf[65536]; // FIXME make threadsafe size_t count = sizeof(numbuf); if(!d0_iobuf_read_packet(buf, numbuf, &count)) return NULL; diff --git a/d0_bignum-openssl.c b/d0_bignum-openssl.c index 1e103a4..1d92c32 100644 --- a/d0_bignum-openssl.c +++ b/d0_bignum-openssl.c @@ -57,8 +57,8 @@ struct d0_bignum_s BIGNUM z; }; -static d0_bignum_t temp; -static BN_CTX *ctx; +static d0_bignum_t temp; // FIXME make threadsafe +static BN_CTX *ctx; // FIXME make threadsafe #include #include @@ -79,7 +79,7 @@ void d0_bignum_SHUTDOWN(void) D0_BOOL d0_iobuf_write_bignum(d0_iobuf_t *buf, const d0_bignum_t *bignum) { - static unsigned char numbuf[65536]; + static unsigned char numbuf[65536]; // FIXME make threadsafe size_t count = 0; numbuf[0] = BN_is_zero(&bignum->z) ? 0 : BN_is_negative(&bignum->z) ? 3 : 1; if((numbuf[0] & 3) != 0) // nonzero @@ -94,7 +94,7 @@ D0_BOOL d0_iobuf_write_bignum(d0_iobuf_t *buf, const d0_bignum_t *bignum) d0_bignum_t *d0_iobuf_read_bignum(d0_iobuf_t *buf, d0_bignum_t *bignum) { - static unsigned char numbuf[65536]; + static unsigned char numbuf[65536]; // FIXME make threadsafe size_t count = sizeof(numbuf); if(!d0_iobuf_read_packet(buf, numbuf, &count)) return NULL; diff --git a/d0_bignum-tommath.c b/d0_bignum-tommath.c index d28a56f..b3230fd 100644 --- a/d0_bignum-tommath.c +++ b/d0_bignum-tommath.c @@ -50,7 +50,7 @@ struct d0_bignum_s mp_int z; }; -static d0_bignum_t temp; +static d0_bignum_t temp; // FIXME make threadsafe #include @@ -123,7 +123,7 @@ void d0_bignum_SHUTDOWN(void) D0_BOOL d0_iobuf_write_bignum(d0_iobuf_t *buf, const d0_bignum_t *bignum) { - static unsigned char numbuf[65536]; + static unsigned char numbuf[65536]; // FIXME make threadsafe size_t count = 0; numbuf[0] = (mp_iszero(&bignum->z) ? 0 : (bignum->z.sign == MP_ZPOS) ? 1 : 3); if((numbuf[0] & 3) != 0) // nonzero @@ -138,7 +138,7 @@ D0_BOOL d0_iobuf_write_bignum(d0_iobuf_t *buf, const d0_bignum_t *bignum) d0_bignum_t *d0_iobuf_read_bignum(d0_iobuf_t *buf, d0_bignum_t *bignum) { - static unsigned char numbuf[65536]; + static unsigned char numbuf[65536]; // FIXME make threadsafe size_t count = sizeof(numbuf); if(!d0_iobuf_read_packet(buf, numbuf, &count)) return NULL; @@ -425,7 +425,7 @@ d0_bignum_t *d0_bignum_gcd(d0_bignum_t *r, d0_bignum_t *s, d0_bignum_t *t, const char *d0_bignum_tostring(const d0_bignum_t *x, unsigned int base) { - static char str[65536]; + static char str[65536]; // FIXME make threadsafe mp_toradix_n((mp_int *) &x->z, str, base, sizeof(str)); return str; } diff --git a/d0_blind_id.c b/d0_blind_id.c index 8852402..fd32cdb 100644 --- a/d0_blind_id.c +++ b/d0_blind_id.c @@ -47,7 +47,7 @@ #define SHA_DIGESTSIZE 32 const char *sha(const unsigned char *in, size_t len) { - static char h[32]; + char h[32]; d0_blind_id_util_sha256(h, (const char *) in, len); return h; } @@ -109,7 +109,8 @@ struct d0_blind_id_s #define USING(x) if(!(ctx->x)) return 0 #define REPLACING(x) -static d0_bignum_t *zero, *one, *four, *temp0, *temp1, *temp2, *temp3, *temp4; +static d0_bignum_t *zero, *one, *four; +static d0_bignum_t *temp0, *temp1, *temp2, *temp3, *temp4; // FIXME make these thread safe by putting them in some per-thread object D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_INITIALIZE(void) { @@ -316,7 +317,7 @@ D0_WARN_UNUSED_RESULT D0_BOOL d0_longhash_destructive(unsigned char *convbuf, si D0_WARN_UNUSED_RESULT D0_BOOL d0_longhash_bignum(const d0_bignum_t *in, unsigned char *outbuf, size_t outbuflen) { - static unsigned char convbuf[1024]; + unsigned char convbuf[1024]; size_t sz; CHECK(d0_bignum_export_unsigned(in, convbuf, sizeof(convbuf)) >= 0); @@ -463,7 +464,7 @@ fail: D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_fingerprint64_public_key(const d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen) { d0_iobuf_t *out = NULL; - static unsigned char convbuf[2048]; + unsigned char convbuf[2048]; d0_iobuf_t *conv = NULL; size_t sz, n; @@ -553,7 +554,7 @@ fail: D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_generate_private_id_request(d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen) { d0_iobuf_t *out = NULL; - static unsigned char shabuf[2048]; + unsigned char shabuf[2048]; size_t sz; // temps: temp0 rsa_blind_signature_camouflage^challenge, temp1 (4^s)*rsa_blind_signature_camouflage^challenge @@ -742,7 +743,7 @@ D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_authenticate_with_private_id_start(d0_ // 1. get random r, send HASH(4^r) { d0_iobuf_t *out = NULL; - static unsigned char convbuf[1024]; + unsigned char convbuf[1024]; d0_iobuf_t *conv = NULL; size_t sz = 0; D0_BOOL failed = 0; @@ -815,7 +816,7 @@ D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_authenticate_with_private_id_challenge { d0_iobuf_t *in = NULL; d0_iobuf_t *out = NULL; - static unsigned char shabuf[2048]; + unsigned char shabuf[2048]; size_t sz; // temps: temp0 order, temp0 signature check @@ -960,7 +961,7 @@ D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_authenticate_with_private_id_verify(d0 // (check using H(g^r) which we know) { d0_iobuf_t *in = NULL; - static unsigned char convbuf[1024]; + unsigned char convbuf[1024]; d0_iobuf_t *conv = NULL; size_t sz; @@ -1027,7 +1028,7 @@ fail: D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_authenticate_with_private_id_generate_missing_signature(d0_blind_id_t *ctx) { size_t sz; - static unsigned char shabuf[2048]; + unsigned char shabuf[2048]; REPLACING(schnorr_H_g_to_s_signature); USING(schnorr_g_to_s); USING(rsa_d); USING(rsa_n); @@ -1053,7 +1054,7 @@ D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_sign_with_private_id_sign_internal(d0_ { d0_iobuf_t *out = NULL; unsigned char *convbuf = NULL; - static unsigned char shabuf[2048]; + unsigned char shabuf[2048]; d0_iobuf_t *conv = NULL; size_t sz = 0; @@ -1127,7 +1128,7 @@ D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_sign_with_private_id_verify_internal(d d0_iobuf_t *in = NULL; d0_iobuf_t *conv = NULL; unsigned char *convbuf = NULL; - static unsigned char shabuf[2048]; + unsigned char shabuf[2048]; size_t sz; if(is_first) @@ -1239,7 +1240,7 @@ D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_sign_with_private_id_verify_detached(d D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_fingerprint64_public_id(const d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen) { d0_iobuf_t *out = NULL; - static unsigned char convbuf[1024]; + unsigned char convbuf[1024]; d0_iobuf_t *conv = NULL; size_t sz, n;