core_crypto_ffi/generic/context/
proteus.rsuse crate::ProteusAutoPrekeyBundle;
use crate::context::CoreCryptoContext;
use crate::generic::CoreCryptoResult;
use crate::proteus_impl;
#[uniffi::export]
impl CoreCryptoContext {
pub async fn proteus_init(&self) -> CoreCryptoResult<()> {
proteus_impl!({
self.context.proteus_init().await?;
Ok(())
})
}
pub async fn proteus_session_from_prekey(&self, session_id: String, prekey: Vec<u8>) -> CoreCryptoResult<()> {
proteus_impl!({
self.context.proteus_session_from_prekey(&session_id, &prekey).await?;
Ok(())
})
}
pub async fn proteus_session_from_message(
&self,
session_id: String,
envelope: Vec<u8>,
) -> CoreCryptoResult<Vec<u8>> {
proteus_impl!({
let (_, payload) = self
.context
.proteus_session_from_message(&session_id, &envelope)
.await?;
Ok(payload)
})
}
pub async fn proteus_session_save(&self, session_id: String) -> CoreCryptoResult<()> {
proteus_impl!({ Ok(self.context.proteus_session_save(&session_id).await?) })
}
pub async fn proteus_session_delete(&self, session_id: String) -> CoreCryptoResult<()> {
proteus_impl!({ Ok(self.context.proteus_session_delete(&session_id).await?) })
}
pub async fn proteus_session_exists(&self, session_id: String) -> CoreCryptoResult<bool> {
proteus_impl!({ Ok(self.context.proteus_session_exists(&session_id).await?) })
}
pub async fn proteus_decrypt(&self, session_id: String, ciphertext: Vec<u8>) -> CoreCryptoResult<Vec<u8>> {
proteus_impl!({ Ok(self.context.proteus_decrypt(&session_id, &ciphertext).await?) })
}
pub async fn proteus_encrypt(&self, session_id: String, plaintext: Vec<u8>) -> CoreCryptoResult<Vec<u8>> {
proteus_impl!({ Ok(self.context.proteus_encrypt(&session_id, &plaintext).await?) })
}
pub async fn proteus_encrypt_batched(
&self,
sessions: Vec<String>,
plaintext: Vec<u8>,
) -> CoreCryptoResult<std::collections::HashMap<String, Vec<u8>>> {
proteus_impl!({ Ok(self.context.proteus_encrypt_batched(&sessions, &plaintext).await?) })
}
pub async fn proteus_new_prekey(&self, prekey_id: u16) -> CoreCryptoResult<Vec<u8>> {
proteus_impl!({ CoreCryptoResult::Ok(self.context.proteus_new_prekey(prekey_id).await?) })
}
pub async fn proteus_new_prekey_auto(&self) -> CoreCryptoResult<ProteusAutoPrekeyBundle> {
proteus_impl!({
let (id, pkb) = self.context.proteus_new_prekey_auto().await?;
CoreCryptoResult::Ok(ProteusAutoPrekeyBundle { id, pkb })
})
}
pub async fn proteus_last_resort_prekey(&self) -> CoreCryptoResult<Vec<u8>> {
proteus_impl!({ Ok(self.context.proteus_last_resort_prekey().await?) })
}
pub fn proteus_last_resort_prekey_id(&self) -> CoreCryptoResult<u16> {
proteus_impl!({ Ok(core_crypto::CoreCrypto::proteus_last_resort_prekey_id()) })
}
pub async fn proteus_fingerprint(&self) -> CoreCryptoResult<String> {
proteus_impl!({ Ok(self.context.proteus_fingerprint().await?) })
}
pub async fn proteus_fingerprint_local(&self, session_id: String) -> CoreCryptoResult<String> {
proteus_impl!({ Ok(self.context.proteus_fingerprint_local(&session_id).await?) })
}
pub async fn proteus_fingerprint_remote(&self, session_id: String) -> CoreCryptoResult<String> {
proteus_impl!({ Ok(self.context.proteus_fingerprint_remote(&session_id).await?) })
}
pub fn proteus_fingerprint_prekeybundle(&self, prekey: Vec<u8>) -> CoreCryptoResult<String> {
proteus_impl!({ Ok(core_crypto::proteus::ProteusCentral::fingerprint_prekeybundle(&prekey)?) })
}
pub async fn proteus_cryptobox_migrate(&self, path: String) -> CoreCryptoResult<()> {
proteus_impl!({ Ok(self.context.proteus_cryptobox_migrate(&path).await?) })
}
}