---
name: "krb5_string_to_key_data"
section: "3"
platform: "linux"
package: "heimdal-dev"
version: "7.8.git20221117.28daf24+dfsg-9+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/krb5_string_to_key_data"
---

# krb5\_string\_to\_key\_data(3)

turns a string to a Kerberos key

## NAME

**krb5\_string\_to\_key**, **krb5\_string\_to\_key\_data**, **krb5\_string\_to\_key\_data\_salt**, **krb5\_string\_to\_key\_data\_salt\_opaque**, **krb5\_string\_to\_key\_salt**, **krb5\_string\_to\_key\_salt\_opaque**, **krb5\_get\_pw\_salt**, **krb5\_free\_salt** – turns a string to a Kerberos key

## LIBRARY

Kerberos 5 Library (libkrb5, -lkrb5)

## SYNOPSIS

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

*krb5\_error\_code*\

**krb5\_string\_to\_key**(*krb5\_context context*, *krb5\_enctype enctype*, *const char \*password*, *krb5\_principal principal*, *krb5\_keyblock \*key*);

*krb5\_error\_code*\

**krb5\_string\_to\_key\_data**(*krb5\_context context*, *krb5\_enctype enctype*, *krb5\_data password*, *krb5\_principal principal*, *krb5\_keyblock \*key*);

*krb5\_error\_code*\

**krb5\_string\_to\_key\_data\_salt**(*krb5\_context context*, *krb5\_enctype enctype*, *krb5\_data password*, *krb5\_salt salt*, *krb5\_keyblock \*key*);

*krb5\_error\_code*\

**krb5\_string\_to\_key\_data\_salt\_opaque**(*krb5\_context context*, *krb5\_enctype enctype*, *krb5\_data password*, *krb5\_salt salt*, *krb5\_data opaque*, *krb5\_keyblock \*key*);

*krb5\_error\_code*\

**krb5\_string\_to\_key\_salt**(*krb5\_context context*, *krb5\_enctype enctype*, *const char \*password*, *krb5\_salt salt*, *krb5\_keyblock \*key*);

*krb5\_error\_code*\

**krb5\_string\_to\_key\_salt\_opaque**(*krb5\_context context*, *krb5\_enctype enctype*, *const char \*password*, *krb5\_salt salt*, *krb5\_data opaque*, *krb5\_keyblock \*key*);

*krb5\_error\_code*\

**krb5\_get\_pw\_salt**(*krb5\_context context*, *krb5\_const\_principal principal*, *krb5\_salt \*salt*);

*krb5\_error\_code*\

**krb5\_free\_salt**(*krb5\_context context*, *krb5\_salt salt*);

## DESCRIPTION

The string to key functions convert a string to a kerberos key.

**krb5\_string\_to\_key\_data\_salt\_opaque**() is the function that does all the work, the rest of the functions are just wrappers around **krb5\_string\_to\_key\_data\_salt\_opaque**() that calls it with default values.

**krb5\_string\_to\_key\_data\_salt\_opaque**() transforms the *password* with the given salt-string *salt* and the opaque, encryption type specific parameter *opaque* to a encryption key *key* according to the string to key function associated with *enctype*.

The *key* should be freed with **krb5\_free\_keyblock\_contents**().

If one of the functions that doesn't take a krb5\_salt as it argument **krb5\_get\_pw\_salt**() is used to get the salt value.

**krb5\_get\_pw\_salt**() get the default password salt for a principal, use **krb5\_free\_salt**() to free the salt when done.

**krb5\_free\_salt**() frees the content of *salt*.

## SEE ALSO

[krb5(3)](/krb5/3.md), [krb5\_data(3)](/krb5_data/3.md), [krb5\_keyblock(3)](/krb5_keyblock/3.md), [kerberos(8)](/kerberos/8.md)
