> Were you doing something similar to "byte key [16]"?
As a matter of fact, I was doing
byte aesDKey[32], aesDIV[16];
> I always use the Crypto++ defines.
I could correct it for IV - but hardly for the key size (as my application
requires 256-bit keys).
In your opinion, how should I define the key and the IV (post a code-line or
two please)? (and why would that make a difference?)
> If so, this is the first thing I would correct.
I hear you. But the symptoms ar weird. When the encrypted file contains just
one record - all my code works fine, no problem. When it has more than one
record - my decrypting code dumps core at the moment it tries to set
connection between FileSource and Decryptor...
I've tried this on Windows (XP Pro SP2) under current release of Cygwin.
Checked also on CoLinux - same result. (Still have MS Visual Studio to check
against)
Please find attached the complete source of the test program, together with
two encoded files (file with hex-encoded 256-bit AES key and 128-bit IV, and
file with 5 lines of base64-encoded encrypted 100-byte long text strings).
If anybody can make any sense of it - I'd greatly appreciate it.
Thanks!
> On 9/27/07, Mouse <[EMAIL PROTECTED]> wrote:
> >
> > > Without seeing the code that doesn't work (i.e. precisely what
> > > you're doing to "reverse" the process), it's hard to say why it
> > > doesn't work for you. If you simply don't give the
> > > StreamTransformationFilter an attachment, though, it
> behaves exactly
> > > as you wish.
> >
> > I understand what you're saying. You're right, and your new
> example helps.
> >
> > The funny thing is - my decrypting program dumps core on
> the last line
> > of the following block of code:
> >
> > CBC_Mode<AES>::Decryption decrAES(aesDKey, 32, aesDIV);
> SecByteBlock
> > recbytes; StreamTransformationFilter *aesD =
> > new StreamTransformationFilter(decrAES);
> > FileSource fs("tenc.txt", true, new Base64Decoder(aesD));
> >
> >
> > The example you've given below makes perfect sense. I'm
> tryng to think
> > along the same lines. For some reasons I just can't establish that
> > connection with FileSource...
> >
> > > StreamTransformationFilter * outfilt = new
> > > StreamTransformationFilter(decryptor);
> > > FileSource outgoing(encfile.c_str(), true, new
> > > Base64Decoder(outfilt));
> >
> > Here's where my code coredumps... My debugging is unsuccessful, I'm
> > getting "No stack" with Backtrace...
> >
> > > The loop at the end is a silly example, but I think it
> shows how to
> > > do what you want.
> >
> > Yes it does. Now I need to figure out why that line dumps core (and
> > why that dump seems un-analyzable).
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---
// ui-r3.cpp :
//
#if defined (__unix__)
#define OS_RNG_AVAILABLE 1
#endif
#define FALSE 0
#define TRUE 1
#define CNT_LIMIT 15
#include <cryptopp/cryptlib.h>
#include <cryptopp/hex.h>
#include <cryptopp/aes.h>
#include <cryptopp/modes.h>
#include <cryptopp/oids.h>
#include <cryptopp/files.h>
#include <cryptopp/filters.h>
#include <cryptopp/base64.h>
#include <stdlib.h>
#if defined(__unix__)
#include <unistd.h>
#endif
#include <iostream>
USING_NAMESPACE(CryptoPP);
USING_NAMESPACE(std);
int main(int argc, char ** argv)
{
byte aesDKey[32], aesDIV[16]; // 256-bit key & 128-bit IV
string keyString;
StringSink sk(keyString);
FileSource faesk("keys.txt", true, new HexDecoder(&sk));
memset(aesDKey, 0x0, 32); memset(aesDIV, 0x0, 16);
memcpy(aesDKey, keyString.c_str(), 32);
memcpy(aesDIV, keyString.c_str()+32, 16);
CBC_Mode<AES>::Decryption decrAES(aesDKey, 32, aesDIV);
cout << "Created and configured AES decryptor..." << endl;
SecByteBlock recbytes;
StreamTransformationFilter *aesD =
new StreamTransformationFilter(decrAES);
FileSource fstxt("tenc.txt", true, new Base64Decoder(aesD));
cout << "have " << aesD->MaxRetrievable() << " bytes ready\n";
int i=0, len=0;
while (aesD->AnyRetrievable()) {
recbytes.CleanNew(100);
i = aesD->MaxRetrievable();
len = aesD->Get(recbytes, 100);
cout << "Got " << len << " bytes: \""
<< (char *)recbytes.data() << "\"\n";
}
exit(0);
}
62CB30B07A45F6B46A64A572673E8EC1D8C612A780960CEB52D24E87C883455301FB3CBE27E6B4BDCAAEE962CCEBFC58
L1VZpdFIkhu3wctry4ZAhxXt8RTTU4ZwPXNtgOluUv2Agv8wC4z1muXEm1TBHn/+Lm/QrZoe
jZVPwx57a5xNIDNWh6cxdZlN1RMacCGMWUR6uUTI9S/6c4od6zs3Egndou9OP7N6Y1xB27Po
e5PMTQ==
WkAwTUZcNw2OKQVz7jZNJYIYBA+IGSzXHCbqhoLBzx+HM+UC4O1WGqmkLZfO1br4d5eiv84m
Hm3d0xxiI3Aco4IseXqmh55k/r7YQWNhHmvBZi2RMTtgixV90ain7tnPjqvcBXDou+UTlVj4
PAtaJQ==
dBr7bU+291pL5YuTyvMqyMKKkt9YsPQB9Q00G0Qz/WUavFiXDUQ2hgj/6bDlNyxPU0tTe0oK
yxeb4vPxiWjIJy6LBTh/vtFGqDS+k+6nwBvONKzWvLx/Zffxl8xfF905QzY/wgAYhhcN7wW5
cp1+OA==
5sQT1N5ajoFVwkh5h13g/iHvvsdtvSiDb1Y8ohc5Jzpz9L5jrputwZO4DmhYXLkKdBZpqDhS
Pt5GkaoY7xu80gvKNEaC9ZsDEljMFUWR92OBQrYqv0kRGgDeco3vW2TFTCOqjUW4msZ2DCYn
oX5hdw==
kplghD0PGhyOxj2EqVkEwEHH8VcFELjkf9V6yUxwrC8ef5UWSjzOzoLHuvD0qtA4F6Rmnduq
QG6opvs+MXrE2fCg2pbZHhINW05ZKUKu5PBoNhB1eZt5imqBYN4Pfui0wdRIvS7UlVnfinJK
EiwNiQ==