-1

I m new in this world of Cryptography. I`m trying to check the performance of the various algorithms on with OpenSSL.

Looking on the internet I find this command :

openssl speed aes-128-cbc des md5

that gives me this result:

type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
md5             141163.54k   328300.37k   585034.84k   725997.91k   781058.05k   784356.69k
des cbc          87455.53k    88825.00k    90427.39k    90697.05k    89822.55k    89953.62k
des ede3         34051.47k    34361.83k    34424.58k    34591.40k    34493.78k    34635.78k
aes-128 cbc     274253.87k   296425.66k   298769.49k   304985.43k   301938.01k   302945.62k

So the question is: If I wish to measure the time with a specific algorithm, with a specific file...how can I do?

Ex. I have a picture.jpg that I what encrypt with AES-128. I wish to know how many time the PC compute this encryption procedure.

5
  • Why do you need this? A picture is also a file. You can look at the file size and compare. The OpenSSL speed doesn't let you define the file. A specific algorithm, do you mean an algorithm not found in OpenSSL? Also, you can use time but it is not perfect – kelalaka Oct 29 '19 at 11:39
  • Basically you can use time with the encryption command. The encryption procedure generally runs just once per block, which for AES is 16 bytes. MD5 is not encryption. – Maarten Bodewes Oct 29 '19 at 12:17
  • If you want to know "how many times" the block cipher (e.g. AES-128) is used: that's a function of file size and block size, and was (mildly) approriate in crypto.SE where the question used to be. If you want to know "how much time" is spent in the encryption procedure, well that's a benchmarking problem, and as a rule of thumb for a proper implementation of a modern cipher (esp. AES-128 on a modern CPU with AES-NI), that's not much compared to the time spent in file IO. – fgrieu Oct 29 '19 at 12:17
  • @kelalaka No, I wish to check the existing algorithm in OpenSSL(like DES, AES, BLowfish and so on) and compare home many times use for encrypting and decrypting my file. – theantomc Oct 29 '19 at 14:46
  • What are you looking for? Fastest algorithm? Lery's answer gives you how to do it. – kelalaka Oct 29 '19 at 17:05
2

For a specific size, this is possible using the -bytes size argument simply:

$ openssl speed -bytes $(ls -l picture.jpg | cut -d " " -f5) aes-128-cbc des md5
Doing md5 for 3s on 1023 size blocks: 1736134 md5's in 2.99s
Doing des cbc for 3s on 1023 size blocks: 224215 des cbc's in 3.00s
Doing des ede3 for 3s on 1023 size blocks: 84333 des ede3's in 3.00s
Doing aes-128 cbc for 3s on 1023 size blocks: 438308 aes-128 cbc's in 3.00s
...

However, if you want to get the time it takes per operation, you will need to do the maths: aes-128 cbc was performed 438308 times in 3.00s, so it took 0.0068445ms or 6844.5ns per operation.

For a specific file, this is not directly possible without writing a wrapper that uses openssl to do it. But could take a look at the source of speed.c and tweak it a bit, if you really need to. Or just rewrite a small program doing it.

6
  • With a good cipher, there should be no measurable difference for specific files: encrypting 1 MB should always take as long as 1 MB takes. – user1686 Oct 29 '19 at 12:37
  • Well, if your CPU supports AES-NI for example, it will be significantly faster at using AES CBC rather than DES CBC. Optimizing the ciphers you want to use can be useful for servers that have to serve a lot of queries for example. – Lery Oct 29 '19 at 12:39
  • How is the math that you are used on AES-128? why take 6.9 ms about? – theantomc Oct 29 '19 at 15:54
  • Ups, I had a typo, it's 0.0068445ms or 6844.5ns – Lery Oct 29 '19 at 16:06
  • ok, but what you used for got that value? You are assumed that file is big how many bits? – theantomc Oct 29 '19 at 16:41

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.