10
11
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
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFCryptoHash.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFHMAC OFHMAC.h ObjFW/OFHMAC.h
*
* @brief A class which provides methods to calculate an HMAC.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFHMAC: OFObject
{
Class <OFCryptoHash> _hashClass;
bool _allowsSwappableMemory;
id <OFCryptoHash> _Nullable _outerHash, _innerHash;
id <OFCryptoHash> _Nullable _outerHashCopy, _innerHashCopy;
bool _calculated;
}
/**
* @brief The class for the cryptographic hash used by the HMAC.
*/
@property (readonly, nonatomic) Class <OFCryptoHash> hashClass;
/**
* @brief Whether data may be stored in swappable memory.
*/
@property (readonly, nonatomic) bool allowsSwappableMemory;
/**
|
|
|
|
|
|
|
10
11
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
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFCryptographicHash.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFHMAC OFHMAC.h ObjFW/OFHMAC.h
*
* @brief A class which provides methods to calculate an HMAC.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFHMAC: OFObject
{
Class <OFCryptographicHash> _hashClass;
bool _allowsSwappableMemory;
id <OFCryptographicHash> _Nullable _outerHash, _innerHash;
id <OFCryptographicHash> _Nullable _outerHashCopy, _innerHashCopy;
bool _calculated;
}
/**
* @brief The class for the cryptographic hash used by the HMAC.
*/
@property (readonly, nonatomic) Class <OFCryptographicHash> hashClass;
/**
* @brief Whether data may be stored in swappable memory.
*/
@property (readonly, nonatomic) bool allowsSwappableMemory;
/**
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/**
* @brief Returns a new OFHMAC with the specified hashing algorithm.
*
* @param hashClass The class of the hashing algorithm
* @param allowsSwappableMemory Whether data may be stored in swappable memory
* @return A new, autoreleased OFHMAC
*/
+ (instancetype)HMACWithHashClass: (Class <OFCryptoHash>)hashClass
allowsSwappableMemory: (bool)allowsSwappableMemory;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initialized an already allocated OFHMAC with the specified hashing
* algorithm.
*
* @param hashClass The class of the hashing algorithm
* @param allowsSwappableMemory Whether data may be stored in swappable memory
* @return An initialized OFHMAC
*/
- (instancetype)initWithHashClass: (Class <OFCryptoHash>)hashClass
allowsSwappableMemory: (bool)allowsSwappableMemory
OF_DESIGNATED_INITIALIZER;
/**
* @brief Sets the key for the HMAC.
*
* @note This resets the HMAC!
|
|
|
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/**
* @brief Returns a new OFHMAC with the specified hashing algorithm.
*
* @param hashClass The class of the hashing algorithm
* @param allowsSwappableMemory Whether data may be stored in swappable memory
* @return A new, autoreleased OFHMAC
*/
+ (instancetype)HMACWithHashClass: (Class <OFCryptographicHash>)hashClass
allowsSwappableMemory: (bool)allowsSwappableMemory;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initialized an already allocated OFHMAC with the specified hashing
* algorithm.
*
* @param hashClass The class of the hashing algorithm
* @param allowsSwappableMemory Whether data may be stored in swappable memory
* @return An initialized OFHMAC
*/
- (instancetype)initWithHashClass: (Class <OFCryptographicHash>)hashClass
allowsSwappableMemory: (bool)allowsSwappableMemory
OF_DESIGNATED_INITIALIZER;
/**
* @brief Sets the key for the HMAC.
*
* @note This resets the HMAC!
|