summaryrefslogtreecommitdiff
path: root/scard.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-08-06 21:42:00 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-08-06 21:42:00 +0000
commita6c8a8d4d5c482163fc7c6784017cd8a802174f4 (patch)
tree8686262cb08ae2136a446380ba1445add3977694 /scard.c
parent6818bfbf3084af380eea97ac91237a9a201d9504 (diff)
- markus@cvs.openbsd.org 2001/08/01 23:38:45
[scard.c ssh.c] support finish rsa keys. free public keys after login -> call finish -> close smartcard.
Diffstat (limited to 'scard.c')
-rw-r--r--scard.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/scard.c b/scard.c
index 8b3abcfa..cfcd953b 100644
--- a/scard.c
+++ b/scard.c
@@ -24,7 +24,7 @@
#ifdef SMARTCARD
#include "includes.h"
-RCSID("$OpenBSD: scard.c,v 1.11 2001/08/01 22:03:33 markus Exp $");
+RCSID("$OpenBSD: scard.c,v 1.12 2001/08/01 23:38:45 markus Exp $");
#include <openssl/engine.h>
#include <sectok.h>
@@ -262,6 +262,20 @@ err:
return (len >= 0 ? len : status);
}
+/* called on free */
+
+static int (*orig_finish)(RSA *rsa) = NULL;
+
+static int
+sc_finish(RSA *rsa)
+{
+ if (orig_finish)
+ orig_finish(rsa);
+ sc_close();
+ return 1;
+}
+
+
/* engine for overloading private key operations */
static ENGINE *smart_engine = NULL;
@@ -291,13 +305,16 @@ sc_get_engine(void)
smart_rsa.rsa_priv_enc = sc_private_encrypt;
smart_rsa.rsa_priv_dec = sc_private_decrypt;
+ /* save original */
+ orig_finish = def->finish;
+ smart_rsa.finish = sc_finish;
+
/* just use the OpenSSL version */
smart_rsa.rsa_pub_enc = def->rsa_pub_enc;
smart_rsa.rsa_pub_dec = def->rsa_pub_dec;
smart_rsa.rsa_mod_exp = def->rsa_mod_exp;
smart_rsa.bn_mod_exp = def->bn_mod_exp;
smart_rsa.init = def->init;
- smart_rsa.finish = def->finish;
smart_rsa.flags = def->flags;
smart_rsa.app_data = def->app_data;
smart_rsa.rsa_sign = def->rsa_sign;