Package org.jivesoftware.util
Class AesEncryptor
java.lang.Object
org.jivesoftware.util.AesEncryptor
- All Implemented Interfaces:
Encryptor
Utility class providing symmetric AES encryption/decryption. To strengthen
the encrypted result, use the
setKey(byte[]) method to provide a custom
key prior to invoking the encrypt(java.lang.String) or decrypt(java.lang.String) methods.- Author:
- Tom Evans
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDecrypts a Base64-encoded encrypted string using AES with hardcoded IV.Decrypt an encrypted String.Deprecated.This method uses a hardcoded IV which makes encryption deterministic (same plaintext always produces same ciphertext).Encrypt a clear text String.voidSet the encryption key.
-
Constructor Details
-
AesEncryptor
public AesEncryptor()Default constructor -
AesEncryptor
Custom key constructor- Parameters:
key- the custom key
-
-
Method Details
-
encrypt
Deprecated.This method uses a hardcoded IV which makes encryption deterministic (same plaintext always produces same ciphertext). This is a security vulnerability as it enables pattern analysis attacks. Useencrypt(String, byte[])with a randomly generated IV instead. This method is only kept for backward compatibility with existing encrypted values in configuration files.Encrypts a string value using AES with hardcoded IV. -
encrypt
Description copied from interface:EncryptorEncrypt a clear text String. -
decrypt
Decrypts a Base64-encoded encrypted string using AES with hardcoded IV. This method is kept for backward compatibility with values encrypted by older versions of Openfire that used a hardcoded IV. For new encryption operations, useencrypt(String, byte[])with a randomly generated IV anddecrypt(String, byte[])with the same IV for decryption. -
decrypt
Description copied from interface:EncryptorDecrypt an encrypted String. -
setKey
Description copied from interface:EncryptorSet the encryption key. This will apply the user-defined key, truncated or filled (via the default key) as needed to meet the key length specifications.
-