|
29 | 29 | import java.util.Collection;
|
30 | 30 | import java.util.List;
|
31 | 31 | import java.util.Map;
|
| 32 | +import java.util.logging.Logger; |
| 33 | +import java.util.regex.Pattern; |
32 | 34 |
|
33 | 35 | import javax.crypto.Cipher;
|
34 | 36 | import javax.crypto.SecretKey;
|
|
49 | 51 | * {@link #getInstance(PublicKey, PrivateKey, String, String, String)}.
|
50 | 52 | */
|
51 | 53 | public abstract class JceMasterKey extends MasterKey<JceMasterKey> {
|
| 54 | + private static final Logger LOGGER = Logger.getLogger(JceMasterKey.class.getName()); |
52 | 55 | private static final byte[] EMPTY_ARRAY = new byte[0];
|
53 | 56 |
|
54 | 57 | private final SecureRandom rnd = new SecureRandom();
|
@@ -234,12 +237,17 @@ public WrappingData(final Cipher cipher, final byte[] extraInfo) {
|
234 | 237 | }
|
235 | 238 |
|
236 | 239 | private static class Rsa extends JceMasterKey {
|
| 240 | + private static final Pattern SUPPORTED_TRANSFORMATIONS = |
| 241 | + Pattern.compile("RSA/ECB/(?:PKCS1Padding|OAEPWithSHA-(?:1|256|384|512)AndMGF1Padding)"); |
237 | 242 | private final String transformation_;
|
238 | 243 |
|
239 | 244 | private Rsa(PublicKey wrappingKey, PrivateKey unwrappingKey, String providerName, String keyId,
|
240 | 245 | String transformation) {
|
241 | 246 | super(wrappingKey, unwrappingKey, providerName, keyId);
|
242 | 247 | transformation_ = transformation;
|
| 248 | + if (!SUPPORTED_TRANSFORMATIONS.matcher(transformation_).matches()) { |
| 249 | + LOGGER.warning(transformation_ + " is not officially supported by the JceMasterKey"); |
| 250 | + } |
243 | 251 | }
|
244 | 252 |
|
245 | 253 | @Override
|
|
0 commit comments