jCryption と互換性のある RSA デコードのスニペットを次に示します。encExternalKey
これが、jCryption がkey
ハンドシェイク呼び出しのパラメーターで送信するものであると想定しています。modulus
jCryptionに付属のファイルsecretExponent
から取得されます。100_1024_keys.inc.php
RSAPrivateKeySpec privateKeySpec =
new RSAPrivateKeySpec(new BigInteger(modulus, 10), new BigInteger(secretExponent, 10));
RSAPrivateKey privateKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(privateKeySpec);
Cipher cipher = Cipher.getInstance("RSA/ECB/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
StringBuilder externalKeyBuf =
new StringBuilder(new String(cipher.doFinal(new BigInteger(encExternalKey, 16).toByteArray())));
String externalKey = externalKeyBuf.reverse().toString().trim();