/** * Writes the ptgs to the data buffer, starting at the specified offset. * * <br/> * The 2 byte encode Length field is <b>not</b> written by this method. * @return number of bytes written */ public static int SerializePtgs(Ptg[] ptgs, byte[] array, int offset) { int size = ptgs.Length; LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(array, offset); ArrayList arrayPtgs = null; for (int k = 0; k < size; k++) { Ptg ptg = ptgs[k]; ptg.Write(out1); if (ptg is ArrayPtg) { if (arrayPtgs == null) { arrayPtgs = new ArrayList(5); } arrayPtgs.Add(ptg); } } if (arrayPtgs != null) { for (int i = 0; i < arrayPtgs.Count; i++) { ArrayPtg p = (ArrayPtg)arrayPtgs[i]; p.WriteTokenValueBytes(out1); } } return(out1.WriteIndex - offset);; }
protected void marshallEncryptionDocument(EncryptionDocument ed, LittleEndianByteArrayOutputStream os) { //XmlOptions xo = new XmlOptions(); //xo.SetCharacterEncoding("UTF-8"); Dictionary <String, String> nsMap = new Dictionary <String, String>(); nsMap.Add(passwordUri.ToString(), "p"); nsMap.Add(certificateUri.ToString(), "c"); //xo.UseDefaultNamespace(); //xo.SaveSuggestedPrefixes(nsMap); //xo.SaveNamespacesFirst(); //xo.SaveAggressiveNamespaces(); // Setting standalone doesn't work with xmlbeans-2.3 & 2.6 // ed.DocumentProperties().Standalone=(/*setter*/true); //xo.SaveNoXmlDecl(); MemoryStream bos = new MemoryStream(); try { byte[] buf = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n"); bos.Write(buf, 0, buf.Length); ed.Save(bos); os.Write(bos.ToArray()); } catch (IOException e) { throw new EncryptedDocumentException("error marshalling encryption info document", e); } }
public void Write(LittleEndianByteArrayOutputStream bos) { bos.WriteShort(info.VersionMajor); bos.WriteShort(info.VersionMinor); header.Write(bos); verifier.Write(bos); }
public void TestExtRstEqualsAndHashCode() { byte[] buf = new byte[200]; LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(buf, 0); String str = "\u1d02\u1d12\u1d22"; bos.WriteShort(1); bos.WriteShort(5 * LittleEndianConsts.SHORT_SIZE + str.Length * 2 + 3 * LittleEndianConsts.SHORT_SIZE + 2); // data size bos.WriteShort(0x4711); bos.WriteShort(0x0815); bos.WriteShort(1); bos.WriteShort(str.Length); bos.WriteShort(str.Length); StringUtil.PutUnicodeLE(str, bos); bos.WriteShort(1); bos.WriteShort(1); bos.WriteShort(3); bos.WriteShort(42); LittleEndianByteArrayInputStream in1 = new LittleEndianByteArrayInputStream(buf, 0, bos.WriteIndex); UnicodeString.ExtRst extRst1 = new UnicodeString.ExtRst(in1, bos.WriteIndex); in1 = new LittleEndianByteArrayInputStream(buf, 0, bos.WriteIndex); UnicodeString.ExtRst extRst2 = new UnicodeString.ExtRst(in1, bos.WriteIndex); Assert.AreEqual(extRst1, extRst2); Assert.AreEqual(extRst1.GetHashCode(), extRst2.GetHashCode()); }
public void Write(LittleEndianByteArrayOutputStream bos) { // see [MS-OFFCRYPTO] - 2.3.4.9 byte[] salt = Salt; Debug.Assert(salt.Length == 16); bos.WriteInt(salt.Length); // salt size bos.Write(salt); // The resulting Verifier value MUST be an array of 16 bytes. byte[] encryptedVerifier = EncryptedVerifier; Debug.Assert(encryptedVerifier.Length == 16); bos.Write(encryptedVerifier); // The number of bytes used by the decrypted Verifier hash is given by // the VerifierHashSize field, which MUST be 20 bos.WriteInt(20); // EncryptedVerifierHash: An array of bytes that Contains the encrypted form of the hash of // the randomly generated Verifier value. The length of the array MUST be the size of the // encryption block size multiplied by the number of blocks needed to encrypt the hash of the // Verifier. If the encryption algorithm is RC4, the length MUST be 20 bytes. If the encryption // algorithm is AES, the length MUST be 32 bytes. After decrypting the EncryptedVerifierHash // field, only the first VerifierHashSize bytes MUST be used. byte[] encryptedVerifierHash = EncryptedVerifierHash; Debug.Assert(encryptedVerifierHash.Length == CipherAlgorithm.encryptedVerifierHashLength); bos.Write(encryptedVerifierHash); }
public override int Serialize(int offset, byte [] data) { int recSize = RecordSize; int dataSize = recSize - 4; LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset, recSize); out1.WriteShort(sid); out1.WriteShort(dataSize); if (_uninterpretedData == null) { for (int i = 0; i < subrecords.Count; i++) { SubRecord record = subrecords[i]; record.Serialize(out1); } int expectedEndIx = offset + dataSize; // padding while (out1.WriteIndex < expectedEndIx) { out1.WriteByte(0); } } else { out1.Write(_uninterpretedData); } return(recSize); }
/** * Serializes the header */ public void Write(LittleEndianByteArrayOutputStream bos) { int startIdx = bos.WriteIndex; ILittleEndianOutput sizeOutput = bos.CreateDelayedOutput(LittleEndianConsts.INT_SIZE); bos.WriteInt(Flags); bos.WriteInt(0); // size extra bos.WriteInt(CipherAlgorithm.ecmaId); bos.WriteInt(HashAlgorithm.ecmaId); bos.WriteInt(KeySize); bos.WriteInt(CipherProvider.ecmaId); bos.WriteInt(0); // reserved1 bos.WriteInt(0); // reserved2 String cspName = CspName; if (cspName == null) { cspName = CipherProvider.cipherProviderName; } bos.Write(StringUtil.GetToUnicodeLE(cspName)); bos.WriteShort(0); int headerSize = bos.WriteIndex - startIdx - LittleEndianConsts.INT_SIZE; sizeOutput.WriteInt(headerSize); }
public void Write(LittleEndianByteArrayOutputStream bos) { transformInfoHeader.Write(bos); bos.WriteInt(extensibilityHeader); WriteUtf8LPP4(bos, xrMLLicense); bos.WriteInt(4); // where does this 4 come from??? }
/** * Writes the ptgs to the data buffer, starting at the specified offset. * * <br/> * The 2 byte encode Length field is <b>not</b> written by this method. * @return number of bytes written */ public static int SerializePtgs(Ptg[] ptgs, byte[] array, int offset) { LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(array, offset); List <Ptg> arrayPtgs = null; foreach (Ptg ptg in ptgs) { ptg.Write(out1); if (ptg is ArrayPtg) { if (arrayPtgs == null) { arrayPtgs = new List <Ptg>(5); } arrayPtgs.Add(ptg); } } if (arrayPtgs != null) { foreach (Ptg arrayPtg in arrayPtgs) { ArrayPtg p = (ArrayPtg)arrayPtg; p.WriteTokenValueBytes(out1); } } return(out1.WriteIndex - offset);; }
public override byte[] GetBytes() { byte[] bytes = new byte[NPOI.SS.Util.CellRangeAddress.ENCODED_SIZE]; ILittleEndianOutput leo = new LittleEndianByteArrayOutputStream(bytes, 0); this.Record.Serialize(leo); return(bytes); }
public override int Serialize(int offset, byte[] data) { LittleEndianOutput leo = new LittleEndianByteArrayOutputStream(data, offset); ContinuableRecordOutput out1 = new ContinuableRecordOutput(leo, this.Sid); Serialize(out1); out1.Terminate(); return(out1.TotalSize); }
public void Write(LittleEndianByteArrayOutputStream bos) { bos.WriteInt(8); bos.WriteInt(transformer.Length); foreach (String str in transformer) { WriteUnicodeLPP4(bos, str); } }
public void Write(LittleEndianByteArrayOutputStream os) { os.WriteInt(8); os.WriteInt(entries.Length); foreach (DataSpaceMapEntry dsme in entries) { dsme.Write(os); } }
public void Write(LittleEndianByteArrayOutputStream bos) { WriteUnicodeLPP4(bos, featureIdentifier); bos.WriteShort(readerVersionMajor); bos.WriteShort(readerVersionMinor); bos.WriteShort(updaterVersionMajor); bos.WriteShort(updaterVersionMinor); bos.WriteShort(writerVersionMajor); bos.WriteShort(writerVersionMinor); }
//protected internal void SetEncryptedVerifier(byte[] encryptedVerifier) //{ // base.EncryptedVerifier = (encryptedVerifier); //} //protected internal void SetEncryptedVerifierHash(byte[] encryptedVerifierHash) //{ // base.EncryptedVerifierHash = (encryptedVerifierHash); //} public void Write(LittleEndianByteArrayOutputStream bos) { byte[] salt = Salt; Debug.Assert(salt.Length == 16); bos.Write(salt); byte[] encryptedVerifier = EncryptedVerifier; Debug.Assert(encryptedVerifier.Length == 16); bos.Write(encryptedVerifier); byte[] encryptedVerifierHash = EncryptedVerifierHash; Debug.Assert(encryptedVerifierHash.Length == 16); bos.Write(encryptedVerifierHash); }
public override int Serialize(int offset, byte[] data) { LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset, this.RecordSize); int result = this.Serialize(out1); if (out1.WriteIndex - offset != this.RecordSize) { throw new InvalidOperationException("Error in serialization of (" + this.GetType().Name + "): " + "Incorrect number of bytes written - expected " + this.RecordSize + " but got " + (out1.WriteIndex - offset)); } return(result); }
public void Write(LittleEndianByteArrayOutputStream os) { int start = os.WriteIndex; ILittleEndianOutput sizeOut = os.CreateDelayedOutput(LittleEndianConsts.INT_SIZE); os.WriteInt(referenceComponent.Length); for (int i = 0; i < referenceComponent.Length; i++) { os.WriteInt(referenceComponentType[i]); WriteUnicodeLPP4(os, referenceComponent[i]); } WriteUnicodeLPP4(os, dataSpaceName); sizeOut.WriteInt(os.WriteIndex - start); }
public void Write(LittleEndianByteArrayOutputStream bos) { int start = bos.WriteIndex; ILittleEndianOutput sizeOut = bos.CreateDelayedOutput(LittleEndianConsts.INT_SIZE); bos.WriteInt(transformType); WriteUnicodeLPP4(bos, transformerId); sizeOut.WriteInt(bos.WriteIndex - start); WriteUnicodeLPP4(bos, transformerName); bos.WriteShort(readerVersionMajor); bos.WriteShort(readerVersionMinor); bos.WriteShort(updaterVersionMajor); bos.WriteShort(updaterVersionMinor); bos.WriteShort(writerVersionMajor); bos.WriteShort(writerVersionMinor); }
public override int Serialize(int offset, byte[] data) { int dataSize = DataSize; int recSize = 4 + dataSize; LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset, recSize); out1.WriteShort(this.Sid); out1.WriteShort(dataSize); Serialize(out1); if (out1.WriteIndex - offset != recSize) { throw new InvalidOperationException("Error in serialization of (" + this.GetType().Name + "): " + "Incorrect number of bytes written - expected " + recSize + " but got " + (out1.WriteIndex - offset)); } return(recSize); }
public static DocumentEntry CreateEncryptionEntry(DirectoryEntry dir, String path, EncryptionRecord out1) { String[] parts = path.Split("/".ToCharArray()); for (int i = 0; i < parts.Length - 1; i++) { dir = dir.HasEntry(parts[i]) ? (DirectoryEntry)dir.GetEntry(parts[i]) : dir.CreateDirectory(parts[i]); } byte[] buf = new byte[5000]; LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(buf, 0); out1.Write(bos); String fileName = parts[parts.Length - 1]; if (dir.HasEntry(fileName)) { dir.GetEntry(fileName).Delete(); } return(dir.CreateDocument(fileName, bos.WriteIndex, new POIFSWriterListenerImpl(buf))); }
/** * Writes the ptgs to the data buffer, starting at the specified offset. * * <br/> * The 2 byte encode Length field is <b>not</b> written by this method. * @return number of bytes written */ public static int SerializePtgs(Ptg[] ptgs, byte[] array, int offset) { int size = ptgs.Length; LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(array, offset); ArrayList arrayPtgs = null; for (int k = 0; k < size; k++) { Ptg ptg = ptgs[k]; ptg.Write(out1); if (ptg is ArrayPtg) { if (arrayPtgs == null) { arrayPtgs = new ArrayList(5); } arrayPtgs.Add(ptg); } } if (arrayPtgs != null) { for (int i=0;i<arrayPtgs.Count;i++) { ArrayPtg p = (ArrayPtg)arrayPtgs[i]; p.WriteTokenValueBytes(out1); } } return out1.WriteIndex - offset;; }
public void Write(LittleEndianByteArrayOutputStream littleendianbytearrayoutputstream) { }
public override int Serialize(int offset, byte [] data) { int recSize = RecordSize; int dataSize = recSize - 4; LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset, recSize); out1.WriteShort(sid); out1.WriteShort(dataSize); if (_uninterpretedData == null) { for (int i = 0; i < subrecords.Count; i++) { SubRecord record = subrecords[i]; record.Serialize(out1); } int expectedEndIx = offset + dataSize; // padding while (out1.WriteIndex < expectedEndIx) { out1.WriteByte(0); } } else { out1.Write(_uninterpretedData); } return recSize; }