Class AESKeyWrapTest


  • public class AESKeyWrapTest
    extends java.lang.Object
    Note: No 192-bit key tests, 192-bit AES is commonly unsupported on constrained platforms
    • Constructor Summary

      Constructors 
      Constructor Description
      AESKeyWrapTest()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void testAESWrap128_unwrap128()
      Test wrapping and unwrapping a 128-bit key using a 128-bit KEK.
      void testAESWrap128_wrap128()
      Test wrapping a 128-bit key using a 128-bit KEK, and verify the output against the RFC 3394 test vector (section 4.1).
      void testAESWrap256_unwrap256()
      Test wrapping and unwrapping a 256-bit key using a 256-bit KEK.
      void testAESWrap256_wrap128()
      Test wrapping a 128-bit key using a 256-bit KEK, and verify the output against the RFC 3394 test vector (section 4.3).
      void testAESWrap256_wrap256()
      Test wrapping a 256-bit key using a 256-bit KEK, and verify the output against the RFC 3394 test vector (section 4.6).
      void testParallelKeyWrap()
      Test parallel Cipher initialization and key wrapping.
      void testReinitWithDifferentKek()
      Initializing an already initialized key wrap cipher with another key-encryption key wraps as a freshly created cipher does, and the result unwraps.
      void testUnwrapRejectsAlteredBlob()
      Unwrapping a blob whose bytes were altered fails with the InvalidKeyException that Cipher.unwrap(byte[], String, int) declares.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AESKeyWrapTest

        public AESKeyWrapTest()
    • Method Detail

      • testAESWrap128_wrap128

        public void testAESWrap128_wrap128()
                                    throws java.lang.Exception
        Test wrapping a 128-bit key using a 128-bit KEK, and verify the output against the RFC 3394 test vector (section 4.1).
        Throws:
        java.lang.Exception
      • testAESWrap256_wrap128

        public void testAESWrap256_wrap128()
                                    throws java.lang.Exception
        Test wrapping a 128-bit key using a 256-bit KEK, and verify the output against the RFC 3394 test vector (section 4.3).
        Throws:
        java.lang.Exception
      • testAESWrap256_wrap256

        public void testAESWrap256_wrap256()
                                    throws java.lang.Exception
        Test wrapping a 256-bit key using a 256-bit KEK, and verify the output against the RFC 3394 test vector (section 4.6).
        Throws:
        java.lang.Exception
      • testAESWrap128_unwrap128

        public void testAESWrap128_unwrap128()
                                      throws java.lang.Exception
        Test wrapping and unwrapping a 128-bit key using a 128-bit KEK. Unwrap the result and verify it matches the original key.
        Throws:
        java.lang.Exception
      • testAESWrap256_unwrap256

        public void testAESWrap256_unwrap256()
                                      throws java.lang.Exception
        Test wrapping and unwrapping a 256-bit key using a 256-bit KEK. Unwrap the result and verify it matches the original key.
        Throws:
        java.lang.Exception
      • testParallelKeyWrap

        public void testParallelKeyWrap()
                                 throws java.lang.Throwable
        Test parallel Cipher initialization and key wrapping.
        Throws:
        java.lang.Throwable
      • testUnwrapRejectsAlteredBlob

        public void testUnwrapRejectsAlteredBlob()
                                          throws java.lang.Exception
        Unwrapping a blob whose bytes were altered fails with the InvalidKeyException that Cipher.unwrap(byte[], String, int) declares. The library raises it only for the error code the abstraction layer declares for a failed integrity check, not for a backend failure.

        RFC 3394 wraps an integrity value alongside the key, and unwrapping is the only thing that checks it. A caller that cannot tell the check failing from the backend failing cannot tell a blob it should reject from a fault of its own, so the distinction is the contract and not an implementation detail.

        Throws:
        java.lang.Exception
      • testReinitWithDifferentKek

        public void testReinitWithDifferentKek()
                                        throws java.lang.Exception
        Initializing an already initialized key wrap cipher with another key-encryption key wraps as a freshly created cipher does, and the result unwraps.

        The key wrap cipher has a close path of its own in the backend, reached from the second initialization only. A wrap is one operation, so no data can be fed to the first context before the second initialization.

        Throws:
        java.lang.Exception