mirror of
https://github.com/apple/swift-crypto
synced 2026-11-28 05:04:21 +00:00
Minimum deployment versions in package manifests can be problematic for libraries, because changing them or adding them to an existing package that doesn't already use them forces SemVer breaking majors. Furthermore, depending on a new library that specifies minimum deployment targets would force the adopting library to also have to add these platforms to its manifest (which would in turn force a major). This PR removes the platforms stanza from the package manifest and replaces them with availability guards. This will allow more packages to use swift-crypto, without forcing them to mint new majors to support the appropriate platforms. --------- Co-authored-by: Cory Benfield <lukasa@apple.com>
58 lines
1.6 KiB
Swift
58 lines
1.6 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftCrypto open source project
|
|
//
|
|
// Copyright (c) 2019-2020 Apple Inc. and the SwiftCrypto project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
|
@_exported import CryptoKit
|
|
#else
|
|
import Foundation
|
|
|
|
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|
|
protocol Zeroization {
|
|
mutating func zeroize()
|
|
}
|
|
|
|
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|
|
extension UnsafeMutablePointer: Zeroization {
|
|
/// Zeroizes the pointee
|
|
func zeroize() {
|
|
let size = MemoryLayout.size(ofValue: Pointee.self)
|
|
memset_s(self, size, 0, size)
|
|
}
|
|
}
|
|
|
|
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|
|
extension UnsafeMutableRawBufferPointer: Zeroization {
|
|
func zeroize() {
|
|
memset_s(self.baseAddress, self.count, 0, self.count)
|
|
}
|
|
}
|
|
|
|
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|
|
extension Array: Zeroization where Element == UInt8 {
|
|
/// Zeroizes the array
|
|
mutating func zeroize() {
|
|
memset_s(&self, self.count, 0, self.count)
|
|
}
|
|
}
|
|
|
|
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|
|
extension Data: Zeroization {
|
|
internal mutating func zeroize() {
|
|
_ = self.withUnsafeMutableBytes {
|
|
memset_s($0.baseAddress!, $0.count, 0, $0.count)
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif // Linux or !SwiftPM
|