summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/authfd.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2003-06-11 11:18:39 +0000
committerDamien Miller <djm@cvs.openbsd.org>2003-06-11 11:18:39 +0000
commitcf3de089d90be8cd8c9098cc49c54b4cd38e0c0e (patch)
tree3f7aa92535ec8a18939e07e927478e2023a132b6 /usr.bin/ssh/authfd.c
parentdd9283af0d9a9094628ace5f9e4d2f3e40564575 (diff)
make agent constraints (lifetime, confirm) work with smartcard keys; ok markus@
Diffstat (limited to 'usr.bin/ssh/authfd.c')
-rw-r--r--usr.bin/ssh/authfd.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/usr.bin/ssh/authfd.c b/usr.bin/ssh/authfd.c
index 7e96269a468..368544b17b6 100644
--- a/usr.bin/ssh/authfd.c
+++ b/usr.bin/ssh/authfd.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: authfd.c,v 1.59 2003/04/08 20:21:28 itojun Exp $");
+RCSID("$OpenBSD: authfd.c,v 1.60 2003/06/11 11:18:38 djm Exp $");
#include <openssl/evp.h>
@@ -589,16 +589,33 @@ ssh_remove_identity(AuthenticationConnection *auth, Key *key)
}
int
-ssh_update_card(AuthenticationConnection *auth, int add, const char *reader_id, const char *pin)
+ssh_update_card(AuthenticationConnection *auth, int add,
+ const char *reader_id, const char *pin, u_int life, u_int confirm)
{
Buffer msg;
- int type;
+ int type, constrained = (life || confirm);
+
+ if (add) {
+ type = constrained ?
+ SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED :
+ SSH_AGENTC_ADD_SMARTCARD_KEY;
+ } else
+ type = SSH_AGENTC_REMOVE_SMARTCARD_KEY;
buffer_init(&msg);
- buffer_put_char(&msg, add ? SSH_AGENTC_ADD_SMARTCARD_KEY :
- SSH_AGENTC_REMOVE_SMARTCARD_KEY);
+ buffer_put_char(&msg, type);
buffer_put_cstring(&msg, reader_id);
buffer_put_cstring(&msg, pin);
+
+ if (constrained) {
+ if (life != 0) {
+ buffer_put_char(&msg, SSH_AGENT_CONSTRAIN_LIFETIME);
+ buffer_put_int(&msg, life);
+ }
+ if (confirm != 0)
+ buffer_put_char(&msg, SSH_AGENT_CONSTRAIN_CONFIRM);
+ }
+
if (ssh_request_reply(auth, &msg, &msg) == 0) {
buffer_free(&msg);
return 0;