public static LockableRandomAccessBuffer create(DataInputStream dis, FilenameGenerator fg, PersistentFileTracker persistentFileTracker, MasterSecret masterKey)
throws IOException, StorageFormatException, ResumeFailedException {
EncryptedRandomAccessBufferType type = EncryptedRandomAccessBufferType.getByBitmask(dis.readInt());
if(type == null)
throw new StorageFormatException("Unknown EncryptedRandomAccessBufferType");
LockableRandomAccessBuffer underlying = BucketTools.restoreRAFFrom(dis, fg, persistentFileTracker, masterKey);
try {
return new EncryptedRandomAccessBuffer(type, underlying, masterKey, false);
} catch (GeneralSecurityException e) {
Logger.error(EncryptedRandomAccessBuffer.class, "Crypto error resuming: "+e, e);
throw new ResumeFailedException(e);