mirror of
https://github.com/signalapp/libsignal.git
synced 2026-05-05 06:32:35 +02:00
This is very similar to the AuthCredential used by the group server, but using CallLinkParams to encrypt the user ID rather than GroupParams (and using GenericServerParams to issue the credential rather than the group server's ServerParams).
46 lines
1.3 KiB
Swift
46 lines
1.3 KiB
Swift
//
|
|
// Copyright 2023 Signal Messenger, LLC.
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import Foundation
|
|
import SignalFfi
|
|
|
|
public class CallLinkSecretParams: ByteArray {
|
|
|
|
public static func deriveFromRootKey<RootKey: ContiguousBytes>(_ rootKey: RootKey) -> CallLinkSecretParams {
|
|
return failOnError {
|
|
try rootKey.withUnsafeBorrowedBuffer { rootKey in
|
|
try invokeFnReturningVariableLengthSerialized {
|
|
signal_call_link_secret_params_derive_from_root_key($0, rootKey)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public required init(contents: [UInt8]) throws {
|
|
try super.init(contents, checkValid: signal_call_link_secret_params_check_valid_contents)
|
|
}
|
|
|
|
public func getPublicParams() -> CallLinkPublicParams {
|
|
return failOnError {
|
|
try withUnsafeBorrowedBuffer { contents in
|
|
try invokeFnReturningVariableLengthSerialized {
|
|
signal_call_link_secret_params_get_public_params($0, contents)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public func decryptUserId(_ ciphertext: UuidCiphertext) throws -> UUID {
|
|
return try withUnsafeBorrowedBuffer { contents in
|
|
try ciphertext.withUnsafePointerToSerialized { ciphertext in
|
|
try invokeFnReturningUuid {
|
|
signal_call_link_secret_params_decrypt_user_id($0, contents, ciphertext)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|