]> git.xonotic.org Git - xonotic/d0_blind_id.git/commitdiff
mark things that need to be made threadsafe
authorRudolf Polzer <divverent@xonotic.org>
Tue, 25 Oct 2011 11:30:18 +0000 (13:30 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 25 Oct 2011 11:30:18 +0000 (13:30 +0200)
d0_bignum-gmp.c
d0_bignum-openssl.c
d0_bignum-tommath.c
d0_blind_id.c

index c26e9fc7e13656f1d0b1dabf4050083dc53711a4..d59f735009fb262bee270647e4fe13f9f16be4ac 100644 (file)
@@ -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 <time.h>
 #include <stdio.h>
@@ -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;
index 1e103a4c725c8ca75dcf67e052544cdfdb153dd4..1d92c32898763bfd91511f496e6da1ae179ae74b 100644 (file)
@@ -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 <time.h>
 #include <stdio.h>
@@ -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;
index d28a56fc0cb31765b08678de60755cb869828645..b3230fd6d4e422b7b47908ef4cb73523b010467f 100644 (file)
@@ -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 <stdio.h>
 
@@ -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;
 }
index 8852402cfe544e317bdd4c429b0ee3c192f4d8cc..fd32cdb75b7b7c0af0125edc5e2c949d2216be7e 100644 (file)
@@ -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;