Exemplo n.º 1
0
        public void TestReadHeaderUshort()
        {
            StreamTester st = CreateStreamTester(0x50, "BA AD F0 0D 00", unchecked ((int)0x96C66829));

            st.RollForward(0x0004, 0x03FF);

            Biff8DecryptingStream bds = st.GetBDS();
            int hval    = bds.ReadDataSize(); // unencrypted
            int nextInt = bds.ReadInt();

            if (nextInt == unchecked ((int)0x8F534029))
            {
                throw new AssertionException(
                          "Indentified bug in key alignment After call to ReadHeaderUshort()");
            }
            Assert.AreEqual(0x16885243, nextInt);
            if (hval == 0x283E)
            {
                throw new AssertionException("readHeaderUshort() incorrectly decrypted result");
            }
            Assert.AreEqual(0x504F, hval);

            // confirm next key change
            st.RollForward(0x0405, 0x07FC);
            st.ConfirmInt(0x76CC1223);
            st.ConfirmInt(0x4842D83E);
            st.AssertNoErrors();
        }
Exemplo n.º 2
0
 /**
  * @param expectedFirstInt expected value of the first int read from the decrypted stream
  */
 public StreamTester(MockStream ms, String keyDigestHex, int expectedFirstInt)
 {
     _ms = ms;
     byte[] keyDigest = HexRead.ReadFromString(keyDigestHex);
     _bds = new Biff8DecryptingStream(_ms, 0, new Biff8EncryptionKey(keyDigest));
     Assert.AreEqual(expectedFirstInt, _bds.ReadInt());
     _errorsOccurred = false;
 }
Exemplo n.º 3
0
 public RecordInputStream(Stream in1, Biff8EncryptionKey key, int initialOffset)
 {
     if (key == null)
     {
         _dataInput = SimpleHeaderInput.GetLEI(in1);
         _bhi       = new SimpleHeaderInput(in1);
     }
     else
     {
         Biff8DecryptingStream bds = new Biff8DecryptingStream(in1, initialOffset, key);
         _bhi       = bds;
         _dataInput = bds;
     }
     _nextSid = ReadNextSid();
 }
Exemplo n.º 4
0
 public RecordInputStream(Stream in1, Biff8EncryptionKey key, int initialOffset)
 {
     if (key == null)
     {
         _dataInput = SimpleHeaderInput.GetLEI(in1);
         _bhi = new SimpleHeaderInput(in1);
     }
     else
     {
         Biff8DecryptingStream bds = new Biff8DecryptingStream(in1, initialOffset, key);
         _bhi = bds;
         _dataInput = bds;
     }
     _nextSid = ReadNextSid();
 }