| 139 | } |
| 140 | |
| 141 | size_t BlockTransformation::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const |
| 142 | { |
| 143 | size_t blockSize = BlockSize(); |
| 144 | size_t inIncrement = (flags & (BT_InBlockIsCounter|BT_DontIncrementInOutPointers)) ? 0 : blockSize; |
| 145 | size_t xorIncrement = xorBlocks ? blockSize : 0; |
| 146 | size_t outIncrement = (flags & BT_DontIncrementInOutPointers) ? 0 : blockSize; |
| 147 | |
| 148 | if (flags & BT_ReverseDirection) |
| 149 | { |
| 150 | assert(length % blockSize == 0); |
| 151 | inBlocks += length - blockSize; |
| 152 | xorBlocks += length - blockSize; |
| 153 | outBlocks += length - blockSize; |
| 154 | inIncrement = 0-inIncrement; |
| 155 | xorIncrement = 0-xorIncrement; |
| 156 | outIncrement = 0-outIncrement; |
| 157 | } |
| 158 | |
| 159 | while (length >= blockSize) |
| 160 | { |
| 161 | if (flags & BT_XorInput) |
| 162 | { |
| 163 | xorbuf(outBlocks, xorBlocks, inBlocks, blockSize); |
| 164 | ProcessBlock(outBlocks); |
| 165 | } |
| 166 | else |
| 167 | ProcessAndXorBlock(inBlocks, xorBlocks, outBlocks); |
| 168 | if (flags & BT_InBlockIsCounter) |
| 169 | const_cast<byte *>(inBlocks)[blockSize-1]++; |
| 170 | inBlocks += inIncrement; |
| 171 | outBlocks += outIncrement; |
| 172 | xorBlocks += xorIncrement; |
| 173 | length -= blockSize; |
| 174 | } |
| 175 | |
| 176 | return length; |
| 177 | } |
| 178 | |
| 179 | unsigned int BlockTransformation::OptimalDataAlignment() const |
| 180 | { |
no test coverage detected