ObjFW
Toggle main menu visibility
Loading...
Searching...
No Matches
OFHMAC.h
1
/*
2
* Copyright (c) 2008-2026 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
23
OF_ASSUME_NONNULL_BEGIN
24
30
OF_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
142
OF_ASSUME_NONNULL_END
OFObject.h
OFHMAC
A class which provides methods to calculate an HMAC.
Definition
OFHMAC.h:32
OFHMAC::hashClass
Class< OFCryptographicHash > hashClass
The class for the cryptographic hash used by the HMAC.
Definition
OFHMAC.h:43
-[OFHMAC zero]
void zero()
This is like reset, but also zeroes the hashed key and all state.
Definition
OFHMAC.m:190
OFHMAC::digest
const unsigned char * digest
A buffer containing the HMAC.
Definition
OFHMAC.m:165
-[OFHMAC calculate]
void calculate()
Performs the final calculation of the HMAC.
Definition
OFHMAC.m:149
OFHMAC::allowsSwappableMemory
bool allowsSwappableMemory
Whether data may be stored in swappable memory.
Definition
OFHMAC.h:48
-[OFHMAC reset]
void reset()
Resets the HMAC so that it can be calculated for a new message.
Definition
OFHMAC.m:178
OFHMAC::digestSize
size_t digestSize
The size of the digest.
Definition
OFHMAC.m:173
OFObject
The root class for all other classes inside ObjFW.
Definition
OFObject.h:956
-[OFObject init]
instancetype init()
Initializes an already allocated object.
Definition
OFObject.m:671
src
OFHMAC.h
Generated by
1.17.0