|
@@ -567,6 +567,26 @@ extension AESTests {
|
|
let decrypted = decrypt(encrypted)
|
|
let decrypted = decrypt(encrypted)
|
|
XCTAssertEqual(decrypted, plaintext)
|
|
XCTAssertEqual(decrypted, plaintext)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ func testAESGCMTagLengthCombined2() {
|
|
|
|
+ let key = Array<UInt8>(hex: "0x00000000000000000000000000000000")
|
|
|
|
+ let plaintext = Array<UInt8>(hex: "0x0000000000000000000000000000000000000000")
|
|
|
|
+ let iv = Array<UInt8>(hex: "0x000000000000")
|
|
|
|
+
|
|
|
|
+ let gcm = GCM(iv: iv, tagLength: 12, mode: .combined)
|
|
|
|
+ let aes = try! AES(key: key, blockMode: gcm, padding: .noPadding)
|
|
|
|
+ let encrypted = try! aes.encrypt(plaintext)
|
|
|
|
+
|
|
|
|
+ // decrypt
|
|
|
|
+ func decrypt(_ encrypted: Array<UInt8>) -> Array<UInt8> {
|
|
|
|
+ let decGCM = GCM(iv: iv, authenticationTag: gcm.authenticationTag!, mode: .combined)
|
|
|
|
+ let aes = try! AES(key: key, blockMode: decGCM, padding: .noPadding)
|
|
|
|
+ return try! aes.decrypt(encrypted)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let decrypted = decrypt(encrypted)
|
|
|
|
+ XCTAssertEqual(decrypted, plaintext)
|
|
|
|
+ }
|
|
|
|
|
|
func testAESGCMTestCaseIrregularCombined1() {
|
|
func testAESGCMTestCaseIrregularCombined1() {
|
|
// echo -n "0123456789010123456789012345" | openssl enc -aes-128-gcm -K feffe9928665731c6d6a8f9467308308 -iv cafebabefacedbaddecaf888 -nopad -nosalt
|
|
// echo -n "0123456789010123456789012345" | openssl enc -aes-128-gcm -K feffe9928665731c6d6a8f9467308308 -iv cafebabefacedbaddecaf888 -nopad -nosalt
|