mirror of
https://github.com/signalapp/libsignal.git
synced 2026-05-03 21:12:20 +02:00
swift-format is owned by the Swift project and is generally less opinionated than swiftformat (but better at formatting to a limited line length).
36 lines
1.1 KiB
Swift
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)!)
|
|
}
|
|
}
|