ObjFW
OFHMAC.h
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 #import "OFCryptoHash.h"
18 
19 OF_ASSUME_NONNULL_BEGIN
20 
26 OF_SUBCLASSING_RESTRICTED
27 @interface OFHMAC: OFObject
28 {
29  Class <OFCryptoHash> _hashClass;
30  bool _allowsSwappableMemory;
31  id <OFCryptoHash> _Nullable _outerHash, _innerHash;
32  id <OFCryptoHash> _Nullable _outerHashCopy, _innerHashCopy;
33  bool _calculated;
34 }
35 
39 @property (readonly, nonatomic) Class <OFCryptoHash> hashClass;
40 
44 @property (readonly, nonatomic) bool allowsSwappableMemory;
45 
52 @property (readonly, nonatomic) const unsigned char *digest
53  OF_RETURNS_INNER_POINTER;
54 
58 @property (readonly, nonatomic) size_t digestSize;
59 
67 + (instancetype)HMACWithHashClass: (Class <OFCryptoHash>)hashClass
68  allowsSwappableMemory: (bool)allowsSwappableMemory;
69 
70 - (instancetype)init OF_UNAVAILABLE;
71 
80 - (instancetype)initWithHashClass: (Class <OFCryptoHash>)hashClass
81  allowsSwappableMemory: (bool)allowsSwappableMemory
82  OF_DESIGNATED_INITIALIZER;
83 
96 - (void)setKey: (const void *)key length: (size_t)length;
97 
104 - (void)updateWithBuffer: (const void *)buffer length: (size_t)length;
105 
117 - (void)reset;
118 
125 - (void)zero;
126 @end
127 
128 OF_ASSUME_NONNULL_END
struct objc_object * id
A pointer to any object.
Definition: ObjFWRT.h:90
struct objc_class * Class
A pointer to a class.
Definition: ObjFWRT.h:85
A class which provides methods to calculate an HMAC.
Definition: OFHMAC.h:28
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A protocol for classes providing cryptographic hash functions.
Definition: OFCryptoHash.h:29