Lines Matching refs:instance
143 int SpongeInitialize(SpongeInstance *instance, unsigned int rate, unsigned int capacity)
150 SnP_Initialize(instance->state);
151 instance->rate = rate;
152 instance->byteIOIndex = 0;
153 instance->squeezing = 0;
160 int SpongeAbsorb(SpongeInstance *instance, const unsigned char *data, size_t dataByteLen)
165 unsigned int rateInBytes = instance->rate/8;
167 if (instance->squeezing)
174 if ((instance->byteIOIndex == 0) && (dataByteLen >= (i + rateInBytes))) {
181 … j = SnP_FastLoop_Absorb(instance->state, rateInBytes/(SnP_width/200), curData, dataByteLen - i);
191 SnP_AddBytes(instance->state, curData, 0, rateInBytes);
192 SnP_Permute(instance->state);
204 if (partialBlock+instance->byteIOIndex > rateInBytes)
205 partialBlock = rateInBytes-instance->byteIOIndex;
211 SnP_AddBytes(instance->state, curData, instance->byteIOIndex, partialBlock);
213 instance->byteIOIndex += partialBlock;
214 if (instance->byteIOIndex == rateInBytes) {
215 SnP_Permute(instance->state);
216 instance->byteIOIndex = 0;
225 int SpongeAbsorbLastFewBits(SpongeInstance *instance, unsigned char delimitedData)
227 unsigned int rateInBytes = instance->rate/8;
231 if (instance->squeezing)
244 SnP_AddByte(instance->state, delimitedData, instance->byteIOIndex);
247 if ((delimitedData >= 0x80) && (instance->byteIOIndex == (rateInBytes-1)))
248 SnP_Permute(instance->state);
251 SnP_AddByte(instance->state, 0x80, rateInBytes-1);
260 SnP_Permute(instance->state);
261 instance->byteIOIndex = 0;
262 instance->squeezing = 1;
271 int SpongeSqueeze(SpongeInstance *instance, unsigned char *data, size_t dataByteLen)
275 unsigned int rateInBytes = instance->rate/8;
278 if (!instance->squeezing)
279 SpongeAbsorbLastFewBits(instance, 0x01);
284 if ((instance->byteIOIndex == rateInBytes) && (dataByteLen >= (i + rateInBytes))) {
286 SnP_Permute(instance->state);
287 SnP_ExtractBytes(instance->state, curData, 0, rateInBytes);
298 if (instance->byteIOIndex == rateInBytes) {
299 SnP_Permute(instance->state);
300 instance->byteIOIndex = 0;
303 if (partialBlock+instance->byteIOIndex > rateInBytes)
304 partialBlock = rateInBytes-instance->byteIOIndex;
307 SnP_ExtractBytes(instance->state, curData, instance->byteIOIndex, partialBlock);
312 instance->byteIOIndex += partialBlock;