+/* --- @keykg@ --- *
+ *
+ * Arguments: @key_file *kf@ = pointer to key file
+ * @key *k@ = pointer to key
+ * @const char **tyr@ = where to put the type string
+ *
+ * Returns: Pointer to indicated key-group options, or null.
+ *
+ * Use: Looks up a key's group indicator and tries to find a matching
+ * table entry.
+ */
+
+static const kgops *keykg(key_file *kf, key *k, const char **tyr)
+{
+ const char *ty;
+ const kgops **ko;
+
+ /* --- Look up the key type in the table --- *
+ *
+ * There are several places to look for this. The most obvious is the
+ * `kx-group' key attribute. But there's also the key type itself.
+ */
+
+ ty = key_getattr(kf, k, "kx-group");
+ if (!ty && strncmp(k->type, "tripe-", 6) == 0) ty = k->type + 6;
+ if (!ty) ty = "dh";
+ if (tyr) *tyr = ty;
+
+ for (ko = kgtab; *ko; ko++) {
+ if (strcmp((*ko)->ty, ty) == 0)
+ return (*ko);
+ }
+ return (0);
+}
+