/* this interface isn't right - hook into callback for getting passphrase */ char * __ops_export_key(__ops_io_t *io, const __ops_key_t *keydata, uint8_t *passphrase) { __ops_output_t *output; __ops_memory_t *mem; char *cp; __OPS_USED(io); __ops_setup_memory_write(&output, &mem, 128); if (keydata->type == OPS_PTAG_CT_PUBLIC_KEY) { __ops_write_xfer_pubkey(output, keydata, 1); } else { __ops_write_xfer_seckey(output, keydata, passphrase, strlen((char *)passphrase), 1); } cp = netpgp_strdup(__ops_mem_data(mem)); __ops_teardown_memory_write(output, mem); return cp; }
/* append a key to a keyring */ static int appendkey(__ops_io_t *io, __ops_key_t *key, char *ringfile) { __ops_output_t *create; const unsigned noarmor = 0; int fd; if ((fd = __ops_setup_file_append(&create, ringfile)) < 0) { fd = __ops_setup_file_write(&create, ringfile, 0); } if (fd < 0) { (void) fprintf(io->errs, "can't open pubring '%s'\n", ringfile); return 0; } if (!__ops_write_xfer_pubkey(create, key, noarmor)) { (void) fprintf(io->errs, "Cannot write pubkey\n"); return 0; } __ops_teardown_file_write(create, fd); return 1; }