]> git.rm.cloudns.org Git - xonotic/d0_blind_id.git/commitdiff
add d0_blind_id_fingerprint64_public_key
authorRudolf Polzer <divverent@alientrap.org>
Mon, 5 Jul 2010 09:25:58 +0000 (11:25 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Mon, 5 Jul 2010 09:25:58 +0000 (11:25 +0200)
d0_blind_id.c
d0_blind_id.h

index 108f082495381f74f3cc4f275830d2c56d5252be..d2fc63112071d32ea4c0ac9f3deb1366f84da9b8 100644 (file)
@@ -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);
index 177682b0f1466615c5ccd7fa9086219e03b4405b..5260acac68378e5d82a4435d9127b551fbe5169c 100644 (file)
@@ -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);