ObjFW
OFCryptoHash.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 
18 OF_ASSUME_NONNULL_BEGIN
19 
30 #ifdef OF_HAVE_CLASS_PROPERTIES
31 @property (class, readonly, nonatomic) size_t digestSize;
32 @property (class, readonly, nonatomic) size_t blockSize;
33 #endif
34 
38 @property (readonly, nonatomic) size_t digestSize;
39 
43 @property (readonly, nonatomic) size_t blockSize;
44 
48 @property (readonly, nonatomic) bool allowsSwappableMemory;
49 
53 @property (readonly, nonatomic, getter=isCalculated) bool calculated;
54 
61 @property (readonly, nonatomic) const unsigned char *digest
62  OF_RETURNS_INNER_POINTER;
63 
69 + (instancetype)cryptoHashWithAllowsSwappableMemory:
70  (bool)allowsSwappableMemory;
71 
77 + (size_t)digestSize;
78 
84 + (size_t)blockSize;
85 
91 - (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory;
92 
93 - (instancetype)init OF_UNAVAILABLE;
94 
101 - (void)updateWithBuffer: (const void *)buffer length: (size_t)length;
102 
110 - (void)reset;
111 @end
112 
113 OF_ASSUME_NONNULL_END
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A protocol for the creation of copies.
Definition: OFObject.h:1187
A protocol for classes providing cryptographic hash functions.
Definition: OFCryptoHash.h:29
bool allowsSwappableMemory
Whether data may be stored in swappable memory.
Definition: OFCryptoHash.h:48
void reset()
Resets all state so that a new hash can be calculated.
const unsigned char * digest
A buffer containing the cryptographic hash.
Definition: OFCryptoHash.h:62
bool calculated
A boolean whether the hash has already been calculated.
Definition: OFCryptoHash.h:53
size_t blockSize
The block size of the cryptographic hash, in bytes.
Definition: OFCryptoHash.h:43
size_t digestSize
The digest size of the cryptographic hash, in bytes.
Definition: OFCryptoHash.h:38