词条 | Crypt (C) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
释义 |
crypt is the library function which is used to compute a password hash that can be used to store user account passwords while keeping them relatively secure (a passwd file). The output of the function is not simply the hash{{snd}} it is a text string which also encodes the salt (usually the first two characters are the salt itself and the rest is the hashed result), and identifies the hash algorithm used (defaulting to the "traditional" one explained below). This output string is what is meant for putting in a password record which may be stored in a plain text file. More formally, crypt provides cryptographic key derivation functions for password validation and storage on Unix systems. Relationship to Unix crypt utilityThere is a crypt utility in Unix, which is often confused with the C library function. To distinguish between the two, writers often refer to the utility program as crypt(1), because it is documented in section 1 of the Unix manual pages, and refer to the C library function as crypt(3), because its documentation is in manual section 3. DetailsThis same crypt function is used both to generate a new hash for storage and also to hash a proffered password with a recorded salt for comparison. Modern Unix implementations of the crypt library routine support a variety of hash schemes. The particular hash algorithm used can be identified by a unique code prefix in the resulting hashtext, following a de facto standard called Modular Crypt Format.[1][2][3] The Key derivation functions supported by cryptOver time various algorithms have been introduced. To enable backward compatibility, each scheme started using some convention of serializing the password hashes that was later called the Modular Crypt Format (MCF).[2] Old crypt(3) hashes generated before the de facto MCF standard may vary from scheme to scheme. A well-defined subset of the Modular Crypt Format was created during the Password Hashing Competition. It is a restricted and well-defined subset of the MCF.[2] The format is defined as[9]: $ where
Original implementation using the password as a keyThe original implementation of the crypt() library function[10] in Third Edition Unix[11] mimicked the M-209 cipher machine. Rather than encrypting the password with a key, which would have allowed the password to be recovered from the encrypted value and the key, it used the password itself as a key, and the password database contained the result of encrypting the password with this key. Traditional DES-based schemeThe original password encryption scheme was found to be too fast and thus subject to brute force enumeration of the most likely passwords.[10] In Seventh Edition Unix,[12] the scheme was changed to a modified form of the DES algorithm. A goal of this change was to make encryption slower. In addition, the algorithm incorporated a 12-bit salt in order to ensure that an attacker would be forced to crack each password independently as opposed to being able to target the entire password database simultaneously. In detail, the user's password is truncated to eight characters, and those are coerced down to only 7-bits each; this forms the 56-bit DES key. That key is then used to encrypt an all-bits-zero block, and then the ciphertext is encrypted again with the same key, and so on for a total of 25 DES encryptions. A 12-bit salt is used to perturb the encryption algorithm, so standard DES implementations can't be used to implement crypt(). The salt and the final ciphertext are encoded into a printable string in a form of base64. This is technically not encryption since the data (all bits zero) is not being kept secret; it's widely known to all in advance. However, one of the properties of DES is that it's very resistant to key recovery even in the face of known plaintext situations. It is theoretically possible that two different passwords could result in exactly the same hash. Thus the password is never "decrypted": it is merely used to compute a result, and the matching results are presumed to be proof that the passwords were "the same." The advantages of this method have been that the hashtext can be stored and copied among Unix systems without exposing the corresponding plaintext password to the system administrators or other users. This portability has worked for over 30 years across many generations of computing architecture, and across many versions of Unix from many vendors. Weaknesses of the traditional schemeThe traditional DES-based crypt algorithm was originally chosen because DES was resistant to key recovery even in the face of "known plaintext" attacks, and because it was computationally expensive. On the earliest Unix machines it took over a full second to compute a password hash. This also made it reasonably resistant to dictionary attacks in that era. At that time password hashes were commonly stored in an account file ( In the three decades since that time, computers have become vastly more powerful. Moore's Law has generally held true, so the computer speed and capacity available for a given financial investment has doubled over 20 times since Unix was first written. This has long since left the DES-based algorithm vulnerable to dictionary attacks, and Unix and Unix-like systems such as Linux have used "shadow" files for a long time, migrating just the password hash values out of the account file ( To increase the computational cost of password breaking, some Unix sites privately started increasing the number of encryption rounds on an ad hoc basis.{{Citation needed|date=July 2011}} This had the side effect of making their BSDi extended DES-based schemeBSDi used a slight modification of the classic DES-based scheme. BSDi extended the salt to 24 bits and made the number of rounds variable (up to 224-1). The chosen number of rounds is encoded in the stored password hash, avoiding the incompatibility that occurred when sites modified the number of rounds used by the original scheme. These hashes are identified by starting with an underscore ( The BSDi algorithm also supports longer passwords, using DES to fold the initial long password down to the eight 7-bit bytes supported by the original algorithm. MD5-based schemePoul-Henning Kamp designed a baroque and (at the time) computationally expensive algorithm based on the MD5 message digest algorithm. MD5 itself would provide good cryptographic strength for the password hash, but it is designed to be quite quick to calculate relative to the strength it provides. The crypt() scheme is designed to be expensive to calculate, to slow down dictionary attacks. The printable form of MD5 password hashes starts with This scheme allows users to have any length password, and they can use any characters supported by their platform (not just 7-bit ASCII). (In practice many implementations limit the password length, but they generally support passwords far longer than any person would be willing to type.) The salt is also an arbitrary string, limited only by character set considerations. First the passphrase and salt are hashed together, yielding an MD5 message digest. Then a new digest is constructed, hashing together the passphrase, the salt, and the first digest, all in a rather complex form. Then this digest is passed through a thousand iterations of a function which rehashes it together with the passphrase and salt in a manner that varies between rounds. The output of the last of these rounds is the resulting passphrase hash. The fixed iteration count has caused this scheme to lose the computational expense that it once enjoyed and variable numbers of rounds are now favoured. In June 2012, Poul-Henning Kamp declared the algorithm insecure and encouraged users to migrate to stronger password scramblers.[13] Blowfish-based schemeNiels Provos and David Mazières designed a crypt() scheme called bcrypt based on Blowfish, and presented it at USENIX in 1999.[14] The printable form of these hashes starts with
Blowfish is notable among block ciphers for its expensive key setup phase. It starts off with subkeys in a standard state, then uses this state to perform a block encryption using part of the key, and uses the result of that encryption (really, a hashing) to replace some of the subkeys. Then it uses this modified state to encrypt another part of the key, and uses the result to replace more of the subkeys. It proceeds in this fashion, using a progressively modified state to hash the key and replace bits of state, until all subkeys have been set. The number of rounds of keying is a power of two, which is an input to the algorithm. The number is encoded in the textual hash, e.g. NT hash schemeFreeBSD implemented support for the NT LAN Manager hash algorithm to provide easier compatibility with NT accounts.[18] The NT-Hash algorithm is known to be weak, as it uses the deprecated md4 hash algorithm without any salting.[19] FreeBSD used the SHA2-based schemeThe commonly used MD5 based scheme has become easier to attack as computer power has increased. Although the Blowfish-based system has the option of adding rounds and thus remain a challenging password algorithm, it does not use a NIST-approved algorithm. In light of these facts, Ulrich Drepper of Red Hat led an effort to create a scheme based on the SHA-2 (SHA-256 and SHA-512) hash functions.[21] The printable form of these hashes starts with
The specification and sample code have been released into the public domain; it is often referred to as "SHAcrypt".[24] Support in operating systems
Archaic Unix schemesBigCrypt is the modified version of DES-Crypt used on HP-UX, Digital Unix, and OSF/1. The main difference between it and DES is that BigCrypt uses all the characters of a password, not just the first 8, and has a variable length hash.[25]Crypt16 is the minor modification of DES, which allows passwords of up to 16 characters. Used on Ultrix and Tru64.[26]GNU/LinuxThe GNU C Library used by almost all GNU/Linux distributions provides an implementation of the crypt function which supports the DES, MD5, and (since version 2.7) SHA-2 based hashing algorithms mentioned above. Ulrich Drepper, the glibc maintainer, rejected bcrypt support since it isn't approved by NIST.[27] macOSDarwin’s native See also
References1. ^Simson Garfinkel, Alan Schwartz, Gene Spafford.[https://books.google.com/books?id=50maN7VmpusC&q=Modular+Crypt+Format "Practical Unix & Internet Security"].2003.section "4.3.2.3 crypt16( ), DES Extended, and Modular Crypt Format"."The Modular Crypt Format (MCF) specifies an extensible scheme for formatting encrypted passwords. MCF is one of the most popular formats for encrypted passwords" 2. ^1 2 {{cite web|url=http://pythonhosted.org/passlib/modular_crypt_format.html|title=Modular Crypt Format — Passlib v1.7.1 Documentation|website=Pythonhosted.org|accessdate=2 December 2018}} 3. ^{{cite web|url=https://github.com/ademarre/binary-mcf|title=ademarre/binary-mcf|website=GitHub.com|accessdate=2 December 2018}} 4. ^{{cite web|url=http://perldoc.perl.org/functions/crypt.html|title=crypt - perldoc.perl.org|website=Perldoc.perl.org|accessdate=2 December 2018}} 5. ^{{cite web|url=http://us.php.net/manual/en/function.crypt.php|title=PHP: crypt - Manual|website=Us.php.net|accessdate=2 December 2018}} 6. ^{{cite web |url=http://pike.ida.liu.se/generated/manual/modref/ex/predef_3A_3A/crypt.html |title=crypt() |accessdate=2013-02-09 |deadurl=yes |archiveurl=https://web.archive.org/web/20121002215125/http://pike.ida.liu.se/generated/manual/modref/ex/predef_3A_3A/crypt.html |archivedate=2012-10-02 |df= }} 7. ^{{cite web|url=https://docs.python.org/library/crypt.html|title=crypt — Function to check Unix passwords — Python 3.7.1 documentation|website=Docs.python.org|accessdate=2 December 2018}} 8. ^{{cite web|url=http://ruby-doc.org/core/classes/String.html#M001174|title=Class: String (Ruby 2.5.3)|website=Ruby-doc.org|accessdate=2 December 2018}} 9. ^{{cite web | url=https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md | title=Password Hash Competition string format|website=Github.com }} 10. ^1 {{cite web | url=https://www.bell-labs.com/usr/dmr/www/passwd.ps | title=Password Security: A Case History. | work=Bell Laboratories |author1=Morris, Robert |author2=Thompson, Ken | date=1978-04-03 | accessdate=2013-12-17 }} 11. ^{{cite web | url=http://minnie.tuhs.org/cgi-bin/utree.pl?file=V3/man/man3/crypt.3 | title=crypt – password encoding | work=UNIX Third Edition Programmers' Manual | date = 1973-01-15 }} 12. ^{{cite web | url=http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/man/man3/crypt.3 | title=crypt, setkey, encrypt – DES encryption | work=UNIX Seventh Edition Programmers' Manual | date = 1979 }} 13. ^{{cite web|url=http://phk.freebsd.dk/sagas/md5crypt_eol.html|title=Md5crypt Password scrambler is no longer considered safe by author — PHKs Bikeshed|website=Phk.freebsd.dk|accessdate=2 December 2018}} 14. ^{{cite journal | url = http://www.usenix.org/events/usenix99/provos/provos_html/node1.html | title = A Future-Adaptable Password Scheme | first = Niels | last = Provos |author2=Mazières, David | year = 1999 | journal = Proceedings of 1999 USENIX Annual Technical Conference | pages = 81–92}} 15. ^{{cite web | url = http://www.openwall.com/lists/announce/2011/06/21/1 | title = crypt_blowfish 1.1; Owl glibc security update | date = 2011-06-21 | first = Solar | last = Designer}} See also CVE-2011-2483. 16. ^{{Cite web|url=http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/crypt/bcrypt.c?rev=1.27&content-type=text/x-cvsweb-markup|title=src/lib/libc/crypt/bcrypt.c – view – 1.27|website=Cvsweb.openbsd.org|access-date=2016-05-14}} 17. ^{{cite web | url = http://www.openwall.com/lists/oss-security/2012/01/02/4 | title = OpenBSD bcrypt 8-bit key_len wraparound | date = 2012-01-02 | first = Solar | last = Designer}} 18. ^{{cite web|url=http://www.mail-archive.com/freebsd-current@freebsd.org/msg52586.html|title=NT MD4 password hash as new password encryption method for FreeBSD|website=Mail-archive.com|accessdate=2 December 2018}} 19. ^{{cite web|url=http://davenport.sourceforge.net/ntlm.html#theNtlmResponse|title=The NTLM Authentication Protocol and Security Support Provider|website=Davenport.sourceforge.net|accessdate=2 December 2018}} 20. ^{{cite web|url=http://www.freebsd.org/cgi/man.cgi?query=crypt&apropos=0&sektion=3&manpath=FreeBSD+8.2-RELEASE&format=html|title=crypt(3)|website=Freebsd.org|accessdate=2 December 2018}} 21. ^1 {{cite web | first = Ulrich | last = Drepper | date = {{date|2007-09-19|ISO}}| access-date = {{date|21 Nov 2018|ISO}}| title = Unix crypt with SHA-256/512 | url = http://people.redhat.com/drepper/sha-crypt.html| df = dmy-all}} 22. ^{{cite web | author = Sun Microsystems | title = crypt_sunmd5(5) man page | url = http://docs.sun.com/app/docs/doc/816-5175/6mbba7evg | accessdate = 2008-03-05 | deadurl = yes | archiveurl = https://web.archive.org/web/20080416021006/http://docs.sun.com/app/docs/doc/816-5175/6mbba7evg | archivedate = 2008-04-16 | df = }} 23. ^{{cite web | title = OpenSolaris, Pluggable Crypt, and the SunMD5 Password Hash Algorithm | first = Alec | last = Muffett | url = http://dropsafe.crypticide.com/article/1389 | date = 2005-12-05 | accessdate = 2012-08-11}} 24. ^{{cite web | url = http://www.akkadia.org/drepper/SHA-crypt.txt | title = Unix crypt using SHA-256 and SHA-512 | first = Ulrich | last = Drepper }} 25. ^{{cite web|url=https://pythonhosted.org/passlib/lib/passlib.hash.bigcrypt.html|title=passlib.hash.bigcrypt - BigCrypt — Passlib v1.7.1 Documentation|website=Pythonhosted.org|accessdate=2 December 2018}} 26. ^{{cite web|url=https://pythonhosted.org/passlib/lib/passlib.hash.crypt16.html|title=passlib.hash.crypt16 - Crypt16 — Passlib v1.7.1 Documentation|website=Pythonhosted.org|accessdate=2 December 2018}} 27. ^{{cite web|url=https://access.redhat.com/articles/1519843|title=bcrypt support for passwords in /etc/shadow - Red Hat Customer Portal|website=Access.redhat.com|accessdate=2 December 2018}} 28. ^{{cite web|url=http://www.dribin.org/dave/blog/archives/2006/04/07/os_x_passwords/|title=How Mac OS X Implements Password Authentication|website=Dribin.org|accessdate=2 December 2018}} 29. ^{{cite web|url=http://www.onlinehashcrack.com/how-to-extract-hashes-crack-mac-osx-passwords.php|title=How to crack Mac OS X Passwords - Online Hash Crack|website=Onlinehashcrack.com|accessdate=2 December 2018}} External links
5 : Password authentication|Broken cryptography algorithms|Cryptographic hash functions|Computer access control protocols|Key derivation functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。