Actor model: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>DumbBOT
removing a protection template from a non-protected page (info)
 
en>Sanspeur
m minor punctuation changes
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Infobox cryptographic hash function
Hi there! :) My name is Linnea, I'm a student studying Comparative Politics from Unterdietfurt, Germany.<br><br>Feel free to surf to my website; http://www.hostgator1centcoupon.info/ ([http://orichinese.com/groups/easy-remedies-to-assist-you-locate-good-quality-internet-hosting/ orichinese.com])
| name = SHA-2
| image =
| caption =
<!-- General -->
| designers = [[National Security Agency]]
| publish date = 2001
| series = (SHA-0), [[SHA-1]], SHA-2, [[SHA-3]]
| derived from =
| derived to =
| related to =
| certification = [[Federal Information Processing Standard|FIPS]] PUB 180-4, [[CRYPTREC]], [[NESSIE]]
<!-- Detail -->
| digest size = 224, 256, 384, or 512 bits
| structure = [[Merkle–Damgård construction]]
| rounds = 64 or 80
| cryptanalysis = A 2011 attack breaks [[preimage resistance]] for 57 out of 80 rounds of SHA-512, and 52 out of 64 rounds for SHA-256.<ref name=preimage-khov/>
Pseudo collision attack against up to 46 rounds of SHA-256.<ref name=collision-lamberger/>
}}
 
