gpgmeutils.h File Reference

Protos and data structures for GPGME utilities. More...

`#include <glib.h>`
`#include <gpgme.h>`

Go to the source code of this file.

## Functions

void | log_gpgme (GLogLevelFlags, gpg_error_t, const char *,...)
| Log function with extra gpg-error style output. More...
gpgme_ctx_t | gvm_init_gpgme_ctx_from_dir (const gchar *)
| Returns a new gpgme context. More...
int | gvm_gpg_import_many_types_from_string (gpgme_ctx_t, const char *, ssize_t, GArray *)
| Import a key or certificate given by a string. More...
int | gvm_gpg_import_from_string (gpgme_ctx_t, const char *, ssize_t, gpgme_data_type_t)
| Import a key or certificate given by a string. More...
int | gvm_pgp_pubkey_encrypt_stream (FILE *, FILE *, const char *, const char *, ssize_t)
| Encrypt a stream for a PGP public key, writing to another stream. More...
int | gvm_smime_encrypt_stream (FILE *, FILE *, const char *, const char *, ssize_t)
| Encrypt a stream for a S/MIME certificate, writing to another stream. More...

## Detailed Description

Protos and data structures for GPGME utilities.

This file contains the protos for gpgmeutils.c

## Function Documentation

## gvm_gpg_import_from_string()

int gvm_gpg_import_from_string | ( | gpgme_ctx_t | ctx,
|  | const char * | key_str,
|  | ssize_t | key_len,
|  | gpgme_data_type_t | key_type
| ) |  |

Import a key or certificate given by a string.

Parameters

  [in] | ctx | The GPGME context to import the key / certificate into.
  [in] | key_str | Key or certificate string.
  [in] | key_len | Length of key/certificate string or -1 to use strlen.
  [in] | key_type | The expected key type.

Returns
  0 success, 1 invalid key data, 2 unexpected key data, 3 error importing key/certificate, -1 error.

## gvm_gpg_import_many_types_from_string()

int gvm_gpg_import_many_types_from_string | ( | gpgme_ctx_t | ctx,
|  | const char * | key_str,
|  | ssize_t | key_len,
|  | GArray * | key_types
| ) |  |

Import a key or certificate given by a string.

Parameters

  [in] | ctx | The GPGME context to import the key / certificate into.
  [in] | key_str | Key or certificate string.
  [in] | key_len | Length of key/certificate string or -1 to use strlen.
  [in] | key_types | GArray of expected key types.

Returns
  0 success, 1 invalid key data, 2 unexpected key data, 3 error importing key/certificate, -1 error.

## gvm_init_gpgme_ctx_from_dir()

gpgme_ctx_t gvm_init_gpgme_ctx_from_dir | ( | const gchar * | dir | ) |

Returns a new gpgme context.

Inits a gpgme context with the custom gpg directory, protocol version etc. Returns the context or NULL if an error occurred. This function also does an gpgme initialization the first time it is called.

Parameters

  dir | Directory to use for gpg

Returns
  The gpgme_ctx_t to the context or NULL if an error occurred.

## gvm_pgp_pubkey_encrypt_stream()

int gvm_pgp_pubkey_encrypt_stream | ( | FILE * | plain_file,
|  | FILE * | encrypted_file,
|  | const char * | uid_email,
|  | const char * | public_key_str,
|  | ssize_t | public_key_len
| ) |  |

Encrypt a stream for a PGP public key, writing to another stream.

The output will use ASCII armor mode and no compression.

Parameters

  [in] | plain_file | Stream / FILE* providing the plain text.
  [in] | encrypted_file | Stream to write the encrypted text to.
  [in] | uid_email | Email address of public key to use.
  [in] | public_key_str | String containing the public key.
  [in] | public_key_len | Length of public key or -1 to use strlen.

Returns
  0 success, -1 error.

## gvm_smime_encrypt_stream()

int gvm_smime_encrypt_stream | ( | FILE * | plain_file,
|  | FILE * | encrypted_file,
|  | const char * | uid_email,
|  | const char * | certificate_str,
|  | ssize_t | certificate_len
| ) |  |

Encrypt a stream for a S/MIME certificate, writing to another stream.

The output will use ASCII armor mode and no compression.

Parameters

  [in] | plain_file | Stream / FILE* providing the plain text.
  [in] | encrypted_file | Stream to write the encrypted text to.
  [in] | uid_email | Email address of certificate to use.
  [in] | certificate_str | String containing the public key.
  [in] | certificate_len | Length of public key or -1 to use strlen.

Returns
  0 success, -1 error.

## log_gpgme()

void log_gpgme | ( | GLogLevelFlags | level,
|  | gpg_error_t | err,
|  | const char * | fmt,
|  |  | ...
| ) |  |

Log function with extra gpg-error style output.

If `err` is not 0, the appropriate error string is appended to the output. It takes care to only add the error source string if it makes sense.

Parameters

  level | The GLib style log level
  err | An gpg-error value or 0
  fmt | The printf style format string, followed by its arguments.