Class AESCipherTest


  • public class AESCipherTest
    extends java.lang.Object
    Tests for AES cipher operations including CBC, CTR, and authenticated cipher modes (e.g. GCM, CCM).

    Authenticated cipher tests are configuration-driven. All properties are prefixed with com.microej.crypto.test. and hex-encoded unless stated otherwise.

    • cipher.auth.transformations - comma-separated list of transformations to test (default: AES/GCM/NoPadding). <i> in the following properties refers to the 0-based index in this list.
    • cipher.auth.<i>.keySizes - comma-separated key sizes in bits (default: 128)
    • cipher.auth.<i>.plaintext - plaintext (default: 000102030405060708090a0b0c0d0e0f)
    • cipher.auth.<i>.nonce - nonce (default: 0123456789abcdef01234567, 12 bytes)
    • cipher.auth.<i>.aad - additional authenticated data (default: 0123456789abcdef0123456789abcdef)
    • cipher.auth.<i>.key.<keySize> - raw key for the given key size (default: 0123456789abcdef0123456789abcdef)
    • cipher.auth.<i>.cipherTextAndTag.<keySize> - expected ciphertext+tag without AAD
    • cipher.auth.<i>.cipherTextAndTag.<keySize>.withAad - expected ciphertext+tag with AAD
    • Constructor Detail

      • AESCipherTest

        public AESCipherTest()
    • Method Detail

      • testAES128_16bytes

        public void testAES128_16bytes()
                                throws java.lang.Exception
        Test encryption of 16 data bytes using a 128-bit AES key, and verify the output against a precomputed ciphertext.
        Throws:
        java.lang.Exception
      • testAES128_80bytes

        public void testAES128_80bytes()
                                throws java.lang.Exception
        Test encryption of 80 data bytes using a 128-bit AES key, and verify the output against a precomputed ciphertext.
        Throws:
        java.lang.Exception
      • testAES256_16bytes

        public void testAES256_16bytes()
                                throws java.lang.Exception
        Test encryption of 16 data bytes using a 256-bit AES key, and verify the output against a precomputed ciphertext.
        Throws:
        java.lang.Exception
      • testAES256_80bytes

        public void testAES256_80bytes()
                                throws java.lang.Exception
        Test encryption of 80 data bytes using a 256-bit AES key, and verify the output against a precomputed ciphertext.
        Throws:
        java.lang.Exception
      • testAES128_16bytes_no_IV

        public void testAES128_16bytes_no_IV()
                                      throws java.lang.Exception
        Test encryption of 16 data bytes using a 128-bit AES key without an initialization vector. Decrypt the result and verify it matches the original plaintext.
        Throws:
        java.lang.Exception
      • testAES128_80bytes_no_IV

        public void testAES128_80bytes_no_IV()
                                      throws java.lang.Exception
        Test encryption of 80 data bytes using a 128-bit AES key without an initialization vector. Decrypt the result and verify it matches the original plaintext.
        Throws:
        java.lang.Exception
      • testAES256_16bytes_no_IV

        public void testAES256_16bytes_no_IV()
                                      throws java.lang.Exception
        Test encryption of 16 data bytes using a 256-bit AES key without an initialization vector. Decrypt the result and verify it matches the original plaintext.
        Throws:
        java.lang.Exception
      • testAES256_80bytes_no_IV

        public void testAES256_80bytes_no_IV()
                                      throws java.lang.Exception
        Test encryption of 80 data bytes using a 256-bit AES key without an initialization vector. Decrypt the result and verify it matches the original plaintext.
        Throws:
        java.lang.Exception
      • testParallelCipherEncryption

        public void testParallelCipherEncryption()
                                          throws java.lang.Exception
        Test parallel Cipher initialization and encryption
        Throws:
        java.lang.Exception
      • testMultiPartCipherAndResetOnDoFinalNoPadding

        public void testMultiPartCipherAndResetOnDoFinalNoPadding()
                                                           throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • testAuthenticatedCipherEncrypt

        public void testAuthenticatedCipherEncrypt()
                                            throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • testAuthenticatedCipherEncryptWithAad

        public void testAuthenticatedCipherEncryptWithAad()
                                                   throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • testAuthenticatedCipherDecrypt

        public void testAuthenticatedCipherDecrypt()
                                            throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • testAuthenticatedCipherDecryptWithAad

        public void testAuthenticatedCipherDecryptWithAad()
                                                   throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException