[SailfishDevel] OpenSSL AES CTR 128 help needed

Sander van Grieken sander at outright.solutions
Sun Mar 1 12:34:00 UTC 2015


On Sunday 01 March 2015 11:31:57 Sander van Grieken wrote:
> On Monday 23 February 2015 22:00:09 Andrey Kozhevnikov wrote:
> > Hello Sailors!
> > 
> > I need help in debugging issue in my simple test project: 
> > https://github.com/CODeRUS/aes-test
> > In any platform/device it gives at least one failure during iterations. 
> > I googled and tried everything and have no ideas anymore.
> > Any help/ideas/suggestions are appreciated.
> > 
> > Best regards,
> > Andrey Kozhevnikov
> 
> QByteArray out(ciphertext.size(), '\0');
> 
> This looks like a possible off-by-one bug, it might on occasion not have a trailing \0, when the plaintext is exactly of length ciphertext
> 
> grtz,
> Sander

Hmm it's not that.. Strange how the failed index number is different when additional unrelated code is added. 

When I replace
    unsigned char ecount[AES_BLOCK_SIZE];
    memset(ecount, 0, AES_BLOCK_SIZE);
with
    QByteArray ecount(AES_BLOCK_SIZE, '\0');

and change the parameter in the openssl function to 
    (unsigned char*)ecount.data()
it works correctly though..

It looks like something goes wrong when passing the locally scoped char array ptr.. (?)

grtz,
Sander





More information about the Devel mailing list