public long readUInt() { int i = readInt(); return i & 0xFFFFFFFFL; }
public long readUInt() { int i = readInt(); return i & 0xFFFFFFFFL; }
public int readInt() { return delegate.readInt(); }
public int readInt() { return delegate.readInt(); }
public EncryptionHeader(DocumentInputStream is) throws IOException { flags = is.readInt(); sizeExtra = is.readInt(); algorithm = is.readInt(); hashAlgorithm = is.readInt(); keySize = is.readInt(); providerType = is.readInt(); is.readLong(); // skip reserved StringBuilder builder = new StringBuilder(); while (true) { char c = (char) is.readShort(); if (c == 0) { break; } builder.append(c); } cspName = builder.toString(); cipherMode = MODE_ECB; keySalt = null; }
public EncryptionHeader(DocumentInputStream is) throws IOException { flags = is.readInt(); sizeExtra = is.readInt(); algorithm = is.readInt(); hashAlgorithm = is.readInt(); keySize = is.readInt(); providerType = is.readInt(); is.readLong(); // skip reserved StringBuilder builder = new StringBuilder(); while (true) { char c = (char) is.readShort(); if (c == 0) { break; } builder.append(c); } cspName = builder.toString(); cipherMode = MODE_ECB; keySalt = null; }
public EncryptionVerifier(DocumentInputStream is, int encryptedLength) { int saltSize = is.readInt(); if (saltSize!=16) { throw new RuntimeException("Salt size != 16 !?"); } salt = new byte[16]; is.readFully(salt); verifier = new byte[16]; is.readFully(verifier); verifierHashSize = is.readInt(); verifierHash = new byte[encryptedLength]; is.readFully(verifierHash); spinCount = 50000; algorithm = EncryptionHeader.ALGORITHM_AES_128; cipherMode = EncryptionHeader.MODE_ECB; encryptedKey = null; }
public EncryptionVerifier(DocumentInputStream is, int encryptedLength) { int saltSize = is.readInt(); if (saltSize!=16) { throw new RuntimeException("Salt size != 16 !?"); } salt = new byte[16]; is.readFully(salt); verifier = new byte[16]; is.readFully(verifier); verifierHashSize = is.readInt(); verifierHash = new byte[encryptedLength]; is.readFully(verifierHash); spinCount = 50000; algorithm = EncryptionHeader.ALGORITHM_AES_128; cipherMode = EncryptionHeader.MODE_ECB; encryptedKey = null; }
public EncryptionInfo(DirectoryNode dir) throws IOException { DocumentInputStream dis = dir.createDocumentInputStream("EncryptionInfo"); versionMajor = dis.readShort(); versionMinor = dis.readShort(); encryptionFlags = dis.readInt(); if (versionMajor == 4 && versionMinor == 4 && encryptionFlags == 0x40) { StringBuilder builder = new StringBuilder(); byte[] xmlDescriptor = new byte[dis.available()]; dis.read(xmlDescriptor); for (byte b : xmlDescriptor) builder.append((char)b); String descriptor = builder.toString(); header = new EncryptionHeader(descriptor); verifier = new EncryptionVerifier(descriptor); } else { int hSize = dis.readInt(); header = new EncryptionHeader(dis); if (header.getAlgorithm()==EncryptionHeader.ALGORITHM_RC4) { verifier = new EncryptionVerifier(dis, 20); } else { verifier = new EncryptionVerifier(dis, 32); } } }
public EncryptionInfo(DirectoryNode dir) throws IOException { DocumentInputStream dis = dir.createDocumentInputStream("EncryptionInfo"); versionMajor = dis.readShort(); versionMinor = dis.readShort(); encryptionFlags = dis.readInt(); if (versionMajor == 4 && versionMinor == 4 && encryptionFlags == 0x40) { StringBuilder builder = new StringBuilder(); byte[] xmlDescriptor = new byte[dis.available()]; dis.read(xmlDescriptor); for (byte b : xmlDescriptor) builder.append((char)b); String descriptor = builder.toString(); header = new EncryptionHeader(descriptor); verifier = new EncryptionVerifier(descriptor); } else { int hSize = dis.readInt(); header = new EncryptionHeader(dis); if (header.getAlgorithm()==EncryptionHeader.ALGORITHM_RC4) { verifier = new EncryptionVerifier(dis, 20); } else { verifier = new EncryptionVerifier(dis, 32); } } }