-
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.
Password Based Encryption model (#135)
* PBE model + JCA update Signed-off-by: Hugo Queinnec <[email protected]> * BcPbeMapper Signed-off-by: Hugo Queinnec <[email protected]> * fix JCA tests Signed-off-by: Hugo Queinnec <[email protected]> * ECIES-KEM Signed-off-by: Hugo Queinnec <[email protected]> * chnage PBE mapping for jca Signed-off-by: Nicklas Körtge <[email protected]> * chnage PBE mapping for jca Signed-off-by: Nicklas Körtge <[email protected]> * update PBE and PKDF naming, update HMAC in jca, fix tests Signed-off-by: Nicklas Körtge <[email protected]> --------- Signed-off-by: Hugo Queinnec <[email protected]> Signed-off-by: Nicklas Körtge <[email protected]> Co-authored-by: Nicklas Körtge <[email protected]>
- Loading branch information
1 parent
ebcb614
commit e8bc9f9
Showing
20 changed files
with
397 additions
and
146 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
63 changes: 63 additions & 0 deletions
63
mapper/src/main/java/com/ibm/mapper/mapper/bc/BcPbeMapper.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,63 @@ | ||
/* | ||
* 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.mapper.mapper.bc; | ||
|
||
import com.ibm.mapper.mapper.IMapper; | ||
import com.ibm.mapper.model.Algorithm; | ||
import com.ibm.mapper.model.INode; | ||
import com.ibm.mapper.model.PBES1; | ||
import com.ibm.mapper.model.PBES2; | ||
import com.ibm.mapper.model.PKCS12PBE; | ||
import com.ibm.mapper.model.PasswordBasedEncryption; | ||
import com.ibm.mapper.model.Unknown; | ||
import com.ibm.mapper.utils.DetectionLocation; | ||
import java.util.Optional; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class BcPbeMapper implements IMapper { | ||
|
||
@Override | ||
@Nonnull | ||
public Optional<? extends INode> parse( | ||
@Nullable String str, @Nonnull DetectionLocation detectionLocation) { | ||
if (str == null) { | ||
return Optional.empty(); | ||
} | ||
return map(str, detectionLocation); | ||
} | ||
|
||
@Nonnull | ||
private Optional<? extends INode> map( | ||
@Nonnull String pbeString, @Nonnull DetectionLocation detectionLocation) { | ||
return switch (pbeString) { | ||
case "OpenSSLPBEParametersGenerator" -> Optional.of(new PBES1(detectionLocation)); | ||
case "PKCS12ParametersGenerator" -> Optional.of(new PKCS12PBE(detectionLocation)); | ||
case "PKCS5S1ParametersGenerator" -> Optional.of(new PBES1(detectionLocation)); | ||
case "PKCS5S2ParametersGenerator" -> Optional.of(new PBES2(detectionLocation)); | ||
default -> { | ||
final Algorithm algorithm = | ||
new Algorithm(pbeString, PasswordBasedEncryption.class, detectionLocation); | ||
algorithm.put(new Unknown(detectionLocation)); | ||
yield Optional.of(algorithm); | ||
} | ||
}; | ||
} | ||
} |
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
Oops, something went wrong.