Debian Codegraph @

README.markdown

raw symbols SCIP
1 # NAME
2
3 Dancer2::Plugin::Passphrase - Passphrases and Passwords as objects for Dancer2
4
5 # SYNOPSIS
6
7 This plugin manages the hashing of passwords for Dancer2 apps, allowing
8 developers to follow cryptography best practices without having to
9 become a cryptography expert.
10
11 It uses the bcrypt algorithm as the default, while also supporting any
12 hashing function provided by [Digest](https://metacpan.org/pod/Digest)
13
14 # MORE INFORMATION
15
16 ## Purpose
17
18 The aim of this module is to help you store new passwords in a secure manner,
19 whilst still being able to verify and upgrade older passwords.
20
21 Cryptography is a vast and complex field. Many people try to roll their own
22 methods for securing user data, but succeed only in coming up with
23 a system that has little real security.
24
25 This plugin provides a simple way of managing that complexity, allowing
26 developers to follow crypto best practice without having to become an expert.
27
28 ## Rationale
29
30 The module defaults to hashing passwords using the bcrypt algorithm, returning them
31 in RFC 2307 format.
32
33 RFC 2307 describes an encoding system for passphrase hashes, as used in the "userPassword"
34 attribute in LDAP databases. It encodes hashes as ASCII text, and supports several
35 passphrase schemes by starting the encoding with an alphanumeric scheme identifier enclosed
36 in braces.
37
38 RFC 2307 only specifies the `MD5`, and `SHA` schemes - however in real-world usage,
39 schemes that are salted are widely supported, and are thus provided by this module.
40
41 Bcrypt is an adaptive hashing algorithm that is designed to resist brute
42 force attacks by including a cost (aka work factor). This cost increases
43 the computational effort it takes to compute the hash.
44
45 SHA and MD5 are designed to be fast, and modern machines compute a billion
46 hashes a second. With computers getting faster every day, brute forcing
47 SHA hashes is a very real problem that cannot be easily solved.
48
49 Increasing the cost of generating a bcrypt hash is a trivial way to make
50 brute forcing ineffective. With a low cost setting, bcrypt is just as secure
51 as a more traditional SHA+salt scheme, and just as fast. Increasing the cost
52 as computers become more powerful keeps you one step ahead
53
54 For a more detailed description of why bcrypt is preferred, see this article:
55 [http://codahale.com/how-to-safely-store-a-password/](http://codahale.com/how-to-safely-store-a-password/)
56
57 ## Common Mistakes
58
59 Common mistakes people make when creating their own solution. If any of these
60 seem familiar, you should probably be using this module
61
62 - Passwords are stored as plain text for a reason
63
64 There is never a valid reason to store a password as plain text.
65 Passwords should be reset and not emailed to customers when they forget.
66 Support people should be able to login as a user without knowing the users password.
67 No-one except the user should know the password - that is the point of authentication.
68
69 - No-one will ever guess our super secret algorithm!
70
71 Unless you're a cryptography expert with many years spent studying
72 super-complex maths, your algorithm is almost certainly not as secure
73 as you think. Just because it's hard for you to break doesn't mean
74 it's difficult for a computer.
75
76 - Our application-wide salt is "Sup3r\_S3cret\_L0ng\_Word" - No-one will ever guess that.
77
78 This is common misunderstanding of what a salt is meant to do. The purpose of a
79 salt is to make sure the same password doesn't always generate the same hash.
80 A fresh salt needs to be created each time you hash a password. It isn't meant
81 to be a secret key.
82
83 - We generate our random salt using `rand`.
84
85 `rand` isn't actually random, it's a non-unform pseudo-random number generator,
86 and not suitable for cryptographic applications. Whilst this module also defaults to
87 a PRNG, it is better than the one provided by `rand`. Using a true RNG is a config
88 option away, but is not the default as it it could potentially block output if the
89 system does not have enough entropy to generate a truly random number
90
91 - We use `md5(pass.salt)`, and the salt is from `/dev/random`
92
93 MD5 has been broken for many years. Commodity hardware can find a
94 hash collision in seconds, meaning an attacker can easily generate
95 the correct MD5 hash without using the correct password.
96
97 - We use `sha(pass.salt)`, and the salt is from `/dev/random`
98
99 SHA isn't quite as broken as MD5, but it shares the same theoretical
100 weaknesses. Even without hash collisions, it is vulnerable to brute forcing.
101 Modern hardware is so powerful it can try around a billion hashes a second.
102 That means every 7 chracter password in the range \[A-Za-z0-9\] can be cracked
103 in one hour on your average desktop computer.
104
105 - If the only way to break the hash is to brute-force it, it's secure enough
106
107 It is unlikely that your database will be hacked and your hashes brute forced.
108 However, in the event that it does happen, or SHA512 is broken, using this module
109 gives you an easy way to change to a different algorithm, while still allowing
110 you to validate old passphrases