Sailfish Crypto
API DocumentationImportStoredKeyRequest Class
(Sailfish::Crypto::ImportStoredKeyRequest)Allows a client request that the system crypto service import and securely store a key. More...
Header: | #include <Crypto/importstoredkeyrequest.h> |
Instantiated By: | ImportStoredKeyRequest |
Inherits: | Sailfish::Crypto::Request |
Properties
|
|
- 4 properties inherited from Sailfish::Crypto::Request
Public Functions
ImportStoredKeyRequest(QObject *parent = Q_NULLPTR) | |
~ImportStoredKeyRequest() | |
QString | cryptoPluginName() const |
QByteArray | data() const |
Sailfish::Crypto::Key | importedKeyReference() const |
Sailfish::Crypto::InteractionParameters | interactionParameters() const |
Sailfish::Crypto::Key | keyTemplate() const |
void | setCryptoPluginName(const QString &pluginName) |
void | setData(const QByteArray &data) |
void | setInteractionParameters(const Sailfish::Crypto::InteractionParameters &uiParams) |
void | setKeyTemplate(const Sailfish::Crypto::Key &keyTemplate) |
Reimplemented Public Functions
virtual QVariantMap | customParameters() const |
virtual Sailfish::Crypto::CryptoManager * | manager() const |
virtual Sailfish::Crypto::Result | result() const |
virtual void | setCustomParameters(const QVariantMap ¶ms) |
virtual void | setManager(Sailfish::Crypto::CryptoManager *manager) |
virtual void | startRequest() |
virtual Sailfish::Crypto::Request::Status | status() const |
virtual void | waitForFinished() |
- 8 public functions inherited from Sailfish::Crypto::Request
Signals
void | cryptoPluginNameChanged() |
void | dataChanged() |
void | importedKeyReferenceChanged() |
void | interactionParametersChanged() |
void | keyTemplateChanged() |
- 4 signals inherited from Sailfish::Crypto::Request
Detailed Description
Allows a client request that the system crypto service import and securely store a key.
The imported key will be stored securely by the crypto daemon into the storage plugin identified by the storage plugin specified in the key template's identifier, and the returned key reference will not contain any private or secret key data.
Available storage providers can be enumerated from the Sailfish Secrets API.
If the cryptoPluginName() and the storage plugin specified in the identifier of the keyTemplate() are the same, then the key will be stored in storage managed by the crypto provider plugin, if that plugin supports storing keys. In that case, the crypto plugin must also be a Sailfish::Secrets::EncryptedStoragePlugin. Such crypto storage plugins can enforce key component readability constraints, and allow cryptographic operations to occur in the most secure manner possible.
An example of importing a public key from a .pem file and storing securely follows:
// Read the PEM data from the file. QFile pemFile("/path/to/file.pem"); if (!pemFile.open(QIODevice::ReadOnly)) { qWarning() << "Unable to open file for reading."; return; } const QByteArray pemData = pemFile.readAll(); // Set interaction parameters for the passphrase prompt // if a passphrase is required to decrypt the key from .pem. Sailfish::Crypto::InteractionParameters uiParams; uiParams.setInputType(Sailfish::Crypto::InteractionParameters::AlphaNumericInput); uiParams.setEchoMode(Sailfish::Crypto::InteractionParameters::NormalEcho); // Define the key metadata via a template. Sailfish::Crypto::Key keyTemplate; keyTemplate.setOperations(Sailfish::Crypto::CryptoManager::OperationEncrypt |Sailfish::Crypto::CryptoManager::OperationVerify); keyTemplate.setComponentConstraints(Sailfish::Crypto::Key::MetaData |Sailfish::Crypto::Key::PublicKeyData); keyTemplate.setIdentifier( Sailfish::Crypto::Key::Identifier( QLatin1String("ExampleImportedKey"), QLatin1String("ExampleCollection"), Sailfish::Crypto::CryptoManager::DefaultCryptoStoragePluginName))); // Ask the crypto service to perform the required operations. Sailfish::Crypto::ImportStoredKeyRequest iskr; iskr.setManager(cryptoManager); iskr.setCryptoPluginName(Sailfish::Crypto::CryptoManager::DefaultCryptoStoragePluginName); iskr.setInteractionParameters(uiParams); iskr.setKeyTemplate(keyTemplate); iskr.setData(pemData); iskr.startRequest();
Property Documentation
cryptoPluginName : QString
Access functions:
QString | cryptoPluginName() const |
void | setCryptoPluginName(const QString &pluginName) |
Notifier signal:
void | cryptoPluginNameChanged() |
data : QByteArray
Access functions:
Notifier signal:
void | dataChanged() |
importedKeyReference : const Sailfish::Crypto::Key
Access functions:
Sailfish::Crypto::Key | importedKeyReference() const |
Notifier signal:
void | importedKeyReferenceChanged() |
interactionParameters : Sailfish::Crypto::InteractionParameters
Access functions:
Sailfish::Crypto::InteractionParameters | interactionParameters() const |
void | setInteractionParameters(const Sailfish::Crypto::InteractionParameters &uiParams) |
Notifier signal:
void | interactionParametersChanged() |
keyTemplate : Sailfish::Crypto::Key
Access functions:
Sailfish::Crypto::Key | keyTemplate() const |
void | setKeyTemplate(const Sailfish::Crypto::Key &keyTemplate) |
Notifier signal:
void | keyTemplateChanged() |
Member Function Documentation
ImportStoredKeyRequest::ImportStoredKeyRequest(QObject *parent = Q_NULLPTR)
Constructs a new ImportStoredKeyRequest object with the given parent.
ImportStoredKeyRequest::~ImportStoredKeyRequest()
Destroys the ImportStoredKeyRequest
QString ImportStoredKeyRequest::cryptoPluginName() const
Returns the name of the crypto plugin which the client wishes to perform the key generation operation
Note: Getter function for property cryptoPluginName.
See also setCryptoPluginName().
[virtual]
QVariantMap ImportStoredKeyRequest::customParameters() const
See also setCustomParameters().
QByteArray ImportStoredKeyRequest::data() const
Returns the data which should be imported as a key.
Note: Getter function for property data.
See also setData().
Sailfish::Crypto::Key ImportStoredKeyRequest::importedKeyReference() const
Returns a key reference to the securely-stored imported key
Note: this value is only valid if the status of the request is Request::Finished.
The key reference will contain metadata and a valid identifier, but no private or secret key data.
Note: Getter function for property importedKeyReference.
Sailfish::Crypto::InteractionParameters ImportStoredKeyRequest::interactionParameters() const
Returns the user input parameters which should be used when requesting the input data from the user
If specified, the user may be prompted to enter a pass phrase needed to decrypt the imported key.
Note: Getter function for property interactionParameters.
See also setInteractionParameters().
Sailfish::Crypto::Key ImportStoredKeyRequest::keyTemplate() const
Returns the key which should be used as a template when storing the imported key
The key template should contain a valid identifier, component constraints to prevent unauthorized clients from reading back sensitive data, and valid operations, as well as any filter data the client wishes to be associated with the key.
Other information, like the algorithm and key size, will be set automatically by the crypto plugin which constructs the key from the import data.
Note: Getter function for property keyTemplate.
See also setKeyTemplate().
[virtual]
Sailfish::Crypto::CryptoManager *ImportStoredKeyRequest::manager() const
See also setManager().
[virtual]
Sailfish::Crypto::Result ImportStoredKeyRequest::result() const
void ImportStoredKeyRequest::setCryptoPluginName(const QString &pluginName)
Sets the name of the crypto plugin which the client wishes to perform the key generation operation to pluginName
Note: Setter function for property cryptoPluginName.
See also cryptoPluginName().
[virtual]
void ImportStoredKeyRequest::setCustomParameters(const QVariantMap ¶ms)
See also customParameters().
void ImportStoredKeyRequest::setData(const QByteArray &data)
Sets the data which should be imported.
Note: Setter function for property data.
See also data().
void ImportStoredKeyRequest::setInteractionParameters(const Sailfish::Crypto::InteractionParameters &uiParams)
Sets the user input parameters which should be used when requesting the input data from the user to uiParams
Note: Setter function for property interactionParameters.
See also interactionParameters().
[virtual]
void ImportStoredKeyRequest::setManager(Sailfish::Crypto::CryptoManager *manager)
See also manager().