Build pycrypto in AIX

  • Download pycrypto-2.6.1 from https://www.dlitz.net/software/pycrypto/

  • Unzip pycrypto tar xzvf pycrypto-2.6.1.tar.gz

  • set environment vairable and build source code export ac_cv_func_malloc_0_nonnull=yes(It would throw Error “undefined symbol rpl_malloc”) python setup.py buildRefer to iperf-for-arm-cross-compile and openwrt

  • Download dependencies and install them http://www.bullfreeware.com/recherche.php

    • gmp-devel-5.1.3-1.aix6.1.ppc.rpm
      http://www.perzl.org/aix/index.php
    • libtomcrypt-1.17-1.aix5.1.ppc.rpm
    • libtomcrypt-devel-1.17-1.aix5.1.ppc.rpm
    • libtommath-0.42.0-1.aix5.1.ppc.rpm
  • Makefile as below

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    CC=gcc
    CFLAGS=-pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/opt/freeware/include/python2.7 -c
    LDFLAGS=-pthread -shared -lpython2.7
    OBJ_DIR=build/temp.aix-7.1-2.7/src
    SO_DIR=build/lib.aix-7.1-2.7/Crypto

    all:
    echo "building 'Crypto.PublicKey._fastmath' extension"
    $(CC) $(CFLAGS) src/_fastmath.c -o $(OBJ_DIR)/fastmath.o
    $(CC) $(LDFLAGS) -lgmp -lm $(OBJ_DIR)/fastmath.o -o $(SO_DIR)/PublicKey/_fastmath.so (added -lgmp -lm)

    echo "building 'Crypto.Hash._MD2' extension"
    $(CC) $(CFLAGS) src/MD2.c -o $(OBJ_DIR)/MD2.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/MD2.o -o $(SO_DIR)/Hash/_MD2.so

    echo "building 'Crypto.Hash._SHA256' extension"
    $(CC) $(CFLAGS) src/MD2.c -o $(OBJ_DIR)/SHA256.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/MD2.o -o $(SO_DIR)/Hash/_SHA256.so

    echo "building 'Crypto.Hash._SHA224' extension"
    $(CC) $(CFLAGS) src/SHA224.c -o $(OBJ_DIR)/SHA224.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/SHA224.o -o $(SO_DIR)/Hash/_SHA224.so

    echo "building 'Crypto.Hash._SHA384' extension"
    $(CC) $(CFLAGS) src/SHA384.c -o $(OBJ_DIR)/SHA384.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/SHA384.o -o $(SO_DIR)/Hash/_SHA384.so

    echo "building 'Crypto.Hash._SHA512' extension"
    $(CC) $(CFLAGS) src/SHA512.c -o $(OBJ_DIR)/SHA512.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/SHA512.o -o $(SO_DIR)/Hash/_SHA512.so

    echo "building 'Crypto.Hash._RIPEMD160' extension"
    $(CC) $(CFLAGS) src/RIPEMD160.c -o $(OBJ_DIR)/RIPEMD160.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/RIPEMD160.o -o $(SO_DIR)/Hash/_RIPEMD160.so

    echo "building 'Crypto.Cipher._AES' extension"
    $(CC) $(CFLAGS) src/AES.c -o $(OBJ_DIR)/AES.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/AES.o -o $(SO_DIR)/Cipher/_AES.so

    echo "building 'Crypto.Cipher._ARC2' extension"
    $(CC) $(CFLAGS) src/ARC2.c -o $(OBJ_DIR)/ARC2.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/ARC2.o -o $(SO_DIR)/Cipher/_ARC2.so

    echo "building 'Crypto.Cipher._Blowfish' extension"
    $(CC) $(CFLAGS) src/Blowfish.c -o $(OBJ_DIR)/Blowfish.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/Blowfish.o -o $(SO_DIR)/Cipher/_Blowfish.so

    echo "building 'Crypto.Cipher._CAST' extension"
    $(CC) $(CFLAGS) src/CAST.c -o $(OBJ_DIR)/CAST.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/CAST.o -o $(SO_DIR)/Cipher/_CAST.so

    echo "building 'Crypto.Cipher._DES' extension"
    $(CC) $(CFLAGS) -I/opt/freeware/include/tomcrypt src/DES.c -o $(OBJ_DIR)/DES.o (added -I/opt/freeware/include/tomcrypt)
    $(CC) $(LDFLAGS) -ltomcrypt $(OBJ_DIR)/DES.o -o $(SO_DIR)/Cipher/_DES.so (added -ltomcrypt)

    echo "building 'Crypto.Cipher._DES3' extension"
    $(CC) $(CFLAGS) -I/opt/freeware/include/tomcrypt src/DES3.c -o $(OBJ_DIR)/DES3.o (added -I/opt/freeware/include/tomcrypt)
    $(CC) $(LDFLAGS) -ltomcrypt $(OBJ_DIR)/DES3.o -o $(SO_DIR)/Cipher/_DES3.so (added -ltomcrypt)

    echo "building 'Crypto.Cipher._ARC4' extension"
    $(CC) $(CFLAGS) src/ARC4.c -o $(OBJ_DIR)/ARC4.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/ARC4.o -o $(SO_DIR)/Cipher/_ARC4.so

    echo "building 'Crypto.Cipher._XOR' extension"
    $(CC) $(CFLAGS) src/XOR.c -o $(OBJ_DIR)/XOR.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/XOR.o -o $(SO_DIR)/Cipher/_XOR.so

    echo "building 'Crypto.Util.strxor' extension"
    $(CC) $(CFLAGS) src/strxor.c -o $(OBJ_DIR)/strxor.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/strxor.o -o $(SO_DIR)/Util/strxor.so

    echo "building 'Crypto.Util._counter' extension"
    $(CC) $(CFLAGS) src/_counter.c -o $(OBJ_DIR)/counter.o
    $(CC) $(LDFLAGS) $(OBJ_DIR)/counter.o -o $(SO_DIR)/Util/_counter.so