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

# lc\_ctx\_set\_sym\_key(3)

set Librecast channel encoding keys

## NAME

lc\_ctx\_set\_sym\_key, lc\_ctx\_set\_pub\_key, lc\_channel\_set\_sym\_key, lc\_channel\_set\_pub\_key - set Librecast channel encoding keys

## LIBRARY

Librecast library (*liblibrecast*, *-llibrecast*)

## SYNOPSIS

```
#include <librecast/net.h>
```

**int lc\_ctx\_set\_sym\_key(lc\_ctx\_t** *\*ctx***, unsigned char** *\*key***, size\_t** *len***);** **int lc\_ctx\_set\_pub\_key(lc\_ctx\_t** *\*ctx***, unsigned char** *\*key***, size\_t** *len***);** **int lc\_channel\_set\_sym\_key(lc\_channel\_t** *\*chan***, unsigned char** *\*key***, size\_t** *len***);** **int lc\_channel\_set\_pub\_key(lc\_channel\_t** *\*chan***, unsigned char** *\*key***, size\_t** *len"***);"**

Compile and link with *-llibrecast*.

## DESCRIPTION

These functions set encryption keys for a Librecast context *ctx* or channel *chan*.

The **lc\_ctx\_set\_sym\_key**() function sets a symmetric *key* of length *len* on a Librecast context. This key will be used by default by any channels subsequently created using the context. Any existing channels will retain their existing key.

The **lc\_ctx\_set\_pub\_key**() function sets a public *key* of length *len* on a Librecast context. This key will be used by default by any channels subsequently created using the context. Any existing channels will retain their existing key.

The **lc\_channel\_set\_sym\_key**() function sets a symmetric *key* of length *len* on a Librecast channel.

The **lc\_channel\_set\_pub\_key**() function sets a public *key* of length *len* on a Librecast channel.

## RETURN VALUE

These functions return zero on success. On error, -1 is returned and **errno** is set to indicate the error.

## ERRORS

- **EINVAL**

  Invalid argument.

## SEE ALSO

[**lc\_ctx\_coding\_set**(3)](/lc_ctx_coding_set/3.md), **lc\_channel\_new**(3), **lc\_channel\_close**(3), [**lc\_channel\_coding\_set**(3)](/lc_channel_coding_set/3.md), [**lc\_channel\_send**(3)](/lc_channel_send/3.md), [**lc\_ctx\_new**(3)](/lc_ctx_new/3.md), **lc\_socket\_setopt**(3), **lc\_socket\_recv**(3)
