--- ssh-1.2.27-fresh/rsaglue.c	Wed May 12 07:19:28 1999
+++ ssh-1.2.27/rsaglue.c	Fri Jul 21 13:46:05 2000
@@ -18,8 +18,20 @@
 */
 
 /*
- * $Id: rsaglue.c,v 1.5 1997/03/19 21:29:59 kivinen Exp $
+ * $Id: rsaglue.c,v 1.2 2000/05/13 19:40:31 itoi Exp $
  * $Log: rsaglue.c,v $
+ * Revision 1.2  2000/05/13 19:40:31  itoi
+ * ssh / speke / udp / ip / 7816 works!
+ *
+ * Revision 1.1  2000/05/10 11:13:31  itoi
+ * Initial revision
+ *
+ * Revision 1.1.1.1  2000/02/21 22:19:49  itoi
+ * SSH / Smartcard
+ *
+ * Revision 1.1  2000/02/11 03:54:27  tomokof
+ * Initial revision
+ *
  * Revision 1.5  1997/03/19 21:29:59  kivinen
  * 	Added missing &.
  *
@@ -59,6 +71,9 @@
 #include "mpaux.h"
 #include "xmalloc.h"
 
+/* NI */
+extern int remote_sc_mode; /* defined in ssh.c */
+
 #ifdef RSAREF
 
 /* This code uses the following RSAREF functions:
@@ -226,9 +241,53 @@
   unsigned int len, i;
   unsigned char *value;
 
+#ifdef TF_PRINT
+  /* printf ("\nrsa_private_decrypt: No RSAREF\n"); */
+  /*
+  printf ("size of RSAPrivateKey= %d\n", sizeof (RSAPrivateKey));
+  printRSAPrivateKey (key);
+  */
+  /*
+  printf ("_mp_alloc=%d, _mp_size=%d, mp_limb_t=%d\n",
+	  sizeof (challenge->_mp_alloc), sizeof (challenge->_mp_size), sizeof (mp_limb_t));
+  */
+  /* turned out to be: _mp_alloc=4, _mp_size=4, mp_limb_t=4 */
+
+  debug ("printing key...\n");
+  if (key)
+    printPrivateKeyForCyberflex (key);  
+  debug ("printing key done\n");
+  /* printMPInt (stdout, input, "\n---------------challenge before decrypt"); */
+  /*
+  sendToCard ((unsigned char*)input->_mp_d, 4 * input->_mp_size,
+	      0, "--------------before decrypt");
+  */
+#endif
+
+
+#ifdef SC_SSH
+  if (key) {
+    rsa_private(output, input, key);
+    len = (key->bits + 7) / 8;
+  } else {/* go to local smartcard */
+    rsa_private_sc (output, input); /* local */
+    len = ((output->_mp_size*32) + 7) / 8;
+  }
+#else
   rsa_private(output, input, key);
-
   len = (key->bits + 7) / 8;
+#endif
+
+#ifdef TF_PRINT
+  /* printMPInt (stdout, output, "\n---------------challenge after decrypt"); */
+  /* sendMPIntToCard (stdout, output, 0, "--------------after decrypt"); */
+  /*
+  sendToCard ((unsigned char*)output->_mp_d, 4 * output->_mp_size,
+	      0, "--------------after decrypt");
+  */
+  /* exit (0); */
+#endif
+
   value = xmalloc(len);
 
   mpz_init_set(&aux, output);
