Esempio n. 1
0
        public SignatureStream(Stream inputStream, SignatureJobSettings settings)
        {
            this.inputStream = inputStream;
            this.inputReader = new BinaryReader(inputStream);
            this.settings = settings;

            // initialize the buffer with the header
            this.InitializeHeader();
            this.currentPosition = 0;
        }
Esempio n. 2
0
        public static void WriteBlock(BinaryWriter s, byte[] block, SignatureJobSettings settings)
        {
            int weakSum = CalculateWeakSum(block);
            byte[] strongSum;

            if (settings.MagicNumber == MagicNumber.Blake2Signature)
            {
                strongSum = CalculateBlake2StrongSum(block);
            }
            else
            {
                throw new NotImplementedException("Non-blake2 hashes aren't supported");
            }

            StreamHelpers.WriteBigEndian(s, (ulong)weakSum, bytes: 4);
            s.Write(strongSum, 0, settings.StrongSumLength);
        }
Esempio n. 3
0
 public static Stream ComputeSignature(Stream inputFile, SignatureJobSettings settings)
 {
     return new SignatureStream(inputFile, settings);
 }
Esempio n. 4
0
 public static void WriteHeader(BinaryWriter s, SignatureJobSettings settings)
 {
     StreamHelpers.WriteBigEndian(s, (uint)settings.MagicNumber);
     StreamHelpers.WriteBigEndian(s, (uint)settings.BlockLength);
     StreamHelpers.WriteBigEndian(s, (uint)settings.StrongSumLength);
 }