0
$\begingroup$

I am encrypting files in a two layered fashion as follows:

  1. Inner layer is 128 bit AES-CTR encryption
  2. Outer/Second layer is a simple one time padding with a particular key.

While testing the running times I noticed that it takes same time to encrypt a 100kB file as it takes to encrypt a 10kB file. Logically it seems wrong to me, is it something that I am missing ?

$\endgroup$
  • 2
    $\begingroup$ Are both so fast that your timer can't actually measure it? $\endgroup$ – poncho Sep 16 '15 at 5:49
  • $\begingroup$ Or the timing is mostly down to e.g. disk latency that only happens once. $\endgroup$ – otus Sep 16 '15 at 6:06
  • $\begingroup$ Did you mean "one-time-pad" where you wrote "one-time-padding"? And where does the pad come from? Read from a file? $\endgroup$ – CodesInChaos Sep 17 '15 at 10:35
1
$\begingroup$

Modern computers are quite fast, and modern cryptographic algorithms are quite efficient.

Most computers benchmark hardware accelerated AES in CTR mode well above 1GB/s, which would be a fraction of a millisecond for a 100KiB file. Since the standard system timer generally runs at 1ms intervals, the entire encryption operation ([file data] XOR [AES] XOR [Pad]) will take less than a single timer 'tick' to complete, and they will report the same completion time.

I would expect files up to 3 MiB will take less than 1ms to complete on computers made in the last 5 years, if the timer is started after the file data is read from disk, just prior to encryption.

Try using a much larger file, at least 1 GiB, in order to gauge the performance of the system. Also, Windows offers a high resolution timer through the kernel, if the hardware supports it, offering sub-microsecond accuracy. If you try to repeatedly measure very small time windows, they will vary greatly if there are other processes using the same CPU core.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.