Class AesCipherUtil


  • public class AesCipherUtil
    extends Object
    • Constructor Detail

      • AesCipherUtil

        public AesCipherUtil()
    • Method Detail

      • derivePasswordBasedKey

        public static byte[] derivePasswordBasedKey​(byte[] salt,
                                                    char[] password,
                                                    AesKeyStrength aesKeyStrength,
                                                    boolean useUtf8ForPassword)
                                             throws ZipException
        Derive Password-Based Key for AES according to AE-1 and AE-2 Specifications
        Parameters:
        salt - Salt used for PBKDF2
        password - Password used for PBKDF2 containing characters matching ISO-8859-1 character set
        aesKeyStrength - Requested AES Key and MAC Strength
        Returns:
        Derived Password-Based Key
        Throws:
        ZipException - Thrown when Derived Key is not valid
      • derivePasswordVerifier

        public static byte[] derivePasswordVerifier​(byte[] derivedKey,
                                                    AesKeyStrength aesKeyStrength)
        Derive Password Verifier using Derived Key and requested AES Key Strength
        Parameters:
        derivedKey - Derived Key
        aesKeyStrength - AES Key Strength
        Returns:
        Derived Password Verifier
      • getMacBasedPRF

        public static MacBasedPRF getMacBasedPRF​(byte[] derivedKey,
                                                 AesKeyStrength aesKeyStrength)
        Get MAC-Based PRF using default HMAC Algorithm defined in AE-1 and AE-2 Specification
        Parameters:
        derivedKey - Derived Key
        aesKeyStrength - AES Key Strength
        Returns:
        Initialized MAC-Based PRF
      • getAESEngine

        public static AESEngine getAESEngine​(byte[] derivedKey,
                                             AesKeyStrength aesKeyStrength)
                                      throws ZipException
        Get AES Engine using derived key and requested AES Key Strength
        Parameters:
        derivedKey - Derived Key
        aesKeyStrength - AES Key Strength
        Returns:
        AES Engine configured with AES Key
        Throws:
        ZipException - Thrown on AESEngine initialization failures
      • prepareBuffAESIVBytes

        public static void prepareBuffAESIVBytes​(byte[] buff,
                                                 int nonce)