ObjFW  Diff

Differences From Artifact [5de5b91012]:

To Artifact [7296eed131]:


12
13
14
15
16
17
18



19
20
21
22
23
24
25
26
27
28







29
30





31
32
33



34
35
36
37
38
39
40
41
42
43
44







45
46





47
48
#import <stdint.h>

#import "OFObject.h"

#define MD5_DIGEST_SIZE	 16
#define SHA1_DIGEST_SIZE 20




@interface OFMD5Hash: OFObject
{
	uint32_t buf[4];
	uint32_t bits[2];
	uint8_t	 in[64];

	BOOL	 calculated;
}

- init;







- updateWithBuffer: (const uint8_t*)buf
	    ofSize: (size_t)size;





- (uint8_t*)digest;
@end




@interface OFSHA1Hash: OFObject
{
	uint32_t    state[5];
	uint64_t    count;
	uint8_t	    buffer[64];
	uint8_t	    digest[SHA1_DIGEST_SIZE];

	BOOL	 calculated;
}

- init;







- updateWithBuffer: (const uint8_t*)buf
	    ofSize: (size_t)size;





- (uint8_t*)digest;
@end







>
>
>










>
>
>
>
>
>
>


>
>
>
>
>



>
>
>











>
>
>
>
>
>
>


>
>
>
>
>


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#import <stdint.h>

#import "OFObject.h"

#define MD5_DIGEST_SIZE	 16
#define SHA1_DIGEST_SIZE 20

/**
 * The OFMD5Hash class provides functions to create an MD5 hash.
 */
@interface OFMD5Hash: OFObject
{
	uint32_t buf[4];
	uint32_t bits[2];
	uint8_t	 in[64];

	BOOL	 calculated;
}

- init;

/**
 * Adds a buffer to the hash to be calculated.
 * 
 * \param buf The buffer which should be included into calculation.
 * \param size The size of the buffer
 */
- updateWithBuffer: (const uint8_t*)buf
	    ofSize: (size_t)size;

/**
 * \return A buffer containing the hash (MD5_DIGEST_SIZE = 16 bytes).
 *	   The buffer is part of object's memory pool.
 */
- (uint8_t*)digest;
@end

/**
 * The OFSHA1Hash class provides functions to create an SHA1 hash.
 */
@interface OFSHA1Hash: OFObject
{
	uint32_t    state[5];
	uint64_t    count;
	uint8_t	    buffer[64];
	uint8_t	    digest[SHA1_DIGEST_SIZE];

	BOOL	 calculated;
}

- init;

/**
 * Adds a buffer to the hash to be calculated.
 * 
 * \param buf The buffer which should be included into calculation.
 * \param size The size of the buffer
 */
- updateWithBuffer: (const uint8_t*)buf
	    ofSize: (size_t)size;

/**
 * \return A buffer containing the hash (SHA1_DIGEST_SIZE = 20 bytes).
 *	   The buffer is part of object's memory pool.
 */
- (uint8_t*)digest;
@end