Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -28,11 +28,11 @@ OFColor.m \ OFConstantString.m \ OFCountedSet.m \ OFData.m \ OFData+ASN1DERParsing.m \ - OFData+CryptoHashing.m \ + OFData+CryptographicHashing.m \ OFData+MessagePackParsing.m \ OFDate.m \ OFDictionary.m \ OFEnumerator.m \ OFFileManager.m \ @@ -82,11 +82,11 @@ OFSHA512Hash.m \ OFSortedList.m \ OFStdIOStream.m \ OFStream.m \ OFString.m \ - OFString+CryptoHashing.m \ + OFString+CryptographicHashing.m \ OFString+JSONParsing.m \ OFString+PropertyListParsing.m \ OFString+Serialization.m \ OFString+URLEncoding.m \ OFString+XMLEscaping.m \ @@ -175,11 +175,11 @@ atomic_sync_builtins.h \ atomic_x86.h INCLUDES := ${SRCS:.m=.h} \ OFASN1DERRepresentation.h \ OFCollection.h \ - OFCryptoHash.h \ + OFCryptographicHash.h \ OFJSONRepresentation.h \ OFKernelEventObserver.h \ OFKeyValueCoding.h \ OFLocking.h \ OFMessagePackRepresentation.h \ DELETED src/OFCryptoHash.h Index: src/OFCryptoHash.h ================================================================== --- src/OFCryptoHash.h +++ src/OFCryptoHash.h @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2008-2021 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * 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" - -OF_ASSUME_NONNULL_BEGIN - -/** - * @protocol OFCryptoHash OFCryptoHash.h ObjFW/OFCryptoHash.h - * - * @brief A protocol for classes providing cryptographic hash functions. - * - * A cryptographic hash implementing this protocol can be copied. The entire - * state is copied, allowing to calculate a new hash from there. This is - * especially useful for generating many hashes with a common prefix. - */ -@protocol OFCryptoHash -#ifdef OF_HAVE_CLASS_PROPERTIES -@property (class, readonly, nonatomic) size_t digestSize; -@property (class, readonly, nonatomic) size_t blockSize; -#endif - -/** - * @brief The digest size of the cryptographic hash, in bytes. - */ -@property (readonly, nonatomic) size_t digestSize; - -/** - * @brief The block size of the cryptographic hash, in bytes. - */ -@property (readonly, nonatomic) size_t blockSize; - -/** - * @brief Whether data may be stored in swappable memory. - */ -@property (readonly, nonatomic) bool allowsSwappableMemory; - -/** - * @brief A boolean whether the hash has already been calculated. - */ -@property (readonly, nonatomic, getter=isCalculated) bool calculated; - -/** - * @brief A buffer containing the cryptographic hash. - * - * The size of the buffer depends on the hash used. The buffer is part of the - * receiver's memory pool. - */ -@property (readonly, nonatomic) const unsigned char *digest - OF_RETURNS_INNER_POINTER; - -/** - * @brief Creates a new cryptographic hash. - * - * @return A new autoreleased cryptographic hash - */ -+ (instancetype)cryptoHashWithAllowsSwappableMemory: - (bool)allowsSwappableMemory; - -/** - * @brief Returns the digest size of the cryptographic hash, in bytes. - * - * @return The digest size of the cryptographic hash, in bytes - */ -+ (size_t)digestSize; - -/** - * @brief Returns the block size of the cryptographic hash, in bytes. - * - * @return The block size of the cryptographic hash, in bytes - */ -+ (size_t)blockSize; - -/** - * @brief Initializes an already allocated cryptographic hash. - * - * @return An initialized cryptographic hash - */ -- (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory; - -- (instancetype)init OF_UNAVAILABLE; - -/** - * @brief Adds a buffer to the cryptographic hash to be calculated. - * - * @param buffer The buffer which should be included into the calculation - * @param length The length of the buffer - */ -- (void)updateWithBuffer: (const void *)buffer length: (size_t)length; - -/** - * @brief Resets all state so that a new hash can be calculated. - * - * @warning This invalidates any pointer previously returned by @ref digest. If - * you are still interested in the previous digest, you need to memcpy - * it yourself before calling @ref reset! - */ -- (void)reset; -@end - -OF_ASSUME_NONNULL_END ADDED src/OFCryptographicHash.h Index: src/OFCryptographicHash.h ================================================================== --- src/OFCryptographicHash.h +++ src/OFCryptographicHash.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * 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" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @protocol OFCryptographicHash \ + * OFCryptographicHash.h ObjFW/OFCryptographicHash.h + * + * @brief A protocol for classes providing cryptographic hash functions. + * + * A cryptographic hash implementing this protocol can be copied. The entire + * state is copied, allowing to calculate a new hash from there. This is + * especially useful for generating many hashes with a common prefix. + */ +@protocol OFCryptographicHash +#ifdef OF_HAVE_CLASS_PROPERTIES +@property (class, readonly, nonatomic) size_t digestSize; +@property (class, readonly, nonatomic) size_t blockSize; +#endif + +/** + * @brief The digest size of the cryptographic hash, in bytes. + */ +@property (readonly, nonatomic) size_t digestSize; + +/** + * @brief The block size of the cryptographic hash, in bytes. + */ +@property (readonly, nonatomic) size_t blockSize; + +/** + * @brief Whether data may be stored in swappable memory. + */ +@property (readonly, nonatomic) bool allowsSwappableMemory; + +/** + * @brief A boolean whether the hash has already been calculated. + */ +@property (readonly, nonatomic, getter=isCalculated) bool calculated; + +/** + * @brief A buffer containing the cryptographic hash. + * + * The size of the buffer depends on the hash used. The buffer is part of the + * receiver's memory pool. + */ +@property (readonly, nonatomic) const unsigned char *digest + OF_RETURNS_INNER_POINTER; + +/** + * @brief Creates a new cryptographic hash. + * + * @return A new autoreleased cryptographic hash + */ ++ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory; + +/** + * @brief Returns the digest size of the cryptographic hash, in bytes. + * + * @return The digest size of the cryptographic hash, in bytes + */ ++ (size_t)digestSize; + +/** + * @brief Returns the block size of the cryptographic hash, in bytes. + * + * @return The block size of the cryptographic hash, in bytes + */ ++ (size_t)blockSize; + +/** + * @brief Initializes an already allocated cryptographic hash. + * + * @return An initialized cryptographic hash + */ +- (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory; + +- (instancetype)init OF_UNAVAILABLE; + +/** + * @brief Adds a buffer to the cryptographic hash to be calculated. + * + * @param buffer The buffer which should be included into the calculation + * @param length The length of the buffer + */ +- (void)updateWithBuffer: (const void *)buffer length: (size_t)length; + +/** + * @brief Resets all state so that a new hash can be calculated. + * + * @warning This invalidates any pointer previously returned by @ref digest. If + * you are still interested in the previous digest, you need to memcpy + * it yourself before calling @ref reset! + */ +- (void)reset; +@end + +OF_ASSUME_NONNULL_END DELETED src/OFData+CryptoHashing.h Index: src/OFData+CryptoHashing.h ================================================================== --- src/OFData+CryptoHashing.h +++ src/OFData+CryptoHashing.h @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008-2021 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * 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 "OFData.h" - -OF_ASSUME_NONNULL_BEGIN - -@class OFString; - -#ifdef __cplusplus -extern "C" { -#endif -extern int _OFData_CryptoHashing_reference; -#ifdef __cplusplus -} -#endif - -@interface OFData (CryptoHashing) -/** - * @brief The MD5 hash of the data as a string. - */ -@property (readonly, nonatomic) OFString *stringByMD5Hashing; - -/** - * @brief The RIPEMD-160 hash of the data as a string. - */ -@property (readonly, nonatomic) OFString *stringByRIPEMD160Hashing; - -/** - * @brief The SHA-1 hash of the data as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA1Hashing; - -/** - * @brief The SHA-224 hash of the data as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA224Hashing; - -/** - * @brief The SHA-256 hash of the data as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA256Hashing; - -/** - * @brief The SHA-384 hash of the data as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA384Hashing; - -/** - * @brief The SHA-512 hash of the data as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA512Hashing; -@end - -OF_ASSUME_NONNULL_END DELETED src/OFData+CryptoHashing.m Index: src/OFData+CryptoHashing.m ================================================================== --- src/OFData+CryptoHashing.m +++ src/OFData+CryptoHashing.m @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2008-2021 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * 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. - */ - -#include "config.h" - -#import "OFData+CryptoHashing.h" -#import "OFString.h" -#import "OFCryptoHash.h" -#import "OFMD5Hash.h" -#import "OFRIPEMD160Hash.h" -#import "OFSHA1Hash.h" -#import "OFSHA224Hash.h" -#import "OFSHA256Hash.h" -#import "OFSHA384Hash.h" -#import "OFSHA512Hash.h" - -int _OFData_CryptoHashing_reference; - -@implementation OFData (CryptoHashing) -- (OFString *)of_cryptoHashWithClass: (Class )class OF_DIRECT -{ - void *pool = objc_autoreleasePoolPush(); - id hash = - [class cryptoHashWithAllowsSwappableMemory: true]; - size_t digestSize = [class digestSize]; - const unsigned char *digest; - char cString[digestSize * 2]; - - [hash updateWithBuffer: _items length: _count * _itemSize]; - digest = hash.digest; - - for (size_t i = 0; i < digestSize; i++) { - uint8_t high, low; - - high = digest[i] >> 4; - low = digest[i] & 0x0F; - - cString[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); - cString[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); - } - - objc_autoreleasePoolPop(pool); - - return [OFString stringWithCString: cString - encoding: OF_STRING_ENCODING_ASCII - length: digestSize * 2]; -} - -- (OFString *)stringByMD5Hashing -{ - return [self of_cryptoHashWithClass: [OFMD5Hash class]]; -} - -- (OFString *)stringByRIPEMD160Hashing -{ - return [self of_cryptoHashWithClass: [OFRIPEMD160Hash class]]; -} - -- (OFString *)stringBySHA1Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA1Hash class]]; -} - -- (OFString *)stringBySHA224Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA224Hash class]]; -} - -- (OFString *)stringBySHA256Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA256Hash class]]; -} - -- (OFString *)stringBySHA384Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA384Hash class]]; -} - -- (OFString *)stringBySHA512Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA512Hash class]]; -} -@end ADDED src/OFData+CryptographicHashing.h Index: src/OFData+CryptographicHashing.h ================================================================== --- src/OFData+CryptographicHashing.h +++ src/OFData+CryptographicHashing.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * 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 "OFData.h" + +OF_ASSUME_NONNULL_BEGIN + +@class OFString; + +#ifdef __cplusplus +extern "C" { +#endif +extern int _OFData_CryptographicHashing_reference; +#ifdef __cplusplus +} +#endif + +@interface OFData (CryptographicHashing) +/** + * @brief The MD5 hash of the data as a string. + */ +@property (readonly, nonatomic) OFString *stringByMD5Hashing; + +/** + * @brief The RIPEMD-160 hash of the data as a string. + */ +@property (readonly, nonatomic) OFString *stringByRIPEMD160Hashing; + +/** + * @brief The SHA-1 hash of the data as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA1Hashing; + +/** + * @brief The SHA-224 hash of the data as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA224Hashing; + +/** + * @brief The SHA-256 hash of the data as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA256Hashing; + +/** + * @brief The SHA-384 hash of the data as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA384Hashing; + +/** + * @brief The SHA-512 hash of the data as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA512Hashing; +@end + +OF_ASSUME_NONNULL_END ADDED src/OFData+CryptographicHashing.m Index: src/OFData+CryptographicHashing.m ================================================================== --- src/OFData+CryptographicHashing.m +++ src/OFData+CryptographicHashing.m @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * 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. + */ + +#include "config.h" + +#import "OFData+CryptographicHashing.h" +#import "OFString.h" +#import "OFCryptographicHash.h" +#import "OFMD5Hash.h" +#import "OFRIPEMD160Hash.h" +#import "OFSHA1Hash.h" +#import "OFSHA224Hash.h" +#import "OFSHA256Hash.h" +#import "OFSHA384Hash.h" +#import "OFSHA512Hash.h" + +int _OFData_CryptographicHashing_reference; + +@implementation OFData (CryptographicHashing) +static OFString * +stringByHashing(Class class, OFData *self) +{ + void *pool = objc_autoreleasePoolPush(); + id hash = + [class hashWithAllowsSwappableMemory: true]; + size_t digestSize = [class digestSize]; + const unsigned char *digest; + char cString[digestSize * 2]; + + [hash updateWithBuffer: self->_items + length: self->_count * self->_itemSize]; + digest = hash.digest; + + for (size_t i = 0; i < digestSize; i++) { + uint8_t high, low; + + high = digest[i] >> 4; + low = digest[i] & 0x0F; + + cString[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); + cString[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); + } + + objc_autoreleasePoolPop(pool); + + return [OFString stringWithCString: cString + encoding: OF_STRING_ENCODING_ASCII + length: digestSize * 2]; +} + +- (OFString *)stringByMD5Hashing +{ + return stringByHashing([OFMD5Hash class], self); +} + +- (OFString *)stringByRIPEMD160Hashing +{ + return stringByHashing([OFRIPEMD160Hash class], self); +} + +- (OFString *)stringBySHA1Hashing +{ + return stringByHashing([OFSHA1Hash class], self); +} + +- (OFString *)stringBySHA224Hashing +{ + return stringByHashing([OFSHA224Hash class], self); +} + +- (OFString *)stringBySHA256Hashing +{ + return stringByHashing([OFSHA256Hash class], self); +} + +- (OFString *)stringBySHA384Hashing +{ + return stringByHashing([OFSHA384Hash class], self); +} + +- (OFString *)stringBySHA512Hashing +{ + return stringByHashing([OFSHA512Hash class], self); +} +@end Index: src/OFData.h ================================================================== --- src/OFData.h +++ src/OFData.h @@ -330,7 +330,7 @@ OF_ASSUME_NONNULL_END #import "OFMutableData.h" #import "OFData+ASN1DERParsing.h" -#import "OFData+CryptoHashing.h" +#import "OFData+CryptographicHashing.h" #import "OFData+MessagePackParsing.h" Index: src/OFData.m ================================================================== --- src/OFData.m +++ src/OFData.m @@ -45,11 +45,11 @@ /* References for static linking */ void _references_to_categories_of_OFData(void) { _OFData_ASN1DERParsing_reference = 1; - _OFData_CryptoHashing_reference = 1; + _OFData_CryptographicHashing_reference = 1; _OFData_MessagePackParsing_reference = 1; } @implementation OFData @synthesize itemSize = _itemSize; Index: src/OFHMAC.h ================================================================== --- src/OFHMAC.h +++ src/OFHMAC.h @@ -12,11 +12,11 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" -#import "OFCryptoHash.h" +#import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFHMAC OFHMAC.h ObjFW/OFHMAC.h @@ -24,21 +24,21 @@ * @brief A class which provides methods to calculate an HMAC. */ OF_SUBCLASSING_RESTRICTED @interface OFHMAC: OFObject { - Class _hashClass; + Class _hashClass; bool _allowsSwappableMemory; - id _Nullable _outerHash, _innerHash; - id _Nullable _outerHashCopy, _innerHashCopy; + id _Nullable _outerHash, _innerHash; + id _Nullable _outerHashCopy, _innerHashCopy; bool _calculated; } /** * @brief The class for the cryptographic hash used by the HMAC. */ -@property (readonly, nonatomic) Class hashClass; +@property (readonly, nonatomic) Class hashClass; /** * @brief Whether data may be stored in swappable memory. */ @property (readonly, nonatomic) bool allowsSwappableMemory; @@ -62,11 +62,11 @@ * * @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 )hashClass ++ (instancetype)HMACWithHashClass: (Class )hashClass allowsSwappableMemory: (bool)allowsSwappableMemory; - (instancetype)init OF_UNAVAILABLE; /** @@ -75,11 +75,11 @@ * * @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 )hashClass +- (instancetype)initWithHashClass: (Class )hashClass allowsSwappableMemory: (bool)allowsSwappableMemory OF_DESIGNATED_INITIALIZER; /** * @brief Sets the key for the HMAC. Index: src/OFHMAC.m ================================================================== --- src/OFHMAC.m +++ src/OFHMAC.m @@ -23,11 +23,11 @@ @implementation OFHMAC @synthesize hashClass = _hashClass; @synthesize allowsSwappableMemory = _allowsSwappableMemory; -+ (instancetype)HMACWithHashClass: (Class )class ++ (instancetype)HMACWithHashClass: (Class )class allowsSwappableMemory: (bool)allowsSwappableMemory { return [[[self alloc] initWithHashClass: class allowsSwappableMemory: allowsSwappableMemory] autorelease]; @@ -36,11 +36,11 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithHashClass: (Class )class +- (instancetype)initWithHashClass: (Class )class allowsSwappableMemory: (bool)allowsSwappableMemory { self = [super init]; _hashClass = class; @@ -78,12 +78,12 @@ [_innerHashCopy release]; _outerHash = _innerHash = _outerHashCopy = _innerHashCopy = nil; @try { if (length > blockSize) { - id hash = [_hashClass - cryptoHashWithAllowsSwappableMemory: + id hash = [_hashClass + hashWithAllowsSwappableMemory: _allowsSwappableMemory]; [hash updateWithBuffer: key length: length]; length = hash.digestSize; if OF_UNLIKELY (length > blockSize) @@ -102,13 +102,13 @@ for (size_t i = 0; i < blockSize; i++) { outerKeyPadItems[i] ^= 0x5C; innerKeyPadItems[i] ^= 0x36; } - _outerHash = [[_hashClass cryptoHashWithAllowsSwappableMemory: + _outerHash = [[_hashClass hashWithAllowsSwappableMemory: _allowsSwappableMemory] retain]; - _innerHash = [[_hashClass cryptoHashWithAllowsSwappableMemory: + _innerHash = [[_hashClass hashWithAllowsSwappableMemory: _allowsSwappableMemory] retain]; [_outerHash updateWithBuffer: outerKeyPadItems length: blockSize]; [_innerHash updateWithBuffer: innerKeyPadItems Index: src/OFMD5Hash.h ================================================================== --- src/OFMD5Hash.h +++ src/OFMD5Hash.h @@ -11,11 +11,11 @@ * 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 "OFCryptoHash.h" +#import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; @@ -23,11 +23,11 @@ * @class OFMD5Hash OFMD5Hash.h ObjFW/OFMD5Hash.h * * @brief A class which provides methods to create an MD5 hash. */ OF_SUBCLASSING_RESTRICTED -@interface OFMD5Hash: OFObject +@interface OFMD5Hash: OFObject { OFSecureData *_iVarsData; struct of_md5_hash_ivars { uint32_t state[4]; uint64_t bits; Index: src/OFMD5Hash.m ================================================================== --- src/OFMD5Hash.m +++ src/OFMD5Hash.m @@ -133,11 +133,11 @@ + (size_t)blockSize { return BLOCK_SIZE; } -+ (instancetype)cryptoHashWithAllowsSwappableMemory: (bool)allowsSwappableMemory ++ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory { return [[[self alloc] initWithAllowsSwappableMemory: allowsSwappableMemory] autorelease]; } Index: src/OFRIPEMD160Hash.h ================================================================== --- src/OFRIPEMD160Hash.h +++ src/OFRIPEMD160Hash.h @@ -11,11 +11,11 @@ * 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 "OFCryptoHash.h" +#import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; @@ -23,11 +23,11 @@ * @class OFRIPEMD160Hash OFRIPEMD160Hash.h ObjFW/OFRIPEMD160Hash.h * * @brief A class which provides methods to create a RIPEMD-160 hash. */ OF_SUBCLASSING_RESTRICTED -@interface OFRIPEMD160Hash: OFObject +@interface OFRIPEMD160Hash: OFObject { OFSecureData *_iVarsData; struct of_ripemd160_hash_ivars { uint32_t state[5]; uint64_t bits; Index: src/OFRIPEMD160Hash.m ================================================================== --- src/OFRIPEMD160Hash.m +++ src/OFRIPEMD160Hash.m @@ -147,11 +147,11 @@ + (size_t)blockSize { return BLOCK_SIZE; } -+ (instancetype)cryptoHashWithAllowsSwappableMemory: (bool)allowsSwappableMemory ++ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory { return [[[self alloc] initWithAllowsSwappableMemory: allowsSwappableMemory] autorelease]; } Index: src/OFSHA1Hash.h ================================================================== --- src/OFSHA1Hash.h +++ src/OFSHA1Hash.h @@ -11,11 +11,11 @@ * 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 "OFCryptoHash.h" +#import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; @@ -23,11 +23,11 @@ * @class OFSHA1Hash OFSHA1Hash.h ObjFW/OFSHA1Hash.h * * @brief A class which provides methods to create an SHA-1 hash. */ OF_SUBCLASSING_RESTRICTED -@interface OFSHA1Hash: OFObject +@interface OFSHA1Hash: OFObject { OFSecureData *_iVarsData; struct of_sha1_hash_ivars { uint32_t state[5]; uint64_t bits; Index: src/OFSHA1Hash.m ================================================================== --- src/OFSHA1Hash.m +++ src/OFSHA1Hash.m @@ -107,11 +107,11 @@ + (size_t)blockSize { return BLOCK_SIZE; } -+ (instancetype)cryptoHashWithAllowsSwappableMemory: (bool)allowsSwappableMemory ++ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory { return [[[self alloc] initWithAllowsSwappableMemory: allowsSwappableMemory] autorelease]; } Index: src/OFSHA224Or256Hash.h ================================================================== --- src/OFSHA224Or256Hash.h +++ src/OFSHA224Or256Hash.h @@ -11,11 +11,11 @@ * 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 "OFCryptoHash.h" +#import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; @@ -22,11 +22,11 @@ /** * @class OFSHA224Or256Hash OFSHA224Or256Hash.h ObjFW/OFSHA224Or256Hash.h * * @brief A base class for SHA-224 and SHA-256. */ -@interface OFSHA224Or256Hash: OFObject +@interface OFSHA224Or256Hash: OFObject { @private OFSecureData *_iVarsData; @protected struct of_sha224_or_256_hash_ivars { Index: src/OFSHA224Or256Hash.m ================================================================== --- src/OFSHA224Or256Hash.m +++ src/OFSHA224Or256Hash.m @@ -127,11 +127,11 @@ + (size_t)blockSize { return BLOCK_SIZE; } -+ (instancetype)cryptoHashWithAllowsSwappableMemory: (bool)allowsSwappableMemory ++ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory { return [[[self alloc] initWithAllowsSwappableMemory: allowsSwappableMemory] autorelease]; } Index: src/OFSHA384Or512Hash.h ================================================================== --- src/OFSHA384Or512Hash.h +++ src/OFSHA384Or512Hash.h @@ -11,11 +11,11 @@ * 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 "OFCryptoHash.h" +#import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; @@ -22,11 +22,11 @@ /** * @class OFSHA384Or512Hash OFSHA384Or512Hash.h ObjFW/OFSHA384Or512Hash.h * * @brief A base class for SHA-384 and SHA-512. */ -@interface OFSHA384Or512Hash: OFObject +@interface OFSHA384Or512Hash: OFObject { @private OFSecureData *_iVarsData; @protected struct of_sha384_or_512_hash_ivars { Index: src/OFSHA384Or512Hash.m ================================================================== --- src/OFSHA384Or512Hash.m +++ src/OFSHA384Or512Hash.m @@ -138,11 +138,11 @@ + (size_t)blockSize { return BLOCK_SIZE; } -+ (instancetype)cryptoHashWithAllowsSwappableMemory: (bool)allowsSwappableMemory ++ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory { return [[[self alloc] initWithAllowsSwappableMemory: allowsSwappableMemory] autorelease]; } DELETED src/OFString+CryptoHashing.h Index: src/OFString+CryptoHashing.h ================================================================== --- src/OFString+CryptoHashing.h +++ src/OFString+CryptoHashing.h @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2008-2021 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * 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 "OFString.h" - -OF_ASSUME_NONNULL_BEGIN - -#ifdef __cplusplus -extern "C" { -#endif -extern int _OFString_CryptoHashing_reference; -#ifdef __cplusplus -} -#endif - -@interface OFString (CryptoHashing) -/** - * @brief The MD5 hash of the string as a string. - */ -@property (readonly, nonatomic) OFString *stringByMD5Hashing; - -/** - * @brief The RIPEMD-160 hash of the string as a string. - */ -@property (readonly, nonatomic) OFString *stringByRIPEMD160Hashing; - -/** - * @brief The SHA-1 hash of the string as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA1Hashing; - -/** - * @brief The SHA-224 hash of the string as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA224Hashing; - -/** - * @brief The SHA-256 hash of the string as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA256Hashing; - -/** - * @brief The SHA-384 hash of the string as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA384Hashing; - -/** - * @brief The SHA-512 hash of the string as a string. - */ -@property (readonly, nonatomic) OFString *stringBySHA512Hashing; -@end - -OF_ASSUME_NONNULL_END DELETED src/OFString+CryptoHashing.m Index: src/OFString+CryptoHashing.m ================================================================== --- src/OFString+CryptoHashing.m +++ src/OFString+CryptoHashing.m @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2008-2021 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * 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. - */ - -#include "config.h" - -#import "OFString.h" -#import "OFCryptoHash.h" -#import "OFMD5Hash.h" -#import "OFRIPEMD160Hash.h" -#import "OFSHA1Hash.h" -#import "OFSHA224Hash.h" -#import "OFSHA256Hash.h" -#import "OFSHA384Hash.h" -#import "OFSHA512Hash.h" - -int _OFString_CryptoHashing_reference; - -@implementation OFString (CryptoHashing) -- (OFString *)of_cryptoHashWithClass: (Class )class -{ - void *pool = objc_autoreleasePoolPush(); - id hash = [class - cryptoHashWithAllowsSwappableMemory: true]; - size_t digestSize = [class digestSize]; - const unsigned char *digest; - char cString[digestSize * 2]; - - [hash updateWithBuffer: self.UTF8String length: self.UTF8StringLength]; - digest = hash.digest; - - for (size_t i = 0; i < digestSize; i++) { - uint8_t high, low; - - high = digest[i] >> 4; - low = digest[i] & 0x0F; - - cString[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); - cString[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); - } - - objc_autoreleasePoolPop(pool); - - return [OFString stringWithCString: cString - encoding: OF_STRING_ENCODING_ASCII - length: digestSize * 2]; -} - -- (OFString *)stringByMD5Hashing -{ - return [self of_cryptoHashWithClass: [OFMD5Hash class]]; -} - -- (OFString *)stringByRIPEMD160Hashing -{ - return [self of_cryptoHashWithClass: [OFRIPEMD160Hash class]]; -} - -- (OFString *)stringBySHA1Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA1Hash class]]; -} - -- (OFString *)stringBySHA224Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA224Hash class]]; -} - -- (OFString *)stringBySHA256Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA256Hash class]]; -} - -- (OFString *)stringBySHA384Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA384Hash class]]; -} - -- (OFString *)stringBySHA512Hashing -{ - return [self of_cryptoHashWithClass: [OFSHA512Hash class]]; -} -@end ADDED src/OFString+CryptographicHashing.h Index: src/OFString+CryptographicHashing.h ================================================================== --- src/OFString+CryptographicHashing.h +++ src/OFString+CryptographicHashing.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * 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 "OFString.h" + +OF_ASSUME_NONNULL_BEGIN + +#ifdef __cplusplus +extern "C" { +#endif +extern int _OFString_CryptographicHashing_reference; +#ifdef __cplusplus +} +#endif + +@interface OFString (CryptographicHashing) +/** + * @brief The MD5 hash of the string as a string. + */ +@property (readonly, nonatomic) OFString *stringByMD5Hashing; + +/** + * @brief The RIPEMD-160 hash of the string as a string. + */ +@property (readonly, nonatomic) OFString *stringByRIPEMD160Hashing; + +/** + * @brief The SHA-1 hash of the string as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA1Hashing; + +/** + * @brief The SHA-224 hash of the string as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA224Hashing; + +/** + * @brief The SHA-256 hash of the string as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA256Hashing; + +/** + * @brief The SHA-384 hash of the string as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA384Hashing; + +/** + * @brief The SHA-512 hash of the string as a string. + */ +@property (readonly, nonatomic) OFString *stringBySHA512Hashing; +@end + +OF_ASSUME_NONNULL_END ADDED src/OFString+CryptographicHashing.m Index: src/OFString+CryptographicHashing.m ================================================================== --- src/OFString+CryptographicHashing.m +++ src/OFString+CryptographicHashing.m @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * 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. + */ + +#include "config.h" + +#import "OFString.h" +#import "OFCryptographicHash.h" +#import "OFMD5Hash.h" +#import "OFRIPEMD160Hash.h" +#import "OFSHA1Hash.h" +#import "OFSHA224Hash.h" +#import "OFSHA256Hash.h" +#import "OFSHA384Hash.h" +#import "OFSHA512Hash.h" + +int _OFString_CryptographicHashing_reference; + +@implementation OFString (CryptographicHashing) +static OFString * +stringByHashing(Class class, OFString *self) +{ + void *pool = objc_autoreleasePoolPush(); + id hash = + [class hashWithAllowsSwappableMemory: true]; + size_t digestSize = [class digestSize]; + const unsigned char *digest; + char cString[digestSize * 2]; + + [hash updateWithBuffer: self.UTF8String length: self.UTF8StringLength]; + digest = hash.digest; + + for (size_t i = 0; i < digestSize; i++) { + uint8_t high, low; + + high = digest[i] >> 4; + low = digest[i] & 0x0F; + + cString[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); + cString[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); + } + + objc_autoreleasePoolPop(pool); + + return [OFString stringWithCString: cString + encoding: OF_STRING_ENCODING_ASCII + length: digestSize * 2]; +} + +- (OFString *)stringByMD5Hashing +{ + return stringByHashing([OFMD5Hash class], self); +} + +- (OFString *)stringByRIPEMD160Hashing +{ + return stringByHashing([OFRIPEMD160Hash class], self); +} + +- (OFString *)stringBySHA1Hashing +{ + return stringByHashing([OFSHA1Hash class], self); +} + +- (OFString *)stringBySHA224Hashing +{ + return stringByHashing([OFSHA224Hash class], self); +} + +- (OFString *)stringBySHA256Hashing +{ + return stringByHashing([OFSHA256Hash class], self); +} + +- (OFString *)stringBySHA384Hashing +{ + return stringByHashing([OFSHA384Hash class], self); +} + +- (OFString *)stringBySHA512Hashing +{ + return stringByHashing([OFSHA512Hash class], self); +} +@end Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -1292,11 +1292,11 @@ OF_ASSUME_NONNULL_END #include "OFConstantString.h" #include "OFMutableString.h" #ifdef __OBJC__ -# import "OFString+CryptoHashing.h" +# import "OFString+CryptographicHashing.h" # import "OFString+JSONParsing.h" # ifdef OF_HAVE_FILES # import "OFString+PathAdditions.h" # endif # import "OFString+PropertyListParsing.h" Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -125,11 +125,11 @@ /* References for static linking */ void _references_to_categories_of_OFString(void) { - _OFString_CryptoHashing_reference = 1; + _OFString_CryptographicHashing_reference = 1; _OFString_JSONParsing_reference = 1; #ifdef OF_HAVE_FILES _OFString_PathAdditions_reference = 1; #endif _OFString_PropertyListParsing_reference = 1; Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -100,11 +100,11 @@ #ifdef OF_HAVE_SUBPROCESSES # import "OFSubprocess.h" #endif -#import "OFCryptoHash.h" +#import "OFCryptographicHash.h" #import "OFMD5Hash.h" #import "OFRIPEMD160Hash.h" #import "OFSHA1Hash.h" #import "OFSHA224Hash.h" #import "OFSHA256Hash.h" Index: tests/OFMD5HashTests.m ================================================================== --- tests/OFMD5HashTests.m +++ tests/OFMD5HashTests.m @@ -29,12 +29,12 @@ { void *pool = objc_autoreleasePoolPush(); OFMD5Hash *md5, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; - TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", - (md5 = [OFMD5Hash cryptoHashWithAllowsSwappableMemory: true])) + TEST(@"+[hashWithAllowsSwappableMemory:]", + (md5 = [OFMD5Hash hashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; [md5 updateWithBuffer: buf length: len]; Index: tests/OFRIPEMD160HashTests.m ================================================================== --- tests/OFRIPEMD160HashTests.m +++ tests/OFRIPEMD160HashTests.m @@ -30,13 +30,12 @@ { void *pool = objc_autoreleasePoolPush(); OFRIPEMD160Hash *rmd160, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; - TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", - (rmd160 = [OFRIPEMD160Hash - cryptoHashWithAllowsSwappableMemory: true])) + TEST(@"+[hashWithAllowsSwappableMemory:]", + (rmd160 = [OFRIPEMD160Hash hashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; [rmd160 updateWithBuffer: buf length: len]; Index: tests/OFSHA1HashTests.m ================================================================== --- tests/OFSHA1HashTests.m +++ tests/OFSHA1HashTests.m @@ -30,12 +30,12 @@ { void *pool = objc_autoreleasePoolPush(); OFSHA1Hash *sha1, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; - TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", - (sha1 = [OFSHA1Hash cryptoHashWithAllowsSwappableMemory: true])) + TEST(@"+[hashWithAllowsSwappableMemory:]", + (sha1 = [OFSHA1Hash hashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; [sha1 updateWithBuffer: buf length: len]; Index: tests/OFSHA224HashTests.m ================================================================== --- tests/OFSHA224HashTests.m +++ tests/OFSHA224HashTests.m @@ -30,12 +30,12 @@ { void *pool = objc_autoreleasePoolPush(); OFSHA224Hash *sha224, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; - TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", - (sha224 = [OFSHA224Hash cryptoHashWithAllowsSwappableMemory: true])) + TEST(@"+[hashWithAllowsSwappableMemory:]", + (sha224 = [OFSHA224Hash hashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; [sha224 updateWithBuffer: buf length: len]; Index: tests/OFSHA256HashTests.m ================================================================== --- tests/OFSHA256HashTests.m +++ tests/OFSHA256HashTests.m @@ -30,12 +30,12 @@ { void *pool = objc_autoreleasePoolPush(); OFSHA256Hash *sha256, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; - TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", - (sha256 = [OFSHA256Hash cryptoHashWithAllowsSwappableMemory: true])) + TEST(@"+[hashWithAllowsSwappableMemory:]", + (sha256 = [OFSHA256Hash hashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; [sha256 updateWithBuffer: buf length: len]; Index: tests/OFSHA384HashTests.m ================================================================== --- tests/OFSHA384HashTests.m +++ tests/OFSHA384HashTests.m @@ -31,12 +31,12 @@ { void *pool = objc_autoreleasePoolPush(); OFSHA384Hash *sha384, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; - TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", - (sha384 = [OFSHA384Hash cryptoHashWithAllowsSwappableMemory: true])) + TEST(@"+[hashWithAllowsSwappableMemory:]", + (sha384 = [OFSHA384Hash hashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[128]; size_t len = [f readIntoBuffer: buf length: 128]; [sha384 updateWithBuffer: buf length: len]; Index: tests/OFSHA512HashTests.m ================================================================== --- tests/OFSHA512HashTests.m +++ tests/OFSHA512HashTests.m @@ -32,12 +32,12 @@ { void *pool = objc_autoreleasePoolPush(); OFSHA512Hash *sha512, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; - TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", - (sha512 = [OFSHA512Hash cryptoHashWithAllowsSwappableMemory: true])) + TEST(@"+[hashWithAllowsSwappableMemory:]", + (sha512 = [OFSHA512Hash hashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[128]; size_t len = [f readIntoBuffer: buf length: 128]; [sha512 updateWithBuffer: buf length: len]; Index: utils/ofhash/OFHash.m ================================================================== --- utils/ofhash/OFHash.m +++ utils/ofhash/OFHash.m @@ -49,11 +49,11 @@ [OFApplication terminateWithStatus: 1]; } static void -printHash(OFString *algo, OFString *path, id hash) +printHash(OFString *algo, OFString *path, id hash) { const unsigned char *digest = hash.digest; size_t digestSize = hash.digestSize; [of_stdout writeFormat: @"%@ ", algo]; @@ -146,29 +146,24 @@ if (optionsParser.remainingArguments.count < 1) help(); if (calculateMD5) - MD5Hash = [OFMD5Hash cryptoHashWithAllowsSwappableMemory: true]; + MD5Hash = [OFMD5Hash hashWithAllowsSwappableMemory: true]; if (calculateRIPEMD160) RIPEMD160Hash = - [OFRIPEMD160Hash cryptoHashWithAllowsSwappableMemory: true]; + [OFRIPEMD160Hash hashWithAllowsSwappableMemory: true]; if (calculateSHA1) - SHA1Hash = - [OFSHA1Hash cryptoHashWithAllowsSwappableMemory: true]; + SHA1Hash = [OFSHA1Hash hashWithAllowsSwappableMemory: true]; if (calculateSHA224) - SHA224Hash = - [OFSHA224Hash cryptoHashWithAllowsSwappableMemory: true]; + SHA224Hash = [OFSHA224Hash hashWithAllowsSwappableMemory: true]; if (calculateSHA256) - SHA256Hash = - [OFSHA256Hash cryptoHashWithAllowsSwappableMemory: true]; + SHA256Hash = [OFSHA256Hash hashWithAllowsSwappableMemory: true]; if (calculateSHA384) - SHA384Hash = - [OFSHA384Hash cryptoHashWithAllowsSwappableMemory: true]; + SHA384Hash = [OFSHA384Hash hashWithAllowsSwappableMemory: true]; if (calculateSHA512) - SHA512Hash = - [OFSHA512Hash cryptoHashWithAllowsSwappableMemory: true]; + SHA512Hash = [OFSHA512Hash hashWithAllowsSwappableMemory: true]; for (OFString *path in optionsParser.remainingArguments) { void *pool = objc_autoreleasePoolPush(); OFStream *file;