'''SHA-2''' is a set of [[cryptographic hash function]]s ('''SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256''') designed by the U.S. [[National Security Agency]] (NSA) and published in 2001 by the [[National Institute of Standards and Technology|NIST]] as a U.S. [[Federal Information Processing Standard]] (FIPS). SHA stands for [[Secure Hash Algorithm]]. SHA-2 includes a significant number of changes from its predecessor, [[SHA-1]]. SHA-2 currently consists of a set of six hash functions with [[Cryptographic_hash_function#message digest|digests]] that are 224, 256, 384 or 512 bits.
 
SHA-256 and SHA-512 are novel hash functions computed with 32 and 64-bit words, respectively. They use different shift amounts and additive constants, but their structures are otherwise virtually identical, differing only in the number of rounds. SHA-224 and SHA-384 are simply truncated versions of the first two, computed with different initial values. SHA-512/224 and SHA-512/256 are also truncated versions of SHA-512, but the initial values are generated using the method described in FIPS PUB 180-4. The SHA-2 family of algorithms are patented in {{cite patent|US|6829355}}. The [[United States]] has released the patent under a royalty-free license.<ref>{{cite journal |title=Licensing Declaration for US patent 6829355.|url=https://datatracker.ietf.org/ipr/858/|accessdate=2008-02-17}}</ref>
 
In 2005, security flaws were identified in SHA-1, namely that a mathematical weakness might exist, indicating that a stronger hash function would be desirable.<ref>{{cite web|url=http://www.schneier.com/blog/archives/2005/02/cryptanalysis_o.html |title=Schneier on Security: Cryptanalysis of SHA-1 |publisher=Schneier.com |date= |accessdate=2011-11-08}}</ref> Although SHA-2 bears some similarity to the SHA-1 algorithm, these attacks have not been successfully extended to SHA-2.
 
Currently, the best public attacks break preimage resistance 52 rounds of SHA-256 or 57 rounds of SHA-512, and collision resistance for 46 rounds of SHA-256, as shown in [[#Cryptanalysis and validation|the "Cryptanalysis and Validation"]] section below.<ref name=preimage-khov/><ref name=collision-lamberger/>
 
==Hash standard==
[[File:SHA-2.svg|thumbnail|right|400px|One iteration in a SHA-2 family compression function.
The blue components perform the following operations: <br />
<math>\operatorname{Ch}(E,F,G) = (E \and F) \oplus (\neg E \and G)</math>
<math>\operatorname{Ma}(A,B,C) = (A \and B) \oplus (A \and C) \oplus (B \and C)</math>
<math>\Sigma_0(A) = (A\!\ggg\!2) \oplus (A\!\ggg\!13) \oplus (A\!\ggg\!22)</math>
<math>\Sigma_1(E) = (E\!\ggg\!6) \oplus (E\!\ggg\!11) \oplus (E\!\ggg\!25)</math> <br />
The bitwise rotation uses different constants for SHA-512. The given numbers are for SHA-256.
The red <math>\color{red}\boxplus</math> is addition modulo 2<sup>32</sup>.
]]
 
With the publication of FIPS PUB 180-2, NIST added three additional hash functions in the SHA family. The algorithms are collectively known as SHA-2, named after their digest lengths (in bits): SHA-256, SHA-384, and SHA-512.
 
The algorithms were first published in 2001 in the draft FIPS PUB 180-2, at which time public review and comments were accepted. In August 2002, FIPS PUB 180-2 became the new [[Secure Hash Standard]], replacing FIPS PUB 180-1, which was released in April 1995. The updated standard included the original [[SHA-1]] algorithm, with updated technical notation consistent with that describing the inner workings of the SHA-2 family.<ref>Federal Register Notice 02-21599, [https://federalregister.gov/a/02-21599 Announcing Approval of FIPS Publication 180-2]</ref>
 
In February 2004, a change notice was published for FIPS PUB 180-2, specifying an additional variant, SHA-224, defined to match the key length of two-key [[Triple DES]].<ref>[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2 with Change Notice 1]</ref> In October 2008, the standard was updated in FIPS PUB 180-3, including SHA-224 from the change notice, but otherwise making no fundamental changes to the standard. The primary motivation for updating the standard was relocating security information about the hash algorithms and recommendations for their use to Special Publications 800-107 and 800-57.<ref>Federal Register Notice E8-24743, [https://federalregister.gov/a/E8-24743 Announcing Approval of FIPS Publication 180-3]</ref><ref name=sp800107>FIPS SP 800-107 [http://csrc.nist.gov/publications/nistpubs/800-107-rev1/sp800-107-rev1.pdf Recommendation for Applications Using Approved Hash Algorithms]</ref><ref name=sp80057>FIPS SP 800-57 [http://csrc.nist.gov/publications/nistpubs/800-57/sp800-57_part1_rev3_general.pdf Recommendation for Key Management: Part 1: General]</ref> Detailed test data and example message digests were also removed from the standard, and provided as separate documents.<ref>NIST Algorithm Examples, [http://csrc.nist.gov/groups/ST/toolkit/examples.html#aHashing Secure Hashing]</ref>
 
In January 2011, NIST published SP800-131A, which specified a move from the current minimum security of 80-bits (provided by SHA-1) allowable for federal government use until the end of 2013, with 112-bit security (provided by SHA-2) being the minimum requirement current thereafter, and the recommended security level from the publication date.<ref>FIPS SP 800-131A [http://csrc.nist.gov/publications/nistpubs/800-131A/sp800-131A.pdf Recommendation for Transitioning the Use of Cryptographic Algorithms and Key Lengths]</ref>
 
In March 2012, the standard was updated in FIPS PUB 180-4, adding the hash functions SHA-512/224 and SHA-512/256, and describing a method for generating initial values for truncated versions of SHA-512. Additionally, a restriction on padding the input data prior to hash calculation was removed, allowing hash data to be calculated simultaneously with content generation, such as a real-time video or audio feed. Padding the final data block must still occur prior to hash output.<ref>Federal Register Notice 2012-5400, [https://federalregister.gov/a/2012-5400 Announcing Approval of FIPS Publication 180-4]</ref>
 
In July 2012, NIST revised SP800-57, which provides guidance for cryptographic key management. The publication disallows creation of digital signatures with a hash security lower than 112-bits after 2013. The previous revision from 2007 specified the cutoff to be the end of 2010.<ref name=sp80057/> In August 2012, NIST revised SP800-107 in the same manner.<ref name=sp800107/>
 
The [[NIST hash function competition]] selected a new hash function, [[SHA-3]], in 2012.<ref name="nist.gov">[http://www.nist.gov/itl/csd/sha-100212.cfm NIST Selects Winner of Secure Hash Algorithm (SHA-3) Competition]</ref> The SHA-3 algorithm is not derived from SHA-2.
 
==Comparison of SHA functions==
In the table below, ''internal state'' means the "internal hash sum" after each compression of a data block.
{{Further|Merkle–Damgård construction}}
 
{{Comparison of SHA functions}}
 
In the bitwise operations column, "rot" stands for [[Bitwise_operation#Rotate_no_carry|rotate no carry]], and "shr" stands for [[Bitwise_operation#Logical_shift|right logical shift]].  All of these algorithms employ [[Modular_arithmetic#Other_operations|modular addition]] in some fashion except for SHA-3.
 
The performance numbers above were for a single-threaded implementation on an AMD Opteron 8354 running at 2.2&nbsp;GHz under Linux in 64-bit mode, and serve only as a rough point for general comparison. More detailed performance measurements on modern processor architectures are given in the table below.
 
{| class="wikitable"
|-
! CPU Architecture
! Frequency
! Algorithm
! Word size (bits)
! Cycles/Byte [[x86]]
! MiB/s x86
! Cycles/Byte [[x86-64]]
! MiB/s x86-64
|- style="text-align:center;"
| rowspan="2" | [[Ivy Bridge (microarchitecture)|Intel Ivy Bridge]] || rowspan="2" | 3.5&nbsp;GHz || SHA-256 || 32-bit || 16.80 || 199 || 13.05 || 256
|- style="text-align:center;"
| SHA-512 || 64-bit || 43.66 || 76 || 8.48 || 394
|- style="text-align:center;"
| rowspan="2" | [[Piledriver (microarchitecture)|AMD Piledriver]] || rowspan="2" | 3.8&nbsp;GHz || SHA-256 || 32-bit || 22.87 || 158 || 18.47 || 196
|- style="text-align:center;"
| SHA-512 || 64-bit || 88.36 || 41 || 12.43 || 292
|}
 
The performance numbers labeled 'x86' were running using 32-bit code on 64-bit processors, whereas the 'x86-64' numbers are native 64-bit code. While SHA-256 is designed for 32-bit calculations, it does benefit from code optimized for 64-bit processors. 32-bit implementations of SHA-512 are significantly slower than their 64-bit counterparts. Variants of both algorithms with different output sizes will perform similarly, since the message expansion and compression functions are identical, and only the initial hash values and output sizes are different. The best implementations of MD5 and SHA-1 perform between 4.5 and 6 cycles per byte on modern processors.
 
Testing was performed by the [[University of Illinois at Chicago]] on their hydra8 system running an Intel Xeon E3-1275 V2 at a clock speed of 3.5&nbsp;GHz, and on their hydra9 system running an AMD A10-5800K at a clock speed of 3.8&nbsp;GHz.<ref>SUPERCOP Benchmarks [http://bench.cr.yp.to/results-hash.html Measurements of hash functions, indexed by machine]</ref> The referenced cycles per byte speeds above are the median performance of an algorithm digesting a 4096 byte message using the SUPERCOP cryptographic benchmarking software.<ref>[http://bench.cr.yp.to/supercop.html SUPERCOP Benchmarking Toolkit]</ref> The MiB/s performance is extrapolated from the CPU clockspeed on a single core, real world performance will vary due to a variety of factors.
 
==Applications==
{{details|Cryptographic hash function#Applications}}
The SHA-2 hash function is implemented in some widely used security applications and protocols, including [[Transport Layer Security|TLS]] and [[Secure Sockets Layer|SSL]], [[Pretty Good Privacy|PGP]], [[Secure Shell|SSH]], [[S/MIME]], [[Bitcoin]] and [[IPsec]].
 
Several [[cryptocurrency|cryptocurrencies]] use SHA-2 as part of their [[proof-of-work]] scheme. Bitcoin was the first to do this by using [[Hashcash]] with a double round of SHA-256 at its core. The rise of [[ASIC]] SHA-2 accelerator chips used in cryptocurrency mining has led to the use of [[scrypt]] based proof-of-work schemes for many alternative cryptocurrencies. SHA-256 is used to authenticate [[Debian GNU/Linux]] software packages<ref>{{cite web|url=http://google.com/codesearch/p?hl=en#nywQboHfkw4/apt/apt-pkg/acquire-item.cc&q=SHA256 |title=Debian codebase in Google Code |publisher=Google |date= |accessdate=2011-11-08}}{{dead link|date=November 2012}}</ref> and in the [[DKIM]] message signing standard; SHA-512 is part of a system to authenticate archival video from the [[International Criminal Tribunal for Rwanda|International Criminal Tribunal of the Rwandan genocide]].<ref>John Markoff, [http://www.nytimes.com/2009/01/27/science/27arch.html A Tool to Verify Digital Records, Even as Technology Shifts], ''New York Times'', January 26, 2009</ref> SHA-256 and SHA-512 are proposed for use in [[DNSSEC]].<ref>RFC 5702,[http://www.rfc-editor.org/rfc/rfc5702.txt RFC-Editor.org]</ref> Unix and Linux vendors are moving to using 256- and 512-bit SHA-2 for secure password hashing.<ref>Ulrich Drepper, [http://people.redhat.com/drepper/sha-crypt.html Unix crypt with SHA-256/512]</ref>
 
SHA-1 and SHA-2 are the secure hash algorithms required by law for use in certain [[U.S. Government]] applications, including use within other cryptographic algorithms and protocols, for the protection of sensitive unclassified information. FIPS PUB 180-1 also encouraged adoption and use of SHA-1 by private and commercial organizations. SHA-1 is being retired for most government uses; the U.S. National Institute of Standards and Technology says, "Federal agencies '''''should''''' stop using SHA-1 for...applications that require collision resistance as soon as practical, and must use the SHA-2 family of hash functions for these applications after 2010" (emphasis in original).<ref>National Institute on Standards and Technology Computer Security Resource Center, [http://csrc.nist.gov/groups/ST/hash/policy.html NIST's Policy on Hash Functions], accessed March 29, 2009.</ref> NIST's directive that U.S. government agencies must stop uses of SHA-1 after 2010<ref>{{cite web
| url=http://csrc.nist.gov/groups/ST/toolkit/secure_hashing.html
| title=Secure Hashing - NIST Computer Security Division - Computer Security Resource Center
| work=[[NIST]]
| accessdate=2010-11-25 }}
</ref> and the completion of SHA-3<ref name="nist.gov"/> may accelerate migration away from SHA-1.
 
The SHA-2 functions are not as widely used as SHA-1, despite their better security. Reasons might include lack of support for SHA-2 on systems running Windows XP SP2 or older,<ref>Microsoft Corporation,[http://download.microsoft.com/download/6/8/7/687484ed-8174-496d-8db9-f02b40c12982/Overview%20of%20Windows%20XP%20Service%20Pack%203.pdf Overview of Windows XP Service Pack 3]</ref> or a lack of perceived urgency since SHA-1 collisions have not yet been found.
 
==Cryptanalysis and validation==
For a hash function for which ''L'' is the number of [[bit]]s in the [[message digest]], finding a message that corresponds to a given message digest can always be done using a [[Brute-force attack|brute force]] search in 2<sup>''L''</sup> evaluations. This is called a [[preimage attack]] and may or may not be practical depending on ''L'' and the particular computing environment. The second criterion, finding two different messages that produce the same message digest, known as a [[Collision (computer science)|collision]], requires on average only 2<sup>''L''/2</sup> evaluations using a [[birthday attack]].
 
Some of the applications that use cryptographic hashes, such as password storage, are only minimally affected by a [[collision attack]]. Constructing a password that works for a given account requires a preimage attack, as well as access to the hash of the original password (typically in the <tt>[[Shadow password|shadow]]</tt> file) which may or may not be trivial. Reversing password encryption (e.g., to obtain a password to try against a user's account elsewhere) is not made possible by the attacks. (However, even a secure password hash cannot prevent brute-force attacks on [[password strength|weak passwords]].)
 
In the case of document signing, an attacker could not simply fake a signature from an existing document—the attacker would have to produce a pair of documents, one innocuous and one damaging, and get the private key holder to sign the innocuous document. There are practical circumstances in which this is possible; until the end of 2008, it was possible to create forged [[Transport Layer Security|SSL]] certificates using a [[MD5]] collision.<ref>Alexander Sotirov, Marc Stevens,
Jacob Appelbaum, Arjen Lenstra, David Molnar, Dag Arne Osvik, Benne de Weger, [http://www.win.tue.nl/hashclash/rogue-ca/ MD5 considered harmful today: Creating a rogue CA certificate], accessed March 29, 2009.</ref>
 
Increased interest in cryptographic hash analysis during the SHA-3 competition produced several new attacks on the SHA-2 family, the best of which are given in the table below. Only the collision attacks are of practical complexity; none of the attacks extend to the full round hash function.
At [[Fast Software Encryption|FSE]] 2012, researchers at [[Sony]] gave a presentation suggesting pseudo collision attacks could be extended to 52 rounds on SHA-256 and 57 rounds on SHA-512 by building upon the biclique pseudo preimage attack.<ref>Ji Li, Takanori Isobe and Kyoji Shibutani, Sony China Research Laboratory and Sony Corporation, [http://fse2012.inria.fr/SLIDES/67.pdf Converting Meet-in-the-Middle Preimage Attack into Pseudo Collision Attack: Application to SHA-2 ]</ref>
 
{| class="wikitable"
|-
! Published in
! Year
! Attack Method
! Attack
! Variant
! Rounds
! Complexity
 
|- style="text-align:center;"
| rowspan="2" | New Collision attacks Against<br>Up To 24-step SHA-2 <ref name=collision-sanadhya>{{Cite journal | author=Somitra Kumar Sanadhya and Palash Sarkar | year=2008 | title=New Collision attacks Against Up To 24-step SHA-2 | journal=IACR Cryptology ePrint Archive | volume=2008:270 | url=http://eprint.iacr.org/2008/270.pdf}}</ref> || rowspan="2" | 2008 || rowspan="2" | Deterministic || rowspan="2" | Collision || SHA-256 || 24/64 || 2<sup>28.5</sup>
|- style="text-align:center;"
| SHA-512 || 24/80 || 2<sup>32.5</sup>
 
|- style="text-align:center;"
| rowspan="4" | Preimages for step-reduced SHA-2 <ref name=preimage-merged>{{Cite journal | author=Kazumaro Aoki, Jian Guo, Krystian Matusiewicz, Yu Sasaki, and Lei Wang | title=Preimages for step-reduced SHA-2 | year=2009 | journal=Advances in Cryptology - [[ASIACRYPT]] 2009 | series=Lecture Notes in Computer Science | volume=5912 | pages=578–597 | publisher=Springer Berlin Heidelberg | doi=10.1007/978-3-642-10366-7_34 | isbn=978-3-642-10366-7 | issn=0302-9743 | url=http://link.springer.com/chapter/10.1007%2F978-3-642-10366-7_34}}</ref> || rowspan="4" | 2009 || rowspan="4" | Meet-in-the-middle || rowspan="4" | Preimage || rowspan="2" | SHA-256 || 42/64 || 2<sup>251.7</sup>
|- style="text-align:center;"
| 43/64 || 2<sup>254.9</sup>
|- style="text-align:center;"
| rowspan="2" | SHA-512 || 42/80 || 2<sup>502.3</sup>
|- style="text-align:center;"
| 46/80 || 2<sup>511.5</sup>
 
|- style="text-align:center;"
| rowspan="2" | Advanced meet-in-the-middle<br>preimage attacks <ref name=preimage-gou>{{Cite journal | author=Jian Guo, San Ling, Christian Rechberger, and Huaxiong Wang | title=Advanced meet-in-the-middle preimage attacks&#58; First results on full Tiger, and improved results on MD4 and SHA-2 | year=2010 | journal=Advances in Cryptology - [[ASIACRYPT]] 2010 | series=Lecture Notes in Computer Science | volume=6477 | pages=56–75 | publisher=Springer Berlin Heidelberg | doi=10.1007/978-3-642-17373-8_4 | isbn=978-3-642-17373-8 | issn=0302-9743 | url=http://eprint.iacr.org/2010/016.pdf}}</ref> || rowspan="2" | 2010 || rowspan="2" | Meet-in-the-middle || rowspan="2" | Preimage || SHA-256 || 42/64 || 2<sup>248.4</sup>
|- style="text-align:center;"
| SHA-512 || 42/80 || 2<sup>494.6</sup>
 
|- style="text-align:center;"
| rowspan="2" | Higher-Order Differential Attack<br>on Reduced SHA-256 <ref name=collision-lamberger>{{Cite journal | author=Mario Lamberger and Florian Mendel | title=Higher-Order Differential Attack on Reduced SHA-256 | year=2011 | journal=IACR Cryptology ePrint Archive | volume=2011:37 | url=http://eprint.iacr.org/2011/037.pdf}}</ref> || rowspan="2" | 2011 || rowspan="2" | Differential || rowspan="2" | Pseudo Collision || rowspan="2" | SHA-256 || 46/64 || 2<sup>178</sup>
|- style="text-align:center;"
| 46/64 || 2<sup>46</sup>
 
|- style="text-align:center;"
| rowspan="4" | Bicliques for Preimages&#58; Attacks on<br>Skein-512 and the SHA-2 family <ref name=preimage-khov>{{Cite journal | author=Dmitry Khovratovich, Christian Rechberger and Alexandra Savelieva | title=Bicliques for Preimages&#58; Attacks on Skein-512 and the SHA-2 family | year=2011 | journal=IACR Cryptology ePrint Archive | volume=2011:286 | url=http://eprint.iacr.org/2011/286.pdf}}</ref> || rowspan="4" | 2011 || rowspan="4" | Biclique || rowspan="2" | Preimage || SHA-256 || 45/64 || 2<sup>255.5</sup>
|- style="text-align:center;"
| SHA-512 || 50/80 || 2<sup>511.5</sup>
|- style="text-align:center;"
| rowspan="2" | Pseudo Preimage || SHA-256 || 52/64 || 2<sup>255</sup>
|- style="text-align:center;"
| SHA-512 || 57/80 || 2<sup>511</sup>
|}
 
===Official validation===
{{Main|Cryptographic Module Validation Program}}
Implementations of all FIPS-approved security functions can be officially validated through the [[Cryptographic Module Validation Program|CMVP program]], jointly run by the [[National Institute of Standards and Technology]] (NIST) and the [[Communications Security Establishment]] (CSE). For informal verification, a package to generate a high number of test vectors is made available for download on the NIST site; the resulting verification however does not replace, in any way, the formal CMVP validation, which is required by law for certain applications.
 
{{As of|2013|alt=As of December 2013}}, there are over 1300 validated implementations of SHA-256 and over 900 of SHA-512, with only 5 of them being capable of handling messages with a length in bits not a multiple of eight while supporting both variants (see [http://csrc.nist.gov/groups/STM/cavp/documents/shs/shaval.htm SHS Validation List]).
 
==Examples of SHA-2 variants==
Hash values of empty string.
<span style="color: green;">SHA224("")
0x d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f</span>
<span style="color: green;">SHA256("")
0x e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855</span>
<span style="color: green;">SHA384("")
0x 38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b</span>
<span style="color: green;">SHA512("")
0x cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e</span>
<span style="color: green;">SHA512/224("")
0x 6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4</span>
<span style="color: green;">SHA512/256("")
0x c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a</span>
 
Even a small change in the message will (with overwhelming probability) result in a mostly different hash, due to the [[avalanche effect]]. For example, adding a period to the end of the sentence:
<span style="color: green;">SHA224("The quick brown fox jumps over the lazy dog")
0x 730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525</span>
<span style="color: green;">SHA224("The quick brown fox jumps over the lazy dog.")
0x 619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4c</span>
<span style="color: green;">SHA256("The quick brown fox jumps over the lazy dog")
0x d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592</span>
<span style="color: green;">SHA256("The quick brown fox jumps over the lazy dog.")
0x ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c</span>
<span style="color: green;">SHA384("The quick brown fox jumps over the lazy dog")
0x ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1</span>
<span style="color: green;">SHA384("The quick brown fox jumps over the lazy dog.")
0x ed892481d8272ca6df370bf706e4d7bc1b5739fa2177aae6c50e946678718fc67a7af2819a021c2fc34e91bdb63409d7</span>
<span style="color: green;">SHA512("The quick brown fox jumps over the lazy dog")
0x 07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6</span>
<span style="color: green;">SHA512("The quick brown fox jumps over the lazy dog.")
0x 91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed</span>
<span style="color: green;">SHA512/224("The quick brown fox jumps over the lazy dog")
0x 944cd2847fb54558d4775db0485a50003111c8e5daa63fe722c6aa37</span>
<span style="color: green;">SHA512/224("The quick brown fox jumps over the lazy dog.")
0x 6d6a9279495ec4061769752e7ff9c68b6b0b3c5a281b7917ce0572de</span>
<span style="color: green;">SHA512/256("The quick brown fox jumps over the lazy dog")
0x dd9d67b371519c339ed8dbd25af90e976a1eeefd4ad3d889005e532fc5bef04d</span>
<span style="color: green;">SHA512/256("The quick brown fox jumps over the lazy dog.")
0x 1546741840f8a492b959d9b8b2344b9b0eb51b004bba35c0aebaac86d45264c3</span>
 
==Pseudocode==
[[Pseudocode]] for the SHA-256 algorithm follows. Note the great increase in mixing between bits of the <code>w&#91;16..63&#93;</code> words compared to SHA-1.
 
<span style="color: green;">''Note 1: All variables are 32 bit unsigned integers and addition is calculated modulo 2<sup>32</sup>''</span>
<span style="color: green;">''Note 2: For each round, there is one round constant k&#91;i&#93; and one entry in the message schedule array w&#91;i&#93;, 0 ≤ i ≤ 63''</span>
<span style="color: green;">''Note 3: The compression function uses 8 working variables, a through h</span>
<span style="color: green;">''Note 4: Big-endian convention is used when expressing the constants in this pseudocode,''</span>
    <span style="color: green;">''and when parsing message block data from bytes to words, for example,''</span>
    <span style="color: green;">''the first word of the input message "abc" after padding is 0x61626380''</span>
<span style="color:green;">''Initialize hash values:''</span>
<span style="color:green;">(first 32 bits of the <em>fractional parts<em> of the square roots of the first 8 primes 2..19):</span>
h0 := 0x6a09e667
h1 := 0xbb67ae85
h2 := 0x3c6ef372
h3 := 0xa54ff53a
h4 := 0x510e527f
h5 := 0x9b05688c
h6 := 0x1f83d9ab
h7 := 0x5be0cd19
<span style="color:green;">''Initialize array of round constants:''</span>
<span style="color:green;">(first 32 bits of the ''fractional parts'' of the cube roots of the first 64 primes 2..311):</span>
k&#91;0..63&#93; :=
    0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
    0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
    0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
    0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
    0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
    0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
    0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
    0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
<span style="color:green;">''Pre-processing:''</span>
append the bit '1' to the message
append k bits '0', where k is the minimum number >= 0 such that the resulting message
    length (modulo 512 in ''bits'') is 448.
append length of message (without the '1' bit or padding), in ''bits'', as 64-bit big-endian integer
    (this will make the entire post-processed length a multiple of 512 bits)
<span style="color:green;">''Process the message in successive 512-bit chunks:''</span>
break message into 512-bit chunks
'''for''' each chunk
    create a 64-entry message schedule array w&#91;0..63&#93; of 32-bit words
    <span style="color:green;">''(The initial values in w&#91;0..63&#93; don't matter, so many implementations zero them here)''</span>
    copy chunk into first 16 words w[0..15] of the message schedule array
    <span style="color:green;">''Extend the first 16 words into the remaining 48 words w&#91;16..63&#93; of the message schedule array:''</span>
    '''for''' i '''from''' 16 to 63
        s0 := (w&#91;i-15&#93; '''rightrotate''' 7) '''xor''' (w&#91;i-15&#93; '''rightrotate''' 18) '''xor''' (w&#91;i-15&#93; '''rightshift''' 3)
        s1 := (w&#91;i-2&#93; '''rightrotate''' 17) '''xor''' (w&#91;i-2&#93; '''rightrotate''' 19) '''xor''' (w&#91;i-2&#93; '''rightshift''' 10)
        w&#91;i&#93; := w&#91;i-16&#93; '''+''' s0 '''+''' w&#91;i-7&#93; '''+''' s1
    <span style="color:green;">''Initialize working variables to current hash value:''</span>
    a := h0
    b := h1
    c := h2
    d := h3
    e := h4
    f := h5
    g := h6
    h := h7
    <span style="color:green;">''Compression function main loop:''</span>
    '''for''' i '''from''' 0 to 63
        S1 := (e '''rightrotate''' 6) '''xor''' (e '''rightrotate''' 11) '''xor''' (e '''rightrotate''' 25)
        ch := (e '''and''' f) '''xor''' (('''not''' e) '''and''' g)
        temp1 := h '''+''' S1 '''+''' ch '''+''' k&#91;i&#93; '''+''' w&#91;i&#93;
        S0 := (a '''rightrotate''' 2) '''xor''' (a '''rightrotate''' 13) '''xor''' (a '''rightrotate''' 22)
        maj := (a '''and''' b) '''xor''' (a '''and''' c) '''xor''' (b '''and''' c)
        temp2 := S0 '''+''' maj
 
        h := g
        g := f
        f := e
        e := d '''+''' temp1
        d := c
        c := b
        b := a
        {{not a typo|a}} := temp1 '''+''' temp2
    <span style="color:green;">''Add the compressed chunk to the current hash value:''</span>
    h0 := h0 '''+''' a
    h1 := h1 '''+''' b
    h2 := h2 '''+''' c
    h3 := h3 '''+''' d
    h4 := h4 '''+''' e
    h5 := h5 '''+''' f
    h6 := h6 '''+''' g
    h7 := h7 '''+''' h
<span style="color:green;">''Produce the final hash value (big-endian):''</span>
digest := hash := h0 '''append''' h1 '''append''' h2 '''append''' h3 '''append''' h4 '''append''' h5 '''append''' h6 '''append''' h7
 
The computation of the <code>ch</code> and <code>maj</code> values can be optimized the same way [[SHA-1#SHA-1 pseudocode|as described for SHA-1]].
 
SHA-224 is identical to SHA-256, except that:
* the initial hash values <code>h0</code> through <code>h7</code> are different, and
* the output is constructed by omitting <code>h7</code>.
<span style="color:green;">SHA-224 initial hash values (in big endian):</span>
<span style="color:green;">(The second 32 bits of the fractional parts of the square roots of the 9th through 16th primes 23..53)</span>
h&#91;0..7&#93; :=
    0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
 
SHA-512 is identical in structure to SHA-256, but:
* the message is broken into 1024-bit chunks,
* the initial hash values and round constants are extended to 64 bits,
* there are 80 rounds instead of 64,
* the round constants are based on the first 80 primes 2..409,
* the word size used for calculations is 64 bits long,
* the appended length of the message (before pre-processing), in ''bits'', is a 128-bit big-endian integer, and
* the shift and rotate amounts used are different.
 
<span style="color:green;">SHA-512 initial hash values (in big-endian):</span>
<span style="color:green;"></span>
h&#91;0..7&#93; := 0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
            0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179
<span style="color:green;">SHA-512 round constants:</span>
<span style="color:green;"></span>
k&#91;0..79&#93; := [ 0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, 0x3956c25bf348b538,
              0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, 0xd807aa98a3030242, 0x12835b0145706fbe,
              0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235,
              0xc19bf174cf692694, 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,
              0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, 0x983e5152ee66dfab,
              0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4, 0xc6e00bf33da88fc2, 0xd5a79147930aa725,
              0x06ca6351e003826f, 0x142929670a0e6e70, 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed,
              0x53380d139d95b3df, 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b,
              0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30, 0xd192e819d6ef5218,
              0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8, 0x19a4c116b8d2d0c8, 0x1e376c085141ab53,
              0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373,
              0x682e6ff3d6b2b8a3, 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec,
              0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b, 0xca273eceea26619c,
              0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178, 0x06f067aa72176fba, 0x0a637dc5a2c898a6,
              0x113f9804bef90dae, 0x1b710b35131c471b, 0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc,
              0x431d67c49c100d4c, 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817]
<span style="color:green;">SHA-512 Sum & Sigma:</span>
<span style="color:green;"></span>
S0 := (a '''rightrotate''' 28) '''xor''' (a '''rightrotate''' 34) '''xor''' (a '''rightrotate''' 39)
S1 := (e '''rightrotate''' 14) '''xor''' (e '''rightrotate''' 18) '''xor''' (e '''rightrotate''' 41)
<span style="color:green;"></span>
s0 := (w&#91;i-15&#93; '''rightrotate''' 1) '''xor''' (w&#91;i-15&#93; '''rightrotate''' 8) '''xor''' (w&#91;i-15&#93; '''rightshift''' 7)
s1 := (w&#91;i-2&#93; '''rightrotate''' 19) '''xor''' (w&#91;i-2&#93; '''rightrotate''' 61) '''xor''' (w&#91;i-2&#93; '''rightshift''' 6)
 
SHA-384 is identical to SHA-512, except that:
* the initial hash values <code>h0</code> through <code>h7</code> are different (taken from the 9th through 16th primes), and
* the output is constructed by omitting <code>h6</code> and <code>h7</code>.
<span style="color:green;">SHA-384 initial hash values (in big-endian):</span>
<span style="color:green;"></span>
h&#91;0..7&#93; := 0xcbbb9d5dc1059ed8, 0x629a292a367cd507, 0x9159015a3070dd17, 0x152fecd8f70e5939,
            0x67332667ffc00b31, 0x8eb44a8768581511, 0xdb0c2e0d64f98fa7, 0x47b5481dbefa4fa4
 
SHA-512/t is identical to SHA-512 except that:
* the initial hash values <code>h0</code> through <code>h7</code> are given by the ''SHA-512/t IV generation function'',
* the output is constructed by truncating the concatenation of <code>h0</code> through <code>h7</code> at ''t'' bits,
* ''t'' equal to 384 is not allowed, instead SHA-384 should be used as specified, and
* ''t'' values 224 and 256 are especially mentioned as approved.
 
==Implementations==
 
===Implementations in common languages===
SHA hashing functions are found in many modern programming languages, such as [[C]], [[C++]], [[C Sharp (programming language)|C#]], [[Go (programming language)|Go]],<ref>{{cite web |url=http://golang.org/src/pkg/crypto/sha256/ |title=The Go Programming Language |deadurl=no |accessdate=2013-02-04}}</ref> [[Javascript]], [[Java (programming language)|Java]],<ref>{{cite web |url=https://www.owasp.org/index.php/Hashing_Java#Complete_Java_Sample |title=Hashing Java |publisher=OWASP |date= |accessdate=2011-11-08}}</ref> [[Python (programming language)|Python]],<ref>{{cite web|url=http://docs.python.org/library/hashlib.html |title=14.1. hashlib — Secure hashes and message digests — Python v2.7.2 documentation |publisher=Docs.python.org |date= |accessdate=2011-11-08}}</ref> [[PHP]],<ref>{{cite web|url=http://php.net/manual/en/function.hash.php |title=hash - Manual |publisher=PHP |date=2011-11-04 |accessdate=2011-11-08}}</ref> [[Perl]],<ref>{{cite web|url=http://metacpan.org/pod/Digest::SHA |title=Digest::SHA |publisher=metacpan.org |date= |accessdate=2013-12-09}}</ref> and [[Ruby (programming language)|Ruby]].<ref>{{cite web|url=http://ruby-doc.org/stdlib-2.0.0/libdoc/digest/rdoc/Digest.html |title=Module: Digest |publisher=Ruby |date= |accessdate=2013-10-14}}</ref>
 
===Other implementations===
<!-- This section should include only implementations that are commercially or algorithmically significant, such as those widely used in existing technologies and platforms -->
;[[Bouncy Castle (cryptography)|Bouncy Castle]]: The Bouncy Castle Library is a free Java and C# class library that contains implementations of the SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512 algorithms as well as other algorithms like [[Whirlpool (cryptography)|Whirlpool]], [[Tiger (hash)|Tiger]], [[RIPEMD]], [[GOST (hash function)|GOST-3411]], [[MD2 (cryptography)|MD2]], [[MD4]] and [[MD5]].
;[[cryptlib]]: an [[open source]] cross-platform software security toolkit library.
;[[Crypto++]]: An open source, permissively licensed, C++ class library of cryptographic schemes, including implementations of the SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 algorithms.
;[[jsSHA]]: A cross-browser [[JavaScript]] library for client-side calculation of SHA digests. jsSHA works around the fact that JavaScript does not natively support the 64-bit operations required for SHA-384 and SHA-512.
;[[libsparkcrypto]]: A formally verified implementation of several widely used symmetric cryptographic algorithms using the SPARK programming language and toolset, complete library proofs of the absence of run-time errors like type range violations, division by zero and numerical overflows are available.
;[[LibTomCrypt]]: A portable ISO C cryptographic toolkit, Public Domain.
;[[Libgcrypt]]: A general purpose cryptographic library based on the code from [[GNU Privacy Guard]].
;[[md5deep]]: A set of programs to compute MD5, SHA-1, SHA-256, Tiger, or Whirlpool cryptographic message digests on an arbitrary number of files. It is used in computer security, system administration and computer forensics communities for purposes of running large numbers of files through any of several different cryptographic digests. It is similar to [[sha1sum]] from [[GNU Core Utilities]] and [[md5sum]].
;[[OpenSSL]]: The widely used OpenSSL <code>crypto</code> library includes [[free software|free]], [[open source|open-source]]&nbsp;– implementations of SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512.
;[[PolarSSL]]: The small PolarSSL <code>crypto</code> and <code>SSL</code> library includes [[open source|open-source]] – implementations of SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512.
;[[sphlib]]: A free, [[open source|open-source]] library which implements many hash functions, including SHA-1 and SHA-2, both in portable (but optimized) C and in Java.
;[[VHDL (cryptography)|VHDL]]: A free, [[open source|open-source]] collection of hardware implementations of hash functions (including SHA-1 and SHA-2) in portable (but optimized) VHDL.
 
==See also==
{{Portal|Cryptography}}
* [[Comparison of cryptographic hash functions]]
* [[Digital timestamping]]
* [[HMAC|Hash based Message Authentication Code (HMAC) or Keyed Hash]]
* [[Hashcash]]
* [[International Association for Cryptologic Research]] (IACR)
* <tt>[[sha1sum]]</tt> (<tt>sha224sum</tt>, <tt>sha256sum</tt>, <tt>sha384sum</tt> and <tt>sha512sum</tt>) commands
* [[scrypt]]
 
==Notes==
{{Reflist|colwidth=30em}}
 
==References==
{{refbegin|colwidth=30em}}
* Henri Gilbert, Helena Handschuh: Security Analysis of SHA-256 and Sisters. [[Selected Areas in Cryptography]] 2003: pp175–193
* {{cite journal|title=Proposed Revision of Federal Information Processing Standard (FIPS) 180, Secure Hash Standard|journal=Federal Register|date=1994-07-11|first=|last=|coauthors=|volume=59|issue=131|pages=35317–35318|id= |url=http://frwebgate1.access.gpo.gov/cgi-bin/waisgate.cgi?WAISdocID=5963452267+0+0+0&WAISaction=retrieve|format=|accessdate=2007-04-26}}
{{refend}}
 
==External links==
<!-- We suffer from a lot of self promotion here.
--- Please do not add a link to your own site. See http://en.wikipedia.org/w/index.php?title=WP:COI
--- It will be removed, and you may be blocked without further warning. -->
* [http://csrc.nist.gov/groups/STM/cavp/documents/shs/sha256-384-512.pdf Descriptions of SHA-256, SHA-384, and SHA-512] from [[National Institute of Standards and Technology|NIST]]
* [http://www.eff.org/Privacy/Digital_signature/?f=fips_sha_shs.standard.txt Specifications for a Secure Hash Standard (SHS)] – Draft for proposed SHS (SHA-0)
* [http://www.eff.org/Privacy/Digital_signature/?f=fips_sha_shs.info.txt Secure Hash Standard (SHS)] – Proposed SHS (SHA-0)
* [http://csrc.nist.gov/CryptoToolkit/tkhash.html CSRC Cryptographic Toolkit] – Official [[National Institute of Standards and Technology|NIST]] site for the Secure Hash Standard
** [http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf FIPS 180-4: Secure Hash Standard (SHS)] ([[Portable Document Format|PDF]], 1.7 MB) – Current version of the Secure Hash Standard (SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512), March 2012
* [https://www.cosic.esat.kuleuven.be/nessie/testvectors/hash/sha/index.html Test vectors for SHA-256/384/512] from the [[NESSIE]] project
* [http://csrc.nist.gov/groups/STM/cavp/index.html#03 Test vectors for SHA-1, SHA-2] from [[National Institute of Standards and Technology|NIST]] site
* [http://www.csrc.nist.gov/groups/ST/hash/index.html NIST Cryptographic Hash Project] SHA-3 competition
* RFC 3874: A 224-bit One-way Hash Function: SHA-224.
* RFC 6234: US Secure Hash Algorithms SHA and SHA-based HMAC and HKDF. Contains sample C implementation.
 
 
{{Cryptography navbox|hash}}
 
{{DEFAULTSORT:Sha-2}}
[[Category:Cryptographic hash functions]]
[[Category:Articles with example pseudocode]]
[[Category:Checksum algorithms]]

Latest revision as of 17:30, 3 January 2015

Hi there! :) My name is Linnea, I'm a student studying Comparative Politics from Unterdietfurt, Germany.

Feel free to surf to my website; http://www.hostgator1centcoupon.info/ (orichinese.com)