Skip to content

Explicit sendable changes #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ jobs:
with:
runner_pool: nightly
build_scheme: swift-certificates
xcode_16_2_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable"
xcode_16_3_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable"
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ jobs:
with:
runner_pool: general
build_scheme: swift-certificates
xcode_16_2_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable"
xcode_16_3_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable"
2 changes: 1 addition & 1 deletion Sources/X509/CSR/CSRAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ extension CertificateSigningRequest.Attribute: DERImplicitlyTaggable {

extension ASN1ObjectIdentifier {
/// Object Identifiers that identify attributes applied to CSRs.
public enum CSRAttributes {
public enum CSRAttributes: Sendable {
/// A request to apply specific certificate extensions.
public static let extensionRequest: ASN1ObjectIdentifier = [1, 2, 840, 113549, 1, 9, 14]
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/X509/CryptographicMessageSyntax/CMSOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import SwiftASN1
import Crypto

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
public enum CMS {
public enum CMS: Sendable {
@_spi(CMS)
@inlinable
public static func sign<Bytes: DataProtocol>(
Expand Down Expand Up @@ -447,7 +447,7 @@ public enum CMS {
@_spi(CMS)
public typealias SignatureVerificationResult = Result<Valid, VerificationError>

public struct Valid: Hashable {
public struct Valid: Hashable, Sendable {
public var signer: Certificate

@inlinable
Expand Down
4 changes: 2 additions & 2 deletions Sources/X509/Digests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import FoundationEssentials
#else
import Foundation
#endif
import Crypto
@preconcurrency import Crypto

@usableFromInline
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
enum Digest {
enum Digest: Sendable {
case insecureSHA1(Insecure.SHA1Digest)
case sha256(SHA256Digest)
case sha384(SHA384Digest)
Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/DistinguishedNameBuilder/CommonName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftASN1
/// Set the Common Name (CN) of a ``DistinguishedName``.
///
/// This type is used in ``DistinguishedNameBuilder`` contexts.
public struct CommonName: RelativeDistinguishedNameConvertible {
public struct CommonName: RelativeDistinguishedNameConvertible, Sendable {
/// The value of the common name
public var name: String

Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/DistinguishedNameBuilder/CountryName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftASN1
/// Set the Country Name (C) of a ``DistinguishedName``.
///
/// This type is used in ``DistinguishedNameBuilder`` contexts.
public struct CountryName: RelativeDistinguishedNameConvertible {
public struct CountryName: RelativeDistinguishedNameConvertible, Sendable {
/// The value of the country name field.
public var name: String

Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/DistinguishedNameBuilder/DNBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/// Users can extend this syntax for their own extensions by conforming their semantic type to ``RelativeDistinguishedNameConvertible``.
/// This is the only requirement for adding new extensions to this builder syntax.
@resultBuilder
public struct DistinguishedNameBuilder {
public struct DistinguishedNameBuilder: Sendable {
@inlinable
public static func buildExpression<Extension: RelativeDistinguishedNameConvertible>(
_ expression: Extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftASN1
/// Set the Domain Component (DC) of a ``DistinguishedName``.
///
/// This type is used in ``DistinguishedNameBuilder`` contexts.
public struct DomainComponent: RelativeDistinguishedNameConvertible {
public struct DomainComponent: RelativeDistinguishedNameConvertible, Sendable {
/// The value of the organizational unit name field.
public var name: String

Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/DistinguishedNameBuilder/EmailAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftASN1
/// Set the Domain Component (E) of a ``DistinguishedName``.
///
/// This type is used in ``DistinguishedNameBuilder`` contexts.
public struct EmailAddress: RelativeDistinguishedNameConvertible {
public struct EmailAddress: RelativeDistinguishedNameConvertible, Sendable {
/// The value of the email name field.
public var name: String

Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/DistinguishedNameBuilder/LocalityName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftASN1
/// Set the Locality Name (L) of a ``DistinguishedName``.
///
/// This type is used in ``DistinguishedNameBuilder`` contexts.
public struct LocalityName: RelativeDistinguishedNameConvertible {
public struct LocalityName: RelativeDistinguishedNameConvertible, Sendable {
/// The value of the locality name field.
public var name: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftASN1
/// Set the Organization Name (O) of a ``DistinguishedName``.
///
/// This type is used in ``DistinguishedNameBuilder`` contexts.
public struct OrganizationName: RelativeDistinguishedNameConvertible {
public struct OrganizationName: RelativeDistinguishedNameConvertible, Sendable {
/// The value of the organization name field.
public var name: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftASN1
/// Set the Organizational Unit Name (OU) of a ``DistinguishedName``.
///
/// This type is used in ``DistinguishedNameBuilder`` contexts.
public struct OrganizationalUnitName: RelativeDistinguishedNameConvertible {
public struct OrganizationalUnitName: RelativeDistinguishedNameConvertible, Sendable {
/// The value of the organizational unit name field.
public var name: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftASN1
/// Set the State or Province Name (ST) of a ``DistinguishedName``.
///
/// This type is used in ``DistinguishedNameBuilder`` contexts.
public struct StateOrProvinceName: RelativeDistinguishedNameConvertible {
public struct StateOrProvinceName: RelativeDistinguishedNameConvertible, Sendable {
/// The value of the state or province name field.
public var name: String

Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/DistinguishedNameBuilder/StreetAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftASN1
/// Set the Street Address (STREET) of a ``DistinguishedName``.
///
/// This type is used in ``DistinguishedNameBuilder`` contexts.
public struct StreetAddress: RelativeDistinguishedNameConvertible {
public struct StreetAddress: RelativeDistinguishedNameConvertible, Sendable {
/// The value of the street address field.
public var name: String

Expand Down
6 changes: 3 additions & 3 deletions Sources/X509/Extension Types/AuthorityInformationAccess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ extension AuthorityInformationAccess: CertificateExtensionConvertible {
// accessMethod OBJECT IDENTIFIER,
// accessLocation GeneralName }
@usableFromInline
struct AuthorityInfoAccessSyntax: DERImplicitlyTaggable {
struct AuthorityInfoAccessSyntax: DERImplicitlyTaggable, Sendable {
@inlinable
static var defaultIdentifier: ASN1Identifier {
.sequence
Expand Down Expand Up @@ -285,7 +285,7 @@ struct AuthorityInfoAccessSyntax: DERImplicitlyTaggable {
}

@usableFromInline
struct AIAAccessDescription: DERImplicitlyTaggable {
struct AIAAccessDescription: DERImplicitlyTaggable, Sendable {
@inlinable
static var defaultIdentifier: ASN1Identifier {
.sequence
Expand Down Expand Up @@ -329,7 +329,7 @@ struct AIAAccessDescription: DERImplicitlyTaggable {

extension ASN1ObjectIdentifier {
@usableFromInline
enum AccessMethodIdentifiers {
enum AccessMethodIdentifiers: Sendable {
@usableFromInline
static let ocspServer: ASN1ObjectIdentifier = [1, 3, 6, 1, 5, 5, 7, 48, 1]

Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/Extension Types/AuthorityKeyIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ extension AuthorityKeyIdentifier: CertificateExtensionConvertible {

// MARK: ASN1 helpers
@usableFromInline
struct AuthorityKeyIdentifierValue: DERImplicitlyTaggable {
struct AuthorityKeyIdentifierValue: DERImplicitlyTaggable, Sendable {
@inlinable
static var defaultIdentifier: ASN1Identifier {
.sequence
Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/Extension Types/BasicConstraints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extension BasicConstraints: CertificateExtensionConvertible {

// MARK: ASN1 helpers
@usableFromInline
struct BasicConstraintsValue: DERImplicitlyTaggable {
struct BasicConstraintsValue: DERImplicitlyTaggable, Sendable {
@inlinable
static var defaultIdentifier: ASN1Identifier {
.sequence
Expand Down
4 changes: 2 additions & 2 deletions Sources/X509/Extension Types/ExtendedKeyUsage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ extension ASN1ObjectIdentifier {
/// An acceptable usage for a certificate as attested in an
/// ``ExtendedKeyUsage``
/// extension.
public enum ExtendedKeyUsage {
public enum ExtendedKeyUsage: Sendable {
/// The public key may be used for any purpose.
public static let any: ASN1ObjectIdentifier = [2, 5, 29, 37, 0]

Expand Down Expand Up @@ -402,7 +402,7 @@ extension ASN1ObjectIdentifier {
}

@usableFromInline
struct ASN1ExtendedKeyUsage: DERImplicitlyTaggable {
struct ASN1ExtendedKeyUsage: DERImplicitlyTaggable, Sendable {
@inlinable
static var defaultIdentifier: ASN1Identifier {
.sequence
Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/Extension Types/ExtensionIdentifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import SwiftASN1

extension ASN1ObjectIdentifier {
/// OIDs that identify known X509 extensions.
public enum X509ExtensionID {
public enum X509ExtensionID: Sendable {
/// Identifies the authority key identifier extension, corresponding to
/// ``AuthorityKeyIdentifier``.
public static let authorityKeyIdentifier: ASN1ObjectIdentifier = [2, 5, 29, 35]
Expand Down
12 changes: 6 additions & 6 deletions Sources/X509/Extension Types/NameConstraints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public struct NameConstraints {
hasher.combine(contentsOf: self)
}

public struct Index: Comparable {
public struct Index: Comparable, Sendable {
@inlinable
public static func < (lhs: Self, rhs: Self) -> Bool {
lhs.wrapped < rhs.wrapped
Expand Down Expand Up @@ -157,7 +157,7 @@ public struct NameConstraints {
hasher.combine(contentsOf: self)
}

public struct Index: Comparable {
public struct Index: Comparable, Sendable {
@inlinable
public static func < (lhs: Self, rhs: Self) -> Bool {
lhs.wrapped < rhs.wrapped
Expand Down Expand Up @@ -253,7 +253,7 @@ public struct NameConstraints {
hasher.combine(contentsOf: self)
}

public struct Index: Comparable {
public struct Index: Comparable, Sendable {
@inlinable
public static func < (lhs: Self, rhs: Self) -> Bool {
lhs.wrapped < rhs.wrapped
Expand Down Expand Up @@ -349,7 +349,7 @@ public struct NameConstraints {
hasher.combine(contentsOf: self)
}

public struct Index: Comparable {
public struct Index: Comparable, Sendable {
@inlinable
public static func < (lhs: Self, rhs: Self) -> Bool {
lhs.wrapped < rhs.wrapped
Expand Down Expand Up @@ -749,7 +749,7 @@ extension NameConstraints: CertificateExtensionConvertible {
// MARK: ASN1 Helpers
@usableFromInline
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
struct NameConstraintsValue: DERImplicitlyTaggable {
struct NameConstraintsValue: DERImplicitlyTaggable, Sendable {
@inlinable
static var defaultIdentifier: ASN1Identifier {
.sequence
Expand Down Expand Up @@ -837,7 +837,7 @@ struct NameConstraintsValue: DERImplicitlyTaggable {
// [GeneralSubtree] will force a heap allocation. Instead, we inline the definition of GeneralSubtree into
// GeneralSubtrees, to avoid the extra allocation.
@usableFromInline
struct GeneralSubtrees: DERImplicitlyTaggable {
struct GeneralSubtrees: DERImplicitlyTaggable, Sendable {
@inlinable
static var defaultIdentifier: ASN1Identifier {
.sequence
Expand Down
5 changes: 4 additions & 1 deletion Sources/X509/ExtensionsBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/// Users are also able to mark specific extensions as critical by using the ``Critical`` helper type.
@resultBuilder
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
public struct ExtensionsBuilder {
public struct ExtensionsBuilder: Sendable {
@inlinable
public static func buildExpression<Extension: CertificateExtensionConvertible>(
_ expression: Extension
Expand Down Expand Up @@ -147,3 +147,6 @@ public struct Critical<BaseExtension: CertificateExtensionConvertible>: Certific
return ext
}
}

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension Critical: Sendable where BaseExtension: Sendable {}
2 changes: 1 addition & 1 deletion Sources/X509/GeneralName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ extension GeneralName.OtherName: CustomStringConvertible {
}

@usableFromInline
struct GeneralNames: DERImplicitlyTaggable {
struct GeneralNames: DERImplicitlyTaggable, Sendable {
@inlinable
static var defaultIdentifier: ASN1Identifier {
.sequence
Expand Down
5 changes: 4 additions & 1 deletion Sources/X509/Lock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typealias LockPrimitive = pthread_mutex_t
#endif

@usableFromInline
enum LockOperations {}
enum LockOperations: Sendable {}

extension LockOperations {
@inlinable
Expand Down Expand Up @@ -196,6 +196,9 @@ final class LockStorage<Value>: ManagedBuffer<Value, LockPrimitive> {
}
}

@available(*, unavailable)
extension LockStorage: Sendable {}

/// A threading lock based on `libpthread` instead of `libdispatch`.
///
/// - Note: ``CertificatesLock`` has reference semantics.
Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/OCSP/DirectoryString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import SwiftASN1
/// Note that these upper bounds are measured in _characters_, not bytes.
///
@usableFromInline
enum DirectoryString: DERParseable, DERSerializable, Hashable {
enum DirectoryString: DERParseable, DERSerializable, Hashable, Sendable {
case teletexString(ASN1TeletexString)
case printableString(ASN1PrintableString)
case universalString(ASN1UniversalString)
Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/OCSP/OCSPPolicy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public struct OCSPFailureMode: Hashable, Sendable {
}

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
public struct OCSPVerifierPolicy<Requester: OCSPRequester>: VerifierPolicy {
public struct OCSPVerifierPolicy<Requester: OCSPRequester>: VerifierPolicy, Sendable {
public let verifyingCriticalExtensions: [ASN1ObjectIdentifier] = []

struct Storage: Sendable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/PKCS8PrivateKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import SwiftASN1
// We disregard the attributes because we don't support them anyway.
//
@usableFromInline
struct PKCS8PrivateKey: DERImplicitlyTaggable {
struct PKCS8PrivateKey: DERImplicitlyTaggable, Sendable {
@inlinable
static var defaultIdentifier: ASN1Identifier {
return .sequence
Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/RDNAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ extension RelativeDistinguishedName.Attribute {

extension ASN1ObjectIdentifier {
/// Common object identifiers used within ``RelativeDistinguishedName/Attribute``s.
public enum RDNAttributeType {
public enum RDNAttributeType: Sendable {
/// The 'countryName' attribute type contains a two-letter
/// ISO 3166 country code.
public static let countryName: ASN1ObjectIdentifier = [2, 5, 4, 6]
Expand Down
2 changes: 1 addition & 1 deletion Sources/X509/SEC1PrivateKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import SwiftASN1
// publicKey [1] EXPLICIT BIT STRING OPTIONAL
// }
@usableFromInline
struct SEC1PrivateKey: DERImplicitlyTaggable, PEMRepresentable {
struct SEC1PrivateKey: DERImplicitlyTaggable, PEMRepresentable, Sendable {
@usableFromInline
static let defaultPEMDiscriminator: String = "EC PRIVATE KEY"

Expand Down
3 changes: 3 additions & 0 deletions Sources/X509/Verifier/AllOfPolicies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ public struct AllOfPolicies<Policy: VerifierPolicy>: VerifierPolicy {
await self.policy.chainMeetsPolicyRequirements(chain: chain)
}
}

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension AllOfPolicies: Sendable where Policy: Sendable {}
3 changes: 3 additions & 0 deletions Sources/X509/Verifier/AnyPolicy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public struct AnyPolicy: VerifierPolicy {
}
}

@available(*, unavailable)
extension AnyPolicy: Sendable {}

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
struct LegacyPolicySet: VerifierPolicy {
let verifyingCriticalExtensions: [ASN1ObjectIdentifier]
Expand Down
4 changes: 2 additions & 2 deletions Sources/X509/Verifier/CertificateStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ extension CertificateStore {
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension CertificateStore {
@usableFromInline
enum Resolved {
enum Resolved: Sendable {
case custom(AnyCustomCertificateStore)
case concrete(ConcreteResolved)
}
Expand Down Expand Up @@ -158,7 +158,7 @@ extension CertificateStore.Resolved {
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension CertificateStore {
@usableFromInline
struct ConcreteResolved {
struct ConcreteResolved: Sendable {

@usableFromInline
var systemTrustRoots: [DistinguishedName: [Certificate]]
Expand Down
Loading
Loading