Example #1
0
 public SignatureBuilder(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     HashAlgorithm            = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     ChunkSize      = DefaultChunkSize;
     ProgressReport = null;
 }
Example #2
0
 public Signature(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm, short chunkSize)
 {
     HashAlgorithm            = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     Chunks    = new List <ChunkSignature>();
     ChunkSize = chunkSize;
 }
Example #3
0
 public DeltaGenerator(IRollingChecksum checksumProvider, IHashAlgorithm hashProvider)
 {
     if (checksumProvider == null) throw new ArgumentNullException("checksumProvider");
     if (hashProvider == null) throw new ArgumentNullException("hashProvider");
     _initialized = false;
     ChecksumProvider = checksumProvider;
     HashProvider = hashProvider;
 }
Example #4
0
 public void WriteMetadata(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     signatureStream.Write(BinaryFormat.SignatureHeader);
     signatureStream.Write(BinaryFormat.Version);
     signatureStream.Write(hashAlgorithm.Name);
     signatureStream.Write(rollingChecksumAlgorithm.Name);
     signatureStream.Write(BinaryFormat.EndOfMetadata);
 }
Example #5
0
 public void WriteMetadata(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm, byte[] hash)
 {
     signatureStream.Write(BinaryFormat.SignatureHeader);
     signatureStream.Write(BinaryFormat.Version);
     signatureStream.Write(hashAlgorithm.Name);
     signatureStream.Write(rollingChecksumAlgorithm.Name);
     signatureStream.Write(BinaryFormat.EndOfMetadata);
 }
Example #6
0
 public HashBlockGenerator(IRollingChecksum checksumProvider, IHashAlgorithm hashProvider, int blockSize)
 {
     if (checksumProvider == null) throw new ArgumentNullException("checksumProvider");
     if (hashProvider == null) throw new ArgumentNullException("hashProvider");
     if (blockSize <= 0) throw new ArgumentException("blockSize must be greater than zero");
     ChecksumProvider = checksumProvider;
     HashAlgorithm = hashProvider;
     _blockSize = blockSize;
 }
Example #7
0
 public DeltaGenerator(IRollingChecksum checksumProvider, IHashAlgorithm hashProvider)
 {
     if (checksumProvider == null)
     {
         throw new ArgumentNullException("checksumProvider");
     }
     if (hashProvider == null)
     {
         throw new ArgumentNullException("hashProvider");
     }
     _initialized     = false;
     ChecksumProvider = checksumProvider;
     HashProvider     = hashProvider;
 }
Example #8
0
 public HashBlockGenerator(IRollingChecksum checksumProvider, IHashAlgorithm hashProvider, int blockSize)
 {
     if (checksumProvider == null)
     {
         throw new ArgumentNullException("checksumProvider");
     }
     if (hashProvider == null)
     {
         throw new ArgumentNullException("hashProvider");
     }
     if (blockSize <= 0)
     {
         throw new ArgumentException("blockSize must be greater than zero");
     }
     ChecksumProvider = checksumProvider;
     HashAlgorithm    = hashProvider;
     _blockSize       = blockSize;
 }
 public OctodiffSignatureBuilder(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     HashAlgorithm            = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     ChunkSize = DefaultChunkSize;
 }
Example #10
0
 public Signature(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     HashAlgorithm = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     Chunks = new List<ChunkSignature>();
 }
Example #11
0
 public OctodiffSignature(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     HashAlgorithm            = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     Chunks = new List <ChunkSignature>();
 }
Example #12
0
        public static void ValidateSignature(Stream signatureStream, IHashAlgorithm hashAlgorithm, string baseFileHash, IRollingChecksum rollingAlgorithm)
        {
            signatureStream.Seek(0, SeekOrigin.Begin);
            var sig = new SignatureReader(signatureStream, null).ReadSignature();

            Assert.AreEqual(RsyncFormatType.FastRsync, sig.Type);
            Assert.AreEqual(hashAlgorithm.Name, sig.HashAlgorithm.Name);
            Assert.AreEqual(hashAlgorithm.Name, sig.Metadata.ChunkHashAlgorithm);
            Assert.AreEqual(hashAlgorithm.HashLength, sig.HashAlgorithm.HashLength);
            Assert.AreEqual(rollingAlgorithm.Name, sig.RollingChecksumAlgorithm.Name);
            Assert.AreEqual(rollingAlgorithm.Name, sig.Metadata.RollingChecksumAlgorithm);
            Assert.AreEqual("MD5", sig.Metadata.BaseFileHashAlgorithm);
            Assert.AreEqual(baseFileHash, sig.Metadata.BaseFileHash);
        }