mirror of
https://github.com/apple/swift-crypto
synced 2026-11-28 05:04:21 +00:00
Remove @_implementationOnly from imports and raw pointer APIs
This commit is contained in:
1 parent
1d03155198
commit
280681b061
32 files changed
+49
-103
No files matched your search
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import CryptoBoringWrapper
|
||||
import Foundation
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import CryptoBoringWrapper
|
||||
import Foundation
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
|
||||
protocol HashFunctionImplementationDetails: HashFunction where Digest: DigestPrivate {}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
|
||||
extension P256.KeyAgreement.PrivateKey {
|
||||
internal func openSSLSharedSecretFromKeyAgreement(with publicKeyShare: P256.KeyAgreement.PublicKey) throws -> SharedSecret {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import Foundation
|
||||
|
||||
enum BoringSSLAESWRAPImpl {
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import Foundation
|
||||
|
||||
// For signing and verifying, we use BoringSSL's Ed25519, not the X25519 stuff.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import CryptoBoringWrapper
|
||||
|
||||
/// A wrapper around BoringSSL's EC_POINT with some lifetime management.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import CryptoBoringWrapper
|
||||
|
||||
/// A wrapper around BoringSSL's EC_GROUP object that handles reference counting and
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import CryptoBoringWrapper
|
||||
import Foundation
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import Foundation
|
||||
|
||||
extension Curve25519.KeyAgreement {
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import CryptoBoringWrapper
|
||||
import Foundation
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import Foundation
|
||||
|
||||
extension Data {
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import Foundation
|
||||
|
||||
extension Curve25519.Signing.PublicKey {
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftCrypto open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the SwiftCrypto project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CryptoBoringWrapper
|
||||
|
||||
extension ArbitraryPrecisionInteger {
|
||||
func withUnsafeBignumPointer<T>(_ body: (UnsafePointer<BIGNUM>) throws -> T) rethrows -> T {
|
||||
try self.withUnsafeRawBignumPointer { pointer in
|
||||
try body(pointer.assumingMemoryBound(to: BIGNUM.self))
|
||||
}
|
||||
}
|
||||
|
||||
mutating func withUnsafeMutableBignumPointer<T>(_ body: (UnsafeMutablePointer<BIGNUM>) throws -> T) rethrows -> T {
|
||||
try self.withUnsafeMutableRawBignumPointer { pointer in
|
||||
try body(pointer.assumingMemoryBound(to: BIGNUM.self))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
|
||||
extension CryptoKitError {
|
||||
/// A helper function that packs the value of `ERR_get_error` into the internal error field.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import CryptoBoringWrapper
|
||||
import Foundation
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if !canImport(Darwin)
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
|
||||
typealias errno_t = CInt
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import Foundation
|
||||
|
||||
/// An abstraction over a BoringSSL AEAD
|
||||
|
||||
@@ -11,27 +11,23 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import Foundation
|
||||
|
||||
/// A wrapper around the OpenSSL BIGNUM object that is appropriately lifetime managed,
|
||||
/// and that provides better Swift types for this object.
|
||||
public struct ArbitraryPrecisionInteger { // TODO: this should be SPI
|
||||
public struct ArbitraryPrecisionInteger {
|
||||
private var _backing: BackingStorage
|
||||
|
||||
public init() {
|
||||
self._backing = BackingStorage()
|
||||
}
|
||||
|
||||
init(copying original: UnsafePointer<BIGNUM>) throws {
|
||||
public init(copying original: UnsafePointer<BIGNUM>) throws {
|
||||
self._backing = try BackingStorage(copying: original)
|
||||
}
|
||||
|
||||
public init(copying original: UnsafeRawPointer) throws {
|
||||
self._backing = try BackingStorage(copying: original.assumingMemoryBound(to: BIGNUM.self))
|
||||
}
|
||||
|
||||
public init(_ original: ArbitraryPrecisionInteger) throws {
|
||||
self._backing = try BackingStorage(copying: original._backing)
|
||||
}
|
||||
@@ -109,24 +105,11 @@ extension ArbitraryPrecisionInteger.BackingStorage {
|
||||
// MARK: - Pointer helpers
|
||||
|
||||
extension ArbitraryPrecisionInteger {
|
||||
func withUnsafeBignumPointer<T>(_ body: (UnsafePointer<BIGNUM>) throws -> T) rethrows -> T {
|
||||
public func withUnsafeBignumPointer<T>(_ body: (UnsafePointer<BIGNUM>) throws -> T) rethrows -> T {
|
||||
try self._backing.withUnsafeBignumPointer(body)
|
||||
}
|
||||
|
||||
mutating func withUnsafeMutableBignumPointer<T>(_ body: (UnsafeMutablePointer<BIGNUM>) throws -> T) rethrows -> T {
|
||||
if !isKnownUniquelyReferenced(&self._backing) {
|
||||
// Failing to CoW is a fatal error here.
|
||||
self._backing = try! BackingStorage(copying: self._backing)
|
||||
}
|
||||
|
||||
return try self._backing.withUnsafeMutableBignumPointer(body)
|
||||
}
|
||||
|
||||
public func withUnsafeRawBignumPointer<T>(_ body: (UnsafeRawPointer) throws -> T) rethrows -> T {
|
||||
try self._backing.withUnsafeBignumPointer(body)
|
||||
}
|
||||
|
||||
public mutating func withUnsafeMutableRawBignumPointer<T>(_ body: (UnsafeMutableRawPointer) throws -> T) rethrows -> T {
|
||||
public mutating func withUnsafeMutableBignumPointer<T>(_ body: (UnsafeMutablePointer<BIGNUM>) throws -> T) rethrows -> T {
|
||||
if !isKnownUniquelyReferenced(&self._backing) {
|
||||
// Failing to CoW is a fatal error here.
|
||||
self._backing = try! BackingStorage(copying: self._backing)
|
||||
@@ -144,14 +127,6 @@ extension ArbitraryPrecisionInteger.BackingStorage {
|
||||
func withUnsafeMutableBignumPointer<T>(_ body: (UnsafeMutablePointer<BIGNUM>) throws -> T) rethrows -> T {
|
||||
try body(&self._backing)
|
||||
}
|
||||
|
||||
func withUnsafeBignumPointer<T>(_ body: (UnsafeRawPointer) throws -> T) rethrows -> T {
|
||||
try body(&self._backing)
|
||||
}
|
||||
|
||||
func withUnsafeMutableBignumPointer<T>(_ body: (UnsafeMutableRawPointer) throws -> T) rethrows -> T {
|
||||
try body(&self._backing)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Other helpers
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
|
||||
public enum CryptoBoringWrapperError: Error {
|
||||
case underlyingCoreCryptoError(error: Int32)
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Crypto
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import CryptoBoringWrapper
|
||||
#if canImport(Darwin) || swift(>=5.9.1)
|
||||
import Foundation
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Crypto
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import CryptoBoringWrapper
|
||||
import Foundation
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import Crypto
|
||||
import Foundation
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
// This is a copy ChaChaPoly_boring just with a different set aes algos
|
||||
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import Crypto
|
||||
import CryptoBoringWrapper
|
||||
import Foundation
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import Crypto
|
||||
import CryptoBoringWrapper
|
||||
import Foundation
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
import Crypto
|
||||
import CryptoBoringWrapper
|
||||
#if canImport(Darwin) || swift(>=5.9.1)
|
||||
|
||||
@@ -17,8 +17,8 @@ import Crypto
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
// Nothing; this is implemented in RSA_security
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import CCryptoBoringSSL
|
||||
import CCryptoBoringSSLShims
|
||||
|
||||
internal struct BoringSSLRSAPublicKey: Sendable {
|
||||
private var backing: Backing
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
// This is only used when bulding with BoringSSL.
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import Foundation
|
||||
import Crypto
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import Crypto
|
||||
|
||||
extension CryptoKitError {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
// Nothing to do in this case
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
import Crypto
|
||||
|
||||
struct DigestType {
|
||||
|
||||
@@ -20,7 +20,7 @@ import XCTest
|
||||
#if !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@testable import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
@testable import Crypto
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import XCTest
|
||||
#if !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@testable import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import CCryptoBoringSSL
|
||||
@testable import Crypto
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user