ObjFW  Diff

Differences From Artifact [fd5490715b]:

To Artifact [a97ba49f22]:


132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
	buf[1] = 0xEFCDAB89;
	buf[2] = 0x98BADCFE;
	buf[3] = 0x10325476;

	return self;
}

- updateWithBuffer: (const char*)buffer
	    ofSize: (size_t)size
{
	uint32_t t;

	if (size == 0)
		return self;

	if (calculated)
		@throw [OFHashAlreadyCalculatedException newWithClass: isa];

	/* Update bitcount */
	t = bits[0];
	if ((bits[0] = t + ((uint32_t)size << 3)) < t)







|
|




|







132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
	buf[1] = 0xEFCDAB89;
	buf[2] = 0x98BADCFE;
	buf[3] = 0x10325476;

	return self;
}

- (void)updateWithBuffer: (const char*)buffer
		  ofSize: (size_t)size
{
	uint32_t t;

	if (size == 0)
		return;

	if (calculated)
		@throw [OFHashAlreadyCalculatedException newWithClass: isa];

	/* Update bitcount */
	t = bits[0];
	if ((bits[0] = t + ((uint32_t)size << 3)) < t)
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	if (t) {
		uint8_t *p = in + t;

		t = 64 - t;

		if (size < t) {
			memcpy(p, buffer, size);
			return self;
		}

		memcpy(p, buffer, t);
		OF_BSWAP32_V_IF_BE((uint32_t*)in, 16);
		md5_transform(buf, (uint32_t*)in);

		buffer += t;







|







161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	if (t) {
		uint8_t *p = in + t;

		t = 64 - t;

		if (size < t) {
			memcpy(p, buffer, size);
			return;
		}

		memcpy(p, buffer, t);
		OF_BSWAP32_V_IF_BE((uint32_t*)in, 16);
		md5_transform(buf, (uint32_t*)in);

		buffer += t;
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199

		buffer += 64;
		size -= 64;
	}

	/* Handle any remaining bytes of data. */
	memcpy(in, buffer, size);

	return self;
}

- (uint8_t*)digest
{
	uint8_t	*p;
	size_t	count;








<
<







184
185
186
187
188
189
190


191
192
193
194
195
196
197

		buffer += 64;
		size -= 64;
	}

	/* Handle any remaining bytes of data. */
	memcpy(in, buffer, size);


}

- (uint8_t*)digest
{
	uint8_t	*p;
	size_t	count;

374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
	state[2] = 0x98BADCFE;
	state[3] = 0x10325476;
	state[4] = 0xC3D2E1F0;

	return self;
}

- updateWithBuffer: (const char*)buf
	    ofSize: (size_t)size
{
	if (size == 0)
		return self;

	if (calculated)
		@throw [OFHashAlreadyCalculatedException newWithClass: isa];

	sha1_update(state, &count, buffer, buf, size);

	return self;
}

- (uint8_t*)digest
{
	size_t i;
	char   finalcount[8];








|
|


|





<
<







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388


389
390
391
392
393
394
395
	state[2] = 0x98BADCFE;
	state[3] = 0x10325476;
	state[4] = 0xC3D2E1F0;

	return self;
}

- (void)updateWithBuffer: (const char*)buf
		  ofSize: (size_t)size
{
	if (size == 0)
		return;

	if (calculated)
		@throw [OFHashAlreadyCalculatedException newWithClass: isa];

	sha1_update(state, &count, buffer, buf, size);


}

- (uint8_t*)digest
{
	size_t i;
	char   finalcount[8];