Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / bytestr.h / byte_zzero.3.md

% limb manual
% byte_zzero(3)
% limb 0.1.0
% 2023-07-24

# NAME

byte_zzero - fill a byte array with zeroes

# SYNOPSIS

    #include <limb/bytestr.h>

```pre hl
void byte_zzero(const char *<em>arr</em>, size_t <em>len</em>)
```

# DESCRIPTION

The `byte_zzero`() function writes zeroes in the `len` bytes of memory pointed
by `arr`.

It guarantees that compiler optimizations will not remove the erase operation if
the compiler deduces that the operation is "unnecessary" (e.g. memory is not
used afterwards), which may be of importance when erasing sensitive information,
such as keys in a cryptographic context.

! NOTE:
! In order to ensure memory is erased :
! - if available, [explicit_bzero](3) is called,
! - otherwise, Otherwise, [memset](3) is used to clear the memory, then a
!   special no-op function with a weak alias is called, in order to trick the
!   compiler.