Hi Jaroslav and the others,
I want to encrypt data with the private key but it returned an error!
Here is my code:
byte[] decode = rawData
Mechanism mechanism = new Mechanism(CKM.CKM_RSA_X_509);
byte[] decryptedData = session.Decrypt(
mechanism, privateKey, decode);
var PlText = decryptmessage(splitter.EncryptedData, splitter.IV, decryptedData);//Getting error Here when passing above line data(i.e., decryptedData)
private byte[] decryptmessage(byte[] cmessage, byte[] iVector, byte[] m_Key)
{
//// randomly generated number acts as inetialization vector
byte[] m_IV = new byte[16];
Array.Copy(iVector, 0, m_IV, 0, 16);
// GenerateAESKey();
KeyParameter aesKeyParam = ParameterUtilities.CreateKeyParameter("AES", m_Key);
ParametersWithIV aesIVKeyParam = new ParametersWithIV(aesKeyParam, m_IV);
IBufferedCipher cipher = CipherUtilities.GetCipher("AES/CFB/NoPadding");
cipher.Init(false, aesIVKeyParam);
return cipher.DoFinal(cmessage);
}
The Error is:
the key should be 128/192/256 bits in length
I am getting session key in 256 bytes. Can anyone help me to get the session key as 32 bytes?