Browse Source

Repairs.

OPENBSD_2_7
aaron 24 years ago
parent
commit
36ceaa2f58
3 changed files with 69 additions and 51 deletions
  1. +5
    -5
      src/lib/libc/crypt/arc4random.3
  2. +3
    -2
      src/lib/libc/crypt/blowfish.3
  3. +61
    -44
      src/lib/libc/crypt/crypt.3

+ 5
- 5
src/lib/libc/crypt/arc4random.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: arc4random.3,v 1.13 2000/04/15 02:15:22 aaron Exp $
.\" $OpenBSD: arc4random.3,v 1.14 2000/04/18 02:31:34 aaron Exp $
.\" .\"
.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> .\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
.\" All rights reserved. .\" All rights reserved.
@ -50,8 +50,8 @@
The The
.Fn arc4random .Fn arc4random
function uses the key stream generator employed by the function uses the key stream generator employed by the
arc4 cipher, which uses 8*8 8 bit S-Boxes. The S-Boxes
can be in about (2**1700) states.
arc4 cipher, which uses 8*8 8 bit S-Boxes.
The S-Boxes can be in about (2**1700) states.
.Pp .Pp
The The
.Fn arc4random_stir .Fn arc4random_stir
@ -74,8 +74,8 @@ automatically initializes itself.
.Sh HISTORY .Sh HISTORY
An algorithm call An algorithm call
.Pa RC4 .Pa RC4
was designed by RSA Data Security, Inc. It was considered a trade secret,
but not trademarked.
was designed by RSA Data Security, Inc.
It was considered a trade secret, but not trademarked.
A clone of this was posted anonymously to the USENET and was confirmed to A clone of this was posted anonymously to the USENET and was confirmed to
be equivalent by several sources who had access to the original cipher. be equivalent by several sources who had access to the original cipher.
Because of the trade secret situation, RSA Data Security, Inc. can do Because of the trade secret situation, RSA Data Security, Inc. can do


+ 3
- 2
src/lib/libc/crypt/blowfish.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: blowfish.3,v 1.8 2000/04/15 02:15:22 aaron Exp $
.\" $OpenBSD: blowfish.3,v 1.9 2000/04/18 02:31:34 aaron Exp $
.\" .\"
.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> .\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
.\" All rights reserved. .\" All rights reserved.
@ -63,7 +63,8 @@ The block size is 64 bit and the key size is maximal 448 bit.
The The
.Fn blf_key .Fn blf_key
function initializes the 4 8bit S-boxes and the 18 Subkeys with function initializes the 4 8bit S-boxes and the 18 Subkeys with
the hexadecimal digits of Pi. The key is used for further randomization.
the hexadecimal digits of Pi.
The key is used for further randomization.
The first argument to The first argument to
.Fn blf_enc .Fn blf_enc
is the initialized state derived from is the initialized state derived from


