---
name: "lc_ctx_getkey"
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_getkey"
---

# lc\_ctx\_getkey(3)

set Librecast channel encoding options

## NAME

lc\_ctx\_getkey, lc\_ctx\_setkey, lc\_channel\_getkey, lc\_channel\_setkey - set Librecast channel encoding options

## LIBRARY

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

## SYNOPSIS

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

**int lc\_ctx\_getkey(lc\_ctx\_t** *\*ctx***, lc\_key\_t** *\*key***, int** *type***);** **int lc\_ctx\_setkey(lc\_ctx\_t** *\*ctx***, lc\_key\_t** *\*key***, int** *type***);** **int lc\_channel\_getkey(lc\_channel\_t** *\*chan***, lc\_key\_t** *\*key***, int** *type***);** **int lc\_channel\_setkey(lc\_channel\_t** *\*chan***, lc\_key\_t** *\*key***, int** *type***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

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

*is*a*pointer*to*an*lc\_key\_t*structure.* The set functions will use this to set the key on the context or channel, and the set functions will return a copy of the current key in this structure.

The *type* argument must be one of the following options:

- **LC\_CODE\_SYMM**

  Symmetric key.

- **LC\_CODE\_PUBK**

  Public key.

## 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\_channel\_set\_sym\_key**(3)](/lc_channel_set_sym_key/3.md), [**lc\_ctx\_new**(3)](/lc_ctx_new/3.md), **lc\_socket\_setopt**(3), **lc\_socket\_recv**(3)
