+2001-03-15 Werner Koch <wk@gnupg.org>
+
+ * rungpg.c: Included time.h.
+
+ * key.h: New keyflags for capabilities.
+ * keylist.c (set_mainkey_capability, set_subkey_capability): New.
+ (keylist_colon_handler): Parse them.
+ * gpgme.h: New attribute values for capabilties.
+ * key.c (gpgme_key_get_string_attr): Return them.
+ (capabilities_to_string): New.
+ (gpgme_key_get_ulong_attr): Return the global caps.
+
+2001-03-14 Werner Koch <wk@gnupg.org>
+
+ * w32-io.c (destroy_reader,destroy_writer): Fixed syntax error.
+ Thanks to Jan Oliver Wagner.
+
2001-03-13 Werner Koch <wk@gnupg.org>
* context.h: Add invalid and revoke flags to user_id structure.
GPGME_ATTR_KEY_REVOKED = 16,
GPGME_ATTR_KEY_INVALID = 17,
GPGME_ATTR_UID_REVOKED = 18,
- GPGME_ATTR_UID_INVALID = 19
+ GPGME_ATTR_UID_INVALID = 19,
+ GPGME_ATTR_KEY_CAPS = 20,
+ GPGME_ATTR_CAN_ENCRYPT = 21,
+ GPGME_ATTR_CAN_SIGN = 22,
+ GPGME_ATTR_CAN_CERTIFY = 23
} GpgmeAttr;
typedef enum {
}
+static const char *
+capabilities_to_string (struct subkey_s *k)
+{
+ static char *strings[8] = {
+ "",
+ "c",
+ "s",
+ "sc",
+ "e",
+ "ec",
+ "es",
+ "esc"
+ };
+ return strings[ (!!k->flags.can_encrypt << 2)
+ | (!!k->flags.can_sign << 1)
+ | (!!k->flags.can_certify ) ];
+}
+
const char *
gpgme_key_get_string_attr ( GpgmeKey key, GpgmeAttr what,
const void *reserved, int idx )
case GPGME_ATTR_KEY_INVALID:
case GPGME_ATTR_UID_REVOKED:
case GPGME_ATTR_UID_INVALID:
+ case GPGME_ATTR_CAN_ENCRYPT:
+ case GPGME_ATTR_CAN_SIGN:
+ case GPGME_ATTR_CAN_CERTIFY:
break;
case GPGME_ATTR_IS_SECRET:
if (key->secret)
val = "1";
break;
+ case GPGME_ATTR_KEY_CAPS:
+ for (k=&key->keys; k && idx; k=k->next, idx-- )
+ ;
+ if (k)
+ val = capabilities_to_string (k);
+ break;
}
return val;
}
if (u)
val = u->invalid;
break;
+ case GPGME_ATTR_CAN_ENCRYPT:
+ val = key->gloflags.can_encrypt;
+ break;
+ case GPGME_ATTR_CAN_SIGN:
+ val = key->gloflags.can_sign;
+ break;
+ case GPGME_ATTR_CAN_CERTIFY:
+ val = key->gloflags.can_encrypt;
+ break;
default:
break;
}
unsigned int expired:1 ;
unsigned int disabled:1 ;
unsigned int invalid:1 ;
+ unsigned int can_encrypt:1;
+ unsigned int can_sign:1;
+ unsigned int can_certify:1;
} flags;
unsigned int key_algo;
unsigned int key_len;
unsigned int expired:1 ;
unsigned int disabled:1 ;
unsigned int invalid:1 ;
+ unsigned int can_encrypt:1;
+ unsigned int can_sign:1;
+ unsigned int can_certify:1;
} gloflags;
unsigned int ref_count;
unsigned int secret:1;
}
}
+static void
+set_mainkey_capability ( GpgmeKey key, const char *s )
+{
+ for (; *s ; s++ ) {
+ switch (*s) {
+ case 'e': key->keys.flags.can_encrypt = 1; break;
+ case 's': key->keys.flags.can_sign = 1; break;
+ case 'c': key->keys.flags.can_certify = 1; break;
+ case 'E': key->gloflags.can_encrypt = 1; break;
+ case 'S': key->gloflags.can_sign = 1; break;
+ case 'C': key->gloflags.can_certify = 1; break;
+ }
+ }
+}
+
+static void
+set_subkey_capability ( struct subkey_s *k, const char *s )
+{
+ for (; *s; s++ ) {
+ switch (*s) {
+ case 'e': k->flags.can_encrypt = 1; break;
+ case 's': k->flags.can_sign = 1; break;
+ case 'c': k->flags.can_certify = 1; break;
+ }
+ }
+}
+
+
/* Note: we are allowed to modify line */
static void
break;
case 10: /* not used due to --fixed-list-mode option */
break;
- case 11: /* signature class */
+ case 11: /* signature class */
break;
- case 12:
+ case 12: /* capabilities */
+ set_mainkey_capability (key, p );
+ break;
+ case 13:
pend = NULL; /* we can stop here */
break;
}
break;
case 11: /* signature class */
break;
- case 12:
+ case 12: /* capability */
+ set_subkey_capability ( sk, p );
+ break;
+ case 13:
pend = NULL; /* we can stop here */
break;
}
const char *
_gpgme_get_gpg_path (void)
{
+ /* #warning Forced to development version
+ return "/home/wk/work/gnupg-stable/g10/gpg";
+ */
return GPG_PATH;
}
#include <string.h>
#include <assert.h>
#include <errno.h>
+#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <signal.h>
else
fputs("<!-- Ooops: gpgme_key_get_as_xml failed -->\n", stdout );
- s = gpgme_key_get_string_attr (key, GPGME_ATTR_KEYID, NULL, 0 );
- printf ("<!-- keyid=%s -->\n", s );
- s = gpgme_key_get_string_attr (key, GPGME_ATTR_ALGO, NULL, 0 );
- printf ("<!-- algo=%s -->\n", s );
+
+ for (i=0; ; i++ ) {
+ s = gpgme_key_get_string_attr (key, GPGME_ATTR_KEYID, NULL, i );
+ if (!s)
+ break;
+ printf ("<!-- keyid.%d=%s -->\n", i, s );
+ s = gpgme_key_get_string_attr (key, GPGME_ATTR_ALGO, NULL, i );
+ printf ("<!-- algo.%d=%s -->\n", i, s );
+ s = gpgme_key_get_string_attr (key, GPGME_ATTR_KEY_CAPS, NULL, i );
+ printf ("<!-- caps.%d=%s -->\n", i, s );
+ }
for (i=0; ; i++ ) {
s = gpgme_key_get_string_attr (key, GPGME_ATTR_NAME, NULL, i );
if (!s)
s = gpgme_key_get_string_attr (key, GPGME_ATTR_COMMENT, NULL, i );
printf ("<!-- comment.%d=%s -->\n", i, s );
}
+
+ fputs ("<!-- usable for:", stdout );
+ if ( gpgme_key_get_ulong_attr (key, GPGME_ATTR_CAN_ENCRYPT, NULL, 0 ))
+ fputs (" encryption", stdout);
+ if ( gpgme_key_get_ulong_attr (key, GPGME_ATTR_CAN_SIGN, NULL, 0 ))
+ fputs (" signing", stdout);
+ if ( gpgme_key_get_ulong_attr (key, GPGME_ATTR_CAN_CERTIFY, NULL, 0 ))
+ fputs (" certification", stdout);
+ fputs (" -->\n", stdout );
printf ("<!-- End key object (%p) -->\n", key );
gpgme_key_release (key);
err = gpgme_new (&ctx);
fail_if_err (err);
+ gpgme_set_keylist_mode (ctx, 1); /* no validity calculation */
do {
fprintf (stderr, "** pattern=`%s'\n", pattern );
doit ( ctx, pattern );