|
13 | 13 | </p> |
14 | 14 | <ul> |
15 | 15 | <li> |
16 | | - pre-image attacks: if you know a hash value <code>h(x)</code>, |
| 16 | + <b>Pre-image attacks</b>. If you know a hash value <code>h(x)</code>, |
17 | 17 | you should not be able to easily find the input <code>x</code>. |
18 | 18 | </li> |
19 | 19 | <li> |
20 | | - collision attacks: if you know a hash value <code>h(x)</code>, |
| 20 | + <b>Collision attacks</b>. If you know a hash value <code>h(x)</code>, |
21 | 21 | you should not be able to easily find a different input |
22 | 22 | <code>y</code> |
23 | 23 | with the same hash value <code>h(x) = h(y)</code>. |
24 | 24 | </li> |
25 | 25 | </ul> |
26 | | - <!--<p> |
27 | | - In cases with a limited input space, such as for passwords, the hash |
28 | | - function also needs to be computationally expensive to be resistant to |
29 | | - brute-force attacks. Passwords should also have an unique salt applied |
30 | | - before hashing, but that is not considered by this query. |
31 | | - </p>--> |
32 | 26 |
|
33 | 27 | <p> |
34 | 28 | As an example, both MD5 and SHA-1 are known to be vulnerable to collision attacks. |
|
44 | 38 | <recommendation> |
45 | 39 |
|
46 | 40 | <p> |
47 | | - Ensure that you use a strong, modern cryptographic hash function: |
| 41 | + Ensure that you use a strong, modern cryptographic hash function, such as: |
48 | 42 | </p> |
49 | 43 |
|
50 | 44 | <ul> |
51 | 45 | <li> |
52 | | - such as Argon2, scrypt, bcrypt, or PBKDF2 for passwords and other data with limited input space where |
| 46 | + Argon2, scrypt, bcrypt, or PBKDF2 for passwords and other data with limited input space where |
53 | 47 | a dictionary-like attack is feasible. |
54 | 48 | </li> |
55 | 49 | <li> |
56 | | - such as SHA-2, or SHA-3 in other cases. |
| 50 | + SHA-2, or SHA-3 in other cases. |
57 | 51 | </li> |
58 | 52 | </ul> |
59 | 53 |
|
|
69 | 63 | <sample src="WeakSensitiveDataHashingBad.swift"/> |
70 | 64 | <p> |
71 | 65 |
|
72 | | - Here is the same function using SHA-512 that is a strong cryptographic hashing function. |
| 66 | + Here is the same function using SHA-512, which is a strong cryptographic hashing function. |
73 | 67 | </p> |
74 | 68 | <sample src="WeakSensitiveDataHashingGood.swift"/> |
75 | 69 |
|
|
0 commit comments