SYNOPSIS

        use Authen::Passphrase::Crypt16;

        $ppr = Authen::Passphrase::Crypt16->new(
                salt_base64 => "qi",
                hash_base64 => "8H8R7OM4xMUNMPuRAZxlY.");

        $ppr = Authen::Passphrase::Crypt16->new(
                salt_random => 12,
                passphrase => "passphrase");

        $salt = $ppr->salt;
        $salt_base64 = $ppr->salt_base64_2;
        $hash = $ppr->hash;
        $hash_base64 = $ppr->hash_base64;

        $ppr0 = $ppr->first_half;
        $ppr1 = $ppr->second_half;

        if($ppr->match($passphrase)) { ...

DESCRIPTION

An object of this class encapsulates a passphrase hashed using the \*(L"crypt16\*(R" hash function found in Ultrix and Tru64. Do not confuse this with the \*(L"bigcrypt\*(R" found on HP-UX, Digital Unix, and \s-1OSF/1\s0 (for which see Authen::Passphrase::BigCrypt). This is a subclass of Authen::Passphrase, and this document assumes that the reader is familiar with the documentation for that class.

This is a derivation of the original DES-based crypt function found on all Unices (see Authen::Passphrase::DESCrypt). The first eight bytes of the passphrase are used as a \s-1DES\s0 key to encrypt the all-bits-zero block through 20 rounds of (12-bit) salted \s-1DES\s0. (The standard crypt function does this, but with 25 encryption rounds instead of 20.) Then the next eight bytes, or the null string if the passphrase is eight bytes or shorter, are used as a \s-1DES\s0 key to encrypt the all-bits-zero block through 5 rounds of salted \s-1DES\s0 with the same salt. The two eight-byte ciphertexts are concatenated to form the sixteen-byte hash.

A password hash of this scheme is conventionally represented in \s-1ASCII\s0 as a 24-character string using a base 64 encoding. The first two characters give the salt, the next eleven give the hash of the first half, and the last eleven give the hash of the second half. A hash thus encoded is used as a crypt string, on those systems where the crypt16 algorithm is part of crypt(), but the syntax clashes with that of bigcrypt. This module does not treat it as a crypt string syntax.

Because the two halves of the passphrase are hashed separately, it is possible to manipulate (e.g., crack) a half hash in isolation. See Authen::Passphrase::DESCrypt for handling of a single half.

Warning: This is a fatally flawed design, often providing less security than the plain \s-1DES\s0 scheme alone. Do not use seriously.

CONSTRUCTOR

Authen::Passphrase::Crypt16->new(\s-1ATTR\s0 => \s-1VALUE\s0, ...)

Generates a new passphrase recogniser object using the crypt16 hash algorithm. The following attributes may be given:

salt

The salt, as an integer in the range [0, 4096).

salt_base64

The salt, as a string of two base 64 digits.

salt_random

Causes salt to be generated randomly. The value given for this attribute must be 12, indicating generation of 12 bits of salt. The source of randomness may be controlled by the facility described in Data::Entropy.

hash

The hash, as a string of 16 bytes.

hash_base64

The hash, as a string of 22 base 64 digits.

passphrase

A passphrase that will be accepted.

The salt must be given, and either the hash or the passphrase.

METHODS

Returns the salt, as a Perl integer. Returns the salt, as a string of two base 64 digits. Returns the hash value, as a string of 16 bytes. Returns the hash value, as a string of 22 base 64 digits. This is the concatenation of the base 64 encodings of the two hashes, rather than a base64 encoding of the combined hash. Returns the hash of the first half of the passphrase, as an Authen::Passphrase::DESCrypt passphrase recogniser. Returns the hash of the second half of the passphrase, as an Authen::Passphrase::DESCrypt passphrase recogniser. This method is part of the standard Authen::Passphrase interface.

RELATED TO Authen::Passphrase::Crypt16…

Authen::Passphrase, Authen::Passphrase::DESCrypt

AUTHOR

Andrew Main (Zefram) <[email protected]>

COPYRIGHT

Copyright (C) 2006, 2007, 2009, 2010, 2012 Andrew Main (Zefram) <[email protected]>

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.