Hi Dave, Thanks for the reply. I do have access to the server code but cannot change it's implementation to suite my requirement as the server is serving other clients in other platforms as well.
Below is the java code to encrypt an AES symmetric key with the public key it recieves from the client. After encryption, the size of the data is about 176 characters. public static String encryptAESKey(byte[] aesKeyBytes, String publicKeyStr) { String cipherStr = null; try { PublicKey pkey = getPublicKey(publicKeyStr); final Cipher cipher = Cipher.getInstance(RSA_ALGORITHM); cipher.init(Cipher.ENCRYPT_MODE, pkey); byte[] cipherBytes = cipher.doFinal(aesKeyBytes); cipherStr = Base64.encodeBase64String(cipherBytes); } catch (Exception e) { e.printStackTrace(); } return cipherStr; } private static PublicKey getPublicKey(String publicKey) throws InvalidKeySpecException, NoSuchAlgorithmException { KeyFactory rsaKeyFac = KeyFactory.getInstance(RSA_ALGORITHM); byte[] keyBytes = Base64.decodeBase64(publicKey.getBytes()); X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes); RSAPublicKey rsaPubKey = (RSAPublicKey)rsaKeyFac.generatePublic(keySpec); return rsaPubKey; } -- View this message in context: http://openssl.6102.n7.nabble.com/RSA-encryption-decryption-with-OpenSSL-tp46234p46259.html Sent from the OpenSSL - User mailing list archive at Nabble.com. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org