After huge amount of time spent on another project I came back on this application, and solved my issue.
First of all, the private key json generated by the SJCL/JSBN library are hexa strings. So I just needed to convert my strings in byte arrays.
BigInteger n = new BigInteger(Utils.hexStringToByteArray(nString));
BigInteger e = new BigInteger("10001", 16); // Public exponent
The cyphered data sent, are also an hexa string.
byte[] dec = cipher.doFinal(Utils.hexStringToByteArray(data));
return new String(dec, "UTF-8");
The cipher return a byte array as a plaintext.
Bellow the algorithm:
Cipher cipher = Cipher.getInstance("RSA/None/PKCS1Padding");
and the hexStringToByteArray functions:
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len/2];
s = s.toUpperCase();
for(int i = 0; i < len; i+=2){
data[i/2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i+1), 16));
}
return data;
}
public static String byteArrayToHexString(byte[] bytes) {
char[] hexChars = new char[bytes.length*2];
int v;
for(int j=0; j < bytes.length; j++) {
v = bytes[j] & 0xFF;
hexChars[j*2] = hexArray[v>>>4];
hexChars[j*2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars).toLowerCase();
}
At the time I was looking at the wrong place, decoding my BigInteger as base64 coded strings.