DevelopersVietNam / as3crypto

Automatically exported from code.google.com/p/as3crypto
0 stars 0 forks source link

Found error! in RSA _encrypt ( r28 ) #59

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Sometimes, the chunks has incorrect length with x64 flashplayer.
Padding with zeros seems to be a stable solution.

At r28 in RSAKey::_encrypt around line 126:

before:
while (src.position<end) {
  var block:BigInteger = new BigInteger(pad(src, end, bl, padType), bl, true);
  var chunk:BigInteger = op(block); 
  chunk.toArray(dst);
}

after:
while (src.position<end) {
  var block:BigInteger = new BigInteger(pad(src, end, bl, padType), bl, true);
  var chunk:BigInteger = op(block);

  for (var b:uint = bl - Math.ceil(chunk.bitLength() / 8); b > 0; --b)
    dst.writeByte(0);

  chunk.toArray(dst);
}

Original issue reported on code.google.com by apostol....@gmail.com on 19 Apr 2011 at 9:31

GoogleCodeExporter commented 8 years ago
Thanks! Implemented this hotfix in a fork on GitHub: 
https://github.com/timkurvers/as3-crypto
Credited in the actual commit and changelog.

If you would prefer to be credited with your name instead of your partial 
e-mail address, please let me know and I'll make sure to bring it up to date.

Kind regards,

Tim Kurvers

Original comment by TimKurvers on 3 Oct 2011 at 4:20