Donald Stufft | d8f0118 | 2013-10-27 16:59:56 -0400 | [diff] [blame] | 1 | .. danger:: |
| 2 | |
| 3 | This is a "Hazardous Materials" module. You should **ONLY** use it if |
| 4 | you're 100% absolutely sure that you know what you're doing because this |
| 5 | module is full of land mines, dragons, and dinosaurs with laser guns. |
| 6 | |
| 7 | |
Donald Stufft | e51fb93 | 2013-10-27 17:26:17 -0400 | [diff] [blame^] | 8 | Message Digests |
| 9 | =============== |
| 10 | |
Donald Stufft | f04317a | 2013-10-27 16:44:30 -0400 | [diff] [blame] | 11 | .. currentmodule:: cryptography.hazmat.primitives.hashes |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame] | 12 | |
| 13 | .. class:: BaseHash(data=None) |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 14 | |
Paul Kehrer | 6b9ddeb | 2013-10-19 12:28:15 -0500 | [diff] [blame] | 15 | Abstract base class that implements a common interface for all hash |
| 16 | algorithms that follow here. |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 17 | |
Alex Gaynor | f3b06cd | 2013-10-21 21:49:50 -0700 | [diff] [blame] | 18 | If ``data`` is provided ``update(data)`` is called upon construction. |
| 19 | |
Paul Kehrer | 6b9ddeb | 2013-10-19 12:28:15 -0500 | [diff] [blame] | 20 | .. method:: update(data) |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 21 | |
Alex Gaynor | ddc62f0 | 2013-10-20 06:14:24 -0700 | [diff] [blame] | 22 | :param bytes data: The bytes you wish to hash. |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 23 | |
| 24 | .. method:: copy() |
| 25 | |
Paul Kehrer | 6b9ddeb | 2013-10-19 12:28:15 -0500 | [diff] [blame] | 26 | :return: a new instance of this object with a copied internal state. |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 27 | |
| 28 | .. method:: digest() |
| 29 | |
| 30 | :return bytes: The message digest as bytes. |
| 31 | |
| 32 | .. method:: hexdigest() |
| 33 | |
| 34 | :return str: The message digest as hex. |
| 35 | |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 36 | SHA-1 |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 37 | ~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 38 | |
| 39 | .. attention:: |
| 40 | |
| 41 | NIST has deprecated SHA-1 in favor of the SHA-2 variants. New applications |
| 42 | are strongly suggested to use SHA-2 over SHA-1. |
| 43 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame] | 44 | .. class:: SHA1() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 45 | |
| 46 | SHA-1 is a cryptographic hash function standardized by NIST. It has a |
| 47 | 160-bit message digest. |
| 48 | |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 49 | SHA-2 Family |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 50 | ~~~~~~~~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 51 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame] | 52 | .. class:: SHA224() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 53 | |
| 54 | SHA-224 is a cryptographic hash function from the SHA-2 family and |
| 55 | standardized by NIST. It has a 224-bit message digest. |
| 56 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame] | 57 | .. class:: SHA256() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 58 | |
| 59 | SHA-256 is a cryptographic hash function from the SHA-2 family and |
| 60 | standardized by NIST. It has a 256-bit message digest. |
| 61 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame] | 62 | .. class:: SHA384() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 63 | |
| 64 | SHA-384 is a cryptographic hash function from the SHA-2 family and |
| 65 | standardized by NIST. It has a 384-bit message digest. |
| 66 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame] | 67 | .. class:: SHA512() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 68 | |
| 69 | SHA-512 is a cryptographic hash function from the SHA-2 family and |
| 70 | standardized by NIST. It has a 512-bit message digest. |
| 71 | |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 72 | RIPEMD160 |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 73 | ~~~~~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 74 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame] | 75 | .. class:: RIPEMD160() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 76 | |
| 77 | RIPEMD160 is a cryptographic hash function that is part of ISO/IEC |
| 78 | 10118-3:2004. It has a 160-bit message digest. |
| 79 | |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 80 | Whirlpool |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 81 | ~~~~~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 82 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame] | 83 | .. class:: Whirlpool() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 84 | |
| 85 | Whirlpool is a cryptographic hash function that is part of ISO/IEC |
| 86 | 10118-3:2004. It has a 512-bit message digest. |
| 87 | |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 88 | MD5 |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 89 | ~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 90 | |
| 91 | .. warning:: |
| 92 | |
| 93 | MD5 is a deprecated hash algorithm that has practical known collision |
| 94 | attacks. You are strongly discouraged from using it. |
| 95 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame] | 96 | .. class:: MD5() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 97 | |
Paul Kehrer | 2b9b301 | 2013-10-22 17:09:38 -0500 | [diff] [blame] | 98 | MD5 is a deprecated cryptographic hash function. It has a 128-bit message |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 99 | digest and has practical known collision attacks. |