ObjFW  Diff

Differences From Artifact [682e9b5139]:

  • File src/OFHMAC.h — part of check-in [19f7dc67af] at 2016-07-24 12:14:41 on branch trunk — -[OFCryptoHash digest]: uint8_t -> unsigned char

    While in practice they are usually the same, the C standard says that
    only char does not have any alignment requirements. As (u)int*_t is
    defined to be an integer type of the specified size, it does not mean
    (u)int8_t needs to be char. (user: js, size: 2485) [annotate] [blame] [check-ins using]

To Artifact [fe33092934]:


22
23
24
25
26
27
28

29

30
31



32
33
34
35
36
37
38
/*!
 * @class OFHMAC OFHMAC.h ObjFW/OFHMAC.h
 *
 * @brief A class which provides methods to calculate an HMAC.
 */
@interface OFHMAC: OFObject
{

	id <OFCryptoHash> _outerHash, _innerHash;

	bool _keySet, _calculated;
}




/*!
 * @brief Returns a new OFHMAC with the specified hashing algorithm.
 *
 * @param class The class of the hashing algorithm
 * @return A new, autoreleased OFHMAC
 */







>

>
|

>
>
>







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*!
 * @class OFHMAC OFHMAC.h ObjFW/OFHMAC.h
 *
 * @brief A class which provides methods to calculate an HMAC.
 */
@interface OFHMAC: OFObject
{
	Class <OFCryptoHash> _hashClass;
	id <OFCryptoHash> _outerHash, _innerHash;
	id <OFCryptoHash> _outerHashCopy, _innerHashCopy;
	bool _calculated;
}

/*! The class for the cryptographic hash used by the HMAC. */
@property (assign, readonly) Class <OFCryptoHash> hashClass;

/*!
 * @brief Returns a new OFHMAC with the specified hashing algorithm.
 *
 * @param class The class of the hashing algorithm
 * @return A new, autoreleased OFHMAC
 */
46
47
48
49
50
51
52






53
54
55
56
57
58
59
 * @return An initialized OFHMAC
 */
- initWithHashClass: (Class <OFCryptoHash>)class;

/*!
 * @brief Sets the key for the HMAC.
 *






 * @param key The key for the HMAC
 * @param length The length of the key for the HMAC
 */
- (void)setKey: (const void*)key
	length: (size_t)length;

/*!







>
>
>
>
>
>







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 * @return An initialized OFHMAC
 */
- initWithHashClass: (Class <OFCryptoHash>)class;

/*!
 * @brief Sets the key for the HMAC.
 *
 * @note This resets the HMAC!
 *
 * @warning This invalidates any pointer previously returned by @ref digest. If
 *	    you are still interested in the previous digest, you need to memcpy
 *	    it yourself before calling @ref setKey:length:!
 *
 * @param key The key for the HMAC
 * @param length The length of the key for the HMAC
 */
- (void)setKey: (const void*)key
	length: (size_t)length;

/*!
79
80
81
82
83
84
85
86




87
88
89
90
91
92
93
94
95
 * @brief Returns the size of the digest.
 *
 * @return The size of the digest.
 */
- (size_t)digestSize;

/*!
 * @brief Resets all state so that a new HMAC can be calculated.




 *
 * @warning This invalidates any pointer previously returned by @ref digest. If
 *	    you are still interested in the previous digest, you need to memcpy
 *	    it yourself before calling @ref reset!
 */
- (void)reset;
@end

OF_ASSUME_NONNULL_END







|
>
>
>
>









90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
 * @brief Returns the size of the digest.
 *
 * @return The size of the digest.
 */
- (size_t)digestSize;

/*!
 * @brief Resets the HMAC so that it can be calculated for a new message.
 *
 * @note This does not reset the key so that a new HMAC with the same key can
 *	 be calculated efficiently. If you want to reset both, use
 *	 @ref setKey:length:.
 *
 * @warning This invalidates any pointer previously returned by @ref digest. If
 *	    you are still interested in the previous digest, you need to memcpy
 *	    it yourself before calling @ref reset!
 */
- (void)reset;
@end

OF_ASSUME_NONNULL_END