mirror of
https://github.com/apple/swift-crypto
synced 2026-11-30 05:18:46 +00:00
[5.x] Align with CryptoKit from Xcode 27 beta 6 (#462)
## Motivation Xcode 27 beta 6 is now available[^1] with so we can tag a compatible release with the cross-platform code here. ## Modifications - Resync with CryptoKit (CryptoKit-383.2.1) ## Result - Aligned with CryptoKit in latest Xcode beta release. [^1]: https://developer.apple.com/download/all/?q=Xcode%2027
This commit is contained in:
1 parent
2e074efbe2
commit
20f90497e5
1 file changed
+31
@@ -93,6 +93,37 @@ final class XWingTests: XCTestCase {
|
|||||||
let importedKey = try XWingMLKEM768X25519.PrivateKey.init(integrityCheckedRepresentation: exportedFormat)
|
let importedKey = try XWingMLKEM768X25519.PrivateKey.init(integrityCheckedRepresentation: exportedFormat)
|
||||||
XCTAssertEqual(importedKey.seedRepresentation, privateKey.seedRepresentation)
|
XCTAssertEqual(importedKey.seedRepresentation, privateKey.seedRepresentation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testDecapsulateInputValidation() throws {
|
||||||
|
let ciphersuite = HPKE.Ciphersuite.XWingMLKEM768X25519_SHA256_AES_GCM_256
|
||||||
|
let skR = try XWingMLKEM768X25519.PrivateKey.generate()
|
||||||
|
|
||||||
|
// Dummy key with the correct size fails with an error from the underlying implementation.
|
||||||
|
let corretlySizedKey = Data(repeating: 0x00, count: 1120)
|
||||||
|
XCTAssertThrowsError(
|
||||||
|
try HPKE.Recipient(
|
||||||
|
privateKey: skR,
|
||||||
|
ciphersuite: ciphersuite,
|
||||||
|
info: Data(),
|
||||||
|
encapsulatedKey: corretlySizedKey
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
// Keys with the wrong size fail input validation.
|
||||||
|
let keySizesToTest = [0, 1, 1119, 1221, 2000]
|
||||||
|
for keySize in keySizesToTest {
|
||||||
|
let wronglySizedKey = Data(repeating: 0x00, count: keySize)
|
||||||
|
XCTAssertThrowsError(
|
||||||
|
try HPKE.Recipient(
|
||||||
|
privateKey: skR,
|
||||||
|
ciphersuite: ciphersuite,
|
||||||
|
info: Data(),
|
||||||
|
encapsulatedKey: wronglySizedKey
|
||||||
|
),
|
||||||
|
"Unexpectedly returned from malformed decapsulation path for keySize \(keySize)"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Struct to parse KAT file
|
// Struct to parse KAT file
|
||||||
|
|||||||
Reference in new issue
Block a user