mirror of
https://github.com/apple/swift-nio-ssl
synced 2026-11-27 05:04:24 +00:00
* Port SecureBytes from Swift Crypto to use with TLS-PSK Motivation: Porting SecureBytes to NIOSSLSecureBytes for using in (Add TLS-PSK Support #360). Modifications: Addition and modification of SecureBytes to work within SwiftNIO SSL. Added additional test cases. Result: NIOSSLSecureBytes will be ported for usage in a later PR with TLS-PSK. * secure-bytes-transfer: Added LinuxMain tests * secure-bytes-transfer: Removed case from NIOSSLError * secure-bytes-transfer: Addressed initial feedback * secure-bytes-transfer: Removed NIOSSLSecureBytesError from SSLErrors * secure-bytes-transfer: Remove public access from NIOSSLSecureBytes * Remove remaining public declaration. Co-authored-by: meaton2 <meaton3@apple.com> Co-authored-by: Cory Benfield <lukasa@apple.com>
27 lines
1021 B
Swift
27 lines
1021 B
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2017-2022 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
@_implementationOnly import CNIOBoringSSL
|
|
|
|
typealias errno_t = CInt
|
|
|
|
// This is a Swift wrapper for the libc function that does not exist on Linux. We shim it via a call to OPENSSL_cleanse.
|
|
// We have the same syntax, but mostly ignore it.
|
|
@discardableResult
|
|
func memset_s(_ s: UnsafeMutableRawPointer!, _ smax: Int, _ byte: CInt, _ n: Int) -> errno_t {
|
|
assert(smax == n, "memset_s invariant not met")
|
|
assert(byte == 0, "memset_s used to not zero anything")
|
|
CNIOBoringSSL_OPENSSL_cleanse(s, smax)
|
|
return 0
|
|
}
|