Skip to content

Commit

Permalink
Test accepting attached timed signature as detached
Browse files Browse the repository at this point in the history
  • Loading branch information
jonct committed Nov 22, 2024
1 parent 5c3e4f5 commit 2c6754f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Tests/X509Tests/CMSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,27 @@ final class CMSTests: XCTestCase {
XCTAssertValidSignature(isValidSignature)
}

func testToleratesAttachedSignatureWithSigningTimeSignedAttrVerifyingAsDetached() async throws {
let data: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
let signature = try CMS.sign(
data,
signatureAlgorithm: .ecdsaWithSHA256,
certificate: Self.leaf1Cert,
privateKey: Self.leaf1Key,
signingTime: Date(),
detached: false
)
let isValidDetachedSignature = await CMS.isValidSignature(
dataBytes: data,
signatureBytes: signature,
trustRoots: CertificateStore([Self.rootCert]),
allowAttachedContent: true
) {
Self.defaultPolicies
}
XCTAssertValidSignature(isValidDetachedSignature)
}

func testForbidsDetachedSignatureWithSigningTimeSignedAttrVerifyingAsAttached() async throws {
let data: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
let signature = try CMS.sign(
Expand Down

0 comments on commit 2c6754f

Please sign in to comment.