Skip to content

eBPF-based security platform

proofs: model sha256_buffer() in chain-events as crypto.h promises

Daniel Borkmann944880a00abc
diff --git a/testing/proofs/cbmc/chain-events.c b/testing/proofs/cbmc/chain-events.c
index 465faa2f..477a0e66 100644
--- a/testing/proofs/cbmc/chain-events.c
+++ b/testing/proofs/cbmc/chain-events.c
@@ -90,11 +90,17 @@ void sha256_free(struct sha256_ctx *ctx)
{
}
+/* As util/crypto.h promises: where it fails, out is all zeros. */
int sha256_buffer(const void *data, size_t len, __u8 out[32])
{
+ int ret;
+
begin();
record(data, len);
- return give_digest(out);
+ ret = give_digest(out);
+ if (ret)
+ memset(out, 0, 32);
+ return ret;
}
static void start(void)