@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2021 Jonathan Schleifer + * Copyright (c) 2008-2022 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 @@ -49,11 +49,13 @@ @implementation TestsAppDelegate (OFHMACTests) - (void)HMACTests { void *pool = objc_autoreleasePoolPush(); - OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; + OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"]; + OFStream *file = [[OFURLHandler handlerForURL: URL] + openItemAtURL: URL mode: @"r"]; OFHMAC *HMACMD5, *HMACSHA1, *HMACRMD160; OFHMAC *HMACSHA256, *HMACSHA384, *HMACSHA512; TEST(@"+[HMACWithHashClass:] with MD5", (HMACMD5 = [OFHMAC HMACWithHashClass: [OFMD5Hash class] @@ -101,10 +103,17 @@ [HMACSHA384 updateWithBuffer: buffer length: length]; [HMACSHA512 updateWithBuffer: buffer length: length]; } [file close]; + TEST(@"-[calculate] with MD5", R([HMACMD5 calculate])) + TEST(@"-[calculate] with SHA-1", R([HMACSHA1 calculate])) + TEST(@"-[calculate] with RIPEMD-160", R([HMACRMD160 calculate])) + TEST(@"-[calculate] with SHA-256", R([HMACSHA256 calculate])) + TEST(@"-[calculate] with SHA-384", R([HMACSHA384 calculate])) + TEST(@"-[calculate] with SHA-512", R([HMACSHA512 calculate])) + TEST(@"-[digest] with MD5", memcmp(HMACMD5.digest, MD5Digest, HMACMD5.digestSize) == 0) TEST(@"-[digest] with SHA-1", memcmp(HMACSHA1.digest, SHA1Digest, HMACSHA1.digestSize) == 0) TEST(@"-[digest] with RIPEMD-160",