Skip to content

Commit 402dbbf

Browse files
author
jester
committed
Supporting OAEP with SHA256 key encryption/decrption.
This is a back port of the feature from RI 8.1.0. It changes the default key encryption algorithm to use OAEP with SHA1 and support decypting with a SHA256 key digest.
1 parent 3ab1d02 commit 402dbbf

File tree

12 files changed

+1418
-1059
lines changed

12 files changed

+1418
-1059
lines changed

pom.xml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<artifactId>agent</artifactId>
66
<name>Direct Project Security And Trust Agent</name>
7-
<version>6.0.4</version>
7+
<version>6.1.0-SNAPSHOT</version>
88
<description>Direct Project Security And Trust Agent</description>
99
<inceptionYear>2010</inceptionYear>
1010
<url>https://github.com/DirectProjectJavaRI/agent</url>
@@ -54,12 +54,18 @@
5454
<dependency>
5555
<groupId>org.nhind</groupId>
5656
<artifactId>direct-policy</artifactId>
57+
<exclusions>
58+
<exclusion>
59+
<groupId>org.bouncycastle</groupId>
60+
<artifactId>bcprov-jdk15on</artifactId>
61+
</exclusion>
62+
</exclusions>
5763
<version>6.0</version>
5864
</dependency>
5965
<dependency>
6066
<groupId>org.nhind</groupId>
6167
<artifactId>direct-common</artifactId>
62-
<version>6.0.1</version>
68+
<version>6.1.0-SNAPSHOT</version>
6369
</dependency>
6470
<dependency>
6571
<groupId>org.nhind</groupId>
@@ -99,18 +105,18 @@
99105
</dependency>
100106
<dependency>
101107
<groupId>org.bouncycastle</groupId>
102-
<artifactId>bcprov-jdk15on</artifactId>
103-
<version>1.60</version>
108+
<artifactId>bcprov-jdk18on</artifactId>
109+
<version>1.81</version>
104110
</dependency>
105111
<dependency>
106112
<groupId>org.bouncycastle</groupId>
107-
<artifactId>bcmail-jdk15on</artifactId>
108-
<version>1.60</version>
113+
<artifactId>bcmail-jdk18on</artifactId>
114+
<version>1.81</version>
109115
</dependency>
110116
<dependency>
111117
<groupId>org.bouncycastle</groupId>
112-
<artifactId>bcpkix-jdk15on</artifactId>
113-
<version>1.60</version>
118+
<artifactId>bcpkix-jdk18on</artifactId>
119+
<version>1.81</version>
114120
</dependency>
115121
<dependency>
116122
<groupId>dnsjava</groupId>

src/main/java/org/nhindirect/stagent/cert/tools/certgen/CertGenerator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4444
import org.apache.commons.io.FileUtils;
4545
import org.bouncycastle.asn1.ASN1Sequence;
4646
import org.bouncycastle.asn1.ASN1Set;
47-
import org.bouncycastle.asn1.DERObjectIdentifier;
4847
import org.bouncycastle.asn1.DERSequence;
4948
import org.bouncycastle.asn1.cms.Attribute;
5049
import org.bouncycastle.asn1.pkcs.CertificationRequestInfo;

src/main/java/org/nhindirect/stagent/cryptography/EncryptionAlgorithm.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2323
package org.nhindirect.stagent.cryptography;
2424

2525
import org.apache.commons.lang3.StringUtils;
26+
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
2627
import org.bouncycastle.cms.CMSEnvelopedGenerator;
2728
import org.bouncycastle.cms.CMSSignedDataGenerator;
2829
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator;
@@ -45,8 +46,10 @@ public enum EncryptionAlgorithm
4546
DES_EDE3_CBC("DESEDE/CBC/PKCS5Padding", CMSEnvelopedGenerator.DES_EDE3_CBC),
4647
AES128_CBC("AES/CBC/PKCS5Padding", CMSEnvelopedGenerator.AES128_CBC),
4748
AES192_CBC("AES/CBC/PKCS5Padding", CMSEnvelopedGenerator.AES192_CBC),
48-
AES256_CBC("AES/CBC/PKCS5Padding", CMSEnvelopedGenerator.AES256_CBC);
49-
49+
AES256_CBC("AES/CBC/PKCS5Padding", CMSEnvelopedGenerator.AES256_CBC),
50+
RSA_OAEP("RSA_OAEP", PKCSObjectIdentifiers.id_RSAES_OAEP.getId()),
51+
RSA_PKCS1_V15("RSA_PKCS1_V15", PKCSObjectIdentifiers.rsaEncryption.getId());
52+
5053
protected final String algName;
5154
protected final String OID;
5255

@@ -82,7 +85,9 @@ else if (algorithmName.equalsIgnoreCase(RSA.getAlgName()))
8285
else if (algorithmName.equalsIgnoreCase(RSAandMGF1.getAlgName()))
8386
return RSAandMGF1;
8487
else if (algorithmName.equalsIgnoreCase(ECDSA.getAlgName()))
85-
return ECDSA;
88+
return ECDSA;
89+
else if (algorithmName.equalsIgnoreCase(RSA_PKCS1_V15.getAlgName()))
90+
return RSA_PKCS1_V15;
8691
else
8792
return defaultAlgorithm;
8893
}

0 commit comments

Comments
 (0)