-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support non standard sha designations (#351)
* Use RFC5751 algorithm identifiers * Unit rtest for converting to FRC5751 identiifiers * Update to latest libraries and OpenAS2 version * Updated documentation around algorithm identifiers * Standalone method for reuse to adjust algorithm to standard format * Test different forms of the signing algorithm * Release notes
- Loading branch information
1 parent
443c681
commit 71fcd22
Showing
13 changed files
with
103 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.openas2.lib; | ||
|
||
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; | ||
import org.bouncycastle.mail.smime.SMIMESignedGenerator; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.openas2.lib.helper.BCCryptoHelper; | ||
import org.openas2.lib.helper.ICryptoHelper; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import java.security.NoSuchAlgorithmException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
|
||
public class HelperMethods { | ||
|
||
@Test | ||
public void convertAlgorithmString() throws NoSuchAlgorithmException { | ||
Map<String, String> algorithmChecks = new HashMap<String, String>(); | ||
algorithmChecks.put(ICryptoHelper.AES128_CBC, SMIMEEnvelopedGenerator.AES128_CBC); | ||
algorithmChecks.put(ICryptoHelper.DIGEST_SHA1.replaceAll("-", ""), SMIMESignedGenerator.DIGEST_SHA1); | ||
algorithmChecks.put(ICryptoHelper.DIGEST_SHA256.replaceAll("-", ""), SMIMESignedGenerator.DIGEST_SHA256); | ||
algorithmChecks.put(ICryptoHelper.DIGEST_SHA256.replaceAll("-", "2_"), SMIMESignedGenerator.DIGEST_SHA256); | ||
algorithmChecks.put(ICryptoHelper.DIGEST_SHA256.replaceAll("-", "2-"), SMIMESignedGenerator.DIGEST_SHA256); | ||
algorithmChecks.put(ICryptoHelper.DIGEST_SHA384.replaceAll("-", "2-"), SMIMESignedGenerator.DIGEST_SHA384); | ||
|
||
BCCryptoHelper bch = new BCCryptoHelper(); | ||
for (Map.Entry<String, String> entry : algorithmChecks.entrySet()) { | ||
String convertedAlgo = bch.convertAlgorithm(entry.getKey(), true); | ||
assertThat("Algorithm matches expected", convertedAlgo, equalTo(entry.getValue())); | ||
} | ||
} | ||
} |
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
Binary file not shown.
Binary file not shown.
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