/* this interface isn't right - hook into callback for getting passphrase */ char * pgp_export_key(pgp_io_t *io, const pgp_key_t *keydata, uint8_t *passphrase) { pgp_output_t *output; pgp_memory_t *mem; char *cp; __PGP_USED(io); pgp_setup_memory_write(&output, &mem, 128); if (keydata->type == PGP_PTAG_CT_PUBLIC_KEY) { pgp_write_xfer_pubkey(output, keydata, 1); } else { pgp_write_xfer_seckey(output, keydata, passphrase, strlen((char *)passphrase), 1); } cp = netpgp_strdup(pgp_mem_data(mem)); pgp_teardown_memory_write(output, mem); return cp; }
/* append a key to a keyring */ static int appendkey(pgp_io_t *io, pgp_key_t *key, char *ringfile) { pgp_output_t *create; const unsigned noarmor = 0; int fd; if ((fd = pgp_setup_file_append(&create, ringfile)) < 0) { fd = pgp_setup_file_write(&create, ringfile, 0); } if (fd < 0) { (void) fprintf(io->errs, "can't open pubring '%s'\n", ringfile); return 0; } if (!pgp_write_xfer_pubkey(create, key, noarmor)) { (void) fprintf(io->errs, "Cannot write pubkey\n"); return 0; } pgp_teardown_file_write(create, fd); return 1; }