Index: ObjFW.xcodeproj/project.pbxproj ================================================================== --- ObjFW.xcodeproj/project.pbxproj +++ ObjFW.xcodeproj/project.pbxproj @@ -168,11 +168,11 @@ 4B3D238C1337FC0D00DD29B8 /* OFArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B67995B1099E7C50041064A /* OFArray.m */; }; 4B3D238D1337FC0D00DD29B8 /* OFAutoreleasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B67995D1099E7C50041064A /* OFAutoreleasePool.m */; }; 4B3D238E1337FC0D00DD29B8 /* OFBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD86D811237A6C600ED9912 /* OFBlock.m */; }; 4B3D238F1337FC0D00DD29B8 /* OFConstantString.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0D812DF4225005C7A0C /* OFConstantString.m */; }; 4B3D23901337FC0D00DD29B8 /* OFDataArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6799611099E7C50041064A /* OFDataArray.m */; }; - 4B3D23911337FC0D00DD29B8 /* OFDataArray+Hashing.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE17ADA12FD746D002CEB0B /* OFDataArray+Hashing.m */; }; + 4B3D23911337FC0D00DD29B8 /* OFDataArray+CryptoHashing.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE17ADA12FD746D002CEB0B /* OFDataArray+CryptoHashing.m */; }; 4B3D23921337FC0D00DD29B8 /* OFDate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0DA12DF4225005C7A0C /* OFDate.m */; }; 4B3D23931337FC0D00DD29B8 /* OFDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6799631099E7C50041064A /* OFDictionary.m */; }; 4B3D23941337FC0D00DD29B8 /* OFEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B0108CA10EB8C9300631877 /* OFEnumerator.m */; }; 4B3D23961337FC0D00DD29B8 /* OFFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6799671099E7C50041064A /* OFFile.m */; }; 4B3D23981337FC0D00DD29B8 /* OFHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B99251012E0780000215DBE /* OFHTTPRequest.m */; }; @@ -187,11 +187,11 @@ 4B3D23A11337FC0D00DD29B8 /* OFSeekableStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B981CDF116F71DD00294DB7 /* OFSeekableStream.m */; }; 4B3D23A21337FC0D00DD29B8 /* OFSHA1Hash.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF1BCC511C9663F0025511F /* OFSHA1Hash.m */; }; 4B3D23A31337FC0D00DD29B8 /* OFStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B67997E1099E7C50041064A /* OFStream.m */; }; 4B3D23A51337FC0D00DD29B8 /* OFStreamSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BAF5F4A123460C900F4E111 /* OFStreamSocket.m */; }; 4B3D23A61337FC0D00DD29B8 /* OFString.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6799801099E7C50041064A /* OFString.m */; }; - 4B3D23A71337FC0D00DD29B8 /* OFString+Hashing.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF1BCC711C9663F0025511F /* OFString+Hashing.m */; }; + 4B3D23A71337FC0D00DD29B8 /* OFString+CryptoHashing.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF1BCC711C9663F0025511F /* OFString+CryptoHashing.m */; }; 4B3D23A81337FC0D00DD29B8 /* OFString+URLEncoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF1BCC911C9663F0025511F /* OFString+URLEncoding.m */; }; 4B3D23A91337FC0D00DD29B8 /* OFString+XMLEscaping.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF1BCCB11C9663F0025511F /* OFString+XMLEscaping.m */; }; 4B3D23AA1337FC0D00DD29B8 /* OFString+XMLUnescaping.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF1BCCD11C9663F0025511F /* OFString+XMLUnescaping.m */; }; 4B3D23AB1337FC0D00DD29B8 /* OFTCPSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6799821099E7C50041064A /* OFTCPSocket.m */; }; 4B3D23AC1337FC0D00DD29B8 /* OFThread.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6799841099E7C50041064A /* OFThread.m */; }; @@ -210,16 +210,16 @@ 4B3D23BE1337FC8300DD29B8 /* OFAutoreleasePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B67995C1099E7C50041064A /* OFAutoreleasePool.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23BF1337FC8300DD29B8 /* OFBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD86D801237A6C600ED9912 /* OFBlock.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23C01337FC8300DD29B8 /* OFCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAF5F46123460C900F4E111 /* OFCollection.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23C11337FC8300DD29B8 /* OFConstantString.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BE5F0D712DF4225005C7A0C /* OFConstantString.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23C21337FC8300DD29B8 /* OFDataArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6799601099E7C50041064A /* OFDataArray.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4B3D23C31337FC8300DD29B8 /* OFDataArray+Hashing.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BE17AD912FD746D002CEB0B /* OFDataArray+Hashing.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4B3D23C31337FC8300DD29B8 /* OFDataArray+CryptoHashing.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BE17AD912FD746D002CEB0B /* OFDataArray+CryptoHashing.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23C41337FC8300DD29B8 /* OFDate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BE5F0D912DF4225005C7A0C /* OFDate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23C51337FCB000DD29B8 /* OFDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6799621099E7C50041064A /* OFDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23C61337FCB000DD29B8 /* OFEnumerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B0108C910EB8C9300631877 /* OFEnumerator.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23C81337FCB000DD29B8 /* OFFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6799661099E7C50041064A /* OFFile.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4B3D23C91337FCB000DD29B8 /* OFHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF1BCC011C9663F0025511F /* OFHash.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4B3D23C91337FCB000DD29B8 /* OFCryptoHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF1BCC011C9663F0025511F /* OFCryptoHash.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23CA1337FCB000DD29B8 /* OFHTTPRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B99250F12E0780000215DBE /* OFHTTPRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23CB1337FCB000DD29B8 /* OFList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B67996C1099E7C50041064A /* OFList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23CC1337FCB000DD29B8 /* OFMD5Hash.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF1BCC211C9663F0025511F /* OFMD5Hash.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23CD1337FCB000DD29B8 /* OFMutableArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B67996F1099E7C50041064A /* OFMutableArray.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23CE1337FCB000DD29B8 /* OFMutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6799711099E7C50041064A /* OFMutableDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -230,11 +230,11 @@ 4B3D23D31337FCB000DD29B8 /* OFSeekableStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B981CDE116F71DD00294DB7 /* OFSeekableStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23D41337FCB000DD29B8 /* OFSHA1Hash.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF1BCC411C9663F0025511F /* OFSHA1Hash.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23D51337FCB000DD29B8 /* OFStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B67997D1099E7C50041064A /* OFStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23D71337FCB000DD29B8 /* OFStreamSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAF5F49123460C900F4E111 /* OFStreamSocket.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23D81337FCB000DD29B8 /* OFString.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B67997F1099E7C50041064A /* OFString.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4B3D23D91337FCB000DD29B8 /* OFString+Hashing.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF1BCC611C9663F0025511F /* OFString+Hashing.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4B3D23D91337FCB000DD29B8 /* OFString+CryptoHashing.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF1BCC611C9663F0025511F /* OFString+CryptoHashing.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23DA1337FCB000DD29B8 /* OFString+URLEncoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF1BCC811C9663F0025511F /* OFString+URLEncoding.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23DB1337FCB000DD29B8 /* OFString+XMLEscaping.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF1BCCA11C9663F0025511F /* OFString+XMLEscaping.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23DC1337FCB000DD29B8 /* OFString+XMLUnescaping.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF1BCCC11C9663F0025511F /* OFString+XMLUnescaping.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23DD1337FCB000DD29B8 /* OFTCPSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6799811099E7C50041064A /* OFTCPSocket.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23DE1337FCB000DD29B8 /* OFThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6799831099E7C50041064A /* OFThread.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -975,12 +975,12 @@ 4BD86D801237A6C600ED9912 /* OFBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBlock.h; path = src/OFBlock.h; sourceTree = SOURCE_ROOT; }; 4BD86D811237A6C600ED9912 /* OFBlock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBlock.m; path = src/OFBlock.m; sourceTree = SOURCE_ROOT; }; 4BD98C011338140B0048DD5B /* objfw-defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "objfw-defs.h"; path = "src/objfw-defs.h"; sourceTree = SOURCE_ROOT; }; 4BDF37B41338055600F9A81A /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = SOURCE_ROOT; }; 4BE17AD812FD744C002CEB0B /* foundation-compat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "foundation-compat.m"; path = "src/foundation-compat.m"; sourceTree = SOURCE_ROOT; }; - 4BE17AD912FD746D002CEB0B /* OFDataArray+Hashing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFDataArray+Hashing.h"; path = "src/OFDataArray+Hashing.h"; sourceTree = SOURCE_ROOT; }; - 4BE17ADA12FD746D002CEB0B /* OFDataArray+Hashing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFDataArray+Hashing.m"; path = "src/OFDataArray+Hashing.m"; sourceTree = SOURCE_ROOT; }; + 4BE17AD912FD746D002CEB0B /* OFDataArray+CryptoHashing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFDataArray+CryptoHashing.h"; path = "src/OFDataArray+CryptoHashing.h"; sourceTree = SOURCE_ROOT; }; + 4BE17ADA12FD746D002CEB0B /* OFDataArray+CryptoHashing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFDataArray+CryptoHashing.m"; path = "src/OFDataArray+CryptoHashing.m"; sourceTree = SOURCE_ROOT; }; 4BE52D1F17B990B4005958D1 /* OFZIPArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFZIPArchive.h; path = src/OFZIPArchive.h; sourceTree = ""; }; 4BE52D2017B990B4005958D1 /* OFZIPArchive.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFZIPArchive.m; path = src/OFZIPArchive.m; sourceTree = ""; }; 4BE52D2317B990DA005958D1 /* OFChecksumFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFChecksumFailedException.h; path = src/exceptions/OFChecksumFailedException.h; sourceTree = ""; }; 4BE52D2417B990DA005958D1 /* OFChecksumFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFChecksumFailedException.m; path = src/exceptions/OFChecksumFailedException.m; sourceTree = ""; }; 4BE5F0D712DF4225005C7A0C /* OFConstantString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConstantString.h; path = src/OFConstantString.h; sourceTree = SOURCE_ROOT; }; @@ -994,17 +994,17 @@ 4BEC83B819B7CB7100E4BB08 /* OFRIPEMD160Hash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRIPEMD160Hash.m; path = src/OFRIPEMD160Hash.m; sourceTree = ""; }; 4BEC83BB19B7CBDE00E4BB08 /* OFRIPEMD160HashTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRIPEMD160HashTests.m; path = tests/OFRIPEMD160HashTests.m; sourceTree = ""; }; 4BF0749512DFAFCA00A4ADD1 /* OFURLTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFURLTests.m; path = tests/OFURLTests.m; sourceTree = SOURCE_ROOT; }; 4BF171B11C9499F300F5B47B /* OFStdIOStream+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFStdIOStream+Private.h"; path = "src/OFStdIOStream+Private.h"; sourceTree = ""; }; 4BF1BCBF11C9663F0025511F /* objfw-defs.h.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "objfw-defs.h.in"; path = "src/objfw-defs.h.in"; sourceTree = ""; }; - 4BF1BCC011C9663F0025511F /* OFHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFHash.h; path = src/OFHash.h; sourceTree = ""; }; + 4BF1BCC011C9663F0025511F /* OFCryptoHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFCryptoHash.h; path = src/OFCryptoHash.h; sourceTree = ""; }; 4BF1BCC211C9663F0025511F /* OFMD5Hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMD5Hash.h; path = src/OFMD5Hash.h; sourceTree = ""; }; 4BF1BCC311C9663F0025511F /* OFMD5Hash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMD5Hash.m; path = src/OFMD5Hash.m; sourceTree = ""; }; 4BF1BCC411C9663F0025511F /* OFSHA1Hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSHA1Hash.h; path = src/OFSHA1Hash.h; sourceTree = ""; }; 4BF1BCC511C9663F0025511F /* OFSHA1Hash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSHA1Hash.m; path = src/OFSHA1Hash.m; sourceTree = ""; }; - 4BF1BCC611C9663F0025511F /* OFString+Hashing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFString+Hashing.h"; path = "src/OFString+Hashing.h"; sourceTree = ""; }; - 4BF1BCC711C9663F0025511F /* OFString+Hashing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFString+Hashing.m"; path = "src/OFString+Hashing.m"; sourceTree = ""; }; + 4BF1BCC611C9663F0025511F /* OFString+CryptoHashing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFString+CryptoHashing.h"; path = "src/OFString+CryptoHashing.h"; sourceTree = ""; }; + 4BF1BCC711C9663F0025511F /* OFString+CryptoHashing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFString+CryptoHashing.m"; path = "src/OFString+CryptoHashing.m"; sourceTree = ""; }; 4BF1BCC811C9663F0025511F /* OFString+URLEncoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFString+URLEncoding.h"; path = "src/OFString+URLEncoding.h"; sourceTree = ""; }; 4BF1BCC911C9663F0025511F /* OFString+URLEncoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFString+URLEncoding.m"; path = "src/OFString+URLEncoding.m"; sourceTree = ""; }; 4BF1BCCA11C9663F0025511F /* OFString+XMLEscaping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFString+XMLEscaping.h"; path = "src/OFString+XMLEscaping.h"; sourceTree = ""; }; 4BF1BCCB11C9663F0025511F /* OFString+XMLEscaping.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFString+XMLEscaping.m"; path = "src/OFString+XMLEscaping.m"; sourceTree = ""; }; 4BF1BCCC11C9663F0025511F /* OFString+XMLUnescaping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFString+XMLUnescaping.h"; path = "src/OFString+XMLUnescaping.h"; sourceTree = ""; }; @@ -1319,14 +1319,15 @@ 4BE5F0D812DF4225005C7A0C /* OFConstantString.m */, 4B45355113DCFE1E0037AB4D /* OFCountedSet.h */, 4B45355213DCFE1E0037AB4D /* OFCountedSet.m */, 4BA85BC4140ECCE800E91D51 /* OFCountedSet_hashtable.h */, 4BA85BC5140ECCE800E91D51 /* OFCountedSet_hashtable.m */, + 4BF1BCC011C9663F0025511F /* OFCryptoHash.h */, 4B6799601099E7C50041064A /* OFDataArray.h */, 4B6799611099E7C50041064A /* OFDataArray.m */, - 4BE17AD912FD746D002CEB0B /* OFDataArray+Hashing.h */, - 4BE17ADA12FD746D002CEB0B /* OFDataArray+Hashing.m */, + 4BE17AD912FD746D002CEB0B /* OFDataArray+CryptoHashing.h */, + 4BE17ADA12FD746D002CEB0B /* OFDataArray+CryptoHashing.m */, 4B879A89177231F000EBCEA4 /* OFDataArray+MessagePackValue.h */, 4B879A8A177231F000EBCEA4 /* OFDataArray+MessagePackValue.m */, 4BE5F0D912DF4225005C7A0C /* OFDate.h */, 4BE5F0DA12DF4225005C7A0C /* OFDate.m */, 4BC1761F1D04963000C32718 /* OFDeflate64Stream.h */, @@ -1343,11 +1344,10 @@ 4B6799671099E7C50041064A /* OFFile.m */, 4B2C72881B888B6900717583 /* OFFileManager.h */, 4B2C72891B888B6900717583 /* OFFileManager.m */, 4BD1125E1CCB739A0076FDB9 /* OFGZIPStream.h */, 4BD1125F1CCB739A0076FDB9 /* OFGZIPStream.m */, - 4BF1BCC011C9663F0025511F /* OFHash.h */, 4BB4B53F16775FF4002A2DCE /* OFHTTPClient.h */, 4BB4B54016775FF4002A2DCE /* OFHTTPClient.m */, 4B99250F12E0780000215DBE /* OFHTTPRequest.h */, 4B99251012E0780000215DBE /* OFHTTPRequest.m */, 4B7161AB17A6FC7600B74970 /* OFHTTPResponse.h */, @@ -1459,12 +1459,12 @@ 4B6C8AD217BD5C2E00B194F2 /* OFStream+Private.h */, 4BAF5F49123460C900F4E111 /* OFStreamSocket.h */, 4BAF5F4A123460C900F4E111 /* OFStreamSocket.m */, 4B67997F1099E7C50041064A /* OFString.h */, 4B6799801099E7C50041064A /* OFString.m */, - 4BF1BCC611C9663F0025511F /* OFString+Hashing.h */, - 4BF1BCC711C9663F0025511F /* OFString+Hashing.m */, + 4BF1BCC611C9663F0025511F /* OFString+CryptoHashing.h */, + 4BF1BCC711C9663F0025511F /* OFString+CryptoHashing.m */, 4B5CF8F614940BD2007AA324 /* OFString+JSONValue.h */, 4B5CF8F714940BD2007AA324 /* OFString+JSONValue.m */, 4BB25E84139C388A00F574EA /* OFString+Serialization.h */, 4BB25E85139C388A00F574EA /* OFString+Serialization.m */, 4BF1BCC811C9663F0025511F /* OFString+URLEncoding.h */, @@ -1683,12 +1683,13 @@ 4B3D23BF1337FC8300DD29B8 /* OFBlock.h in Headers */, 4B3D23C01337FC8300DD29B8 /* OFCollection.h in Headers */, 4B674400163C395900EB1E59 /* OFCondition.h in Headers */, 4B3D23C11337FC8300DD29B8 /* OFConstantString.h in Headers */, 4B45355313DCFE1E0037AB4D /* OFCountedSet.h in Headers */, + 4B3D23C91337FCB000DD29B8 /* OFCryptoHash.h in Headers */, 4B3D23C21337FC8300DD29B8 /* OFDataArray.h in Headers */, - 4B3D23C31337FC8300DD29B8 /* OFDataArray+Hashing.h in Headers */, + 4B3D23C31337FC8300DD29B8 /* OFDataArray+CryptoHashing.h in Headers */, 4B879A8C177231F000EBCEA4 /* OFDataArray+MessagePackValue.h in Headers */, 4B3D23C41337FC8300DD29B8 /* OFDate.h in Headers */, 4BC1762D1D04963000C32718 /* OFDeflateStream.h in Headers */, 4BC1762B1D04963000C32718 /* OFDeflate64Stream.h in Headers */, 4B3D23C51337FCB000DD29B8 /* OFDictionary.h in Headers */, @@ -1695,11 +1696,10 @@ 4B3D23C61337FCB000DD29B8 /* OFEnumerator.h in Headers */, 4B17FF74133A2AAB003E6DCD /* OFException.h in Headers */, 4B3D23C81337FCB000DD29B8 /* OFFile.h in Headers */, 4B2C728C1B888B8700717583 /* OFFileManager.h in Headers */, 4BD112621CCB73A90076FDB9 /* OFGZIPStream.h in Headers */, - 4B3D23C91337FCB000DD29B8 /* OFHash.h in Headers */, 4BB4B54416775FF4002A2DCE /* OFHTTPClient.h in Headers */, 4B3D23CA1337FCB000DD29B8 /* OFHTTPRequest.h in Headers */, 4B7161AD17A6FC7600B74970 /* OFHTTPResponse.h in Headers */, 4BB4B54616775FF4002A2DCE /* OFHTTPServer.h in Headers */, 4B06855318B2AD3800FC731A /* OFINICategory.h in Headers */, @@ -1744,11 +1744,11 @@ 4B141BA415FCDF74000C21A8 /* OFSortedList.h in Headers */, 4B0256E4172B60400062B5F1 /* OFStdIOStream.h in Headers */, 4B3D23D51337FCB000DD29B8 /* OFStream.h in Headers */, 4B3D23D71337FCB000DD29B8 /* OFStreamSocket.h in Headers */, 4B3D23D81337FCB000DD29B8 /* OFString.h in Headers */, - 4B3D23D91337FCB000DD29B8 /* OFString+Hashing.h in Headers */, + 4B3D23D91337FCB000DD29B8 /* OFString+CryptoHashing.h in Headers */, 4B5CF8F914940BD2007AA324 /* OFString+JSONValue.h in Headers */, 4BB25E8A139C388A00F574EA /* OFString+Serialization.h in Headers */, 4B3D23DA1337FCB000DD29B8 /* OFString+URLEncoding.h in Headers */, 4B3D23DB1337FCB000DD29B8 /* OFString+XMLEscaping.h in Headers */, 4B3D23DC1337FCB000DD29B8 /* OFString+XMLUnescaping.h in Headers */, @@ -2074,11 +2074,11 @@ 4B674401163C395900EB1E59 /* OFCondition.m in Sources */, 4B3D238F1337FC0D00DD29B8 /* OFConstantString.m in Sources */, 4B45355413DCFE1E0037AB4D /* OFCountedSet.m in Sources */, 4BA85BCB140ECCE800E91D51 /* OFCountedSet_hashtable.m in Sources */, 4B3D23901337FC0D00DD29B8 /* OFDataArray.m in Sources */, - 4B3D23911337FC0D00DD29B8 /* OFDataArray+Hashing.m in Sources */, + 4B3D23911337FC0D00DD29B8 /* OFDataArray+CryptoHashing.m in Sources */, 4B879A8D177231F000EBCEA4 /* OFDataArray+MessagePackValue.m in Sources */, 4B3D23921337FC0D00DD29B8 /* OFDate.m in Sources */, 4BC1762C1D04963000C32718 /* OFDeflate64Stream.m in Sources */, 4BC1762E1D04963000C32718 /* OFDeflateStream.m in Sources */, 4B3D23931337FC0D00DD29B8 /* OFDictionary.m in Sources */, @@ -2136,11 +2136,11 @@ 4B141BA515FCDF74000C21A8 /* OFSortedList.m in Sources */, 4B0256E5172B60400062B5F1 /* OFStdIOStream.m in Sources */, 4B3D23A31337FC0D00DD29B8 /* OFStream.m in Sources */, 4B3D23A51337FC0D00DD29B8 /* OFStreamSocket.m in Sources */, 4B3D23A61337FC0D00DD29B8 /* OFString.m in Sources */, - 4B3D23A71337FC0D00DD29B8 /* OFString+Hashing.m in Sources */, + 4B3D23A71337FC0D00DD29B8 /* OFString+CryptoHashing.m in Sources */, 4B5CF8FA14940BD2007AA324 /* OFString+JSONValue.m in Sources */, 4BB25E8B139C388A00F574EA /* OFString+Serialization.m in Sources */, 4B3D23A81337FC0D00DD29B8 /* OFString+URLEncoding.m in Sources */, 4B3D23A91337FC0D00DD29B8 /* OFString+XMLEscaping.m in Sources */, 4B3D23AA1337FC0D00DD29B8 /* OFString+XMLUnescaping.m in Sources */, Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -16,11 +16,11 @@ OFBigDataArray.m \ OFBlock.m \ OFConstantString.m \ OFCountedSet.m \ OFDataArray.m \ - OFDataArray+Hashing.m \ + OFDataArray+CryptoHashing.m \ OFDataArray+MessagePackValue.m \ OFDate.m \ OFDeflateStream.m \ OFDeflate64Stream.m \ OFDictionary.m \ @@ -56,11 +56,11 @@ OFSortedList.m \ OFStdIOStream.m \ ${OFSTDIOSTREAM_WIN32CONSOLE_M} \ OFStream.m \ OFString.m \ - OFString+Hashing.m \ + OFString+CryptoHashing.m \ OFString+JSONValue.m \ OFString+Serialization.m \ OFString+URLEncoding.m \ OFString+XMLEscaping.m \ OFString+XMLUnescaping.m \ @@ -113,11 +113,11 @@ OFThreadPool.m \ threading.m INCLUDES := ${SRCS:.m=.h} \ OFCollection.h \ - OFHash.h \ + OFCryptoHash.h \ OFJSONRepresentation.h \ OFKeyValueCoding.h \ OFLocking.h \ OFMessagePackRepresentation.h \ OFSerialization.h \ ADDED src/OFCryptoHash.h Index: src/OFCryptoHash.h ================================================================== --- src/OFCryptoHash.h +++ src/OFCryptoHash.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 + * 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. + */ +@protocol OFCryptoHash +/*! + * A boolean whether the hash has already been calculated. + */ +@property (readonly, getter=isCalculated) bool calculated; + +/*! + * @brief Creates a new cryptographic hash. + * + * @return A new autoreleased OFCryptoHash + */ ++ (instancetype)cryptoHash; + +/*! + * @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 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 Returns 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. + * + * @return A buffer containing the hash + */ +- (const uint8_t*)digest OF_RETURNS_INNER_POINTER; + +/*! + * @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/OFDataArray+CryptoHashing.h Index: src/OFDataArray+CryptoHashing.h ================================================================== --- src/OFDataArray+CryptoHashing.h +++ src/OFDataArray+CryptoHashing.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 + * 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 "OFDataArray.h" + +OF_ASSUME_NONNULL_BEGIN + +@class OFString; + +#ifdef __cplusplus +extern "C" { +#endif +extern int _OFDataArray_CryptoHashing_reference; +#ifdef __cplusplus +} +#endif + +@interface OFDataArray (CryptoHashing) +/*! + * @brief Returns the MD5 hash of the data array as an autoreleased OFString. + * + * @return The MD5 hash of the data array as an autoreleased OFString + */ +- (OFString*)MD5Hash; + +/*! + * @brief Returns the RIPEMD-160 hash of the data array as an autoreleased + * OFString. + * + * @return The RIPEMD-160 hash of the data array as an autoreleased OFString + */ +- (OFString*)RIPEMD160Hash; + +/*! + * @brief Returns the SHA-1 hash of the data array as an autoreleased OFString. + * + * @return The SHA-1 hash of the data array as an autoreleased OFString + */ +- (OFString*)SHA1Hash; + +/*! + * @brief Returns the SHA-224 hash of the data array as an autoreleased + * OFString. + * + * @return The SHA-224 hash of the data array as an autoreleased OFString + */ +- (OFString*)SHA224Hash; + +/*! + * @brief Returns the SHA-256 hash of the data array as an autoreleased + * OFString. + * + * @return The SHA-256 hash of the data array as an autoreleased OFString + */ +- (OFString*)SHA256Hash; + +/*! + * @brief Returns the SHA-384 hash of the data array as an autoreleased + * OFString. + * + * @return The SHA-384 hash of the data array as an autoreleased OFString + */ +- (OFString*)SHA384Hash; + +/*! + * @brief Returns the SHA-512 hash of the data array as an autoreleased + * OFString. + * + * @return The SHA-512 hash of the data array as an autoreleased OFString + */ +- (OFString*)SHA512Hash; +@end + +OF_ASSUME_NONNULL_END ADDED src/OFDataArray+CryptoHashing.m Index: src/OFDataArray+CryptoHashing.m ================================================================== --- src/OFDataArray+CryptoHashing.m +++ src/OFDataArray+CryptoHashing.m @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 + * 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 "OFDataArray.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 _OFDataArray_CryptoHashing_reference; + +@implementation OFDataArray (Hashing) +- (OFString*)OF_cryptoHashWithClass: (Class )class +{ + void *pool = objc_autoreleasePoolPush(); + id hash = [class cryptoHash]; + size_t digestSize = [class digestSize]; + const uint8_t *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*)MD5Hash +{ + return [self OF_cryptoHashWithClass: [OFMD5Hash class]]; +} + +- (OFString*)RIPEMD160Hash +{ + return [self OF_cryptoHashWithClass: [OFRIPEMD160Hash class]]; +} + +- (OFString*)SHA1Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA1Hash class]]; +} + +- (OFString*)SHA224Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA224Hash class]]; +} + +- (OFString*)SHA256Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA256Hash class]]; +} + +- (OFString*)SHA384Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA384Hash class]]; +} + +- (OFString*)SHA512Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA512Hash class]]; +} +@end DELETED src/OFDataArray+Hashing.h Index: src/OFDataArray+Hashing.h ================================================================== --- src/OFDataArray+Hashing.h +++ src/OFDataArray+Hashing.h @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 - * 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 "OFDataArray.h" - -OF_ASSUME_NONNULL_BEGIN - -@class OFString; - -#ifdef __cplusplus -extern "C" { -#endif -extern int _OFDataArray_Hashing_reference; -#ifdef __cplusplus -} -#endif - -@interface OFDataArray (Hashing) -/*! - * @brief Returns the MD5 hash of the data array as an autoreleased OFString. - * - * @return The MD5 hash of the data array as an autoreleased OFString - */ -- (OFString*)MD5Hash; - -/*! - * @brief Returns the RIPEMD-160 hash of the data array as an autoreleased - * OFString. - * - * @return The RIPEMD-160 hash of the data array as an autoreleased OFString - */ -- (OFString*)RIPEMD160Hash; - -/*! - * @brief Returns the SHA-1 hash of the data array as an autoreleased OFString. - * - * @return The SHA-1 hash of the data array as an autoreleased OFString - */ -- (OFString*)SHA1Hash; - -/*! - * @brief Returns the SHA-224 hash of the data array as an autoreleased - * OFString. - * - * @return The SHA-224 hash of the data array as an autoreleased OFString - */ -- (OFString*)SHA224Hash; - -/*! - * @brief Returns the SHA-256 hash of the data array as an autoreleased - * OFString. - * - * @return The SHA-256 hash of the data array as an autoreleased OFString - */ -- (OFString*)SHA256Hash; - -/*! - * @brief Returns the SHA-384 hash of the data array as an autoreleased - * OFString. - * - * @return The SHA-384 hash of the data array as an autoreleased OFString - */ -- (OFString*)SHA384Hash; - -/*! - * @brief Returns the SHA-512 hash of the data array as an autoreleased - * OFString. - * - * @return The SHA-512 hash of the data array as an autoreleased OFString - */ -- (OFString*)SHA512Hash; -@end - -OF_ASSUME_NONNULL_END DELETED src/OFDataArray+Hashing.m Index: src/OFDataArray+Hashing.m ================================================================== --- src/OFDataArray+Hashing.m +++ src/OFDataArray+Hashing.m @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 - * 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 "OFDataArray.h" -#import "OFString.h" -#import "OFHash.h" -#import "OFMD5Hash.h" -#import "OFRIPEMD160Hash.h" -#import "OFSHA1Hash.h" -#import "OFSHA224Hash.h" -#import "OFSHA256Hash.h" -#import "OFSHA384Hash.h" -#import "OFSHA512Hash.h" - -int _OFDataArray_Hashing_reference; - -@implementation OFDataArray (Hashing) -- (OFString*)OF_hashAsStringWithHash: (Class )hashClass -{ - void *pool = objc_autoreleasePoolPush(); - id hash = [hashClass hash]; - size_t digestSize = [hashClass digestSize]; - const uint8_t *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*)MD5Hash -{ - return [self OF_hashAsStringWithHash: [OFMD5Hash class]]; -} - -- (OFString*)RIPEMD160Hash -{ - return [self OF_hashAsStringWithHash: [OFRIPEMD160Hash class]]; -} - -- (OFString*)SHA1Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA1Hash class]]; -} - -- (OFString*)SHA224Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA224Hash class]]; -} - -- (OFString*)SHA256Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA256Hash class]]; -} - -- (OFString*)SHA384Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA384Hash class]]; -} - -- (OFString*)SHA512Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA512Hash class]]; -} -@end Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -320,7 +320,7 @@ #endif @end OF_ASSUME_NONNULL_END -#import "OFDataArray+Hashing.h" +#import "OFDataArray+CryptoHashing.h" #import "OFDataArray+MessagePackValue.h" Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -51,12 +51,12 @@ /* References for static linking */ void _references_to_categories_of_OFDataArray(void) { + _OFDataArray_CryptoHashing_reference = 1; _OFDataArray_MessagePackValue_reference = 1; - _OFDataArray_Hashing_reference = 1; } @implementation OFDataArray @synthesize itemSize = _itemSize; DELETED src/OFHash.h Index: src/OFHash.h ================================================================== --- src/OFHash.h +++ src/OFHash.h @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 - * 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 OFHash OFHash.h ObjFW/OFHash.h - * - * @brief A protocol for classes providing hash functions. - */ -@protocol OFHash -/*! - * A boolean whether the hash has already been calculated. - */ -@property (readonly, getter=isCalculated) bool calculated; - -/*! - * @brief Creates a new hash. - * - * @return A new autoreleased OFHash - */ -+ (instancetype)hash; - -/*! - * @brief Returns the digest size of the hash, in bytes. - * - * @return The digest size of the hash, in bytes - */ -+ (size_t)digestSize; - -/*! - * @brief Returns the block size of the hash, in bytes. - * - * @return The block size of the hash, in bytes - */ -+ (size_t)blockSize; - -/*! - * @brief Adds a buffer to the 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 Returns a buffer containing the hash. - * - * The size of the buffer depends on the hash used. The buffer is part of the - * receiver's memory pool. - * - * @return A buffer containing the hash - */ -- (const uint8_t*)digest OF_RETURNS_INNER_POINTER; - -/*! - * @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 Index: src/OFMD5Hash.h ================================================================== --- src/OFMD5Hash.h +++ src/OFMD5Hash.h @@ -12,20 +12,20 @@ * 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 "OFHash.h" +#import "OFCryptoHash.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFMD5Hash OFMD5Hash.h ObjFW/OFMD5Hash.h * * @brief A class which provides functions to create an MD5 hash. */ -@interface OFMD5Hash: OFObject +@interface OFMD5Hash: OFObject { uint32_t _state[4]; uint64_t _bits; union { uint8_t bytes[64]; Index: src/OFMD5Hash.m ================================================================== --- src/OFMD5Hash.m +++ src/OFMD5Hash.m @@ -123,11 +123,11 @@ + (size_t)blockSize { return 64; } -+ (instancetype)hash ++ (instancetype)cryptoHash { return [[[self alloc] init] autorelease]; } - init @@ -152,11 +152,11 @@ { const uint8_t *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException - exceptionWithHash: self]; + exceptionWithObject: self]; _bits += (length * 8); while (length > 0) { size_t min = 64 - _bufferLength; Index: src/OFRIPEMD160Hash.h ================================================================== --- src/OFRIPEMD160Hash.h +++ src/OFRIPEMD160Hash.h @@ -12,20 +12,20 @@ * 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 "OFHash.h" +#import "OFCryptoHash.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFRIPEMD160Hash OFRIPEMD160Hash.h ObjFW/OFRIPEMD160Hash.h * * @brief A class which provides functions to create a RIPEMD-160 hash. */ -@interface OFRIPEMD160Hash: OFObject +@interface OFRIPEMD160Hash: OFObject { uint32_t _state[5]; uint64_t _bits; union { uint8_t bytes[64]; Index: src/OFRIPEMD160Hash.m ================================================================== --- src/OFRIPEMD160Hash.m +++ src/OFRIPEMD160Hash.m @@ -137,11 +137,11 @@ + (size_t)blockSize { return 64; } -+ (instancetype)hash ++ (instancetype)cryptoHash { return [[[self alloc] init] autorelease]; } - init @@ -167,11 +167,11 @@ { const uint8_t *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException - exceptionWithHash: self]; + exceptionWithObject: self]; _bits += (length * 8); while (length > 0) { size_t min = 64 - _bufferLength; Index: src/OFSHA1Hash.h ================================================================== --- src/OFSHA1Hash.h +++ src/OFSHA1Hash.h @@ -12,20 +12,20 @@ * 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 "OFHash.h" +#import "OFCryptoHash.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFSHA1Hash OFSHA1Hash.h ObjFW/OFSHA1Hash.h * * @brief A class which provides functions to create an SHA-1 hash. */ -@interface OFSHA1Hash: OFObject +@interface OFSHA1Hash: OFObject { uint32_t _state[5]; uint64_t _bits; union { uint8_t bytes[64]; Index: src/OFSHA1Hash.m ================================================================== --- src/OFSHA1Hash.m +++ src/OFSHA1Hash.m @@ -97,11 +97,11 @@ + (size_t)blockSize { return 64; } -+ (instancetype)hash ++ (instancetype)cryptoHash { return [[[self alloc] init] autorelease]; } - init @@ -127,11 +127,11 @@ { const uint8_t *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException - exceptionWithHash: self]; + exceptionWithObject: self]; _bits += (length * 8); while (length > 0) { size_t min = 64 - _bufferLength; Index: src/OFSHA224Or256Hash.h ================================================================== --- src/OFSHA224Or256Hash.h +++ src/OFSHA224Or256Hash.h @@ -12,20 +12,20 @@ * 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 "OFHash.h" +#import "OFCryptoHash.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFSHA224Or256Hash OFSHA224Or256Hash.h ObjFW/OFSHA224Or256Hash.h * * @brief A base class for SHA-224 and SHA-256. */ -@interface OFSHA224Or256Hash: OFObject +@interface OFSHA224Or256Hash: OFObject { uint32_t _state[8]; uint64_t _bits; union { uint8_t bytes[64]; Index: src/OFSHA224Or256Hash.m ================================================================== --- src/OFSHA224Or256Hash.m +++ src/OFSHA224Or256Hash.m @@ -14,10 +14,11 @@ * file. */ #include "config.h" +#include #include #import "OFSHA224Or256Hash.h" #import "OFHashAlreadyCalculatedException.h" @@ -118,20 +119,30 @@ + (size_t)blockSize { return 64; } -+ (instancetype)hash ++ (instancetype)cryptoHash { return [[[self alloc] init] autorelease]; } - init { self = [super init]; - [self OF_resetState]; + @try { + if ([self class] == [OFSHA224Or256Hash class]) { + [self doesNotRecognizeSelector: _cmd]; + abort(); + } + + [self OF_resetState]; + } @catch (id e) { + [self release]; + @throw e; + } return self; } - (void)updateWithBuffer: (const void*)buffer_ @@ -139,11 +150,11 @@ { const uint8_t *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException - exceptionWithHash: self]; + exceptionWithObject: self]; _bits += (length * 8); while (length > 0) { size_t min = 64 - _bufferLength; Index: src/OFSHA384Or512Hash.h ================================================================== --- src/OFSHA384Or512Hash.h +++ src/OFSHA384Or512Hash.h @@ -12,20 +12,20 @@ * 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 "OFHash.h" +#import "OFCryptoHash.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFSHA384Or512Hash OFSHA384Or512Hash.h ObjFW/OFSHA384Or512Hash.h * * @brief A base class for SHA-384 and SHA-512. */ -@interface OFSHA384Or512Hash: OFObject +@interface OFSHA384Or512Hash: OFObject { uint64_t _state[8]; uint64_t _bits[2]; union { uint8_t bytes[128]; Index: src/OFSHA384Or512Hash.m ================================================================== --- src/OFSHA384Or512Hash.m +++ src/OFSHA384Or512Hash.m @@ -14,10 +14,11 @@ * file. */ #include "config.h" +#include #include #import "OFSHA384Or512Hash.h" #import "OFHashAlreadyCalculatedException.h" @@ -129,20 +130,30 @@ + (size_t)blockSize { return 128; } -+ (instancetype)hash ++ (instancetype)cryptoHash { return [[[self alloc] init] autorelease]; } - init { self = [super init]; - [self OF_resetState]; + @try { + if ([self class] == [OFSHA384Or512Hash class]) { + [self doesNotRecognizeSelector: _cmd]; + abort(); + } + + [self OF_resetState]; + } @catch (id e) { + [self release]; + @throw e; + } return self; } - (void)updateWithBuffer: (const void*)buffer_ @@ -150,11 +161,11 @@ { const uint8_t *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException - exceptionWithHash: self]; + exceptionWithObject: self]; if (UINT64_MAX - _bits[0] < (length * 8)) _bits[1]++; _bits[0] += (length * 8); ADDED src/OFString+CryptoHashing.h Index: src/OFString+CryptoHashing.h ================================================================== --- src/OFString+CryptoHashing.h +++ src/OFString+CryptoHashing.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 + * 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 Returns the MD5 hash of the string as an autoreleased OFString. + * + * @return The MD5 hash of the string as an autoreleased OFString + */ +- (OFString*)MD5Hash; + +/*! + * @brief Returns the RIPEMD-160 hash of the string as an autoreleased OFString. + * + * @return The RIPEMD-160 hash of the string as an autoreleased OFString + */ +- (OFString*)RIPEMD160Hash; + +/*! + * @brief Returns the SHA-1 hash of the string as an autoreleased OFString. + * + * @return The SHA-1 hash of the string as an autoreleased OFString + */ +- (OFString*)SHA1Hash; + +/*! + * @brief Returns the SHA-224 hash of the string as an autoreleased OFString. + * + * @return The SHA-224 hash of the string as an autoreleased OFString + */ +- (OFString*)SHA224Hash; + +/*! + * @brief Returns the SHA-256 hash of the string as an autoreleased OFString. + * + * @return The SHA-256 hash of the string as an autoreleased OFString + */ +- (OFString*)SHA256Hash; + +/*! + * @brief Returns the SHA-384 hash of the string as an autoreleased OFString. + * + * @return The SHA-384 hash of the string as an autoreleased OFString + */ +- (OFString*)SHA384Hash; + +/*! + * @brief Returns the SHA-512 hash of the string as an autoreleased OFString. + * + * @return The SHA-512 hash of the string as an autoreleased OFString + */ +- (OFString*)SHA512Hash; +@end + +OF_ASSUME_NONNULL_END ADDED src/OFString+CryptoHashing.m Index: src/OFString+CryptoHashing.m ================================================================== --- src/OFString+CryptoHashing.m +++ src/OFString+CryptoHashing.m @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 + * 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 cryptoHash]; + size_t digestSize = [class digestSize]; + const uint8_t *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*)MD5Hash +{ + return [self OF_cryptoHashWithClass: [OFMD5Hash class]]; +} + +- (OFString*)RIPEMD160Hash +{ + return [self OF_cryptoHashWithClass: [OFRIPEMD160Hash class]]; +} + +- (OFString*)SHA1Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA1Hash class]]; +} + +- (OFString*)SHA224Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA224Hash class]]; +} + +- (OFString*)SHA256Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA256Hash class]]; +} + +- (OFString*)SHA384Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA384Hash class]]; +} + +- (OFString*)SHA512Hash +{ + return [self OF_cryptoHashWithClass: [OFSHA512Hash class]]; +} +@end DELETED src/OFString+Hashing.h Index: src/OFString+Hashing.h ================================================================== --- src/OFString+Hashing.h +++ src/OFString+Hashing.h @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 - * 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_Hashing_reference; -#ifdef __cplusplus -} -#endif - -@interface OFString (Hashing) -/*! - * @brief Returns the MD5 hash of the string as an autoreleased OFString. - * - * @return The MD5 hash of the string as an autoreleased OFString - */ -- (OFString*)MD5Hash; - -/*! - * @brief Returns the RIPEMD-160 hash of the string as an autoreleased OFString. - * - * @return The RIPEMD-160 hash of the string as an autoreleased OFString - */ -- (OFString*)RIPEMD160Hash; - -/*! - * @brief Returns the SHA-1 hash of the string as an autoreleased OFString. - * - * @return The SHA-1 hash of the string as an autoreleased OFString - */ -- (OFString*)SHA1Hash; - -/*! - * @brief Returns the SHA-224 hash of the string as an autoreleased OFString. - * - * @return The SHA-224 hash of the string as an autoreleased OFString - */ -- (OFString*)SHA224Hash; - -/*! - * @brief Returns the SHA-256 hash of the string as an autoreleased OFString. - * - * @return The SHA-256 hash of the string as an autoreleased OFString - */ -- (OFString*)SHA256Hash; - -/*! - * @brief Returns the SHA-384 hash of the string as an autoreleased OFString. - * - * @return The SHA-384 hash of the string as an autoreleased OFString - */ -- (OFString*)SHA384Hash; - -/*! - * @brief Returns the SHA-512 hash of the string as an autoreleased OFString. - * - * @return The SHA-512 hash of the string as an autoreleased OFString - */ -- (OFString*)SHA512Hash; -@end - -OF_ASSUME_NONNULL_END DELETED src/OFString+Hashing.m Index: src/OFString+Hashing.m ================================================================== --- src/OFString+Hashing.m +++ src/OFString+Hashing.m @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 - * 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 "OFHash.h" -#import "OFMD5Hash.h" -#import "OFRIPEMD160Hash.h" -#import "OFSHA1Hash.h" -#import "OFSHA224Hash.h" -#import "OFSHA256Hash.h" -#import "OFSHA384Hash.h" -#import "OFSHA512Hash.h" - -int _OFString_Hashing_reference; - -@implementation OFString (Hashing) -- (OFString*)OF_hashAsStringWithHash: (Class )hashClass -{ - void *pool = objc_autoreleasePoolPush(); - id hash = [hashClass hash]; - size_t digestSize = [hashClass digestSize]; - const uint8_t *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*)MD5Hash -{ - return [self OF_hashAsStringWithHash: [OFMD5Hash class]]; -} - -- (OFString*)RIPEMD160Hash -{ - return [self OF_hashAsStringWithHash: [OFRIPEMD160Hash class]]; -} - -- (OFString*)SHA1Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA1Hash class]]; -} - -- (OFString*)SHA224Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA224Hash class]]; -} - -- (OFString*)SHA256Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA256Hash class]]; -} - -- (OFString*)SHA384Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA384Hash class]]; -} - -- (OFString*)SHA512Hash -{ - return [self OF_hashAsStringWithHash: [OFSHA512Hash class]]; -} -@end Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -1124,11 +1124,11 @@ OF_ASSUME_NONNULL_END #import "OFConstantString.h" #import "OFMutableString.h" -#import "OFString+Hashing.h" +#import "OFString+CryptoHashing.h" #import "OFString+JSONValue.h" #import "OFString+Serialization.h" #import "OFString+URLEncoding.h" #import "OFString+XMLEscaping.h" #import "OFString+XMLUnescaping.h" Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -86,11 +86,11 @@ /* References for static linking */ void _references_to_categories_of_OFString(void) { - _OFString_Hashing_reference = 1; + _OFString_CryptoHashing_reference = 1; _OFString_JSONValue_reference = 1; _OFString_Serialization_reference = 1; _OFString_URLEncoding_reference = 1; _OFString_XMLEscaping_reference = 1; _OFString_XMLUnescaping_reference = 1; Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -73,11 +73,11 @@ #ifdef OF_HAVE_PROCESSES # import "OFProcess.h" #endif -#import "OFHash.h" +#import "OFCryptoHash.h" #import "OFMD5Hash.h" #import "OFRIPEMD160Hash.h" #import "OFSHA1Hash.h" #import "OFSHA224Hash.h" #import "OFSHA256Hash.h" Index: src/exceptions/OFHashAlreadyCalculatedException.h ================================================================== --- src/exceptions/OFHashAlreadyCalculatedException.h +++ src/exceptions/OFHashAlreadyCalculatedException.h @@ -13,11 +13,11 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFException.h" -#import "OFHash.h" +#import "OFCryptoHash.h" /*! * @class OFHashAlreadyCalculatedException \ * OFHashAlreadyCalculatedException.h \ * ObjFW/OFHashAlreadyCalculatedException.h @@ -24,29 +24,29 @@ * * @brief An exception indicating that the hash has already been calculated. */ @interface OFHashAlreadyCalculatedException: OFException { - id _hashObject; + id _object; } /*! * The hash which has already been calculated. */ -@property (readonly, retain) id hashObject; +@property (readonly, retain) id object; /*! * @brief Creates a new, autoreleased hash already calculated exception. * - * @param hash The hash which has already been calculated + * @param object The hash which has already been calculated * @return A new, autoreleased hash already calculated exception */ -+ (instancetype)exceptionWithHash: (id )hash; ++ (instancetype)exceptionWithObject: (id )object; /*! * @brief Initializes an already allocated hash already calculated exception. * - * @param hash The hash which has already been calculated + * @param object The hash which has already been calculated * @return An initialized hash already calculated exception */ -- initWithHash: (id )hash; +- initWithObject: (id )object; @end Index: src/exceptions/OFHashAlreadyCalculatedException.m ================================================================== --- src/exceptions/OFHashAlreadyCalculatedException.m +++ src/exceptions/OFHashAlreadyCalculatedException.m @@ -18,40 +18,40 @@ #import "OFHashAlreadyCalculatedException.h" #import "OFString.h" @implementation OFHashAlreadyCalculatedException -@synthesize hashObject = _hashObject; +@synthesize object = _object; -+ (instancetype)exceptionWithHash: (id )hash ++ (instancetype)exceptionWithObject: (id )object { - return [[[self alloc] initWithHash: hash] autorelease]; + return [[[self alloc] initWithObject: object] autorelease]; } - init { OF_INVALID_INIT_METHOD } -- initWithHash: (id )hashObject +- initWithObject: (id )object { self = [super init]; - _hashObject = [hashObject retain]; + _object = [object retain]; return self; } - (void)dealloc { - [_hashObject release]; + [_object release]; [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: @"The hash of type %@ has already been calculated and thus no new " - @"data can be added!", [_hashObject class]]; + @"data can be added!", [_object class]]; } @end Index: tests/OFMD5HashTests.m ================================================================== --- tests/OFMD5HashTests.m +++ tests/OFMD5HashTests.m @@ -38,11 +38,11 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMD5Hash *md5; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; - TEST(@"+[hash]", (md5 = [OFMD5Hash hash])) + TEST(@"+[cryptoHash]", (md5 = [OFMD5Hash cryptoHash])) while (![f isAtEndOfStream]) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; Index: tests/OFRIPEMD160HashTests.m ================================================================== --- tests/OFRIPEMD160HashTests.m +++ tests/OFRIPEMD160HashTests.m @@ -39,11 +39,11 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFRIPEMD160Hash *rmd160; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; - TEST(@"+[hash]", (rmd160 = [OFRIPEMD160Hash hash])) + TEST(@"+[cryptoHash]", (rmd160 = [OFRIPEMD160Hash cryptoHash])) while (![f isAtEndOfStream]) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; Index: tests/OFSHA1HashTests.m ================================================================== --- tests/OFSHA1HashTests.m +++ tests/OFSHA1HashTests.m @@ -39,11 +39,11 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFSHA1Hash *sha1; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; - TEST(@"+[hash]", (sha1 = [OFSHA1Hash hash])) + TEST(@"+[cryptoHash]", (sha1 = [OFSHA1Hash cryptoHash])) while (![f isAtEndOfStream]) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; Index: tests/OFSHA224HashTests.m ================================================================== --- tests/OFSHA224HashTests.m +++ tests/OFSHA224HashTests.m @@ -39,11 +39,11 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFSHA224Hash *sha224; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; - TEST(@"+[hash]", (sha224 = [OFSHA224Hash hash])) + TEST(@"+[cryptoHash]", (sha224 = [OFSHA224Hash cryptoHash])) while (![f isAtEndOfStream]) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; Index: tests/OFSHA256HashTests.m ================================================================== --- tests/OFSHA256HashTests.m +++ tests/OFSHA256HashTests.m @@ -39,11 +39,11 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFSHA256Hash *sha256; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; - TEST(@"+[hash]", (sha256 = [OFSHA256Hash hash])) + TEST(@"+[cryptoHash]", (sha256 = [OFSHA256Hash cryptoHash])) while (![f isAtEndOfStream]) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; Index: tests/OFSHA384HashTests.m ================================================================== --- tests/OFSHA384HashTests.m +++ tests/OFSHA384HashTests.m @@ -40,11 +40,11 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFSHA384Hash *sha384; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; - TEST(@"+[hash]", (sha384 = [OFSHA384Hash hash])) + TEST(@"+[cryptoHash]", (sha384 = [OFSHA384Hash cryptoHash])) while (![f isAtEndOfStream]) { char buf[128]; size_t len = [f readIntoBuffer: buf length: 128]; Index: tests/OFSHA512HashTests.m ================================================================== --- tests/OFSHA512HashTests.m +++ tests/OFSHA512HashTests.m @@ -41,11 +41,11 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFSHA512Hash *sha512; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; - TEST(@"+[hash]", (sha512 = [OFSHA512Hash hash])) + TEST(@"+[cryptoHash]", (sha512 = [OFSHA512Hash cryptoHash])) while (![f isAtEndOfStream]) { char buf[128]; size_t len = [f readIntoBuffer: buf length: 128]; Index: utils/ofhash/OFHash.m ================================================================== --- utils/ofhash/OFHash.m +++ utils/ofhash/OFHash.m @@ -45,36 +45,36 @@ [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } -static id +static id hashForName(OFString *name) { if ([name isEqual: @"md5"]) - return [OFMD5Hash hash]; + return [OFMD5Hash cryptoHash]; else if ([name isEqual: @"rmd160"] || [name isEqual: @"ripemd160"]) - return [OFRIPEMD160Hash hash]; + return [OFRIPEMD160Hash cryptoHash]; else if ([name isEqual: @"sha1"]) - return [OFSHA1Hash hash]; + return [OFSHA1Hash cryptoHash]; else if ([name isEqual: @"sha224"]) - return [OFSHA224Hash hash]; + return [OFSHA224Hash cryptoHash]; else if ([name isEqual: @"sha256"]) - return [OFSHA256Hash hash]; + return [OFSHA256Hash cryptoHash]; else if ([name isEqual: @"sha384"]) - return [OFSHA384Hash hash]; + return [OFSHA384Hash cryptoHash]; else if ([name isEqual: @"sha512"]) - return [OFSHA512Hash hash]; + return [OFSHA512Hash cryptoHash]; return nil; } @implementation OFHash - (void)applicationDidFinishLaunching { OFArray OF_GENERIC(OFString*) *arguments = [OFApplication arguments]; - id hash; + id hash; bool first = true; int exitStatus = 0; if ([arguments count] < 2) help();