ObjFW
Loading...
Searching...
No Matches
OFHMAC.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFObject.h"
21#import "OFCryptographicHash.h"
22
23OF_ASSUME_NONNULL_BEGIN
24
30OF_SUBCLASSING_RESTRICTED
31@interface OFHMAC: OFObject
32{
33 Class <OFCryptographicHash> _hashClass;
34 bool _allowsSwappableMemory;
35 id <OFCryptographicHash> _Nullable _outerHash, _innerHash;
36 id <OFCryptographicHash> _Nullable _outerHashCopy, _innerHashCopy;
37 bool _calculated;
38}
39
43@property (readonly, nonatomic) Class <OFCryptographicHash> hashClass;
44
48@property (readonly, nonatomic) bool allowsSwappableMemory;
49
58@property (readonly, nonatomic) const unsigned char *digest
59 OF_RETURNS_INNER_POINTER;
60
64@property (readonly, nonatomic) size_t digestSize;
65
73+ (instancetype)HMACWithHashClass: (Class <OFCryptographicHash>)hashClass
74 allowsSwappableMemory: (bool)allowsSwappableMemory;
75
76- (instancetype)init OF_UNAVAILABLE;
77
86- (instancetype)initWithHashClass: (Class <OFCryptographicHash>)hashClass
87 allowsSwappableMemory: (bool)allowsSwappableMemory
88 OF_DESIGNATED_INITIALIZER;
89
102- (void)setKey: (const void *)key length: (size_t)length;
103
111- (void)updateWithBuffer: (const void *)buffer length: (size_t)length;
112
118- (void)calculate;
119
131- (void)reset;
132
139- (void)zero;
140@end
141
142OF_ASSUME_NONNULL_END
A class which provides methods to calculate an HMAC.
Definition OFHMAC.h:32
The root class for all other classes inside ObjFW.
Definition OFObject.h:692