Skip to content
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

Add Sendable annotations to Crypto Extras #211

Merged
merged 1 commit into from
Dec 12, 2023
Merged
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
8 changes: 6 additions & 2 deletions Sources/_CryptoExtras/AES/AES_GCM_SIV.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import Crypto
@_implementationOnly import CCryptoBoringSSL
@_implementationOnly import CCryptoBoringSSLShims
@_implementationOnly import CryptoBoringWrapper
#if canImport(Darwin) || swift(>=5.9.1)
import Foundation
#else
@preconcurrency import Foundation
#endif

/// Types associated with the AES GCM SIV algorithm
extension AES.GCM {
Expand Down Expand Up @@ -81,7 +85,7 @@ extension AES.GCM {
}

extension AES.GCM._SIV {
public struct Nonce: ContiguousBytes, Sequence {
public struct Nonce: Sendable, ContiguousBytes, Sequence {
let bytes: Data

/// Generates a fresh random Nonce. Unless required by a specification to provide a specific Nonce, this is the recommended initializer.
Expand Down Expand Up @@ -115,7 +119,7 @@ extension AES.GCM._SIV {
}

extension AES.GCM._SIV {
public struct SealedBox {
public struct SealedBox: Sendable {
/// The combined representation ( nonce || ciphertext || tag)
public let combined: Data
/// The authentication tag
Expand Down
8 changes: 6 additions & 2 deletions Sources/_CryptoExtras/ChaCha20CTR/ChaCha20CTR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
@_implementationOnly import CCryptoBoringSSLShims
import Crypto
@_implementationOnly import CryptoBoringWrapper
#if canImport(Darwin) || swift(>=5.9.1)
import Foundation
#else
@preconcurrency import Foundation
#endif

typealias ChaCha20CTRImpl = OpenSSLChaCha20CTRImpl

Expand Down Expand Up @@ -51,7 +55,7 @@ extension Insecure {
}

extension Insecure.ChaCha20CTR {
public struct Nonce: ContiguousBytes, Sequence {
public struct Nonce: Sendable, ContiguousBytes, Sequence {
let bytes: Data

/// Generates a fresh random Nonce. Unless required by a specification to provide a specific Nonce, this is the recommended initializer.
Expand Down Expand Up @@ -83,7 +87,7 @@ extension Insecure.ChaCha20CTR {
}
}

public struct Counter: ContiguousBytes {
public struct Counter: Sendable, ContiguousBytes {
let counter: UInt32

/// Generates a fresh Counter set to 0. Unless required by a specification to provide a specific Counter, this is the recommended initializer.
Expand Down
8 changes: 4 additions & 4 deletions Sources/_CryptoExtras/RSA/RSA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ extension _RSA.Signing {
}

extension _RSA.Signing {
public struct RSASignature: ContiguousBytes {
public struct RSASignature: Sendable, ContiguousBytes {
public var rawRepresentation: Data

public init<D: DataProtocol>(rawRepresentation: D) {
Expand All @@ -177,7 +177,7 @@ extension _RSA.Signing {
}

extension _RSA.Signing {
public struct Padding {
public struct Padding: Sendable {
internal enum Backing {
case pkcs1v1_5
case pss
Expand Down Expand Up @@ -305,7 +305,7 @@ extension _RSA.Signing.PublicKey {
}

extension _RSA.Signing {
public struct KeySize {
public struct KeySize: Sendable {
public let bitCount: Int

/// RSA key size of 2048 bits
Expand Down Expand Up @@ -399,7 +399,7 @@ extension _RSA.Encryption {
}

extension _RSA.Encryption {
public struct Padding {
public struct Padding: Sendable {
internal enum Backing {
case pkcs1_oaep(Digest)
}
Expand Down