[Nathan, sorry for sending this twice. I accidentally sent the original
straight to you]

It looks like you are assuming that the ciphertext size will be the same as
the plaintext size (100). I don't know anything about the Sosemanuk cipher,
but with Elliptic Curve Crypto, you need to size the ciphertext buffer based
on the result from the Encryptor.

e.g. in http://www.cryptopp.com/w/images/d/dc/ECCTest.zip , in
ecctest/ecctest.cpp, the ciphertext length is available as
Encryptor.CiphertextLength(plaintextLength).

Given that you are segfaulting at address 0x50000065, where that lower octet
"65" is 101 decimal, it looks like you are running off the end of your
ciphertext buffer, indicating it is too small.


On Sun, Jul 4, 2010 at 8:59 AM, Nathan Ridge <[email protected]> wrote:

> Hello,
>
> I am trying to run a very simple stream cipher example, taken from the
> FAQ, but I am getting a segmentation fault.
>
> Here is the code:
>
> #include <sosemanuk.h>
> using CryptoPP::Sosemanuk;
>
> int main()
> {
>    byte plaintext[100], ciphertext[100],
> key[Sosemanuk::DEFAULT_KEYLENGTH], iv[Sosemanuk::IV_LENGTH];
>    // put data into key, iv, and plaintext here
>    // encrypt
>    Sosemanuk::Encryption enc(key, Sosemanuk::DEFAULT_KEYLENGTH, iv);
>    enc.ProcessData(ciphertext, plaintext, 100);
>    // now decrypt
>    Sosemanuk::Decryption dec(key, Sosemanuk::DEFAULT_KEYLENGTH, iv);
>    dec.ProcessData(plaintext, ciphertext, 100);
> }
>
> My compiler in MinGW g++ 4.5.0, OS is Windows XP 64-bit edition
> Service Pack 2.
> CryptoPP version is 5.6.0.
>
> gdb gives this strack trace:
>
> Program received signal SIGSEGV, Segmentation fault.
> #0 0x00409da8 in CryptoPP::SosemanukPolicy::OperateKeystream
> (this=0x46a190, operation=2293488,output=0x77bbcbb5 "ï≡ï╞ΦA╣",
> input=0x3f0000 "╚", iterationCount=0) at sosemanuk.cpp:605
> #1 0x003f23e0 in ?? ()
> Cannot access memory at address 0x50000065
>
> What am I doing wrong?
>
> Thanks,
>
> Nate.
>
> --
> 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.

-- 
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.

Reply via email to