【问题标题】:Generating SignatureValue using HMAC-SHA1 in XML在 XML 中使用 HMAC-SHA1 生成 SignatureValue
【发布时间】:2010-10-21 05:05:20
【问题描述】:

签名方法是HMAC-SHA1,我已经生成了<SignedInfo>。问题是我不确定在 HMAC 计算中使用什么作为键。

我注意到初始请求 (RST) 和响应 (RSTR) 中有两个 <Entropy>,其中包含 <BinarySecret>。我从 WS-Trust 中读到,这表明我可以使用来自响应的<ComputeKey> 标记中指定的<BinarySecret>PSHA1 中的这两个二进制值生成证明密钥。但是,我永远无法从服务提供商那里获得与示例中的签名值相同的签名值。

任何信息都会有所帮助!

举个例子:

  • 来自 RST 的二进制机密是 grrlUUfhuNwlvQzQ4bV6TT3wA8ieZPltIf4+H7nIvCE=
  • 来自 RSTR 的二进制机密是 YLABh3ZmZyiO5gvVLZe9J4JPd9w59KGeTFwE85XlzxE=
  • 正确的签名值为 nXJEN8p1nupMA/00TK03VZlADkU=
  • 我生成的签名值为 bEGpeRFsznafFRf86g281zKV3Ro=
  • SignInfo的内容如下
<SignedInfo>
   <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
   <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/>
   <Reference URI="#_0">
    <Transforms>
     <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
    <DigestValue>CwMGnFZklO7XsDfFguzl0tw7iHM=</DigestValue>
   </Reference>
  </SignedInfo>

【问题讨论】:

    标签: php xml signature saml


    【解决方案1】:

    您是否记得在散列/验证之前对值进行 base64 解码? 顺便说一句,您可以使用 hash() 来使用 sha256 进行哈希,而无需密钥。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-01
      • 2017-07-08
      相关资源
      最近更新 更多