Encryption of a very large file with smime is not recommended, since you can encrypt large files using the -stream option, but do not decrypt the resulting file due to hardware limitations, see the problem of decrypting large files
As mentioned above, public key cryptocurrencies are not designed to encrypt arbitrarily long files. Therefore, the following commands will generate a missing phrase, encrypt the file using symmetric encryption, and then encrypt the missing phrase using an asymmetric (public key). Note: smime includes using the primary public key and the backup key to encrypt the phrase. A backup public / private key pair would be reasonable.
Random Password Generation
Set the RANDFILE value to a file accessible to the current user, generate the passwd.txt file and clear the settings
export OLD_RANDFILE=$RANDFILE RANDFILE=~/rand1 openssl rand -base64 2048 > passwd.txt rm ~/rand1 export RANDFILE=$OLD_RANDFILE
Encryption
Use the commands below to encrypt the file, using passwd.txt as the password and AES256 for the base64 (-a) file. Encrypt passwd.txt using asymmetric encryption in the XXLarge.crypt.pass file using the primary public key and the backup key.
openssl enc -aes-256-cbc -a -salt -in XXLarge.data -out XXLarge.crypt -pass file:passwd.txt openssl smime -encrypt -binary -in passwd.txt -out XXLarge.crypt.pass -aes256 PublicKey1.pem PublicBackupKey.pem rm passwd.txt
decryption
The decryption simply decrypts XXLarge.crypt.pass for passwd.tmp, decrypts XXLarge.crypt to XXLarge2.data, and deletes the passwd.tmp file.
openssl smime -decrypt -binary -in XXLarge.crypt.pass -out passwd.tmp -aes256 -recip PublicKey1.pem -inkey PublicKey1.key openssl enc -d -aes-256-cbc -a -in XXLarge.crypt -out XXLarge2.data -pass file:passwd.tmp rm passwd.tmp
This has been tested against files> 5 GB.
5365295400 Nov 17 10:07 XXLarge.data 7265504220 Nov 17 10:03 XXLarge.crypt 5673 Nov 17 10:03 XXLarge.crypt.pass 5365295400 Nov 17 10:07 XXLarge2.data
Ipswitch Nov 17 '13 at 12:07 on 2013-11-17 12:07
source share