Skip to content

Commit

Permalink
shake parameterSetIdentifier
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoqnc committed Sep 3, 2024
1 parent d394578 commit 63cdd05
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public final class PycaDigestMapper implements IMapper {
case "SHA3_256" -> Optional.of(new SHA3(256, detectionLocation));
case "SHA3_384" -> Optional.of(new SHA3(384, detectionLocation));
case "SHA3_512" -> Optional.of(new SHA3(512, detectionLocation));
case "SHAKE128", "SHAKE256" -> Optional.of(new SHAKE(detectionLocation));
case "SHAKE128" -> Optional.of(new SHAKE(128, detectionLocation));
case "SHAKE256" -> Optional.of(new SHAKE(256, detectionLocation));
case "MD5" -> Optional.of(new MD5(detectionLocation));
case "BLAKE2B" -> Optional.of(new BLAKE2b(false, detectionLocation));
case "BLAKE2S" -> Optional.of(new BLAKE2s(false, detectionLocation));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,16 @@ public final class PycaHashBasedKeyDerivationMapper implements IMapper {
Optional.of(
new SHA3(
KeyDerivationFunction.class, new SHA3(512, detectionLocation)));
case "SHAKE128", "SHAKE256" ->
case "SHAKE128" ->
Optional.of(
new SHAKE(KeyDerivationFunction.class, new SHAKE(detectionLocation)));
new SHAKE(
KeyDerivationFunction.class,
new SHAKE(128, detectionLocation)));
case "SHAKE256" ->
Optional.of(
new SHAKE(
KeyDerivationFunction.class,
new SHAKE(256, detectionLocation)));
case "MD5" -> Optional.of(new MD5(Mac.class, detectionLocation));
case "BLAKE2B" ->
Optional.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public class PycaMacMapper implements IMapper {
case "SHA3_256" -> Optional.of(new SHA3(Mac.class, new SHA3(256, detectionLocation)));
case "SHA3_384" -> Optional.of(new SHA3(Mac.class, new SHA3(384, detectionLocation)));
case "SHA3_512" -> Optional.of(new SHA3(Mac.class, new SHA3(512, detectionLocation)));
case "SHAKE128", "SHAKE256" ->
Optional.of(new SHAKE(Mac.class, new SHAKE(detectionLocation)));
case "SHAKE128" -> Optional.of(new SHAKE(Mac.class, new SHAKE(128, detectionLocation)));
case "SHAKE256" -> Optional.of(new SHAKE(Mac.class, new SHAKE(256, detectionLocation)));
case "MD5" -> Optional.of(new MD5(Mac.class, detectionLocation));
case "BLAKE2B" ->
Optional.of(new BLAKE2b(Mac.class, new BLAKE2b(false, detectionLocation)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public final class Ed448 extends EdDSA implements Signature {
public Ed448(@NotNull DetectionLocation detectionLocation) {
super(NAME, detectionLocation);
this.put(new Edwards448(detectionLocation));
this.put(new SHAKE(detectionLocation));
this.put(new SHAKE(256, detectionLocation));
this.put(new Oid("1.3.101.113", detectionLocation));
}
}
25 changes: 25 additions & 0 deletions mapper/src/main/java/com/ibm/mapper/model/algorithms/SHAKE.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@

import com.ibm.mapper.model.Algorithm;
import com.ibm.mapper.model.ExtendableOutputFunction;
import com.ibm.mapper.model.INode;
import com.ibm.mapper.model.IPrimitive;
import com.ibm.mapper.model.ParameterSetIdentifier;
import com.ibm.mapper.utils.DetectionLocation;
import java.util.Optional;
import javax.annotation.Nonnull;

public final class SHAKE extends Algorithm implements ExtendableOutputFunction {
Expand All @@ -32,6 +35,28 @@ public SHAKE(@Nonnull DetectionLocation detectionLocation) {
super(NAME, ExtendableOutputFunction.class, detectionLocation);
}

/** Returns a name of the form "SHAKEXXX" where XXX is the parameter set identifer */
@Override
@Nonnull
public String getName() {
StringBuilder builtName = new StringBuilder(this.name);

Optional<INode> parameterSetIdentifier = this.hasChildOfType(ParameterSetIdentifier.class);

if (parameterSetIdentifier.isPresent()) {
builtName.append(parameterSetIdentifier.get().asString());
}

return builtName.toString();
}

public SHAKE(int parameterSetIdentifier, @Nonnull DetectionLocation detectionLocation) {
this(detectionLocation);
this.put(
new ParameterSetIdentifier(
String.valueOf(parameterSetIdentifier), detectionLocation));
}

public SHAKE(@Nonnull final Class<? extends IPrimitive> asKind, @Nonnull SHAKE shake) {
super(shake, asKind);
}
Expand Down

0 comments on commit 63cdd05

Please sign in to comment.