doumiao0498 2019-08-13 10:17
浏览 398

如何使用rsa-oaep-mgf1p加密方法和sha1摘要方法生成EncryptedKey的CipherValue?

Anyone know how can I generate the CipherValue of the EncryptedKey? This example was generated with VB.Net

I suppose there is something like encrypt a token with the public key and a SHA1 of this token but I have no idea how it combined. I want to do that in PHP but I haven't found any tool.

<e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#" Id="uuid-7dcc6d1e-6d3b-4ac3-a013-a75550f3e9f7-1">
    <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"><DigestMethod xmlns="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /></e:EncryptionMethod>
    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <o:SecurityTokenReference>
           <o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">UE8lna0CUXfunLavERh30l1lQjQ=</o:KeyIdentifier>
        </o:SecurityTokenReference>
    </KeyInfo>
    <e:CipherData>
        <e:CipherValue>k9UiWxqVrQqj4674bFDcPSW6waF8wGLKwvARONEMjATyX7RZty2z9N154ycO8PXmSDTMSvBDdyC6ZMAXa3d1WH3+P9IGN9FKPsAi7oOnVGab6ikXt2bQaljxlGvaAAbiVS+BiY5x15jhzrXCCIIrEq4rsrQm9oiMFV1D1s7kPguE/TRNkT8XzOMArJ7Sk2DZVs7A4LF8dcKDH+W2Ece5JmD/H9spOQWPBRcyH29nbVy8l3/F2oTphV1UMy8Bwuax66majDmL1CqlZ5n5t9wbTuRm4rG6MLwcdZi+1xj8V0LDqs/HpxDtyHNAXcnogIu7+BBN6Rw5xX7GfZsXF0tp+w==</e:CipherValue>
    </e:CipherData>
    <e:ReferenceList>
       <e:DataReference URI="#_2" />
    </e:ReferenceList>
</e:EncryptedKey>
  • 写回答

1条回答 默认 最新

  • dongzouh51192 2019-08-14 12:31
    关注

    The XML says it's doing RSA OAEP and that it's using sha1. So, my guess, is that this would work, provided you have the public key:

    (using phpseclib)

    $rsa = new RSA();
    $rsa->loadKey('...');
    $rsa->encrypt('...');
    

    (phpseclib 2.0 uses OAEP by default and sha1 as the MGF / hash)

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器