sslcrypto
sslcrypto copied to clipboard
OpenSSL Generated Keys?
We created a key as:
openssl ecparam -name prime256v1 -genkey -noout -out private-key.pem
But whenever trying to decrypt we get an error for wrong curve.
curve = sslcrypto.ecc.get_curve("prime256v1") print(curve.decrypt(ciphertext, private_key, algo="aes-256-ofb") )
Not sure if I'm far off or close enough - but any direction will be appreciated.
Perhaps the problem is in the ciphertext format. sslcrypto expects the ciphertext to start with 16 bits of AES IV, followed by the ephemeral public key, followed by the AES-encrypted data.
It'd be great if you specified which library you're using to encrypt the data and how you're using it.
The app sending me the encrypted message is JAVA - here's the encryption snippet:
byte[] plainTextBytes = inputData.getBytes("UTF-8");
cipher = Cipher.getInstance("ECIES", BouncyCastleProvider.PROVIDER_NAME);
cipher.init(Cipher.ENCRYPT_MODE, keys.getPublic());
byte[] encryptedData = cipher.doFinal(plainTextBytes);
return Base64.getEncoder().encodeToString(encryptedData);
It'd help if you sent me an example of a ciphertext (here or to [email protected]). I can only guess the format is probably PKCS #7, but I'd like to make sure.
Sent.