Skip to content

Commit 046176d

Browse files
Ensuring OAEP is used with RSA.
1 parent 4120161 commit 046176d

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed
+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri May 15 17:54:33 EDT 2020
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
31
distributionBase=GRADLE_USER_HOME
42
distributionPath=wrapper/dists
5-
zipStorePath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
64
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

gradlew

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fi
130130
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131131
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132132
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133-
133+
134134
JAVACMD=`cygpath --unix "$JAVACMD"`
135135

136136
# We build the pattern for arguments to be converted via cygpath

src/main/java/com/softwareverde/security/rsa/BouncyCastleRsaKeys.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.bouncycastle.crypto.AsymmetricBlockCipher;
1212
import org.bouncycastle.crypto.Signer;
1313
import org.bouncycastle.crypto.digests.SHA256Digest;
14-
import org.bouncycastle.crypto.encodings.PKCS1Encoding;
14+
import org.bouncycastle.crypto.encodings.OAEPEncoding;
1515
import org.bouncycastle.crypto.engines.RSAEngine;
1616
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
1717
import org.bouncycastle.crypto.params.RSAKeyParameters;
@@ -65,7 +65,7 @@ public BouncyCastleRsaKeys(final PGPPublicKey publicKey, final PGPPrivateKey pri
6565
throw new RuntimeException("Unable to store private key information", exception);
6666
}
6767

68-
_cipher = new PKCS1Encoding(new RSAEngine());
68+
_cipher = new OAEPEncoding(new RSAEngine());
6969
_signer = new RSADigestSigner(new SHA256Digest());
7070
}
7171

@@ -82,7 +82,7 @@ public BouncyCastleRsaKeys(final byte[] publicKey, final byte[] privateKey, fina
8282
throw new IOException("Unable to convert keys", exception);
8383
}
8484

85-
_cipher = new PKCS1Encoding(new RSAEngine());
85+
_cipher = new OAEPEncoding(new RSAEngine());
8686
_signer = new RSADigestSigner(new SHA256Digest());
8787
}
8888

@@ -156,7 +156,7 @@ public static byte[] encryptWithPublicKey(final PGPPublicKey publicKey, final by
156156

157157
try {
158158
AsymmetricKeyParameter underlyingPublicKey = _createPublicKey(publicKey);
159-
AsymmetricBlockCipher cipher = new PKCS1Encoding(new RSAEngine());
159+
AsymmetricBlockCipher cipher = new OAEPEncoding(new RSAEngine());
160160

161161
cipher.init(true, underlyingPublicKey);
162162
return cipher.processBlock(plainText, 0, plainText.length);

0 commit comments

Comments
 (0)