+ } else if (dbctx->fetch_key_id(dbctx, keyid, &keys,
+ false)) {
+ unsigned char *photo = NULL;
+ size_t length = 0;
+
+ if (getphoto(keys, 0, &photo,
+ &length) == ONAK_E_OK) {
+ fwrite(photo,
+ 1,
+ length,
+ stdout);
+ }
+ free_publickey(keys);
+ keys = NULL;
+ } else {
+ puts("Key not found");
+ }
+ } else if (!strcmp("delete", argv[optind])) {
+ dbctx->delete_key(dbctx,
+ dbctx->getfullkeyid(dbctx, keyid),
+ false);
+ } else if (!strcmp("get", argv[optind])) {
+ if (!(ishex || isfp)) {
+ puts("Can't get a key on uid text."
+ " You must supply a keyid / "
+ "fingerprint.");
+ } else if ((isfp &&
+ dbctx->fetch_key_fp(dbctx,
+ &fingerprint,
+ &keys, false)) ||
+ (ishex &&
+ dbctx->fetch_key_id(dbctx, keyid,
+ &keys, false))) {
+ logthing(LOGTHING_INFO, "Got key.");
+ flatten_publickey(keys,
+ &packets,
+ &list_end);
+ free_publickey(keys);
+ if (binary) {
+ write_openpgp_stream(stdout_putchar,
+ NULL,
+ packets);
+ } else {
+ armor_openpgp_stream(stdout_putchar,
+ NULL,
+ packets);
+ }
+ free_packet_list(packets);
+ packets = NULL;
+ } else {
+ puts("Key not found");
+ }
+ } else if (!strcmp("hget", argv[optind])) {
+ if (!parse_skshash(search, &hash)) {
+ puts("Couldn't parse sks hash.");
+ } else if (dbctx->fetch_key_skshash(dbctx, &hash,
+ &keys)) {