Files
libsignal/swift/Sources/LibSignalClient/Svr2.swift
Jordan Rose 9e13263581 Switch to swift-format for formatting instead of swiftformat
swift-format is owned by the Swift project and is generally less
opinionated than swiftformat (but better at formatting to a limited
line length).
2025-06-25 11:24:57 -07:00

36 lines
1.1 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
var result = SignalMutPointerSgxClientState()
try checkError(
signal_svr2_client_new(
&result,
mrenclaveBuffer,
attestationMessageBuffer,
UInt64(currentDate.timeIntervalSince1970 * 1000)
)
)
return result
}
}
self.init(owned: NonNull(handle)!)
}
}