@@ -71,7 +71,7 @@ class BlockchainInfoHandler extends AbstractImportExportHandler{
71
71
if (pass == null ){
72
72
throw new Exception (" not possible without password" )
73
73
}
74
- val decrypted = decrypt (payload, pass, iterations)
74
+ val decrypted = decryptWithPass (payload, pass, iterations)
75
75
parseAndImport(decrypted, pass2)
76
76
}
77
77
@@ -114,7 +114,7 @@ class BlockchainInfoHandler extends AbstractImportExportHandler{
114
114
if (bciKey. has(" priv" )){
115
115
if (doubleEnc){
116
116
val doubleEncText = bciKey. getString(" priv" )
117
- priv = decrypt (doubleEncText, doubleEncSalt, pass2, doubleEncIter)
117
+ priv = decryptWithPass (doubleEncText, doubleEncSalt + pass2, doubleEncIter)
118
118
} else {
119
119
priv = bciKey. getString(" priv" )
120
120
}
@@ -158,7 +158,7 @@ class BlockchainInfoHandler extends AbstractImportExportHandler{
158
158
* @return decrypted plain text. This would be the JSON string representation of the wallet
159
159
* @throws InvalidCipherTextException if decryption fails
160
160
*/
161
- private def decrypt (String cipherText , String password , int iterations ) throws InvalidCipherTextException {
161
+ private def decryptWithPass (String cipherText , String password , int iterations ) throws InvalidCipherTextException {
162
162
val cipherdata = Base64 . decode(cipherText);
163
163
164
164
// Separate the IV and cipher data
@@ -168,18 +168,6 @@ class BlockchainInfoHandler extends AbstractImportExportHandler{
168
168
return decrypt(iv, input, password, iterations)
169
169
}
170
170
171
- /**
172
- * This is used to decrypt the individual key with the secondary password
173
- * @param encPrivKey the base64 encoded encrypted private key (from the "priv" field)
174
- * @param sharedKey used as a password salt (this is taken from the "sharedKey" field)
175
- * @param password2 the secondary password for this wallet
176
- * @param iterations as found in the "pbkdf2_iterations" field of the wallet
177
- * @throws InvalidCipherTextException if decryption fails
178
- */
179
- private def decrypt (String encPrivKey , String sharedKey , String password2 , int iterations ) throws InvalidCipherTextException {
180
- decrypt(encPrivKey, sharedKey + password2, iterations)
181
- }
182
-
183
171
/**
184
172
* Decrypt the byte array according to the specifications given by blockchain.info.
185
173
* @param iv initialization vector used to initialize the cipher
@@ -211,16 +199,14 @@ class BlockchainInfoHandler extends AbstractImportExportHandler{
211
199
* @return a newly initialized Cipher object usable to encrypt or decrypt the data from blockchain.info
212
200
*/
213
201
private def createCipher (String password , byte [] iv , int PBKDF2Iterations , Boolean forEncryption ){
214
- val generator = new PKCS5S2ParametersGenerator
215
202
val passbytes = PBEParametersGenerator . PKCS5PasswordToUTF8Bytes (password. toCharArray())
216
- generator. init(passbytes, iv, PBKDF2Iterations )
217
- val keyParam = generator. generateDerivedParameters(AESKeySize )
218
203
219
- val params = new ParametersWithIV (keyParam, iv)
204
+ val generator = new PKCS5S2ParametersGenerator
205
+ generator. init(passbytes, iv, PBKDF2Iterations )
206
+ val keyParams = new ParametersWithIV (generator. generateDerivedParameters(AESKeySize ), iv)
220
207
221
- val padding = new ISO10126d2Padding
222
- val cipher = new PaddedBufferedBlockCipher (new CBCBlockCipher (new AESEngine ()), padding)
223
- cipher. init(forEncryption, params)
208
+ val cipher = new PaddedBufferedBlockCipher (new CBCBlockCipher (new AESEngine ()), new ISO10126d2Padding )
209
+ cipher. init(forEncryption, keyParams)
224
210
return cipher
225
211
}
226
212
0 commit comments