Merge branch 'master' of ssh://bitbucket.org/bilthon/fullerene

This commit is contained in:
Nelson R. Perez 2016-12-05 17:37:52 -05:00
commit 16f2a26479
3 changed files with 21 additions and 7 deletions

View file

@ -65,11 +65,12 @@ public abstract class FileBin {
} else { } else {
wallet = wallet.get("wallet").getAsJsonObject(); wallet = wallet.get("wallet").getAsJsonObject();
} }
byte[] encKey_enc = new BigInteger(wallet.get("encryption_key").getAsString(), 16).toByteArray(); byte[] encKey_enc = new BigInteger(wallet.get("encryption_key").getAsString(), 16).toByteArray();
byte[] temp = new byte[encKey_enc.length - (encKey_enc[0] == 0 ? 1 : 0)]; byte[] temp = new byte[encKey_enc.length - (encKey_enc[0] == 0 ? 1 : 0)];
System.arraycopy(encKey_enc, (encKey_enc[0] == 0 ? 1 : 0), temp, 0, temp.length); System.arraycopy(encKey_enc, (encKey_enc[0] == 0 ? 1 : 0), temp, 0, temp.length);
byte[] encKey = decryptAES(temp, password.getBytes("UTF-8")); byte[] encKey = decryptAES(temp, password.getBytes("UTF-8"));
temp = new byte[encKey.length - 16]; temp = new byte[encKey.length];
System.arraycopy(encKey, 0, temp, 0, temp.length); System.arraycopy(encKey, 0, temp, 0, temp.length);
byte[] encBrain = new BigInteger(wallet.get("encrypted_brainkey").getAsString(), 16).toByteArray(); byte[] encBrain = new BigInteger(wallet.get("encrypted_brainkey").getAsString(), 16).toByteArray();
@ -190,7 +191,13 @@ public abstract class FileBin {
System.arraycopy(pre_out, 0, out, 0, proc+proc2); System.arraycopy(pre_out, 0, out, 0, proc+proc2);
//Unpadding //Unpadding
int count = out[out.length-1]; byte countByte = (byte)((byte)out[out.length-1] % 16);
int count = countByte & 0xFF;
if ((count > 15) || (count <= 0)){
return out;
}
byte[] temp = new byte[count]; byte[] temp = new byte[count];
System.arraycopy(out, out.length - count, temp, 0, temp.length); System.arraycopy(out, out.length - count, temp, 0, temp.length);
byte[] temp2 = new byte[count]; byte[] temp2 = new byte[count];
@ -201,7 +208,7 @@ public abstract class FileBin {
return temp; return temp;
} else { } else {
return out; return out;
} }
} catch (NoSuchAlgorithmException | DataLengthException | IllegalStateException | InvalidCipherTextException ex) { } catch (NoSuchAlgorithmException | DataLengthException | IllegalStateException | InvalidCipherTextException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }

View file

@ -64,8 +64,9 @@ public class Main {
// test.testRelativeAccountHistory(); // test.testRelativeAccountHistory();
// test.testingInvoiceGeneration(); // test.testingInvoiceGeneration();
// test.testCompression(); // test.testCompression();
// test.testCreateBinFile(); // test.testAccountUpdateSerialization();
test.testAccountUpdateSerialization();
// test.testAccountUpdateOperationBroadcast(); // test.testAccountUpdateOperationBroadcast();
test.testCreateBinFile();
test.testImportBinFile();
} }
} }

File diff suppressed because one or more lines are too long