1
votes

I used the following command on my Ubuntu machine "openssl passwd -crypt - salt pass book" to generate a salted password.

What hash is the output made up of? e.g SHA-512, MD5 etc. Also, i'm wondering how it's made up. For example, is it made by hashing "passbook" together?

I need more information on what hashing/algorithm is being used to generate the output I see.

Thanks

1

1 Answers

0
votes

The result provided by the openssl passwd app when using the -crypt algorithm seems to be the same as the result provided by the Linux/Unix crypt() function. You can verify this with the following (quick'n'dirty) code snippet:

#include <crypt.h>
#include <stdio.h>

int main(
  int argc,
  char **argv)
{
  char *key = argv[1];
  char *salt = argv[2];
  char *enc = crypt(key, salt);
  printf("key = \"%s\", salt = \"%s\", enc = \"%s\"\n",
    key ? key:"NULL", salt ? salt:"NULL", enc ? enc:"NULL");
}

Result:

$ ./main book pass
key = "book", salt = "pass", enc = "pahzZkfwawIXw"
$ openssl passwd -crypt -salt pass book
pahzZkfwawIXw

The exact details of how the crypt() function seem to be explained most clearly in its OSX man page, in particular:

Traditional crypt:
  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 DES key.

  The salt is a 2-character array of the ASCII-encoded salt.  Thus, only 12 bits of salt are
  used.  count is set to 25.

Algorithm:
  The salt introduces disorder in the DES algorithm in one of 16777216 or 4096 possible ways
  (ie. with 24 or 12 bits: if bit i of the salt is set, then bits i and i+24 are swapped in
  the DES E-box output).

  The DES key is used to encrypt a 64-bit constant, using count iterations of DES.  The value
  returned is a null-terminated string, 20 or 13 bytes (plus null) in length, consisting of
  the salt, followed by the encoded 64-bit encryption.