---
name: "libkeccak_spec_check"
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_spec_check"
---

# libkeccak\_spec\_check(3)

Validate hashing parameters

## NAME

libkeccak\_spec\_check - Validate hashing parameters

## SYNOPSIS

```
#include <libkeccak.h>
int libkeccak_spec_check(const struct libkeccak_spec *spec);
```

Link with *-lkeccak*.

## DESCRIPTION

The **libkeccak\_spec\_check**() function validates the parameters of *\*spec*, so that unusable configurations can be detected. It is recommended to call this function after calling [**libkeccak\_spec\_sha3**(3)](/libkeccak_spec_sha3/3.md), [**libkeccak\_spec\_cshake**(3)](/libkeccak_spec_cshake/3.md), [**libkeccak\_spec\_rawshake**(3)](/libkeccak_spec_rawshake/3.md), [**libkeccak\_spec\_shake**(3)](/libkeccak_spec_shake/3.md), or, especially, after settings the parameters manually for Keccak hashing.

```
struct libkeccak_spec {
	long int bitrate;  /* bitrate (in bits) */
	long int capacity; /* capacity (in bits) */
	long int output;   /* output size (in bits) */
};
```

## RETURN VALUES

The **libkeccak\_spec\_check**() function returns 0 if the settings are usable. Otherwise it will return one of the following constants.

- **LIBKECCAK\_SPEC\_ERROR\_BITRATE\_NONPOSITIVE**

  The specified bitrate was non-positive.

- **LIBKECCAK\_SPEC\_ERROR\_BITRATE\_MOD\_8**

  The specified bitrate was not equivalent to 0 modulus 8, that is, it was not in whole bytes.

- **LIBKECCAK\_SPEC\_ERROR\_CAPACITY\_NONPOSITIVE**

  The specified capacity was non-positive.

- **LIBKECCAK\_SPEC\_ERROR\_CAPACITY\_MOD\_8**

  The specified capacity was not equivalent to 0 modulus 8, that is, it was not in whole bytes.

- **LIBKECCAK\_SPEC\_ERROR\_OUTPUT\_NONPOSITIVE**

  The specified output size was non-positive.

- **LIBKECCAK\_SPEC\_ERROR\_STATE\_TOO\_LARGE**

  The state size, that is the sum of the bitrate and the capacity, exceeded the supported limit (currently at 1600 bits.)

- **LIBKECCAK\_SPEC\_ERROR\_STATE\_MOD\_25**

  The state size, that is the sum of the bitrate and the capacity, in bits, was not equivalent to 0 modulus 25. Meaning the state size cannot cover all lanes equivalently.

- **LIBKECCAK\_SPEC\_ERROR\_WORD\_NON\_2\_POTENT**

  The word size, that is the state size divided by 25, is not a power of 2.

- **LIBKECCAK\_SPEC\_ERROR\_WORD\_MOD\_8**

  The word size, that is the state size divided by 25, is not quivalent to 0 modulus 8, that is, it is not in whole bytes.

Note that there may be more than one error. Only the first detected is returned.

## ERRORS

The **libkeccak\_spec\_check**() function cannot fail.

## SEE ALSO

[**libkeccak\_spec\_sha3**(3)](/libkeccak_spec_sha3/3.md), [**libkeccak\_spec\_cshake**(3)](/libkeccak_spec_cshake/3.md), [**libkeccak\_spec\_rawshake**(3)](/libkeccak_spec_rawshake/3.md), [**libkeccak\_spec\_shake**(3)](/libkeccak_spec_shake/3.md), [**libkeccak\_generalised\_spec\_initialise**(3)](/libkeccak_generalised_spec_initialise/3.md), [**libkeccak\_state\_initialise**(3)](/libkeccak_state_initialise/3.md), [**libkeccak\_hmac\_initialise**(3)](/libkeccak_hmac_initialise/3.md)
