[SailfishDevel] OpenSSL AES CTR 128 help needed

Sander van Grieken sander at outright.solutions
Sun Mar 1 14:54:55 UTC 2015


On Sunday 01 March 2015 14:35:47 Ove Kåven wrote:
> Den 23. feb. 2015 18:00, skrev Andrey Kozhevnikov:
> > 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.
> 
> The problem is probably that, in your calls to AES_ctr128_encrypt, the 
> last argument is &ctr, but ctr isn't always zero here. The last argument 
> is supposed to be stream state and *must* be initialized to zero before 
> encrypting/decrypting the first block of the stream (which, in your 
> case, is also the only block).
> 
> (By the way, your intToByteArray seems to take a signed int value, you 
> should probably change it to unsigned, as the % operator won't work the 
> way you want on negative numbers.)

Also in OpenSSL the value of ctr is directly used in pointer arithmetic, so pointing to invalid memory where ctr >= 16. 




More information about the Devel mailing list