Encryption key in CodeIgniter
Date : March 29 2020, 07:55 AM
will be helpful for those in need The key should be as random as possible and it must not be a regular text string, nor the output of a hashing function, etc. $config['encryption_key'] = 'yourKeyHere'
|
C# AES Encryption in CFB Where Plaintext Length Equals Encrypted Length
Tag : chash , By : nhuser
Date : March 29 2020, 07:55 AM
Any of those help I revisited trying to use cryptlib and it solved my problem... code is below: using cryptlib;
byte[] key = new byte[16] {...key bytes here...};
byte[] iv = new byte[16] {...iv bytes here...};
byte[] enc; //ciphertext bytes (i populated them from a filestream)
crypt.Init();
int cryptContext = crypt.CreateContext(crypt.UNUSED, crypt.ALGO_AES);
crypt.SetAttribute(cryptContext, crypt.CTXINFO_MODE, crypt.MODE_CFB);
crypt.SetAttributeString(cryptContext, crypt.CTXINFO_KEY, key, 0, 16);
crypt.SetAttributeString(cryptContext, crypt.CTXINFO_IV, iv, 0, 16);
crypt.Decrypt(cryptContext, enc); //ciphertext bytes replaced with plaintext bytes
crypt.DestroyContext(cryptContext);
|
ASP.NET DES encryption with encrypted text length equal to plain text length
Tag : chash , By : glisignoli
Date : March 29 2020, 07:55 AM
will be helpful for those in need As stated in this CodeProject article from some time ago. public static byte[] Encrypt(byte[] data, byte[] key, byte[] iv)
{
BufferedBlockCipher cipher = new CtsBlockCipher(new CbcBlockCipher(new AesEngine()));
ICipherParameters keyParam = new ParametersWithIV(new KeyParameter(key), iv);
cipher.Init(true, keyParam);
return cipher.DoFinal(data, 0, data.Length);
}
public static byte[] Decrypt(byte[] data, byte[] key, byte[] iv)
{
BufferedBlockCipher cipher = new CtsBlockCipher(new CbcBlockCipher(new AesEngine()));
ICipherParameters keyParam = new ParametersWithIV(new KeyParameter(key), iv);
cipher.Init(false, keyParam);
return cipher.DoFinal(data, 0, data.Length);
}
|
Why Laravel4.2 Encryption Key less than Encryption Key character in CodeIgniter?
Tag : php , By : SachinJadhav
Date : March 29 2020, 07:55 AM
this will help AES keys need to be indistinguishable from random and either 16, 24 or 32 bytes in length. It seems Laravel adds an additional check for the AES key to be a valid size. Basically what the PHP's mcrypt does (not sure about the C-code) is that it extends the key data with 00 valued bytes if the key is smaller than 32 bytes, until it gets to the first legal AES key size. If the key is larger than 32 bytes it simply cuts it to 32 bytes. This is absolutely against any good practice with regards to handling keys.
|
AES/CCM Encryption and Plaintext Length Exceeds Maximum Message Length
Date : March 29 2020, 07:55 AM
I wish did fix the issue. My question is, how do I encrypt/decrypt a plaintext which is longer than 16777215 bytes? lword MaxMessageLength() const
{return m_L<8 ? (W64LIT(1)<<(8*m_L))-1 : W64LIT(0)-1;}
if (m_state >= State_IVSet && length > MaxMessageLength()-m_totalMessageLength)
throw InvalidArgument(AlgorithmName() + ": message length exceeds maximum");
m_totalMessageLength += length;
const int TAG_SIZE = 8;
CCM< AES, TAG_SIZE >::Encryption e;
CCM< AES, TAG_SIZE >::Decryption d;
|