From: Rudolf Polzer Date: Mon, 5 Jul 2010 09:25:58 +0000 (+0200) Subject: add d0_blind_id_fingerprint64_public_key X-Git-Tag: xonotic-v0.1.0preview~38^2~19 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3d6c20c20f33d4d421fce506a5904948612fbe1a;p=xonotic%2Fd0_blind_id.git add d0_blind_id_fingerprint64_public_key --- diff --git a/d0_blind_id.c b/d0_blind_id.c index 108f082..d2fc631 100644 --- a/d0_blind_id.c +++ b/d0_blind_id.c @@ -314,6 +314,38 @@ fail: return 0; } +WARN_UNUSED_RESULT BOOL d0_blind_id_fingerprint64_public_key(d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen) +{ + d0_iobuf_t *out = NULL; + static unsigned char convbuf[2048]; + d0_iobuf_t *conv = NULL; + size_t sz, n; + + USING(schnorr_4_to_s); + + out = d0_iobuf_open_write(outbuf, *outbuflen); + conv = d0_iobuf_open_write(convbuf, sizeof(convbuf)); + + CHECK(d0_iobuf_write_bignum(conv, ctx->rsa_n)); + CHECK(d0_iobuf_write_bignum(conv, ctx->rsa_e)); + CHECK(d0_iobuf_close(conv, &sz)); + conv = NULL; + + n = (*outbuflen / 4) * 3; + if(n > SHA_DIGESTSIZE) + n = SHA_DIGESTSIZE; + CHECK(d0_iobuf_write_raw(out, sha(convbuf, sz), n) == n); + CHECK(d0_iobuf_conv_base64_out(out)); + + return d0_iobuf_close(out, outbuflen); + +fail: + if(conv) + d0_iobuf_close(conv, &sz); + d0_iobuf_close(out, outbuflen); + return 0; +} + WARN_UNUSED_RESULT BOOL d0_blind_id_generate_private_id_modulus(d0_blind_id_t *ctx) { USING(rsa_n); diff --git a/d0_blind_id.h b/d0_blind_id.h index 177682b..5260aca 100644 --- a/d0_blind_id.h +++ b/d0_blind_id.h @@ -14,6 +14,7 @@ EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_read_private_key(d0_blind_id_t *ctx, EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_read_public_key(d0_blind_id_t *ctx, const char *inbuf, size_t inbuflen); EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_write_private_key(d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen); EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_write_public_key(d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen); +EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_fingerprint64_public_key(d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen); EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_generate_private_id_modulus(d0_blind_id_t *ctx); EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_read_private_id_modulus(d0_blind_id_t *ctx, const char *inbuf, size_t inbuflen); EXPORT WARN_UNUSED_RESULT BOOL d0_blind_id_write_private_id_modulus(d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen);