Random password generator

Random password generator

A random password generator is software program or hardware device that takes input from a random or pseudo-random number generator and automatically generates a password. Random passwords can be generated manually, using simple sources of randomness such as dice or coins, or they can be generated using a computer.

While there are many examples of "random" password generator programs available on the Internet, generating randomness can be tricky and many programs do not generate random characters in a way that ensures strong security. A common recommendation is to use open source security tools where possible, since they allow independent checks on the quality of the methods used. Note that simply generating a password at random does not ensure the password is a strong password, because it is possible, although highly unlikely, to generate an easily guessed or cracked password.

A password generator can be part of a password manager. When a password policy enforces complex rules, it can be easier to use a password generator based on that set of rules than to manually create passwords.

The naive approach

Here are two code samples that a naive programmer might believeweasel-inline is a suitable password generator:


= C =


#include
#include
#include

int main(void) { int length = 8; int r,i; char c; srand((unsigned int)time(0)); //Seed number for rand() for (i = 0; i < length; i++) { r = rand() + 33; c = (char)r; printf("%c", c); } return 0;}

In this case, the standard C function "rand", which is a pseudo-random number generator, is seeded using the C "time" function. According to the ANSI C standard, "time" returns a value of type "time t", which is implementation defined, but most commonly a 32-bit integer containing the current number of seconds since January 1, 1970 ("see:" Unix time). There are about 31 million seconds in a year, so an attacker who knows the year in which the password was generated (a simple matter in situations where frequent password changes are mandated by password policy) faces a relatively small number, by cryptographic standards, of choices to test. If the attacker knows more accurately when the password was generated, he faces an even smaller number of candidates to test &ndash; a serious flaw in this implementation.

In situations where the attacker can obtain an encrypted version of the password, such testing can be performed rapidly enough so that a few million trial passwords can be checked in a matter of seconds. "See:" password cracking.

The function "rand" presents another problem. All pseudo-random number generators have an internal memory or state. The size of that state determines the maximum number of different values it can produce: an "n"-bit state can produce at most 2^n different values. On many systems "rand" has a 31 or 32 bit state, which is already a significant security limitation. In the Visual C++ implementation of the C standard library, "rand" has only a 15-bit state, allowing just 32 767 possible outputs. [http://msdn2.microsoft.com/en-us/library/2dfe3bzd.aspx]

PHP

function pass_gen($len) { $pass = "; srand((float) microtime() * 10000000); for ($i = 0; $i < $len; $i++) { $pass .= chr(rand(33, 126)); } return $pass;}

In the second case, the PHP function [http://us3.php.net/microtime "microtime"] is used, which returns the current Unix timestamp with microseconds. This increases the number of possibilities, but someone with a good guess of when the password was generated, for example the date an employee started work, still has a reasonably small search space. Also some operating systems do not provide time to microsecond resolution, sharply reducing the number of choices. Finally the [http://us3.php.net/manual/en/function.rand.php "rand"] function usually uses the underlying C "rand" function, and may have a small state space, depending on how it is implemented.

tronger methods

Some computer operating systems provide much stronger random number generators. One example, common on most Unix platforms, is /dev/random. The Java programming language includes a class called [http://java.sun.com/j2se/1.4.2/docs/api/java/security/SecureRandom.html "SecureRandom"] . Windows programmers can use the Cryptographic Application Programming Interface function CryptGenRandom. Another possibility, is to derive randomness by measuring some external phenomenon, such as timing user keyboard input. Using random bytes from any of these sources should prove adequate for most password generation needs.

Yet another method is to use physical devices such as dice to generate the randomness. One simple way to do this uses a 6 by 6 table of characters. The first die roll selects a row in the table and the second a column. So, for example, a roll of 2 followed by a roll of 4 would select the letter "j" from the table below. [Levine, John R., Ed.: "Internet Secrets", Second edition, page 831 ff. John Wiley and Sons.] To generate uppper/lower case characters or some symbols a coin flip can be used, heads capital, tails lower case. If a digit was selected in the dice rolls, a heads coin flip might select the symbol above it on a standard keyboard, such as the '$' above the '4' instead of '4'.

:

Type and strength of password generated

Random password generators normally output a string of symbols of specified length. These can be individual characters from some character set, syllables designed to form pronounceable passwords, or words from some word list to form a passphrase. The program can be customized to ensure the resulting password complies with the local password policy, say by always producing a mix of letters, numbers and special characters.

The strength of a random password against a particular attack (brute force search), can be calculated by computing the information entropy of the random process that produced it. If each symbol in the password is produced independently, the entropy is just given by the formula

:H = Llog_2 N = L {log N over log 2}

where "N" is the number of possible symbols and "L" is the number of symbols in the password. The function log2 is the base-2 logarithm. "H" is measured in bits. [Schneier, B: "Applied Cryptography", Second edition, page 233 ff. John Wiley and Sons.]

:

Thus an eight character password of single case letters and digits would have 41 bits of entropy (8 x 5.17). The same length password selected at random from the characters available on a U.S. English computer keyboard (these are essentially the printable ASCII characters) would have 52 bit entropy; however such a password would be harder to memorize than an actual word or name, and might be difficult to enter on non-U.S. keyboards. A ten character password of single case letters and digits would have essentially the same strength (51.7 bits).

Any password generator is limited by the state space of the pseudo-random number generator used, if it based on one. Thus a password generated using a 32-bit generator is limited to 32 bits entropy, regardless of the number of characters the password contains.

Note, however, that a different type of attack might succeed against a password evaluated as 'very strong' by the above calculation.

Password generator programs and Web sites

A large number of password generator programs and Web sites are available on the Internet. Their quality varies and can be hard to assess if there is no clear description of the source of randomness that is used, and if source code is not provided to allow claims to be checked. Furthermore, and probably most importantly, transmitting candidate passwords over the Internet raises obvious security concerns, particularly if the connection to the password generation site's program is not properly secured or if the site is compromised in some way. Without a secure channel, it is not possible to prevent eavesdropping, especially over public networks such as the Internet.

ee also

*Diceware
*Key size
*Password length parameter
*Password manager
*Random number generator

References

External links

* [http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx Cryptographically Secure Random number on Windows without using CryptoAPI] from MSDN
* [http://www.ietf.org/rfc/rfc4086.txt RFC 4086 on Randomness Recommendations for Security] (Replaces earlier RFC 1750.)
* [http://www.itl.nist.gov/fipspubs/fip181.htm Automated Password Generator standard FIPS 181]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Random number generator attack — The security of cryptographic systems depends on some secret data that is known to authorized persons but unknown and unpredictable to others. To achieve this unpredictability, some randomization is typically employed. Modern cryptographic… …   Wikipedia

  • Password strength — is a measurement of the effectiveness of a password as an authentication credential. Specifically, it estimates how many trials an attacker who does not have direct access to the password would need, on average, to correctly guess it. The… …   Wikipedia

  • Random number generation — A random number generator (often abbreviated as RNG) is a computational or physical device designed to generate a sequence of numbers or symbols that lack any pattern, i.e. appear random. Computer based systems for random number generation are… …   Wikipedia

  • Password — For other uses, see Password (disambiguation). A password is a secret word or string of characters that is used for authentication, to prove identity or gain access to a resource (example: an access code is a type of password). The password… …   Wikipedia

  • Password policy — A password policy is a set of rules designed to enhance computer security by encouraging users to employ strong passwords and use them properly. A password policy is often part of an organization s official regulations and may be taught as part… …   Wikipedia

  • Password manager — A password manager is software that helps a user organize passwords and PIN codes. The software typically has a local database or a file that holds the encrypted password data for secure logon onto computers, networks, web sites and application… …   Wikipedia

  • One-time password — A one time password (OTP) is a password that is valid for only one login session or transaction. OTPs avoid a number of shortcomings that are associated with traditional (static) passwords. The most important shortcoming that is addressed by OTPs …   Wikipedia

  • OTPW — is a one time password system developed for authentication in Unix like operating systems by Markus Kuhn. A user s real password is not directly transmitted across the network. Rather, the real password is combined with a short set of characters… …   Wikipedia

  • KeePass — Infobox Software name = KeePass Password Safe caption = KeePass 1.x Main Window collapsible = author = developer = Dominik Reichl released = November 16, 2003 latest release version = 1.13 latest release date = release date|2008|09|7 latest… …   Wikipedia

  • Brute-force attack — The EFF s US$250,000 DES cracking machine contained over 1,800 custom chips and could brute force a DES key in a matter of days. The photograph shows a DES Cracker circuit board fitted with 32 Deep Crack chips and some control chips. In… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”