This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x: How to update the OpenSSL from 1.0.0j to 1.0.1g in SDK version 7.0.

Guru 24520 points

Dear All,

Please provide us your advices for this topics.

[Question.1]

Would you please teach us the way of updating the OPENSSL from 1.0.1e to 1.0.1g with using Sitara SDK 7.0?

My customer requested us that provide the detail way(Especially "Configure option") in order to update it.


[Question.2]

Do you have a plan to update it on Sitara SDK?

Let me know if you have further questions.

Best regards.

Kaka

  • Hi,

    Have you seen this page: http://processors.wiki.ti.com/index.php/Build_OpenSSL_for_Sitara

    Regarding your second question, I don't know the Sitara SDK team plans, but judging by the fact that in SDK 06.00.00.00 the openssl version was 1.0.0j and in SDK 07.00.00.00 it has been updated to 1.0.1e, my guess is that in the next version of the SDK openssl will be updated to its latest version.

    Best regards,
    Miroslav

  • Hi Miroslav,

    Thank you for your response.

    Regarding answer for my question1, I have known this page. However I have stopped the step of "Patch OpenSSL" because we need to use the Patch file against for 1.0.1g version.  Is my understanding correct?

    If yes, what should we do in order to update to this version? Or do you have that patch file?

    Please provide me your advice for this.

    Best regards.

    Kaka

  • Hi Miroslav,

    I revised the "eng_cryptodev.c" file in OPENSSL folder however, I could not complete the "make" command by happening Error.  I got the log and attached it and the revised file to this post.

    [Log]

    making all in crypto...
    make[1]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto'
    ( echo "#ifndef MK1MF_BUILD"; \
    	echo '  /* auto-generated by crypto/Makefile for crypto/cversion.c */'; \
    	echo '  #define CFLAGS "arm-linux-gnueabihf-gcc -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS"'; \
    	echo '  #define PLATFORM "dist"'; \
    	echo "  #define DATE \"`LC_ALL=C LC_TIME=C date`\""; \
    	echo '#endif' ) >buildinf.h
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cryptlib.o cryptlib.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o mem.o mem.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o mem_dbg.o mem_dbg.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cversion.o cversion.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ex_data.o ex_data.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cpt_err.o cpt_err.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ebcdic.o ebcdic.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o uid.o uid.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o o_time.o o_time.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o o_str.o o_str.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o o_dir.o o_dir.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o o_fips.o o_fips.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o o_init.o o_init.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o fips_ers.o fips_ers.c
    arm-linux-gnueabihf-gcc -I. -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o mem_clr.o mem_clr.c
    arm-linux-gnueabihf-ar  r ../libcrypto.a cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o cpt_err.o ebcdic.o uid.o o_time.o o_str.o o_dir.o o_fips.o o_init.o fips_ers.o mem_clr.o
    arm-linux-gnueabihf-ar: creating ../libcrypto.a
    [ -z "" ] || arm-linux-gnueabihf-ar  r ../libcrypto.a fipscanister.o
    arm-linux-gnueabihf-ranlib ../libcrypto.a || echo Never mind.
    making all in crypto/objects...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/objects'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o o_names.o o_names.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o obj_dat.o obj_dat.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o obj_lib.o obj_lib.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o obj_err.o obj_err.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o obj_xref.o obj_xref.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/objects'
    making all in crypto/md4...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/md4'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o md4_dgst.o md4_dgst.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o md4_one.o md4_one.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a md4_dgst.o md4_one.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/md4'
    making all in crypto/md5...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/md5'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o md5_dgst.o md5_dgst.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o md5_one.o md5_one.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a md5_dgst.o md5_one.o 
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/md5'
    making all in crypto/sha...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/sha'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o sha_dgst.o sha_dgst.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o sha1dgst.o sha1dgst.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o sha_one.o sha_one.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o sha1_one.o sha1_one.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o sha256.o sha256.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o sha512.o sha512.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a sha_dgst.o sha1dgst.o sha_one.o sha1_one.o sha256.o sha512.o 
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/sha'
    making all in crypto/mdc2...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/mdc2'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o mdc2dgst.o mdc2dgst.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o mdc2_one.o mdc2_one.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a mdc2dgst.o mdc2_one.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/mdc2'
    making all in crypto/hmac...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/hmac'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o hmac.o hmac.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o hm_ameth.o hm_ameth.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o hm_pmeth.o hm_pmeth.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a hmac.o hm_ameth.o hm_pmeth.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/hmac'
    making all in crypto/ripemd...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/ripemd'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rmd_dgst.o rmd_dgst.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rmd_one.o rmd_one.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a rmd_dgst.o rmd_one.o 
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/ripemd'
    making all in crypto/whrlpool...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/whrlpool'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o wp_dgst.o wp_dgst.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o wp_block.o wp_block.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a wp_dgst.o wp_block.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/whrlpool'
    making all in crypto/des...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/des'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o set_key.o set_key.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ecb_enc.o ecb_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cbc_enc.o cbc_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ecb3_enc.o ecb3_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cfb64enc.o cfb64enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cfb64ede.o cfb64ede.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cfb_enc.o cfb_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ofb64ede.o ofb64ede.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o enc_read.o enc_read.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o enc_writ.o enc_writ.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ofb64enc.o ofb64enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ofb_enc.o ofb_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o str2key.o str2key.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o pcbc_enc.o pcbc_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o qud_cksm.o qud_cksm.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rand_key.o rand_key.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o des_enc.o des_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o fcrypt_b.o fcrypt_b.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o fcrypt.o fcrypt.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o xcbc_enc.o xcbc_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rpc_enc.o rpc_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cbc_cksm.o cbc_cksm.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ede_cbcm_enc.o ede_cbcm_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o des_old.o des_old.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o des_old2.o des_old2.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o read2pwd.o read2pwd.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a set_key.o  ecb_enc.o  cbc_enc.o ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o  ofb64ede.o enc_read.o enc_writ.o ofb64enc.o ofb_enc.o  str2key.o  pcbc_enc.o qud_cksm.o rand_key.o des_enc.o fcrypt_b.o fcrypt.o xcbc_enc.o rpc_enc.o  cbc_cksm.o ede_cbcm_enc.o des_old.o des_old2.o read2pwd.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/des'
    making all in crypto/aes...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/aes'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o aes_misc.o aes_misc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o aes_ecb.o aes_ecb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o aes_cfb.o aes_cfb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o aes_ofb.o aes_ofb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o aes_ctr.o aes_ctr.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o aes_ige.o aes_ige.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o aes_wrap.o aes_wrap.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o aes_core.o aes_core.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o aes_cbc.o aes_cbc.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a aes_misc.o aes_ecb.o aes_cfb.o aes_ofb.o aes_ctr.o aes_ige.o aes_wrap.o aes_core.o aes_cbc.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/aes'
    making all in crypto/rc2...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/rc2'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rc2_ecb.o rc2_ecb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rc2_skey.o rc2_skey.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rc2_cbc.o rc2_cbc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rc2cfb64.o rc2cfb64.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rc2ofb64.o rc2ofb64.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a rc2_ecb.o rc2_skey.o rc2_cbc.o rc2cfb64.o rc2ofb64.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/rc2'
    making all in crypto/rc4...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/rc4'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rc4_enc.o rc4_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rc4_skey.o rc4_skey.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o rc4_utl.o rc4_utl.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a rc4_enc.o rc4_skey.o rc4_utl.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/rc4'
    making all in crypto/idea...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/idea'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o i_cbc.o i_cbc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o i_cfb64.o i_cfb64.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o i_ofb64.o i_ofb64.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o i_ecb.o i_ecb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o i_skey.o i_skey.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a i_cbc.o i_cfb64.o i_ofb64.o i_ecb.o i_skey.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/idea'
    making all in crypto/bf...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/bf'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o bf_skey.o bf_skey.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o bf_ecb.o bf_ecb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o bf_enc.o bf_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o bf_cfb64.o bf_cfb64.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o bf_ofb64.o bf_ofb64.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a bf_skey.o bf_ecb.o bf_enc.o bf_cfb64.o bf_ofb64.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/bf'
    making all in crypto/cast...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/cast'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o c_skey.o c_skey.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o c_ecb.o c_ecb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o c_enc.o c_enc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o c_cfb64.o c_cfb64.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o c_ofb64.o c_ofb64.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a c_skey.o c_ecb.o c_enc.o c_cfb64.o c_ofb64.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/cast'
    making all in crypto/camellia...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/camellia'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cmll_ecb.o cmll_ecb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cmll_ofb.o cmll_ofb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cmll_cfb.o cmll_cfb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cmll_ctr.o cmll_ctr.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cmll_utl.o cmll_utl.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o camellia.o camellia.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cmll_misc.o cmll_misc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cmll_cbc.o cmll_cbc.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a cmll_ecb.o cmll_ofb.o cmll_cfb.o cmll_ctr.o cmll_utl.o camellia.o cmll_misc.o cmll_cbc.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/camellia'
    making all in crypto/seed...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/seed'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o seed.o seed.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o seed_ecb.o seed_ecb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o seed_cbc.o seed_cbc.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o seed_cfb.o seed_cfb.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o seed_ofb.o seed_ofb.c
    arm-linux-gnueabihf-ar  r ../../libcrypto.a seed.o seed_ecb.o seed_cbc.o seed_cfb.o seed_ofb.o
    arm-linux-gnueabihf-ranlib ../../libcrypto.a || echo Never mind.
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/seed'
    making all in crypto/modes...
    make[2]: Entering directory `/home/kato/test/openssl-1.0.1g/crypto/modes'
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cbc128.o cbc128.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ctr128.o ctr128.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cts128.o cts128.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o cfb128.o cfb128.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o ofb128.o ofb128.c
    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi  -c -o gcm128.o gcm128.c
    gcm128.c: In function ‘CRYPTO_gcm128_encrypt’:
    gcm128.c:1069:1: internal compiler error: in push_minipool_fix, at config/arm/arm.c:13375
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <https://bugs.launchpad.net/gcc-linaro> for instructions.
    make[2]: *** [gcm128.o] Error 1
    make[2]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto/modes'
    make[1]: *** [subdirs] Error 1
    make[1]: Leaving directory `/home/kato/test/openssl-1.0.1g/crypto'
    make: *** [build_crypto] Error 1
    

    [File]

     

    /*
     * Copyright (c) 2002 Bob Beck <beck@openbsd.org>
     * Copyright (c) 2002 Theo de Raadt
     * Copyright (c) 2002 Markus Friedl
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     * 1. Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     * 2. Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
     * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
     * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    
    #include <openssl/objects.h>
    #include <openssl/engine.h>
    #include <openssl/evp.h>
    #include <openssl/bn.h>
    
    #if (defined(__unix__) || defined(unix)) && !defined(USG) && \
    	(defined(OpenBSD) || defined(__FreeBSD__))
    #include <sys/param.h>
    # if (OpenBSD >= 200112) || ((__FreeBSD_version >= 470101 && __FreeBSD_version < 500000) || __FreeBSD_version >= 500041)
    #  define HAVE_CRYPTODEV
    # endif
    # if (OpenBSD >= 200110)
    #  define HAVE_SYSLOG_R
    # endif
    #endif
    
    #define OPENSSL_CRYPTODEF_HASH_NO_ONESHOT 1
    
    #ifndef HAVE_CRYPTODEV
    
    void
    ENGINE_load_cryptodev(void)
    {
    	/* This is a NOP on platforms without /dev/crypto */
    	return;
    }
    
    #else 
     
    #include <sys/types.h>
    #include <crypto/cryptodev.h>
    #include <crypto/dh/dh.h>
    #include <crypto/dsa/dsa.h>
    #include <crypto/err/err.h>
    #include <crypto/rsa/rsa.h>
    #include <sys/ioctl.h>
    #include <errno.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <stdarg.h>
    #include <syslog.h>
    #include <errno.h>
    #include <string.h>
    
    struct dev_crypto_state {
    	struct session_op d_sess;
    	int d_fd;
    
    #ifdef USE_CRYPTODEV_DIGESTS
    	char dummy_mac_key[HASH_MAX_LEN];
    
    	unsigned char digest_res[HASH_MAX_LEN];
    	char *mac_data;
    	int mac_len;
    #endif
    };
    
    static u_int32_t cryptodev_asymfeat = 0;
    
    static int get_asym_dev_crypto(void);
    static int open_dev_crypto(void);
    static int get_dev_crypto(void);
    static int get_cryptodev_ciphers(const int **cnids);
    #ifdef USE_CRYPTODEV_DIGESTS
    static int get_cryptodev_digests(const int **cnids);
    #endif
    static int cryptodev_usable_ciphers(const int **nids);
    static int cryptodev_usable_digests(const int **nids);
    static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        const unsigned char *in, size_t inl);
    static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
        const unsigned char *iv, int enc);
    static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx);
    static int cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
        const int **nids, int nid);
    static int cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
        const int **nids, int nid);
    static int bn2crparam(const BIGNUM *a, struct crparam *crp);
    static int crparam2bn(struct crparam *crp, BIGNUM *a);
    static void zapparams(struct crypt_kop *kop);
    static int cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r,
        int slen, BIGNUM *s);
    
    static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a,
        const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
    static int cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I,
        RSA *rsa, BN_CTX *ctx);
    static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
    static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a,
        const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
    static int cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
        BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
        BN_CTX *ctx, BN_MONT_CTX *mont);
    static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst,
        int dlen, DSA *dsa);
    static int cryptodev_dsa_verify(const unsigned char *dgst, int dgst_len,
        DSA_SIG *sig, DSA *dsa);
    static int cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
        const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
        BN_MONT_CTX *m_ctx);
    static int cryptodev_dh_compute_key(unsigned char *key,
        const BIGNUM *pub_key, DH *dh);
    static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
        void (*f)(void));
    void ENGINE_load_cryptodev(void);
    
    static const ENGINE_CMD_DEFN cryptodev_defns[] = {
    	{ 0, NULL, NULL, 0 }
    };
    
    static struct {
    	int	id;
    	int	nid;
    	int	ivmax;
    	int	keylen;
    } ciphers[] = {
    	{ CRYPTO_ARC4,			NID_rc4,		0,	16, },
    	{ CRYPTO_DES_CBC,		NID_des_cbc,		8,	 8, },
    	{ CRYPTO_3DES_CBC,		NID_des_ede3_cbc,	8,	24, },
    	{ CRYPTO_AES_CBC,		NID_aes_128_cbc,	16,	16, },
    	{ CRYPTO_AES_CBC,		NID_aes_192_cbc,	16,	24, },
    	{ CRYPTO_AES_CBC,		NID_aes_256_cbc,	16,	32, },
    	{ CRYPTO_BLF_CBC,		NID_bf_cbc,		8,	16, },
    	{ CRYPTO_CAST_CBC,		NID_cast5_cbc,		8,	16, },
    	{ CRYPTO_SKIPJACK_CBC,		NID_undef,		0,	 0, },
    	{ 0,				NID_undef,		0,	 0, },
    };
    
    #ifdef USE_CRYPTODEV_DIGESTS
    static struct {
    	int	id;
    	int	nid;
    	int 	keylen;
    } digests[] = {
    	{ CRYPTO_MD5_HMAC,		NID_hmacWithMD5,	16},
    	{ CRYPTO_SHA1_HMAC,		NID_hmacWithSHA1,	20},
    	{ CRYPTO_RIPEMD160_HMAC,	NID_ripemd160,		16/*?*/},
    	{ CRYPTO_MD5_KPDK,		NID_undef,		0},
    	{ CRYPTO_SHA1_KPDK,		NID_undef,		0},
    	{ CRYPTO_MD5,			NID_md5,		16},
    	{ CRYPTO_SHA1,			NID_sha1,		20},
    	{ 0,				NID_undef,		0},
    };
    #endif
    
    /*
     * Return a fd if /dev/crypto seems usable, 0 otherwise.
     */
    static int
    open_dev_crypto(void)
    {
    	static int fd = -1;
    
    	if (fd == -1) {
    		if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
    			return (-1);
    		/* close on exec */
    		if (fcntl(fd, F_SETFD, 1) == -1) {
    			close(fd);
    			fd = -1;
    			return (-1);
    		}
    	}
    	return (fd);
    }
    
    static int
    get_dev_crypto(void)
    {
    	int fd, retfd;
    
    	if ((fd = open_dev_crypto()) == -1)
    		return (-1);
    #ifndef CRIOGET_NOT_NEEDED
    	if (ioctl(fd, CRIOGET, &retfd) == -1)
    		return (-1);
    
    	/* close on exec */
    	if (fcntl(retfd, F_SETFD, 1) == -1) {
    		close(retfd);
    		return (-1);
    	}
    #else
            retfd = fd;
    #endif
    	return (retfd);
    }
    
    static void put_dev_crypto(int fd)
    {
    #ifndef CRIOGET_NOT_NEEDED
    	close(fd);
    #endif
    }
    
    /* Caching version for asym operations */
    static int
    get_asym_dev_crypto(void)
    {
    	static int fd = -1;
    
    	if (fd == -1)
    		fd = get_dev_crypto();
    	return fd;
    }
    
    /*
     * Find out what ciphers /dev/crypto will let us have a session for.
     * XXX note, that some of these openssl doesn't deal with yet!
     * returning them here is harmless, as long as we return NULL
     * when asked for a handler in the cryptodev_engine_ciphers routine
     */
    static int
    get_cryptodev_ciphers(const int **cnids)
    {
    	static int nids[CRYPTO_ALGORITHM_MAX];
    	struct session_op sess;
    	int fd, i, count = 0;
    
    	if ((fd = get_dev_crypto()) < 0) {
    		*cnids = NULL;
    		return (0);
    	}
    	memset(&sess, 0, sizeof(sess));
    	sess.key = (caddr_t)"123456789abcdefghijklmno";
    
    	for (i = 0; ciphers[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
    		if (ciphers[i].nid == NID_undef)
    			continue;
    		sess.cipher = ciphers[i].id;
    		sess.keylen = ciphers[i].keylen;
    		sess.mac = 0;
    		if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
    		    ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
    			nids[count++] = ciphers[i].nid;
    	}
    	put_dev_crypto(fd);
    
    	if (count > 0)
    		*cnids = nids;
    	else
    		*cnids = NULL;
    	return (count);
    }
    
    #ifdef USE_CRYPTODEV_DIGESTS
    /*
     * Find out what digests /dev/crypto will let us have a session for.
     * XXX note, that some of these openssl doesn't deal with yet!
     * returning them here is harmless, as long as we return NULL
     * when asked for a handler in the cryptodev_engine_digests routine
     */
    static int
    get_cryptodev_digests(const int **cnids)
    {
    	static int nids[CRYPTO_ALGORITHM_MAX];
    	struct session_op sess;
    	int fd, i, count = 0;
    
    	if ((fd = get_dev_crypto()) < 0) {
    		*cnids = NULL;
    		return (0);
    	}
    	memset(&sess, 0, sizeof(sess));
    	sess.mackey = (caddr_t)"123456789abcdefghijklmno";
    	for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
    		if (digests[i].nid == NID_undef)
    			continue;
    		sess.mac = digests[i].id;
    		sess.mackeylen = digests[i].keylen;
    		sess.cipher = 0;
    		if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
    		    ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
    			nids[count++] = digests[i].nid;
    	}
    	put_dev_crypto(fd);
    
    	if (count > 0)
    		*cnids = nids;
    	else
    		*cnids = NULL;
    	return (count);
    }
    #endif  /* 0 */
    
    /*
     * Find the useable ciphers|digests from dev/crypto - this is the first
     * thing called by the engine init crud which determines what it
     * can use for ciphers from this engine. We want to return
     * only what we can do, anythine else is handled by software.
     *
     * If we can't initialize the device to do anything useful for
     * any reason, we want to return a NULL array, and 0 length,
     * which forces everything to be done is software. By putting
     * the initalization of the device in here, we ensure we can
     * use this engine as the default, and if for whatever reason
     * /dev/crypto won't do what we want it will just be done in
     * software
     *
     * This can (should) be greatly expanded to perhaps take into
     * account speed of the device, and what we want to do.
     * (although the disabling of particular alg's could be controlled
     * by the device driver with sysctl's.) - this is where we
     * want most of the decisions made about what we actually want
     * to use from /dev/crypto.
     */
    static int
    cryptodev_usable_ciphers(const int **nids)
    {
    	return (get_cryptodev_ciphers(nids));
    }
    
    static int
    cryptodev_usable_digests(const int **nids)
    {
    #ifdef USE_CRYPTODEV_DIGESTS
    	return (get_cryptodev_digests(nids));
    #else
    	/*
    	 * XXXX just disable all digests for now, because it sucks.
    	 * we need a better way to decide this - i.e. I may not
    	 * want digests on slow cards like hifn on fast machines,
    	 * but might want them on slow or loaded machines, etc.
    	 * will also want them when using crypto cards that don't
    	 * suck moose gonads - would be nice to be able to decide something
    	 * as reasonable default without having hackery that's card dependent.
    	 * of course, the default should probably be just do everything,
    	 * with perhaps a sysctl to turn algoritms off (or have them off
    	 * by default) on cards that generally suck like the hifn.
    	 */
    	*nids = NULL;
    	return (0);
    #endif
    }
    
    static int
    cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        const unsigned char *in, size_t inl)
    {
    	struct crypt_op cryp;
    	struct dev_crypto_state *state = ctx->cipher_data;
    	struct session_op *sess = &state->d_sess;
    	const void *iiv;
    	unsigned char save_iv[EVP_MAX_IV_LENGTH];
    
    	if (state->d_fd < 0)
    		return (0);
    	if (!inl)
    		return (1);
    	if ((inl % ctx->cipher->block_size) != 0)
    		return (0);
    
    	memset(&cryp, 0, sizeof(cryp));
    
    	cryp.ses = sess->ses;
    	cryp.flags = 0;
    	cryp.len = inl;
    	cryp.src = (caddr_t) in;
    	cryp.dst = (caddr_t) out;
    	cryp.mac = 0;
    
    	cryp.op = ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
    
    	if (ctx->cipher->iv_len) {
    		cryp.iv = (caddr_t) ctx->iv;
    		if (!ctx->encrypt) {
    			iiv = in + inl - ctx->cipher->iv_len;
    			memcpy(save_iv, iiv, ctx->cipher->iv_len);
    		}
    	} else
    		cryp.iv = NULL;
    
    	if (ioctl(state->d_fd, CIOCCRYPT, &cryp) == -1) {
    		/* XXX need better errror handling
    		 * this can fail for a number of different reasons.
    		 */
    		return (0);
    	}
    
    	if (ctx->cipher->iv_len) {
    		if (ctx->encrypt)
    			iiv = out + inl - ctx->cipher->iv_len;
    		else
    			iiv = save_iv;
    		memcpy(ctx->iv, iiv, ctx->cipher->iv_len);
    	}
    	return (1);
    }
    
    static int
    cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
        const unsigned char *iv, int enc)
    {
    	struct dev_crypto_state *state = ctx->cipher_data;
    	struct session_op *sess = &state->d_sess;
    	int cipher = -1, i;
    
    	for (i = 0; ciphers[i].id; i++)
    		if (ctx->cipher->nid == ciphers[i].nid &&
    		    ctx->cipher->iv_len <= ciphers[i].ivmax &&
    		    ctx->key_len == ciphers[i].keylen) {
    			cipher = ciphers[i].id;
    			break;
    		}
    
    	if (!ciphers[i].id) {
    		state->d_fd = -1;
    		return (0);
    	}
    
    	memset(sess, 0, sizeof(struct session_op));
    
    	if ((state->d_fd = get_dev_crypto()) < 0)
    		return (0);
    
    	sess->key = (caddr_t)key;
    	sess->keylen = ctx->key_len;
    	sess->cipher = cipher;
    
    	if (ioctl(state->d_fd, CIOCGSESSION, sess) == -1) {
    		put_dev_crypto(state->d_fd);
    		state->d_fd = -1;
    		return (0);
    	}
    	return (1);
    }
    
    /*
     * free anything we allocated earlier when initting a
     * session, and close the session.
     */
    static int
    cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
    {
    	int ret = 0;
    	struct dev_crypto_state *state = ctx->cipher_data;
    	struct session_op *sess = &state->d_sess;
    
    	if (state->d_fd < 0)
    		return (0);
    
    	/* XXX if this ioctl fails, someting's wrong. the invoker
    	 * may have called us with a bogus ctx, or we could
    	 * have a device that for whatever reason just doesn't
    	 * want to play ball - it's not clear what's right
    	 * here - should this be an error? should it just
    	 * increase a counter, hmm. For right now, we return
    	 * 0 - I don't believe that to be "right". we could
    	 * call the gorpy openssl lib error handlers that
    	 * print messages to users of the library. hmm..
    	 */
    
    	if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) == -1) {
    		ret = 0;
    	} else {
    		ret = 1;
    	}
    	put_dev_crypto(state->d_fd);
    	state->d_fd = -1;
    
    	return (ret);
    }
    
    /*
     * libcrypto EVP stuff - this is how we get wired to EVP so the engine
     * gets called when libcrypto requests a cipher NID.
     */
    
    /* RC4 */
    const EVP_CIPHER cryptodev_rc4 = {
    	NID_rc4,
    	1, 16, 0,
    	EVP_CIPH_VARIABLE_LENGTH,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	NULL,
    	NULL,
    	NULL
    };
    
    /* DES CBC EVP */
    const EVP_CIPHER cryptodev_des_cbc = {
    	NID_des_cbc,
    	8, 8, 8,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    /* 3DES CBC EVP */
    const EVP_CIPHER cryptodev_3des_cbc = {
    	NID_des_ede3_cbc,
    	8, 24, 8,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_bf_cbc = {
    	NID_bf_cbc,
    	8, 16, 8,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_cast_cbc = {
    	NID_cast5_cbc,
    	8, 16, 8,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_aes_cbc = {
    	NID_aes_128_cbc,
    	16, 16, 16,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_aes_192_cbc = {
    	NID_aes_192_cbc,
    	16, 24, 16,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_aes_256_cbc = {
    	NID_aes_256_cbc,
    	16, 32, 16,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    /*
     * Registered by the ENGINE when used to find out how to deal with
     * a particular NID in the ENGINE. this says what we'll do at the
     * top level - note, that list is restricted by what we answer with
     */
    static int
    cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
        const int **nids, int nid)
    {
    	if (!cipher)
    		return (cryptodev_usable_ciphers(nids));
    
    	switch (nid) {
    	case NID_rc4:
    		*cipher = &cryptodev_rc4;
    		break;
    	case NID_des_ede3_cbc:
    		*cipher = &cryptodev_3des_cbc;
    		break;
    	case NID_des_cbc:
    		*cipher = &cryptodev_des_cbc;
    		break;
    	case NID_bf_cbc:
    		*cipher = &cryptodev_bf_cbc;
    		break;
    	case NID_cast5_cbc:
    		*cipher = &cryptodev_cast_cbc;
    		break;
    	case NID_aes_128_cbc:
    		*cipher = &cryptodev_aes_cbc;
    		break;
    	case NID_aes_192_cbc:
    		*cipher = &cryptodev_aes_192_cbc;
    		break;
    	case NID_aes_256_cbc:
    		*cipher = &cryptodev_aes_256_cbc;
    		break;
    	default:
    		*cipher = NULL;
    		break;
    	}
    	return (*cipher != NULL);
    }
    
    
    #ifdef USE_CRYPTODEV_DIGESTS
    
    /* convert digest type to cryptodev */
    static int
    digest_nid_to_cryptodev(int nid)
    {
    	int i;
    
    	for (i = 0; digests[i].id; i++)
    		if (digests[i].nid == nid)
    			return (digests[i].id);
    	return (0);
    }
    
    
    static int
    digest_key_length(int nid)
    {
    	int i;
    
    	for (i = 0; digests[i].id; i++)
    		if (digests[i].nid == nid)
    			return digests[i].keylen;
    	return (0);
    }
    
    
    static int cryptodev_digest_init(EVP_MD_CTX *ctx)
    {
    	struct dev_crypto_state *state = ctx->md_data;
    	struct session_op *sess = &state->d_sess;
    	int digest;
    
    	if ((digest = digest_nid_to_cryptodev(ctx->digest->type)) == NID_undef){
    		printf("cryptodev_digest_init: Can't get digest \n");
    		return (0);
    	}
    
    	memset(state, 0, sizeof(struct dev_crypto_state));
    
    	if ((state->d_fd = get_dev_crypto()) < 0) {
    		printf("cryptodev_digest_init: Can't get Dev \n");
    		return (0);
    	}
    
    	sess->mackey = state->dummy_mac_key;
    	sess->mackeylen = digest_key_length(ctx->digest->type);
    	sess->mac = digest;
    
    	if (ioctl(state->d_fd, CIOCGSESSION, sess) < 0) {
    		put_dev_crypto(state->d_fd);
    		state->d_fd = -1;
    		printf("cryptodev_digest_init: Open session failed\n");
    		return (0);
    	}
    
    	return (1);
    }
    
    static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
    		size_t count)
    {
    	struct crypt_op cryp;
    	struct dev_crypto_state *state = ctx->md_data;
    	struct session_op *sess = &state->d_sess;
    
    	if (!data || state->d_fd < 0) {
    		printf("cryptodev_digest_update: illegal inputs \n");
    		return (0);
    	}
    
    	if (!count) {
    		return (0);
    	}
    #ifndef OPENSSL_CRYPTODEF_HASH_NO_ONESHOT
    	if (!(ctx->flags & EVP_MD_CTX_FLAG_ONESHOT)) {
    		/* if application doesn't support one buffer */
    		state->mac_data = OPENSSL_realloc(state->mac_data, state->mac_len + count);
    
    		if (!state->mac_data) {
    			printf("cryptodev_digest_update: realloc failed\n");
    			return (0);
    		}
    
    		memcpy(state->mac_data + state->mac_len, data, count);
       		state->mac_len += count;
    	
    		return (1);
    	}
    #endif
    	memset(&cryp, 0, sizeof(cryp));
    
    	cryp.ses = sess->ses;
    	cryp.flags = 0;
    	cryp.len = count;
    	cryp.src = (caddr_t) data;
    	cryp.dst = NULL;
    	cryp.mac = (caddr_t) state->digest_res;
    	if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
    		printf("cryptodev_digest_update: digest failed\n");
    		return (0);
    	}
    	return (1);
    }
    
    
    static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
    {
    	struct crypt_op cryp;
    	struct dev_crypto_state *state = ctx->md_data;
    	struct session_op *sess = &state->d_sess;
    
    	int ret = 1;
    
    	if (!md || state->d_fd < 0) {
    		printf("cryptodev_digest_final: illegal input\n");
    		return(0);
    	}
    #ifndef OPENSSL_CRYPTODEF_HASH_NO_ONESHOT
    	if (! (ctx->flags & EVP_MD_CTX_FLAG_ONESHOT) ) {
    		/* if application doesn't support one buffer */
    		memset(&cryp, 0, sizeof(cryp));
    		cryp.ses = sess->ses;
    		cryp.flags = 0;
    		cryp.len = state->mac_len;
    		cryp.src = state->mac_data;
    		cryp.dst = NULL;
    		cryp.mac = (caddr_t)md;
    		if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
    			printf("cryptodev_digest_final: digest failed\n");
    			return (0);
    		}
    
    		return 1;
    	}
    #endif
    	memcpy(md, state->digest_res, ctx->digest->md_size);
    
    	return (ret);
    }
    
    
    static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
    {
    	int ret = 1;
    	struct dev_crypto_state *state = ctx->md_data;
    	struct session_op *sess = &state->d_sess;
    
    	if (state == NULL)
    	  return 0;
    
    	if (state->d_fd < 0) {
    		printf("cryptodev_digest_cleanup: illegal input\n");
    		return (0);
    	}
    
    	if (state->mac_data) {
    		OPENSSL_free(state->mac_data);
    		state->mac_data = NULL;
    		state->mac_len = 0;
    	}
    
    	if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
    		printf("cryptodev_digest_cleanup: failed to close session\n");
    		ret = 0;
    	} else {
    		ret = 1;
    	}
    	put_dev_crypto(state->d_fd);	
    	state->d_fd = -1;
    
    	return (ret);
    }
    
    static int cryptodev_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
    {
    	struct dev_crypto_state *fstate = from->md_data;
    	struct dev_crypto_state *dstate = to->md_data;
    	struct session_op *sess;
    	int digest;
    
    	if (dstate == NULL || fstate == NULL)
    	  return 1;
    
           	memcpy(dstate, fstate, sizeof(struct dev_crypto_state));
    
    	sess = &dstate->d_sess;
    
    	digest = digest_nid_to_cryptodev(to->digest->type);
    
    	sess->mackey = dstate->dummy_mac_key;
    	sess->mackeylen = digest_key_length(to->digest->type);
    	sess->mac = digest;
    
    	dstate->d_fd = get_dev_crypto();
    
    	if (ioctl(dstate->d_fd, CIOCGSESSION, sess) < 0) {
    		put_dev_crypto(dstate->d_fd);
    		dstate->d_fd = -1;
    		printf("cryptodev_digest_init: Open session failed\n");
    		return (0);
    	}
    
    	if (fstate->mac_len != 0) {
    	        if (fstate->mac_data != NULL)
    	                {
            		dstate->mac_data = OPENSSL_malloc(fstate->mac_len);
    	        	memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len);
               		dstate->mac_len = fstate->mac_len;
    	        	}
    	}
    
    	return 1;
    }
    
    
    const EVP_MD cryptodev_sha1 = {
    	NID_sha1,
    	NID_undef, 
    	SHA_DIGEST_LENGTH, 
    	EVP_MD_FLAG_ONESHOT,
    	cryptodev_digest_init,
    	cryptodev_digest_update,
    	cryptodev_digest_final,
    	cryptodev_digest_copy,
    	cryptodev_digest_cleanup,
    	EVP_PKEY_NULL_method,
    	SHA_CBLOCK,
    	sizeof(struct dev_crypto_state),
    };
    
    const EVP_MD cryptodev_md5 = {
    	NID_md5,
    	NID_undef, 
    	16 /* MD5_DIGEST_LENGTH */, 
    	EVP_MD_FLAG_ONESHOT,
    	cryptodev_digest_init,
    	cryptodev_digest_update,
    	cryptodev_digest_final,
    	cryptodev_digest_copy,
    	cryptodev_digest_cleanup,
    	EVP_PKEY_NULL_method,
    	64 /* MD5_CBLOCK */,
    	sizeof(struct dev_crypto_state),
    };
    
    #endif /* USE_CRYPTODEV_DIGESTS */
    
    
    static int
    cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
        const int **nids, int nid)
    {
    	if (!digest)
    		return (cryptodev_usable_digests(nids));
    
    	switch (nid) {
    #ifdef USE_CRYPTODEV_DIGESTS
    	case NID_md5:
    		*digest = &cryptodev_md5; 
    		break;
    	case NID_sha1:
    		*digest = &cryptodev_sha1;
     		break;
    	default:
    #endif /* USE_CRYPTODEV_DIGESTS */
    		*digest = NULL;
    		break;
    	}
    	return (*digest != NULL);
    }
    
    /*
     * Convert a BIGNUM to the representation that /dev/crypto needs.
     * Upon completion of use, the caller is responsible for freeing
     * crp->crp_p.
     */
    static int
    bn2crparam(const BIGNUM *a, struct crparam *crp)
    {
    	int i, j, k;
    	ssize_t bytes, bits;
    	u_char *b;
    
    	crp->crp_p = NULL;
    	crp->crp_nbits = 0;
    
    	bits = BN_num_bits(a);
    	bytes = (bits + 7) / 8;
    
    	b = malloc(bytes);
    	if (b == NULL)
    		return (1);
    	memset(b, 0, bytes);
    
    	crp->crp_p = (caddr_t) b;
    	crp->crp_nbits = bits;
    
    	for (i = 0, j = 0; i < a->top; i++) {
    		for (k = 0; k < BN_BITS2 / 8; k++) {
    			if ((j + k) >= bytes)
    				return (0);
    			b[j + k] = a->d[i] >> (k * 8);
    		}
    		j += BN_BITS2 / 8;
    	}
    	return (0);
    }
    
    /* Convert a /dev/crypto parameter to a BIGNUM */
    static int
    crparam2bn(struct crparam *crp, BIGNUM *a)
    {
    	u_int8_t *pd;
    	int i, bytes;
    
    	bytes = (crp->crp_nbits + 7) / 8;
    
    	if (bytes == 0)
    		return (-1);
    
    	if ((pd = (u_int8_t *) malloc(bytes)) == NULL)
    		return (-1);
    
    	for (i = 0; i < bytes; i++)
    		pd[i] = crp->crp_p[bytes - i - 1];
    
    	BN_bin2bn(pd, bytes, a);
    	free(pd);
    
    	return (0);
    }
    
    static void
    zapparams(struct crypt_kop *kop)
    {
    	int i;
    
    	for (i = 0; i < kop->crk_iparams + kop->crk_oparams; i++) {
    		if (kop->crk_param[i].crp_p)
    			free(kop->crk_param[i].crp_p);
    		kop->crk_param[i].crp_p = NULL;
    		kop->crk_param[i].crp_nbits = 0;
    	}
    }
    
    static int
    cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r, int slen, BIGNUM *s)
    {
    	int fd, ret = -1;
    
    	if ((fd = get_asym_dev_crypto()) < 0)
    		return (ret);
    
    	if (r) {
    		kop->crk_param[kop->crk_iparams].crp_p = calloc(rlen, sizeof(char));
    		kop->crk_param[kop->crk_iparams].crp_nbits = rlen * 8;
    		kop->crk_oparams++;
    	}
    	if (s) {
    		kop->crk_param[kop->crk_iparams+1].crp_p = calloc(slen, sizeof(char));
    		kop->crk_param[kop->crk_iparams+1].crp_nbits = slen * 8;
    		kop->crk_oparams++;
    	}
    
    	if (ioctl(fd, CIOCKEY, kop) == 0) {
    		if (r)
    			crparam2bn(&kop->crk_param[kop->crk_iparams], r);
    		if (s)
    			crparam2bn(&kop->crk_param[kop->crk_iparams+1], s);
    		ret = 0;
    	}
    
    	return (ret);
    }
    
    static int
    cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
        const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
    {
    	struct crypt_kop kop;
    	int ret = 1;
    
    	/* Currently, we know we can do mod exp iff we can do any
    	 * asymmetric operations at all.
    	 */
    	if (cryptodev_asymfeat == 0) {
    		ret = BN_mod_exp(r, a, p, m, ctx);
    		return (ret);
    	}
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_MOD_EXP;
    
    	/* inputs: a^p % m */
    	if (bn2crparam(a, &kop.crk_param[0]))
    		goto err;
    	if (bn2crparam(p, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(m, &kop.crk_param[2]))
    		goto err;
    	kop.crk_iparams = 3;
    
    	if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL)) {
    		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    		printf("OCF asym process failed, Running in software\n");
    		ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
    
    	} else if (ECANCELED == kop.crk_status) {
    		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    		printf("OCF hardware operation cancelled. Running in Software\n");
    		ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
    	}
    	/* else cryptodev operation worked ok ==> ret = 1*/
    
    err:
    	zapparams(&kop);
    	return (ret);
    }
    
    static int
    cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
    {
    	int r;
    	ctx = BN_CTX_new();
    	r = cryptodev_bn_mod_exp(r0, I, rsa->d, rsa->n, ctx, NULL);
    	BN_CTX_free(ctx);
    	return (r);
    }
    
    static int
    cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
    {
    	struct crypt_kop kop;
    	int ret = 1;
    
    	if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) {
    		/* XXX 0 means failure?? */
    		return (0);
    	}
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_MOD_EXP_CRT;
    	/* inputs: rsa->p rsa->q I rsa->dmp1 rsa->dmq1 rsa->iqmp */
    	if (bn2crparam(rsa->p, &kop.crk_param[0]))
    		goto err;
    	if (bn2crparam(rsa->q, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(I, &kop.crk_param[2]))
    		goto err;
    	if (bn2crparam(rsa->dmp1, &kop.crk_param[3]))
    		goto err;
    	if (bn2crparam(rsa->dmq1, &kop.crk_param[4]))
    		goto err;
    	if (bn2crparam(rsa->iqmp, &kop.crk_param[5]))
    		goto err;
    	kop.crk_iparams = 6;
    
    	if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL)) {
    		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    		printf("OCF asym process failed, running in Software\n");
    		ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
    
    	} else if (ECANCELED == kop.crk_status) {
    		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    		printf("OCF hardware operation cancelled. Running in Software\n");
    		ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
    	}
    	/* else cryptodev operation worked ok ==> ret = 1*/
    
    err:
    	zapparams(&kop);
    	return (ret);
    }
    
    static RSA_METHOD cryptodev_rsa = {
    	"cryptodev RSA method",
    	NULL,				/* rsa_pub_enc */
    	NULL,				/* rsa_pub_dec */
    	NULL,				/* rsa_priv_enc */
    	NULL,				/* rsa_priv_dec */
    	NULL,
    	NULL,
    	NULL,				/* init */
    	NULL,				/* finish */
    	0,				/* flags */
    	NULL,				/* app_data */
    	NULL,				/* rsa_sign */
    	NULL				/* rsa_verify */
    };
    
    static int
    cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
        const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
    {
    	return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
    }
    
    static int
    cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
        BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
        BN_CTX *ctx, BN_MONT_CTX *mont)
    {
    	BIGNUM t2;
    	int ret = 0;
    
    	BN_init(&t2);
    
    	/* v = ( g^u1 * y^u2 mod p ) mod q */
    	/* let t1 = g ^ u1 mod p */
    	ret = 0;
    
    	if (!dsa->meth->bn_mod_exp(dsa,t1,dsa->g,u1,dsa->p,ctx,mont))
    		goto err;
    
    	/* let t2 = y ^ u2 mod p */
    	if (!dsa->meth->bn_mod_exp(dsa,&t2,dsa->pub_key,u2,dsa->p,ctx,mont))
    		goto err;
    	/* let u1 = t1 * t2 mod p */
    	if (!BN_mod_mul(u1,t1,&t2,dsa->p,ctx))
    		goto err;
    
    	BN_copy(t1,u1);
    
    	ret = 1;
    err:
    	BN_free(&t2);
    	return(ret);
    }
    
    static DSA_SIG *
    cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
    {
    	struct crypt_kop kop;
    	BIGNUM *r = NULL, *s = NULL;
    	DSA_SIG *dsaret = NULL;
    
    	if ((r = BN_new()) == NULL)
    		goto err;
    	if ((s = BN_new()) == NULL) {
    		BN_free(r);
    		goto err;
    	}
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_DSA_SIGN;
    
    	/* inputs: dgst dsa->p dsa->q dsa->g dsa->priv_key */
    	kop.crk_param[0].crp_p = (caddr_t)dgst;
    	kop.crk_param[0].crp_nbits = dlen * 8;
    	if (bn2crparam(dsa->p, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(dsa->q, &kop.crk_param[2]))
    		goto err;
    	if (bn2crparam(dsa->g, &kop.crk_param[3]))
    		goto err;
    	if (bn2crparam(dsa->priv_key, &kop.crk_param[4]))
    		goto err;
    	kop.crk_iparams = 5;
    
    	if (cryptodev_asym(&kop, BN_num_bytes(dsa->q), r,
    	    BN_num_bytes(dsa->q), s) == 0) {
    		dsaret = DSA_SIG_new();
    		dsaret->r = r;
    		dsaret->s = s;
    	} else {
    		const DSA_METHOD *meth = DSA_OpenSSL();
    		BN_free(r);
    		BN_free(s);
    		dsaret = (meth->dsa_do_sign)(dgst, dlen, dsa);
    	}
    err:
    	kop.crk_param[0].crp_p = NULL;
    	zapparams(&kop);
    	return (dsaret);
    }
    
    static int
    cryptodev_dsa_verify(const unsigned char *dgst, int dlen,
        DSA_SIG *sig, DSA *dsa)
    {
    	struct crypt_kop kop;
    	int dsaret = 1;
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_DSA_VERIFY;
    
    	/* inputs: dgst dsa->p dsa->q dsa->g dsa->pub_key sig->r sig->s */
    	kop.crk_param[0].crp_p = (caddr_t)dgst;
    	kop.crk_param[0].crp_nbits = dlen * 8;
    	if (bn2crparam(dsa->p, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(dsa->q, &kop.crk_param[2]))
    		goto err;
    	if (bn2crparam(dsa->g, &kop.crk_param[3]))
    		goto err;
    	if (bn2crparam(dsa->pub_key, &kop.crk_param[4]))
    		goto err;
    	if (bn2crparam(sig->r, &kop.crk_param[5]))
    		goto err;
    	if (bn2crparam(sig->s, &kop.crk_param[6]))
    		goto err;
    	kop.crk_iparams = 7;
    
    	if (cryptodev_asym(&kop, 0, NULL, 0, NULL) == 0) {
    /*OCF success value is 0, if not zero, change dsaret to fail*/
    		if(0 != kop.crk_status) dsaret  = 0;
    	} else {
    		const DSA_METHOD *meth = DSA_OpenSSL();
    
    		dsaret = (meth->dsa_do_verify)(dgst, dlen, sig, dsa);
    	}
    err:
    	kop.crk_param[0].crp_p = NULL;
    	zapparams(&kop);
    	return (dsaret);
    }
    
    static DSA_METHOD cryptodev_dsa = {
    	"cryptodev DSA method",
    	NULL,
    	NULL,				/* dsa_sign_setup */
    	NULL,
    	NULL,				/* dsa_mod_exp */
    	NULL,
    	NULL,				/* init */
    	NULL,				/* finish */
    	0,	/* flags */
    	NULL	/* app_data */
    };
    
    static int
    cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
        const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
        BN_MONT_CTX *m_ctx)
    {
    	return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
    }
    
    static int
    cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
    {
    	struct crypt_kop kop;
    	int dhret = 1;
    	int fd, keylen;
    
    	if ((fd = get_asym_dev_crypto()) < 0) {
    		const DH_METHOD *meth = DH_OpenSSL();
    
    		return ((meth->compute_key)(key, pub_key, dh));
    	}
    
    	keylen = BN_num_bits(dh->p);
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_DH_COMPUTE_KEY;
    
    	/* inputs: dh->priv_key pub_key dh->p key */
    	if (bn2crparam(dh->priv_key, &kop.crk_param[0]))
    		goto err;
    	if (bn2crparam(pub_key, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(dh->p, &kop.crk_param[2]))
    		goto err;
    	kop.crk_iparams = 3;
    
    	kop.crk_param[3].crp_p = (caddr_t) key;
    	kop.crk_param[3].crp_nbits = keylen * 8;
    	kop.crk_oparams = 1;
    
    	if (ioctl(fd, CIOCKEY, &kop) == -1) {
    		const DH_METHOD *meth = DH_OpenSSL();
    
    		dhret = (meth->compute_key)(key, pub_key, dh);
    	}
    err:
    	kop.crk_param[3].crp_p = NULL;
    	zapparams(&kop);
    	return (dhret);
    }
    
    static DH_METHOD cryptodev_dh = {
    	"cryptodev DH method",
    	NULL,				/* cryptodev_dh_generate_key */
    	NULL,
    	NULL,
    	NULL,
    	NULL,
    	0,	/* flags */
    	NULL	/* app_data */
    };
    
    /*
     * ctrl right now is just a wrapper that doesn't do much
     * but I expect we'll want some options soon.
     */
    static int
    cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
    {
    #ifdef HAVE_SYSLOG_R
    	struct syslog_data sd = SYSLOG_DATA_INIT;
    #endif
    
    	switch (cmd) {
    	default:
    #ifdef HAVE_SYSLOG_R
    		syslog_r(LOG_ERR, &sd,
    		    "cryptodev_ctrl: unknown command %d", cmd);
    #else
    		syslog(LOG_ERR, "cryptodev_ctrl: unknown command %d", cmd);
    #endif
    		break;
    	}
    	return (1);
    }
    
    void
    ENGINE_load_cryptodev(void)
    {
    	ENGINE *engine = ENGINE_new();
    	int fd;
    
    	if (engine == NULL)
    		return;
    	if ((fd = get_dev_crypto()) < 0) {
    		ENGINE_free(engine);
    		return;
    	}
    
    	/*
    	 * find out what asymmetric crypto algorithms we support
    	 */
    	if (ioctl(fd, CIOCASYMFEAT, &cryptodev_asymfeat) == -1) {
    		put_dev_crypto(fd);
    		ENGINE_free(engine);
    		return;
    	}
    	put_dev_crypto(fd);
    
    	if (!ENGINE_set_id(engine, "cryptodev") ||
    	    !ENGINE_set_name(engine, "BSD cryptodev engine") ||
    	    !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
    	    !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
    	    !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
    	    !ENGINE_set_cmd_defns(engine, cryptodev_defns)) {
    		ENGINE_free(engine);
    		return;
    	}
    
    	if (ENGINE_set_RSA(engine, &cryptodev_rsa)) {
    		const RSA_METHOD *rsa_meth = RSA_PKCS1_SSLeay();
    
    		cryptodev_rsa.bn_mod_exp = rsa_meth->bn_mod_exp;
    		cryptodev_rsa.rsa_mod_exp = rsa_meth->rsa_mod_exp;
    		cryptodev_rsa.rsa_pub_enc = rsa_meth->rsa_pub_enc;
    		cryptodev_rsa.rsa_pub_dec = rsa_meth->rsa_pub_dec;
    		cryptodev_rsa.rsa_priv_enc = rsa_meth->rsa_priv_enc;
    		cryptodev_rsa.rsa_priv_dec = rsa_meth->rsa_priv_dec;
    		if (cryptodev_asymfeat & CRF_MOD_EXP) {
    			cryptodev_rsa.bn_mod_exp = cryptodev_bn_mod_exp;
    			if (cryptodev_asymfeat & CRF_MOD_EXP_CRT)
    				cryptodev_rsa.rsa_mod_exp =
    				    cryptodev_rsa_mod_exp;
    			else
    				cryptodev_rsa.rsa_mod_exp =
    				    cryptodev_rsa_nocrt_mod_exp;
    		}
    	}
    
    	if (ENGINE_set_DSA(engine, &cryptodev_dsa)) {
    		const DSA_METHOD *meth = DSA_OpenSSL();
    
    		memcpy(&cryptodev_dsa, meth, sizeof(DSA_METHOD));
    		if (cryptodev_asymfeat & CRF_DSA_SIGN)
    			cryptodev_dsa.dsa_do_sign = cryptodev_dsa_do_sign;
    		if (cryptodev_asymfeat & CRF_MOD_EXP) {
    			cryptodev_dsa.bn_mod_exp = cryptodev_dsa_bn_mod_exp;
    			cryptodev_dsa.dsa_mod_exp = cryptodev_dsa_dsa_mod_exp;
    		}
    		if (cryptodev_asymfeat & CRF_DSA_VERIFY)
    			cryptodev_dsa.dsa_do_verify = cryptodev_dsa_verify;
    	}
    
    	if (ENGINE_set_DH(engine, &cryptodev_dh)){
    		const DH_METHOD *dh_meth = DH_OpenSSL();
    
    		cryptodev_dh.generate_key = dh_meth->generate_key;
    		cryptodev_dh.compute_key = dh_meth->compute_key;
    		cryptodev_dh.bn_mod_exp = dh_meth->bn_mod_exp;
    		if (cryptodev_asymfeat & CRF_MOD_EXP) {
    			cryptodev_dh.bn_mod_exp = cryptodev_mod_exp_dh;
    			if (cryptodev_asymfeat & CRF_DH_COMPUTE_KEY)
    				cryptodev_dh.compute_key =
    				    cryptodev_dh_compute_key;
    		}
    	}
    
    	ENGINE_add(engine);
    	ENGINE_free(engine);
    	ERR_clear_error();
    }
    
    #endif /* HAVE_CRYPTODEV */
    


    I also tried to make the openssl version 1.0.0d which was explained about the wiki which you have informed to us.
    As a result, there is not any problem to do the "make" command. Just in case, I attached the log file just in case.

    3276.1_0_0d_log.log

    Please provide us the solution to resolve this problem.

    Best regards,

    Kaka

  • Kato,

    The instructions from the link are fine.

    Here are my steps to successfully cross-compile the latest openssl package:

    1. Download and extract openssl-1.0.1g
    2. cd openssl-1.0.1g
    3. Edit the Makefile as shown in the guide from the link above, replacing arm-arago-linux-gnueabi- with arm-linux-gnueabihf-
    4. Manually add the changes from the patch to the openssl-1.0.1g/crypto/engine/eng_cryptodev.c file.
    5. make
    6. make install
    7. Test the generated openssl binary with file ${INSTALL_PREFIX}/usr/local/ssl/bin/openssl command:

    usr/local/ssl/bin/openssl: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.31, BuildID[sha1]=0x437dfc5317ebdb2a34872dd89c061b65a17c425f, not stripped

    Best regards,
    Miroslav

  • Miroslav,

    Thank you for verification in your side.

    Would you please share the "Makefile" and "eng_cryptodev.c" file? Or would you please double check whether my revised code of eng_cryptodev.c is correct? And did you use the SDK version 7?

    I have done the make command with the same setup as you have posted. However, I could not make them. Let me know if you have further question.

    Best regards,

    Kaka

  • /*
     * Copyright (c) 2002 Bob Beck <beck@openbsd.org>
     * Copyright (c) 2002 Theo de Raadt
     * Copyright (c) 2002 Markus Friedl
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     * 1. Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     * 2. Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
     * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
     * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    
    #include <openssl/objects.h>
    #include <openssl/engine.h>
    #include <openssl/evp.h>
    #include <openssl/bn.h>
    
    #if (defined(__unix__) || defined(unix)) && !defined(USG) && \
    	(defined(OpenBSD) || defined(__FreeBSD__))
    #include <sys/param.h>
    # if (OpenBSD >= 200112) || ((__FreeBSD_version >= 470101 && __FreeBSD_version < 500000) || __FreeBSD_version >= 500041)
    #  define HAVE_CRYPTODEV
    # endif
    # if (OpenBSD >= 200110)
    #  define HAVE_SYSLOG_R
    # endif
    #endif
    
    #define OPENSSL_CRYPTODEF_HASH_NO_ONESHOT 1
    
    #ifndef HAVE_CRYPTODEV
    
    void
    ENGINE_load_cryptodev(void)
    {
    	/* This is a NOP on platforms without /dev/crypto */
    	return;
    }
    
    #else 
     
    #include <sys/types.h>
    #include <crypto/cryptodev.h>
    #include <crypto/dh/dh.h>
    #include <crypto/dsa/dsa.h>
    #include <crypto/err/err.h>
    #include <crypto/rsa/rsa.h>
    #include <sys/ioctl.h>
    #include <errno.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <stdarg.h>
    #include <syslog.h>
    #include <errno.h>
    #include <string.h>
    
    struct dev_crypto_state {
    	struct session_op d_sess;
    	int d_fd;
    
    #ifdef USE_CRYPTODEV_DIGESTS
    	char dummy_mac_key[HASH_MAX_LEN];
    
    	unsigned char digest_res[HASH_MAX_LEN];
    	char *mac_data;
    	int mac_len;
    #endif
    };
    
    static u_int32_t cryptodev_asymfeat = 0;
    
    static int get_asym_dev_crypto(void);
    static int open_dev_crypto(void);
    static int get_dev_crypto(void);
    static int get_cryptodev_ciphers(const int **cnids);
    #ifdef USE_CRYPTODEV_DIGESTS
    static int get_cryptodev_digests(const int **cnids);
    #endif
    static int cryptodev_usable_ciphers(const int **nids);
    static int cryptodev_usable_digests(const int **nids);
    static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        const unsigned char *in, size_t inl);
    static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
        const unsigned char *iv, int enc);
    static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx);
    static int cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
        const int **nids, int nid);
    static int cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
        const int **nids, int nid);
    static int bn2crparam(const BIGNUM *a, struct crparam *crp);
    static int crparam2bn(struct crparam *crp, BIGNUM *a);
    static void zapparams(struct crypt_kop *kop);
    static int cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r,
        int slen, BIGNUM *s);
    
    static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a,
        const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
    static int cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I,
        RSA *rsa, BN_CTX *ctx);
    static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
    static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a,
        const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
    static int cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
        BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
        BN_CTX *ctx, BN_MONT_CTX *mont);
    static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst,
        int dlen, DSA *dsa);
    static int cryptodev_dsa_verify(const unsigned char *dgst, int dgst_len,
        DSA_SIG *sig, DSA *dsa);
    static int cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
        const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
        BN_MONT_CTX *m_ctx);
    static int cryptodev_dh_compute_key(unsigned char *key,
        const BIGNUM *pub_key, DH *dh);
    static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
        void (*f)(void));
    void ENGINE_load_cryptodev(void);
    
    static const ENGINE_CMD_DEFN cryptodev_defns[] = {
    	{ 0, NULL, NULL, 0 }
    };
    
    static struct {
    	int	id;
    	int	nid;
    	int	ivmax;
    	int	keylen;
    } ciphers[] = {
    	{ CRYPTO_ARC4,			NID_rc4,		0,	16, },
    	{ CRYPTO_DES_CBC,		NID_des_cbc,		8,	 8, },
    	{ CRYPTO_3DES_CBC,		NID_des_ede3_cbc,	8,	24, },
    	{ CRYPTO_AES_CBC,		NID_aes_128_cbc,	16,	16, },
    	{ CRYPTO_AES_CBC,		NID_aes_192_cbc,	16,	24, },
    	{ CRYPTO_AES_CBC,		NID_aes_256_cbc,	16,	32, },
    	{ CRYPTO_BLF_CBC,		NID_bf_cbc,		8,	16, },
    	{ CRYPTO_CAST_CBC,		NID_cast5_cbc,		8,	16, },
    	{ CRYPTO_SKIPJACK_CBC,		NID_undef,		0,	 0, },
    	{ 0,				NID_undef,		0,	 0, },
    };
    
    #ifdef USE_CRYPTODEV_DIGESTS
    static struct {
    	int	id;
    	int	nid;
    	int 	keylen;
    } digests[] = {
    	{ CRYPTO_MD5_HMAC,		NID_hmacWithMD5,	16},
    	{ CRYPTO_SHA1_HMAC,		NID_hmacWithSHA1,	20},
    	{ CRYPTO_RIPEMD160_HMAC,	NID_ripemd160,		16/*?*/},
    	{ CRYPTO_MD5_KPDK,		NID_undef,		0},
    	{ CRYPTO_SHA1_KPDK,		NID_undef,		0},
    	{ CRYPTO_MD5,			NID_md5,		16},
    	{ CRYPTO_SHA1,			NID_sha1,		20},
    	{ 0,				NID_undef,		0},
    };
    #endif
    
    /*
     * Return a fd if /dev/crypto seems usable, 0 otherwise.
     */
    static int
    open_dev_crypto(void)
    {
    	static int fd = -1;
    
    	if (fd == -1) {
    		if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
    			return (-1);
    		/* close on exec */
    		if (fcntl(fd, F_SETFD, 1) == -1) {
    			close(fd);
    			fd = -1;
    			return (-1);
    		}
    	}
    	return (fd);
    }
    
    static int
    get_dev_crypto(void)
    {
    	int fd, retfd;
    
    	if ((fd = open_dev_crypto()) == -1)
    		return (-1);
    #ifndef CRIOGET_NOT_NEEDED
    	if (ioctl(fd, CRIOGET, &retfd) == -1)
    		return (-1);
    
    	/* close on exec */
    	if (fcntl(retfd, F_SETFD, 1) == -1) {
    		close(retfd);
    		return (-1);
    	}
    #else
            retfd = fd;
    #endif
    	return (retfd);
    }
    
    static void put_dev_crypto(int fd)
    {
    #ifndef CRIOGET_NOT_NEEDED
    	close(fd);
    #endif
    }
    
    /* Caching version for asym operations */
    static int
    get_asym_dev_crypto(void)
    {
    	static int fd = -1;
    
    	if (fd == -1)
    		fd = get_dev_crypto();
    	return fd;
    }
    
    /*
     * Find out what ciphers /dev/crypto will let us have a session for.
     * XXX note, that some of these openssl doesn't deal with yet!
     * returning them here is harmless, as long as we return NULL
     * when asked for a handler in the cryptodev_engine_ciphers routine
     */
    static int
    get_cryptodev_ciphers(const int **cnids)
    {
    	static int nids[CRYPTO_ALGORITHM_MAX];
    	struct session_op sess;
    	int fd, i, count = 0;
    
    	if ((fd = get_dev_crypto()) < 0) {
    		*cnids = NULL;
    		return (0);
    	}
    	memset(&sess, 0, sizeof(sess));
    	sess.key = (caddr_t)"123456789abcdefghijklmno";
    
    	for (i = 0; ciphers[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
    		if (ciphers[i].nid == NID_undef)
    			continue;
    		sess.cipher = ciphers[i].id;
    		sess.keylen = ciphers[i].keylen;
    		sess.mac = 0;
    		if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
    		    ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
    			nids[count++] = ciphers[i].nid;
    	}
    	put_dev_crypto(fd);
    
    	if (count > 0)
    		*cnids = nids;
    	else
    		*cnids = NULL;
    	return (count);
    }
    
    #ifdef USE_CRYPTODEV_DIGESTS
    /*
     * Find out what digests /dev/crypto will let us have a session for.
     * XXX note, that some of these openssl doesn't deal with yet!
     * returning them here is harmless, as long as we return NULL
     * when asked for a handler in the cryptodev_engine_digests routine
     */
    static int
    get_cryptodev_digests(const int **cnids)
    {
    	static int nids[CRYPTO_ALGORITHM_MAX];
    	struct session_op sess;
    	int fd, i, count = 0;
    
    	if ((fd = get_dev_crypto()) < 0) {
    		*cnids = NULL;
    		return (0);
    	}
    	memset(&sess, 0, sizeof(sess));
    	sess.mackey = (caddr_t)"123456789abcdefghijklmno";
    	for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
    		if (digests[i].nid == NID_undef)
    			continue;
    		sess.mac = digests[i].id;
    		sess.mackeylen = digests[i].keylen;
    		sess.cipher = 0;
    		if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
    		    ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
    			nids[count++] = digests[i].nid;
    	}
    	put_dev_crypto(fd);
    
    	if (count > 0)
    		*cnids = nids;
    	else
    		*cnids = NULL;
    	return (count);
    }
    #endif  /* 0 */
    
    /*
     * Find the useable ciphers|digests from dev/crypto - this is the first
     * thing called by the engine init crud which determines what it
     * can use for ciphers from this engine. We want to return
     * only what we can do, anythine else is handled by software.
     *
     * If we can't initialize the device to do anything useful for
     * any reason, we want to return a NULL array, and 0 length,
     * which forces everything to be done is software. By putting
     * the initalization of the device in here, we ensure we can
     * use this engine as the default, and if for whatever reason
     * /dev/crypto won't do what we want it will just be done in
     * software
     *
     * This can (should) be greatly expanded to perhaps take into
     * account speed of the device, and what we want to do.
     * (although the disabling of particular alg's could be controlled
     * by the device driver with sysctl's.) - this is where we
     * want most of the decisions made about what we actually want
     * to use from /dev/crypto.
     */
    static int
    cryptodev_usable_ciphers(const int **nids)
    {
    	return (get_cryptodev_ciphers(nids));
    }
    
    static int
    cryptodev_usable_digests(const int **nids)
    {
    #ifdef USE_CRYPTODEV_DIGESTS
    	return (get_cryptodev_digests(nids));
    #else
    	/*
    	 * XXXX just disable all digests for now, because it sucks.
    	 * we need a better way to decide this - i.e. I may not
    	 * want digests on slow cards like hifn on fast machines,
    	 * but might want them on slow or loaded machines, etc.
    	 * will also want them when using crypto cards that don't
    	 * suck moose gonads - would be nice to be able to decide something
    	 * as reasonable default without having hackery that's card dependent.
    	 * of course, the default should probably be just do everything,
    	 * with perhaps a sysctl to turn algoritms off (or have them off
    	 * by default) on cards that generally suck like the hifn.
    	 */
    	*nids = NULL;
    	return (0);
    #endif
    }
    
    static int
    cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        const unsigned char *in, size_t inl)
    {
    	struct crypt_op cryp;
    	struct dev_crypto_state *state = ctx->cipher_data;
    	struct session_op *sess = &state->d_sess;
    	const void *iiv;
    	unsigned char save_iv[EVP_MAX_IV_LENGTH];
    
    	if (state->d_fd < 0)
    		return (0);
    	if (!inl)
    		return (1);
    	if ((inl % ctx->cipher->block_size) != 0)
    		return (0);
    
    	memset(&cryp, 0, sizeof(cryp));
    
    	cryp.ses = sess->ses;
    	cryp.flags = 0;
    	cryp.len = inl;
    	cryp.src = (caddr_t) in;
    	cryp.dst = (caddr_t) out;
    	cryp.mac = 0;
    
    	cryp.op = ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
    
    	if (ctx->cipher->iv_len) {
    		cryp.iv = (caddr_t) ctx->iv;
    		if (!ctx->encrypt) {
    			iiv = in + inl - ctx->cipher->iv_len;
    			memcpy(save_iv, iiv, ctx->cipher->iv_len);
    		}
    	} else
    		cryp.iv = NULL;
    
    	if (ioctl(state->d_fd, CIOCCRYPT, &cryp) == -1) {
    		/* XXX need better errror handling
    		 * this can fail for a number of different reasons.
    		 */
    		return (0);
    	}
    
    	if (ctx->cipher->iv_len) {
    		if (ctx->encrypt)
    			iiv = out + inl - ctx->cipher->iv_len;
    		else
    			iiv = save_iv;
    		memcpy(ctx->iv, iiv, ctx->cipher->iv_len);
    	}
    	return (1);
    }
    
    static int
    cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
        const unsigned char *iv, int enc)
    {
    	struct dev_crypto_state *state = ctx->cipher_data;
    	struct session_op *sess = &state->d_sess;
    	int cipher = -1, i;
    
    	for (i = 0; ciphers[i].id; i++)
    		if (ctx->cipher->nid == ciphers[i].nid &&
    		    ctx->cipher->iv_len <= ciphers[i].ivmax &&
    		    ctx->key_len == ciphers[i].keylen) {
    			cipher = ciphers[i].id;
    			break;
    		}
    
    	if (!ciphers[i].id) {
    		state->d_fd = -1;
    		return (0);
    	}
    
    	memset(sess, 0, sizeof(struct session_op));
    
    	if ((state->d_fd = get_dev_crypto()) < 0)
    		return (0);
    
    	sess->key = (caddr_t)key;
    	sess->keylen = ctx->key_len;
    	sess->cipher = cipher;
    
    	if (ioctl(state->d_fd, CIOCGSESSION, sess) == -1) {
    		put_dev_crypto(state->d_fd);
    		state->d_fd = -1;
    		return (0);
    	}
    	return (1);
    }
    
    /*
     * free anything we allocated earlier when initting a
     * session, and close the session.
     */
    static int
    cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
    {
    	int ret = 0;
    	struct dev_crypto_state *state = ctx->cipher_data;
    	struct session_op *sess = &state->d_sess;
    
    	if (state->d_fd < 0)
    		return (0);
    
    	/* XXX if this ioctl fails, someting's wrong. the invoker
    	 * may have called us with a bogus ctx, or we could
    	 * have a device that for whatever reason just doesn't
    	 * want to play ball - it's not clear what's right
    	 * here - should this be an error? should it just
    	 * increase a counter, hmm. For right now, we return
    	 * 0 - I don't believe that to be "right". we could
    	 * call the gorpy openssl lib error handlers that
    	 * print messages to users of the library. hmm..
    	 */
    
    	if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) == -1) {
    		ret = 0;
    	} else {
    		ret = 1;
    	}
    	put_dev_crypto(state->d_fd);
    	state->d_fd = -1;
    
    	return (ret);
    }
    
    /*
     * libcrypto EVP stuff - this is how we get wired to EVP so the engine
     * gets called when libcrypto requests a cipher NID.
     */
    
    /* RC4 */
    const EVP_CIPHER cryptodev_rc4 = {
    	NID_rc4,
    	1, 16, 0,
    	EVP_CIPH_VARIABLE_LENGTH,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	NULL,
    	NULL,
    	NULL
    };
    
    /* DES CBC EVP */
    const EVP_CIPHER cryptodev_des_cbc = {
    	NID_des_cbc,
    	8, 8, 8,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    /* 3DES CBC EVP */
    const EVP_CIPHER cryptodev_3des_cbc = {
    	NID_des_ede3_cbc,
    	8, 24, 8,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_bf_cbc = {
    	NID_bf_cbc,
    	8, 16, 8,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_cast_cbc = {
    	NID_cast5_cbc,
    	8, 16, 8,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_aes_cbc = {
    	NID_aes_128_cbc,
    	16, 16, 16,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_aes_192_cbc = {
    	NID_aes_192_cbc,
    	16, 24, 16,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    const EVP_CIPHER cryptodev_aes_256_cbc = {
    	NID_aes_256_cbc,
    	16, 32, 16,
    	EVP_CIPH_CBC_MODE,
    	cryptodev_init_key,
    	cryptodev_cipher,
    	cryptodev_cleanup,
    	sizeof(struct dev_crypto_state),
    	EVP_CIPHER_set_asn1_iv,
    	EVP_CIPHER_get_asn1_iv,
    	NULL
    };
    
    /*
     * Registered by the ENGINE when used to find out how to deal with
     * a particular NID in the ENGINE. this says what we'll do at the
     * top level - note, that list is restricted by what we answer with
     */
    static int
    cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
        const int **nids, int nid)
    {
    	if (!cipher)
    		return (cryptodev_usable_ciphers(nids));
    
    	switch (nid) {
    	case NID_rc4:
    		*cipher = &cryptodev_rc4;
    		break;
    	case NID_des_ede3_cbc:
    		*cipher = &cryptodev_3des_cbc;
    		break;
    	case NID_des_cbc:
    		*cipher = &cryptodev_des_cbc;
    		break;
    	case NID_bf_cbc:
    		*cipher = &cryptodev_bf_cbc;
    		break;
    	case NID_cast5_cbc:
    		*cipher = &cryptodev_cast_cbc;
    		break;
    	case NID_aes_128_cbc:
    		*cipher = &cryptodev_aes_cbc;
    		break;
    	case NID_aes_192_cbc:
    		*cipher = &cryptodev_aes_192_cbc;
    		break;
    	case NID_aes_256_cbc:
    		*cipher = &cryptodev_aes_256_cbc;
    		break;
    	default:
    		*cipher = NULL;
    		break;
    	}
    	return (*cipher != NULL);
    }
    
    
    #ifdef USE_CRYPTODEV_DIGESTS
    
    /* convert digest type to cryptodev */
    static int
    digest_nid_to_cryptodev(int nid)
    {
    	int i;
    
    	for (i = 0; digests[i].id; i++)
    		if (digests[i].nid == nid)
    			return (digests[i].id);
    	return (0);
    }
    
    
    static int
    digest_key_length(int nid)
    {
    	int i;
    
    	for (i = 0; digests[i].id; i++)
    		if (digests[i].nid == nid)
    			return digests[i].keylen;
    	return (0);
    }
    
    
    static int cryptodev_digest_init(EVP_MD_CTX *ctx)
    {
    	struct dev_crypto_state *state = ctx->md_data;
    	struct session_op *sess = &state->d_sess;
    	int digest;
    
    	if ((digest = digest_nid_to_cryptodev(ctx->digest->type)) == NID_undef){
    		printf("cryptodev_digest_init: Can't get digest \n");
    		return (0);
    	}
    
    	memset(state, 0, sizeof(struct dev_crypto_state));
    
    	if ((state->d_fd = get_dev_crypto()) < 0) {
    		printf("cryptodev_digest_init: Can't get Dev \n");
    		return (0);
    	}
    
    	sess->mackey = state->dummy_mac_key;
    	sess->mackeylen = digest_key_length(ctx->digest->type);
    	sess->mac = digest;
    
    	if (ioctl(state->d_fd, CIOCGSESSION, sess) < 0) {
    		put_dev_crypto(state->d_fd);
    		state->d_fd = -1;
    		printf("cryptodev_digest_init: Open session failed\n");
    		return (0);
    	}
    
    	return (1);
    }
    
    static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
    		size_t count)
    {
    	struct crypt_op cryp;
    	struct dev_crypto_state *state = ctx->md_data;
    	struct session_op *sess = &state->d_sess;
    
    	if (!data || state->d_fd < 0) {
    		printf("cryptodev_digest_update: illegal inputs \n");
    		return (0);
    	}
    
    	if (!count) {
    		return (0);
    	}
    
    #ifndef OPENSSL_CRYPTODEF_HASH_NO_ONESHOT
    	if (!(ctx->flags & EVP_MD_CTX_FLAG_ONESHOT)) {
    		/* if application doesn't support one buffer */
    		state->mac_data = OPENSSL_realloc(state->mac_data, state->mac_len + count);
    
    		if (!state->mac_data) {
    			printf("cryptodev_digest_update: realloc failed\n");
    			return (0);
    		}
    
    		memcpy(state->mac_data + state->mac_len, data, count);
       		state->mac_len += count;
    	
    		return (1);
    	}
    #endif
    
    	memset(&cryp, 0, sizeof(cryp));
    
    	cryp.ses = sess->ses;
    	cryp.flags = 0;
    	cryp.len = count;
    	cryp.src = (caddr_t) data;
    	cryp.dst = NULL;
    	cryp.mac = (caddr_t) state->digest_res;
    	if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
    		printf("cryptodev_digest_update: digest failed\n");
    		return (0);
    	}
    	return (1);
    }
    
    
    static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
    {
    	struct crypt_op cryp;
    	struct dev_crypto_state *state = ctx->md_data;
    	struct session_op *sess = &state->d_sess;
    
    	int ret = 1;
    
    	if (!md || state->d_fd < 0) {
    		printf("cryptodev_digest_final: illegal input\n");
    		return(0);
    	}
    
    #ifndef OPENSSL_CRYPTODEF_HASH_NO_ONESHOT
    	if (! (ctx->flags & EVP_MD_CTX_FLAG_ONESHOT) ) {
    		/* if application doesn't support one buffer */
    		memset(&cryp, 0, sizeof(cryp));
    		cryp.ses = sess->ses;
    		cryp.flags = 0;
    		cryp.len = state->mac_len;
    		cryp.src = state->mac_data;
    		cryp.dst = NULL;
    		cryp.mac = (caddr_t)md;
    		if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
    			printf("cryptodev_digest_final: digest failed\n");
    			return (0);
    		}
    
    		return 1;
    	}
    #endif
    
    	memcpy(md, state->digest_res, ctx->digest->md_size);
    
    	return (ret);
    }
    
    
    static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
    {
    	int ret = 1;
    	struct dev_crypto_state *state = ctx->md_data;
    	struct session_op *sess = &state->d_sess;
    
    	if (state == NULL)
    	  return 0;
    
    	if (state->d_fd < 0) {
    		printf("cryptodev_digest_cleanup: illegal input\n");
    		return (0);
    	}
    
    	if (state->mac_data) {
    		OPENSSL_free(state->mac_data);
    		state->mac_data = NULL;
    		state->mac_len = 0;
    	}
    
    	if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
    		printf("cryptodev_digest_cleanup: failed to close session\n");
    		ret = 0;
    	} else {
    		ret = 1;
    	}
    	put_dev_crypto(state->d_fd);	
    	state->d_fd = -1;
    
    	return (ret);
    }
    
    static int cryptodev_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
    {
    	struct dev_crypto_state *fstate = from->md_data;
    	struct dev_crypto_state *dstate = to->md_data;
    	struct session_op *sess;
    	int digest;
    
    	if (dstate == NULL || fstate == NULL)
    	  return 1;
    
           	memcpy(dstate, fstate, sizeof(struct dev_crypto_state));
    
    	sess = &dstate->d_sess;
    
    	digest = digest_nid_to_cryptodev(to->digest->type);
    
    	sess->mackey = dstate->dummy_mac_key;
    	sess->mackeylen = digest_key_length(to->digest->type);
    	sess->mac = digest;
    
    	dstate->d_fd = get_dev_crypto();
    
    	if (ioctl(dstate->d_fd, CIOCGSESSION, sess) < 0) {
    		put_dev_crypto(dstate->d_fd);
    		dstate->d_fd = -1;
    		printf("cryptodev_digest_init: Open session failed\n");
    		return (0);
    	}
    
    	if (fstate->mac_len != 0) {
    	        if (fstate->mac_data != NULL)
    	                {
            		dstate->mac_data = OPENSSL_malloc(fstate->mac_len);
    	        	memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len);
               		dstate->mac_len = fstate->mac_len;
    	        	}
    	}
    
    	return 1;
    }
    
    
    const EVP_MD cryptodev_sha1 = {
    	NID_sha1,
    	NID_undef, 
    	SHA_DIGEST_LENGTH, 
    	EVP_MD_FLAG_ONESHOT,
    	cryptodev_digest_init,
    	cryptodev_digest_update,
    	cryptodev_digest_final,
    	cryptodev_digest_copy,
    	cryptodev_digest_cleanup,
    	EVP_PKEY_NULL_method,
    	SHA_CBLOCK,
    	sizeof(struct dev_crypto_state),
    };
    
    const EVP_MD cryptodev_md5 = {
    	NID_md5,
    	NID_undef, 
    	16 /* MD5_DIGEST_LENGTH */, 
    	EVP_MD_FLAG_ONESHOT,
    	cryptodev_digest_init,
    	cryptodev_digest_update,
    	cryptodev_digest_final,
    	cryptodev_digest_copy,
    	cryptodev_digest_cleanup,
    	EVP_PKEY_NULL_method,
    	64 /* MD5_CBLOCK */,
    	sizeof(struct dev_crypto_state),
    };
    
    #endif /* USE_CRYPTODEV_DIGESTS */
    
    
    static int
    cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
        const int **nids, int nid)
    {
    	if (!digest)
    		return (cryptodev_usable_digests(nids));
    
    	switch (nid) {
    #ifdef USE_CRYPTODEV_DIGESTS
    	case NID_md5:
    		*digest = &cryptodev_md5; 
    		break;
    	case NID_sha1:
    		*digest = &cryptodev_sha1;
     		break;
    	default:
    #endif /* USE_CRYPTODEV_DIGESTS */
    		*digest = NULL;
    		break;
    	}
    	return (*digest != NULL);
    }
    
    /*
     * Convert a BIGNUM to the representation that /dev/crypto needs.
     * Upon completion of use, the caller is responsible for freeing
     * crp->crp_p.
     */
    static int
    bn2crparam(const BIGNUM *a, struct crparam *crp)
    {
    	int i, j, k;
    	ssize_t bytes, bits;
    	u_char *b;
    
    	crp->crp_p = NULL;
    	crp->crp_nbits = 0;
    
    	bits = BN_num_bits(a);
    	bytes = (bits + 7) / 8;
    
    	b = malloc(bytes);
    	if (b == NULL)
    		return (1);
    	memset(b, 0, bytes);
    
    	crp->crp_p = (caddr_t) b;
    	crp->crp_nbits = bits;
    
    	for (i = 0, j = 0; i < a->top; i++) {
    		for (k = 0; k < BN_BITS2 / 8; k++) {
    			if ((j + k) >= bytes)
    				return (0);
    			b[j + k] = a->d[i] >> (k * 8);
    		}
    		j += BN_BITS2 / 8;
    	}
    	return (0);
    }
    
    /* Convert a /dev/crypto parameter to a BIGNUM */
    static int
    crparam2bn(struct crparam *crp, BIGNUM *a)
    {
    	u_int8_t *pd;
    	int i, bytes;
    
    	bytes = (crp->crp_nbits + 7) / 8;
    
    	if (bytes == 0)
    		return (-1);
    
    	if ((pd = (u_int8_t *) malloc(bytes)) == NULL)
    		return (-1);
    
    	for (i = 0; i < bytes; i++)
    		pd[i] = crp->crp_p[bytes - i - 1];
    
    	BN_bin2bn(pd, bytes, a);
    	free(pd);
    
    	return (0);
    }
    
    static void
    zapparams(struct crypt_kop *kop)
    {
    	int i;
    
    	for (i = 0; i < kop->crk_iparams + kop->crk_oparams; i++) {
    		if (kop->crk_param[i].crp_p)
    			free(kop->crk_param[i].crp_p);
    		kop->crk_param[i].crp_p = NULL;
    		kop->crk_param[i].crp_nbits = 0;
    	}
    }
    
    static int
    cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r, int slen, BIGNUM *s)
    {
    	int fd, ret = -1;
    
    	if ((fd = get_asym_dev_crypto()) < 0)
    		return (ret);
    
    	if (r) {
    		kop->crk_param[kop->crk_iparams].crp_p = calloc(rlen, sizeof(char));
    		kop->crk_param[kop->crk_iparams].crp_nbits = rlen * 8;
    		kop->crk_oparams++;
    	}
    	if (s) {
    		kop->crk_param[kop->crk_iparams+1].crp_p = calloc(slen, sizeof(char));
    		kop->crk_param[kop->crk_iparams+1].crp_nbits = slen * 8;
    		kop->crk_oparams++;
    	}
    
    	if (ioctl(fd, CIOCKEY, kop) == 0) {
    		if (r)
    			crparam2bn(&kop->crk_param[kop->crk_iparams], r);
    		if (s)
    			crparam2bn(&kop->crk_param[kop->crk_iparams+1], s);
    		ret = 0;
    	}
    
    	return (ret);
    }
    
    static int
    cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
        const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
    {
    	struct crypt_kop kop;
    	int ret = 1;
    
    	/* Currently, we know we can do mod exp iff we can do any
    	 * asymmetric operations at all.
    	 */
    	if (cryptodev_asymfeat == 0) {
    		ret = BN_mod_exp(r, a, p, m, ctx);
    		return (ret);
    	}
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_MOD_EXP;
    
    	/* inputs: a^p % m */
    	if (bn2crparam(a, &kop.crk_param[0]))
    		goto err;
    	if (bn2crparam(p, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(m, &kop.crk_param[2]))
    		goto err;
    	kop.crk_iparams = 3;
    
    	if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL)) {
    		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    		printf("OCF asym process failed, Running in software\n");
    		ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
    
    	} else if (ECANCELED == kop.crk_status) {
    		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    		printf("OCF hardware operation cancelled. Running in Software\n");
    		ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
    	}
    	/* else cryptodev operation worked ok ==> ret = 1*/
    
    err:
    	zapparams(&kop);
    	return (ret);
    }
    
    static int
    cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
    {
    	int r;
    	ctx = BN_CTX_new();
    	r = cryptodev_bn_mod_exp(r0, I, rsa->d, rsa->n, ctx, NULL);
    	BN_CTX_free(ctx);
    	return (r);
    }
    
    static int
    cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
    {
    	struct crypt_kop kop;
    	int ret = 1;
    
    	if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) {
    		/* XXX 0 means failure?? */
    		return (0);
    	}
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_MOD_EXP_CRT;
    	/* inputs: rsa->p rsa->q I rsa->dmp1 rsa->dmq1 rsa->iqmp */
    	if (bn2crparam(rsa->p, &kop.crk_param[0]))
    		goto err;
    	if (bn2crparam(rsa->q, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(I, &kop.crk_param[2]))
    		goto err;
    	if (bn2crparam(rsa->dmp1, &kop.crk_param[3]))
    		goto err;
    	if (bn2crparam(rsa->dmq1, &kop.crk_param[4]))
    		goto err;
    	if (bn2crparam(rsa->iqmp, &kop.crk_param[5]))
    		goto err;
    	kop.crk_iparams = 6;
    
    	if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL)) {
    		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    		printf("OCF asym process failed, running in Software\n");
    		ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
    
    	} else if (ECANCELED == kop.crk_status) {
    		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    		printf("OCF hardware operation cancelled. Running in Software\n");
    		ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
    	}
    	/* else cryptodev operation worked ok ==> ret = 1*/
    
    err:
    	zapparams(&kop);
    	return (ret);
    }
    
    static RSA_METHOD cryptodev_rsa = {
    	"cryptodev RSA method",
    	NULL,				/* rsa_pub_enc */
    	NULL,				/* rsa_pub_dec */
    	NULL,				/* rsa_priv_enc */
    	NULL,				/* rsa_priv_dec */
    	NULL,
    	NULL,
    	NULL,				/* init */
    	NULL,				/* finish */
    	0,				/* flags */
    	NULL,				/* app_data */
    	NULL,				/* rsa_sign */
    	NULL				/* rsa_verify */
    };
    
    static int
    cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
        const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
    {
    	return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
    }
    
    static int
    cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
        BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
        BN_CTX *ctx, BN_MONT_CTX *mont)
    {
    	BIGNUM t2;
    	int ret = 0;
    
    	BN_init(&t2);
    
    	/* v = ( g^u1 * y^u2 mod p ) mod q */
    	/* let t1 = g ^ u1 mod p */
    	ret = 0;
    
    	if (!dsa->meth->bn_mod_exp(dsa,t1,dsa->g,u1,dsa->p,ctx,mont))
    		goto err;
    
    	/* let t2 = y ^ u2 mod p */
    	if (!dsa->meth->bn_mod_exp(dsa,&t2,dsa->pub_key,u2,dsa->p,ctx,mont))
    		goto err;
    	/* let u1 = t1 * t2 mod p */
    	if (!BN_mod_mul(u1,t1,&t2,dsa->p,ctx))
    		goto err;
    
    	BN_copy(t1,u1);
    
    	ret = 1;
    err:
    	BN_free(&t2);
    	return(ret);
    }
    
    static DSA_SIG *
    cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
    {
    	struct crypt_kop kop;
    	BIGNUM *r = NULL, *s = NULL;
    	DSA_SIG *dsaret = NULL;
    
    	if ((r = BN_new()) == NULL)
    		goto err;
    	if ((s = BN_new()) == NULL) {
    		BN_free(r);
    		goto err;
    	}
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_DSA_SIGN;
    
    	/* inputs: dgst dsa->p dsa->q dsa->g dsa->priv_key */
    	kop.crk_param[0].crp_p = (caddr_t)dgst;
    	kop.crk_param[0].crp_nbits = dlen * 8;
    	if (bn2crparam(dsa->p, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(dsa->q, &kop.crk_param[2]))
    		goto err;
    	if (bn2crparam(dsa->g, &kop.crk_param[3]))
    		goto err;
    	if (bn2crparam(dsa->priv_key, &kop.crk_param[4]))
    		goto err;
    	kop.crk_iparams = 5;
    
    	if (cryptodev_asym(&kop, BN_num_bytes(dsa->q), r,
    	    BN_num_bytes(dsa->q), s) == 0) {
    		dsaret = DSA_SIG_new();
    		dsaret->r = r;
    		dsaret->s = s;
    	} else {
    		const DSA_METHOD *meth = DSA_OpenSSL();
    		BN_free(r);
    		BN_free(s);
    		dsaret = (meth->dsa_do_sign)(dgst, dlen, dsa);
    	}
    err:
    	kop.crk_param[0].crp_p = NULL;
    	zapparams(&kop);
    	return (dsaret);
    }
    
    static int
    cryptodev_dsa_verify(const unsigned char *dgst, int dlen,
        DSA_SIG *sig, DSA *dsa)
    {
    	struct crypt_kop kop;
    	int dsaret = 1;
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_DSA_VERIFY;
    
    	/* inputs: dgst dsa->p dsa->q dsa->g dsa->pub_key sig->r sig->s */
    	kop.crk_param[0].crp_p = (caddr_t)dgst;
    	kop.crk_param[0].crp_nbits = dlen * 8;
    	if (bn2crparam(dsa->p, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(dsa->q, &kop.crk_param[2]))
    		goto err;
    	if (bn2crparam(dsa->g, &kop.crk_param[3]))
    		goto err;
    	if (bn2crparam(dsa->pub_key, &kop.crk_param[4]))
    		goto err;
    	if (bn2crparam(sig->r, &kop.crk_param[5]))
    		goto err;
    	if (bn2crparam(sig->s, &kop.crk_param[6]))
    		goto err;
    	kop.crk_iparams = 7;
    
    	if (cryptodev_asym(&kop, 0, NULL, 0, NULL) == 0) {
    /*OCF success value is 0, if not zero, change dsaret to fail*/
    		if(0 != kop.crk_status) dsaret  = 0;
    	} else {
    		const DSA_METHOD *meth = DSA_OpenSSL();
    
    		dsaret = (meth->dsa_do_verify)(dgst, dlen, sig, dsa);
    	}
    err:
    	kop.crk_param[0].crp_p = NULL;
    	zapparams(&kop);
    	return (dsaret);
    }
    
    static DSA_METHOD cryptodev_dsa = {
    	"cryptodev DSA method",
    	NULL,
    	NULL,				/* dsa_sign_setup */
    	NULL,
    	NULL,				/* dsa_mod_exp */
    	NULL,
    	NULL,				/* init */
    	NULL,				/* finish */
    	0,	/* flags */
    	NULL	/* app_data */
    };
    
    static int
    cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
        const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
        BN_MONT_CTX *m_ctx)
    {
    	return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
    }
    
    static int
    cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
    {
    	struct crypt_kop kop;
    	int dhret = 1;
    	int fd, keylen;
    
    	if ((fd = get_asym_dev_crypto()) < 0) {
    		const DH_METHOD *meth = DH_OpenSSL();
    
    		return ((meth->compute_key)(key, pub_key, dh));
    	}
    
    	keylen = BN_num_bits(dh->p);
    
    	memset(&kop, 0, sizeof kop);
    	kop.crk_op = CRK_DH_COMPUTE_KEY;
    
    	/* inputs: dh->priv_key pub_key dh->p key */
    	if (bn2crparam(dh->priv_key, &kop.crk_param[0]))
    		goto err;
    	if (bn2crparam(pub_key, &kop.crk_param[1]))
    		goto err;
    	if (bn2crparam(dh->p, &kop.crk_param[2]))
    		goto err;
    	kop.crk_iparams = 3;
    
    	kop.crk_param[3].crp_p = (caddr_t) key;
    	kop.crk_param[3].crp_nbits = keylen * 8;
    	kop.crk_oparams = 1;
    
    	if (ioctl(fd, CIOCKEY, &kop) == -1) {
    		const DH_METHOD *meth = DH_OpenSSL();
    
    		dhret = (meth->compute_key)(key, pub_key, dh);
    	}
    err:
    	kop.crk_param[3].crp_p = NULL;
    	zapparams(&kop);
    	return (dhret);
    }
    
    static DH_METHOD cryptodev_dh = {
    	"cryptodev DH method",
    	NULL,				/* cryptodev_dh_generate_key */
    	NULL,
    	NULL,
    	NULL,
    	NULL,
    	0,	/* flags */
    	NULL	/* app_data */
    };
    
    /*
     * ctrl right now is just a wrapper that doesn't do much
     * but I expect we'll want some options soon.
     */
    static int
    cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
    {
    #ifdef HAVE_SYSLOG_R
    	struct syslog_data sd = SYSLOG_DATA_INIT;
    #endif
    
    	switch (cmd) {
    	default:
    #ifdef HAVE_SYSLOG_R
    		syslog_r(LOG_ERR, &sd,
    		    "cryptodev_ctrl: unknown command %d", cmd);
    #else
    		syslog(LOG_ERR, "cryptodev_ctrl: unknown command %d", cmd);
    #endif
    		break;
    	}
    	return (1);
    }
    
    void
    ENGINE_load_cryptodev(void)
    {
    	ENGINE *engine = ENGINE_new();
    	int fd;
    
    	if (engine == NULL)
    		return;
    	if ((fd = get_dev_crypto()) < 0) {
    		ENGINE_free(engine);
    		return;
    	}
    
    	/*
    	 * find out what asymmetric crypto algorithms we support
    	 */
    	if (ioctl(fd, CIOCASYMFEAT, &cryptodev_asymfeat) == -1) {
    		put_dev_crypto(fd);
    		ENGINE_free(engine);
    		return;
    	}
    	put_dev_crypto(fd);
    
    	if (!ENGINE_set_id(engine, "cryptodev") ||
    	    !ENGINE_set_name(engine, "BSD cryptodev engine") ||
    	    !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
    	    !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
    	    !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
    	    !ENGINE_set_cmd_defns(engine, cryptodev_defns)) {
    		ENGINE_free(engine);
    		return;
    	}
    
    	if (ENGINE_set_RSA(engine, &cryptodev_rsa)) {
    		const RSA_METHOD *rsa_meth = RSA_PKCS1_SSLeay();
    
    		cryptodev_rsa.bn_mod_exp = rsa_meth->bn_mod_exp;
    		cryptodev_rsa.rsa_mod_exp = rsa_meth->rsa_mod_exp;
    		cryptodev_rsa.rsa_pub_enc = rsa_meth->rsa_pub_enc;
    		cryptodev_rsa.rsa_pub_dec = rsa_meth->rsa_pub_dec;
    		cryptodev_rsa.rsa_priv_enc = rsa_meth->rsa_priv_enc;
    		cryptodev_rsa.rsa_priv_dec = rsa_meth->rsa_priv_dec;
    		if (cryptodev_asymfeat & CRF_MOD_EXP) {
    			cryptodev_rsa.bn_mod_exp = cryptodev_bn_mod_exp;
    			if (cryptodev_asymfeat & CRF_MOD_EXP_CRT)
    				cryptodev_rsa.rsa_mod_exp =
    				    cryptodev_rsa_mod_exp;
    			else
    				cryptodev_rsa.rsa_mod_exp =
    				    cryptodev_rsa_nocrt_mod_exp;
    		}
    	}
    
    	if (ENGINE_set_DSA(engine, &cryptodev_dsa)) {
    		const DSA_METHOD *meth = DSA_OpenSSL();
    
    		memcpy(&cryptodev_dsa, meth, sizeof(DSA_METHOD));
    		if (cryptodev_asymfeat & CRF_DSA_SIGN)
    			cryptodev_dsa.dsa_do_sign = cryptodev_dsa_do_sign;
    		if (cryptodev_asymfeat & CRF_MOD_EXP) {
    			cryptodev_dsa.bn_mod_exp = cryptodev_dsa_bn_mod_exp;
    			cryptodev_dsa.dsa_mod_exp = cryptodev_dsa_dsa_mod_exp;
    		}
    		if (cryptodev_asymfeat & CRF_DSA_VERIFY)
    			cryptodev_dsa.dsa_do_verify = cryptodev_dsa_verify;
    	}
    
    	if (ENGINE_set_DH(engine, &cryptodev_dh)){
    		const DH_METHOD *dh_meth = DH_OpenSSL();
    
    		cryptodev_dh.generate_key = dh_meth->generate_key;
    		cryptodev_dh.compute_key = dh_meth->compute_key;
    		cryptodev_dh.bn_mod_exp = dh_meth->bn_mod_exp;
    		if (cryptodev_asymfeat & CRF_MOD_EXP) {
    			cryptodev_dh.bn_mod_exp = cryptodev_mod_exp_dh;
    			if (cryptodev_asymfeat & CRF_DH_COMPUTE_KEY)
    				cryptodev_dh.compute_key =
    				    cryptodev_dh_compute_key;
    		}
    	}
    
    	ENGINE_add(engine);
    	ENGINE_free(engine);
    	ERR_clear_error();
    }
    
    #endif /* HAVE_CRYPTODEV */
    

    http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/791/3566.Makefile

    You can find my Makefile and eng_cryptodev.c files attached above.

    Here are my exported environment settings:

    export CROSS_COMPILE=arm-linux-gnueabihf-
    export ARCH=arm
    export PATH=$PATH:$HOME/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin

    Best regards,
    Miroslav

  • Thank you for your support.

    I will look to do the make command by using your documents tomorrow.

    If I met any trouble, please give me your advice again.

    Best regards.

    Kaka 

  • I looked to do the make command with using your documents which you attached to your previous Post.

    Just in case, I attached the error log as below.

    ***********************************************

    arm-linux-gnueabihf-gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi -c -o gcm128.o gcm128.c
    gcm128.c: In function ‘CRYPTO_gcm128_encrypt’:
    gcm128.c:1069:1: internal compiler error: in push_minipool_fix, at config/arm/arm.c:13375
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <https://bugs.launchpad.net/gcc-linaro> for instructions.
    make[2]: *** [gcm128.o] Error 1
    make[2]: Leaving directory `/home/kato/OPENSSL/openssl-1.0.1g/crypto/modes'
    make[1]: *** [subdirs] Error 1
    make[1]: Leaving directory `/home/kato/OPENSSL/openssl-1.0.1g/crypto'
    make: *** [build_crypto] Error 1

    **************************************

    What should we check my environment? I summarized my and environment and setup as below.

    [Environment]
    Ubuntu: 12.04
    SDK: 6.0.0.0

    [Setup]
    1. Download and extract openssl-1.0.1g and move openssl folder
    ************************
    # wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
    # tar -xzf openssl-1.0.1g
    # cd openssl-1.0.1g
    ************************

    2. Edit the Makefile as shown in the guide from the link above, replacing arm-arago-linux-gnueabi- with arm-linux-gnueabihf-
    **************************************************
    INSTALL_PREFIX=/home/kato/ti-sdk-am335x-evm-06.00.00.00/targetNFS
    CFLAG= -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS
    CC= arm-linux-gnueabihf-gcc
    AR= arm-linux-gnueabihf-ar $(ARFLAGS) r
    RANLIB= arm-linux-gnueabihf-ranlib
    NM= arm-linux-gnueabihf-nm
    **************************************************

    3. Manually add the changes from the patch to the openssl-1.0.1g/crypto/engine/eng_cryptodev.c file.
    *Or used your edited file.
    4. make clean and make command
    ************************
    # make clean
    # make
    ************************

    Let me know if you have further question.

    Best regards.

    Kaka

  • Kato,

    The steps you follow are correct, but from your error log I see that you have additional compiler flags that are missing in my log.

    Can you please post your environment here? To print the environment, type "export" in the Terminal.

    Best regards,
    Miroslav

  • Hi Miroslv,

    I attached my environment by using "export" command as below.

    Would you please check this?

    declare -x AR="arm-linux-gnueabihf-ar"
    declare -x AS="arm-linux-gnueabihf-as"
    declare -x CC="arm-linux-gnueabihf-gcc"
    declare -x CFLAGS=" -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x COLORTERM="gnome-terminal"
    declare -x COMPIZ_CONFIG_PROFILE="ubuntu"
    declare -x CONFIGURE_FLAGS="--target=armv7ahf-vfp-neon-3.2-oe-linux-gnueabi --host=armv7ahf-vfp-neon-3.2-oe-linux-gnueabi --build=i686-linux --with-libtool-sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x CONFIG_SITE="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/site-config-armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x CPATH="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi/usr/include:"
    declare -x CPP="arm-linux-gnueabihf-gcc -E"
    declare -x CPPFLAGS=" -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x CXX="arm-linux-gnueabihf-g++"
    declare -x CXXFLAGS=" -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-35FGXOwnGt,guid=9d15cc019d6986729576592800000008"
    declare -x DEFAULTS_PATH="/usr/share/gconf/ubuntu.default.path"
    declare -x DESKTOP_SESSION="ubuntu"
    declare -x DISPLAY=":0"
    declare -x GDB="arm-linux-gnueabihf-gdb"
    declare -x GDMSESSION="ubuntu"
    declare -x GNOME_DESKTOP_SESSION_ID="this-is-deprecated"
    declare -x GNOME_KEYRING_CONTROL="/tmp/keyring-UM91O3"
    declare -x GPG_AGENT_INFO="/tmp/keyring-UM91O3/gpg:0:1"
    declare -x HOME="/home/kato"
    declare -x LANG="en_US.UTF-8"
    declare -x LDFLAGS=" --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x LOGNAME="kato"
    declare -x MANDATORY_PATH="/usr/share/gconf/ubuntu.mandatory.path"
    declare -x NM="arm-linux-gnueabihf-nm"
    declare -x NO_PROXY="localhost,127.0.0.0/8"
    declare -x OBJCOPY="arm-linux-gnueabihf-objcopy"
    declare -x OBJDUMP="arm-linux-gnueabihf-objdump"
    declare -x OECORE_ACLOCAL_OPTS="-I /home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/share/aclocal"
    declare -x OECORE_DISTRO_VERSION="2013.05"
    declare -x OECORE_NATIVE_SYSROOT="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux"
    declare -x OECORE_SDK_VERSION="2013.05"
    declare -x OECORE_TARGET_SYSROOT="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x OE_QMAKE_AR="arm-linux-gnueabihf-ar"
    declare -x OE_QMAKE_CC="arm-linux-gnueabihf-gcc"
    declare -x OE_QMAKE_CFLAGS=" -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x OE_QMAKE_CXX="arm-linux-gnueabihf-g++"
    declare -x OE_QMAKE_CXXFLAGS=" -march=armv7-a    -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x OE_QMAKE_INCDIR_QT="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi/usr/include/qtopia"
    declare -x OE_QMAKE_LDFLAGS=" --sysroot=/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x OE_QMAKE_LIBDIR_QT="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi/usr/lib"
    declare -x OE_QMAKE_LINK="arm-linux-gnueabihf-g++"
    declare -x OE_QMAKE_MOC="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/moc4"
    declare -x OE_QMAKE_QDBUSCPP2XML="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/qdbuscpp2xml4"
    declare -x OE_QMAKE_QDBUSXML2CPP="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/qdbusxml2cpp4"
    declare -x OE_QMAKE_QT_CONFIG="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi/usr/share/qtopia/mkspecs/qconfig.pri"
    declare -x OE_QMAKE_RCC="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/rcc4"
    declare -x OE_QMAKE_STRIP="echo"
    declare -x OE_QMAKE_UIC="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/uic4"
    declare -x OE_QMAKE_UIC3="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/uic34"
    declare -x OLDPWD="/home/kato/test"
    declare -x PATH="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
    declare -x PKG_CONFIG_ALLOW_SYSTEM_LIBS="1"
    declare -x PKG_CONFIG_PATH="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi/usr/lib/pkgconfig"
    declare -x PKG_CONFIG_SYSROOT_DIR="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x PS1="\\[\\e[32;1m\\][linux-devkit]\\[\\e[0m\\]:\\w> "
    declare -x PWD="/home/kato/test/openssl-1.0.1g"
    declare -x QMAKESPEC="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi/usr/share/qtopia/mkspecs/linux-g++"
    declare -x RANLIB="arm-linux-gnueabihf-ranlib"
    declare -x SDK_PATH="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit"
    declare -x SDK_PATH_NATIVE="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux"
    declare -x SDK_PATH_TARGET="/home/kato/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x SDK_SYS="i686-arago-linux"
    declare -x SESSION_MANAGER="local/kato-virtual-machine:@/tmp/.ICE-unix/1958,unix/kato-virtual-machine:/tmp/.ICE-unix/1958"
    declare -x SHELL="/bin/bash"
    declare -x SHLVL="1"
    declare -x SSH_AGENT_PID="2015"
    declare -x SSH_AUTH_SOCK="/tmp/keyring-UM91O3/ssh"
    declare -x STRIP="arm-linux-gnueabihf-strip"
    declare -x TARGET_SYS="armv7ahf-vfp-neon-3.2-oe-linux-gnueabi"
    declare -x TERM="xterm"
    declare -x TOOLCHAIN_PREFIX="arm-linux-gnueabihf-"
    declare -x TOOLCHAIN_SYS="arm-linux-gnueabihf"
    declare -x UBUNTU_MENUPROXY="libappmenu.so"
    declare -x USER="kato"
    declare -x WINDOWID="62914566"
    declare -x XAUTHORITY="/home/kato/.Xauthority"
    declare -x XDG_CONFIG_DIRS="/etc/xdg/xdg-ubuntu:/etc/xdg"
    declare -x XDG_CURRENT_DESKTOP="Unity"
    declare -x XDG_DATA_DIRS="/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/"
    declare -x XDG_SEAT_PATH="/org/freedesktop/DisplayManager/Seat0"
    declare -x XDG_SESSION_COOKIE="5415661a9b8cc245e6572dfa00000002-1400137127.279644-912409742"
    declare -x XDG_SESSION_PATH="/org/freedesktop/DisplayManager/Session0"

    Let me know if you have further question.

    Best regards.

    Kaka

  • Unset your CFLAGS variable before you build openssl:

    unset CFLAGS

    Best regards,
    Miroslav

  • Hi Miroslav,

    Thank you for your advices.

    I could do the make command by removing the following setep.

    ******************************
    user@usergt-laptop:~/OpenSSL/openssl-1.0.0d$
    user@usergt-laptop:~/OpenSSL/openssl-1.0.0d$ source ~/ti-sdk-am37x-evm-05.04.00.00/linux-devkit/environment-setup [linux-devkit]:~/OpenSSL/openssl-1.0.0d>
    ******************************

    I had do the above steps before building openssl. When I could compile this project , I have done the following command instead of using the above command.


    ******************************
    export CROSS_COMPILE=arm-linux-gnueabihf-
    export ARCH=arm
    export PATH=$PATH:$HOME/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin
    ******************************

    Again, thank you very much for your help

    Best regards.

    Kaka

  • Hi,



    I am also having similar problem .

    is it solved?

    Please find part of my log  as follows.

    arm-linux-gnueabihf-gcc -DMONOLITH -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/cortexa8hf-vfp-neon-3.8-oe-linux-gnueabi  -c -o rand.o rand.c
    arm-linux-gnueabihf-gcc -DMONOLITH -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/cortexa8hf-vfp-neon-3.8-oe-linux-gnueabi  -c -o engine.o engine.c
    arm-linux-gnueabihf-gcc -DMONOLITH -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/cortexa8hf-vfp-neon-3.8-oe-linux-gnueabi  -c -o ocsp.o ocsp.c
    arm-linux-gnueabihf-gcc -DMONOLITH -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/cortexa8hf-vfp-neon-3.8-oe-linux-gnueabi  -c -o prime.o prime.c
    arm-linux-gnueabihf-gcc -DMONOLITH -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/cortexa8hf-vfp-neon-3.8-oe-linux-gnueabi  -c -o ts.o ts.c
    arm-linux-gnueabihf-gcc -DMONOLITH -I.. -I../include  -O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS  -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/cortexa8hf-vfp-neon-3.8-oe-linux-gnueabi  -c -o openssl.o openssl.c
    rm -f openssl
    shlib_target=; if [ -n "" ]; then \
                    shlib_target=""; \
            fi; \
            LIBRARIES="-L.. -lssl  -L.. -lcrypto" ; \
            make -f ../Makefile.shared -e \
                    APPNAME=openssl OBJECTS="openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o" \
                    LIBDEPS=" $LIBRARIES " \
                    link_app.${shlib_target}
    make[2]: Entering directory `/home/TISDKutils/openssl-1.0.0d/apps'
    ( :; LIBDEPS="${LIBDEPS:--L.. -lssl  -L.. -lcrypto }"; LDCMD="${LDCMD:-arm-linux-gnueabihf-gcc}"; LDFLAGS="${LDFLAGS:--O -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS}"; LIBPATH=`for x in $LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o ${LIBDEPS} )
    /opt/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find crt1.o: No such file or directory
    /opt/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find crti.o: No such file or directory
    collect2: error: ld returned 1 exit status
    make[2]: *** [link_app.] Error 1
    make[2]: Leaving directory `/home/TISDKutils/openssl-1.0.0d/apps'
    make[1]: *** [openssl] Error 2
    make[1]: Leaving directory `/home/TISDKutils/openssl-1.0.0d/apps'
    make: *** [build_apps] Error 1
    root@Server openssl-1.0.0d]#


    Please let me know if anyone got a solution for this .

    Thanks and regards

    Gokul CG[gokul.g@kalkitech.in]