crypt(), crypt_r(), encrypt(), encrypt_r(), setkey(), setkey_r()

cryptography functions 

Function


SYNOPSIS

#include <crypt.h>

char *crypt(const char *key, const char *salt);

void encrypt(char *block, int edflag);

void setkey(const char *key);

char *crypt_r(const char *key, const char *salt);

void encrypt_r(char *block, int edflag);

void setkey_r(const char *key);


DESCRIPTION

The crypt() function encrypts the string pointed to by key using first two characters of the string pointed to by salt to perturb the encryption algorithm.

The encrypt() function encrypts or decrypts (depending on the value of the edflag argument) the string pointed to by block using the encryption key set by the setkey() function.

The setkey() function sets the encryption key for encrypt() as the string specified by key.

The crypt_r(), encrypt_r(), and setkey_r() are the reentrant versions of crypt(), encrypt(), and setkey() respectively.


PARAMETERS

block 

Points to a string to be encrypted (or decrypted) by encrypt(). This string is a 64 byte array of zeroes and ones,

Note:

This string is encrypted (or decrypted) in place. Thus, when encrypt() is finished, block points to the encrypted (or decrypted) string.

edflag 

determines whether the encrypt() function is to perform encryption or decryption. When edflag is 1, decryption is performed. When edflag is 0, encryption is performed.

key 

For crypt(), points to the string to be encoded.

For setkey(), it points to a 64 byte array of zeroes and ones. When the string is divided into groups of eights (creating the equivalent of a 8-bit byte), the low order bit in each group is ignored, leaving a 56-bit key to be used by encrypt().

salt 

Points to a string used by crypt() to perturb its encryption algorithm. This string may only contain uppercase and lowercase letters, digits, periods (.), and slashes (/). Only the first two characters of this string are used.


RETURN VALUES

The encrypt() and setkey() functions never return a value.

If successful, crypt() returns the encrypted string (the first characters of which are the first two characters of the salt argument). On failure, it returns a null pointer.

When crypt(), encrypt(), or setkey() fails, errno is set as follows:

ENOSYS 

The functionality is not currently supported.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

Unsafe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
_NutValidatePassword()


PTC MKS Toolkit 10.4 Documentation Build 39.