CoreCryptoContextProtocol
public protocol CoreCryptoContextProtocol : AnyObject, Sendable
The CoreCryptoContext holds the primary CoreCrypto APIs.
An instance of this struct is provided to the function handed to CoreCrypto::transaction.
Every mutable operation is done through this struct. This struct will buffer all operations in memory and when [TransactionContext::finish] is called, it will persist the data into the keystore.
-
See [core_crypto::mls::conversation::ConversationGuard::add_members]
Declaration
Swift
func addClientsToConversation(conversationId: ConversationId, keyPackages: [KeyPackage]) async throws -> [String]? -
addCredential(credential:Asynchronous) Add a [
Credential][crate::Credential] to this client.Note that while an arbitrary number of credentials can be generated, those which are added to a CC instance must be distinct in credential type, signature scheme, and the timestamp of creation. This timestamp has only 1 second of resolution, limiting the number of credentials which can be added. This is a known limitation and will be relaxed in the future.
Declaration
Swift
func addCredential(credential: Credential) async throws -> CredentialRef -
See [core_crypto::transaction_context::TransactionContext::get_or_create_client_keypackages]
Declaration
Swift
func clientKeypackages(ciphersuite: Ciphersuite, credentialType: CredentialType, amountRequested: UInt32) async throws -> [KeyPackage] -
clientPublicKey(ciphersuite:AsynchronouscredentialType: ) See [core_crypto::transaction_context::TransactionContext::client_public_key]
Declaration
Swift
func clientPublicKey(ciphersuite: Ciphersuite, credentialType: CredentialType) async throws -> Data -
See [core_crypto::transaction_context::TransactionContext::client_valid_key_packages_count]
Declaration
Swift
func clientValidKeypackagesCount(ciphersuite: Ciphersuite, credentialType: CredentialType) async throws -> UInt64 -
commitPendingProposals(conversationId:Asynchronous) See [core_crypto::mls::conversation::ConversationGuard::commit_pending_proposals]
Declaration
Swift
func commitPendingProposals(conversationId: ConversationId) async throws -
conversationCiphersuite(conversationId:Asynchronous) See [core_crypto::mls::conversation::Conversation::ciphersuite]
Declaration
Swift
func conversationCiphersuite(conversationId: ConversationId) async throws -> Ciphersuite -
conversationEpoch(conversationId:Asynchronous) See [core_crypto::mls::conversation::Conversation::epoch]
Declaration
Swift
func conversationEpoch(conversationId: ConversationId) async throws -> UInt64 -
conversationExists(conversationId:Asynchronous) See [core_crypto::Session::conversation_exists]
Declaration
Swift
func conversationExists(conversationId: ConversationId) async throws -> Bool -
See [core_crypto::transaction_context::TransactionContext::new_conversation]
Declaration
Swift
func createConversation(conversationId: ConversationId, creatorCredentialType: CredentialType, config: ConversationConfiguration) async throws -
decryptMessage(conversationId:Asynchronouspayload: ) See [core_crypto::mls::conversation::ConversationGuard::decrypt_message]
Declaration
Swift
func decryptMessage(conversationId: ConversationId, payload: Data) async throws -> DecryptedMessage -
deleteStaleKeyPackages(ciphersuite:Asynchronous) See [core_crypto::transaction_context::TransactionContext::delete_stale_key_packages]
Declaration
Swift
func deleteStaleKeyPackages(ciphersuite: Ciphersuite) async throws -
disableHistorySharing(conversationId:Asynchronous) See [core_crypto::mls::conversation::ConversationGuard::disable_history_sharing]
Declaration
Swift
func disableHistorySharing(conversationId: ConversationId) async throws -
e2eiConversationState(conversationId:Asynchronous) See [core_crypto::mls::conversation::Conversation::e2ei_conversation_state]
Declaration
Swift
func e2eiConversationState(conversationId: ConversationId) async throws -> E2eiConversationState -
e2eiEnrollmentStash(enrollment:Asynchronous) See [core_crypto::transaction_context::TransactionContext::e2ei_enrollment_stash]
Note that this can only succeed if the enrollment is unique and there are no other hard refs to it.
Declaration
Swift
func e2eiEnrollmentStash(enrollment: E2eiEnrollment) async throws -> Data -
e2eiEnrollmentStashPop(handle:Asynchronous) See [core_crypto::transaction_context::TransactionContext::e2ei_enrollment_stash_pop]
Declaration
Swift
func e2eiEnrollmentStashPop(handle: Data) async throws -> E2eiEnrollment -
e2eiIsEnabled(ciphersuite:Asynchronous) See [core_crypto::Session::e2ei_is_enabled]
Declaration
Swift
func e2eiIsEnabled(ciphersuite: Ciphersuite) async throws -> Bool -
e2eiIsPkiEnvSetup()AsynchronousSee [core_crypto::Session::e2ei_is_pki_env_setup]
Declaration
Swift
func e2eiIsPkiEnvSetup() async throws -> Bool -
e2eiMlsInitOnly(enrollment:AsynchronouscertificateChain: ) See [core_crypto::transaction_context::TransactionContext::e2ei_mls_init_only]
Declaration
Swift
func e2eiMlsInitOnly(enrollment: E2eiEnrollment, certificateChain: String) async throws -> [String]? -
See [core_crypto::transaction_context::TransactionContext::e2ei_new_activation_enrollment]
Declaration
Swift
func e2eiNewActivationEnrollment(displayName: String, handle: String, team: String?, expirySec: UInt32, ciphersuite: Ciphersuite) async throws -> E2eiEnrollment -
See [core_crypto::transaction_context::TransactionContext::e2ei_new_enrollment]
Declaration
Swift
func e2eiNewEnrollment(clientId: String, displayName: String, handle: String, team: String?, expirySec: UInt32, ciphersuite: Ciphersuite) async throws -> E2eiEnrollment -
See [core_crypto::transaction_context::TransactionContext::e2ei_new_rotate_enrollment]
Declaration
Swift
func e2eiNewRotateEnrollment(displayName: String?, handle: String?, team: String?, expirySec: UInt32, ciphersuite: Ciphersuite) async throws -> E2eiEnrollment -
e2eiRegisterAcmeCa(trustAnchorPem:Asynchronous) See [core_crypto::transaction_context::TransactionContext::e2ei_register_acme_ca]
Declaration
Swift
func e2eiRegisterAcmeCa(trustAnchorPem: String) async throws -
e2eiRegisterCrl(crlDp:AsynchronouscrlDer: ) See [core_crypto::transaction_context::TransactionContext::e2ei_register_crl]
Declaration
Swift
func e2eiRegisterCrl(crlDp: String, crlDer: Data) async throws -> CrlRegistration -
e2eiRegisterIntermediateCa(certPem:Asynchronous) See [core_crypto::transaction_context::TransactionContext::e2ei_register_intermediate_ca_pem]
Declaration
Swift
func e2eiRegisterIntermediateCa(certPem: String) async throws -> [String]? -
e2eiRotate(conversationId:Asynchronous) See [core_crypto::mls::conversation::ConversationGuard::e2ei_rotate]
Declaration
Swift
func e2eiRotate(conversationId: ConversationId) async throws -
enableHistorySharing(conversationId:Asynchronous) See [core_crypto::mls::conversation::ConversationGuard::enable_history_sharing]
Declaration
Swift
func enableHistorySharing(conversationId: ConversationId) async throws -
encryptMessage(conversationId:Asynchronousmessage: ) See [core_crypto::mls::conversation::ConversationGuard::encrypt_message]
Declaration
Swift
func encryptMessage(conversationId: ConversationId, message: Data) async throws -> Data -
exportSecretKey(conversationId:AsynchronouskeyLength: ) See [core_crypto::mls::conversation::Conversation::export_secret_key]
Declaration
Swift
func exportSecretKey(conversationId: ConversationId, keyLength: UInt32) async throws -> SecretKey -
Get all credentials from this client which match the provided parameters.
Parameters which are unset or
Nonematch anything. Those with a particular value find only credentials matching that value.Declaration
Swift
func findCredentials(clientId: ClientId?, publicKey: Data?, ciphersuite: Ciphersuite?, credentialType: CredentialType?, earliestValidity: UInt64?) async throws -> [CredentialRef] -
getClientIds(conversationId:Asynchronous) See [core_crypto::mls::conversation::Conversation::get_client_ids]
Declaration
Swift
func getClientIds(conversationId: ConversationId) async throws -> [ClientId] -
getCredentials()AsynchronousGet all credentials from this client.
Declaration
Swift
func getCredentials() async throws -> [CredentialRef] -
getData()AsynchronousSee [core_crypto::transaction_context::TransactionContext::get_data]
Declaration
Swift
func getData() async throws -> Data? -
getDeviceIdentities(conversationId:AsynchronousdeviceIds: ) See [core_crypto::mls::conversation::Conversation::get_device_identities]
Declaration
Swift
func getDeviceIdentities(conversationId: ConversationId, deviceIds: [ClientId]) async throws -> [WireIdentity] -
getExternalSender(conversationId:Asynchronous) See [core_crypto::mls::conversation::Conversation::get_external_sender]
Declaration
Swift
func getExternalSender(conversationId: ConversationId) async throws -> ExternalSenderKey -
getUserIdentities(conversationId:AsynchronoususerIds: ) See [core_crypto::mls::conversation::Conversation::get_user_identities]
Declaration
Swift
func getUserIdentities(conversationId: ConversationId, userIds: [String]) async throws -> [String : [WireIdentity]] -
See [core_crypto::transaction_context::TransactionContext::join_by_external_commit]
Declaration
Swift
func joinByExternalCommit(groupInfo: GroupInfo, customConfiguration: CustomConfiguration, credentialType: CredentialType) async throws -> WelcomeBundle -
markConversationAsChildOf(childId:AsynchronousparentId: ) See [core_crypto::mls::conversation::ConversationGuard::mark_as_child_of]
Declaration
Swift
func markConversationAsChildOf(childId: ConversationId, parentId: ConversationId) async throws -
mlsInit(clientId:Asynchronousciphersuites: ) See [core_crypto::transaction_context::TransactionContext::mls_init]
Declaration
Swift
func mlsInit(clientId: ClientId, ciphersuites: [Ciphersuite]) async throws -
See [core_crypto::transaction_context::TransactionContext::process_raw_welcome_message]
Declaration
Swift
func processWelcomeMessage(welcomeMessage: Welcome, customConfiguration: CustomConfiguration) async throws -> WelcomeBundle -
proteusDecrypt(sessionId:Asynchronousciphertext: ) See [core_crypto::transaction_context::TransactionContext::proteus_decrypt]
Declaration
Swift
func proteusDecrypt(sessionId: String, ciphertext: Data) async throws -> Data -
proteusDecryptSafe(sessionId:Asynchronousciphertext: ) Decrypt a message whether or not the proteus session already exists, and saves the session.
This is intended to replace simple usages of
proteusDecrypt.However, when decrypting large numbers of messages in a single session, the existing methods may be more efficient.
Declaration
Swift
func proteusDecryptSafe(sessionId: String, ciphertext: Data) async throws -> Data -
proteusEncrypt(sessionId:Asynchronousplaintext: ) See [core_crypto::transaction_context::TransactionContext::proteus_encrypt]
Declaration
Swift
func proteusEncrypt(sessionId: String, plaintext: Data) async throws -> Data -
proteusEncryptBatched(sessions:Asynchronousplaintext: ) See [core_crypto::transaction_context::TransactionContext::proteus_encrypt_batched]
Declaration
Swift
func proteusEncryptBatched(sessions: [String], plaintext: Data) async throws -> [String : Data] -
proteusFingerprint()AsynchronousSee [core_crypto::transaction_context::TransactionContext::proteus_fingerprint]
Declaration
Swift
func proteusFingerprint() async throws -> String -
proteusFingerprintLocal(sessionId:Asynchronous) See [core_crypto::transaction_context::TransactionContext::proteus_fingerprint_local]
Declaration
Swift
func proteusFingerprintLocal(sessionId: String) async throws -> String -
proteusFingerprintRemote(sessionId:Asynchronous) See [core_crypto::transaction_context::TransactionContext::proteus_fingerprint_remote]
Declaration
Swift
func proteusFingerprintRemote(sessionId: String) async throws -> String -
proteusInit()AsynchronousSee [core_crypto::proteus::ProteusCentral::try_new]
Declaration
Swift
func proteusInit() async throws -
proteusLastResortPrekey()AsynchronousSee [core_crypto::transaction_context::TransactionContext::proteus_last_resort_prekey]
Declaration
Swift
func proteusLastResortPrekey() async throws -> Data -
proteusNewPrekey(prekeyId:Asynchronous) Creates a new Proteus prekey with the given id and returns the CBOR-serialized version of the prekey bundle
Warning: The Proteus client MUST be initialized with
proteus_initfirst or an error will be returnedSee [core_crypto::transaction_context::TransactionContext::proteus_new_prekey]
Declaration
Swift
func proteusNewPrekey(prekeyId: UInt16) async throws -> Data -
proteusNewPrekeyAuto()AsynchronousCreates a new Proteus prekey with an automatically incremented ID and returns the CBOR-serialized version of the prekey bundle
Warning: The Proteus client MUST be initialized with
proteus_initfirst or an error will be returnedSee [core_crypto::transaction_context::TransactionContext::proteus_new_prekey_auto]
Declaration
Swift
func proteusNewPrekeyAuto() async throws -> ProteusAutoPrekeyBundle -
proteusReloadSessions()AsynchronousSee [core_crypto::transaction_context::TransactionContext::proteus_reload_sessions]
Declaration
Swift
func proteusReloadSessions() async throws -
proteusSessionDelete(sessionId:Asynchronous) See [core_crypto::transaction_context::TransactionContext::proteus_session_delete]
Declaration
Swift
func proteusSessionDelete(sessionId: String) async throws -
proteusSessionExists(sessionId:Asynchronous) See [core_crypto::transaction_context::TransactionContext::proteus_session_exists]
Declaration
Swift
func proteusSessionExists(sessionId: String) async throws -> Bool -
proteusSessionFromMessage(sessionId:Asynchronousenvelope: ) See [core_crypto::transaction_context::TransactionContext::proteus_session_from_message]
Declaration
Swift
func proteusSessionFromMessage(sessionId: String, envelope: Data) async throws -> Data -
proteusSessionFromPrekey(sessionId:Asynchronousprekey: ) See [core_crypto::transaction_context::TransactionContext::proteus_session_from_prekey]
Declaration
Swift
func proteusSessionFromPrekey(sessionId: String, prekey: Data) async throws -
proteusSessionSave(sessionId:Asynchronous) See [core_crypto::transaction_context::TransactionContext::proteus_session_save]
Note: This isn’t usually needed as persisting sessions happens automatically when decrypting/encrypting messages and initializing Sessions
Declaration
Swift
func proteusSessionSave(sessionId: String) async throws -
randomBytes(len:Asynchronous) See [core_crypto::Session::random_bytes].
Declaration
Swift
func randomBytes(len: UInt32) async throws -> Data -
See [core_crypto::mls::conversation::ConversationGuard::remove_members]
Declaration
Swift
func removeClientsFromConversation(conversationId: ConversationId, clients: [ClientId]) async throws -
removeCredential(credentialRef:Asynchronous) Remove a [
Credential][crate::Credential] from this client.Declaration
Swift
func removeCredential(credentialRef: CredentialRef) async throws -
saveX509Credential(enrollment:AsynchronouscertificateChain: ) See [core_crypto::transaction_context::TransactionContext::save_x509_credential]
Declaration
Swift
func saveX509Credential(enrollment: E2eiEnrollment, certificateChain: String) async throws -> [String]? -
setData(data:Asynchronous) See [core_crypto::transaction_context::TransactionContext::set_data]
Declaration
Swift
func setData(data: Data) async throws -
updateKeyingMaterial(conversationId:Asynchronous) See [core_crypto::mls::conversation::ConversationGuard::update_key_material]
Declaration
Swift
func updateKeyingMaterial(conversationId: ConversationId) async throws -
wipeConversation(conversationId:Asynchronous) See [core_crypto::mls::conversation::ConversationGuard::wipe]
Declaration
Swift
func wipeConversation(conversationId: ConversationId) async throws