sha algos

Moderator: BarsMonster

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
User avatar
the_drag0n
Posts: 217
Joined: Thu Oct 02, 2008 6:48 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

sha algos

Post by the_drag0n » Thu Oct 02, 2008 6:59 am


kiando
Posts: 64
Joined: Thu Oct 02, 2008 7:30 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: sha algos

Post by kiando » Mon Oct 06, 2008 6:54 pm

pseudocode from http://en.wikipedia.org/wiki/Sha1

Code: Select all

Note: All variables are unsigned 32 bits and wrap modulo 232 when calculating

Initialize variables:
h0 = 0x67452301
h1 = 0xEFCDAB89
h2 = 0x98BADCFE
h3 = 0x10325476
h4 = 0xC3D2E1F0

Pre-processing:
append the bit '1' to the message
append k bits '0', where k is the minimum number ≥ 0 such that the resulting message
    length (in bits) is congruent to 448 (mod 512)
append length of message (before pre-processing), in bits, as 64-bit big-endian integer

Process the message in successive 512-bit chunks:
break message into 512-bit chunks
for each chunk
    break chunk into sixteen 32-bit big-endian words w[i], 0 <= i <= 15

    Extend the sixteen 32-bit words into eighty 32-bit words:
    for i from 16 to 79
        w[i] = (w[i-3] xor w[i-8] xor w[i-14] xor w[i-16]) leftrotate 1

    Initialize hash value for this chunk:
    a = h0
    b = h1
    c = h2
    d = h3
    e = h4

    Main loop:
    for i from 0 to 79
        if 0 ≤ i ≤ 19 then
            f = (b and c) or ((not b) and d)
            k = 0x5A827999
        else if 20 ≤ i ≤ 39
            f = b xor c xor d
            k = 0x6ED9EBA1
        else if 40 ≤ i ≤ 59
            f = (b and c) or (b and d) or (c and d)
            k = 0x8F1BBCDC
        else if 60 ≤ i ≤ 79
            f = b xor c xor d
            k = 0xCA62C1D6

        temp = (a leftrotate 5) + f + e + k + w[i]
        e = d
        d = c
        c = b leftrotate 30
        b = a
        a = temp

    Add this chunk's hash to result so far:
    h0 = h0 + a
    h1 = h1 + b 
    h2 = h2 + c
    h3 = h3 + d
    h4 = h4 + e

Produce the final hash value (big-endian):
digest = hash = h0 append h1 append h2 append h3 append h4
sha1 is coming up as md5 dies.

User avatar
BarsMonster
Site Admin
Posts: 1118
Joined: Wed Oct 01, 2008 7:58 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: sha algos

Post by BarsMonster » Tue Oct 07, 2008 11:05 am


User avatar
the_drag0n
Posts: 217
Joined: Thu Oct 02, 2008 6:48 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: sha algos

Post by the_drag0n » Tue Oct 07, 2008 11:16 am

pass : hash


sha1:

abcdef : 1f8ac10f23c5b5bc1167bda84b833e5c057a77d2
12396123479236 : 3ff7474f546401e2e15f347e895e43badc394480
a734§%&" : f785d808d6cb1026c989a2edd88c90714eb41876


sha-256:

abcdef : BEF57EC7F53A6D40BEB640A780A639C83BC29AC8A9816F1FC6C5C6DCD93C4721
12396123479236 : A7CEF10DBD19929A61DC536F3E3D45942615A8DFA7C321936D140AF01B5736F8
a734§%&" : 8D7CD8153BADFC6311B4D0F0EBB5108604B2DB44AD395FCE2FE76F469A3C585A

sha-512:

abcdef : e32ef19623e8ed9d267f657a81944b3d07adbb768518068e88435745564e8d4150a0a703be2a7d88b61e3d390c2bb97e2d4c311fdc69d6b1267f05f59aa920e7
12396123479236 : dc45f11026161aeddbcd03668cd7bb84885bd5db0f51adb804003c9050ae1a224c650723d0e165e2d51cd8dea831df0011641fc3982f00408691a6745ca530c1
a734§%&" : 8e6ed8487df2bee755c035dfc60561609f4cec04f03bc5ceac5be5ab4f2381da56a8f133d0b8deb7fd65c5e08a7785e48531b4e789ea96f135b0af162b3c2879

im sorry but i cant help with the c source code.

kiando
Posts: 64
Joined: Thu Oct 02, 2008 7:30 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: sha algos

Post by kiando » Tue Oct 07, 2008 3:08 pm

Here is a nice commented implementation:

http://www.di-mgt.com.au/src/sha1.c.txt

User avatar
BarsMonster
Site Admin
Posts: 1118
Joined: Wed Oct 01, 2008 7:58 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: sha algos

Post by BarsMonster » Tue Oct 07, 2008 3:40 pm

Are sha-1, 256 and 512 are all main types of SHA?

Sc00bz
Posts: 136
Joined: Fri Oct 03, 2008 8:28 am
Contact:

Re: sha algos

Post by Sc00bz » Tue Oct 07, 2008 9:08 pm

BarsMonster wrote:Are sha-1, 256 and 512 are all main types of SHA?
Yes, but you missed three SHA-0, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512. Well SHA-0, SHA-224, and SHA-384 are less common.

SHA-0 and SHA-1
SHA-1 fixed a weakness in SHA-0 by adding a bitwise rotation in the message schedule.

SHA-2 family is SHA-224, SHA-256, SHA-384, and SHA-512
SHA-224 is identical to SHA-256, except that:
* the initial variable values h0 through h7 are different, and
* the output is constructed by omitting h7.

SHA-512 is identical in structure, but:
* all numbers are 64 bits long,
* there are 80 rounds instead of 64,
* the initial values and additive constants are extended to 64 bits, and
* the shift and rotate amounts used are different.

SHA-384 is identical to SHA-512, except that:
* the initial values h0 through h7 are different, and
* the output is constructed by omitting h6 and h7.
Info from http://en.wikipedia.org/wiki/SHA

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 1 guest