예제 #1
0
            } // end function Node

            // update incorporates input into the chunkState.
            public unsafe void Update(byte *dataPtr, Int32 a_DataLength)
            {
                Int32 LCount, LIndex;

                LIndex = 0;

                fixed(byte *LBytePtr = Block)
                {
                    fixed(UInt32 *LCardinalPtr = N.Block)
                    {
                        fixed(UInt32 *LCVPtr = N.CV)
                        {
                            while (a_DataLength > 0)
                            {
                                // If the block buffer is full, compress it and clear it. More
                                // input is coming, so this compression is not flagChunkEnd.
                                if (BlockLen == BlockSizeInBytes)
                                {
                                    // copy the chunk block (bytes) into the node block and chain it.
                                    Converters.le32_copy((IntPtr)LBytePtr, 0, (IntPtr)LCardinalPtr, 0, BlockSizeInBytes);
                                    N.ChainingValue(ref N.CV);
                                    // clear the start flag for all but the first block
                                    N.Flags  = N.Flags & (N.Flags ^ flagChunkStart);
                                    BlockLen = 0;
                                } // end if

                                // Copy input bytes into the chunk block.
                                LCount = Math.Min(BlockSizeInBytes - BlockLen, a_DataLength);
                                Utils.Utils.Memmove((IntPtr)(LBytePtr + BlockLen), (IntPtr)(dataPtr + LIndex), LCount);

                                BlockLen      += LCount;
                                BytesConsumed += LCount;
                                LIndex        += LCount;
                                a_DataLength  -= LCount;
                            } // end while
                        }
                    }
                }
            } // end function Update
예제 #2
0
            // update incorporates input into the chunkState.
            public unsafe void Update(byte *dataPtr, int dataLength)
            {
                var index = 0;

                fixed(byte *blockPtr = _block)
                {
                    fixed(uint *blockPtr2 = _n.Block)
                    {
                        fixed(uint *cvPtr = _n.CV)
                        {
                            while (dataLength > 0)
                            {
                                // If the block buffer is full, compress it and clear it. More
                                // input is coming, so this compression is not flagChunkEnd.
                                if (_blockLen == BlockSizeInBytes)
                                {
                                    // copy the chunk block (bytes) into the node block and chain it.
                                    Converters.le32_copy(blockPtr, 0, blockPtr2, 0,
                                                         BlockSizeInBytes);
                                    _n.ChainingValue(cvPtr);
                                    // clear the start flag for all but the first block
                                    _n.Flags &= _n.Flags ^ flagChunkStart;
                                    _blockLen = 0;
                                }

                                // Copy input bytes into the chunk block.
                                var count = Math.Min(BlockSizeInBytes - _blockLen, dataLength);
                                PointerUtils.MemMove(blockPtr + _blockLen, dataPtr + index, count);

                                _blockLen     += count;
                                BytesConsumed += count;
                                index         += count;
                                dataLength    -= count;
                            }
                        }
                    }
                }
            }
예제 #3
0
        }; // end struct Blake3OutputReader

        private Blake3Node RootNode()
        {
            Int32 LIdx, LTrailingZeros64, LLen64;

            Blake3Node result = CS.Node();

            UInt32[] LTemp = new UInt32[8];

            LTrailingZeros64 = TrailingZeros64(Used);
            LLen64           = Len64(Used);

            for (LIdx = LTrailingZeros64; LIdx < LLen64; LIdx++)
            {
                if (HasSubTreeAtHeight(LIdx))
                {
                    result.ChainingValue(ref LTemp);
                    result = Blake3Node.ParentNode(Stack[LIdx], LTemp, Key, Flags);
                }
            }

            result.Flags = result.Flags | flagRoot;

            return(result);
        } // end function RootNode