For the record, we finally managed to reproduce's JUCE's RSA algorithm with a standard PHP environment. Find our solution below.

Keep in mind that JUCE's RSA implenentation is not super-safe (time attacks, etc). I strongly recommend to not use JUCE's RSA for critical network business. In our case, JUCE's RSA implemenation was sufficient, since we only use RSA for certain parts of our key based, "garden fence" copy protection.

First of all, download phpseclib from http://phpseclib.sourceforge.net/ it's an open source (MIT) and dependency free alternative to openSSL. We use its Math/BigInteger.php class to represent the (really) big ints needed for RSA.

Here's the PHP side encryption/decryption code:

<?php
// from http://phpseclib.sourceforge.net/
include('Math/BigInteger.php');
function applyToValue($x, $key_part1, $key_part2)
{
$part1 = new Math_BigInteger($key_part1, 16);
$part2 = new Math_BigInteger($key_part2, 16);
$zero = new Math_BigInteger();
$value = new Math_BigInteger(strrev($x), 256);
$result = new Math_BigInteger();
while (!$value->equals($zero)) {
$result = $result->multiply($part2);
list($value, $remainder) = $value->divide($part2);
$result = $result->add($remainder->modPow($part1, $part2));
}
return strrev($result->toBytes());
}
// generated by RSAKey::createKeyPair()
$PUBLIC_KEY_PART_1 = "5";
$PUBLIC_KEY_PART_2 = "60c838206a7e278ea3af103ce3b602d9de733a99f6d37df6580271996c9fba13";
$PRIVATE_KEY_PART_1 = "3a11bb46a64bb155956909be223a01b52c8bee2841d0caee997204997d4c360d";
$PRIVATE_KEY_PART_2 = "60c838206a7e278ea3af103ce3b602d9de733a99f6d37df6580271996c9fba13";
// secret message
$initial = "There's a rabbit in my hat!";
// encrypt by public key
$encrypted = applyToValue($initial, $PUBLIC_KEY_PART_1, $PUBLIC_KEY_PART_2);
// decrypt by private key
$decrypted = applyToValue($encrypted, $PRIVATE_KEY_PART_1, $PRIVATE_KEY_PART_2);
echo $decrypted."\n";
?>

And just for clarity, here's the JUCE side encryption/decryption:

RSAKey public_key("5,60c838206a7e278ea3af103ce3b602d9de733a99f6d37df6580271996c9fba13");
RSAKey private_key("3a11bb46a64bb155956909be223a01b52c8bee2841d0caee997204997d4c360d,60c838206a7e278ea3af103ce3b602d9de733a99f6d37df6580271996c9fba13");
String initial = "There's a rabbit in my hat!";
BigInteger bi;
bi.loadFromMemoryBlock(MemoryBlock(initial.getCharPointer(), initial.length()));
// encrypt
public_key.applyToValue(bi);
// decrypt
private_key.applyToValue(bi);
String decrypted = bi.toMemoryBlock().toString();