Skip to content

Commit

Permalink
Added additional test for testing HMAC using Data based object along …
Browse files Browse the repository at this point in the history
…with the existing NSData based test.
  • Loading branch information
Bill Abt committed Aug 16, 2016
1 parent 09a5f87 commit 2830c4b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Tests/CryptorTests/CryptorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CryptorTests: XCTestCase {
("test_HMAC_MD5", test_HMAC_MD5),
("test_HMAC_SHA1", test_HMAC_SHA1),
("test_HMAC_SHA1_NSData", test_HMAC_SHA1_NSData),
("test_HMAC_SHA1_Data", test_HMAC_SHA1_Data),
("test_HMAC_SHA224", test_HMAC_SHA224),
("test_HMAC_SHA256", test_HMAC_SHA256),
("test_HMAC_SHA384", test_HMAC_SHA384),
Expand Down Expand Up @@ -494,10 +495,21 @@ class CryptorTests: XCTestCase {
func test_HMAC_SHA1_NSData() {

let key = self.hmacDefaultKeySHA1
let data : [UInt8] = Array(repeating: 0xcd, count:50)
let data: NSData = CryptoUtils.data(from: Array(repeating: 0xcd, count: 50))
let expected = self.hmacDefaultResultSHA1

let hmac = HMAC(using:.sha1, key:key).update(byteArray: data)?.final()
let hmac = HMAC(using:.sha1, key:key).update(data: data)?.final()

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

func test_HMAC_SHA1_Data() {

let key = self.hmacDefaultKeySHA1
var data: Data = CryptoUtils.data(from: Array(repeating: 0xcd, count: 50))
let expected = self.hmacDefaultResultSHA1

let hmac = HMAC(using:.sha1, key:key).update(data: &data)?.final()

XCTAssertEqual(hmac!, expected, "PASS")
}
Expand Down

0 comments on commit 2830c4b

Please sign in to comment.