@@ -648,6 +648,69 @@ final class SigningTests: XCTestCase {
648
648
}
649
649
}
650
650
651
+ func testCMSEndToEndWithECKeyADPCertificate( ) async throws {
652
+ #if ENABLE_REAL_SIGNING_IDENTITY_TEST
653
+ #else
654
+ try XCTSkipIf ( true )
655
+ #endif
656
+
657
+ let keyAndCertChain = try tsc_await { ecADPKeyAndCertChain ( callback: $0) }
658
+ let signingIdentity = SwiftSigningIdentity (
659
+ certificate: try Certificate ( keyAndCertChain. leafCertificate) ,
660
+ privateKey: try Certificate
661
+ . PrivateKey ( P256 . Signing. PrivateKey ( derRepresentation: keyAndCertChain. privateKey) )
662
+ )
663
+ let content = Array ( " per aspera ad astra " . utf8)
664
+
665
+ let cmsProvider = CMSSignatureProvider ( signatureAlgorithm: . ecdsaP256)
666
+ let signature = try cmsProvider. sign (
667
+ content: content,
668
+ identity: signingIdentity,
669
+ intermediateCertificates: keyAndCertChain. intermediateCertificates,
670
+ observabilityScope: ObservabilitySystem . NOOP
671
+ )
672
+
673
+ let verifierConfiguration = VerifierConfiguration (
674
+ trustedRoots: [ keyAndCertChain. rootCertificate] ,
675
+ includeDefaultTrustStore: true ,
676
+ certificateExpiration: . enabled( validationTime: nil ) ,
677
+ certificateRevocation: . strict( validationTime: nil )
678
+ )
679
+
680
+ let status = try await cmsProvider. status (
681
+ signature: signature,
682
+ content: content,
683
+ verifierConfiguration: verifierConfiguration,
684
+ observabilityScope: ObservabilitySystem . NOOP
685
+ )
686
+
687
+ guard case . valid = status else {
688
+ return XCTFail ( " Expected signature status to be .valid but got \( status) " )
689
+ }
690
+
691
+ func ecADPKeyAndCertChain( callback: ( Result < KeyAndCertChain , Error > ) -> Void ) {
692
+ do {
693
+ try fixture ( name: " Signing " , createGitRepo: false ) { fixturePath in
694
+ let privateKey = try readFileContents (
695
+ in: fixturePath,
696
+ pathComponents: " Certificates " , " swift_package_key.p8 "
697
+ )
698
+ let certificate = try readFileContents (
699
+ in: fixturePath,
700
+ pathComponents: " Certificates " , " swift_package.cer "
701
+ )
702
+
703
+ callback ( . success( KeyAndCertChain (
704
+ privateKey: privateKey,
705
+ certificateChain: [ certificate]
706
+ ) ) )
707
+ }
708
+ } catch {
709
+ callback ( . failure( error) )
710
+ }
711
+ }
712
+ }
713
+
651
714
#if os(macOS)
652
715
func testCMS1_0_0EndToEndWithADPSigningIdentityFromKeychain( ) async throws {
653
716
#if ENABLE_REAL_SIGNING_IDENTITY_TEST
0 commit comments