public EncryptionVerifier(DocumentInputStream dis, int encryptedLength) { int saltSize = dis.ReadInt(); if (saltSize != 16) { throw new Exception("Salt size != 16 !?"); } salt = new byte[16]; dis.ReadFully(salt); verifier = new byte[16]; dis.ReadFully(verifier); verifierHashSize = dis.ReadInt(); verifierHash = new byte[encryptedLength]; dis.ReadFully(verifierHash); spinCount = 50000; algorithm = EncryptionHeader.ALGORITHM_AES_128; cipherMode = EncryptionHeader.MODE_ECB; encryptedKey = null; }
protected static EncryptionDocument ParseDescriptor(DocumentInputStream descriptor) { try { XmlDocument xmlDoc = new XmlDocument(); byte[] buf = new byte[descriptor.Length - descriptor.Position]; descriptor.ReadFully(buf); string xml = Encoding.UTF8.GetString(buf); OpenXml4Net.Util.XmlHelper.LoadXmlSafe(xmlDoc, xml, Encoding.UTF8); return(EncryptionDocument.Parse(xmlDoc)); } catch (Exception e) { throw new EncryptedDocumentException("Unable to parse encryption descriptor", e); } }
private byte[] NextChunk() { int index = (int)(_pos >> 12); byte[] blockKey = new byte[4]; LittleEndian.PutInt(blockKey, 0, index); byte[] iv = _ag.GenerateIv(_ag.Info.Header.Algorithm, _ag.Info.Header.KeySalt, blockKey); //_cipher.Mode = CipherMode. _cipher.Key = _ag.SecretKey; _cipher.IV = iv; if (_lastIndex != index) { _stream.Skip((index - _lastIndex) << 12); } byte[] block = new byte[Math.Min(_stream.Available(), 4096)]; _stream.ReadFully(block); _lastIndex = index + 1; throw new NotImplementedException(); //return _cipher.doFinal(block); Leon }
public EncryptionVerifier(DocumentInputStream dis, int encryptedLength) { int saltSize = dis.ReadInt(); if (saltSize != 16) throw new Exception("Salt size != 16 !?"); salt = new byte[16]; dis.ReadFully(salt); verifier = new byte[16]; dis.ReadFully(verifier); verifierHashSize = dis.ReadInt(); verifierHash = new byte[encryptedLength]; dis.ReadFully(verifierHash); spinCount = 50000; algorithm = EncryptionHeader.ALGORITHM_AES_128; cipherMode = EncryptionHeader.MODE_ECB; encryptedKey = null; }