gnutls-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnutls-dev] Using encrypted OpenPGP keys


From: Mario Lenz
Subject: [gnutls-dev] Using encrypted OpenPGP keys
Date: Mon, 07 Aug 2006 18:19:24 +0200

Hi!

If you want to use the pass parameter in gnutls_openpgp_privkey_import
(libextra/openpgp/privkey.c):

int
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:

int
_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)
    {
      rc = GNUTLS_E_OPENPGP_GETKEY_FAILED;
      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.


greez

   Mario




reply via email to

[Prev in Thread] Current Thread [Next in Thread]