Stampa:Infobox cryptographic hash function

Ne kriptografi, SHA-1 është një funksion hash kriptografik dizajnuar prej National Security Agency te shteteve te bashkuara te Amerikës (SHBA) dhe është Standardi për Procesimin e Informatave Shtetërore publikuar nga NIST.[1]

SHA-1 gjeneron një vlere 160-bit (20-byte) për hash. Vlera e SHA-1 hash-it, zakonisht është e dhëne si numër hexadecimal, 40 karaktere i gjate.

SHA është akronim për "algoritëm hash për siguri". Katër SHA algoritmet janë strukturuar ne mënyra te ndryshme dhe janë emëruar SHA-0, SHA-1, SHA-2, dhe SHA-3. SHA-0 është versioni origjinal 160-bit i HASH funksionit, publikuar me 1993 i emëruar si "SHA": nuk u adoptua nga shume aplikacione. Publikuar me 1995, SHA-1 është shume i ngjashëm me SHA-0, por ndryshon origjinalin SHA hashin dhe rregullon specifikat duke permisuar dobësitë. SHA-2, i publikuar me 2001, është i ndryshëm prej SHA-1 funksionit. SHA-1 është me i përdoruri dhe me i përhapuri nga SHA hash funksionet, dhe është i përfshire ne shume aplikacione dhe protokole qe përdoren. Me 2005, kriptoanalistet zbuluan një sulm ne SHA-1 duke propozuar se algoritmi nuk është i sigurt sa duhet për përdorim te mëtutjeshëm.[2] NIST kërkoi se shume aplikacione te agjencisë federale te kalojnë ne SHA-2 pasi qe ne 2010 u zbulua ajo dobesi.[3] Edhe pse as një sulm nuk është raportuar te ketë pasur sukses ne SHA-2, pasi qe algoritmi i tij ka ngjashmëri me SHA-1. Me 2012, pas një konkurrence te gjate NIST zgjodhi algoritmin Keccak, për standardizim ne vend te SHA-3.[4][5] Ne nëntor te vitit 2013 Microsoft paraqiti politiken e tij ne SHA-1 bazuar ne ketë Windows-i nuk do i pranoj me certifikatat e SHA-1 ne SSL me 2017.[6] Ne shtator 2014Google paraqiti politikat e saj për SHA-1 sipas saj Chrome do vazhdoj ti pranoj SHA-1 certifikatat me SSL edhe gjate pas 2017[7] Mozillagjithashtu po planifikon te ndaloj pranimin e SHA-1-certifikatave me SSL rreth vitit 2017.[8][9][10]

SHA-1 hash funksioni Redakto

 
One iteration within the SHA-1 compression function:
A, B, C, D and E are 32-bit words of the state;
F is a nonlinear function that varies;
 n denotes a left bit rotation by n places;
n varies for each operation;
Wt is the expanded message word of round t;
Kt is the round constant of round t;
  denotes addition modulo 232.

SHA-1 krijon një tretje te mesazhit bazuar ne principe te ngjashme te përdorura nga Ronald L. Rivest prej MIT ne dizajnimin e MD4 dhe MD5 algoritmeve për tretës se tekstit, por ka një dizajnë me te kujdesshëm. Specifikimi origjinal i algoritmit është publikuar me 1993 me titullin "Secure Hash Standard" , FIPS PUB 180, me standarde te qeverise nga agjencia NIST(Instituti Nacional p për Standarde Teknologjike). Ky version shpesh emërohet si SHA-0.

Aplikimet Redakto

Shembuj te kodimit Redakto

Shembuj te hasheve Redakto

Këta janë shembuj te SHA-1 tretësit se mesazhit ne hexadecimal dhe ne Base64 binar ne ASCII enkodim te tekstit.

SHA1("The quick brown fox jumps over the lazy dog")
gives hexadecimal: 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
gives Base64 binary to ASCII text encoding: L9ThxnotKPzthJ7hu3bnORuT6xI=

Edhe një ndryshim i vogël ne mesazh do te bej ndryshime te mëdha ne rezultat, duke bere komplet një hash kodit tjetër. Për shembull duke ndryshuar dog to cog krijon një hash me diference prej me shume se 81 prej 160:

SHA1("The quick brown fox jumps over the lazy cog")
gives hexadecimal: de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3
gives Base64 binary to ASCII text encoding: 3p8sf9JeGzr60+haC9F9mxANtLM=

Hashi i teksti pa asnjë karakter është :

SHA1("")
gives hexadecimal: da39a3ee5e6b4b0d3255bfef95601890afd80709
gives Base64 binary to ASCII text encoding: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=

SHA-1 Kodimi Redakto

Kodi për SHA-1 algoritmin është:

Note 1: All variables are unsigned 32 bits and wrap modulo 232 when calculating, except
        ml the message length which is 64 bits, and
        hh the message digest which is 160 bits.
