---
name: "krb5_keyblock_zero"
section: "3"
platform: "linux"
package: "heimdal-dev"
version: "1.2.dfsg.1-2.1+lenny1"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/krb5_keyblock_zero"
---

# krb5\_keyblock\_zero(3)

Kerberos 5 key handling functions

## NAME

**krb5\_keyblock**, **krb5\_keyblock\_get\_enctype**, **krb5\_copy\_keyblock**, **krb5\_copy\_keyblock\_contents**, **krb5\_free\_keyblock**, **krb5\_free\_keyblock\_contents**, **krb5\_generate\_random\_keyblock**, **krb5\_generate\_subkey**, **krb5\_generate\_subkey\_extended**, **krb5\_keyblock\_init**, **krb5\_keyblock\_zero**, **krb5\_random\_to\_key** – Kerberos 5 key handling functions

## LIBRARY

Kerberos 5 Library (libkrb5, -lkrb5)

## SYNOPSIS

**#include \<krb5.h\>**

krb5\_keyblock;

*krb5\_enctype*\

**krb5\_keyblock\_get\_enctype**(*const krb5\_keyblock \*block*);

*krb5\_error\_code*\

**krb5\_copy\_keyblock**(*krb5\_context context*, *krb5\_keyblock \*\*to*);

*krb5\_error\_code*\

**krb5\_copy\_keyblock\_contents**(*krb5\_context context*, *const krb5\_keyblock \*inblock*, *krb5\_keyblock \*to*);

*void*\

**krb5\_free\_keyblock**(*krb5\_context context*, *krb5\_keyblock \*keyblock*);

*void*\

**krb5\_free\_keyblock\_contents**(*krb5\_context context*, *krb5\_keyblock \*keyblock*);

*krb5\_error\_code*\

**krb5\_generate\_random\_keyblock**(*krb5\_context context*, *krb5\_enctype type*, *krb5\_keyblock \*key*);

*krb5\_error\_code*\

**krb5\_generate\_subkey**(*krb5\_context context*, *const krb5\_keyblock \*key*, *krb5\_keyblock \*\*subkey*);

*krb5\_error\_code*\

**krb5\_generate\_subkey\_extended**(*krb5\_context context*, *const krb5\_keyblock \*key*, *krb5\_enctype enctype*, *krb5\_keyblock \*\*subkey*);

*krb5\_error\_code*\

**krb5\_keyblock\_init**(*krb5\_context context*, *krb5\_enctype type*, *const void \*data*, *size\_t size*, *krb5\_keyblock \*key*);

*void*\

**krb5\_keyblock\_zero**(*krb5\_keyblock \*keyblock*);

*krb5\_error\_code*\

**krb5\_random\_to\_key**(*krb5\_context context*, *krb5\_enctype type*, *const void \*data*, *size\_t size*, *krb5\_keyblock \*key*);

## DESCRIPTION

krb5\_keyblock holds the encryption key for a specific encryption type. There is no component inside krb5\_keyblock that is directly referable.

**krb5\_keyblock\_get\_enctype**() returns the encryption type of the keyblock.

**krb5\_copy\_keyblock**() makes a copy the keyblock *inblock* to the output *out*. *out* should be freed by the caller with *krb5\_free\_keyblock*.

**krb5\_copy\_keyblock\_contents**() copies the contents of *inblock* to the *to* keyblock. The destination keyblock is overritten.

**krb5\_free\_keyblock**() zeros out and frees the content and the keyblock itself.

**krb5\_free\_keyblock\_contents**() zeros out and frees the content of the keyblock.

**krb5\_generate\_random\_keyblock**() creates a new content of the keyblock *key* of type encrytion type *type*. The content of *key* is overwritten and not freed, so the caller should be sure it is freed before calling the function.

**krb5\_generate\_subkey**() generates a *subkey* of the same type as *key*. The caller must free the subkey with *krb5\_free\_keyblock*.

**krb5\_generate\_subkey\_extended**() generates a *subkey* of the specified encryption type *type*. If *type* is ETYPE\_NULL, of the same type as *key*. The caller must free the subkey with *krb5\_free\_keyblock*.

**krb5\_keyblock\_init**() Fill in *key* with key data of type *enctype* from  *data* of length *size*. Key should be freed using **krb5\_free\_keyblock\_contents**().

**krb5\_keyblock\_zero**() zeros out the keyblock to to make sure no keymaterial is in memory. Note that **krb5\_free\_keyblock\_contents**() also zeros out the memory.

**krb5\_random\_to\_key**() converts the random bytestring to a protocol key according to Kerberos crypto frame work. It the resulting key will be of type *enctype*. It may be assumed that all the bits of the input string are equally random, even though the entropy present in the random source may be limited

## SEE ALSO

[krb5\_crypto\_init(3)](/krb5_crypto_init/3.md), [krb5(3)](/krb5/3.md), [krb5.conf(5)](/krb5.conf/5.md)
