File: gpgme.info, Node: Decrypt and Verify, Next: Sign, Prev: Verify, Up: Crypto Operations 7.6.3 Decrypt and Verify ------------------------ -- Function: gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t CTX, gpgme_data_t CIPHER, gpgme_data_t PLAIN) The function ‘gpgme_op_decrypt_verify’ decrypts the ciphertext in the data object CIPHER and stores it into the data object PLAIN. If CIPHER contains signatures, they will be verified. After the operation completed, ‘gpgme_op_decrypt_result’ and ‘gpgme_op_verify_result’ can be used to retrieve more information about the signatures. If the error code ‘GPG_ERR_NO_DATA’ is returned, CIPHER does not contain any data to decrypt. However, it might still be signed. The information about detected signatures is available with ‘gpgme_op_verify_result’ in this case. 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. -- Function: gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t CTX, gpgme_data_t CIPHER, gpgme_data_t PLAIN) The function ‘gpgme_op_decrypt_verify_start’ initiates a ‘gpgme_op_decrypt_verify’ operation. It can be completed by calling ‘gpgme_wait’ on the context. *Note Waiting For Completion::. The function returns the error code ‘GPG_ERR_NO_ERROR’ if the operation could be started successfully, ‘GPG_ERR_INV_VALUE’ if CTX, CIPHER, PLAIN or R_STAT is not a valid pointer, and ‘GPG_ERR_NO_DATA’ if CIPHER does not contain any data to decrypt. When processing mails it is sometimes useful to extract the actual mail address (the “addr-spec”) from a string. GPGME provides this helper function which uses the same semantics as the internal functions in GPGME and GnuPG: -- Function: char * gpgme_addrspec_from_uid (const char *UID) SINCE: 1.7.1 Return the mail address (called “addr-spec” in RFC-5322) from the string UID which is assumed to be a user id (called “address” in RFC-5322). All plain ASCII characters (i.e., those with bit 7 cleared) in the result are converted to lowercase. Caller must free the result using ‘gpgme_free’. Returns ‘NULL’ if no valid address was found (in which case ‘ERRNO’ is set to ‘EINVAL’) or for other errors.