Next: , Previous: , Up: Crypto Operations   [Contents][Index]


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. See 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.


Next: Sign, Previous: Verify, Up: Crypto Operations   [Contents][Index]