mirror of
https://github.com/signalapp/libsignal.git
synced 2026-05-02 04:27:22 +02:00
- moves svr2 pin hashing to a standalone function - take string instead of utf-8 encoded bytes where possible
29 lines
1.1 KiB
Swift
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!)
|
|
}
|
|
}
|