0
$\begingroup$

How to do the benchmarking of a self implementation of AES algorithm using NIST test suites?

I am unable to find enough material on the internet regarding this.

$\endgroup$

closed as unclear what you're asking by otus, e-sushi Jan 6 '16 at 17:10

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ are you looking for the test vectors or how to test your implementation? for the first question googling "AES KAT NIST" should take you to the right webpage, for the latter you can take inspiration by the fips module included in libgcrypt and openssl (they drive a binary with a perl script and compute all the answers for the KAT tests) $\endgroup$ – ddddavidee Jan 5 '16 at 8:39
  • $\begingroup$ I am actually looking for a toolkit, either online or a library that tests my algorithm according to the NIST test suites and give values with which I can compare different algos. $\endgroup$ – levi1696 Jan 5 '16 at 8:47
  • $\begingroup$ I'm not sure it exists somewhere or publicly available. But give a look to the libgcrypt source code... $\endgroup$ – ddddavidee Jan 5 '16 at 9:01
  • $\begingroup$ Standard conformity test of AES implementations can be easily done according to Appendix C of FIPS-197. In case you have problems with that, you could compare with my Python coding of AES (s13.zetaboards.com/Crypto/topic/7385224/1/) where the test is performed with the function checkencryptionwithfips197(). $\endgroup$ – Mok-Kong Shen Jan 5 '16 at 9:23
  • $\begingroup$ "CrypTool" is a good program for cryptography.You can encrypt long message with your implemented algorithm and with this program and then compare they. $\endgroup$ – Meysam Ghahramani Jan 5 '16 at 10:32
1
$\begingroup$

http://csrc.nist.gov/groups/STM/cavp/documents/aes/AESAVS.pdf "... specifies the procedures involved in validating implementations of the Advanced Encryption Standard (AES) algorithm in FIPS 197 : Advanced Encryption Standard. The AESAVS is designed to perform automated testing on Implementations Under Test (IUTs). This publication provides the basic design and configuration of the AESAVS. It includes the specifications for the three categories of tests that make up the AESAVS, i.e., the Known Answer Test (KAT), the Multi-block Message Test (MMT), and the Monte Carlo Test (MCT)."

I'm unsure if there's a pre-existing software solution, but it wouldn't be especially hard to code up your own test suite, if you're on about testing your own implementation.

Edit: Just to clarify, obviously this will not give you any FIPS certification nor the assurance that comes from that. However, based on the number of tests, if your solution gives correct responses to each of the Known Answer Tests in the AESAVS spec, then it seems highly likely that your implementation is correct. If "highly likely" is not sufficient, then the answer would be to pay for official AESAVS testing. As Mok-Kong Shen points out, independent testing is far more likely to yield an unbiased evaluation of your implementation. And as ddddavidee pointed out first, your best bet (for self-testing) is to roll your own script to test and compare with the KAT results, or look at the source code of an open-source implementation such as libgcrypt. https://en.wikipedia.org/wiki/Test_automation has more information about automated testing.

$\endgroup$
  • $\begingroup$ Sec. 6.1 of the document says: "To initiate the validation process of the AESAVS, a vendor submits an application to an accredited laboratory requesting the validation of their implementation of the algorithm specified in FIPS 197 ...". This means IMHO that an officially trusted laboratory is to (independently) certify the correctness of an implementation. If the implementer himself writes such a test suite there wouldn't be independence and the result would remain uncertain. (Analogy: In normal programming one could write one's own test codes but often risks to oversee one's own mistakes.) $\endgroup$ – Mok-Kong Shen Jan 5 '16 at 17:06
  • 1
    $\begingroup$ @Mok-KongShen no, you can still write the code to test your implementation, it would just not be officially validated for FIPS compliance. If you make a mistake coding the algorithm or AVS, you will almost certainly not get the same test values. $\endgroup$ – Richie Frame Jan 5 '16 at 21:04
  • 1
    $\begingroup$ @RichieFrame: What is in Appendix C of FIPS 197 is simply known results of certain test vectors. Hence it is a simple comparison to be done by the implementor. What is in AVS is however very much more comprehensive and requires some coding to be written carefully. $\endgroup$ – Mok-Kong Shen Jan 6 '16 at 11:12
  • $\begingroup$ @Mok-KongShen I know, I have coded the algorithm validation for AES MCT ECB so it produces the exact output found in the AVS vectors if the algorithm is correct, it performs around 10000 encryptions for each key size, and is the best way to test correctness independent of a mode $\endgroup$ – Richie Frame Jan 6 '16 at 12:46
0
$\begingroup$

I am not aware about a software doing what you're asking. Moreover I think it would be quite difficult to have a software testing for a generic implementation. It would be possible if there was a standard interface to run a specific operation (just think about the symmetric encryption: you have few variables and parameters as algorithm, mode, key, iv, message. It does not exist a specific input order to feed a given binary. It would be necessary that every developer produce a binary taking the input with the same order (in the same format/encoding: hex? base64? raw?). You may test your implementation implementing a binary that follow the CAVS driver used by OpenSSL and libgcrypt. You may find it here. It is quite easy to do. Then you have to download the CAVS file from the NIST site and run them.

$\endgroup$

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