+WARN_UNUSED_RESULT BOOL d0_longhash_destructive(d0_bignum_t *clobberme, char *outbuf, size_t *outbuflen)
+{
+ d0_iobuf_t *out = NULL;
+ static unsigned char convbuf[1024];
+ d0_iobuf_t *conv = NULL;
+ size_t n, sz;
+
+ n = *outbuflen;
+ while(n > SHA_DIGESTSIZE)
+ {
+ conv = d0_iobuf_open_write(convbuf, sizeof(convbuf));
+ CHECK(d0_iobuf_write_bignum(conv, temp0));
+ CHECK(d0_iobuf_close(conv, &sz));
+ conv = NULL;
+ memcpy(outbuf, sha(convbuf, sz), SHA_DIGESTSIZE);
+ outbuf += SHA_DIGESTSIZE;
+ n -= SHA_DIGESTSIZE;
+ CHECK(d0_bignum_add(temp0, temp0, one));
+ }
+ conv = d0_iobuf_open_write(convbuf, sizeof(convbuf));
+ CHECK(d0_iobuf_write_bignum(conv, temp0));
+ CHECK(d0_iobuf_close(conv, &sz));
+ conv = NULL;
+ memcpy(outbuf, sha(convbuf, sz), n);
+
+ return d0_iobuf_close(out, outbuflen);
+
+fail:
+ if(conv)
+ d0_iobuf_close(conv, &sz);
+ return 0;
+}
+