1 /* |
1 /* |
2 * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.crypto.provider; |
26 package com.sun.crypto.provider; |
27 |
27 |
28 import java.io.IOException; |
28 import java.io.IOException; |
29 import java.io.Serializable; |
|
30 import java.security.Security; |
|
31 import java.security.Key; |
29 import java.security.Key; |
32 import java.security.PrivateKey; |
30 import java.security.PrivateKey; |
33 import java.security.Provider; |
31 import java.security.Provider; |
34 import java.security.KeyFactory; |
32 import java.security.KeyFactory; |
35 import java.security.MessageDigest; |
33 import java.security.MessageDigest; |
36 import java.security.GeneralSecurityException; |
34 import java.security.GeneralSecurityException; |
37 import java.security.NoSuchAlgorithmException; |
35 import java.security.NoSuchAlgorithmException; |
38 import java.security.NoSuchProviderException; |
|
39 import java.security.UnrecoverableKeyException; |
36 import java.security.UnrecoverableKeyException; |
40 import java.security.AlgorithmParameters; |
37 import java.security.AlgorithmParameters; |
41 import java.security.spec.InvalidParameterSpecException; |
38 import java.security.spec.InvalidParameterSpecException; |
42 import java.security.spec.PKCS8EncodedKeySpec; |
39 import java.security.spec.PKCS8EncodedKeySpec; |
43 |
40 |
44 import javax.crypto.Cipher; |
41 import javax.crypto.Cipher; |
45 import javax.crypto.CipherSpi; |
42 import javax.crypto.CipherSpi; |
46 import javax.crypto.SecretKey; |
43 import javax.crypto.SecretKey; |
47 import javax.crypto.IllegalBlockSizeException; |
|
48 import javax.crypto.SealedObject; |
44 import javax.crypto.SealedObject; |
49 import javax.crypto.spec.*; |
45 import javax.crypto.spec.*; |
50 import sun.security.x509.AlgorithmId; |
46 import sun.security.x509.AlgorithmId; |
51 import sun.security.util.ObjectIdentifier; |
47 import sun.security.util.ObjectIdentifier; |
52 |
48 |
345 cipherSpi = new PBEWithMD5AndTripleDESCipher(); |
341 cipherSpi = new PBEWithMD5AndTripleDESCipher(); |
346 Cipher cipher = new CipherForKeyProtector(cipherSpi, |
342 Cipher cipher = new CipherForKeyProtector(cipherSpi, |
347 SunJCE.getInstance(), |
343 SunJCE.getInstance(), |
348 "PBEWithMD5AndTripleDES"); |
344 "PBEWithMD5AndTripleDES"); |
349 cipher.init(Cipher.DECRYPT_MODE, skey, params); |
345 cipher.init(Cipher.DECRYPT_MODE, skey, params); |
350 return (Key)soForKeyProtector.getObject(cipher); |
346 return soForKeyProtector.getKey(cipher); |
351 } catch (NoSuchAlgorithmException ex) { |
347 } catch (NoSuchAlgorithmException ex) { |
352 // Note: this catch needed to be here because of the |
348 // Note: this catch needed to be here because of the |
353 // later catch of GeneralSecurityException |
349 // later catch of GeneralSecurityException |
354 throw ex; |
350 throw ex; |
355 } catch (IOException ioe) { |
351 } catch (IOException ioe) { |