diff --git a/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/AesGcmSiv.java b/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/AesGcmSiv.java index 864ab9fc23..dbb8926bd4 100644 --- a/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/AesGcmSiv.java +++ b/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/AesGcmSiv.java @@ -29,7 +29,6 @@ */ public class AesGcmSiv implements PersistenceCipher { - // TODO: Encrypt secret? private SecretKey secret; private Provider cryptoProvider; private PersistenceCipherType cipherType; @@ -66,7 +65,7 @@ public static AesGcmSiv create(BinaryString secret) throws InvalidKeyException { instance = new AesGcmSiv(secretKey, cipherType); } else { - throw new InvalidKeyException("The secret has to be 128, 192 or 256 bits long, but was " + (rawSecret.length * 8) + " bits long."); + throw new InvalidKeyException("The secret has to be 128 or 256 bits long, but was " + (rawSecret.length * 8) + " bits long."); } return instance; diff --git a/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/BinaryStringFactory.java b/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/BinaryStringFactory.java index 6560287fc5..828969b3b3 100644 --- a/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/BinaryStringFactory.java +++ b/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/BinaryStringFactory.java @@ -52,7 +52,7 @@ public static BinaryString createFromBytes(byte[] bytes, BinaryStringEncodingTyp * @return */ public static BinaryString createFromString(String string) { - return createFromString(string, BinaryStringEncodingType.BASE64); + return createFromString(string, DEFAULT_ENCODING_TYPE); } /** diff --git a/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/RotationStrategy.java b/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/RotationStrategy.java index 69a62f026b..04659d256b 100644 --- a/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/RotationStrategy.java +++ b/sechub-commons-core/src/main/java/com/mercedesbenz/sechub/commons/core/security/persistence/RotationStrategy.java @@ -193,6 +193,6 @@ public boolean isSecretRotationStrategy() { } public boolean isCipherRotationStrategy() { - return (currentCipher.getCipherType() != newCipher.getCipherType()) ? true : false; + return currentCipher.getCipherType() != newCipher.getCipherType(); } } diff --git a/sechub-commons-core/src/test/java/com/mercedesbenz/sechub/commons/core/security/persistence/AesGcmSivTest.java b/sechub-commons-core/src/test/java/com/mercedesbenz/sechub/commons/core/security/persistence/AesGcmSivTest.java index 74b8f72a85..d196a1c772 100644 --- a/sechub-commons-core/src/test/java/com/mercedesbenz/sechub/commons/core/security/persistence/AesGcmSivTest.java +++ b/sechub-commons-core/src/test/java/com/mercedesbenz/sechub/commons/core/security/persistence/AesGcmSivTest.java @@ -194,7 +194,7 @@ void encrypt__aes_256_hex_format_and_emojis() throws InvalidKeyException, Invali void encrypt__aes_128_base64_format_and_emojis() throws InvalidKeyException, InvalidAlgorithmParameterException { /* prepare */ BinaryString secret = new Base64String("🍐🍌🍓🍉"); - ; + String plaintext = "Hello 👋, welcome to 🌐."; String expectedCiphertext = "Qu7ICJBGMw9dAPPBWx86e5bjOq3YKC+x25n/YkluWZAGdSna08tKaE78pMk="; BinaryString initializationVector = new Base64String("🧅".repeat(AesGcmSiv.IV_LENGTH_IN_BYTES / 4));