+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];
+ size_t n, sz;
+
+ n = outbuflen;
+ while(n > SHA_DIGESTSIZE)
+ {
+ sz = (d0_bignum_size(clobberme) + 7) / 8;
+ CHECK(d0_bignum_export_unsigned(clobberme, convbuf, sizeof(convbuf)) >= 0);
+ memcpy(outbuf, sha(convbuf, sz), SHA_DIGESTSIZE);
+ outbuf += SHA_DIGESTSIZE;
+ n -= SHA_DIGESTSIZE;
+ CHECK(d0_bignum_add(clobberme, clobberme, one));
+ }
+ sz = (d0_bignum_size(clobberme) + 7) / 8;
+ CHECK(d0_bignum_export_unsigned(clobberme, convbuf, sizeof(convbuf)) >= 0);
+ memcpy(outbuf, sha(convbuf, sz), n);
+ return 1;
+
+fail:
+ return 0;
+}
+