0

在我的 NetBSD 系统上,master.passwd 中有一个密码哈希,如下所示:

$sha1$[5 numbers]$[8 letters]$[17 alpha numeric].[10 alpha numeric]

出于隐私考虑,我忽略了实际值。有人愿意解释这个的不同部分吗?我的印象是 SHA1 产生了 20 个字节,所以我很困惑到底哪一部分是实际的哈希,哪一部分是盐,以及其他的哪一部分。

4

1 回答 1

1

相关部分可以在 NetBSD 中找到src/lib/libcrypt

对于格式:crypt-sha1.c

The format of the encrypted password is:
$<tag>$<iterations>$<salt>$<digest>
where:
    <tag>       is "sha1"
    <iterations>    is an unsigned int identifying how many rounds
            have been applied to <digest>.  The number
            should vary slightly for each password to make
            it harder to generate a dictionary of
            pre-computed hashes.  See crypt_sha1_iterations.
    <salt>      up to 64 bytes of random data, 8 bytes is
            currently considered more than enough.
    <digest>    the hashed password.

摘要是 160 位 = 20 个字节,但它使用 base64(4 个字节用于 3 个源字节)编码为 28 个字节(一个零填充字节)。请参阅util.c。

于 2015-05-09T00:16:32.400 回答