A class implements MD4 algorithm to generate RDC signature.
Inheritance: System.Security.Cryptography.HashAlgorithm
Esempio n. 1
0
        /// <summary>
        /// Get a chunk with the input bytes.
        /// </summary>
        /// <param name="chunkStart">The start index of the chunk.</param>
        /// <param name="chunkEnd">The end index of the chunk.</param>
        /// <returns>An IntermediateNodeObject which contains a chunk.</returns>
        private IntermediateNodeObject GetChunk(uint chunkStart, uint chunkEnd)
        {
            if (chunkEnd <= chunkStart || (chunkEnd - chunkStart > this.maxChunkSize) || chunkStart > uint.MaxValue)
            {
                throw new ArgumentOutOfRangeException("chunkStart");
            }

            byte[] temp = AdapterHelper.GetBytes(this.FileContent, (int)chunkStart, (int)(chunkEnd - chunkStart));

            byte[] signatureBytes = null;
            using (RDCSignatureGenerator generator = new RDCSignatureGenerator())
            {
                signatureBytes = generator.ComputeHash(temp);
            }

            SignatureObject signature = new SignatureObject();

            signature.SignatureData = new BinaryItem(signatureBytes);

            return(new IntermediateNodeObject.IntermediateNodeObjectBuilder().Build(temp, signature));
        }
        /// <summary>
        /// Get a chunk with the input bytes.
        /// </summary>
        /// <param name="chunkStart">The start index of the chunk.</param>
        /// <param name="chunkEnd">The end index of the chunk.</param>
        /// <returns>An IntermediateNodeObject which contains a chunk.</returns>
        private IntermediateNodeObject GetChunk(uint chunkStart, uint chunkEnd)
        {
            if (chunkEnd <= chunkStart || (chunkEnd - chunkStart > this.maxChunkSize) || chunkStart > uint.MaxValue)
            {
                throw new ArgumentOutOfRangeException("chunkStart");
            }

            byte[] temp = AdapterHelper.GetBytes(this.FileContent, (int)chunkStart, (int)(chunkEnd - chunkStart));

            byte[] signatureBytes = null;
            using (RDCSignatureGenerator generator = new RDCSignatureGenerator())
            {
                signatureBytes = generator.ComputeHash(temp);
            }

            SignatureObject signature = new SignatureObject();
            signature.SignatureData = new BinaryItem(signatureBytes);

            return new IntermediateNodeObject.IntermediateNodeObjectBuilder().Build(temp, signature);
        }