Importing keys means the same as running gpg with the command --import.
The function
gpgme_op_importadds the keys in the data buffer keydata to the key ring of the crypto engine used by ctx. The format of keydata can be ASCII armored, for example, but the details are specific to the crypto engine.After the operation completed successfully, the result can be retrieved with
gpgme_op_import_result.The function returns the error code
GPG_ERR_NO_ERRORif the import was completed successfully,GPG_ERR_INV_VALUEif keydata if ctx or keydata is not a valid pointer, andGPG_ERR_NO_DATAif keydata is an empty data buffer.
The function
gpgme_op_import_startinitiates agpgme_op_importoperation. It can be completed by callinggpgme_waiton the context. See Waiting For Completion.The function returns the error code
GPG_ERR_NO_ERRORif the import could be started successfully,GPG_ERR_INV_VALUEif keydata if ctx or keydata is not a valid pointer, andGPG_ERR_NO_DATAif keydata is an empty data buffer.
The function
gpgme_op_import_keysadds the keys described by theNULLterminated array keys to the key ring of the crypto engine used by ctx. This function is the general interface to move a key from one crypto engine to another as long as they are compatible. In particular it is used to actually import and make keys permanent which have been retrieved from an external source (i.e. usingGPGME_KEYLIST_MODE_EXTERN). 1Only keys of the the currently selected protocol of ctx are considered for import. Other keys specified by the keys are ignored. As of now all considered keys must have been retrieved using the same method, that is the used key listing mode must be identical.
After the operation completed successfully, the result can be retrieved with
gpgme_op_import_result.The function returns the error code
GPG_ERR_NO_ERRORif the import was completed successfully,GPG_ERR_INV_VALUEif keydata if ctx or keydata is not a valid pointer,GPG_ERR_CONFLICTif the key listing mode does not match, andGPG_ERR_NO_DATAif no keys are considered for export.
The function
gpgme_op_import_keys_startinitiates agpgme_op_import_keysoperation. It can be completed by callinggpgme_waiton the context. See Waiting For Completion.The function returns the error code
GPG_ERR_NO_ERRORif the import was completed successfully,GPG_ERR_INV_VALUEif keydata if ctx or keydata is not a valid pointer,GPG_ERR_CONFLICTif the key listing mode does not match, andGPG_ERR_NO_DATAif no keys are considered for export.
This is a pointer to a structure used to store a part of the result of a
gpgme_op_importoperation. For each considered key one status is added that contains information about the result of the import. The structure contains the following members:
gpgme_import_status_t next- This is a pointer to the next status structure in the linked list, or
NULLif this is the last element.char *fpr- This is the fingerprint of the key that was considered.
gpgme_error_t result- If the import was not successful, this is the error value that caused the import to fail. Otherwise the error code is
GPG_ERR_NO_ERROR.unsigned int status- This is a bit-wise OR of the following flags that give more information about what part of the key was imported. If the key was already known, this might be 0.
GPGME_IMPORT_NEW- The key was new.
GPGME_IMPORT_UID- The key contained new user IDs.
GPGME_IMPORT_SIG- The key contained new signatures.
GPGME_IMPORT_SUBKEY- The key contained new sub keys.
GPGME_IMPORT_SECRET- The key contained a secret key.
This is a pointer to a structure used to store the result of a
gpgme_op_importoperation. After a successful import operation, you can retrieve the pointer to the result withgpgme_op_import_result. The structure contains the following members:
int considered- The total number of considered keys.
int no_user_id- The number of keys without user ID.
int imported- The total number of imported keys.
imported_rsa- The number of imported RSA keys.
unchanged- The number of unchanged keys.
new_user_ids- The number of new user IDs.
new_sub_keys- The number of new sub keys.
new_signatures- The number of new signatures.
new_revocations- The number of new revocations.
secret_read- The total number of secret keys read.
secret_imported- The number of imported secret keys.
secret_unchanged- The number of unchanged secret keys.
not_imported- The number of keys not imported.
gpgme_import_status_t imports- A list of gpgme_import_status_t objects which contain more information about the keys for which an import was attempted.
The function
gpgme_op_import_resultreturns agpgme_import_result_tpointer to a structure holding the result of agpgme_op_importoperation. The pointer is only valid if the last operation on the context was agpgme_op_importorgpgme_op_import_startoperation, and if this operation finished successfully. The returned pointer is only valid until the next operation is started on the context.
The following interface is deprecated and only provided for backward compatibility. Don't use it. It will be removed in a future version of GPGME.
The function
gpgme_op_import_extis equivalent to:gpgme_error_t err = gpgme_op_import (ctx, keydata); if (!err) { gpgme_import_result_t result = gpgme_op_import_result (ctx); *nr = result->considered; }
[1] Thus it is a replacement for the usual workaround of exporting and then importing a key to make an X.509 key permanent.