代码之家  ›  专栏  ›  技术社区  ›  Arc

SHA1碰撞演示/示例

  •  26
  • Arc  · 技术社区  · 16 年前

    这个问题类似于 this

    目前已知的任意消息是否存在任何实际的SHA1冲突对?

    我想用这些来测试各种软件产品(我自己的和一些第三方)是如何处理它的。

    5 回复  |  直到 9 年前
        1
  •  14
  •   Nick T twasbrillig    6 年前

    目前已知的第一次碰撞已经发表在 https://shattered.it/

    $ curl -sSO https://shattered.it/static/shattered-1.pdf
    $ curl -sSO https://shattered.it/static/shattered-2.pdf
    
    $ sha1sum *.pdf
    38762cf7f55934b34d179ae6a4c80cadccbb7f0a  shattered-1.pdf
    38762cf7f55934b34d179ae6a4c80cadccbb7f0a  shattered-2.pdf
    
    $ sha256sum *.pdf
    2bb787a73e37352f92383abe7e2902936d1059ad9f1ba6daaa9c1e58ee6970d0  shattered-1.pdf
    d4488775d29bdef7993367d541064dbdda50d383f89f0aa13a6ff2e0894ba5ff  shattered-2.pdf
    
        2
  •  32
  •   Community Mohan Dere    6 年前

    截至2017年2月23日,这个答案不再准确。

    For more than six years, the SHA1 cryptographic hash function underpinning Internet security has been at death's door. Now it's officially dead, thanks to the submission of the first known instance of a fatal exploit known as a "collision."

    目前尚没有已知的沙一号发生碰撞。马上:

    • 车上有些碰撞 减少 SHA-1的版本,少于标准SHA-1的80发。
    • 应该 用大约等于2的计算力获得一个SHA-1碰撞 63 在小消息上调用SHA-1;这比一般算法(需要2个 但这仍然相当大,而且该算法还没有运行。

    有一个努力,以获得一个沙-1碰撞利用电源从谁有一些空闲的CPU时钟周期捐赠,与 BOINC

    理论上的攻击依赖于一些假设,这些假设可能会被证明有点错误;例如,对MD5的攻击实际上比预期的要快一点(在某些点上,有一个属性必须满足,理论上的概率为2) ,但实际上更像是2 -27.7 ,即攻击速度比预期快20%)。人们仍然认为理论攻击是正确的,复杂性“相当准确”。

        3
  •  10
  •   Arc    9 年前

    https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html

    直接链接到2个具有相同SHA-1的PDF(从 site dedicated to this finding

    同样,Marc Stevens与CWI Amsterdam和一些Google员工一起参与了这项工作,但这次是在两个构建的pdf上进行完整的SHA-1。

    Stevens also notes Merkle-DamgÃ¥rd construction ,两个PDF都可以用相同的任意数据进行扩展(附加),以生成哈希到相同摘要的较长版本。

    谷歌显然将在90天内(2017年2月23日)发布附带的源代码,给受影响的系统供应商一些时间更新他们的资料。

    像git这样的软件和像GitHub这样的服务提供商将如何处理这个问题还有待观察,特别是在向后兼容性方面。

    issued a statement regarding git ,注意到它们将以兼容的方式迁移到较新的哈希,但这需要时间。

    sha1("blob " + <size in octets as text> + "\0" + <contents>)
    

    您可以使用 git hash-object <file path>

    related news, Subversion seems to be the first real victim 这证明,造成存储库损坏,从而使上述文件的实际利用。

    --以前。。。--

    76-round collision Marc Stevens .

    密码学家Jean-Philippe Aumasson是 BLAKE SipHash 以及 Password Hashing Competition (PHC) will have been found by 2020 .

    ongoing research by Marc Stevens et al. published in October 2015 ,

    ... 我们估计了沙一号的碰撞成本 (即2015年秋季)介于 7.5万美元和12万美元$ 租用亚马逊EC2云计算几个月。 相比之下,安全专家bruceschneier此前预测

    他们还描述了对SHA-1压缩功能的碰撞攻击。

        4
  •  4
  •   Palec    9 年前

    这里有一个例子 Collision Search Attacks on SHA1

    3 A collision example for 58-step SHA1
    
             h₁ = compress(h₀,M₀) = compress(h₀,M'₀)
     _____________________________________________________
       h₀:  67452301 efcdab89 98badcfe 10325476 c3d2e1f0
     _____________________________________________________
       M₀:  132b5ab6 a115775f 5bfddd6b 4dc470eb
            0637938a 6cceb733 0c86a386 68080139
            534047a4 a42fc29a 06085121 a3131f73
            ad5da5cf 13375402 40bdc7c2 d5a839e2
     _____________________________________________________
       M'₀: 332b5ab6 c115776d 3bfddd28 6dc470ab
            e63793c8 0cceb731 8c86a387 68080119
            534047a7 e42fc2c8 46085161 43131f21
            0d5da5cf 93375442 60bdc7c3 f5a83982
     _____________________________________________________
       h₁:  9768e739 b662af82 a0137d3e 918747cf c8ceb7d4
     _____________________________________________________
    
    Table 2: A collision of SHA1 reduced to 58 steps. The two
    messages that collide are M₀ and M'₀. Note that padding
    rules were not applied to the messages. 
    
        5
  •  2
  •   Arc    9 年前

    不完全是SHA1碰撞, PBKDF2-HMAC-SHA1 消息摘要身份验证代码。

    例如,两个密码的PBKDF2(SHA1,password,salt,iterations,dkLen) plnlrtfpijpuhqylxbgqiiyipieyxvfsavzgxbbcfusqkozwpngsyejqlmjsytrmd eBkXQTfuBqp\'cTcar&g* ,盐 hunter2 4 35d1c8f259129dc800ec8e073bb68f995424619c 对于dkLen 20 ).

    事实上,对于长度超过64字节的字符串,发现这样的冲突是微不足道的。

    >>> import hashlib, binascii
    >>> def pbkdf2sha1hex(x, salt, iters):
    ...     h = hashlib.pbkdf2_hmac('sha1', x, salt, iters)
    ...     return binascii.hexlify(h)
    >>> pbkdf2sha1hex(b'http://stackoverflow.com/questions/3475648/sha1-collision-demo-example/31136714', b'NaCl', 1000000)
    b'20177527e04e05d5e7b448c1ab2b872f86831d0b'
    >>> pbkdf2sha1hex(b'\x8c\xbf8\x94\xbc\xf4\xbe\x90xT,r\xbc\x03\xd1\xed\xd9\xea\xfb\x9f', b'NaCl', 1000000)
    b'20177527e04e05d5e7b448c1ab2b872f86831d0b'
    

    请注意,同样的“问题”也适用于

    >>> h1 = pbkdf2_hmac('sha256', b'http://stackoverflow.com/questions/3475648/sha1-collision-demo-example/31136714', b'NaCl', 1000000)
    b"\xcf\xc5\xee\x15=\r\x0b\x0e\x89r\x9b\xe1\xb7'+\xa4'o\x98kn++u\x12\xec\xd9\xec\xea\xebL\xb7"
    >>> h2 = pbkdf2_hmac('sha256', b'.\x83\xb0D\x93D\x9f\x162\xf3\xd4x\xb6\x1a\x9f-\x1f\xdb\xdc\xa4\x8f\xb3\x95Y5\xea\x99*\x97\x00V\x81', b'NaCl', 1000000)
    >>> h1 == h2
    True
    

    这一切都会发生,因为从PBKDF2定义来看,对于长字符串,它包含:
    PBKDF2(hashalgo, s, ...) == PBKDF2(hashalgo, hashalgo(s), ...) .

    https://mathiasbynens.be/notes/pbkdf2-hmac