11
11
import org .bouncycastle .crypto .AsymmetricBlockCipher ;
12
12
import org .bouncycastle .crypto .Signer ;
13
13
import org .bouncycastle .crypto .digests .SHA256Digest ;
14
- import org .bouncycastle .crypto .encodings .PKCS1Encoding ;
14
+ import org .bouncycastle .crypto .encodings .OAEPEncoding ;
15
15
import org .bouncycastle .crypto .engines .RSAEngine ;
16
16
import org .bouncycastle .crypto .params .AsymmetricKeyParameter ;
17
17
import org .bouncycastle .crypto .params .RSAKeyParameters ;
@@ -65,7 +65,7 @@ public BouncyCastleRsaKeys(final PGPPublicKey publicKey, final PGPPrivateKey pri
65
65
throw new RuntimeException ("Unable to store private key information" , exception );
66
66
}
67
67
68
- _cipher = new PKCS1Encoding (new RSAEngine ());
68
+ _cipher = new OAEPEncoding (new RSAEngine ());
69
69
_signer = new RSADigestSigner (new SHA256Digest ());
70
70
}
71
71
@@ -82,7 +82,7 @@ public BouncyCastleRsaKeys(final byte[] publicKey, final byte[] privateKey, fina
82
82
throw new IOException ("Unable to convert keys" , exception );
83
83
}
84
84
85
- _cipher = new PKCS1Encoding (new RSAEngine ());
85
+ _cipher = new OAEPEncoding (new RSAEngine ());
86
86
_signer = new RSADigestSigner (new SHA256Digest ());
87
87
}
88
88
@@ -156,7 +156,7 @@ public static byte[] encryptWithPublicKey(final PGPPublicKey publicKey, final by
156
156
157
157
try {
158
158
AsymmetricKeyParameter underlyingPublicKey = _createPublicKey (publicKey );
159
- AsymmetricBlockCipher cipher = new PKCS1Encoding (new RSAEngine ());
159
+ AsymmetricBlockCipher cipher = new OAEPEncoding (new RSAEngine ());
160
160
161
161
cipher .init (true , underlyingPublicKey );
162
162
return cipher .processBlock (plainText , 0 , plainText .length );
0 commit comments