Files
libsignal/swift/Sources/LibSignalClient/Svr2.swift
Jordan Rose f19815b938 swift: Add a low-level helper invokeFnReturningValueByPointer
...and use it to avoid having to name return types for bridge
functions, which return by out-parameter.
2025-10-14 11:22:22 -07:00

34 lines
1.0 KiB
Swift

//
// Copyright 2023 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
import SignalFfi
///
/// Svr2Client provides bindings to interact with Signal's v2 Secure Value Recovery service.
///
/// See ``SgxClient``
public class Svr2Client: SgxClient {
public convenience init(
mrenclave: some ContiguousBytes,
attestationMessage: some ContiguousBytes,
currentDate: Date
) throws {
let handle = try attestationMessage.withUnsafeBorrowedBuffer { attestationMessageBuffer in
try mrenclave.withUnsafeBorrowedBuffer { mrenclaveBuffer in
try invokeFnReturningValueByPointer(.init()) {
signal_svr2_client_new(
$0,
mrenclaveBuffer,
attestationMessageBuffer,
UInt64(currentDate.timeIntervalSince1970 * 1000)
)
}
}
}
self.init(owned: NonNull(handle)!)
}
}