+ } else if (kfile || id || ktype) {
+ key_file kf;
+ key *kk;
+ key_data *kd;
+
+ /* --- Open the key file --- */
+
+ if (!kfile)
+ kfile = "keyring";
+ if (key_open(&kf, kfile, KOPEN_READ, key_moan, 0)) {
+ die(EXIT_FAILURE, "error opening key file `%s': %s",
+ kfile, strerror(errno));
+ }
+
+ /* --- Find the key --- */
+
+ if (id) {
+ if ((kk = key_bytag(&kf, id)) == 0)
+ die(EXIT_FAILURE, "key `%s' not found", id);
+ } else {
+ if (!ktype)
+ ktype = "bbs";
+ if ((kk = key_bytype(&kf, ktype)) == 0)
+ die(EXIT_FAILURE, "no suitable key with type `%s' found", ktype);
+ }
+
+ /* --- Read the key data --- */
+
+ if ((kk->k.e & KF_ENCMASK) != KENC_STRUCT)
+ die(EXIT_FAILURE, "key is not structured");
+ if ((kd = key_structfind(&kk->k, "n")) == 0)
+ die(EXIT_FAILURE, "key has no subkey `n'");
+ if ((kd->e & KF_ENCMASK) != KENC_MP)
+ die(EXIT_FAILURE, "incomatible subkey encoding");
+ m = MP_COPY(kd->u.m);
+ key_close(&kf);