---
name: "cl_clear_secret"
section: "3"
platform: "linux"
package: "libcanlock-dev"
version: "3.3.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/cl_clear_secret"
---

# cl\_clear\_secret(3)

Overwrite secret data in memory with libcanlock

## NAME

cl\_clear\_secret - Overwrite secret data in memory with libcanlock

## SYNOPSIS

```
#include <libcanlock-3/canlock.h>

int cl_clear_secret(void *sec, size_t sec_size,
                    size_t buf_size);
```

## DESCRIPTION

The **cl\_clear\_secret**() function tries to overwrite *sec\_size* bytes of memory starting at the address specified by the *sec* parameter.

The size *buf\_size* must be set to the size of the whole buffer.

If the operating system provides **memset\_s**(), it is called with both length values. Otherwise nonportable functions like **explicit\_memset**() are used if available.\
 If neither **memset\_s**() nor a nonportable replacement is available, a call to **memset**() is used instead, but the compiler maybe optimize this attempt to NOP. A positive value is returned as warning.

## RETURN VALUE

Upon successful completion zero is returned.\
 Negative values indicate an error.\
 Positive values indicate a warning.

The value -1 is returned if the parameter *sec* is NULL or if *sec\_size* is greater than *buf\_size*.

The value 1 indicates missing support for explicit memory access from the operating system.

## AUTHORS

Michael Baeuerle

## REPORTING BUGS

Report bugs to \<mailto:michael.baeuerle@gmx.net\>.

## STANDARDS

**libcanlock** tries to comply with the following standards:

RFC 5537, RFC 6234, RFC 8315

## SEE ALSO

[**cl\_get\_key**(3)](/cl_get_key/3.md), [**cl\_get\_lock**(3)](/cl_get_lock/3.md), [**cl\_split**(3)](/cl_split/3.md), [**cl\_verify**(3)](/cl_verify/3.md), [**cl\_verify\_multi**(3)](/cl_verify_multi/3.md), [**canlock**(1)](/canlock/1.md), [**memset**(3)](/memset/3.md), [**memset\_s**(3)](/memset_s/3.md)
