[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


crypt, encrypt, or setkey Subroutine

Purpose

Encrypts or decrypts data.

Library

Standard C Library (libc.a)

Syntax


char *crypt (PW, Salt)
const char * PW, * Salt;


void encrypt (Block, EdFlag)
char Block[64];
int EdFlag;


void setkey (Key)
const char * Key;

Description

The crypt and encrypt subroutines encrypt or decrypt data. The crypt subroutine performs a one-way encryption of a fixed data array with the supplied PW parameter. The subroutine uses the Salt parameter to vary the encryption algorithm.

The encrypt subroutine encrypts or decrypts the data supplied in the Block parameter using the key supplied by an earlier call to the setkey subroutine. The data in the Block parameter on input must be an array of 64 characters. Each character must be an char 0 or char 1.

If you need to statically bind functions from libc.a for crypt do the following:

  1. Create a file and add the following:

    #!
    ___setkey
    ___encrypt
    ___crypt
    
  2. Perform the linking.
  3. Add the following to the make file:

    -bI:YourFileName
    

    where YourFileName is the name of the file you created in step 1. It should look like the following:

    LDFLAGS=bnoautoimp -bI:/lib/syscalls.exp -bI:YourFileName -lc
    

Parameters


Block Identifies a 64-character array containing the values (char) 0 and (char) 1. Upon return, this buffer contains the encrypted or decrypted data.
EdFlag Determines whether the subroutine encrypts or decrypts the data. If this parameter is 0, the data is encrypted. If this is a nonzero value, the data is decrypted. If the /usr/lib/libdes.a file does not exist and the EdFlag parameter is set to nonzero, the encrypt subroutine returns the ENOSYS error code.
Key Specifies an 64-element array of 0's and 1's cast as a const char data type. The Key parameter is used to encrypt or decrypt data.
PW Specifies an 8-character string used to change the encryption algorithm. The first two characters of the PW parameter are the same as the Salt parameter.
Salt Specifies a 2-character string chosen from the following:

A-Z
Uppercase alpha characters

0-9
Numeric characters

.
Period

/
Slash
  The Salt parameter is used to vary the hashing algorithm in one of 4096 different ways.

Return Values

The crypt subroutine returns a pointer to the encrypted password. The static area this pointer indicates may be overwritten by subsequent calls.

Error Codes

The encrypt subroutine returns the following:

ENOSYS The encrypt subroutine was called with the EdFlag parameter which was set to a nonzero value. Also, the /usr/lib/libdes.a file does not exist.

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

These subroutines are provided for compatibility with UNIX system implementations.

Related Information

The newpass (newpass Subroutine) subroutine.

The login command, passwd command, su command.

List of Security and Auditing Subroutines and Subroutines Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]