cache: remove whirlpool as it is not in osrs
This commit is contained in:
@@ -262,7 +262,6 @@ public class CacheClient implements AutoCloseable
|
||||
// update index settings
|
||||
index.setProtocol(indexData.getProtocol());
|
||||
index.setNamed(indexData.isNamed());
|
||||
index.setUsesWhirpool(indexData.isUsesWhirpool());
|
||||
index.setCrc(crc);
|
||||
index.setRevision(revision);
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ public class FileResult
|
||||
private byte[] contents;
|
||||
private int revision;
|
||||
private int crc;
|
||||
private byte[] whirlpool;
|
||||
private int compression; // compression method used by archive data
|
||||
|
||||
public FileResult(int index, int fileId, byte[] compressedData)
|
||||
@@ -69,7 +68,6 @@ public class FileResult
|
||||
contents = res.data;
|
||||
revision = res.revision;
|
||||
crc = res.crc;
|
||||
whirlpool = res.whirlpool;
|
||||
compression = res.compression;
|
||||
}
|
||||
|
||||
@@ -88,11 +86,6 @@ public class FileResult
|
||||
return crc;
|
||||
}
|
||||
|
||||
public byte[] getWhirlpool()
|
||||
{
|
||||
return whirlpool;
|
||||
}
|
||||
|
||||
public int getCompression()
|
||||
{
|
||||
return compression;
|
||||
|
||||
@@ -27,7 +27,6 @@ package net.runelite.cache.fs;
|
||||
import net.runelite.cache.fs.jagex.DataFile;
|
||||
import net.runelite.cache.fs.jagex.DataFileReadResult;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.slf4j.Logger;
|
||||
@@ -43,7 +42,6 @@ public class Archive
|
||||
|
||||
private final int archiveId;
|
||||
private int nameHash;
|
||||
private byte[] whirlpool;
|
||||
private int crc;
|
||||
private int revision;
|
||||
private int compression;
|
||||
@@ -143,12 +141,6 @@ public class Archive
|
||||
this.setCrc(res.crc);
|
||||
}
|
||||
|
||||
if (this.getWhirlpool() != null && !Arrays.equals(this.getWhirlpool(), res.whirlpool))
|
||||
{
|
||||
logger.warn("whirlpool mismatch for archive {}", this.getArchiveId());
|
||||
this.setWhirlpool(res.whirlpool);
|
||||
}
|
||||
|
||||
if (res.revision != -1 && this.getRevision() != res.revision)
|
||||
{
|
||||
// compressed data doesn't always include a revision, but check it if it does
|
||||
@@ -188,16 +180,6 @@ public class Archive
|
||||
this.nameHash = nameHash;
|
||||
}
|
||||
|
||||
public byte[] getWhirlpool()
|
||||
{
|
||||
return whirlpool;
|
||||
}
|
||||
|
||||
public void setWhirlpool(byte[] whirlpool)
|
||||
{
|
||||
this.whirlpool = whirlpool;
|
||||
}
|
||||
|
||||
public int getCrc()
|
||||
{
|
||||
return crc;
|
||||
|
||||
@@ -37,7 +37,6 @@ import net.runelite.cache.index.FileData;
|
||||
import net.runelite.cache.index.IndexData;
|
||||
import net.runelite.cache.util.Crc32;
|
||||
import net.runelite.cache.util.Djb2;
|
||||
import net.runelite.cache.util.Whirlpool;
|
||||
import net.runelite.cache.util.XteaKeyManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -52,10 +51,9 @@ public class Index
|
||||
private XteaKeyManager xteaManager;
|
||||
|
||||
private int protocol = 7;
|
||||
private boolean named = true, usesWhirpool;
|
||||
private boolean named = true;
|
||||
private int revision;
|
||||
private int crc;
|
||||
private byte[] whirlpool;
|
||||
private int compression; // compression method of this index's data in 255
|
||||
|
||||
private final List<Archive> archives = new ArrayList<>();
|
||||
@@ -138,16 +136,6 @@ public class Index
|
||||
this.named = named;
|
||||
}
|
||||
|
||||
public boolean isUsesWhirpool()
|
||||
{
|
||||
return usesWhirpool;
|
||||
}
|
||||
|
||||
public void setUsesWhirpool(boolean usesWhirpool)
|
||||
{
|
||||
this.usesWhirpool = usesWhirpool;
|
||||
}
|
||||
|
||||
public int getRevision()
|
||||
{
|
||||
return revision;
|
||||
@@ -168,16 +156,6 @@ public class Index
|
||||
this.crc = crc;
|
||||
}
|
||||
|
||||
public byte[] getWhirlpool()
|
||||
{
|
||||
return whirlpool;
|
||||
}
|
||||
|
||||
public void setWhirlpool(byte[] whirlpool)
|
||||
{
|
||||
this.whirlpool = whirlpool;
|
||||
}
|
||||
|
||||
public int getCompression()
|
||||
{
|
||||
return compression;
|
||||
@@ -249,10 +227,8 @@ public class Index
|
||||
crc32.update(compressedData, 0, length);
|
||||
|
||||
int crc = crc32.getHash();
|
||||
byte[] whirlpool = Whirlpool.getHash(compressedData, length);
|
||||
|
||||
a.setCrc(crc);
|
||||
a.setWhirlpool(whirlpool);
|
||||
}
|
||||
|
||||
Crc32 crc = new Crc32();
|
||||
@@ -275,7 +251,6 @@ public class Index
|
||||
data.setProtocol(protocol);
|
||||
data.setRevision(revision);
|
||||
data.setNamed(named);
|
||||
data.setUsesWhirpool(usesWhirpool);
|
||||
|
||||
ArchiveData[] archiveDatas = new ArchiveData[archives.size()];
|
||||
data.setArchives(archiveDatas);
|
||||
@@ -287,7 +262,6 @@ public class Index
|
||||
ad.setId(archive.getArchiveId());
|
||||
ad.setNameHash(archive.getNameHash());
|
||||
ad.setCrc(archive.getCrc());
|
||||
ad.setWhirlpool(archive.getWhirlpool());
|
||||
ad.setRevision(archive.getRevision());
|
||||
|
||||
FileData[] files = new FileData[archive.getFiles().size()];
|
||||
|
||||
@@ -40,7 +40,6 @@ import net.runelite.cache.io.InputStream;
|
||||
import net.runelite.cache.io.OutputStream;
|
||||
import net.runelite.cache.util.Crc32;
|
||||
import net.runelite.cache.util.GZip;
|
||||
import net.runelite.cache.util.Whirlpool;
|
||||
import net.runelite.cache.util.Xtea;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -279,8 +278,6 @@ public class DataFile implements Closeable
|
||||
Crc32 crc32 = new Crc32();
|
||||
crc32.update(compressedData, 0, length);
|
||||
res.crc = crc32.getHash();
|
||||
|
||||
res.whirlpool = Whirlpool.getHash(compressedData, length);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -385,7 +382,6 @@ public class DataFile implements Closeable
|
||||
res.revision = revision;
|
||||
res.crc = crc32.getHash();
|
||||
int length = revision != -1 ? b.length - 2 : b.length;
|
||||
res.whirlpool = Whirlpool.getHash(b, length);
|
||||
res.compression = compression;
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,5 @@ public class DataFileReadResult
|
||||
public byte[] data;
|
||||
public int revision;
|
||||
public int crc; // crc of compressed data
|
||||
public byte[] whirlpool;
|
||||
public int compression; // compression method data was compressed with
|
||||
}
|
||||
|
||||
@@ -29,5 +29,4 @@ public class DataFileWriteResult
|
||||
{
|
||||
public int sector, compressedLength;
|
||||
public int crc; // crc of compressed data
|
||||
public byte[] whirlpool;
|
||||
}
|
||||
|
||||
@@ -123,13 +123,11 @@ public class DiskStorage implements Storage
|
||||
index.setProtocol(id.getProtocol());
|
||||
index.setRevision(id.getRevision());
|
||||
index.setNamed(id.isNamed());
|
||||
index.setUsesWhirpool(id.isUsesWhirpool());
|
||||
|
||||
for (ArchiveData ad : id.getArchives())
|
||||
{
|
||||
Archive archive = index.addArchive(ad.getId());
|
||||
archive.setNameHash(ad.getNameHash());
|
||||
archive.setWhirlpool(ad.getWhirlpool());
|
||||
archive.setCrc(ad.getCrc());
|
||||
archive.setRevision(ad.getRevision());
|
||||
|
||||
@@ -144,7 +142,6 @@ public class DiskStorage implements Storage
|
||||
}
|
||||
|
||||
index.setCrc(res.crc);
|
||||
index.setWhirlpool(res.whirlpool);
|
||||
index.setCompression(res.compression);
|
||||
assert res.revision == -1;
|
||||
|
||||
@@ -222,7 +219,6 @@ public class DiskStorage implements Storage
|
||||
index255.write(new IndexEntry(index255, index.getId(), res.sector, res.compressedLength));
|
||||
|
||||
index.setCrc(res.crc);
|
||||
index.setWhirlpool(res.whirlpool);
|
||||
}
|
||||
|
||||
private void saveArchive(Archive a) throws IOException
|
||||
@@ -252,6 +248,5 @@ public class DiskStorage implements Storage
|
||||
logger.trace("Saved archive {}/{} at sector {}, compressed length {}", index.getId(), a.getArchiveId(), res.sector, res.compressedLength);
|
||||
|
||||
a.setCrc(res.crc);
|
||||
a.setWhirlpool(res.whirlpool);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public class ArchiveData
|
||||
{
|
||||
int id;
|
||||
int nameHash;
|
||||
byte[] whirlpool;
|
||||
int crc;
|
||||
int revision;
|
||||
FileData[] files;
|
||||
@@ -53,16 +52,6 @@ public class ArchiveData
|
||||
this.nameHash = nameHash;
|
||||
}
|
||||
|
||||
public byte[] getWhirlpool()
|
||||
{
|
||||
return whirlpool;
|
||||
}
|
||||
|
||||
public void setWhirlpool(byte[] whirlpool)
|
||||
{
|
||||
this.whirlpool = whirlpool;
|
||||
}
|
||||
|
||||
public int getCrc()
|
||||
{
|
||||
return crc;
|
||||
|
||||
@@ -32,7 +32,6 @@ public class IndexData
|
||||
private int protocol;
|
||||
private int revision;
|
||||
private boolean named;
|
||||
private boolean usesWhirpool;
|
||||
private ArchiveData[] archives;
|
||||
|
||||
public void load(byte[] data)
|
||||
@@ -51,7 +50,10 @@ public class IndexData
|
||||
|
||||
int hash = stream.readUnsignedByte();
|
||||
named = (1 & hash) != 0;
|
||||
usesWhirpool = (2 & hash) != 0;
|
||||
if ((hash & ~1) != 0)
|
||||
{
|
||||
throw new IllegalArgumentException("Unknown flags");
|
||||
}
|
||||
assert (hash & ~3) == 0;
|
||||
int validArchivesCount = protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
|
||||
int lastArchiveId = 0;
|
||||
@@ -77,18 +79,6 @@ public class IndexData
|
||||
}
|
||||
}
|
||||
|
||||
if (usesWhirpool)
|
||||
{
|
||||
for (int index = 0; index < validArchivesCount; ++index)
|
||||
{
|
||||
byte[] w = new byte[64];
|
||||
stream.readBytes(w);
|
||||
|
||||
ArchiveData ad = archives[index];
|
||||
ad.whirlpool = w;
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = 0; index < validArchivesCount; ++index)
|
||||
{
|
||||
int crc = stream.readInt();
|
||||
@@ -155,7 +145,7 @@ public class IndexData
|
||||
stream.writeInt(this.revision);
|
||||
}
|
||||
|
||||
stream.writeByte((named ? 1 : 0) | (usesWhirpool ? 2 : 0));
|
||||
stream.writeByte(named ? 1 : 0);
|
||||
if (protocol >= 7)
|
||||
{
|
||||
stream.writeBigSmart(this.archives.length);
|
||||
@@ -195,15 +185,6 @@ public class IndexData
|
||||
}
|
||||
}
|
||||
|
||||
if (usesWhirpool)
|
||||
{
|
||||
for (int i = 0; i < this.archives.length; ++i)
|
||||
{
|
||||
ArchiveData a = this.archives[i];
|
||||
stream.writeBytes(a.getWhirlpool());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.archives.length; ++i)
|
||||
{
|
||||
ArchiveData a = this.archives[i];
|
||||
@@ -305,16 +286,6 @@ public class IndexData
|
||||
this.named = named;
|
||||
}
|
||||
|
||||
public boolean isUsesWhirpool()
|
||||
{
|
||||
return usesWhirpool;
|
||||
}
|
||||
|
||||
public void setUsesWhirpool(boolean usesWhirpool)
|
||||
{
|
||||
this.usesWhirpool = usesWhirpool;
|
||||
}
|
||||
|
||||
public ArchiveData[] getArchives()
|
||||
{
|
||||
return archives;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.cache.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.Security;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
||||
public class Whirlpool
|
||||
{
|
||||
private static MessageDigest messageDigest;
|
||||
|
||||
static
|
||||
{
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
|
||||
try
|
||||
{
|
||||
messageDigest = MessageDigest.getInstance("Whirlpool");
|
||||
}
|
||||
catch (NoSuchAlgorithmException ex)
|
||||
{
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized byte[] getHash(byte[] data, int len)
|
||||
{
|
||||
messageDigest.update(data, 0, len);
|
||||
return messageDigest.digest();
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.cache.util;
|
||||
|
||||
import net.runelite.cache.util.Whirlpool;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class WhirlpoolTest
|
||||
{
|
||||
private static final byte[] result =
|
||||
{
|
||||
92, -33, 60, 4, -28, 24, 54, -39,
|
||||
-11, -85, -123, -74, 6, -107, 32, 36,
|
||||
108, 104, -82, 108, 36, -53, -95, 123,
|
||||
-84, -86, -13, 107, -110, 27, 35, -78,
|
||||
-60, -122, 36, 56, 86, 73, -9, -70,
|
||||
-35, 58, -43, 82, -36, -53, -107, -9,
|
||||
-21, 6, -43, 14, 109, -26, -115, 67,
|
||||
64, 116, 107, 18, 12, 46, -64, 63
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testGetHash()
|
||||
{
|
||||
byte[] data = "runelite".getBytes();
|
||||
byte[] out = Whirlpool.getHash(data, data.length);
|
||||
|
||||
Assert.assertArrayEquals(out, result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user