Open
Description
Hi,
I'm trying to verify a payload, which works otherwise with the same key in Java (tried this to see if the payload or key is mismatching). But when I try using xml-crypto
, it's failing.
Payload:
<?xml version="1.0" encoding="UTF-8"?>
<ns2:RespMsg xmlns:ns2="http://...">
<Head msgId="1GRDBknspOwDM8uJ23Xf" orgId="ORGX" ts="2016-12-22T02:23:49+05:30" ver="1.0" />
<Resp reqMsgId="902f711c7c111e6a17aadc739fb42b" result="SUCCESS" />
<Txn id="902f710c7c111e6a17aadc739fb42b" ts="2016-12-22T02:23:49+05:30" type="Hbt" />
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<DigestValue>GxDsmube6nByWFmPdZe0SgXY/nvU9OjUxR4uH9YLc+k=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>T9ZkCoaMRhm6CGdLQf1n/9oV2mIQb5DIH5qAP9S5nePraOff6Lzza5BAFzTunEh4WcDuAS4zFTH5
0K4A5P783oVp1tMkJUYI3G6nLtZatBMJmkRyAefuk30j64NPv6kEu6dz6j48A0y3xLhKoV3sIm66
jaLQ5uJhiTGRqZfHEsg8o1kxy1anLuomBlPDRISAH6dpoAVBjvS7m21tWg4p4IFElJvTUiSdKSmW
OMwXH1qpkRjMBNQyUalMntVl317cgCJ2QI11z23ivgEyK/8FXQDqDO6w6b0K2RPPWFhQEaJDKXFy
P7hs1PzV8v0I9gQHTyM8mmbz0i5tnrQCUaIi+g==</SignatureValue>
<KeyInfo>
<KeyValue>
<RSAKeyValue>
<Modulus>01DqzBsJTyMHT2S9MK5AIyFXNU646kwiOK3uymXIy9EW0nRKNKRkeIRTlGwX4wEnymGtGgX5B/Ij
1elkLN4VJ9GplDV+wf0Lp2i2q4E6uRiWIzsqq42MCQgv8Fq/IPqjqPbeP9yh/8YPmBiMehBmhQd3
qzl77C03k6d0yBIO5q/zXneTK9uFBNEL5yNpukrLGBcf3b9VHsjXpEaQrxGSMHCgNWpQgXpEcBr5
OJ0/XxWbgMCZMlkYe1d6gswjuCRZ/xxJwEfbSO5AsnPtyqxSIjyhgEi9REtYnzaWwOBN4JCqt0pM
L0ja23lUwVJuNwkwNGKBXvkGoXUln8Sf7PIv7w==</Modulus>
<Exponent>AQAB</Exponent>
</RSAKeyValue>
</KeyValue>
</KeyInfo>
</Signature>
</ns2:RespMsg>
This is the input to the verifySignature
method:
{ '0': '<SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"></SignatureMethod><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod><DigestValue>GxDsmube6nByWFmPdZe0SgXY/nvU9OjUxR4uH9YLc+k=</DigestValue></Reference></SignedInfo>',
'1': <Buffer 2d 2d 2d 2d 2d 42 45 47 49 4e 20 43 45 52 54 49 46 49 43 41 54 45 2d 2d 2d 2d 2d 0a 4d 49 49 46 5a 44 43 43 42 45 79 67 41 77 49 42 41 67 49 4b 55 78 ... >,
'2': 'T9ZkCoaMRhm6CGdLQf1n/9oV2mIQb5DIH5qAP9S5nePraOff6Lzza5BAFzTunEh4WcDuAS4zFTH50K4A5P783oVp1tMkJUYI3G6nLtZatBMJmkRyAefuk30j64NPv6kEu6dz6j48A0y3xLhKoV3sIm66jaLQ5uJhiTGRqZfHEsg8o1kxy1anLuomBlPDRISAH6dpoAVBjvS7m21tWg4p4IFElJvTUiSdKSmWOMwXH1qpkRjMBNQyUalMntVl317cgCJ2QI11z23ivgEyK/8FXQDqDO6w6b0K2RPPWFhQEaJDKXFyP7hs1PzV8v0I9gQHTyM8mmbz0i5tnrQCUaIi+g==' }
Output:
false [ 'invalid signature: the signature value T9ZkCoaMRhm6CGdLQf1n/9oV2mIQb5DIH5qAP9S5nePraOff6Lzza5BAFzTunEh4WcDuAS4zFTH50K4A5P783oVp1tMkJUYI3G6nLtZatBMJmkRyAefuk30j64NPv6kEu6dz6j48A0y3xLhKoV3sIm66jaLQ5uJhiTGRqZfHEsg8o1kxy1anLuomBlPDRISAH6dpoAVBjvS7m21tWg4p4IFElJvTUiSdKSmWOMwXH1qpkRjMBNQyUalMntVl317cgCJ2QI11z23ivgEyK/8FXQDqDO6w6b0K2RPPWFhQEaJDKXFyP7hs1PzV8v0I9gQHTyM8mmbz0i5tnrQCUaIi+g== is incorrect' ]
Any idea why this is happening?