ObjFW  Check-in [5bf0f17e80]

Overview
Comment:Prevent updating a hash after it has been calculated.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5bf0f17e80bfbea73f39917e02f61fb51df9d4d915800a5c41daad349a1df15b
User & Date: js on 2009-08-28 00:18:34
Other Links: manifest | tags
Context
2009-08-28
00:18
Improve -[isEqual:] of OFList. check-in: d68dc5201f user: js tags: trunk
00:18
Prevent updating a hash after it has been calculated. check-in: 5bf0f17e80 user: js tags: trunk
00:05
Add OF_BSWAP{16,32,64}. check-in: c38fc9bb14 user: js tags: trunk
Changes

Modified src/OFHashes.m from [3186857f90] to [8f94b0d560].

11
12
13
14
15
16
17

18
19
20
21
22
23
24

#include "config.h"

#include <string.h>

#import "OFHashes.h"
#import "OFAutoreleasePool.h"

#import "OFMacros.h"

int _OFHashing_reference;

/*******
 * MD5 *
 *******/







>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#include "config.h"

#include <string.h>

#import "OFHashes.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

int _OFHashing_reference;

/*******
 * MD5 *
 *******/
136
137
138
139
140
141
142
143
144
145
146
147




148
149
150
151
152
153
154
}

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

	if (calculated)
		return self;
	if (size == 0)
		return self;





	/* Update bitcount */
	t = bits[0];
	if ((bits[0] = t + ((uint32_t)size << 3)) < t)
		/* Carry from low to high */
		bits[1]++;
	bits[1] += size >> 29;








<
<



>
>
>
>







137
138
139
140
141
142
143


144
145
146
147
148
149
150
151
152
153
154
155
156
157
}

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



	if (size == 0)
		return self;

	if (calculated)
		/* FIXME: Maybe a new exception would be better */
		@throw [OFInvalidArgumentException newWithClass: isa];

	/* Update bitcount */
	t = bits[0];
	if ((bits[0] = t + ((uint32_t)size << 3)) < t)
		/* Carry from low to high */
		bits[1]++;
	bits[1] += size >> 29;

373
374
375
376
377
378
379
380
381
382
383
384




385
386
387
388
389
390
391

	return self;
}

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





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

	return self;
}

- (uint8_t*)digest
{







<
<



>
>
>
>







376
377
378
379
380
381
382


383
384
385
386
387
388
389
390
391
392
393
394
395
396

	return self;
}

- updateWithBuffer: (const char*)buf
	    ofSize: (size_t)size
{


	if (size == 0)
		return self;

	if (calculated)
		/* FIXME: Maybe a new exception would be better */
		@throw [OFInvalidArgumentException newWithClass: isa];

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

	return self;
}

- (uint8_t*)digest
{