The exact error is a SIGABRT, which is being spit out of libstdc++. I can
provide a backtrace if you'd like. I'm running a Linux system with gcc 2.96,
a 2.4.18 kernel and glibc 2.2.4.
Here's essentially the stripped-down code for what I'm doing, minus all of the
nicities. It worked with Crypto++ 4.2, which is what my earlier PHP extension
is based on. Basically, I end up with a bunch of classes derived from MyBase,
and each can return a BlockTransformation via getEncryptionObject(), which
MyBase::encrypt() uses for whatever purpose. This will produce the ABORT
signal upon execution.
---------------
#include <iostream>
#include <cstdlib>
#include "cryptlib.h"
#include "aes.h"
using namespace CryptoPP;
class MyBase
{
public:
bool encrypt();
virtual BlockTransformation* getEncryptionObject() = 0;
string itsPlaintext;
string itsKey;
string itsCiphertext;
};
bool MyBase::encrypt()
{
// as near as I can tell, this line causes the core dump...
BlockTransformation* bt = getEncryptionObject();
// after we have the BlockTransformation, we can use it
// with CBC_Mode_ExternalCipher, ECB_Mode_ExternalCipher, etc.
// Won't bother with that, as we've already core dumped by now.
return true;
}
class MyAES : public MyBase
{
public:
BlockTransformation* getEncryptionObject();
};
BlockTransformation* MyAES::getEncryptionObject()
{
return new AESEncryption((byte*) itsKey.data(), itsKey.length());
}
int main()
{
MyAES myaes;
myaes.itsPlaintext = "this is some plaintext";
myaes.itsKey = "this is a secret key";
myaes.encrypt();
return EXIT_SUCCESS;
}
------------------
The full code is a bit more expansive, naturally, but this reproduces the
crash.
Any ideas?
Thanks again.
J
On October 8, 2002 03:35 pm, Wei Dai wrote:
> On Tue, Oct 08, 2002 at 12:25:24PM -0400, J Smith wrote:
> > BlockTransformation* bt = getEncryptionObject();
> >
> > The getEncryptionObject() method being implemented in some class thusly:
> >
> > BlockTransformation* MyAESClass::getEncryptionObject()
> > {
> > return new AESEncryption((byte*) itsKey, itsKeylength);
> > }
>
> This code should still work. What error are you getting exactly?
>
> > Once I had bt set to a BlockTransformation (in this case, an
> > AESEncryption object), I would hand it off to another method that would
> > implement CBCPaddedEncryptor or CBC_CTS_Encryptor or some ECB
> > implementation.
>
> Instead of CBCPaddedEncryptor, you now use CBC_Mode_ExternalCipher and
> optionally StreamTransformationFilter.