--- lomount.c.bk	Fri Dec  5 15:09:23 2003
+++ lomount.c	Sun Dec  7 16:43:01 2003
@@ -198,45 +198,6 @@
 	return 0;
 }
 
-/*
- * A function to read the passphrase either from the terminal or from
- * an open file descriptor.
- */
-static char *
-xgetpass(int pfd, const char *prompt) {
-	char *pass;
-	int buflen, i;
-
-        if (pfd < 0) /* terminal */
-		return getpass(prompt);
-
-	pass = NULL;
-	buflen = 0;
-	for (i=0; ; i++) {
-		if (i >= buflen-1) {
-				/* we're running out of space in the buffer.
-				 * Make it bigger: */
-			char *tmppass = pass;
-			buflen += 128;
-			pass = realloc(tmppass, buflen);
-			if (pass == NULL) {
-				/* realloc failed. Stop reading. */
-				error("Out of memory while reading passphrase");
-				pass = tmppass; /* the old buffer hasn't changed */
-				break;
-			}
-		}
-		if (read(pfd, pass+i, 1) != 1 || pass[i] == '\n')
-			break;
-	}
-	if (pass == NULL)
-		return "";
-	else {
-		pass[i] = 0;
-		return pass;
-	}
-}
-
 static int
 digits_only(const char *s) {
 	while (*s)
@@ -251,6 +212,7 @@
 	struct loop_info64 loopinfo64;
 	int fd, ffd, mode;
 	char *pass;
+	int keylength;
 
 	mode = (*loopro ? O_RDONLY : O_RDWR);
 	if ((ffd = open(file, mode)) < 0) {
@@ -307,9 +269,17 @@
 			strlen(loopinfo64.lo_encrypt_key);
 		break;
 	default:
-		pass = xgetpass(pfd, _("Password: "));
-		xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE);
-		loopinfo64.lo_encrypt_key_size = LO_KEY_SIZE;
+		if(ttyname(pfd))  {
+			fprintf(stderr,"Won't read binary key from terminal\n");
+			exit(-1);
+		}
+		keylength = read(pfd,loopinfo64.lo_encrypt_key,LO_KEY_SIZE);
+		if(-1 == keylength)  {
+			perror("Problem reading binary key:");
+			exit(-1);
+		}
+		fprintf(stderr,"Notice: Key Length is %d bit\n",keylength*8);
+		loopinfo64.lo_encrypt_key_size = keylength;
 	}
 
 	if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
@@ -449,7 +419,7 @@
 	int delete, off, c;
 	int res = 0;
 	int ro = 0;
-	int pfd = -1;
+	int pfd = 0;
 
 	setlocale(LC_ALL, "");
 	bindtextdomain(PACKAGE, LOCALEDIR);
