Files
libsignal/swift/Sources/LibSignalClient/Svr2.swift
ravi-signal 803e7fe752 pin: move svr2 pin hash out of Svr2Client
- moves svr2 pin hashing to a standalone function
- take string instead of utf-8 encoded bytes where possible
2023-05-30 11:24:54 -05:00

29 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<MrenclaveBytes, AttestationBytes>(mrenclave: MrenclaveBytes, attestationMessage: AttestationBytes, currentDate: Date) throws
where MrenclaveBytes: ContiguousBytes, AttestationBytes: ContiguousBytes {
let handle: OpaquePointer? = try attestationMessage.withUnsafeBorrowedBuffer { attestationMessageBuffer in
try mrenclave.withUnsafeBorrowedBuffer { mrenclaveBuffer in
var result: OpaquePointer?
try checkError(signal_svr2_client_new(&result,
mrenclaveBuffer,
attestationMessageBuffer,
UInt64(currentDate.timeIntervalSince1970 * 1000)))
return result
}
}
self.init(owned: handle!)
}
}