mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-09-11 14:54:54 +00:00
163 lines
4.3 KiB
Groff
163 lines
4.3 KiB
Groff
.\" Copyright (c) 1989, 1991, 1993
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
.\" must display the following acknowledgement:
|
|
.\" This product includes software developed by the University of
|
|
.\" California, Berkeley and its contributors.
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
.\" may be used to endorse or promote products derived from this software
|
|
.\" without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
.\" SUCH DAMAGE.
|
|
.\"
|
|
.\" @(#)crypt.3 8.2 (Berkeley) 12/11/93
|
|
.\"
|
|
.TH CRYPT 3 "28 January 1997" GNO "Library Routines"
|
|
.SH NAME
|
|
.BR crypt ,
|
|
.BR setkey ,
|
|
.BR encrypt ,
|
|
\- simple encryption
|
|
.SH SYNOPSIS
|
|
#include <unistd.h>
|
|
.sp 1
|
|
char
|
|
*\fBcrypt\fR (const char *\fIkey\fR, const char *\fIsalt\fR);
|
|
.br
|
|
int
|
|
\fBsetkey\fR (char *\fIkey\fR);
|
|
.br
|
|
int
|
|
\fBencrypt\fR (char *\fIblock\fR, int \fIflag\fR);
|
|
.SH DESCRIPTION
|
|
The
|
|
.BR crypt
|
|
function
|
|
performs password encryption.
|
|
It is derived from an algorithm given in
|
|
.I "Computer Networks"
|
|
by Andy Tanenbaum.
|
|
.LP
|
|
The first argument to
|
|
.BR crypt
|
|
.RI ( key )
|
|
is a
|
|
.BR NULL -terminated
|
|
string (normally a password typed by a user).
|
|
The second,
|
|
.IR salt ,
|
|
is a two-character array that should be randomly generated by the caller
|
|
in the case of encrypting a new password, or should be taken as the
|
|
first two characters of the
|
|
.BR /etc/passwd
|
|
password entry in the case of validating a password.
|
|
.LP
|
|
The
|
|
functions,
|
|
.BR encrypt
|
|
and
|
|
.BR setkey
|
|
allow limited access to the encryption
|
|
algorithm itself.
|
|
The
|
|
.IR key
|
|
argument to
|
|
.BR setkey
|
|
is a 64 character array of
|
|
binary values (numeric 0 or 1).
|
|
A 56-bit key is derived from this array by dividing the array
|
|
into groups of 8 and ignoring the last bit in each group.
|
|
.LP
|
|
The
|
|
.BR encrypt
|
|
argument
|
|
.I block
|
|
is also a 64 character array of
|
|
binary values.
|
|
If the value of
|
|
.I flag
|
|
is 0,
|
|
the argument
|
|
.I block
|
|
is encrypted, otherwise it
|
|
is decrypted.
|
|
The encryption or decryption is returned in the original
|
|
array
|
|
.I block
|
|
after using the
|
|
key specified
|
|
by
|
|
.BR setkey
|
|
to process it.
|
|
.LP
|
|
The function
|
|
.BR crypt
|
|
returns a pointer to the encrypted value (which is formatted as
|
|
printable ASCII characters) on success and NULL on failure.
|
|
The functions
|
|
.BR setkey
|
|
and
|
|
.BR encrypt
|
|
return 0 on success and 1 on failure.
|
|
.LP
|
|
Use of these routines requires linking with the
|
|
.BR libcrypt
|
|
library.
|
|
.SH SEE ALSO
|
|
.BR login (1),
|
|
.BR passwd (1),
|
|
.BR getpass (3),
|
|
.BR passwd (5)
|
|
.sp
|
|
.RS
|
|
.I "Mathematical Cryptology for Computer Scientists and Mathematicians"
|
|
by
|
|
Wayne Patterson.
|
|
1987.
|
|
Volume ISBN 0-8476-7438-X.
|
|
.RE
|
|
.sp 1
|
|
.RS
|
|
.I "Password Security: A Case History"
|
|
by
|
|
R. Morris,
|
|
Ken Thompson.
|
|
.IR "Communications of the ACM" ,
|
|
vol. 22, pp. 594-597. November 1979.
|
|
.RE
|
|
.sp 1
|
|
.RS
|
|
.I "DES will be Totally Insecure within Ten Years"
|
|
by
|
|
M.E. Hellman.
|
|
.IR "IEEE Spectrum" ,
|
|
vol. 16, pp. 32-39. July 1979.
|
|
.RE
|
|
.SH BUGS
|
|
The
|
|
.BR crypt
|
|
function leaves its result in an internal static object and returns
|
|
a pointer to that object.
|
|
Subsequent calls to
|
|
.BR crypt
|
|
will modify the same object.
|