[gnutls-dev] Using encrypted OpenPGP keys

Mario Lenz mario.lenz at gmx.net
Mon Aug 7 18:19:24 CEST 2006


If you want to use the pass parameter in gnutls_openpgp_privkey_import

gnutls_openpgp_privkey_import (gnutls_openpgp_privkey_t key,
                                   const gnutls_datum_t * data,
                                   gnutls_openpgp_key_fmt_t format,
                                   const char *pass, unsigned int flags)
  int rc;

  rc = _gnutls_openpgp_raw_enc_privkey_to_gkey (&key->pkey, data, pass);
  if (rc)
      gnutls_assert ();
      return rc;

  return 0;

Hmmm, perhaps it would be better not to add new functions, but to add a 
pw parameter to each function and use a define. For example:

_gnutls_openpgp_raw_privkey_to_gkey (gnutls_privkey * pkey, const
gnutls_datum_t * raw_key, const char *pw)
  /* no changes */

  if (pw)
    if (cdk_sk_unprotect (pkt->pkt.secret_key, pw) != CDK_Success)
      goto leave;

  /* no changes from here on */

  sk = pkt->pkt.secret_key;
  pke_algo = sk->pk->pubkey_algo;
  pkey->params_size = cdk_pk_get_npkey (pke_algo);

  /* and so on... */


#define _gnutls_openpgp_raw_privkey_to_gkey(pkey, raw_key) \
_gnutls_openpgp_raw_privkey_to_gkey (pkey, raw_key, NULL)

(This should work, shouldn't it?)

If you want me to send diffs or to work directly in the cvs, just
tell me. But in this case we should first discuss wether to add new
functions or to use defines.



More information about the Gnutls-devel mailing list