Crypt::Mimetic - Crypt a file and mask it behind another file
use Crypt::Mimetic; Crypt::Mimetic::Mask($original_file, $mask_file, $destination_file, $algorithm); Crypt::Mimetic::Unmask($mimetic_file); Crypt::Mimetic::Main($original_file, $mask_file, $destination_file, [$algorithm]); Crypt::Mimetic::Main($mimetic_file);
This module allows you to hide a file by encrypting in and then attaching it to another file of your choice. This mimetic file then looks and behaves like a normal file, and can be stored, used or emailed without attracting attention.
use Crypt::Mimetic; use Error; $Error::Debug = 1; &Crypt::Mimetic::Main(@ARGV);
You should already have it in your bin/ files: write mimetic and follow instructions.
use Crypt::Mimetic; use Error qw(:try); $Error::Debug = 1; print "\nPerforming tests for Crypt::Mimetic\n"; print "Looking for available encryption algorithms, please wait... "; select((select(STDOUT), $| = 1)[0]); #flush stdout @algo = Crypt::Mimetic::GetEncryptionAlgorithms(); print @algo ." algorithms found.\n\n"; $str = "This is a test string"; $failed = 0; $warn = 0; foreach my $algo (@algo) { try { print ''. Crypt::Mimetic::ShortDescr($algo) ."\n"; print " Encrypting string '$str' with $algo..."; select((select(STDOUT), $| = 1)[0]); #flush stdout ($enc,@info) = Crypt::Mimetic::EncryptString($str,$algo,"my stupid password"); print " done.\n"; print " Decrypting encrypted string with $algo..."; select((select(STDOUT), $| = 1)[0]); $dec = Crypt::Mimetic::DecryptString($enc,$algo,"my stupid password",@info); print " '$dec'.\n"; if ($dec eq $str) { print "Algorithm $algo: ok.\n\n"; } else { print "Algorithm $algo: failed. Decrypted string '$dec' not equals to original string '$str'\n\n"; $failed++; }#if-else } catch Error::Mimetic with { my $x = shift; if ($x->type() eq "error") { print "Algorithm $algo: error. ". $x->stringify() ."\n"; $failed++; } elsif ($x->type() eq "warning") { print "Algorithm $algo: warning. ". $x->stringify() ."\n"; $warn++; }#if-else }#try-catch }#foreach print @algo ." tests performed: ". (@algo - $failed) ." passed, $failed failed ($warn warnings).\n\n"; exit $failed;
Script test.pl used by make test in this distribution do exactly the same thing.
Return an array with names of encryption algorithms. Each algorithm is implemented in module Crypt::Mimetic::<algorithm>
Ask for a password with a given prompt (default "Password: ") and return it.
Ask for a password twice and return it only if it's correct.
Throws an Error::Mimetic if passwords don't match
Return a short description of $algorithm
Return true if password is needed by this $algorithm, false otherwise.
Call specific routine to encrypt $filename according to $algorithm. Return 3 int: $len - is the total output length $blocklen - length of an encrypted block (if needed) $padlen - length of last encrypted block (if needed)
If $output is null then the output is returned as string. Ask for a password if key not given.
Throws an Error::Mimetic if cannot open files or if password is not correctly given.
Call specific routine to encrypt $string according to $algorithm and return an encrypted string. Ask for a password if key not given.
Throws an Error::Mimetic if password is not correctly given.
Call specific routine to decrypt $filename according to $algorithm. Return decrypted file as string if $output is not given, void otherwise. Ask for a password if key not given.
Throws an Error::Mimetic if cannot open files or if password is not given
Call specific routine to decrypt $string according to $algorithm and return a decrypted string. Ask for a password if key not given.
Create following sign (all on the same line): Mimetic\0 version\0 mask_file_name\0 mask_file_length\0 original_file_name\0 encrypted_file_length\0 @info
than encrypt it and calculate length of encrypted sign. Return a string composed by concatenation of encrypted sign, algorithm (32 bytes null padding string) and its length (8 bytes hex number).
Return the algorithm and the length of the sing read from last 40 bytes of $mimetic_file.
Throws an Error::Mimetic if cannot open file
Extract information from sign of $mimetic_file. You can obtain $slen and $algorithm from GetSignInfo($mimetic_file) and key from GetPasswd(void) This sub returns an array: $Mimetic - constant string "Mimetic" $version - version of the module $mask_file - mask file's name $mlen - mask file's length $original_file - original file's name $olen - original file's length @pinfo - specific encryption algorithm information
Extract the mask file from $mimetic_file and save it in $mask_file.
Throws an Error::Mimetic if cannot open files
Mask the $original_file with a $mask_file and put everything in $destination_file, according $algorithm and @info instruction. Return true on success, false otherwise.
Throws an Error::Mimetic if cannot open files or password not correctly given
Unmask a $mimetic file splitting it in 2 files: 1. mask file 2. original file
Throws an Error::Mimetic if cannot open files or password not given
A demo main to use this module Usage: to camouflage a file with a mask Main($original_file, $mask_file, $destination_file, [$algorithm]); to split camouflaged file in original file and mask Main($mimetic_file);
Some subroutines in this module throw errors. You can learn more about this reading documentation about Error::Mimetic(3).
To implement a new encryption algorithm, let's say Foo, you should write a module with name Crypt::Mimetic::Foo that has following subroutines:
Return a short description of algorithm
Return true if password is needed by this algorithm, false otherwise.
Encrypt a file with Foo algorithm. See Crypt::Mimetic::EncryptFile.
Encrypt a string with Foo algorithm. See Crypt::Mimetic::EncryptString.
Decrypt a file with Foo algorithm. See Crypt::Mimetic::DecryptFile.
Decrypt a string with Foo algorithm. See Crypt::Mimetic::DecryptString.
To install a new mimetic encryption algorithm that you wrote (or downloaded) you should only install it as a normal Perl module; Crypt::Mimetic module will be able to find it (and use it) automagically if it's in one of the directories listed in @INC.
Obviously if you send me your algorithm I'll include it in the new release of Crypt::Mimetic
This module needs: Error Error::Mimetic Term::ReadKey File::Copy File::Find
Crypt::Mimetic::None(3), Crypt::Mimetic::TEA(3), Crypt::Mimetic::CipherSaber(3)
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself (Artistic/GPL2).
Erich Roncarolo <erich-roncarolo@users.sourceforge.net>
3 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
To install Crypt::Mimetic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Crypt::Mimetic
CPAN shell
perl -MCPAN -e shell install Crypt::Mimetic
For more information on module installation, please visit the detailed CPAN module installation guide.