---
name: "libkeccak_hmac_set_key"
section: "3"
platform: "linux"
package: "libkeccak"
version: "1.4.3-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libkeccak_hmac_set_key"
---

# libkeccak\_hmac\_set\_key(3)

Changes key for a the HMAC-hashing state

## NAME

libkeccak\_hmac\_set\_key - Changes key for a the HMAC-hashing state

## SYNOPSIS

```
#include <libkeccak.h>
int libkeccak_hmac_set_key(struct libkeccak_hmac_state *state, const void *key, size_t key_length);
```

Link with *-lkeccak*.

## DESCRIPTION

The **libkeccak\_hmac\_set\_key**() function sets the key for a HMAC-hashing state without reseting the state of the underlaying hashing-algorithm. *key\_length* is the length of the key in bits.

## RETURN VALUES

The **libkeccak\_hmac\_set\_key**() function returns 0 successful completion. On error -1 is returned and *errno* is set to describe the error.

## ERRORS

The **libkeccak\_hmac\_set\_key**() function may fail for any specified for the function [**realloc**(3)](/realloc/3.md).

## SEE ALSO

[**libkeccak\_hmac\_create**(3)](/libkeccak_hmac_create/3.md), [**libkeccak\_hmac\_initialise**(3)](/libkeccak_hmac_initialise/3.md), [**libkeccak\_hmac\_reset**(3)](/libkeccak_hmac_reset/3.md)
