Re: [Botan-devel] TripleDES /ECB Mode
Brought to you by:
randombit
|
From: Jack L. <ll...@ra...> - 2004-09-07 01:28:14
|
On Mon, Sep 06, 2004 at 03:46:52PM +0200, JnMlMe wrote:
> Hi,
>
> I need to decrypt a string who was encrypted with Triple DES (ECB Mode)
> under SUN Solaris.
>
> First, I would like to compile Botan under Windows 2K environment.
> I have a problem when i process the nmake command :
>
>
>
> D:\botan>perl configure.pl msvc-windows-i586 --module-set=win32
[...]
>
> CL /nologo -Iinclude /O2 /G5 /GX /GR /D_CONSOLE /c src\adler32.cpp
> /Fob
> uild\lib\adler32.obj
> 'CL' n'est pas reconnu en tant que commande interne
> ou externe, un programme exécutable ou un fichier de commandes.
> NMAKE : fatal error U1077: 'CL' : return code '0x1'
> Stop.
It looks like cl, the command line version of the compiler, isn't in your PATH
variable. Have you tried using the command shell that comes with Visual Studio?
Running that will automatically set up your environment with the right
variables for using the compiler and linker from the command line. Otherwise
you'll have to find where the CL binary is installed, and add that directory to
PATH.
> Second point, i have looked the encrypt and decrypt cpp examples files.
>
> These files used the CBC mode.
> Should i only changed the mode with ECB in line 117 ?
>
No -- the examples are doing password hashing, message authentication, and
similiar things that you probably don't want to do. Well, you do want to do
them normally, for decent security, but in this case you won't be able to
decrypt the message trying to use them, so there is not much point.
The following should start you off, but I don't know how the key is derived, so
as-is it won't work (because currently the key is zero-length, which 3DES
doesn't take). If you know the hex value of the key, just assign it to the
key variable (SymmetricKey key = "01234[...]").
----- FILE ------
#include <botan/botan.h>
using namespace Botan;
int main(int argc, char* argv[])
{
try {
if(argc != 2)
{
std::cout << "Usage: " << argv[0] << " input_file" << std::endl;
return 1;
}
LibraryInitializer init;
SymmetricKey key; // fill this in with whatever key you have
Pipe pipe(get_cipher("TripleDES/ECB/NoPadding", key, DECRYPTION));
DataSource_Stream input(argv[1]);
pipe.process_msg(input);
std::cout << pipe.read_all_as_string();
}
catch(std::exception& e)
{
std::cout << "Error: " << e.what() << std::endl;
return 1;
}
return 0;
}
----- /FILE ------
|