Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit cbe6982

Browse files
committed
More fixes
1 parent e312520 commit cbe6982

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<artifactId>maven-surefire-plugin</artifactId>
6161
<executions>
6262
<execution>
63-
<id>utf8</id>
63+
<id>default-test</id>
6464
<goals>
6565
<goal>test</goal>
6666
</goals>

src/main/java/org/sonatype/plexus/components/cipher/PBECipher.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ Licensed to the Apache Software Foundation (ASF) under one
2222
import javax.crypto.Cipher;
2323
import javax.crypto.NoSuchPaddingException;
2424
import javax.crypto.SecretKeyFactory;
25-
import javax.crypto.spec.IvParameterSpec;
25+
import javax.crypto.spec.GCMParameterSpec;
2626
import javax.crypto.spec.PBEKeySpec;
2727
import javax.crypto.spec.SecretKeySpec;
2828

29+
import java.nio.charset.Charset;
30+
import java.nio.charset.StandardCharsets;
2931
import java.security.InvalidAlgorithmParameterException;
3032
import java.security.InvalidKeyException;
3133
import java.security.NoSuchAlgorithmException;
@@ -40,24 +42,13 @@ Licensed to the Apache Software Foundation (ASF) under one
4042
* @author Oleg Gusakov
4143
*/
4244
public class PBECipher {
43-
protected static final String STRING_ENCODING = "UTF8";
44-
45+
protected static final Charset STRING_ENCODING = StandardCharsets.UTF_8;
4546
protected static final int SPICE_SIZE = 16;
46-
4747
protected static final int SALT_SIZE = 8;
48-
4948
protected static final int CHUNK_SIZE = 16;
50-
51-
protected static final byte WIPER = 0;
52-
53-
protected static final String DIGEST_ALG = "SHA-256";
54-
5549
protected static final String KEY_ALG = "AES";
56-
57-
protected static final String CIPHER_ALG = "AES/CBC/PKCS5Padding";
58-
50+
protected static final String CIPHER_ALG = "AES/GCM/NoPadding";
5951
protected static final int PBE_ITERATIONS = 310000;
60-
6152
private static final SecureRandom _secureRandom = new SecureRandom();
6253

6354
// ---------------------------------------------------------------
@@ -144,7 +135,7 @@ private Cipher createCipher(final char[] pwd, byte[] salt, final int mode)
144135

145136
Cipher cipher = Cipher.getInstance(CIPHER_ALG);
146137

147-
cipher.init(mode, new SecretKeySpec(key, KEY_ALG), new IvParameterSpec(iv));
138+
cipher.init(mode, new SecretKeySpec(key, KEY_ALG), new GCMParameterSpec(128, iv));
148139

149140
return cipher;
150141
}

src/test/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class DefaultPlexusCipherTest {
3232

3333
final String str = "my testing phrase";
3434

35-
final String encStr = "t4RzIMd8AT0H3xnTd5IBX9zKE94G+D29fGBuhAJ4RblNC5zJLqYOIkVaSXJQFT7t";
35+
final String encStr = "cQupsZrOFpkGa7Ce/vdwr3a0Zun/X5VHsqXhnZOnhKB6VtTu7mfyI5gtycUsG3Fy";
3636
PlexusCipher pc;
3737

3838
@BeforeEach

src/test/java/org/sonatype/plexus/components/cipher/PBECipherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PBECipherTest {
3434

3535
final String clearText = "veryOpenText";
3636

37-
final String encryptedText = "0bzCbTRh5YQHZ2p7hkr6OZYrfhRqwc9ImgtYweX752k=";
37+
final String encryptedText = "ce/l2ofOiSELRT1WAjOyNoZbG+2FQcrlOKEdDr5mi6esyR2LfvBY855yxW5bqHZi";
3838

3939
final String password = "testtest";
4040

0 commit comments

Comments
 (0)