Skip to content

Commit

Permalink
Feature(#816): fix spotbugs-2
Browse files Browse the repository at this point in the history
  • Loading branch information
commjoen committed May 11, 2023
1 parent f6292a1 commit 261d6f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ private String decrypt(String cipherTextString) {
SecretKey decryptKey = new SecretKeySpec("AIKnowsThisKey12".getBytes(StandardCharsets.UTF_8), "AES");
AlgorithmParameterSpec gcmIv = new GCMParameterSpec(128, Base64.decode(cipherTextString), 0, 12);
decryptor.init(Cipher.DECRYPT_MODE, decryptKey, gcmIv);
byte[] cipherTextBytes = Base64.decode(cipherTextString.getBytes(StandardCharsets.UTF_8));
return new String(decryptor.doFinal(cipherTextBytes), 12, cipherTextBytes.length - 12, StandardCharsets.UTF_8);
return new String(decryptor.doFinal(Base64.decode(cipherTextString.getBytes(StandardCharsets.UTF_8)), 12, Base64.decode(cipherTextString.getBytes(StandardCharsets.UTF_8)).length - 12), StandardCharsets.UTF_8);
} catch (Exception e) {
log.warn("Exception in Challenge32", e);
return "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package org.owasp.wrongsecrets.challenges.docker;

import org.assertj.core.api.Assertions;
import org.bouncycastle.util.encoders.Base64;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.owasp.wrongsecrets.ScoreCard;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;

public class Challenge32Test {
@Mock
private ScoreCard scoreCard;
Expand All @@ -22,4 +32,5 @@ void incorrectAnswerShouldNotSolveChallenge() {
var challenge = new Challenge29(scoreCard);
Assertions.assertThat(challenge.solved("wrong answer")).isFalse();
}

}

0 comments on commit 261d6f9

Please sign in to comment.