Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

AESEncryptCBC on a large files

OTorg
New Contributor III
724 Views

Hi!

I want to encrypt (or decrypt) large file.

It is unreasonable/impossible to load the whole file into memory and process it by single AESEncryptCBC call.

The more affordable way is to process that file using consecutive smaller chunks.

So, as far as I understand, the term "initialization vector" is need only for a first Encrypt call.

And subsequent Encrypt calls require knowledge of some state from previous call.

Is it possible with IPP primitives to process large amounts through several AESEncryptCBC calls?

 

And one more question regarding AESEncryptCBC/AESDecryptCBC.

Can pSrc and pDst pointers be the same?

0 Kudos
1 Solution
Andrey_M_Intel2
Employee
724 Views

Hello,

Yes, you can do AES CBC encryption by chunks, but in this case you should take care about IV for any subsequent chunk yourself.

The algorithm uses previous encrypted block as an input for the next block processing, so when you encrypt first chunk with the "original" IV, you should take last block of the last encrypted chunk as an IV for the next ippsAESEncryptCBC() call. Please also make sure that size of your chunks is a multiple of block size.

As to the second question, yes, they support in-place mode.

 

Regards,

Andrey

View solution in original post

0 Kudos
2 Replies
Andrey_M_Intel2
Employee
725 Views

Hello,

Yes, you can do AES CBC encryption by chunks, but in this case you should take care about IV for any subsequent chunk yourself.

The algorithm uses previous encrypted block as an input for the next block processing, so when you encrypt first chunk with the "original" IV, you should take last block of the last encrypted chunk as an IV for the next ippsAESEncryptCBC() call. Please also make sure that size of your chunks is a multiple of block size.

As to the second question, yes, they support in-place mode.

 

Regards,

Andrey

0 Kudos
OTorg
New Contributor III
724 Views

Andrey-Matyukov (Intel) wrote:


Yes, it works! Thank you!

0 Kudos
Reply