Next: Verify, Up: Crypto Operations
The function
gpgme_op_decrypt
decrypts the ciphertext in the data object cipher and stores it into the data object plain.The function returns the error code
GPG_ERR_NO_ERROR
if the ciphertext could be decrypted successfully,GPG_ERR_INV_VALUE
if ctx, cipher or plain is not a valid pointer,GPG_ERR_NO_DATA
if cipher does not contain any data to decrypt,GPG_ERR_DECRYPT_FAILED
if cipher is not a valid cipher text,GPG_ERR_BAD_PASSPHRASE
if 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_start
initiates agpgme_op_decrypt
operation. It can be completed by callinggpgme_wait
on the context. See Waiting For Completion.The function returns the error code
GPG_ERR_NO_ERROR
if the operation could be started successfully, andGPG_ERR_INV_VALUE
if 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_decrypt
operation. 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
NULL
if 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_decrypt
operation. 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_result
returns agpgme_decrypt_result_t
pointer to a structure holding the result of agpgme_op_decrypt
operation. The pointer is only valid if the last operation on the context was agpgme_op_decrypt
orgpgme_op_decrypt_start
operation. If the operation failed this might be aNULL
pointer. The returned pointer is only valid until the next operation is started on the context.