Lines Matching refs:instance
133 int SpongeInitialize(SpongeInstance *instance, unsigned int rate, unsigned int capacity)
140 SnP_Initialize(instance->state);
141 instance->rate = rate;
142 instance->byteIOIndex = 0;
143 instance->squeezing = 0;
150 int SpongeAbsorb(SpongeInstance *instance, const unsigned char *data, size_t dataByteLen)
155 unsigned int rateInBytes = instance->rate/8;
157 if (instance->squeezing)
163 if ((instance->byteIOIndex == 0) && (dataByteLen-i >= rateInBytes)) {
168 … j = SnP_FastLoop_Absorb(instance->state, rateInBytes/(SnP_width/200), curData, dataByteLen - i);
178 SnP_AddBytes(instance->state, curData, 0, rateInBytes);
179 SnP_Permute(instance->state);
189 if (dataByteLen-i > rateInBytes-instance->byteIOIndex)
190 partialBlock = rateInBytes-instance->byteIOIndex;
198 SnP_AddBytes(instance->state, curData, instance->byteIOIndex, partialBlock);
200 instance->byteIOIndex += partialBlock;
201 if (instance->byteIOIndex == rateInBytes) {
202 SnP_Permute(instance->state);
203 instance->byteIOIndex = 0;
212 int SpongeAbsorbLastFewBits(SpongeInstance *instance, unsigned char delimitedData)
214 unsigned int rateInBytes = instance->rate/8;
218 if (instance->squeezing)
229 SnP_AddByte(instance->state, delimitedData, instance->byteIOIndex);
231 if ((delimitedData >= 0x80) && (instance->byteIOIndex == (rateInBytes-1)))
232 SnP_Permute(instance->state);
234 SnP_AddByte(instance->state, 0x80, rateInBytes-1);
243 SnP_Permute(instance->state);
244 instance->byteIOIndex = 0;
245 instance->squeezing = 1;
254 int SpongeSqueeze(SpongeInstance *instance, unsigned char *data, size_t dataByteLen)
258 unsigned int rateInBytes = instance->rate/8;
261 if (!instance->squeezing)
262 SpongeAbsorbLastFewBits(instance, 0x01);
267 if ((instance->byteIOIndex == rateInBytes) && (dataByteLen-i >= rateInBytes)) {
269 SnP_Permute(instance->state);
270 SnP_ExtractBytes(instance->state, curData, 0, rateInBytes);
280 if (instance->byteIOIndex == rateInBytes) {
281 SnP_Permute(instance->state);
282 instance->byteIOIndex = 0;
284 if (dataByteLen-i > rateInBytes-instance->byteIOIndex)
285 partialBlock = rateInBytes-instance->byteIOIndex;
290 SnP_ExtractBytes(instance->state, curData, instance->byteIOIndex, partialBlock);
295 instance->byteIOIndex += partialBlock;