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 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法