random.nextBytes(newsalt);
byte[] diskSalt = newsalt;
if(masterKey != null) {
BlockCipher cipher;
try {
cipher = new Rijndael(256, 128);
} catch (UnsupportedCipherException e) {
throw new Error("Impossible: no Rijndael(256,128): "+e, e);
}
cipher.initialize(masterKey);
diskSalt = new byte[0x10];
cipher.encipher(newsalt, diskSalt);
if(logDEBUG)
Logger.debug(this, "Encrypting with "+HexUtil.bytesToHex(newsalt)+" from "+HexUtil.bytesToHex(diskSalt));
}
cipherManager = new CipherManager(newsalt, diskSalt);
writeConfigFile();
return true;
} else {
try {
// try to load
RandomAccessFile raf = new RandomAccessFile(configFile, "r");
try {
byte[] salt = new byte[0x10];
raf.readFully(salt);
byte[] diskSalt = salt;
if(masterKey != null) {
BlockCipher cipher;
try {
cipher = new Rijndael(256, 128);
} catch (UnsupportedCipherException e) {
throw new Error("Impossible: no Rijndael(256,128): "+e, e);
}
cipher.initialize(masterKey);
salt = new byte[0x10];