Note 2: All constants in this pseudo code are in big endian.
        Within each word, the most significant byte is stored in the leftmost byte position

Initialize variables:

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

ml = message length in bits (always a multiple of the number of bits in a character).

Pre-processing:
append the bit '1' to the message i.e. by adding 0x80 if characters are 8 bits. 
append 0 ≤ k < 512 bits '0', thus the resulting message length (in bits)
   is congruent to 448 (mod 512)
append ml, in a 64-bit big-endian integer. So now the message length is a multiple of 512 bits.

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:[11]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) as a 160 bit number:
hh = (h0 leftshift 128) or (h1 leftshift 96) or (h2 leftshift 64) or (h3 leftshift 32) or h4

Numri hh ne mesazh është mbetje, e cila mund te shkruhet ne forme heksadecimale(base 16), por me se shpeshti shkruhet si Base64 binar me enkodimin ne ASCII tekst.

Ne vende te formulimit origjinal te FIPS PUB 180-1 , funksione te ngjashme mund te paraqiten per gjetjen e f ne unazën kryesore sipër.

(0  ≤ i ≤ 19): f = d xor (b and (c xor d))                (alternative 1)
(0  ≤ i ≤ 19): f = (b and c) xor ((not b) and d)          (alternative 2)
(0  ≤ i ≤ 19): f = (b and c) + ((not b) and d)            (alternative 3)
(0  ≤ i ≤ 19): f = vec_sel(d, c, b)                       (alternative 4)
 
(40 ≤ i ≤ 59): f = (b and c) or (d and (b or c))          (alternative 1)
(40 ≤ i ≤ 59): f = (b and c) or (d and (b xor c))         (alternative 2)
(40 ≤ i ≤ 59): f = (b and c) + (d and (b xor c))          (alternative 3)
(40 ≤ i ≤ 59): f = (b and c) xor (b and d) xor (c and d)  (alternative 4)
(40 ≤ i ≤ 59): f = vec_sel(c, b, c xor d)                 (alternative 5)

Max Locktyukhin ka shfaqur[12] se per roundet 32-79 llogaritja e:

w[i] = (w[i-3] xor w[i-8] xor w[i-14] xor w[i-16]) leftrotate 1

mund te zavendesohet me:

w[i] = (w[i-6] xor w[i-16] xor w[i-28] xor w[i-32]) leftrotate 2

Ky transformim mban te gjith operatoret 64-bit , duke larguar mbetjet e w[i] on w[i-3],lejon ne menyre eficiente imlepentimin e x86 SSE instruksioneve.

.

Stampa:Comparison of SHA functions

See also Redakto

Notes Redakto

  1. ^ http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
  2. ^ Schneier, Bruce (18 shkurt 2005). "Schneier on Security: Cryptanalysis of SHA-1". {{cite web}}: Mungon ose është bosh parametri |language= (Ndihmë!)
  3. ^ "Kopje e arkivuar". Arkivuar nga origjinali më 29 prill 2017. Marrë më 12 qershor 2015. {{cite web}}: Mungon ose është bosh parametri |language= (Ndihmë!)Mirëmbajtja CS1: Archived copy si titull (lidhja)
  4. ^ Schneier on Security: NIST Hash Workshop Liveblogging (5)
  5. ^ Hash cracked – heise Security
  6. ^ "SHA1 Deprecation Policy". Microsoft. 2013-11-12. Marrë më 2013-11-14. {{cite web}}: Mungon ose është bosh parametri |language= (Ndihmë!)
  7. ^ "Intent to Deprecate: SHA-1 certificates". Google. 2014-09-03. Marrë më 2014-09-04. {{cite web}}: Mungon ose është bosh parametri |language= (Ndihmë!)
  8. ^ "Bug 942515 - stop accepting SHA-1-based SSL certificates with notBefore >= 2014-03-01 and notAfter >= 2017-01-01, or any SHA-1-based SSL certificates after 2017-01-01". Mozilla. Marrë më 2014-09-04. {{cite web}}: Mungon ose është bosh parametri |language= (Ndihmë!)
  9. ^ "CA:Problematic Practices - MozillaWiki". Mozilla. Marrë më 2014-09-09. {{cite web}}: Mungon ose është bosh parametri |language= (Ndihmë!)
  10. ^ "Phasing Out Certificates with SHA-1 based Signature Algorithms | Mozilla Security Blog". Mozilla. 2014-09-23. Marrë më 2014-09-24. {{cite web}}: Mungon ose është bosh parametri |language= (Ndihmë!)
  11. ^ http://www.faqs.org/rfcs/rfc3174.html
  12. ^ Locktyukhin, Max; Farrel, Kathy (2010-03-31), "Improving the Performance of the Secure Hash Algorithm (SHA-1)", Intel Software Knowledge Base, Intel, marrë më 2010-04-02 {{citation}}: Mungon ose është bosh parametri |language= (Ndihmë!)

References Redakto

External links Redakto

Stampa:Cryptography navbox