-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BouncyCastle ongoing translation (#145)
* BcPQCSigner translation Signed-off-by: Hugo Queinnec <[email protected]> * Generic DuplicateParametersFinding2Test Signed-off-by: Hugo Queinnec <[email protected]> * update disabled tests Signed-off-by: Hugo Queinnec <[email protected]> * MergeableCollection Signed-off-by: Hugo Queinnec <[email protected]> * fix BcDigestingMessageSignerTest Signed-off-by: Hugo Queinnec <[email protected]> * fix BcISO9796d2PSSSignerTest Signed-off-by: Hugo Queinnec <[email protected]> * KeyWrap primitive Signed-off-by: Hugo Queinnec <[email protected]> * update wrap handling in translation and tests Signed-off-by: Hugo Queinnec <[email protected]> * translates most KeyWrap Signed-off-by: Hugo Queinnec <[email protected]> * update XOF in model Signed-off-by: Hugo Queinnec <[email protected]> * update Mac in model Signed-off-by: Hugo Queinnec <[email protected]> * update AE in model Signed-off-by: Hugo Queinnec <[email protected]> * remove ClassicalBitSecurityLevel when unecessary Signed-off-by: Hugo Queinnec <[email protected]> * MLKEM oid enricher Signed-off-by: Hugo Queinnec <[email protected]> * RFC3211 KeyWrap Signed-off-by: Hugo Queinnec <[email protected]> * fully cleans Java reorganizers Signed-off-by: Hugo Queinnec <[email protected]> * fix Wrapper tests + change Kalyna naming Signed-off-by: Hugo Queinnec <[email protected]> * fix DuplicateParametersFindingTest Signed-off-by: Hugo Queinnec <[email protected]> * remove Kind use from DigestContext Signed-off-by: Hugo Queinnec <[email protected]> * remove Kind use from AlgorithmParameterContext Signed-off-by: Hugo Queinnec <[email protected]> * fix IES test Signed-off-by: Hugo Queinnec <[email protected]> * remove Kind use from CipherContext Signed-off-by: Hugo Queinnec <[email protected]> * cleaning Signed-off-by: Hugo Queinnec <[email protected]> * remove Kind use in BC for KeyContext Signed-off-by: Hugo Queinnec <[email protected]> * remove Kind use in BC for SignatureContext and MacContext Signed-off-by: Hugo Queinnec <[email protected]> --------- Signed-off-by: Hugo Queinnec <[email protected]>
- Loading branch information
Showing
159 changed files
with
1,550 additions
and
1,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
enricher/src/main/java/com/ibm/enricher/algorithm/KEMEnricher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* SonarQube Cryptography Plugin | ||
* Copyright (C) 2024 IBM | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.ibm.enricher.algorithm; | ||
|
||
import com.ibm.enricher.IEnricher; | ||
import com.ibm.mapper.model.INode; | ||
import com.ibm.mapper.model.Oid; | ||
import com.ibm.mapper.model.ParameterSetIdentifier; | ||
import com.ibm.mapper.model.algorithms.kyber.MLKEM; | ||
import com.ibm.mapper.utils.DetectionLocation; | ||
import java.util.Optional; | ||
import javax.annotation.Nonnull; | ||
|
||
public class KEMEnricher implements IEnricher { | ||
|
||
@Override | ||
public @Nonnull INode enrich(@Nonnull INode node) { | ||
if (node instanceof MLKEM mlkem) { | ||
return enrichMLKEM(mlkem); | ||
} | ||
return node; | ||
} | ||
|
||
@Nonnull | ||
private MLKEM enrichMLKEM(@Nonnull MLKEM mlkem) { | ||
final Optional<INode> parameterSetIdentifierOptional = | ||
mlkem.hasChildOfType(ParameterSetIdentifier.class); | ||
if (parameterSetIdentifierOptional.isPresent() | ||
&& parameterSetIdentifierOptional.get() | ||
instanceof ParameterSetIdentifier parameterSetIdentifier) { | ||
final DetectionLocation detectionLocation = | ||
parameterSetIdentifier.getDetectionContext(); | ||
switch (parameterSetIdentifier.asString()) { | ||
case "512" -> mlkem.put(new Oid("2.16.840.1.101.3.4.4.1", detectionLocation)); | ||
case "768" -> mlkem.put(new Oid("2.16.840.1.101.3.4.4.2", detectionLocation)); | ||
case "1024" -> mlkem.put(new Oid("2.16.840.1.101.3.4.4.3", detectionLocation)); | ||
default -> { | ||
// the base OID for NIST KEM | ||
mlkem.put(new Oid("2.16.840.1.101.3.4.4", detectionLocation)); | ||
} | ||
} | ||
} | ||
return mlkem; | ||
} | ||
} |
Oops, something went wrong.