aboutsummaryrefslogtreecommitdiffstats
path: root/g10/call-agent.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2013-02-06 05:01:23 +0000
committerNIIBE Yutaka <[email protected]>2013-02-12 05:19:12 +0000
commitb90506ea220860c89128f002bd593d0462a08d73 (patch)
treed67894d81203ed7adabe5d0ca56421c387500a74 /g10/call-agent.c
parentagent: Add KEYTOCARD command. (diff)
downloadgnupg-b90506ea220860c89128f002bd593d0462a08d73.tar.gz
gnupg-b90506ea220860c89128f002bd593d0462a08d73.zip
gpg: Implement card_store_subkey again.
* g10/call-agent.h (agent_keytocard): New. * g10/call-agent.c (agent_keytocard): New. * g10/card-util.c (replace_existing_key_p): Returns 1 when replace. (card_generate_subkey): Check return value of replace_existing_key_p. (card_store_subkey): Implement again using agent_keytocard.
Diffstat (limited to 'g10/call-agent.c')
-rw-r--r--g10/call-agent.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c
index ed141dadc..85a3f2842 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -599,6 +599,30 @@ agent_learn (struct agent_card_info_s *info)
return rc;
}
+
+int
+agent_keytocard (const char *hexgrip, int keyno, int force,
+ const char *serialno, const char *timestamp)
+{
+ int rc;
+ char line[ASSUAN_LINELENGTH];
+
+ snprintf (line, DIM(line)-1, "KEYTOCARD %s%s %s OPENPGP.%d %s",
+ force?"--force ": "", hexgrip, serialno, keyno, timestamp);
+ line[DIM(line)-1] = 0;
+
+ rc = start_agent (NULL, 1);
+ if (rc)
+ return rc;
+
+ rc = assuan_transact (agent_ctx, line, NULL, NULL, default_inq_cb,
+ NULL, NULL, NULL);
+ if (rc)
+ return rc;
+
+ return rc;
+}
+
/* Call the agent to retrieve a data object. This function returns
the data in the same structure as used by the learn command. It is
allowed to update such a structure using this commmand. */