Skip to content

Commit 2830c4b

Browse files
author
Bill Abt
committed
Added additional test for testing HMAC using Data based object along with the existing NSData based test.
1 parent 09a5f87 commit 2830c4b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Tests/CryptorTests/CryptorTests.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class CryptorTests: XCTestCase {
5252
("test_HMAC_MD5", test_HMAC_MD5),
5353
("test_HMAC_SHA1", test_HMAC_SHA1),
5454
("test_HMAC_SHA1_NSData", test_HMAC_SHA1_NSData),
55+
("test_HMAC_SHA1_Data", test_HMAC_SHA1_Data),
5556
("test_HMAC_SHA224", test_HMAC_SHA224),
5657
("test_HMAC_SHA256", test_HMAC_SHA256),
5758
("test_HMAC_SHA384", test_HMAC_SHA384),
@@ -494,10 +495,21 @@ class CryptorTests: XCTestCase {
494495
func test_HMAC_SHA1_NSData() {
495496

496497
let key = self.hmacDefaultKeySHA1
497-
let data : [UInt8] = Array(repeating: 0xcd, count:50)
498+
let data: NSData = CryptoUtils.data(from: Array(repeating: 0xcd, count: 50))
498499
let expected = self.hmacDefaultResultSHA1
499500

500-
let hmac = HMAC(using:.sha1, key:key).update(byteArray: data)?.final()
501+
let hmac = HMAC(using:.sha1, key:key).update(data: data)?.final()
502+
503+
XCTAssertEqual(hmac!, expected, "PASS")
504+
}
505+
506+
func test_HMAC_SHA1_Data() {
507+
508+
let key = self.hmacDefaultKeySHA1
509+
var data: Data = CryptoUtils.data(from: Array(repeating: 0xcd, count: 50))
510+
let expected = self.hmacDefaultResultSHA1
511+
512+
let hmac = HMAC(using:.sha1, key:key).update(data: &data)?.final()
501513

502514
XCTAssertEqual(hmac!, expected, "PASS")
503515
}

0 commit comments

Comments
 (0)