Okay, I've figured out what was going on there. Sheesh, that was confusing.

First off, the easy (one line!) fix:

$plaintext = substr($input . ("\x00" x $ciphertextsize), 0, $ciphertex +tsize);

The private data communication protocol is designed to send one 64-bit number, not a variable-length string.

That being said, the code above and the web page it links to both have a subtle error in the protocol. Well, "error" is maybe too strong a word - a subtle quirk, maybe? Both the prefilled values on the webpage and the constants in the code look like byte strings encoded in hex.

That is, it's natural to think that $encryptionkey = 'c488fdd0d81f'; defines a six byte encryption key.

It doesn't. It defines a twelve byte encryption key, where all the bytes used happen to be in the range 48-57 or 96-101.

If you're trying to develop perl code to create test AdX RTB responses (that is the point of this, right?), you'll need to do a few things differently:

Hope this helps. I do wish they'd add perl and python implementations to the sample site; it could have saved you some unneeded frustration.

--
@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

In reply to Re: Private Data Communication Protocol Encryption by fizbin
in thread Private Data Communication Protocol Encryption by pishposh30

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.