/*
* keyd.c - key retrieval daemon
*
- * Jonathan McDowell <noodles@earth.li>
+ * Copyright 2004,2011 Jonathan McDowell <noodles@earth.li>
*
- * Copyright 2004 Project Purple
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <errno.h>
struct buffer_ctx storebuf;
int ret = 0;
int *fd = (int *) ctx;
+ uint64_t keyid;
if (key != NULL) {
storebuf.offset = 0;
storebuf.size = 8192;
storebuf.buffer = malloc(8192);
+ get_keyid(key, &keyid);
logthing(LOGTHING_TRACE,
"Iterating over 0x%016" PRIX64 ".",
- get_keyid(key));
+ keyid);
flatten_publickey(key,
&packets,
struct openpgp_packet_list *packets = NULL;
struct openpgp_packet_list *list_end = NULL;
struct buffer_ctx storebuf;
+ struct skshash hash;
/*
* Get the command from the client.
write(fd, stats,
sizeof(*stats));
break;
+ case KEYD_CMD_GETSKSHASH:
+ cmd = KEYD_REPLY_OK;
+ write(fd, &cmd, sizeof(cmd));
+ bytes = read(fd, hash.hash, sizeof(hash.hash));
+ if (bytes != sizeof(hash.hash)) {
+ ret = 1;
+ }
+ storebuf.offset = 0;
+ if (ret == 0) {
+ logthing(LOGTHING_INFO,
+ "Fetching by hash"
+ ", result: %d",
+ config.dbbackend->
+ fetch_key_skshash(&hash,
+ &key));
+ if (key != NULL) {
+ storebuf.size = 8192;
+ storebuf.buffer = malloc(8192);
+
+ flatten_publickey(key,
+ &packets,
+ &list_end);
+ write_openpgp_stream(buffer_putchar,
+ &storebuf,
+ packets);
+ logthing(LOGTHING_TRACE,
+ "Sending %d bytes.",
+ storebuf.offset);
+ write(fd, &storebuf.offset,
+ sizeof(storebuf.offset));
+ write(fd, storebuf.buffer,
+ storebuf.offset);
+
+ free(storebuf.buffer);
+ storebuf.buffer = NULL;
+ storebuf.size = storebuf.offset = 0;
+ free_packet_list(packets);
+ packets = list_end = NULL;
+ free_publickey(key);
+ key = NULL;
+ } else {
+ write(fd, &storebuf.offset,
+ sizeof(storebuf.offset));
+ }
+ }
+ break;
+
default:
logthing(LOGTHING_ERROR, "Got unknown command: %d",
cmd);