예제 #1
0
        } // end function DoInit

        private void NextAddresses(TFillBlock a_Filler, Block a_ZeroBlock,
                                   Block a_InputBlock, ref Block a_AddressBlock)
        {
            a_InputBlock.v[6]++;
            a_Filler.FillBlock(a_ZeroBlock, a_InputBlock, ref a_AddressBlock, false);
            a_Filler.FillBlock(a_ZeroBlock, a_AddressBlock, ref a_AddressBlock, false);
        } // end function NextAddresses
예제 #2
0
        } //

        private UInt64 GetPseudoRandom(TFillBlock a_Filler, Position a_Position,
                                       Block a_AddressBlock, Block a_InputBlock, Block a_ZeroBlock, Int32 a_PrevOffset,
                                       bool a_DataIndependentAddressing)
        {
            if (a_DataIndependentAddressing)
            {
                if (a_Position.Index % ARGON2_ADDRESSES_IN_BLOCK == 0)
                    NextAddresses(a_Filler, a_ZeroBlock, a_InputBlock, ref a_AddressBlock); }

                return(a_AddressBlock.v[a_Position.Index % ARGON2_ADDRESSES_IN_BLOCK]);
            }
예제 #3
0
        } // end function Initialize

        private void FillSegment(Int32 a_Idx, Position a_Position)
        {
            Block      LAddressBlock, LInputBlock, LZeroBlock, LPrevBlock, LRefBlock, LCurrentBlock;
            bool       LDataIndependentAddressing, LWithXor;
            Int32      LStartingIndex, LCurrentOffset, LPrevOffset, LRefLane, LRefColumn;
            UInt64     LPseudoRandom;
            TFillBlock LFiller;

            // line below not really needed, just added to fix compiler hint
            a_Position.Lane            = a_Idx;
            LFiller                    = TFillBlock.CreateFillBlock();
            LDataIndependentAddressing = IsDataIndependentAddressing(a_Position);
            LStartingIndex             = GetStartingIndex(a_Position);
            LCurrentOffset             = (a_Position.Lane * LaneLength) +
                                         (a_Position.Slice * SegmentLength) + LStartingIndex;
            LPrevOffset = GetPrevOffset(LCurrentOffset);

            LAddressBlock = new Block();
            LInputBlock   = new Block();
            LZeroBlock    = new Block();

            if (LDataIndependentAddressing)
            {
                LAddressBlock = LFiller.AddressBlock.Clear();
                LZeroBlock    = LFiller.ZeroBlock.Clear();
                LInputBlock   = LFiller.InputBlock.Clear();

                InitAddressBlocks(LFiller, a_Position, LZeroBlock, ref LInputBlock, ref LAddressBlock);
            }

            a_Position.Index = LStartingIndex;

            while (a_Position.Index < SegmentLength)
            {
                LPrevOffset = RotatePrevOffset(LCurrentOffset, LPrevOffset);

                LPseudoRandom = GetPseudoRandom(LFiller, a_Position, LAddressBlock,
                                                LInputBlock, LZeroBlock, LPrevOffset, LDataIndependentAddressing);
                LRefLane   = GetRefLane(a_Position, LPseudoRandom);
                LRefColumn = GetRefColumn(a_Position, LPseudoRandom, LRefLane == a_Position.Lane);

                // 2 Creating a new block
                LPrevBlock    = Memory[LPrevOffset];
                LRefBlock     = Memory[(((LaneLength) * LRefLane) + LRefColumn)];
                LCurrentBlock = Memory[LCurrentOffset];

                LWithXor = IsWithXor(a_Position);
                LFiller.FillBlock(LPrevBlock, LRefBlock, ref LCurrentBlock, LWithXor);

                a_Position.Index++;
                LCurrentOffset++;
                LPrevOffset++;
            } //
        }     // end function FillSegment
예제 #4
0
            } // end function ApplyBlake

            public static TFillBlock CreateFillBlock()
            {
                TFillBlock result = new TFillBlock();

                result.R            = Block.CreateBlock();
                result.Z            = Block.CreateBlock();
                result.AddressBlock = Block.CreateBlock();
                result.ZeroBlock    = Block.CreateBlock();
                result.InputBlock   = Block.CreateBlock();

                return(result);
            } // end function CreateFillBlock
예제 #5
0
        } // end function DoParallelFillMemoryBlocks

        private void InitAddressBlocks(TFillBlock a_Filler, Position a_Position,
                                       Block a_ZeroBlock, ref Block a_InputBlock, ref Block a_AddressBlock)
        {
            a_InputBlock.v[0] = IntToUInt64(a_Position.Pass);
            a_InputBlock.v[1] = IntToUInt64(a_Position.Lane);
            a_InputBlock.v[2] = IntToUInt64(a_Position.Slice);
            a_InputBlock.v[3] = IntToUInt64(Memory.Length);
            a_InputBlock.v[4] = IntToUInt64(Parameters.Iterations);
            a_InputBlock.v[5] = IntToUInt64((Int32)Parameters.Type);

            if ((a_Position.Pass == 0) && (a_Position.Slice == 0))
            {
                // Don't forget to generate the first block of addresses: */
                NextAddresses(a_Filler, a_ZeroBlock, a_InputBlock, ref a_AddressBlock);
            }
        } // end function InitAddressBlocks