Skip to content

Commit

Permalink
change PBES1 naming, fix tests (#140)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicklas Körtge <[email protected]>
  • Loading branch information
n1ckl0sk0rtge authored Sep 16, 2024
1 parent af7d128 commit 586910a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void asserts(

INode blockCipher = node.getChildren().get(PublicKeyEncryption.class);
assertThat(blockCipher).isNotNull();
assertThat(blockCipher.asString()).isEqualTo("RSA");
assertThat(blockCipher.asString()).isEqualTo("RSA-2048");

INode defaultKeyLength = blockCipher.getChildren().get(KeyLength.class);
assertThat(defaultKeyLength).isNotNull();
Expand Down
4 changes: 2 additions & 2 deletions mapper/src/main/java/com/ibm/mapper/model/PBES1.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public String asString() {
final Optional<INode> mac = this.hasChildOfType(Mac.class);
final Optional<INode> cipher = this.hasChildOfType(BlockCipher.class);

if (messageDigest.isPresent() && cipher.isPresent()) {
return "pbeWith" + messageDigest.get().asString() + "And" + cipher.get().asString();
if (messageDigest.isPresent() && cipher.isPresent() && cipher.get() instanceof Cipher c) {
return "pbeWith" + messageDigest.get().asString() + "And" + c.getName();
} else if (mac.isPresent()) {
String n = "pbeWith" + changeHMACNameing(mac.get().asString());
return cipher.map(node -> n + "And" + node.asString()).orElse(n);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.ibm.mapper.model.algorithms.DSA;
import com.ibm.mapper.model.algorithms.SHA2;
import com.ibm.mapper.utils.DetectionLocation;
import com.ibm.mapper.utils.Utils;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
Expand All @@ -47,6 +48,7 @@ public void test1() {
assertThat(node).isPresent();
assertThat(node.get().is(CipherSuite.class)).isTrue();
final CipherSuite cipherSuite = (CipherSuite) node.get();
Utils.printNodeTree("tree", List.of(cipherSuite));

assertThat(cipherSuite.getAssetCollection()).isPresent();
assertThat(cipherSuite.getIdentifierCollection()).isPresent();
Expand All @@ -63,8 +65,7 @@ public void test1() {
assertThat(assetCollection)
.contains(
new AES(testDetectionLocation),
new DSA(testDetectionLocation),
new SHA2(256, testDetectionLocation),
new DSA(new SHA2(256, testDetectionLocation)),
new DH(KeyAgreement.class, testDetectionLocation));
}

Expand Down

0 comments on commit 586910a

Please sign in to comment.