0
$\begingroup$

I'm working to implement AES (128/256 - either) on one of the RISCV ISA processors & later improve performance by introducing a custom instruction in RISCV ISA.

I'm a crypto newbie and plan to use the NIST test vectors to validate this C code.

I need to know the below things

1) Is there a link wherein i can find implementation of AES using standard C library ?

2) Do i have to use some hashing scheme along with AES ? If yes, which one ?

3) Is it a good idea to validate my AES C code with the NIST test vectors

4) Do you recommend using a encryption library instead ? If so where can i find it ?

$\endgroup$
  • $\begingroup$ I'm sorry, but library recommendations and implementation recommendations are off-topic here (i.e. your question #1 and the second half of the fourth). They won't be answered because they could get outdated and be actively missleading at that point. $\endgroup$ – SEJPM Oct 19 '16 at 12:20
  • $\begingroup$ 1) I implemented AES in C (with some optimizations of my own) in mokkong-shen.privat.t-online.de 2) No. 3) Yes. cf. also my Python implementation of AES in s13.zetaboards.com/Crypto/topic/7285224/1 4) No. $\endgroup$ – Mok-Kong Shen Oct 20 '16 at 14:28
2
$\begingroup$

Don't roll your own. (AKA: The first rule of cryptography.)

enter image description here

Do not create your own cipher, do not implement a cipher.

Is there a link wherein i can find implementation of AES using standard C library ?

You can find a C implementation of AES in The Design of Rijndael, Section E, page 221. Test vectors are also provided in Section D. However, it is not recommended to use this implementation because it is vulnerable to cache timing attacks:

Do i have to use some hashing scheme along with AES ? If yes, which one ?

You need a hashing scheme only if you want to provide authenticity/integrity (see MAC schemes, for more reading about this see here). Thus having a hashing scheme along is completely independent to having your AES implementation. You might however want to have a look at AES with GCM, EAX or CCM to provide authentication.

For hashing function, if you go by the standards, it is advised to use at least SHA-256 or even better SHA3-256 (as specified in FIPS 202 by the NIST).

Is it a good idea to validate my AES C code with the NIST test vectors

It is more than a good idea. It is required. However, making your implementation work and produce the same results as the test vectors does not guarantees you that your implementation is correct (it does still provide you a strong confidence that your code might be correct). You have to check that every parts of your implementation matches the specifications of the algorithm.

Do you recommend using a encryption library instead ? If so where can i find it ?

Using a encryption library is highly recommended. It will prevent you from suffering from cache timing attacks and other nasty things. It also guarantees that the code is correctly implemented. As for which library to use, at the time of the post (October 2016), you can have a look at OpenSSL, Libsodium or NaCl.

$\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.