+ 61
- 44
src/lib/libc/crypt/crypt.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: crypt.3,v 1.15 2000/04/15 02:15:22 aaron Exp $
.\" $OpenBSD: crypt.3,v 1.16 2000/04/18 02:31:34 aaron Exp $
.\" .\"
.\" FreeSec: libcrypt .\" FreeSec: libcrypt
.\" .\"
@ -56,24 +56,32 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn crypt .Fn crypt
function performs password encryption, based on the
function performs password encryption based on the
.Tn NBS .Tn NBS
Data Encryption Standard (DES). Data Encryption Standard (DES).
Additional code has been added to deter key search attempts and to use Additional code has been added to deter key search attempts and to use
stronger hashing algorithms. stronger hashing algorithms.
.Pp
The first argument to The first argument to
.Fn crypt .Fn crypt
is a is a
.Dv null Ns -terminated .Dv null Ns -terminated
string, typically a user's typed password. string, typically a user's typed password.
The second is in one of three forms: The second is in one of three forms:
if it begins with an underscore (``_'') then an extended format is used
in interpreting both the key and the setting, as outlined below. If it begins
with an string character (``$'') and a number then a different algorithm
is used depending on the number. At the moment a ``$1'' chooses MD5 hashing
and a ``$2'' chooses Blowfish hashing, see below for more information.
.Ss Extended crypt:
.Pp
if it begins with an underscore
.Pq Ql _
then an extended format is used
in interpreting both the key and the setting, as outlined below.
If it begins
with a string character
.Pq Ql $
and a number then a different algorithm is used depending on the number.
At the moment a
.Ql $1
chooses MD5 hashing and a
.Ql $2
chooses Blowfish hashing; see below for more information.
.Ss Extended crypt
The The
.Ar key .Ar key
is divided into groups of 8 characters (the last group is null-padded) is divided into groups of 8 characters (the last group is null-padded)
@ -87,61 +95,68 @@ The setting is a 9-character array consisting of an underscore followed
by 4 bytes of iteration count and 4 bytes of salt. by 4 bytes of iteration count and 4 bytes of salt.
These are encoded as printable characters, 6 bits per character, These are encoded as printable characters, 6 bits per character,
least significant character first. least significant character first.
The values 0 to 63 are encoded as ``./0-9A-Za-z''.
The values 0 to 63 are encoded as
.Dq \&./0-9A-Za-z .
This allows 24 bits for both This allows 24 bits for both
.Fa count .Fa count
and and
.Fa salt . .Fa salt .
.Ss "MD5" crypt:
.Pp
.Ss "MD5" crypt
For For
.Tn MD5 .Tn MD5
crypt the version number, crypt the version number,
.Fa salt .Fa salt
and the hashed password are separated
by the ``$'' character. The maximum length of a password is limited by
and the hashed password are separated by the
.Ql $
character.
The maximum length of a password is limited by
the length counter of the MD5 context, which is about the length counter of the MD5 context, which is about
2**64. A valid MD5 password entry looks like this:
2**64.
A valid MD5 password entry looks like this:
.Pp .Pp
``$1$caeiHQwX$hsKqOjrFRRN6K32OWkCBf1''.
.Dq $1$caeiHQwX$hsKqOjrFRRN6K32OWkCBf1 .
.Pp .Pp
The whole MD5 password string is passed as The whole MD5 password string is passed as
.Fa setting .Fa setting
for interpretation. for interpretation.
.Ss "Blowfish" crypt:
.Pp
.Ss "Blowfish" crypt
The The
.Tn Blowfish .Tn Blowfish
version of crypt has 128 bits of version of crypt has 128 bits of
.Fa salt .Fa salt
in order to make building
dictionaries of common passwords space consuming. The initial state
of the
in order to make building dictionaries of common passwords space consuming.
The initial state of the
.Tn Blowfish .Tn Blowfish
cipher is expanded using the cipher is expanded using the
.Fa salt .Fa salt
and the and the
.Fa password .Fa password
repeating the process a variable number of rounds, which is encoded in repeating the process a variable number of rounds, which is encoded in
the password string. The maximum password length is 72. The final Blowfish
password entry is created by encrypting
the string ``OrpheanBeholderScryDoubt'' with the
the password string.
The maximum password length is 72.
The final Blowfish password entry is created by encrypting the string
.Pp
.Dq OrpheanBeholderScryDoubt
.Pp
with the
.Tn Blowfish .Tn Blowfish
state 64 times. state 64 times.
.Pp .Pp
The version number, the logarithm of the number of rounds and The version number, the logarithm of the number of rounds and
the concatenation of salt and
hashed password are separated by the ``$'' character. An encoded ``8''
the concatenation of salt and hashed password are separated by the
.Ql $
character.
An encoded
.Sq 8
would specify 256 rounds. would specify 256 rounds.
A valid Blowfish password looks like this: A valid Blowfish password looks like this:
.Pp .Pp
``$2a$12$eIAq8PR8sIUnJ1HaohxX2O9x9Qlm2vK97LJ5dsXdmB.eXF42qjchC''.
.Dq $2a$12$eIAq8PR8sIUnJ1HaohxX2O9x9Qlm2vK97LJ5dsXdmB.eXF42qjchC .
.Pp .Pp
The whole Blowfish password string is passed as The whole Blowfish password string is passed as
.Fa setting .Fa setting
for interpretation. for interpretation.
.Ss "Traditional" crypt:
.Pp
.Ss "Traditional" crypt
The first 8 bytes of the key are null-padded, and the low-order 7 bits of The first 8 bytes of the key are null-padded, and the low-order 7 bits of
each character is used to form the 56-bit each character is used to form the 56-bit
.Tn DES .Tn DES
@ -153,8 +168,7 @@ Thus only 12 bits of
are used. are used.
.Fa count .Fa count
is set to 25. is set to 25.
.Ss DES Algorithm:
.Pp
.Ss DES Algorithm
The The
.Fa salt .Fa salt
introduces disorder in the introduces disorder in the
@ -182,10 +196,10 @@ string, 20 or 13 bytes (plus null) in length, consisting of the
.Ar setting .Ar setting
followed by the encoded 64-bit encryption. followed by the encoded 64-bit encryption.
.Pp .Pp
The functions,
The functions
.Fn encrypt , .Fn encrypt ,
.Fn setkey , .Fn setkey ,
.Fn des_setkey
.Fn des_setkey ,
and and
.Fn des_cipher .Fn des_cipher
provide access to the provide access to the
@ -243,7 +257,9 @@ E-box output as described above.
.Pp .Pp
The function The function
.Fn crypt .Fn crypt
returns a pointer to the encrypted value on success, and NULL on failure.
returns a pointer to the encrypted value on success, and
.Dv NULL
on failure.
The functions The functions
.Fn setkey , .Fn setkey ,
.Fn encrypt , .Fn encrypt ,
@ -254,7 +270,7 @@ return 0 on success and 1 on failure.
.Pp .Pp
The The
.Fn crypt , .Fn crypt ,
.Fn setkey
.Fn setkey ,
and and
.Fn des_setkey .Fn des_setkey
functions all manipulate the same key space. functions all manipulate the same key space.
@ -265,12 +281,8 @@ functions all manipulate the same key space.
.Xr getpass 3 , .Xr getpass 3 ,
.Xr md5 3 , .Xr md5 3 ,
.Xr passwd 5 .Xr passwd 5
.Sh BUGS
The
.Fn crypt
function returns a pointer to static data, and subsequent calls to
.Fn crypt
will modify the same object.
.Sh AUTHOR
David Burren <davidb@werj.com.au>
.Sh HISTORY .Sh HISTORY
A rotor-based A rotor-based
.Fn crypt .Fn crypt
@ -289,9 +301,14 @@ Programs linked against the
interface may be exported from the U.S.A. only if they use interface may be exported from the U.S.A. only if they use
.Fn crypt .Fn crypt
solely for authentication purposes and avoid use of solely for authentication purposes and avoid use of
the other programmer interfaces listed above. Special care has been taken
the other programmer interfaces listed above.
Special care has been taken
in the library so that programs which only use the in the library so that programs which only use the
.Fn crypt .Fn crypt
interface do not pull in the other components. interface do not pull in the other components.
.Sh AUTHOR
David Burren <davidb@werj.com.au>
.Sh BUGS
The
.Fn crypt
function returns a pointer to static data, and subsequent calls to
.Fn crypt
will modify the same object.

Loading…
Cancel
Save