Sailfish OS
  • Info
  • User Experience
  • Cases
  • Community
  • Developers
  • Contact
  • Get Sailfish OS
Select Page
  • Info
  • User Experience
  • Cases
  • Community
  • Developers
  • Contact
  • Get Sailfish OS

Sailfish Crypto

API Documentation
  • API Documentation
  • Libsailfishapp
  • Sailfish Silica
    • Documentation
    • Icon Reference
  • Sailfish Components
    • Sailfish Accounts
    • Sailfish Bluetooth
    • Sailfish Contacts
    • Sailfish Crypto
    • Sailfish Gallery
    • Sailfish Media
    • Sailfish Pickers
    • Sailfish Secrets
    • Sailfish Share
    • Sailfish Telephony
    • Sailfish Webview
    • Amber Web Authorization
    • Amber MPRIS
  • Nemo QML Plugins
    • Configuration
    • Contacts
    • D-Bus
    • Keepalive
    • Notifications
    • Thumbnailer
  • Sailfish Middleware
    • MDM Framework
    • MDM Policy Framework
    • User Manager Daemon
  • API Documentation
  • Libsailfishapp
  • Sailfish Silica
    • Documentation
    • Icon Reference
  • Sailfish Components
    • Sailfish Accounts
    • Sailfish Bluetooth
    • Sailfish Contacts
    • Sailfish Crypto
    • Sailfish Gallery
    • Sailfish Media
    • Sailfish Pickers
    • Sailfish Secrets
    • Sailfish Share
    • Sailfish Telephony
    • Sailfish Webview
    • Amber Web Authorization
    • Amber MPRIS
  • Nemo QML Plugins
    • Configuration
    • Contacts
    • D-Bus
    • Keepalive
    • Notifications
    • Thumbnailer
  • Sailfish Middleware
    • MDM Framework
    • MDM Policy Framework
    • User Manager Daemon

Contents

  • Default Crypto Plugins
  • Which Plugin Should My Application Use?
  • Implementing your own plugin

Default Crypto Plugins for the Sailfish OS Secrets and Crypto Framework

A number of plugins have been written for the framework which provide a variety of functionality for clients to use. Most clients should use the platform default plugins when writing their applications, as these will provide the most consistent and secure experience.

Device vendors and trusted partners may wish to provide their own plugins, and some applications may wish to specifically use those plugins.

Default Crypto Plugins

Currently, there are two Sailfish OS Crypto plugins shipped by default:

  • org.sailfishos.crypto.plugin.crypto.openssl
  • org.sailfishos.secrets.plugin.encryptedstorage.sqlcipher

The first plugin provides implementations of common cryptography functionality by calling the OpenSSL library functions internally.

The second plugin shares its cryptography implementation with the first plugin, but also provides block-level encrypted secure storage of collections of secrets, using the SQLCipher library for its database operations. Thus it is both a Sailfish::Crypto::CryptoPlugin and a Sailfish::Secrets::EncryptedStoragePlugin, also known as a Crypto-Storage plugin.

Note that neither of these plugins use TEE/TPM or other secure-hardware to implement the cryptographic functionality.

Which Plugin Should My Application Use?

We recommend that the system default Crypto-Storage plugin be used where possible. In most cases, this will be the "org.sailfishos.secrets.plugin.encryptedstorage.sqlcipher" plugin.

The following snippet shows an example of using the default crypto storage plugin to create a symmetric key, and store it in an encrypted database managed by that same plugin:

 // Set the key template metadata.
 Sailfish::Crypto::Key keyTemplate, symmetricKeyReference;
 keyTemplate.setAlgorithm(Sailfish::Crypto::CryptoManager::AlgorithmAes);
 keyTemplate.setSize(256);
 keyTemplate.setOrigin(Sailfish::Crypto::Key::OriginDevice);
 keyTemplate.setOperations(Sailfish::Crypto::CryptoManager::OperationEncrypt
                          |Sailfish::Crypto::CryptoManager::OperationDecrypt);

 // Set the identifier for the key.
 // This assumes the existence of an "ExampleCollection" secure storage
 // collection, in which the key will be stored.
 // See Sailfish::Secrets::CreateCollectionRequest.
 keyTemplate.setIdentifier(
         Sailfish::Crytpo::Key::Identifier(
                 QStringLiteral("ExampleKey"),
                 QStringLiteral("ExampleCollection"),
                 Sailfish::Crypto::CryptoManager::DefaultCryptoStoragePluginName));

 // Ask the system service to generate and store the key securely.
 Sailfish::Crypto::CryptoManager cm;
 Sailfish::Crypto::GenerateStoredKeyRequest generateRequest;
 generateRequest.setManager(&cm);
 generateRequest.setKeyTemplate(keyTemplate);
 generateRequest.setCryptoPluginName(Sailfish::Crypto::CryptoManager::DefaultCryptoStoragePluginName);
 generateRequest.startRequest();
 generateRequest.waitForFinished();
 if (generateRequest.result().code() == Sailfish::Crypto::Result::Failed) {
     qWarning() << "Unable to generate and store symmetric key:"
                << generateRequest.result().errorMessage();
 } else {
     symmetricKeyReference = generateRequest.generatedKeyReference();
 }

Note that this example assumes that the "ExampleCollection" had already been created, via a Sailfish::Secrets::CreateCollectionRequest.

Implementing your own plugin

Please see the documentation for Sailfish::Crypto::CryptoPlugin for more information about implementing your own custom plugin.

An example (skeleton) Crypto plugin without key storage capability may be found at: https://github.com/sailfishos/sailfish-secrets/tree/master/examples/plugins/examplecryptoplugin/

An example (skeleton) Crypto Storage plugin may be found at: https://github.com/sailfishos/sailfish-secrets/tree/master/examples/plugins/examplecryptostorageplugin/

  • Legal
  • Contact Us
  • Jolla Mobile Ltd © 2025

  • Facebook
  • Twitter
  • Mastodon
  • YouTube
  • LinkedIn