1
0
Files
irix-657m-src/eoe/man/man3x/crypt.3x
2022-09-29 17:59:04 +03:00

147 lines
4.5 KiB
Plaintext

'\"macro stdmacro
.if n .pH g3x.crypt @(#)crypt 30.5 of 1/21/86
.nr X
.if \nX=0 .ds x} CRYPT 3X "C Programming Language Utilities" "\&"
.if \nX=1 .ds x} CRYPT 3X "C Programming Language Utilities"
.if \nX=2 .ds x} CRYPT 3X "" "\&"
.if \nX=3 .ds x} CRYPT "" "" "\&"
.TH \*(x}
.SH NAME
crypt \- password and file encryption functions
.SH SYNOPSIS
.B cc [flag \.\.\.] file \.\.\. \-lcrypt [library \.\.\.]
.PP
.B "char \(**crypt(char \(**key, char \(**salt);
.PP
.B "void setkey(char \(**key);
.PP
.B "void encrypt(char \(**block, int flag);
.PP
.B "char \(**des_crypt(char \(**key, char \(**salt);
.PP
.B "void des_setkey(char \(**key);
.PP
.B "void des_encrypt(char \(**block, int flag);
.PP
.B "int run_setkey(int p[2], char \(**key);
.PP
.B "int run_crypt(long offset, char \(**buffer, unsigned int count, int p[2]);
.PP
.B "int crypt_close(int p[2]);
.SH DESCRIPTION
.I des_crypt\^
is the password encryption function.
It is based on a one way hashing encryption algorithm
with
variations intended (among other things) to frustrate use of hardware
implementations of a
key search.
.PP
.I Key\^
is a user's typed password.
.I Salt\^
is a two-character string chosen from the
set [\f3a-zA-Z0-9.\/\fP];
this
string is used to perturb the
hashing
algorithm in one of 4096
different ways, after which the password
is used as the key to encrypt repeatedly a constant string.
The returned value points to the encrypted password.
The first two characters are the salt itself.
.PP
The
.I des_setkey\^
and
.I des_encrypt\^
entries provide (rather primitive)
access to the actual
hashing
algorithm.
The argument of
.I des_setkey\^
is a character array of length 64 containing only the characters
with numerical value 0 and 1.
If this string is divided into groups of 8,
the low-order bit in each group is ignored;
this gives a 56-bit key which is set into the machine.
This is the key that will be used
with the hashing algorithm to encrypt
the string
.I block\^
with the function
.IR des_encrypt .
.PP
The argument to the
.I des_encrypt\^
entry is a character array of length 64
containing only the characters with
numerical value 0 and 1.
The argument array is modified in place
to a similar array
representing the bits of the argument after having been
subjected to the
hashing
algorithm using the key set by
.IR des_setkey .
If
.IR edflag
is zero, the argument is encrypted; if non-zero, it is decrypted.
.PP
Note that decryption is not provided in the international version
of \f2crypt\fP.
The international version is part of the
C Development Set, and the domestic version is part of
the Encryption Utilities.
If decryption is attempted with
the international version of \f2des_encrypt\f1, an error message is printed.
.PP
\f2Crypt\fP, \f2setkey\fP, and \f2encrypt\fP are front-end
routines that invoke \f2des_crypt\fP,
\f2des_setkey\fP, and \f2des_encrypt\fP respectively.
.PP
The routines \f2run_setkey\fP and \f2run_crypt\fP are designed for use
by applications that need cryptographic capabilities [such as \f2ed\f1(1) and
\f2vi\f1(1)]
that must be compatible with the \f2crypt\f1(1) user-level utility.
\f2Run_setkey\fP establishes a two-way pipe connection with \f2crypt\f1(1),
using \f2key\fP as the password argument. \f2Run_crypt\fP takes a block of
characters and transforms the cleartext or ciphertext into their ciphertext or
cleartext using \f2crypt\f1(1).
\f2Offset\fP is the relative byte position from the beginning
of the file that the block of text provided in \f2block\fP is coming from.
\f2Count\fP is the number of characters in \f2block\fP, and \f2connection\fP
is an array
containing indices to a table of input and output file streams.
When encryption is finished,
\f2crypt_close\f1 is
used to terminate the connection with \f2crypt\f1(1).
.PP
If a null key is
passed to \f2run_setkey\f1,
0 is returned. Otherwise, 1 is returned. \f2Run_crypt\f1 returns
-1 if it cannot write output or read input from the pipe attached to \f2crypt\f1.
Otherwise it returns 0.
.PP
The routines above are found in the library ``libcrypt.a'',
and are loaded if the option ``\-lcrypt'' is used with
.IR cc (1)
or
.IR ld (1).
.SH SEE ALSO
crypt(1), login(1), passwd(1),
getpass(3C), passwd(4).
.SH NOTES
In the international version of \f2crypt\fP(3X),
a flag argument of 1 to \f2encrypt\f1 or \f2des_encrypt\f1
is not accepted, and \f2errno\fP is set to \f2ENOSYS\fP to
indicate that the functionality is not available.
.PP
The return value in \f2crypt\f1
points to static data that are overwritten
by each call.
'\".so /pubs/tools/origin.att
.\" @(#)crypt.3x 6.2 of 10/20/83
.Ee