Next: Verify, Up: Crypto Operations
The function
gpgme_op_decryptdecrypts the ciphertext in the data object cipher and stores it into the data object plain.The function returns the error code
GPG_ERR_NO_ERRORif the ciphertext could be decrypted successfully,GPG_ERR_INV_VALUEif ctx, cipher or plain is not a valid pointer,GPG_ERR_NO_DATAif cipher does not contain any data to decrypt,GPG_ERR_DECRYPT_FAILEDif cipher is not a valid cipher text,GPG_ERR_BAD_PASSPHRASEif the passphrase for the secret key could not be retrieved, and passes through any errors that are reported by the crypto engine support routines.
The function
gpgme_op_decrypt_startinitiates agpgme_op_decryptoperation. It can be completed by callinggpgme_waiton the context. See Waiting For Completion.The function returns the error code
GPG_ERR_NO_ERRORif the operation could be started successfully, andGPG_ERR_INV_VALUEif cipher or plain is not a valid pointer.
This is a pointer to a structure used to store information about the recipient of an encrypted text which is decrypted in a
gpgme_op_decryptoperation. This information (except for the status field) is even available before the operation finished successfully, for example in a passphrase callback. The structure contains the following members:
gpgme_recipient_t next- This is a pointer to the next recipient structure in the linked list, or
NULLif this is the last element.gpgme_pubkey_algo_t- The public key algorithm used in the encryption.
unsigned int wrong_key_usage : 1- This is true if the key was not used according to its policy.
char *keyid- This is the key ID of the key (in hexadecimal digits) used as recipient.
gpgme_error_t status- This is an error number with the error code GPG_ERR_NO_SECKEY if the secret key for this recipient is not available, and 0 otherwise.
This is a pointer to a structure used to store the result of a
gpgme_op_decryptoperation. After successfully decrypting data, you can retrieve the pointer to the result withgpgme_op_decrypt_result. The structure contains the following members:
char *unsupported_algorithm- If an unsupported algorithm was encountered, this string describes the algorithm that is not supported.
unsigned int wrong_key_usage : 1- This is true if the key was not used according to its policy.
gpgme_recipient_t recipient- This is a linked list of recipients to which this message was encrypted.
char *file_name- This is the filename of the original plaintext message file if it is known, otherwise this is a null pointer.
The function
gpgme_op_decrypt_resultreturns agpgme_decrypt_result_tpointer to a structure holding the result of agpgme_op_decryptoperation. The pointer is only valid if the last operation on the context was agpgme_op_decryptorgpgme_op_decrypt_startoperation. If the operation failed this might be aNULLpointer. The returned pointer is only valid until the next operation is started on the context.