ObjFW  Diff

Differences From Artifact [51d3c14901]:

To Artifact [d5b60b898c]:


172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
	memcpy(&copy->_buffer, &_buffer, sizeof(_buffer));
	copy->_bufferLength = _bufferLength;
	copy->_calculated = _calculated;

	return copy;
}

- (void)updateWithBuffer: (const void*)buffer_
		  length: (size_t)length
{
	const uint8_t *buffer = buffer_;

	if (_calculated)
		@throw [OFHashAlreadyCalculatedException
		    exceptionWithObject: self];







|







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
	memcpy(&copy->_buffer, &_buffer, sizeof(_buffer));
	copy->_bufferLength = _bufferLength;
	copy->_calculated = _calculated;

	return copy;
}

- (void)updateWithBuffer: (const void *)buffer_
		  length: (size_t)length
{
	const uint8_t *buffer = buffer_;

	if (_calculated)
		@throw [OFHashAlreadyCalculatedException
		    exceptionWithObject: self];
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
		if (_bufferLength == 128) {
			processBlock(_state, _buffer.words);
			_bufferLength = 0;
		}
	}
}

- (const unsigned char*)digest
{
	if (_calculated)
		return (const uint8_t*)_state;

	_buffer.bytes[_bufferLength] = 0x80;
	memset(_buffer.bytes + _bufferLength + 1, 0, 128 - _bufferLength - 1);

	if (_bufferLength >= 112) {
		processBlock(_state, _buffer.words);
		memset(_buffer.bytes, 0, 128);
	}

	_buffer.words[14] = OF_BSWAP64_IF_LE(_bits[1]);
	_buffer.words[15] = OF_BSWAP64_IF_LE(_bits[0]);

	processBlock(_state, _buffer.words);
	memset(&_buffer, 0, sizeof(_buffer));
	byteSwapVectorIfLE(_state, 8);
	_calculated = true;

	return (const uint8_t*)_state;
}

- (void)reset
{
	[self OF_resetState];
	memset(_bits, 0, sizeof(_bits));
	memset(&_buffer, 0, sizeof(_buffer));







|


|

















|







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
		if (_bufferLength == 128) {
			processBlock(_state, _buffer.words);
			_bufferLength = 0;
		}
	}
}

- (const unsigned char *)digest
{
	if (_calculated)
		return (const uint8_t *)_state;

	_buffer.bytes[_bufferLength] = 0x80;
	memset(_buffer.bytes + _bufferLength + 1, 0, 128 - _bufferLength - 1);

	if (_bufferLength >= 112) {
		processBlock(_state, _buffer.words);
		memset(_buffer.bytes, 0, 128);
	}

	_buffer.words[14] = OF_BSWAP64_IF_LE(_bits[1]);
	_buffer.words[15] = OF_BSWAP64_IF_LE(_bits[0]);

	processBlock(_state, _buffer.words);
	memset(&_buffer, 0, sizeof(_buffer));
	byteSwapVectorIfLE(_state, 8);
	_calculated = true;

	return (const uint8_t *)_state;
}

- (void)reset
{
	[self OF_resetState];
	memset(_bits, 0, sizeof(_bits));
	memset(&_buffer, 0, sizeof(_buffer));