static KeyPair demo(InputStream pub, InputStream pvt) throws IOException, GeneralSecurityException { KeyFactory f = KeyFactory.getInstance(“RSA”); RSAPublicKeySpec pubspec = decodeRSAPublicSSH(readAllBase64Bytes(pub)); RSAPrivateCrtKeySpec pvtspec = decodeRSAPrivatePKCS1(readAllBase64Bytes(pvt)); return new KeyPair(f.generatePublic(pubspec), f.generatePrivate(pvtspec)); } static RSAPublicKeySpec decodeOpenSSH(byte[] input) { String[] fields = new String(input, StandardCharsets.US_ASCII).split(” “); if ((fields.length < 2) || (!fields[0].equals(“ssh-rsa”))) throw new IllegalArgumentException(“Unsupported type”); byte[] std = Base64.getDecoder().decode(fields[1]); return decodeRSAPublicSSH(std); … Read more