ObjFW  Diff

Differences From Artifact [1c897d691a]:

To Artifact [f0d2e79fad]:


18
19
20
21
22
23
24

25
26
27
28
29
30
31
#include <stdlib.h>
#include <string.h>

#import "OFSHA384Or512Hash.h"
#import "OFSecureData.h"

#import "OFHashAlreadyCalculatedException.h"

#import "OFOutOfRangeException.h"

static const size_t blockSize = 128;

@interface OFSHA384Or512Hash ()
- (void)of_resetState;
@end







>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdlib.h>
#include <string.h>

#import "OFSHA384Or512Hash.h"
#import "OFSecureData.h"

#import "OFHashAlreadyCalculatedException.h"
#import "OFHashNotCalculatedException.h"
#import "OFOutOfRangeException.h"

static const size_t blockSize = 128;

@interface OFSHA384Or512Hash ()
- (void)of_resetState;
@end
243
244
245
246
247
248
249
250


251







252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
			_iVars->bufferLength = 0;
		}
	}
}

- (const unsigned char *)digest
{
	if (_calculated)


		return (const unsigned char *)_iVars->state;








	_iVars->buffer.bytes[_iVars->bufferLength] = 0x80;
	OFZeroMemory(_iVars->buffer.bytes + _iVars->bufferLength + 1,
	    128 - _iVars->bufferLength - 1);

	if (_iVars->bufferLength >= 112) {
		processBlock(_iVars->state, _iVars->buffer.words);
		OFZeroMemory(_iVars->buffer.bytes, 128);
	}

	_iVars->buffer.words[14] = OFToBigEndian64(_iVars->bits[1]);
	_iVars->buffer.words[15] = OFToBigEndian64(_iVars->bits[0]);

	processBlock(_iVars->state, _iVars->buffer.words);
	OFZeroMemory(&_iVars->buffer, sizeof(_iVars->buffer));
	byteSwapVectorIfLE(_iVars->state, 8);
	_calculated = true;

	return (const unsigned char *)_iVars->state;
}

- (void)reset
{
	[self of_resetState];
	OFZeroMemory(_iVars->bits, sizeof(_iVars->bits));
	OFZeroMemory(&_iVars->buffer, sizeof(_iVars->buffer));







|
>
>
|
>
>
>
>
>
>
>

















<
<







244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278


279
280
281
282
283
284
285
			_iVars->bufferLength = 0;
		}
	}
}

- (const unsigned char *)digest
{
	if (!_calculated)
		@throw [OFHashNotCalculatedException exceptionWithObject: self];

	return (const unsigned char *)_iVars->state;
}

- (void)calculate
{
	if (_calculated)
		@throw [OFHashAlreadyCalculatedException
		    exceptionWithObject: self];

	_iVars->buffer.bytes[_iVars->bufferLength] = 0x80;
	OFZeroMemory(_iVars->buffer.bytes + _iVars->bufferLength + 1,
	    128 - _iVars->bufferLength - 1);

	if (_iVars->bufferLength >= 112) {
		processBlock(_iVars->state, _iVars->buffer.words);
		OFZeroMemory(_iVars->buffer.bytes, 128);
	}

	_iVars->buffer.words[14] = OFToBigEndian64(_iVars->bits[1]);
	_iVars->buffer.words[15] = OFToBigEndian64(_iVars->bits[0]);

	processBlock(_iVars->state, _iVars->buffer.words);
	OFZeroMemory(&_iVars->buffer, sizeof(_iVars->buffer));
	byteSwapVectorIfLE(_iVars->state, 8);
	_calculated = true;


}

- (void)reset
{
	[self of_resetState];
	OFZeroMemory(_iVars->bits, sizeof(_iVars->bits));
	OFZeroMemory(&_iVars->buffer, sizeof(_iVars->buffer));