I am trying to apply client side encryption, for this using AWS KMS I created Asymmetric key. I downloaded the public key and then from the frontend (I am using react). I am using the following function to encrypt the data
function encryptMessage(message, publicKey) {
const jsEncrypt = new JSEncrypt();
jsEncrypt.setPublicKey(publicKey);
return jsEncrypt.encrypt(message);
}
I later encode this in base64 before sending it,
The key spec is RSA_2048
And I want to use RSAES_OAEP_SHA_256 as my encryption algorithm.
Following is the backend, written in python to decrypt the message:
client = boto3.client('kms')
res = base64.b64decode(blob)
print(res)
response = client.decrypt(
CiphertextBlob=res,
KeyId='xxxxxxxxxxxxxxxxxxxxx',
EncryptionAlgorithm='RSAES_OAEP_SHA_256'
)
print(response)
I am unable to send a proper encrypted message so that it can be decrypted from backend. How do I set EncryptionAlgorithm on react?