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"
|
#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_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_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);
|
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
|
//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 {
|
return wrapStoreCallback(storeCtx, func(store IdentityKeyStore, ctx context.Context) error {
|
||||||
key, err := store.GetIdentityKeyPair(ctx)
|
key, err := store.GetIdentityKeyPair(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if key == nil {
|
if key == nil {
|
||||||
keyp.first.raw = nil
|
keyp.raw = nil
|
||||||
keyp.second.raw = nil
|
} else {
|
||||||
return nil
|
clone, err := key.privateKey.Clone()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
clone.CancelFinalizer()
|
||||||
|
keyp.raw = clone.ptr
|
||||||
}
|
}
|
||||||
privClone, err := key.privateKey.Clone()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
pubClone, err := key.publicKey.Clone()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
privClone.CancelFinalizer()
|
|
||||||
pubClone.CancelFinalizer()
|
|
||||||
keyp.first.raw = privClone.ptr
|
|
||||||
keyp.second.raw = pubClone.ptr
|
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -158,12 +151,12 @@ func signal_destroy_identity_key_store_callback(storeCtx unsafe.Pointer) {
|
||||||
|
|
||||||
func (ctx *CallbackContext) wrapIdentityKeyStore(store IdentityKeyStore) C.SignalConstPointerFfiIdentityKeyStoreStruct {
|
func (ctx *CallbackContext) wrapIdentityKeyStore(store IdentityKeyStore) C.SignalConstPointerFfiIdentityKeyStoreStruct {
|
||||||
return C.SignalConstPointerFfiIdentityKeyStoreStruct{&C.SignalIdentityKeyStore{
|
return C.SignalConstPointerFfiIdentityKeyStoreStruct{&C.SignalIdentityKeyStore{
|
||||||
ctx: wrapStore(ctx, store),
|
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_local_registration_id: C.SignalFfiBridgeIdentityKeyStoreGetLocalRegistrationId(C.signal_get_local_registration_id_callback),
|
||||||
get_identity_key: C.SignalFfiBridgeIdentityKeyStoreGetIdentityKey(C.signal_get_identity_key_callback),
|
get_identity_key: C.SignalFfiBridgeIdentityKeyStoreGetIdentityKey(C.signal_get_identity_key_callback),
|
||||||
save_identity_key: C.SignalFfiBridgeIdentityKeyStoreSaveIdentityKey(C.signal_save_identity_key_callback),
|
save_identity_key: C.SignalFfiBridgeIdentityKeyStoreSaveIdentityKey(C.signal_save_identity_key_callback),
|
||||||
is_trusted_identity: C.SignalFfiBridgeIdentityKeyStoreIsTrustedIdentity(C.signal_is_trusted_identity_callback),
|
is_trusted_identity: C.SignalFfiBridgeIdentityKeyStoreIsTrustedIdentity(C.signal_is_trusted_identity_callback),
|
||||||
destroy: C.SignalFfiBridgeIdentityKeyStoreDestroy(C.signal_destroy_identity_key_store_callback),
|
destroy: C.SignalFfiBridgeIdentityKeyStoreDestroy(C.signal_destroy_identity_key_store_callback),
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit a5e76674882a89bac1ed3f4a982120652966d21e
|
Subproject commit ffaa9f0435569d6775d8be636f268f882ed67ce3
|
||||||
|
|
@ -260,7 +260,6 @@ typedef enum {
|
||||||
SignalErrorCodeKeyTransparencyVerificationFailed = 211,
|
SignalErrorCodeKeyTransparencyVerificationFailed = 211,
|
||||||
SignalErrorCodeRequestUnauthorized = 220,
|
SignalErrorCodeRequestUnauthorized = 220,
|
||||||
SignalErrorCodeMismatchedDevices = 221,
|
SignalErrorCodeMismatchedDevices = 221,
|
||||||
SignalErrorCodeServiceIdNotFound = 222,
|
|
||||||
} SignalErrorCode;
|
} SignalErrorCode;
|
||||||
|
|
||||||
enum SignalSvr2CredentialsResult {
|
enum SignalSvr2CredentialsResult {
|
||||||
|
|
@ -777,19 +776,14 @@ typedef struct {
|
||||||
const SignalSessionStore *raw;
|
const SignalSessionStore *raw;
|
||||||
} SignalConstPointerFfiSessionStoreStruct;
|
} SignalConstPointerFfiSessionStoreStruct;
|
||||||
|
|
||||||
|
typedef int (*SignalFfiBridgeIdentityKeyStoreGetLocalIdentityPrivateKey)(void *ctx, SignalMutPointerPrivateKey *out);
|
||||||
|
|
||||||
|
typedef int (*SignalFfiBridgeIdentityKeyStoreGetLocalRegistrationId)(void *ctx, uint32_t *out);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SignalPublicKey *raw;
|
SignalPublicKey *raw;
|
||||||
} SignalMutPointerPublicKey;
|
} 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 (*SignalFfiBridgeIdentityKeyStoreGetIdentityKey)(void *ctx, SignalMutPointerPublicKey *out, SignalMutPointerProtocolAddress address);
|
||||||
|
|
||||||
typedef int (*SignalFfiBridgeIdentityKeyStoreSaveIdentityKey)(void *ctx, uint8_t *out, SignalMutPointerProtocolAddress address, SignalMutPointerPublicKey public_key);
|
typedef int (*SignalFfiBridgeIdentityKeyStoreSaveIdentityKey)(void *ctx, uint8_t *out, SignalMutPointerProtocolAddress address, SignalMutPointerPublicKey public_key);
|
||||||
|
|
@ -800,7 +794,7 @@ typedef void (*SignalFfiBridgeIdentityKeyStoreDestroy)(void *ctx);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *ctx;
|
void *ctx;
|
||||||
SignalFfiBridgeIdentityKeyStoreGetLocalIdentityKeyPair get_local_identity_key_pair;
|
SignalFfiBridgeIdentityKeyStoreGetLocalIdentityPrivateKey get_local_identity_private_key;
|
||||||
SignalFfiBridgeIdentityKeyStoreGetLocalRegistrationId get_local_registration_id;
|
SignalFfiBridgeIdentityKeyStoreGetLocalRegistrationId get_local_registration_id;
|
||||||
SignalFfiBridgeIdentityKeyStoreGetIdentityKey get_identity_key;
|
SignalFfiBridgeIdentityKeyStoreGetIdentityKey get_identity_key;
|
||||||
SignalFfiBridgeIdentityKeyStoreSaveIdentityKey save_identity_key;
|
SignalFfiBridgeIdentityKeyStoreSaveIdentityKey save_identity_key;
|
||||||
|
|
@ -999,21 +993,6 @@ typedef struct {
|
||||||
size_t length;
|
size_t length;
|
||||||
} SignalOwnedBufferOfServiceIdFixedWidthBinaryBytes;
|
} 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 {
|
typedef struct {
|
||||||
SignalSenderKeyRecord *raw;
|
SignalSenderKeyRecord *raw;
|
||||||
} SignalMutPointerSenderKeyRecord;
|
} SignalMutPointerSenderKeyRecord;
|
||||||
|
|
@ -1211,6 +1190,10 @@ typedef struct {
|
||||||
SignalPlaintextContent *raw;
|
SignalPlaintextContent *raw;
|
||||||
} SignalMutPointerPlaintextContent;
|
} SignalMutPointerPlaintextContent;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SignalPreKeyBundle *raw;
|
||||||
|
} SignalMutPointerPreKeyBundle;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const SignalPreKeyBundle *raw;
|
const SignalPreKeyBundle *raw;
|
||||||
} SignalConstPointerPreKeyBundle;
|
} SignalConstPointerPreKeyBundle;
|
||||||
|
|
@ -1540,26 +1523,6 @@ typedef struct {
|
||||||
SignalCancellationId cancellation_id;
|
SignalCancellationId cancellation_id;
|
||||||
} SignalCPromiseMutPointerUnauthenticatedChatConnection;
|
} 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.
|
* 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);
|
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);
|
void signal_free_string(const char *buf);
|
||||||
|
|
||||||
SignalFfiError *signal_generic_server_public_params_check_valid_contents(SignalBorrowedBuffer params_bytes);
|
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_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_info(SignalMutPointerChatConnectionInfo *out, SignalConstPointerUnauthenticatedChatConnection chat);
|
||||||
|
|
||||||
SignalFfiError *signal_unauthenticated_chat_connection_init_listener(SignalConstPointerUnauthenticatedChatConnection chat, SignalConstPointerFfiChatListenerStruct listener);
|
SignalFfiError *signal_unauthenticated_chat_connection_init_listener(SignalConstPointerUnauthenticatedChatConnection chat, SignalConstPointerFfiChatListenerStruct listener);
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
package libsignalgo
|
package libsignalgo
|
||||||
|
|
||||||
const Version = "v0.89.1"
|
const Version = "v0.87.5"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue