diff -N -d -u -r opensc/docs/pkcs15-crypt.1 opensc.new/docs/pkcs15-crypt.1
--- opensc/docs/pkcs15-crypt.1	2004-08-21 17:26:16.000000000 +0300
+++ opensc.new/docs/pkcs15-crypt.1	2004-11-07 00:56:13.000000000 +0200
@@ -87,6 +87,10 @@
 .BR ps (1)
 command. It is therefore a security risk to specify
 secret information such as PINs on the command line.
+.IP
+If you specify '-' as PIN, \*(nm will read STDIN for PIN. This is
+useful, in example, for doing some decryption when logging in and using
+pam_mount or similiar pam module for passing password to \*(nm.
 .TP
 .BR \-\-verbose ", " \-v
 Causes \*(nm to be more verbose. Specify this flag several times
@@ -94,3 +98,4 @@
 .SH AUTHORS
 \*(nm was written by Juha Yrjölä <juha.yrjola@iki.fi>.
 This manpage was contributed by Olaf Kirch <okir@lst.de>.
+Some additions by Jari Eskelinen <jari.eskelinen@iki.fi>.
diff -N -d -u -r opensc/src/tools/pkcs15-crypt.c opensc.new/src/tools/pkcs15-crypt.c
--- opensc/src/tools/pkcs15-crypt.c	2004-08-21 17:26:16.000000000 +0300
+++ opensc.new/src/tools/pkcs15-crypt.c	2004-11-07 00:26:47.000000000 +0200
@@ -36,6 +36,7 @@
 #include <openssl/dsa.h>
 #endif
 #include "util.h"
+#include "readpin.c"
 
 const char *app_name = "pkcs15-crypt";
 
@@ -78,7 +79,7 @@
 	"Input file is a SHA-1 hash",
 	"Input file is a MD5 hash",
 	"Use PKCS #1 v1.5 padding",
-	"Uses password (PIN) <arg>",
+	"Uses password (PIN) <arg> (use - for reading PIN from STDIN)",
 	"Wait for card insertion",
 	"Verbose operation. Use several times to enable debug output.",
 };
@@ -93,8 +94,11 @@
 	char *pincode;
 	struct sc_pkcs15_pin_info *pinfo = (struct sc_pkcs15_pin_info *) obj->data;
 	
-	if (opt_pincode != NULL)
+        if (opt_pincode != NULL && opt_pincode[0] == '-')
+                return strdup(readpin());
+	else if (opt_pincode != NULL)
 		return strdup(opt_pincode);
+   
 	sprintf(buf, "Enter PIN [%s]: ", obj->label);
 	while (1) {
 		pincode = getpass(buf);
diff -N -d -u -r opensc/src/tools/readpin.c opensc.new/src/tools/readpin.c
--- opensc/src/tools/readpin.c	1970-01-01 02:00:00.000000000 +0200
+++ opensc.new/src/tools/readpin.c	2004-11-07 00:05:00.000000000 +0200
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+char *readpin()
+{
+   static char buf[128];
+   size_t i;
+   
+   for (i = 0; i < sizeof(buf)-1; i++) {
+      buf[i] = fgetc(stdin);
+      if (buf[i] == '\r' || buf[i] == '\n' || buf[i] == EOF) {
+	 buf[i] = '\0';
+	 break;
+      }
+   }
+   buf[i+1] = '\0';
+
+   return buf;
+}
