more fixes for tests
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build macOS ZIP (push) Canceled after 0s

This commit is contained in:
wt committed 2026-08-11 15:42:01 +07:00
1 parent 2558f722fc
commit 88616124b6
4 files changed
+60 -9

No files matched your search

+30 -4
View File
@@ -22,19 +22,45 @@ final class CryptoKitAESGCMEngineTests: XCTestCase {
func testModifiedTagFails() {
let engine = CryptoKitAESGCMEngine()
let key = Data(repeating: 0x31, count: 16)
let iv = Data(repeating: 0x22, count: 12)
var ciphertext = Data()
var tag = Data()
XCTAssertTrue(
guard
engine.encrypt(
iv: iv, key: key, message: Data("secret".utf8), output: &ciphertext, tag: &tag))
iv: iv,
key: key,
message: Data("secret".utf8),
output: &ciphertext,
tag: &tag
)
else {
XCTFail("AES-GCM encryption unexpectedly failed")
return
}
XCTAssertEqual(tag.count, 16)
guard tag.count == 16 else {
return
}
var modifiedTag = tag
modifiedTag[0] ^= 0x01
modifiedTag[modifiedTag.startIndex] ^= 0x01
var decrypted = Data()
XCTAssertFalse(
engine.decrypt(
iv: iv, key: key, encoded: ciphertext, auth: modifiedTag, output: &decrypted))
iv: iv,
key: key,
encoded: ciphertext,
auth: modifiedTag,
output: &decrypted
)
)
}
}