gpgme 0.3.3 questions
Werner Koch
wk@gnupg.org
Fri Sep 28 12:00:01 2001
On Thu, 27 Sep 2001 11:52:31 +0200, Stephane Corthesy said:
> How is it possible to write GpgmeData initialized with
> gpgme_data_new_with_read_cb(), with gpgme_data_new_from_file(), with
> gpgme_data_new_from_filepart() ?
I don't understand this.
> I still don't understand why it would do this. Would it return an
> error code?
No, it just returns 0 for the number of bytes read. EOF is returned
as an error code.
> If I ask for length, how can I sure that it returned me the real
> length (up to EOF)?
It either does return the entire length or returns with an error
(Invalid_Type).
> Do we really need to call rewind before ever trying to read a data?
> If we just inited the data, we don't, do we?
Better do a rewind before you start to read.
> In GpgmeRecipients, would it be possible to provide a function which
> would return the validity assigned to a name contained in the
> GpgmeRecipients instance?
Yes.
> BTW, here's another bug: it it not possible to retrieve fingerprints
> for subkeys
Notyed.
On Thu, 27 Sep 2001 18:57:53 +0200, Stephane Corthesy said:
> - Is there a particular return code we can expect when sign
> operation has been cancelled, either user cancelled entry, or program
> aborted context operation? Can we always expect GPGME_No_Data to be
> returned for this case only?
GPGME_Canceled should be returned, nowever this does not yet work.
> - There is an inconsistent behaviour: if we pass three times an
> invalid (but non empty) passphrase, return code is GPGME_No_Data, but
> if we pass three times an empty (and invalid) passphrase, we get
> GPGME_No_Passphrase.
Will be fixed.
> passphrase callback. If I use the same GpgmeContext as the one which
> is currently asking for a passphrase, my app crashes: the r_hd in
> the
You should not do this - I have to add checks to return an error.
> callback has become invalid; if I use a brand new one, the callback
> is called recursively, when I ask to enumerate keys.
Interesting.
> Seems there is no way to retrieve the corresponding GpgmeKey during
> passphrase callback... This could be OK when signing, 'cause I know
Must be fixed.
> - Currently there is no way to perform encrypt+sign operations!!!
> gpgme_signers_add() cannot be used for gpgme_op_encrypt().
I know but this is a minor problem compared to the fact that it is not
possible to decrypt and check the signature. I don't know what
application you have currently in mind, my primary target are MUAs and
tehre is is better not to use the combined method but first sign, pack
this into a MIEM object and the encrypt this MIME object again. The
big advantage is that you can remove the encryption layer and still
keep the signature.
> - Is there a way to get the currently used hash algorithm? Or to set
> it in a GpgmeContext operation?
Yes, here is my code from Sylpheed to do this (src/rfc2015.c, don't
know whether this is already in the current CVS):
===================
char *siginfo;
sigdata = pgp_sign (plain, ac, &siginfo);
if (siginfo) {
micalg = extract_micalg (siginfo);
free (siginfo);
}
/*
* Find TAG in XML and return a pointer into xml set just behind the
* closing angle. Return NULL if not found.
*/
static const char *
find_xml_tag (const char *xml, const char *tag)
{
int taglen = strlen (tag);
const char *s = xml;
while ( (s = strchr (s, '<')) ) {
s++;
if (!strncmp (s, tag, taglen)) {
const char *s2 = s + taglen;
if (*s2 == '>' || isspace (*(const unsigned char*)s2) ) {
/* found */
while (*s2 && *s2 != '>') /* skip attributes */
s2++;
/* fixme: do need to handle angles inside attribute vallues? */
return *s2? (s2+1):NULL;
}
}
while (*s && *s != '>') /* skip to end of tag */
s++;
}
return NULL;
}
/*
* Extract the micalg from an GnupgOperationInfo XML container.
*/
const char *
extract_micalg (char *xml)
{
const char *s;
s = find_xml_tag (xml, "GnupgOperationInfo");
if (s) {
const char *s_end = find_xml_tag (s, "/GnupgOperationInfo");
s = find_xml_tag (s, "signature");
if (s && s_end && s < s_end) {
const char *s_end2 = find_xml_tag (s, "/signature");
if (s_end2 && s_end2 < s_end) {
s = find_xml_tag (s, "micalg");
if (s && s < s_end2) {
s_end = strchr (s, '<');
if (s_end) {
char *p = g_malloc (s_end - s + 1);
memcpy (p, s, s_end - s);
p[s_end-s] = 0;
return p;
}
}
}
}
}
return NULL;
}
=======================
Werner
--
Werner Koch Omnis enim res, quae dando non deficit, dum habetur
g10 Code GmbH et non datur, nondum habetur, quomodo habenda est.
Privacy Solutions -- Augustinus