From: Rudolf Polzer Date: Fri, 9 Jul 2010 17:50:16 +0000 (+0200) Subject: make "copy" return a value X-Git-Tag: xonotic-v0.1.0preview~38^2~15^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f0b19bc4b96f163e58e2c87a8d8ff43899a919b8;p=xonotic%2Fd0_blind_id.git make "copy" return a value --- diff --git a/d0_blind_id.c b/d0_blind_id.c index 3ab8b38..b4f912e 100644 --- a/d0_blind_id.c +++ b/d0_blind_id.c @@ -273,23 +273,27 @@ void d0_blind_id_clear(d0_blind_id_t *ctx) memset(ctx, 0, sizeof(*ctx)); } -void d0_blind_id_copy(d0_blind_id_t *ctx, const d0_blind_id_t *src) +WARN_UNUSED_RESULT BOOL d0_blind_id_copy(d0_blind_id_t *ctx, const d0_blind_id_t *src) { d0_blind_id_clear(ctx); - if(src->rsa_n) ctx->rsa_n = d0_bignum_mov(NULL, src->rsa_n); - if(src->rsa_e) ctx->rsa_e = d0_bignum_mov(NULL, src->rsa_e); - if(src->rsa_d) ctx->rsa_d = d0_bignum_mov(NULL, src->rsa_d); - if(src->schnorr_G) ctx->schnorr_G = d0_bignum_mov(NULL, src->schnorr_G); - if(src->schnorr_s) ctx->schnorr_s = d0_bignum_mov(NULL, src->schnorr_s); - if(src->schnorr_4_to_s) ctx->schnorr_4_to_s = d0_bignum_mov(NULL, ctx->schnorr_G); - if(src->schnorr_4_to_s_signature) ctx->schnorr_4_to_s_signature = d0_bignum_mov(NULL, src->schnorr_4_to_s_signature); - if(src->rsa_blind_signature_camouflage) ctx->rsa_blind_signature_camouflage = d0_bignum_mov(NULL, src->rsa_blind_signature_camouflage); - if(src->r) ctx->r = d0_bignum_mov(NULL, src->r); - if(src->challenge) ctx->challenge = d0_bignum_mov(NULL, src->challenge); - if(src->other_4_to_r) ctx->other_4_to_r = d0_bignum_mov(NULL, src->other_4_to_r); + if(src->rsa_n) CHECK_ASSIGN(ctx->rsa_n, d0_bignum_mov(NULL, src->rsa_n)); + if(src->rsa_e) CHECK_ASSIGN(ctx->rsa_e, d0_bignum_mov(NULL, src->rsa_e)); + if(src->rsa_d) CHECK_ASSIGN(ctx->rsa_d, d0_bignum_mov(NULL, src->rsa_d)); + if(src->schnorr_G) CHECK_ASSIGN(ctx->schnorr_G, d0_bignum_mov(NULL, src->schnorr_G)); + if(src->schnorr_s) CHECK_ASSIGN(ctx->schnorr_s, d0_bignum_mov(NULL, src->schnorr_s)); + if(src->schnorr_4_to_s) CHECK_ASSIGN(ctx->schnorr_4_to_s, d0_bignum_mov(NULL, ctx->schnorr_G)); + if(src->schnorr_4_to_s_signature) CHECK_ASSIGN(ctx->schnorr_4_to_s_signature, d0_bignum_mov(NULL, src->schnorr_4_to_s_signature)); + if(src->rsa_blind_signature_camouflage) CHECK_ASSIGN(ctx->rsa_blind_signature_camouflage, d0_bignum_mov(NULL, src->rsa_blind_signature_camouflage)); + if(src->r) CHECK_ASSIGN(ctx->r, d0_bignum_mov(NULL, src->r)); + if(src->challenge) CHECK_ASSIGN(ctx->challenge, d0_bignum_mov(NULL, src->challenge)); + if(src->other_4_to_r) CHECK_ASSIGN(ctx->other_4_to_r, d0_bignum_mov(NULL, src->other_4_to_r)); memcpy(ctx->msg, src->msg, sizeof(ctx->msg)); ctx->msglen = src->msglen; memcpy(ctx->msghash, src->msghash, sizeof(ctx->msghash)); + return 0; +fail: + d0_blind_id_clear(ctx); + return 1; } WARN_UNUSED_RESULT BOOL d0_blind_id_generate_private_key_fastreject(d0_blind_id_t *ctx, int k, d0_fastreject_function reject, void *pass) diff --git a/d0_blind_id.h b/d0_blind_id.h index 940cd54..d381898 100644 --- a/d0_blind_id.h +++ b/d0_blind_id.h @@ -9,7 +9,7 @@ typedef BOOL (*d0_fastreject_function) (const d0_blind_id_t *ctx, void *pass); EXPORT WARN_UNUSED_RESULT d0_blind_id_t *d0_blind_id_new(void); EXPORT void d0_blind_id_free(d0_blind_id_t *a); EXPORT void d0_blind_id_clear(d0_blind_id_t *ctx); -EXPORT void d0_blind_id_copy(d0_blind_id_t *ctx, const d0_blind_id_t *src); +EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_copy(d0_blind_id_t *ctx, const d0_blind_id_t *src); EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_generate_private_key(d0_blind_id_t *ctx, int k); EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_generate_private_key_fastreject(d0_blind_id_t *ctx, int k, d0_fastreject_function reject, void *pass); EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_read_private_key(d0_blind_id_t *ctx, const char *inbuf, size_t inbuflen);