- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Iv'e implemented a C++ native dll which allocates a CTR(counter) mode/CBC mode session, encrypts and decrypts buffers.
Iv'e implemented a corresponding C# tester, which takes an input file, and using BinaryReader, readsthe file buffer-buffer, encryptseach buffer using the dll above and writes the encrypted file using a BinaryWriter.
Iv'e tested encryption in CTR mode using different file sizes and different buffer sizes, and all succeeded.
When I tested encryption in CBC mode, I found out that input files larger than 33MB fail in the middle of encryption, producing the error:
ippStsUnderRunErr = -124, /* Data under run error */
I tried changing the buffer size, but the error presists. I tried using CTR mode on the same file (34MB) and it succeeded.
Here is the tester code:
///
{
// Init output paramsTestDuration =
TimeSpan.MinValue; // Open the input file FileStream Infs = new FileStream(InFile, FileMode.Open, FileAccess.Read); if(Infs.Length == 0){
MessageBox.Show("Input file is empty", "AES Transform Tester", MessageBoxButtons.OK, MessageBoxIcon.Error);Infs.Close();
return false;}
// Create the output file FileStream Outfs = new FileStream(OutFile, FileMode.Create, FileAccess.Write); BinaryReader br = new BinaryReader(Infs); BinaryWriter bw = new BinaryWriter(Outfs,System.Text.Encoding.Default); byte[] PlainTextBlock; byte[] EncryptedBlock; try{
// Get the current time DateTime TestStart = DateTime.Now; // Read the file block by block while((PlainTextBlock = br.ReadBytes(BlockSize)).Length != 0){
// Encrypt the byte arrayEncryptedBlock =
new byte[PlainTextBlock.Length]; if(!AESTstrUtil.EncryptPacket(SessionHandle,PlainTextBlock,IV, EncryptedBlock))
{
MessageBox.Show("Failed to encrypt block", "AE S Transform Tester", MessageBoxButtons.OK, MessageBoxIcon.Error); return false;}
bw.Write(EncryptedBlock);
}
// Set the test durationTestDuration =
DateTime.Now - TestStart;}
finally{
bw.Close();
Outfs.Close();
br.Close();
Infs.Close();
}
return true;}
Any ideas / same experience?
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI,
Some suggest from expert for this problem:
The single case when ippsRijndael128EncryptCBC() returns ippStsUnderRunErr status is
0!=(len%16) and padding==NONE, where len is data length (in bytes ) to be encrypted.
Pay attention that behavior of all symmetric ciphers has been changed in IPP v5.1 - padding scheme parameter does not use actually and always assumes NONE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks.
I just found out myself that indeed the case you suggested was the one I confronted.
I think that a different error name or appropriate documentation (Iv'e looked for such anywhere) would have prevented the mess I got in...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page