Package com.microej.crypto.test
Class AESNistVectorsTest
- java.lang.Object
-
- com.microej.crypto.test.AESNistVectorsTest
-
public class AESNistVectorsTest extends java.lang.ObjectChecks AES/ECB and AES/CTR against the example vectors of NIST SP 800-38A.The expected values come from the standard rather than from a run of the implementation, so they constrain the backend instead of recording what it happens to produce. ECB uses appendix F.1 and CTR appendix F.5, both over the same four-block plaintext, which is what makes the two directly comparable.
Key sizes are read from
com.microej.crypto.test.cipher.aes.keysizes. A VEE Port whose backend lacks one of them shortens the list.
-
-
Constructor Summary
Constructors Constructor Description AESNistVectorsTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidtestCtrDecryptMatchesNistVector()Decrypting the appendix F.5 ciphertext with AES/CTR gives the plaintext back.voidtestCtrEncryptMatchesNistVector()Encrypting the appendix F plaintext with AES/CTR gives the ciphertext of appendix F.5.voidtestEcbDecryptMatchesNistVector()Decrypting the appendix F.1 ciphertext with AES/ECB gives the plaintext back.voidtestEcbEncryptMatchesNistVector()Encrypting the appendix F plaintext with AES/ECB gives the ciphertext of appendix F.1.voidtestMultiBlockUpdateMatchesSinglePass()Feeding the input one block at a time throughupdate()gives the same output as onedoFinal(), when encrypting and when decrypting.
-
-
-
Method Detail
-
testEcbEncryptMatchesNistVector
public void testEcbEncryptMatchesNistVector() throws java.lang.ExceptionEncrypting the appendix F plaintext with AES/ECB gives the ciphertext of appendix F.1.- Throws:
java.lang.Exception
-
testEcbDecryptMatchesNistVector
public void testEcbDecryptMatchesNistVector() throws java.lang.ExceptionDecrypting the appendix F.1 ciphertext with AES/ECB gives the plaintext back.- Throws:
java.lang.Exception
-
testCtrEncryptMatchesNistVector
public void testCtrEncryptMatchesNistVector() throws java.lang.ExceptionEncrypting the appendix F plaintext with AES/CTR gives the ciphertext of appendix F.5.- Throws:
java.lang.Exception
-
testCtrDecryptMatchesNistVector
public void testCtrDecryptMatchesNistVector() throws java.lang.ExceptionDecrypting the appendix F.5 ciphertext with AES/CTR gives the plaintext back.- Throws:
java.lang.Exception
-
testMultiBlockUpdateMatchesSinglePass
public void testMultiBlockUpdateMatchesSinglePass() throws java.lang.ExceptionFeeding the input one block at a time throughupdate()gives the same output as onedoFinal(), when encrypting and when decrypting.A four-block input is what makes this worth testing: an implementation that mishandles its internal buffer, or the counter it keeps between two calls, produces the right answer for a single block and the wrong one here.
- Throws:
java.lang.Exception
-
-