I've downloaded all sample iDEAL code I could find. None worked. They were either for the old iDEAL version or they simply did not work. I don't understand what I'm doing wrong. According to every single piece of documentation I've read about iDEAL and signing XML, it should work yet iDEAL keeps returning "invalid digital signature". This is what I do:
# $digest contains the digest of the message (confirmed to be correct)

my $SignedInfo = <<EOT;
    <SignedInfo>
      <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
      <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>$digest</DigestValue>
      </Reference>
    </SignedInfo>
EOT

# SignedInfo needs to be signed using RSAWithSHA256

my $dataToSign = _CanonicalizeXML( $signedInfo, 1 ); # Does exclusive canonicalization
my $pkrsa      = Crypt::PK::RSA->new( "priv.pem", $password );
my $sig        = $pkrsa->sign_message( $dataToSign, "SHA256", "v1.5" );

$sig = encode_base64( $sig );
chomp( $sig );

.
. I then continue building the XML message.
.

sub _CanonicalizeXML {
  my ($xml, $exclusive) = @_;

  my $xpath = '<XPath>(//. | //@* | //namespace::*)</XPath>';
  return XML::CanonicalizeXML::canonicalize( $xml, $xpath, [], $exclusive, 0 );
}

When I send the XML message to the iDEAL server, it returns "invalid digital signture"...

In reply to Re^2: AES support for Crypt::OpenSSL::RSA? by Zippy1970
in thread AES support for Crypt::OpenSSL::RSA? by Zippy1970

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.