#25 compilation of Crypto/MyAes.cpp fails with invalid operands

Unstable (example)


I cannot run the prebuilt binary for AIX 5.1 as it will not load, I guess because my aix 5.1 is an older maintenance level than the binary was built on.
So I'm trying to compile p7zip_9.20.1 using gcc 2.9-aix51-020209 (very old I know) and it is failing with:


-DBREAK_HANDLER -DUNICODE -D_UNICODE -c -I. -I../../../myWindows -I../../../ -

I../../../include_windows ../../Crypto/MyAes.cpp
../../Crypto/MyAes.cpp: In method NCrypto::CAesCbcCoder::CAesCbcCoder ()': ../../Crypto/MyAes.cpp:13: invalid operandsunsigned int ()[71]' and int' to binaryoperator&'
** [MyAes.o] Error 1

The code that is failing is:

_offset = ((0 - (unsigned)(ptrdiff_t)_aes) & 0xF) / sizeof(UInt32);

Can some-one please tell me how to change this line so it is acceptable to gcc?
I'm not any sort of c++ programmer...
Any help would be much appreciated thanks.


  • Igor Pavlov
    Igor Pavlov

    Actually we need pointer to integer conversion.
    Does gcc 2.9 support pointer to unsigned conversion?
    _offset = ((0 - (ptrdiff_t)_aes) & 0xF) / sizeof(UInt32);
    _offset = ((0 - (unsigned)(size_t)(ptrdiff_t)_aes) & 0xF) / sizeof(UInt32);

    This code sets _offset in _aes array to make it (_aes + _offset) aligned for 16 bytes. It's required for Intel AES instructions.
    if your binary doesn't support Intel AES instructions, you can try to write:
    _offset = 0;

    Last edit: Igor Pavlov 2014-07-02
  • Goodvibes2

    Hi Igor,

    Thanks very much for your suggestions.
    I tried the first 2 suggestions but the compiler gave the same error.
    As I'm using a powerpc, I assume it has no Intel AES instructions, so I was able to compile using your 3rd suggestion of _offset = 0;
    I also had to make a similar change to CAesCtr2::CAesCtr2() in Crypto/WzAes.cpp.

    The 'make all_test' has problems with the creation of the 7za.exe.x archive :
    7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
    p7zip Version 9.20 (locale=en_US,Utf16=on,HugeFiles=on,1 CPU)

    Creating archive 7za.exe.xz

    Compressing 7za.exe 0%

    ERROR: Can't allocate required memory!
    ERROR during : /usr/local/src/packages/SOURCES/p7zip_9.20.1/check/../bin/7za -txz a 7za.exe.xz

    make: *** [test] Error 1

    The same problem occurs when testing 7zr.

    I've done some manual tests using .zip and .7z archives and they all seem to be working fine, so I'm happy.
    You're probably not interested in the .xz problem on this old platform, but if you are, just let me know if you'd like me to do anything to help.

    By the way, Does the .7z format with password always use AES256 encryption?
    There doesn't seem to be any options for specifying the encryption method for .7z.
    Is AES:19 the same as AES256?

    Thanks again for your help.

  • Igor Pavlov
    Igor Pavlov

    7zAES:19 means AES-256 + (2^19) SHA-256 iterations in password to key function.

    About xz problem. I want to fix it. If you can debug it, try to use smaller test file (some small txt file). Maybe you can try to reduce dictionary size.

    does "7z b" command work?

    Last edit: Igor Pavlov 2014-07-03
  • Igor Pavlov
    Igor Pavlov

    And do you know any way for your compiler to convert from (char *) variable to unsigned or size_t?