mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-25 17:25:18 +02:00
...and use it to avoid having to name return types for bridge functions, which return by out-parameter.
34 lines
1.0 KiB
Swift
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)!)
|
|
}
|
|
}
|