Using losetup and crypto-API to encrypt individual files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I trying to use crypto-API to encrypt individual file
(against `gpg -c` or mcrypt). Result is strange:

1). Decrypted file every time is not completed
(end 128-bit block of file is lost).

2). Decrypted file every time is one.
(one md5sum). May be IV in CBC is one
or encrypting is ECB?

I need to have CBC with random IV encryption
for individual files (stdin) using bash (perl) 
and crypto-API.

Please help me.

#My examples
#######################################################
#!/bin/bash
#encrypt

FILEIN=/home/plaintext.txt
FILEOUT=/home/cryptext.enc
SIZE=5	#kilobytes

dd if=/dev/zero of=$FILEOUT bs=1k count=$SIZE 

/sbin/losetup /dev/loop1 $FILEIN
/sbin/losetup /dev/loop2 $FILEOUT
/sbin/losetup -e twofish /dev/loop3 /dev/loop2
dd if=/dev/loop1 of=/dev/loop3 bs=2k conv=notrunc

/sbin/losetup -d /dev/loop3
/sbin/losetup -d /dev/loop2
/sbin/losetup -d /dev/loop1

#######################################################

#!/bin/bash
#decrypt

FILEIN=/home/cryptext.enc
FILEOUT=/home/plaintext.txt.dec
SIZE=5	#kilobytes

dd if=/dev/zero of=$FILEOUT bs=1k count=$SIZE 

/sbin/losetup -e twofish /dev/loop1 $FILEIN
/sbin/losetup /dev/loop2 $FILEOUT

dd if=/dev/loop1 of=/dev/loop2 bs=1k conv=notrunc

/sbin/losetup -d /dev/loop2
/sbin/losetup -d /dev/loop1

######################################################


-
Linux-crypto:  cryptography in and on the Linux system
Archive:       http://mail.nl.linux.org/linux-crypto/


[Index of Archives]     [Kernel]     [Linux Crypto]     [Gnu Crypto]     [Gnu Classpath]     [Netfilter]     [Bugtraq]
  Powered by Linux