[Help-gnutls] Re: Failure to import an OpenPGP private key

Ludovic Courtès ludovic.courtes at laas.fr
Wed Dec 13 17:43:12 CET 2006


I'm finally getting back to this issue...

Simon Josefsson <jas at extundo.com> writes:

> ludovic.courtes at laas.fr (Ludovic Courtès) writes:
>> This can be seen as a GnuTLS bug since the FORMAT argument of
>> `gnutls_openpgp_privkey_import' is not honored.  Does CDK provide a way
>> to import ASCII-armored private keys?  Otherwise, `privkey_import'
>> should return `UNIMPLEMENTED_FEATURE' when FORMAT is not `RAW'.
> I agree.  There is code in OpenCDK to decode ASCII-armored data, so I
> suspect there is some minor bug that prevents this from working.

Below is a patch (against HEAD) that allows the import of ASCII-armored
OpenPGP private keys.


ChangeLog entry:

	* lib/gnutls_cert.c (_gnutls_raw_privkey_to_gkey): Pass KEY_ENC to
	`_E_gnutls_openpgp_raw_privkey_to_gkey ()'.

	* libextra/gnutls_extra.h (OPENPGP_RAW_PRIVKEY_TO_GKEY): Added a
	`gnutls_openpgp_key_fmt_t' argument.

	* libextra/gnutls_openpgp.c
	(_gnutls_openpgp_raw_privkey_to_gkey): Take a new FORMAT
	argument.  When FORMAT is `BASE64', set the armor flag on OUT.
	(gnutls_certificate_set_openpgp_key_mem): Pass
	`GNUTLS_OPENPGP_FMT_RAW' as the last argument to
	`_gnutls_openpgp_raw_privkey_to_gkey ()'.

	* libextra/openpgp/gnutls_openpgp.h
	(_gnutls_openpgp_raw_privkey_to_gkey): Updated accordingly.

	* libextra/openpgp/privkey.c (gnutls_openpgp_privkey_import):
	Pass FORMAT to `_gnutls_openpgp_raw_privkey_to_gkey ()'.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ,,armored-priv-key.diff
Type: text/x-patch
Size: 4072 bytes
Desc: The patch
URL: </pipermail/attachments/20061213/719cae85/attachment.bin>

More information about the Gnutls-help mailing list