}
static ossl_inline void ring_buf_cpop_range(struct ring_buf *r,
- uint64_t start, uint64_t end)
+ uint64_t start, uint64_t end,
+ int cleanse)
{
assert(end >= start);
if (start > r->ctail_offset)
return;
+ if (cleanse && r->alloc > 0 && end > r->ctail_offset) {
+ size_t idx = r->ctail_offset % r->alloc;
+ uint64_t cleanse_end = end + 1;
+ size_t l;
+
+ if (cleanse_end > r->head_offset)
+ cleanse_end = r->head_offset;
+ l = (size_t)(cleanse_end - r->ctail_offset);
+ if (l > r->alloc - idx) {
+ OPENSSL_cleanse((unsigned char *)r->start + idx, r->alloc - idx);
+ l -= r->alloc - idx;
+ idx = 0;
+ }
+ if (l > 0)
+ OPENSSL_cleanse((unsigned char *)r->start + idx, l);
+ }
+
r->ctail_offset = end + 1;
/* Allow culling unpushed data */
if (r->head_offset < r->ctail_offset)