@Override protected int invokeCipher(int totalBytes, boolean doFinal) { final int pos = (int)getPos(); final byte xorArray[] = getEncryptionInfo().getDecryptor().getSecretKey().getEncoded(); final byte chunk[] = getChunk(); final byte plain[] = getPlain(); final int posInChunk = pos & getChunkMask(); value = rotateLeft(value, 3); value ^= xorArray[(xorArrayIndex+i) & 0x0F]; chunk[posInChunk+i] = value;
/** * Decrypts a xor obfuscated byte array. * The data is decrypted in-place * * @see <a href="http://msdn.microsoft.com/en-us/library/dd908506.aspx">2.3.7.3 Binary Document XOR Data Transformation Method 1</a> */ @Override public void setNextRecordSize(int recordSize) { final int pos = (int)getPos(); final byte chunk[] = getChunk(); final int chunkMask = getChunkMask(); recordStart = pos; recordEnd = recordStart+recordSize; int nextBytes = Math.min(recordSize, chunk.length-(pos & chunkMask)); invokeCipher(nextBytes, true); } }
@Override protected int invokeCipher(int totalBytes, boolean doFinal) { final int pos = (int)getPos(); final byte xorArray[] = getEncryptionInfo().getDecryptor().getSecretKey().getEncoded(); final byte chunk[] = getChunk(); final byte plain[] = getPlain(); final int posInChunk = pos & getChunkMask(); value = rotateLeft(value, 3); value ^= xorArray[(xorArrayIndex+i) & 0x0F]; chunk[posInChunk+i] = value;
/** * Decrypts a xor obfuscated byte array. * The data is decrypted in-place * * @see <a href="http://msdn.microsoft.com/en-us/library/dd908506.aspx">2.3.7.3 Binary Document XOR Data Transformation Method 1</a> */ @Override public void setNextRecordSize(int recordSize) { final int pos = (int)getPos(); final byte chunk[] = getChunk(); final int chunkMask = getChunkMask(); recordStart = pos; recordEnd = recordStart+recordSize; int nextBytes = Math.min(recordSize, chunk.length-(pos & chunkMask)); invokeCipher(nextBytes, true); } }
@Override public InputStream getDataStream(InputStream stream, int size, int initialPos) throws IOException, GeneralSecurityException { return new XORCipherInputStream(stream, initialPos); }
@Override public InputStream getDataStream(InputStream stream, int size, int initialPos) throws IOException, GeneralSecurityException { return new XORCipherInputStream(stream, initialPos); }