mirror of
https://github.com/mautrix/signal.git
synced 2026-05-14 21:26:54 -04:00
Compare commits
3 commits
main
...
tulir/libs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7712f57b84 | ||
|
|
b618061a0a | ||
|
|
6ae9367ab5 |
4 changed files with 28 additions and 83 deletions
|
|
@ -20,7 +20,7 @@ package libsignalgo
|
|||
/*
|
||||
#include "./libsignal-ffi.h"
|
||||
|
||||
extern int signal_get_identity_key_pair_callback(void *store_ctx, SignalPairOfMutPointerPrivateKeyMutPointerPublicKey *keyp);
|
||||
extern int signal_get_identity_key_pair_callback(void *store_ctx, SignalMutPointerPrivateKey *keyp);
|
||||
extern int signal_get_local_registration_id_callback(void *store_ctx, uint32_t *idp);
|
||||
extern int signal_save_identity_key_callback(void *store_ctx, uint8_t *out, SignalMutPointerProtocolAddress address, SignalMutPointerPublicKey public_key);
|
||||
extern int signal_get_identity_key_callback(void *store_ctx, SignalMutPointerPublicKey *public_keyp, SignalMutPointerProtocolAddress address);
|
||||
|
|
@ -49,29 +49,22 @@ type IdentityKeyStore interface {
|
|||
}
|
||||
|
||||
//export signal_get_identity_key_pair_callback
|
||||
func signal_get_identity_key_pair_callback(storeCtx unsafe.Pointer, keyp *C.SignalPairOfMutPointerPrivateKeyMutPointerPublicKey) C.int {
|
||||
func signal_get_identity_key_pair_callback(storeCtx unsafe.Pointer, keyp *C.SignalMutPointerPrivateKey) C.int {
|
||||
return wrapStoreCallback(storeCtx, func(store IdentityKeyStore, ctx context.Context) error {
|
||||
key, err := store.GetIdentityKeyPair(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if key == nil {
|
||||
keyp.first.raw = nil
|
||||
keyp.second.raw = nil
|
||||
return nil
|
||||
}
|
||||
privClone, err := key.privateKey.Clone()
|
||||
keyp.raw = nil
|
||||
} else {
|
||||
clone, err := key.privateKey.Clone()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pubClone, err := key.publicKey.Clone()
|
||||
if err != nil {
|
||||
return err
|
||||
clone.CancelFinalizer()
|
||||
keyp.raw = clone.ptr
|
||||
}
|
||||
privClone.CancelFinalizer()
|
||||
pubClone.CancelFinalizer()
|
||||
keyp.first.raw = privClone.ptr
|
||||
keyp.second.raw = pubClone.ptr
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
|
@ -159,7 +152,7 @@ func signal_destroy_identity_key_store_callback(storeCtx unsafe.Pointer) {
|
|||
func (ctx *CallbackContext) wrapIdentityKeyStore(store IdentityKeyStore) C.SignalConstPointerFfiIdentityKeyStoreStruct {
|
||||
return C.SignalConstPointerFfiIdentityKeyStoreStruct{&C.SignalIdentityKeyStore{
|
||||
ctx: wrapStore(ctx, store),
|
||||
get_local_identity_key_pair: C.SignalFfiBridgeIdentityKeyStoreGetLocalIdentityKeyPair(C.signal_get_identity_key_pair_callback),
|
||||
get_local_identity_private_key: C.SignalFfiBridgeIdentityKeyStoreGetLocalIdentityPrivateKey(C.signal_get_identity_key_pair_callback),
|
||||
get_local_registration_id: C.SignalFfiBridgeIdentityKeyStoreGetLocalRegistrationId(C.signal_get_local_registration_id_callback),
|
||||
get_identity_key: C.SignalFfiBridgeIdentityKeyStoreGetIdentityKey(C.signal_get_identity_key_callback),
|
||||
save_identity_key: C.SignalFfiBridgeIdentityKeyStoreSaveIdentityKey(C.signal_save_identity_key_callback),
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit a5e76674882a89bac1ed3f4a982120652966d21e
|
||||
Subproject commit ffaa9f0435569d6775d8be636f268f882ed67ce3
|
||||
|
|
@ -260,7 +260,6 @@ typedef enum {
|
|||
SignalErrorCodeKeyTransparencyVerificationFailed = 211,
|
||||
SignalErrorCodeRequestUnauthorized = 220,
|
||||
SignalErrorCodeMismatchedDevices = 221,
|
||||
SignalErrorCodeServiceIdNotFound = 222,
|
||||
} SignalErrorCode;
|
||||
|
||||
enum SignalSvr2CredentialsResult {
|
||||
|
|
@ -777,19 +776,14 @@ typedef struct {
|
|||
const SignalSessionStore *raw;
|
||||
} SignalConstPointerFfiSessionStoreStruct;
|
||||
|
||||
typedef int (*SignalFfiBridgeIdentityKeyStoreGetLocalIdentityPrivateKey)(void *ctx, SignalMutPointerPrivateKey *out);
|
||||
|
||||
typedef int (*SignalFfiBridgeIdentityKeyStoreGetLocalRegistrationId)(void *ctx, uint32_t *out);
|
||||
|
||||
typedef struct {
|
||||
SignalPublicKey *raw;
|
||||
} SignalMutPointerPublicKey;
|
||||
|
||||
typedef struct {
|
||||
SignalMutPointerPrivateKey first;
|
||||
SignalMutPointerPublicKey second;
|
||||
} SignalPairOfMutPointerPrivateKeyMutPointerPublicKey;
|
||||
|
||||
typedef int (*SignalFfiBridgeIdentityKeyStoreGetLocalIdentityKeyPair)(void *ctx, SignalPairOfMutPointerPrivateKeyMutPointerPublicKey *out);
|
||||
|
||||
typedef int (*SignalFfiBridgeIdentityKeyStoreGetLocalRegistrationId)(void *ctx, uint32_t *out);
|
||||
|
||||
typedef int (*SignalFfiBridgeIdentityKeyStoreGetIdentityKey)(void *ctx, SignalMutPointerPublicKey *out, SignalMutPointerProtocolAddress address);
|
||||
|
||||
typedef int (*SignalFfiBridgeIdentityKeyStoreSaveIdentityKey)(void *ctx, uint8_t *out, SignalMutPointerProtocolAddress address, SignalMutPointerPublicKey public_key);
|
||||
|
|
@ -800,7 +794,7 @@ typedef void (*SignalFfiBridgeIdentityKeyStoreDestroy)(void *ctx);
|
|||
|
||||
typedef struct {
|
||||
void *ctx;
|
||||
SignalFfiBridgeIdentityKeyStoreGetLocalIdentityKeyPair get_local_identity_key_pair;
|
||||
SignalFfiBridgeIdentityKeyStoreGetLocalIdentityPrivateKey get_local_identity_private_key;
|
||||
SignalFfiBridgeIdentityKeyStoreGetLocalRegistrationId get_local_registration_id;
|
||||
SignalFfiBridgeIdentityKeyStoreGetIdentityKey get_identity_key;
|
||||
SignalFfiBridgeIdentityKeyStoreSaveIdentityKey save_identity_key;
|
||||
|
|
@ -999,21 +993,6 @@ typedef struct {
|
|||
size_t length;
|
||||
} SignalOwnedBufferOfServiceIdFixedWidthBinaryBytes;
|
||||
|
||||
typedef struct {
|
||||
SignalPreKeyBundle *raw;
|
||||
} SignalMutPointerPreKeyBundle;
|
||||
|
||||
/**
|
||||
* A representation of a array allocated on the Rust heap for use in C code.
|
||||
*/
|
||||
typedef struct {
|
||||
SignalMutPointerPreKeyBundle *base;
|
||||
/**
|
||||
* The number of elements in the buffer (not necessarily the number of bytes).
|
||||
*/
|
||||
size_t length;
|
||||
} SignalOwnedBufferOfMutPointerPreKeyBundle;
|
||||
|
||||
typedef struct {
|
||||
SignalSenderKeyRecord *raw;
|
||||
} SignalMutPointerSenderKeyRecord;
|
||||
|
|
@ -1211,6 +1190,10 @@ typedef struct {
|
|||
SignalPlaintextContent *raw;
|
||||
} SignalMutPointerPlaintextContent;
|
||||
|
||||
typedef struct {
|
||||
SignalPreKeyBundle *raw;
|
||||
} SignalMutPointerPreKeyBundle;
|
||||
|
||||
typedef struct {
|
||||
const SignalPreKeyBundle *raw;
|
||||
} SignalConstPointerPreKeyBundle;
|
||||
|
|
@ -1540,26 +1523,6 @@ typedef struct {
|
|||
SignalCancellationId cancellation_id;
|
||||
} SignalCPromiseMutPointerUnauthenticatedChatConnection;
|
||||
|
||||
typedef struct {
|
||||
SignalMutPointerPublicKey identity_key;
|
||||
SignalOwnedBufferOfMutPointerPreKeyBundle pre_key_bundles;
|
||||
} SignalFfiPreKeysResponse;
|
||||
|
||||
/**
|
||||
* A C callback used to report the results of Rust futures.
|
||||
*
|
||||
* cbindgen will produce independent C types like `SignalCPromisei32` and
|
||||
* `SignalCPromiseProtocolAddress`.
|
||||
*
|
||||
* This derives Copy because it behaves like a C type; nevertheless, a promise should still only be
|
||||
* completed once.
|
||||
*/
|
||||
typedef struct {
|
||||
void (*complete)(SignalFfiError *error, const SignalFfiPreKeysResponse *result, const void *context);
|
||||
const void *context;
|
||||
SignalCancellationId cancellation_id;
|
||||
} SignalCPromiseFfiPreKeysResponse;
|
||||
|
||||
/**
|
||||
* A C callback used to report the results of Rust futures.
|
||||
*
|
||||
|
|
@ -1955,13 +1918,6 @@ void signal_free_list_of_strings(SignalOwnedBufferOfCStringPtr buffer);
|
|||
|
||||
void signal_free_lookup_response_entry_list(SignalOwnedBufferOfFfiCdsiLookupResponseEntry buffer);
|
||||
|
||||
/**
|
||||
* This frees a buffer of PreKeyBundle pointers, and _does not_ free the
|
||||
* pointers within the buffer. This _only_ frees the buffer containing
|
||||
* the pointers.
|
||||
*/
|
||||
void signal_free_outer_buffer_list_of_prekey_bundles(SignalOwnedBufferOfMutPointerPreKeyBundle buffer);
|
||||
|
||||
void signal_free_string(const char *buf);
|
||||
|
||||
SignalFfiError *signal_generic_server_public_params_check_valid_contents(SignalBorrowedBuffer params_bytes);
|
||||
|
|
@ -2730,10 +2686,6 @@ SignalFfiError *signal_unauthenticated_chat_connection_destroy(SignalMutPointerU
|
|||
|
||||
SignalFfiError *signal_unauthenticated_chat_connection_disconnect(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat);
|
||||
|
||||
SignalFfiError *signal_unauthenticated_chat_connection_get_pre_keys_access_group_auth(SignalCPromiseFfiPreKeysResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, SignalBorrowedBuffer auth, const SignalServiceIdFixedWidthBinaryBytes *target, int32_t device);
|
||||
|
||||
SignalFfiError *signal_unauthenticated_chat_connection_get_pre_keys_access_key_auth(SignalCPromiseFfiPreKeysResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, const uint8_t (*auth)[16], const SignalServiceIdFixedWidthBinaryBytes *target, int32_t device);
|
||||
|
||||
SignalFfiError *signal_unauthenticated_chat_connection_info(SignalMutPointerChatConnectionInfo *out, SignalConstPointerUnauthenticatedChatConnection chat);
|
||||
|
||||
SignalFfiError *signal_unauthenticated_chat_connection_init_listener(SignalConstPointerUnauthenticatedChatConnection chat, SignalConstPointerFfiChatListenerStruct listener);
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
package libsignalgo
|
||||
|
||||
const Version = "v0.89.1"
|
||||
const Version = "v0.87.5"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue