From 3d6c20c20f33d4d421fce506a5904948612fbe1a Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Mon, 5 Jul 2010 11:25:58 +0200 Subject: [PATCH] add d0_blind_id_fingerprint64_public_key --- d0_blind_id.c | 32 ++++++++++++++++++++++++++++++++ d0_blind_id.h | 1 + 2 files changed, 33 insertions(+) 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); -- 2.39.2